ItEr44S18RFGravacionDatosHistoricosResponsabilidadesTraballoUnidadesPlanificacion: Setting up link to template when creating an order element from a template
This commit is contained in:
parent
9471822a35
commit
442107f1ca
2 changed files with 21 additions and 4 deletions
|
|
@ -237,6 +237,16 @@ public abstract class OrderElement extends BaseEntity implements
|
|||
schedulingStateType = type;
|
||||
}
|
||||
|
||||
public void initializeTemplate(OrderElementTemplate template) {
|
||||
if (!isNewObject()) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
if (this.template != null) {
|
||||
throw new IllegalStateException("already initialized");
|
||||
}
|
||||
this.template = template;
|
||||
}
|
||||
|
||||
public boolean isSchedulingPoint() {
|
||||
return getSchedulingState().getType() == Type.SCHEDULING_POINT;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -378,7 +378,15 @@ public class OrderModel implements IOrderModel {
|
|||
}
|
||||
|
||||
private Order createOrderFrom(OrderTemplate template) {
|
||||
return template.createElement();
|
||||
return (Order) createOrderElementFrom(null, template);
|
||||
}
|
||||
|
||||
private OrderElement createOrderElementFrom(OrderLineGroup parent,
|
||||
OrderElementTemplate template) {
|
||||
OrderElement result = parent != null ? template.createElement(parent)
|
||||
: template.createElement();
|
||||
result.initializeTemplate(template);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void setDefaultOrderCode() throws ConcurrentModificationException {
|
||||
|
|
@ -395,9 +403,8 @@ public class OrderModel implements IOrderModel {
|
|||
public OrderElement createFrom(OrderLineGroup parent,
|
||||
OrderElementTemplate template) {
|
||||
loadNeededDataForConversation();
|
||||
OrderElementTemplate templateReloaded = templateDAO
|
||||
.findExistingEntity(template.getId());
|
||||
OrderElement result = templateReloaded.createElement(parent);
|
||||
OrderElement result = createOrderElementFrom(parent, templateDAO
|
||||
.findExistingEntity(template.getId()));
|
||||
if (isCodeAutogenerated()) {
|
||||
setAllCodeToNull(result);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue