public boolean validatesWith(final DataDefinition technologyDD, final Entity technology) { boolean isValid = true; isValid = isValid && checkTechnologyDefault(technologyDD, technology); isValid = isValid && checkTechnologyPrototypeState(technologyDD, technology); isValid = isValid && productService.checkIfProductIsNotRemoved(technologyDD, technology); return isValid; }
public void calculateConversionIfUnitChanged(final DataDefinition productDD, final Entity product) { if (productService.hasUnitChangedOnUpdate(product)) { productService.conversionForProductUnit(product); } }
public BigDecimal convertQuantityFromProductUnit(final Entity product, final BigDecimal quantity, final String targetUnit) { String productUnit = product.getStringField(ProductFields.UNIT); PossibleUnitConversions possibleUnitConversions = findPossibleUnitConversions(targetUnit, product); BigDecimal convertedQuantity = possibleUnitConversions.convertTo(quantity, productUnit); return convertedQuantity; }
@Override public void checkIfBelongsToFamilyIsProductsFamily(final ViewDefinitionState view, final String referenceName) { LookupComponent productLookup = (LookupComponent) view.getComponentByReference(referenceName); Entity product = productLookup.getEntity(); if ((product != null) && !productService.checkIfProductEntityTypeIsCorrect(product, ProductFamilyElementType.PRODUCTS_FAMILY)) { productLookup.addMessage("orderSupplies.materialRequirementCoverage.belongToFamily.isNotProductsFamily", MessageType.FAILURE); } }
public void calculateConversionOnCreate(final DataDefinition productDD, final Entity product) { productService.conversionForProductUnit(product); }
public Entity find(final SearchProjection projection, final SearchCriterion criteria, final SearchOrder order) { return prepareCriteriaBuilder(projection, criteria, order).setMaxResults(1).uniqueResult(); }
private SearchCriteriaBuilder prepareCriteriaBuilder(final SearchProjection projection, final SearchCriterion criteria, final SearchOrder order) { SearchCriteriaBuilder scb = getProductDataDefinition().find(); if (projection != null) { scb.setProjection(projection); } if (criteria != null) { scb.add(criteria); } if (order != null) { scb.addOrder(order); } return scb; }
public boolean checkIfProductIsParticularProduct(final DataDefinition companyProductDD, final Entity companyProduct) { if (!productService.checkIfProductEntityTypeIsCorrect(companyProduct.getBelongsToField(PRODUCT), PARTICULAR_PRODUCT)) { companyProduct.addError(companyProductDD.getField(PRODUCT), "basic.company.message.productIsNotParticularProduct"); return false; } return true; }
public void getDefaultConversionsForGrid(final ViewDefinitionState view, final ComponentState state, final String[] args) { final GridComponent productsGrid = (GridComponent) view.getComponentByReference("grid"); if (productsGrid.getSelectedEntities().isEmpty()) { return; } final List<Entity> products = productsGrid.getSelectedEntities(); for (Entity product : products) { conversionForProductUnit(product); product.getDataDefinition().save(product); } productsGrid.addMessage("basic.productsList.message.getDefaultConversionsForProductsSuccess", MessageType.SUCCESS); }
public List<Entity> findAll(final SearchProjection projection, final SearchCriterion criteria, final SearchOrder order) { return prepareCriteriaBuilder(projection, criteria, order).list().getEntities(); }
public boolean checkIfProductIsProductsFamily(final DataDefinition companyProductsFamilyDD, final Entity companyProductsFamily) { if (!productService.checkIfProductEntityTypeIsCorrect(companyProductsFamily.getBelongsToField(PRODUCT), PRODUCTS_FAMILY)) { companyProductsFamily.addError(companyProductsFamilyDD.getField(PRODUCT), "basic.company.message.productIsNotProductsFamily"); return false; } return true; }
public boolean validatesWith(final DataDefinition orderDD, final Entity order) { boolean isValid = true; Entity parameter = parameterService.getParameter(); isValid = isValid && checkOrderDates(orderDD, order); isValid = isValid && checkOrderPlannedQuantity(orderDD, order); isValid = isValid && productService.checkIfProductIsNotRemoved(orderDD, order); isValid = isValid && checkReasonOfStartDateCorrection(parameter, order); isValid = isValid && checkReasonOfEndDateCorrection(parameter, order); isValid = isValid && checkEffectiveDeviation(parameter, order); return isValid; }
public void getDefaultConversions(final ViewDefinitionState view, final ComponentState state, final String[] args) { final FormComponent productForm = (FormComponent) view.getComponentByReference(L_FORM); if (productForm.getEntityId() == null) { return; } Entity product = productForm.getEntity(); conversionForProductUnit(product); product = product.getDataDefinition().save(product); if(product.isValid()) { productForm.addMessage("basic.productDetails.message.getDefaultConversionsForProductSuccess", MessageType.SUCCESS); state.performEvent(view, "reset", new String[0]); } else { productForm.setEntity(product); } }
private boolean checkIfBelongsToFamilyIsProductsFamily(final DataDefinition parameterDD, final Entity parameter) { Entity belongsToFamily = parameter.getBelongsToField(ParameterFieldsOS.BELONGS_TO_FAMILY); if ((belongsToFamily != null) && !productService.checkIfProductEntityTypeIsCorrect(belongsToFamily, ProductFamilyElementType.PRODUCTS_FAMILY)) { parameter.addError(parameterDD.getField(ParameterFieldsOS.BELONGS_TO_FAMILY), "basic.parameter.belongToFamily.isNotProductsFamily"); return false; } return true; }
private boolean checkIfBelongsToFamilyIsProductsFamily(final DataDefinition materialRequirementCoverageDD, final Entity materialRequirementCoverage) { Entity belongsToFamily = materialRequirementCoverage.getBelongsToField(CoverageForOrderFields.BELONGS_TO_FAMILY); if ((belongsToFamily != null) && !productService.checkIfProductEntityTypeIsCorrect(belongsToFamily, ProductFamilyElementType.PRODUCTS_FAMILY)) { materialRequirementCoverage.addError( materialRequirementCoverageDD.getField(CoverageForOrderFields.BELONGS_TO_FAMILY), "materialRequirementCoverageForOrder.coverageForOrder.belongToFamily.isNotProductsFamily"); return false; } return true; }
private boolean checkIfBelongsToFamilyIsProductsFamily(final DataDefinition materialRequirementCoverageDD, final Entity materialRequirementCoverage) { Entity belongsToFamily = materialRequirementCoverage .getBelongsToField(MaterialRequirementCoverageFields.BELONGS_TO_FAMILY); if ((belongsToFamily != null) && !productService.checkIfProductEntityTypeIsCorrect(belongsToFamily, ProductFamilyElementType.PRODUCTS_FAMILY)) { materialRequirementCoverage.addError( materialRequirementCoverageDD.getField(MaterialRequirementCoverageFields.BELONGS_TO_FAMILY), "orderSupplies.materialRequirementCoverage.belongToFamily.isNotProductsFamily"); return false; } return true; }
List<Entity> children = product.getHasManyField(ProductFields.PRODUCT_FAMILY_CHILDRENS); for (Entity child : children) { if (productService.checkIfProductEntityTypeIsCorrect(child, ProductFamilyElementType.PRODUCTS_FAMILY)) { List<Entity> familiesCompanies = child.getHasManyField(ProductFieldsD.PRODUCTS_FAMILY_COMPANIES); if (!familiesCompanies.isEmpty()) {