public Entity fromOperationProductComponentHolder(final OperationProductComponentHolder operationProductComponentHolder) { String modelName = operationProductComponentHolder.getEntityType().getStringValue(); ProductionCountingQuantityRole role = null; String typeOfMaterial = operationProductComponentHolder.getProductMaterialType().getStringValue(); if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT.equals(modelName)) { role = ProductionCountingQuantityRole.USED; } else if (TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT.equals(modelName)) { role = ProductionCountingQuantityRole.PRODUCED; } else { throw new IllegalArgumentException(String.format("Unsupported operation component type: %s", modelName)); } Entity product = operationProductComponentHolder.getProduct(); return fromProduct(product, role, typeOfMaterial); }
@Around("shouldSkipAddingProduct(operationProductComponentHolder,entityTypeWithAlreadyAddedProducts,typeOfProductionRecording)") public boolean aroundShouldSkipAddingProduct(final ProceedingJoinPoint pjp, OperationProductComponentHolder operationProductComponentHolder, Map<OperationProductComponentEntityType, Set<Entity>> entityTypeWithAlreadyAddedProducts, String typeOfProductionRecording) throws Throwable { if (cumulated(typeOfProductionRecording)) { Entity product = operationProductComponentHolder.getProduct(); Entity toc = operationProductComponentHolder.getTechnologyOperationComponent(); if (toc != null) { Entity technology = toc.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY); if (operationProductComponentHolder.getProductMaterialType().getStringValue().equals(TechnologyService.L_02_INTERMEDIATE)) { boolean isProductToSkip = !productionTrackingListenerService.isOperationProductComponentToRegister( operationProductComponentHolder, product, toc); if (isProductToSkip) { return true; } } } } return (boolean) pjp.proceed(); }