private void createOrCopyCalculationOperationComponent(final EntityTreeNode operationComponent,
final Entity calculationOperationComponent, final Entity costCalculation) {
DataDefinition sourceDD = operationComponent.getDataDefinition();
for (String fieldName : Arrays.asList("priority", "nodeNumber", L_PRODUCTION_IN_ONE_CYCLE,
"nextOperationAfterProducedQuantity", "operationOffSet", "effectiveOperationRealizationTime",
"effectiveDateFrom", "effectiveDateTo", "pieceworkCost", "numberOfOperations")) {
calculationOperationComponent.setField(fieldName, operationComponent.getField(fieldName));
}
calculationOperationComponent.setField(L_OPERATION, operationComponent.getBelongsToField(L_OPERATION));
calculationOperationComponent.setField(
"nextOperationAfterProducedType",
operationComponent.getField("nextOperationAfterProducedType") == null ? "01all" : operationComponent
.getField("nextOperationAfterProducedType"));
if (!TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(sourceDD.getName())) {
LOG.error("incorrect model!");
}
calculationOperationComponent.setField(L_TECHNOLOGY_OPERATION_COMPONENT, operationComponent);
calculationOperationComponent.setField(L_ENTITY_TYPE, L_OPERATION);
List<Entity> newTechnologyInstanceOperationComponents = new ArrayList<>();
for (EntityTreeNode child : operationComponent.getChildren()) {
newTechnologyInstanceOperationComponents.add(createCalculationOperationComponent(child,
calculationOperationComponent, calculationOperationComponent.getDataDefinition(), costCalculation));
}
calculationOperationComponent.setField("children", newTechnologyInstanceOperationComponents);
}