private EntityTree getTechnologyOperationComponents(final Entity technology) { return technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); }
private EntityTree getOperationComponentsFromTechnology(final Entity technology) { return technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); }
private List<Entity> operationComponents(Entity technology) { return entityTreeUtilsService.getSortedEntities(technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS)); }
private List<Entity> operationComponents(Entity technology) { return entityTreeUtilsService.getSortedEntities(technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS)); }
public void checkConsumingManyProductsFromOneSubOp(final StateChangeContext stateContext) { final Entity technology = stateContext.getOwner(); final Map<String, Set<String>> parentChildNodeNums = technologyTreeValidationService .checkConsumingManyProductsFromOneSubOp(technology.getTreeField(OPERATION_COMPONENTS)); for (Map.Entry<String, Set<String>> parentChildNodeNum : parentChildNodeNums.entrySet()) { for (String childNodeNum : parentChildNodeNum.getValue()) { stateContext.addMessage("technologies.technology.validate.global.info.consumingManyProductsFromOneSubOperations", StateMessageType.INFO, parentChildNodeNum.getKey(), childNodeNum); } } }
public final List<Entity> buildProductInComponentList(final Entity order) { EntityTree operationsTree = order.getBelongsToField(OrderFields.TECHNOLOGY).getTreeField( TechnologyFields.OPERATION_COMPONENTS); return buildGenealogyProductInComponentsList(operationsTree); }
private Entity getOrderTechnologyOperationComponent(final Entity order) { Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY); if (technology == null) { return null; } else { return technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS).getRoot(); } }
private Entity getOrderTechnologyOperationComponent(final Entity order) { Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY); if (technology == null) { return null; } else { Entity technologyOperationComponent = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS).getRoot(); return technologyOperationComponent; } }
public boolean checkIfTechnologyTreeIsSet(final StateChangeContext stateChangeContext) { final Entity technology = stateChangeContext.getOwner(); final EntityTree operations = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); if (operations.isEmpty()) { stateChangeContext.addValidationError("technologies.technology.validate.global.error.emptyTechnologyTree"); return false; } return true; }
public void setDefaultValuesIfEmpty(final DataDefinition dataDefinition, final Entity technology) { if (technology.getId() == null) { return; } Entity savedTechnology = dataDefinition.get(technology.getId()); if ("02accepted".equals(technology.getStringField("state")) && "01draft".equals(savedTechnology.getStringField("state"))) { final EntityTree operationComponents = savedTechnology.getTreeField("operationComponents"); for (Entity operationComponent : operationComponents) { setOperationComponentDefaults(operationComponent); } } }
private void checkFinalProductionCountingForOrderForEach(final StateChangeContext stateChangeContext) { final Entity order = stateChangeContext.getOwner(); final Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY); final List<Entity> technologyOperationComponents = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); int productionTrackingsNumber = 0; for (Entity technologyOperationComponent : technologyOperationComponents) { if (checkIfOrderHasFinalProductionTrackings(order, technologyOperationComponent)) { productionTrackingsNumber++; } } if (order.getBooleanField(OrderFieldsPC.ALLOW_TO_CLOSE) && (technologyOperationComponents.size() != productionTrackingsNumber)) { stateChangeContext.addValidationError("orders.order.state.allowToClose.failureForEach"); } }
@Transactional public Entity copyTechnologyTree(final Entity costCalculation) { deleteOperationsTreeIfExists(costCalculation); Entity operationsTreeContainer; if (costCalculation.getBelongsToField(L_ORDER) == null) { operationsTreeContainer = costCalculation.getBelongsToField(L_TECHNOLOGY); } else { operationsTreeContainer = costCalculation.getBelongsToField(L_ORDER).getBelongsToField(L_TECHNOLOGY); } EntityTree sourceOperationsTree = operationsTreeContainer.getTreeField(OPERATION_COMPONENTS); return createTechnologyInstanceForCalculation(sourceOperationsTree, costCalculation); }
private Entity createTechnologyInstanceForCalculation(final EntityTree sourceTree, final Entity parentEntity) { checkArgument(sourceTree != null, "source is null"); DataDefinition calculationOperationComponentDD = dataDefinitionService.get(PLUGIN_IDENTIFIER, MODEL_CALCULATION_OPERATION_COMPONENT); // drop old operation components tree EntityTree oldCalculationOperationComponents = parentEntity.getTreeField(L_CALCULATION_OPERATION_COMPONENTS); if (oldCalculationOperationComponents != null && oldCalculationOperationComponents.getRoot() != null) { calculationOperationComponentDD.delete(oldCalculationOperationComponents.getRoot().getId()); } Entity tree = createCalculationOperationComponent(sourceTree.getRoot(), null, calculationOperationComponentDD, parentEntity); parentEntity.setField(L_CALCULATION_OPERATION_COMPONENTS, asList(tree)); return parentEntity; }
private void setParentIfRootNodeAlreadyExists(final Entity technologyOperationComponent) { Entity technology = technologyOperationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); EntityTree tree = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); if (tree == null || tree.isEmpty()) { return; } EntityTreeNode rootNode = tree.getRoot(); if ((rootNode == null) || (technologyOperationComponent.getBelongsToField(TechnologyOperationComponentFields.PARENT) != null)) { return; } technologyOperationComponent.setField(TechnologyOperationComponentFields.PARENT, rootNode); }
public void validateTypeOfProductionRecordingForTechnology(final StateChangeContext stateChangeContext) { Entity technology = stateChangeContext.getOwner(); if (technology != null && !stateChangeContext.getStatus().equals(StateChangeStatus.FAILURE)) { EntityTree tree = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); Entity mainProduct = technologyService.getMainOutputProductComponent(tree.getRoot()); String typeOfProductionRecording = technology.getStringField(TechnologyFieldsPC.TYPE_OF_PRODUCTION_RECORDING); if (mainProduct.getBooleanField(OperationProductOutComponentFields.SET) && typeOfProductionRecording.equals("03forEach")) { stateChangeContext.addValidationError("technologies.technology.technologyState.error.typeOfProductionRecording"); } } }
public boolean checkIfTechnologyHasAtLeastOneComponent(final StateChangeContext stateContext) { Entity technology = stateContext.getOwner(); final Entity savedTechnology = technology.getDataDefinition().get(technology.getId()); final EntityTree operations = savedTechnology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); if (!operations.isEmpty()) { return true; } stateContext.addValidationError("technologies.technology.validate.global.error.emptyTechnologyTree"); return false; }
private Optional<Entity> getSetProductTechnology(final Long productId) { DataDefinition technologyDD = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY); Entity masterTechnology = technologyDD.find().add(SearchRestrictions.eq(TechnologyFields.PRODUCT + ".id", productId)) .add(SearchRestrictions.eq(TechnologyFields.MASTER, true)).uniqueResult(); if (masterTechnology != null) { EntityTree operationComponents = masterTechnology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); boolean isSet = operationComponents.getRoot() .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS).get(0) .getBooleanField(OperationProductOutComponentFields.SET); if (isSet) { return Optional.of(masterTechnology); } } return Optional.empty(); }
public void validateTypeOfProductionRecordingForOrder(final StateChangeContext stateChangeContext) { if(parameterService.getParameter().getBooleanField(ParameterFieldsO.CREATE_SET_ELEMENTS_ON_ACCEPT)) { Entity order = stateChangeContext.getOwner(); Entity technology = order.getBelongsToField(OrderFields.TECHNOLOGY); if (technology != null && !stateChangeContext.getStatus().equals(StateChangeStatus.FAILURE)) { EntityTree tree = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); Entity mainProduct = technologyService.getMainOutputProductComponent(tree.getRoot()); String typeOfProductionRecording = order.getStringField(OrderFieldsPC.TYPE_OF_PRODUCTION_RECORDING); if (typeOfProductionRecording != null && mainProduct.getBooleanField(OperationProductOutComponentFields.SET) && typeOfProductionRecording.equals("03forEach")) { stateChangeContext .addValidationError("technologies.technology.technologyState.error.typeOfProductionRecording"); } } } } }
private void deleteOperationsTreeIfExists(final Entity costCalculation) { Entity yetAnotherCostCalculation = costCalculation.getDataDefinition().get(costCalculation.getId()); EntityTree existingOperationsTree = yetAnotherCostCalculation.getTreeField(L_CALCULATION_OPERATION_COMPONENTS); if (existingOperationsTree == null || existingOperationsTree.getRoot() == null) { return; } debug("existing calculation operation components tree will be removed.."); EntityTreeNode existingOperationsTreeRoot = existingOperationsTree.getRoot(); existingOperationsTreeRoot.getDataDefinition().delete(existingOperationsTreeRoot.getId()); }
public void checkIfEveryOperationHasInComponents(final StateChangeContext stateContext) { Entity technology = stateContext.getOwner(); final Entity savedTechnology = technology.getDataDefinition().get(technology.getId()); final EntityTree operations = savedTechnology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); for (Entity toc : operations) { if (toc.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_IN_COMPONENTS).isEmpty()) { stateContext.addValidationError("technologies.technology.validate.global.error.noInputComponents", toc .getBelongsToField(TechnologyOperationComponentFields.OPERATION).getStringField(OperationFields.NUMBER), toc.getStringField(TechnologyOperationComponentFields.NODE_NUMBER)); return; } } }