private boolean shouldCopyFromLowerInstance(final Entity technologyOperationComponent) { // we can't use here getBooleanField() method!!!! if (technologyOperationComponent.getField(IS_SUBCONTRACTING) != null) { return false; } return true; }
private void setInitialDocumentAcceptationInProgress(final Entity document) { if (document.getField(DocumentFields.ACCEPTATION_IN_PROGRESS) == null) { document.setField(DocumentFields.ACCEPTATION_IN_PROGRESS, false); } }
public void onSave(final DataDefinition productToIssueDD, final Entity issue) { if(issue.getField(IssueFields.ISSUED) == null){ issue.setField(IssueFields.ISSUED, false); } }
private void checkRequired(final List<String> fieldNames, final StateChangeContext stateChangeContext) { checkArgument(stateChangeContext != null, ENTITY_IS_NULL); final Entity stateChangeEntity = stateChangeContext.getOwner(); for (String fieldName : fieldNames) { if (stateChangeEntity.getField(fieldName) == null) { stateChangeContext.addFieldValidationError(fieldName, "orders.order.orderStates.fieldRequired"); } } } }
@Override public boolean checkAutogenealogyRequired() { Entity parameter = parameterService.getParameter(); if (parameter.getField("batchForDoneOrder") == null) { return false; } else { return !"01none".equals(parameter.getStringField("batchForDoneOrder")); } }
private void addErrorIfNull(Entity entity, DataDefinition dataDefinition, String fieldName, String error) { if (entity.getField(fieldName) == null) { entity.addError(dataDefinition.getField(fieldName), error); } } }
private void checkMissing(Entity position, String fieldname, DataDefinition positionDataDefinition) { if (position.getField(fieldname) == null) { position.addError(positionDataDefinition.getField(fieldname), "qcadooView.validate.field.error.missing"); } }
public void addFieldsForParameter(final DataDefinition dataDefinition, final Entity parameter) { if (parameter.getField(ParameterFieldsAG.BATCH_NUMBER_UNIQUENESS) == null) { parameter.setField(ParameterFieldsAG.BATCH_NUMBER_UNIQUENESS, BatchNumberUniqueness.GLOBALLY.getStringValue()); } }
public void fillUnit(final DataDefinition productDD, final Entity product) { if (product.getField(UNIT) == null) { product.setField(UNIT, unitService.getDefaultUnitFromSystemParameters()); } }
private Multimap<Optional<TechnologyOperationId>, ProductInfo> findAndGroup(final String hqlQuery, final TechnologyId techId, final String groupBy, final Map<ProductId, TechnologyId> defaultTechnologies, boolean filterIntermediate) { List<Entity> entities = getGeneratorTreeNodeDD().find(hqlQuery).setLong("techId", techId.get()).list().getEntities(); if(filterIntermediate){ entities = entities.stream().filter(p -> (Long) p.getField("isIntermediate") == 0l) .collect(Collectors.toList()); } Multimap<Optional<TechnologyOperationId>, Entity> groupedProjections = Multimaps.index(entities, (e) -> Optional .ofNullable((Long) e.getField(groupBy)).map(TechnologyOperationId::new)); return ImmutableMultimap.copyOf(Multimaps.transformValues(groupedProjections, p -> buildProductInfo(p, defaultTechnologies))); }
public List<Entity> getOperationProductsForTechnology(final Long technologyId) { List<Entity> operationProductsTo = dataDefinitionService .get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_OPERATION_PRODUCT_IN_COMPONENT) .find(inComponentEntityHQL) .setLong(L_TECHNOLOGY_ID, technologyId).list().getEntities(); return operationProductsTo.stream().filter(p -> (Long) p.getField(L_IS_INTERMEDIATE) == 0l).map(p -> p.getBelongsToField(L_OPERATION_PRODUCT)) .collect(Collectors.toList()); }
public void setCommissionedPlannedQuantity(final DataDefinition orderDD, final Entity order) { if (order == null) { return; } Object quantity = order.getField(OrderFields.PLANNED_QUANTITY); if (quantity != null) { if (BigDecimalUtils.tryParse(quantity.toString(), LocaleContextHolder.getLocale()).isRight()) { order.setField(OrderFields.COMMISSIONED_PLANNED_QUANTITY, numberService.setScaleWithDefaultMathContext(order.getDecimalField(OrderFields.PLANNED_QUANTITY))); } } }
private void checkIfForOneDivisionLocationIsSet(final Entity technology, final StateChangeContext stateChangeContext) { if (technology.getField(TechnologyFieldsPFTD.RANGE).equals(Range.ONE_DIVISION.getStringValue())) { if (technology.getBelongsToField(TechnologyFieldsPFTD.COMPONENTS_LOCATION) == null) { stateChangeContext.addFieldValidationError(TechnologyFieldsPFTD.COMPONENTS_LOCATION, L_QCADOO_VIEW_VALIDATE_FIELD_ERROR_MISSING); } if (technology.getBelongsToField(TechnologyFieldsPFTD.PRODUCTS_INPUT_LOCATION) == null) { stateChangeContext.addFieldValidationError(TechnologyFieldsPFTD.PRODUCTS_INPUT_LOCATION, L_QCADOO_VIEW_VALIDATE_FIELD_ERROR_MISSING); } } }
public void setDefaultValueForTechnologyBatchRequiredField(final DataDefinition dataDefinition, final Entity entity) { if (entity.getId() != null) { return; } if (entity.getField("technologyBatchRequired") != null) { return; } Entity parameter = parameterService.getParameter(); entity.setField("technologyBatchRequired", parameter.getBooleanField("batchNumberRequiredProducts")); } }
private Collection<Long> getContextIds() { DataDefinition dataDef = getDataDefinition(); SearchCriteriaBuilder scb = dataDef.find(); scb.setProjection(SearchProjections.alias(SearchProjections.id(), "id")); List<Long> ids = Lists.newLinkedList(); for (Entity idProjection : scb.list().getEntities()) { ids.add((Long) idProjection.getField("id")); } return ids; }
public void onBeforeRender(final ViewDefinitionState view) { FormComponent form = (FormComponent) view.getComponentByReference(L_FORM); Entity opic = form.getPersistedEntityWithIncludedFormValues(); LookupComponent productsFlowLocationLookup = (LookupComponent) view .getComponentByReference(TechnologyFieldsPFTD.PRODUCTS_FLOW_LOCATION); if (ProductionFlowComponent.WAREHOUSE.getStringValue().equals( opic.getField(TechnologyFieldsPFTD.PRODUCTION_FLOW))) { productsFlowLocationLookup.setEnabled(true); } else { productsFlowLocationLookup.setEnabled(false); } }
private Entity createAverageWithDataFromOrder(final Entity order, final DataDefinition avgLaborCostCalcForOrderDD) { Entity avgLaborCostCalcForOrder = avgLaborCostCalcForOrderDD.create(); avgLaborCostCalcForOrder.setField(ORDER, order); avgLaborCostCalcForOrder.setField(START_DATE, order.getField(OrderFields.START_DATE)); avgLaborCostCalcForOrder.setField(FINISH_DATE, order.getField(OrderFields.FINISH_DATE)); avgLaborCostCalcForOrder.setField(PRODUCTION_LINE, order.getBelongsToField(OrderFields.PRODUCTION_LINE)); avgLaborCostCalcForOrder.setField(BASED_ON, "01assignment"); return avgLaborCostCalcForOrder.getDataDefinition().save(avgLaborCostCalcForOrder); }
private void fillStartDate(final Entity order) { DateRange dateRange = orderDatesService.getCalculatedDates(order); if (dateRange.getFrom() == null) { order.setField(OrderFields.DATE_FROM, order.getField(OrderFields.START_DATE)); } else { order.setField(OrderFields.START_DATE, dateRange.getFrom()); } }
public void onCreate(final DataDefinition resourceDD, final Entity resource) { resource.setField(ResourceFields.IS_CORRECTED, false); if (resource.getField(ResourceFields.WASTE) == null) { resource.setField(ResourceFields.WASTE, false); } if (resource.getDecimalField(ResourceFields.RESERVED_QUANTITY) == null) { resource.setField(ResourceFields.RESERVED_QUANTITY, BigDecimal.ZERO); } if (resource.getDecimalField(ResourceFields.AVAILABLE_QUANTITY) == null) { resource.setField(ResourceFields.AVAILABLE_QUANTITY, resource.getDecimalField(ResourceFields.QUANTITY)); } }