ItEr43S20CUAsignarUsuarioAProxectoPlanificacionItEr12S09 : adds some fields to the Order entity.
This commit is contained in:
parent
90ddbe4c50
commit
34eba78d2c
14 changed files with 443 additions and 26 deletions
|
|
@ -122,4 +122,16 @@ public class ExternalCompanyDAO extends GenericDAOHibernate<ExternalCompany, Lon
|
|||
return c.list();
|
||||
}
|
||||
|
||||
public List<ExternalCompany> getAll() {
|
||||
return list(ExternalCompany.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExternalCompany> getExternalCompaniesAreClient() {
|
||||
Criteria c = getSession().createCriteria(ExternalCompany.class);
|
||||
c.add(Restrictions.eq("client", true));
|
||||
|
||||
return c.list();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,4 +53,7 @@ public interface IExternalCompanyDAO extends IGenericDAO<ExternalCompany, Long>
|
|||
|
||||
List<ExternalCompany> findSubcontractor();
|
||||
|
||||
List<ExternalCompany> getAll();
|
||||
|
||||
List<ExternalCompany> getExternalCompaniesAreClient();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
package org.navalplanner.business.orders.entities;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
|
@ -28,6 +29,7 @@ import java.util.Set;
|
|||
import org.hibernate.validator.AssertTrue;
|
||||
import org.hibernate.validator.NotNull;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.navalplanner.business.planner.entities.DayAssignment;
|
||||
import org.navalplanner.business.planner.entities.Task;
|
||||
import org.navalplanner.business.planner.entities.TaskElement;
|
||||
|
|
@ -45,6 +47,11 @@ public class Order extends OrderLineGroup {
|
|||
Order order = new Order();
|
||||
order.setNewObject(true);
|
||||
|
||||
order.setWorkBudget(new BigDecimal(0).setScale(2));
|
||||
order.setMaterialsBudget(new BigDecimal(0).setScale(2));
|
||||
order.setTotalBudget(new BigDecimal(0).setScale(2));
|
||||
order.setTotalHours(new Integer(0));
|
||||
order.setState(OrderStatusEnum.getDefault());
|
||||
OrderLineGroup.setupOrderLineGroup(order);
|
||||
|
||||
return order;
|
||||
|
|
@ -60,7 +67,6 @@ public class Order extends OrderLineGroup {
|
|||
private String responsible;
|
||||
|
||||
// TODO turn into a many to one relationship when Customer entity is defined
|
||||
private String customer;
|
||||
|
||||
private Boolean dependenciesConstraintsHavePriority;
|
||||
|
||||
|
|
@ -71,6 +77,86 @@ public class Order extends OrderLineGroup {
|
|||
|
||||
private Integer lastOrderElementSequenceCode = 0;
|
||||
|
||||
private BigDecimal workBudget;
|
||||
|
||||
private BigDecimal materialsBudget;
|
||||
|
||||
private BigDecimal totalBudget;
|
||||
|
||||
private Integer totalHours;
|
||||
|
||||
private OrderStatusEnum state;
|
||||
|
||||
private ExternalCompany customer;
|
||||
|
||||
private String customerReference;
|
||||
|
||||
private String externalCode;
|
||||
|
||||
public BigDecimal getWorkBudget() {
|
||||
return workBudget;
|
||||
}
|
||||
|
||||
public void setWorkBudget(BigDecimal workBudget) {
|
||||
this.workBudget = workBudget;
|
||||
}
|
||||
|
||||
public BigDecimal getMaterialsBudget() {
|
||||
return materialsBudget;
|
||||
}
|
||||
|
||||
public void setMaterialsBudget(BigDecimal materialsBudget) {
|
||||
this.materialsBudget = materialsBudget;
|
||||
}
|
||||
|
||||
public BigDecimal getTotalBudget() {
|
||||
return totalBudget;
|
||||
}
|
||||
|
||||
public void setTotalBudget(BigDecimal totalBudget) {
|
||||
this.totalBudget = totalBudget;
|
||||
}
|
||||
|
||||
public Integer getTotalHours() {
|
||||
return totalHours;
|
||||
}
|
||||
|
||||
public void setTotalHours(Integer totalHours) {
|
||||
this.totalHours = totalHours;
|
||||
}
|
||||
|
||||
public OrderStatusEnum getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(OrderStatusEnum state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getCustomerReference() {
|
||||
return this.customerReference;
|
||||
}
|
||||
|
||||
public void setCustomerReference(String customerReference) {
|
||||
this.customerReference = customerReference;
|
||||
}
|
||||
|
||||
public String getExternalCode() {
|
||||
return this.externalCode;
|
||||
}
|
||||
|
||||
public void setExternalCode(String externalCode) {
|
||||
this.externalCode = externalCode;
|
||||
}
|
||||
|
||||
public ExternalCompany getCustomer() {
|
||||
return this.customer;
|
||||
}
|
||||
|
||||
public void setCustomer(ExternalCompany customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public String getResponsible() {
|
||||
return responsible;
|
||||
}
|
||||
|
|
@ -79,14 +165,6 @@ public class Order extends OrderLineGroup {
|
|||
this.responsible = responsible;
|
||||
}
|
||||
|
||||
public String getCustomer() {
|
||||
return customer;
|
||||
}
|
||||
|
||||
public void setCustomer(String customer) {
|
||||
this.customer = customer;
|
||||
}
|
||||
|
||||
public boolean isDeadlineBeforeStart() {
|
||||
return getDeadline() != null && getDeadline().before(getInitDate());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.business.orders.entities;
|
||||
|
||||
|
||||
/**
|
||||
* @author Susana Montes Pedreiera <smotnes@wirelessgalicia.com>
|
||||
*/
|
||||
|
||||
public enum OrderStatusEnum {
|
||||
|
||||
OFFERED("OFFERED"), ACCEPTED("ACCEPTED"), STARTED("STARTED"), FINISHED(
|
||||
"FINISHED"), CANCELLED("CANCELLED");
|
||||
|
||||
private String description;
|
||||
|
||||
private OrderStatusEnum(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return this.description;
|
||||
}
|
||||
|
||||
public static OrderStatusEnum getDefault() {
|
||||
return OFFERED;
|
||||
}
|
||||
}
|
||||
|
|
@ -17,6 +17,7 @@
|
|||
<property name="deadline" access="field" />
|
||||
<property name="mandatoryInit" access="field" />
|
||||
<property name="mandatoryEnd" access="field" />
|
||||
|
||||
<property name="schedulingStateType" access="field" >
|
||||
<type name="org.hibernate.type.EnumType">
|
||||
<param name="enumClass">org.navalplanner.business.orders.entities.SchedulingState$Type</param>
|
||||
|
|
@ -28,10 +29,10 @@
|
|||
<one-to-many class="org.navalplanner.business.advance.entities.DirectAdvanceAssignment" />
|
||||
</set>
|
||||
|
||||
<set name="labels" table="ORDER_ELEMENT_LABEL" access="field" cascade="all">
|
||||
<key column="ORDER_ELEMENT_ID" not-null="true"/>
|
||||
<many-to-many column="LABEL_ID" class="org.navalplanner.business.labels.entities.Label" />
|
||||
</set>
|
||||
<set name="labels" table="ORDER_ELEMENT_LABEL" access="field" cascade="all">
|
||||
<key column="ORDER_ELEMENT_ID" not-null="true"/>
|
||||
<many-to-many column="LABEL_ID" class="org.navalplanner.business.labels.entities.Label" />
|
||||
</set>
|
||||
|
||||
<set name="criterionRequirements" access="field" cascade="all,delete-orphan" inverse="true">
|
||||
<key column="ORDER_ELEMENT_ID" not-null="false"></key>
|
||||
|
|
@ -69,11 +70,25 @@
|
|||
<key column="ORDERELEMENTID"></key>
|
||||
|
||||
<property name="responsible" access="field"></property>
|
||||
<property name="customer" access="field"></property>
|
||||
<property name="dependenciesConstraintsHavePriority" access="field"></property>
|
||||
<property name="codeAutogenerated" access="field"></property>
|
||||
<property name="lastOrderElementSequenceCode" access="field"></property>
|
||||
|
||||
<property name="workBudget" access="field" />
|
||||
<property name="materialsBudget" access="field" />
|
||||
<property name="totalBudget" access="field" />
|
||||
<property name="totalHours" access="field" />
|
||||
<property name="customerReference" access="field" />
|
||||
<property name="externalCode" access="field" />
|
||||
|
||||
<property name="state" access="field" >
|
||||
<type name="org.hibernate.type.EnumType">
|
||||
<param name="enumClass">org.navalplanner.business.orders.entities.OrderStatusEnum</param>
|
||||
</type>
|
||||
</property>
|
||||
|
||||
<many-to-one name="customer" access="field" class="org.navalplanner.business.externalcompanies.entities.ExternalCompany"/>
|
||||
|
||||
<many-to-one name="calendar" column="BASE_CALENDAR_ID" cascade="none"
|
||||
class="org.navalplanner.business.calendars.entities.BaseCalendar"/>
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ public class AddAdvanceAssignmentsToOrderElementTest {
|
|||
private Order createValidOrder() {
|
||||
Order order = Order.create();
|
||||
order.setDescription("description");
|
||||
order.setCustomer("blabla");
|
||||
order.setInitDate(CriterionSatisfactionDAOTest.year(2000));
|
||||
order.setName("name");
|
||||
order.setResponsible("responsible");
|
||||
|
|
|
|||
|
|
@ -57,6 +57,10 @@ public class BandboxSearch extends HtmlMacroComponent {
|
|||
|
||||
private IBandboxFinder finder;
|
||||
|
||||
private String widthBandbox;
|
||||
|
||||
private String widthListbox;
|
||||
|
||||
private List<? extends BaseEntity> model;
|
||||
|
||||
public void afterCompose() {
|
||||
|
|
@ -101,6 +105,7 @@ public class BandboxSearch extends HtmlMacroComponent {
|
|||
});
|
||||
|
||||
addHeaders();
|
||||
updateWidth();
|
||||
}
|
||||
|
||||
private void clearSelectedElement() {
|
||||
|
|
@ -111,6 +116,8 @@ public class BandboxSearch extends HtmlMacroComponent {
|
|||
bandbox.setVariable("selectedElement", obj, true);
|
||||
if (obj != null) {
|
||||
bandbox.setValue(finder.objectToString(obj));
|
||||
} else {
|
||||
bandbox.setValue("");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -234,8 +241,31 @@ public class BandboxSearch extends HtmlMacroComponent {
|
|||
listbox.addEventListener(event, listener);
|
||||
}
|
||||
|
||||
|
||||
public void foucusOnInput() {
|
||||
bandbox.setFocus(true);
|
||||
}
|
||||
|
||||
public String getWidthBandbox() {
|
||||
return widthBandbox;
|
||||
}
|
||||
|
||||
public void setWidthBandbox(String widthBandbox) {
|
||||
this.widthBandbox = widthBandbox;
|
||||
}
|
||||
|
||||
public String getWidthListbox() {
|
||||
return widthListbox;
|
||||
}
|
||||
|
||||
public void setWidthListbox(String widthListbox) {
|
||||
this.widthListbox = widthListbox;
|
||||
}
|
||||
|
||||
private void updateWidth() {
|
||||
if ((widthBandbox != null) && (!widthBandbox.isEmpty())) {
|
||||
this.bandbox.setWidth(widthBandbox);
|
||||
this.listbox.setWidth(widthListbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
* This file is part of ###PROJECT_NAME###
|
||||
*
|
||||
* Copyright (C) 2009 Fundación para o Fomento da Calidade Industrial e
|
||||
* Desenvolvemento Tecnolóxico de Galicia
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package org.navalplanner.web.common.components.finders;
|
||||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.navalplanner.business.externalcompanies.daos.IExternalCompanyDAO;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.zkoss.zul.Bandbox;
|
||||
import org.zkoss.zul.Listcell;
|
||||
import org.zkoss.zul.Listitem;
|
||||
import org.zkoss.zul.ListitemRenderer;
|
||||
|
||||
/**
|
||||
* Implements all the methods needed to comply IBandboxFinder This is a finder
|
||||
* for {@link ExternalCompany}l in a {@link Bandbox}. Provides how many columns
|
||||
* for {@link ExternalCompany} will be shown, how to render
|
||||
* {@link ExternalCompany} object , how to do the matching, what text to show
|
||||
* when an element is selected, etc
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
@Repository
|
||||
public class ExternalCompanyBandboxFinder extends BandboxFinder implements
|
||||
IBandboxFinder {
|
||||
|
||||
@Autowired
|
||||
private IExternalCompanyDAO externalCompanyDAO;
|
||||
|
||||
private final String headers[] = { _("Nif"), _("Name") };
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<ExternalCompany> getAll() {
|
||||
List<ExternalCompany> externalCompanies = externalCompanyDAO.getAll();
|
||||
initializeExternalCompanies(externalCompanies);
|
||||
return externalCompanies;
|
||||
}
|
||||
|
||||
private void initializeExternalCompanies(
|
||||
List<ExternalCompany> externalCompanies) {
|
||||
for (ExternalCompany externalCompany : externalCompanies) {
|
||||
initializeExternalCompany(externalCompany);
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeExternalCompany(ExternalCompany externalCompany) {
|
||||
externalCompany.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean entryMatchesText(Object obj, String text) {
|
||||
final ExternalCompany externalCompany = (ExternalCompany) obj;
|
||||
text = text.toLowerCase();
|
||||
return (externalCompany.getNif().toLowerCase().contains(
|
||||
text.toLowerCase()) || externalCompany.getName().toLowerCase()
|
||||
.contains(text));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String objectToString(Object obj) {
|
||||
return ((ExternalCompany) obj).getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getHeaders() {
|
||||
return headers.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListitemRenderer getItemRenderer() {
|
||||
return externalCompanyRenderer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Render for {@link ExternalCompany}
|
||||
* @author Susana Montes Pedreira <smontes@wirelessgalicia.com>
|
||||
*/
|
||||
private final ListitemRenderer externalCompanyRenderer = new ListitemRenderer() {
|
||||
|
||||
@Override
|
||||
public void render(Listitem item, Object data) throws Exception {
|
||||
ExternalCompany externalCompany = (ExternalCompany) data;
|
||||
|
||||
item.setValue(data);
|
||||
|
||||
final Listcell labelNif = new Listcell();
|
||||
labelNif.setLabel(externalCompany.getNif());
|
||||
labelNif.setParent(item);
|
||||
|
||||
final Listcell labelName = new Listcell();
|
||||
labelName.setLabel(externalCompany.getName());
|
||||
labelName.setParent(item);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
@ -26,6 +26,7 @@ import java.util.Map;
|
|||
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
|
|
@ -105,4 +106,7 @@ public interface IOrderModel {
|
|||
|
||||
void prepareCreationFrom(OrderTemplate template);
|
||||
|
||||
List<ExternalCompany> getExternalCompaniesAreClient();
|
||||
|
||||
void setExternalCompany(ExternalCompany externalCompany);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ package org.navalplanner.web.orders;
|
|||
|
||||
import static org.navalplanner.web.I18nHelper._;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ConcurrentModificationException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
|
@ -33,11 +34,12 @@ import org.apache.commons.logging.LogFactory;
|
|||
import org.hibernate.validator.InvalidValue;
|
||||
import org.navalplanner.business.calendars.entities.BaseCalendar;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.navalplanner.business.orders.entities.HoursGroup;
|
||||
import org.navalplanner.business.orders.entities.Order;
|
||||
import org.navalplanner.business.orders.entities.OrderElement;
|
||||
import org.navalplanner.business.orders.entities.OrderLine;
|
||||
import org.navalplanner.business.orders.entities.OrderLineGroup;
|
||||
import org.navalplanner.business.orders.entities.OrderStatusEnum;
|
||||
import org.navalplanner.business.templates.entities.OrderTemplate;
|
||||
import org.navalplanner.web.common.IMessagesForUser;
|
||||
import org.navalplanner.web.common.Level;
|
||||
|
|
@ -46,6 +48,7 @@ import org.navalplanner.web.common.OnTabSelection;
|
|||
import org.navalplanner.web.common.OnlyOneVisible;
|
||||
import org.navalplanner.web.common.Util;
|
||||
import org.navalplanner.web.common.OnTabSelection.IOnSelectingTab;
|
||||
import org.navalplanner.web.common.components.bandboxsearch.BandboxSearch;
|
||||
import org.navalplanner.web.orders.assigntemplates.TemplateFinderPopup;
|
||||
import org.navalplanner.web.orders.assigntemplates.TemplateFinderPopup.IOnResult;
|
||||
import org.navalplanner.web.orders.labels.AssignedLabelsToOrderElementController;
|
||||
|
|
@ -151,6 +154,8 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
|
||||
private Tab selectedTab;
|
||||
|
||||
private BandboxSearch bdExternalCompanies;
|
||||
|
||||
private OnlyOneVisible cachedOnlyOneVisible;
|
||||
|
||||
private IOrderPlanningGate planningControllerEntryPoints;
|
||||
|
|
@ -307,8 +312,8 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
return cachedOnlyOneVisible;
|
||||
}
|
||||
|
||||
public OrderLineGroup getOrder() {
|
||||
return orderModel.getOrder();
|
||||
public Order getOrder() {
|
||||
return (Order) orderModel.getOrder();
|
||||
}
|
||||
|
||||
public void saveAndContinue() {
|
||||
|
|
@ -343,6 +348,7 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
return false;
|
||||
}
|
||||
try {
|
||||
setSelectedExternalCompany();
|
||||
orderModel.save();
|
||||
orderAuthorizationController.save();
|
||||
messagesForUser.showMessage(Level.INFO, _("Order saved"));
|
||||
|
|
@ -537,4 +543,33 @@ public class OrderCRUDController extends GenericForwardComposer {
|
|||
Util.reloadBindings(editWindow);
|
||||
}
|
||||
|
||||
public OrderStatusEnum[] getOrderStatus() {
|
||||
return OrderStatusEnum.values();
|
||||
}
|
||||
|
||||
public void calculateTotalBudget(BigDecimal workBudget,
|
||||
BigDecimal materialsBudget, Label txtTotalBudget) {
|
||||
BigDecimal sum = new BigDecimal(0);
|
||||
if ((workBudget != null) && (materialsBudget != null)) {
|
||||
sum = workBudget.add(materialsBudget);
|
||||
} else if (workBudget != null) {
|
||||
sum = workBudget;
|
||||
} else if (materialsBudget != null) {
|
||||
sum = materialsBudget;
|
||||
}
|
||||
txtTotalBudget.setValue(sum.toString());
|
||||
txtTotalBudget.invalidate();
|
||||
}
|
||||
|
||||
public List<ExternalCompany> getExternalCompaniesAreClient() {
|
||||
return orderModel.getExternalCompaniesAreClient();
|
||||
}
|
||||
|
||||
private void setSelectedExternalCompany() {
|
||||
this.bdExternalCompanies = (BandboxSearch) editWindow
|
||||
.getFellow("bdExternalCompanies");
|
||||
final Object object = this.bdExternalCompanies.getSelectedElement();
|
||||
orderModel.setExternalCompany((ExternalCompany) object);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ import org.navalplanner.business.common.entities.Configuration;
|
|||
import org.navalplanner.business.common.entities.OrderSequence;
|
||||
import org.navalplanner.business.common.exceptions.InstanceNotFoundException;
|
||||
import org.navalplanner.business.common.exceptions.ValidationException;
|
||||
import org.navalplanner.business.externalcompanies.daos.IExternalCompanyDAO;
|
||||
import org.navalplanner.business.externalcompanies.entities.ExternalCompany;
|
||||
import org.navalplanner.business.labels.daos.ILabelDAO;
|
||||
import org.navalplanner.business.labels.entities.Label;
|
||||
import org.navalplanner.business.orders.daos.IOrderDAO;
|
||||
|
|
@ -85,8 +87,13 @@ public class OrderModel implements IOrderModel {
|
|||
@Autowired
|
||||
private ICriterionTypeDAO criterionTypeDAO;
|
||||
|
||||
@Autowired
|
||||
private IExternalCompanyDAO externalCompanyDAO;
|
||||
|
||||
private static final Map<CriterionType, List<Criterion>> mapCriterions = new HashMap<CriterionType, List<Criterion>>();
|
||||
|
||||
private List<ExternalCompany> externalCompanies = new ArrayList<ExternalCompany>();
|
||||
|
||||
@Autowired
|
||||
private IOrderDAO orderDAO;
|
||||
|
||||
|
|
@ -166,7 +173,17 @@ public class OrderModel implements IOrderModel {
|
|||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<Order> getOrders() {
|
||||
return orderDAO.getOrders();
|
||||
return initializeOrders(orderDAO.getOrders());
|
||||
|
||||
}
|
||||
|
||||
private List<Order> initializeOrders(List<Order> list) {
|
||||
for (Order order : list) {
|
||||
if (order.getCustomer() != null) {
|
||||
order.getCustomer().getName();
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private void loadCriterions() {
|
||||
|
|
@ -205,6 +222,7 @@ public class OrderModel implements IOrderModel {
|
|||
loadCriterions();
|
||||
initializeCacheLabels();
|
||||
getQualityFormsOnConversation().initialize();
|
||||
loadExternalCompaniesAreClient();
|
||||
}
|
||||
|
||||
private void initializeCacheLabels() {
|
||||
|
|
@ -328,13 +346,21 @@ public class OrderModel implements IOrderModel {
|
|||
if (order.isCodeAutogenerated()) {
|
||||
generateOrderElementCodes();
|
||||
}
|
||||
|
||||
calculateAndSetTotalHours();
|
||||
this.orderDAO.save(order);
|
||||
reattachCurrentTaskSources();
|
||||
deleteOrderElementWithoutParent();
|
||||
synchronizeWithSchedule(order);
|
||||
}
|
||||
|
||||
private void calculateAndSetTotalHours() {
|
||||
Integer result = 0;
|
||||
for (OrderElement orderElement : order.getChildren()) {
|
||||
result = result + orderElement.getWorkHours();
|
||||
}
|
||||
order.setTotalHours(result);
|
||||
}
|
||||
|
||||
private void generateOrderElementCodes() {
|
||||
OrderSequence orderSequence = orderSequenceDAO.getActiveOrderSequence();
|
||||
int numberOfDigits = orderSequence.getNumberOfDigits();
|
||||
|
|
@ -538,4 +564,21 @@ public class OrderModel implements IOrderModel {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ExternalCompany> getExternalCompaniesAreClient() {
|
||||
return externalCompanies;
|
||||
}
|
||||
|
||||
private void loadExternalCompaniesAreClient() {
|
||||
this.externalCompanies = externalCompanyDAO
|
||||
.getExternalCompaniesAreClient();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExternalCompany(ExternalCompany externalCompany) {
|
||||
if (this.getOrder() != null) {
|
||||
Order order = (Order) getOrder();
|
||||
order.setCustomer(externalCompany);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -64,6 +64,10 @@
|
|||
<checkbox label="${i18n:_('Autogenerated')}"
|
||||
checked="@{controller.codeAutogenerated}" />
|
||||
</hbox>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('External code')}" />
|
||||
<textbox value="@{controller.order.externalCode}" width="500px"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Starting date')}" />
|
||||
|
|
@ -82,8 +86,14 @@
|
|||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Customer')}" />
|
||||
<textbox
|
||||
value="@{controller.order.customer}" width="500px"/>
|
||||
<bandboxSearch id="bdExternalCompanies" widthBandbox="485px" widthListbox="500px"
|
||||
finder="ExternalCompanyBandboxFinder"
|
||||
model="@{controller.externalCompaniesAreClient}"
|
||||
selectedElement="@{controller.order.customer}"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Customer reference')}" />
|
||||
<textbox value="@{controller.order.customerReference}" width="500px"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Description')}" />
|
||||
|
|
@ -98,11 +108,38 @@
|
|||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Calendar')}" />
|
||||
<combobox id="calendarCombobox"
|
||||
<combobox id="calendarCombobox" width="200px"
|
||||
model="@{controller.baseCalendars}"
|
||||
itemRenderer="@{controller.baseCalendarsComboitemRenderer}"
|
||||
onSelect="controller.setBaseCalendar(self.selectedItem.value);" />
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Budget')}" />
|
||||
<hbox align="center">
|
||||
<label value="${i18n:_('Work')}" />
|
||||
<decimalbox id="boxWorkBudget" width="150px" scale = "2"
|
||||
value="@{controller.order.workBudget}"
|
||||
onChange="controller.calculateTotalBudget(self.value,boxMaterialsBudget.value,txtTotalBudget)"/>
|
||||
<separator bar="false" spacing="15px" orient="vertical"/>
|
||||
<label value="${i18n:_('Materials')}" />
|
||||
<decimalbox id="boxMaterialsBudget" width="150px" scale="2"
|
||||
value="@{controller.order.materialsBudget}"
|
||||
onChange="controller.calculateTotalBudget(boxWorkBudget.value,self.value,txtTotalBudget)"/>
|
||||
<separator bar="false" spacing="15px" orient="vertical"/>
|
||||
<label value="${i18n:_(' Total :')}" />
|
||||
<label id="txtTotalBudget" value="@{controller.order.totalBudget}"/>
|
||||
</hbox>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('Total hours')}" />
|
||||
<label value="@{controller.order.totalHours}" width="200px"/>
|
||||
</row>
|
||||
<row>
|
||||
<label value="${i18n:_('State')}" />
|
||||
<listbox id="listOrderStatus" mold="select" rows="1" width="220px"
|
||||
model="@{controller.orderStatus}"
|
||||
selectedItem="@{controller.order.state}"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</tabpanel>
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
sort="auto(deadline)" />
|
||||
<column label="${i18n:_('Responsible')}"
|
||||
sort="auto(responsible)" />
|
||||
<column label="${i18n:_('Customer')}" sort="auto(customer)" />
|
||||
<column label="${i18n:_('Description')}"
|
||||
sort="auto(description)" />
|
||||
<column label="${i18n:_('Operations')}" />
|
||||
|
|
@ -42,7 +41,6 @@
|
|||
<label value="@{order.initDate, converter='org.navalplanner.web.common.typeconverters.DateConverter'}" />
|
||||
<label value="@{order.deadline, converter='org.navalplanner.web.common.typeconverters.DateConverter'}" />
|
||||
<label value="@{order.responsible}" />
|
||||
<label value="@{order.customer}" />
|
||||
<label value="@{order.description}" />
|
||||
<hbox>
|
||||
<button sclass="icono"
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ public class OrderModelTest {
|
|||
private Order createValidOrder() {
|
||||
Order order = Order.create();
|
||||
order.setDescription("description");
|
||||
order.setCustomer("blabla");
|
||||
order.setInitDate(year(2000));
|
||||
order.setName("name");
|
||||
order.setResponsible("responsible");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue