ItEr44S10CUGravacionModelosUnidadesTraballoItEr43S12: Copying work hours so the order elements are created with the same work hours.

Copying the structure of the hours groups with the actual criterions it's pending.
This commit is contained in:
Óscar González Fernández 2010-01-20 21:52:16 +01:00
parent 9019d4763b
commit ecb28fd030
2 changed files with 17 additions and 3 deletions

View file

@ -36,13 +36,17 @@ import org.navalplanner.business.orders.entities.OrderLineGroup;
public class OrderLineTemplate extends OrderElementTemplate {
public static OrderLineTemplate create(OrderLine orderLine) {
return create(new OrderLineTemplate(), orderLine);
OrderLineTemplate beingBuilt = new OrderLineTemplate();
beingBuilt.workHours = orderLine.getWorkHours();
return create(beingBuilt, orderLine);
}
public static OrderLineTemplate createNew() {
return createNew(new OrderLineTemplate());
}
private Integer workHours;
@Override
public List<OrderElementTemplate> getChildrenTemplates() {
return Collections.emptyList();
@ -72,12 +76,14 @@ public class OrderLineTemplate extends OrderElementTemplate {
@Override
public OrderLine createElement() {
return setupElementParts(OrderLine.create());
return setupElementParts(OrderLine
.createOrderLineWithUnfixedPercentage(getWorkHours()));
}
@Override
public OrderElement createElement(OrderLineGroup parent) {
OrderLine line = OrderLine.create();
OrderLine line = OrderLine
.createOrderLineWithUnfixedPercentage(getWorkHours());
parent.add(line);
return setupElementParts(line);
}
@ -87,4 +93,11 @@ public class OrderLineTemplate extends OrderElementTemplate {
return _("Line");
}
public int getWorkHours() {
if (workHours == null) {
return 0;
}
return workHours;
}
}

View file

@ -56,6 +56,7 @@
<joined-subclass name="OrderLineTemplate">
<key column="ORDER_LINE_TEMPLATE_ID"></key>
<property name="workHours" />
</joined-subclass>
</class>