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 boolean checkTopComponentsProducesProductForTechnology(final StateChangeContext stateContext) { Entity technology = stateContext.getOwner(); final Entity savedTechnology = technology.getDataDefinition().get(technology.getId()); final Entity product = savedTechnology.getBelongsToField(TechnologyFields.PRODUCT); final EntityTree operations = savedTechnology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); final EntityTreeNode root = operations.getRoot(); if (root != null) { final EntityList productOutComps = root .getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS); for (Entity productOutComp : productOutComps) { if (product.getId().equals(productOutComp.getBelongsToField(OperationProductOutComponentFields.PRODUCT).getId())) { return true; } } } stateContext.addValidationError("technologies.technology.validate.global.error.noFinalProductInTechnologyTree"); return false; }
.getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS).get(0); BigDecimal outQuantity = productOutComponent.getDecimalField(OperationProductOutComponentFields.QUANTITY);
if (technology != null) { EntityTree operationComponents = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); Entity operationProductOutComponent = operationComponents.getRoot().getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS).get(0); boolean isSet = operationProductOutComponent.getBooleanField("set"); if (isSet) { EntityTree operationComponents = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); Entity operationProductOutComponent = operationComponents.getRoot().getHasManyField(TechnologyOperationComponentFields.OPERATION_PRODUCT_OUT_COMPONENTS).get(0); boolean isSet = operationProductOutComponent.getBooleanField("set"); if (isSet) {