public boolean isEntityTypeSame(final OperationProductComponentEntityType operationProductComponentEntityType) { return operationProductComponentEntityType.equals(getEntityType()); }
public boolean isEntityTypeSame(final String operationProductComponentModelName) { return isEntityTypeSame(OperationProductComponentEntityType.parseString(operationProductComponentModelName)); }
private OperationProductComponentWithQuantityContainer getProductComponentWithQuantitiesWithoutNonComponents( final OperationProductComponentWithQuantityContainer productComponentWithQuantities, final Set<OperationProductComponentHolder> nonComponents) { for (OperationProductComponentHolder nonComponent : nonComponents) { productComponentWithQuantities.remove(nonComponent); } return productComponentWithQuantities; }
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); }
private OperationProductComponentWithQuantityContainer getAllWithSameEntityType( final OperationProductComponentEntityType operationProductComponentEntityType) { OperationProductComponentWithQuantityContainer allWithSameType = new OperationProductComponentWithQuantityContainer(); for (Entry<OperationProductComponentHolder, BigDecimal> operationProductComponentWithQuantity : operationProductComponentWithQuantities .entrySet()) { OperationProductComponentHolder operationProductComponentHolder = operationProductComponentWithQuantity.getKey(); if (operationProductComponentHolder.isEntityTypeSame(operationProductComponentEntityType)) { BigDecimal quantity = operationProductComponentWithQuantity.getValue(); allWithSameType.put(operationProductComponentHolder, quantity); } } return allWithSameType; }
public BigDecimal get(final Entity operationProductComponent) { Preconditions.checkNotNull(operationProductComponent, L_MISSING_OPERATION_PRODUCT_COMPONENT_ENTITY); OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder( operationProductComponent); return get(operationProductComponentHolder); }
private BigDecimal quantity(OperationProductComponentWithQuantityContainer quantityContainer, Entity operationProductInComponent) { return quantityContainer.get(operationProductInComponent); }
public OperationProductComponentWithQuantityContainer getAllWithSameEntityType(final String operationProductComponentModelName) { return getAllWithSameEntityType(OperationProductComponentEntityType.parseString(operationProductComponentModelName)); }
public void remove(final Entity operationProductComponent) { Preconditions.checkNotNull(operationProductComponent, L_MISSING_OPERATION_PRODUCT_COMPONENT_ENTITY); OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder( operationProductComponent); remove(operationProductComponentHolder); }
public void put(final Entity operationProductComponent, final BigDecimal quantity) { Preconditions.checkNotNull(operationProductComponent, L_MISSING_OPERATION_PRODUCT_COMPONENT_ENTITY); OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder( operationProductComponent); put(operationProductComponentHolder, quantity); }
public boolean containsKey(final Entity operationProductComponent) { Preconditions.checkNotNull(operationProductComponent, L_MISSING_OPERATION_PRODUCT_COMPONENT_ENTITY); OperationProductComponentHolder operationProductComponentHolder = new OperationProductComponentHolder( operationProductComponent); return containsKey(operationProductComponentHolder); }
public Entity getTechnologyOperationComponent() { if ((getTechnologyOperationComponentId() == null) || (getTechnologyOperationComponentDD() == null)) { return null; } else { return getTechnologyOperationComponentDD().get(getTechnologyOperationComponentId()); } }
private String getRole(final OperationProductComponentHolder operationProductComponentHolder) { if (operationProductComponentHolder.isEntityTypeSame(TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT)) { return ProductionCountingQuantityRole.USED.getStringValue(); } else if (operationProductComponentHolder .isEntityTypeSame(TechnologiesConstants.MODEL_OPERATION_PRODUCT_OUT_COMPONENT)) { return ProductionCountingQuantityRole.PRODUCED.getStringValue(); } else { return ProductionCountingQuantityRole.USED.getStringValue(); } }
public Entity getProduct() { if ((getProductId() == null) || (getProductDD() == null)) { return null; } else { return getProductDD().get(getProductId()); } }
public void remove(final OperationProductComponentHolder operationProductComponentHolder) { if (containsKey(operationProductComponentHolder)) { operationProductComponentWithQuantities.remove(operationProductComponentHolder); } }
@Override public void preloadOperationProductComponentQuantity(final List<Entity> operationProductComponents, final OperationProductComponentWithQuantityContainer operationProductComponentWithQuantityContainer) { for (Entity operationProductComponent : operationProductComponents) { BigDecimal neededQuantity = operationProductComponent.getDecimalField(L_QUANTITY); operationProductComponentWithQuantityContainer.put(operationProductComponent, neededQuantity); } }
@Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); }
public BigDecimal fillWithPlanedQuantityValueOUT(final OperationProductComponentWithQuantityContainer productQuantities, final Entity operationProductOutComponent, final boolean takeActualProgress) { if (takeActualProgress) { BigDecimal value = productionCountingService.getRegisteredProductValueForOperationProductOut( operationProductOutComponent, productQuantities.get(operationProductOutComponent)); if (value == null) { value = productQuantities.get(operationProductOutComponent); } return value; } else { return productQuantities.get(operationProductOutComponent); } }
@Override public ProductQuantitiesHolder getProductComponentQuantities(final Entity technology, final BigDecimal givenQuantity) { Map<Long, BigDecimal> operationRuns = Maps.newHashMap(); OperationProductComponentWithQuantityContainer productQuantities = getProductComponentQuantities(technology, givenQuantity, operationRuns); return new ProductQuantitiesHolder(productQuantities, operationRuns); }
public BigDecimal fillWithPlanedQuantityValueIN(final OperationProductComponentWithQuantityContainer productQuantities, final Entity operationProductInComponent, final boolean takeActualProgress) { if (takeActualProgress) { BigDecimal value = productionCountingService.getRegisteredProductValueForOperationProductIn( operationProductInComponent, productQuantities.get(operationProductInComponent)); if (value == null) { value = productQuantities.get(operationProductInComponent); } return value; } else { return productQuantities.get(operationProductInComponent); } }