@Override public Entity getProductionLineFromDB(final Long productionLineId) { return dataDefinitionService.get(ProductionLinesConstants.PLUGIN_IDENTIFIER, ProductionLinesConstants.MODEL_PRODUCTION_LINE).get(productionLineId); }
public void createTechOperCompTimeCalculations(final DataDefinition dd, final Entity technologyOperationComponent) { DataDefinition techOperCompTimeCalculationDD = dataDefinitionService.get(TimeNormsConstants.PLUGIN_IDENTIFIER, TimeNormsConstants.MODEL_TECH_OPER_COMP_TIME_CALCULATION); Entity techOperCompTimeCalculation = techOperCompTimeCalculationDD.create(); techOperCompTimeCalculation = techOperCompTimeCalculationDD.save(techOperCompTimeCalculation); technologyOperationComponent.setField(TechnologyOperationComponentFieldsTNFO.TECH_OPER_COMP_TIME_CALCULATION, techOperCompTimeCalculation); }
private static boolean isBasicProduct(final Entity entity) { DataDefinition dataDefinition = entity.getDataDefinition(); String pluginIdentifier = dataDefinition.getPluginIdentifier(); String modelName = dataDefinition.getName(); return StringUtils.equalsIgnoreCase(pluginIdentifier, BasicConstants.PLUGIN_IDENTIFIER) && StringUtils.equalsIgnoreCase(modelName, BasicConstants.MODEL_PRODUCT); }
public void tryToDispose(Entity palletNumber) { if (palletNumber != null) { DataDefinition palletNumberDataDefinition = palletNumber.getDataDefinition(); Assert.isTrue(palletNumberDataDefinition.getPluginIdentifier().equals(BasicConstants.PLUGIN_IDENTIFIER)); Assert.isTrue(palletNumberDataDefinition.getName().equals(BasicConstants.MODEL_PALLET_NUMBER)); if (canDisposePalletNumber(palletNumber)) { palletNumber.setField(PalletNumberFields.ISSUE_DATE_TIME, new Date()); palletNumberDataDefinition.save(palletNumber); } } }
private Entity getExistingOrder(final Entity order) { if (order.getId() == null) { return null; } StringBuilder query = new StringBuilder(); query.append("SELECT ord.id as id, technology.id as technology "); query.append("FROM #orders_order ord WHERE id = :id"); Entity orderDB = order.getDataDefinition().find(query.toString()).setLong("id", order.getId()).setMaxResults(1).uniqueResult(); return orderDB; }
public boolean checkIfIsMoreThatFiveDays(final DataDefinition assignmentToShiftReportDD, final Entity assignmentToShiftReport) { int days = assignmentToShiftXlsHelper.getNumberOfDaysBetweenGivenDates(assignmentToShiftReport); if (days > 5) { assignmentToShiftReport.addError(assignmentToShiftReportDD.getField(DATE_FROM), "assignmentToShift.assignmentToShift.report.onlyFiveDays"); assignmentToShiftReport.addError(assignmentToShiftReportDD.getField(DATE_TO), "assignmentToShift.assignmentToShift.report.onlyFiveDays"); return false; } return true; }
@Override public Entity findMergedFromOperationInByOperationComponentId(Long operationComponentId) { Entity operationComponent = dataDefinitionService.get(TechnologiesConstants.PLUGIN_IDENTIFIER, TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT).get(operationComponentId); return mergesProductInDD().find() .add(SearchRestrictions.and( SearchRestrictions.belongsTo(TechnologyOperationComponentMergeProductFields.OPERATION_COMPONENT, operationComponent), SearchRestrictions.belongsTo(TechnologyOperationComponentMergeProductFields.MERGED_OPERATION_COMPONENT, operationComponent))) .uniqueResult(); }
private Integer getWorkstationsQuantity(final Map<Entity, Integer> workstations, final Entity operationComponent) { Entity operComp = operationComponent; String entityType = operationComponent.getDataDefinition().getName(); if (!TechnologiesConstants.MODEL_TECHNOLOGY_OPERATION_COMPONENT.equals(entityType)) { operComp = operComp.getBelongsToField(L_TECHNOLOGY_OPERATION_COMPONENT).getDataDefinition() .get(operComp.getBelongsToField(L_TECHNOLOGY_OPERATION_COMPONENT).getId()); } return workstations.get(operComp); }
private Entity createDocument() { DataDefinition documentDD = dataDefinitionService.get(MaterialFlowResourcesConstants.PLUGIN_IDENTIFIER, MaterialFlowResourcesConstants.MODEL_DOCUMENT); Entity newDocument = documentDD.create(); newDocument.setField(DocumentFields.TIME, new Date()); newDocument.setField(DocumentFields.STATE, DocumentState.DRAFT.getStringValue()); newDocument.setField(DocumentFields.POSITIONS, Lists.newArrayList()); return newDocument; }
public void saveCosts(final ViewDefinitionState viewDefinitionState, final ComponentState component, final String[] args) { FormComponent orderForm = (FormComponent) viewDefinitionState.getComponentByReference("order"); Entity order = orderForm.getEntity(); Entity orderEntity = dataDefinitionService.get(OrdersConstants.PLUGIN_IDENTIFIER, OrdersConstants.MODEL_ORDER).get( order.getId()); orderEntity.setField(OrderFieldsCNFM.DIRECT_ADDITIONAL_COST, order.getDecimalField(OrderFieldsCNFM.DIRECT_ADDITIONAL_COST)); orderEntity.setField(OrderFieldsCNFM.DIRECT_ADDITIONAL_COST_DESCRIPTION, order.getStringField(OrderFieldsCNFM.DIRECT_ADDITIONAL_COST_DESCRIPTION)); orderEntity.getDataDefinition().save(orderEntity); }
@Override public void updateProducedQuantity(final Entity order) { Entity basicProductionCounting = getBasicProductionCountingDD().find() .add(SearchRestrictions.belongsTo(BasicProductionCountingFields.ORDER, order)).add(SearchRestrictions .belongsTo(BasicProductionCountingFields.PRODUCT, order.getBelongsToField(OrderFields.PRODUCT))) .setMaxResults(1).uniqueResult(); if (Objects.nonNull(basicProductionCounting)) { basicProductionCounting.setField(BasicProductionCountingFields.PRODUCED_QUANTITY, order.getDecimalField(OrderFields.DONE_QUANTITY)); basicProductionCounting.getDataDefinition().save(basicProductionCounting); } }
private void deleteOperationsTreeIfExists(final Entity costCalculation) { Entity yetAnotherCostCalculation = costCalculation.getDataDefinition().get(costCalculation.getId()); EntityTree existingOperationsTree = yetAnotherCostCalculation.getTreeField(L_CALCULATION_OPERATION_COMPONENTS); if (existingOperationsTree == null || existingOperationsTree.getRoot() == null) { return; } debug("existing calculation operation components tree will be removed.."); EntityTreeNode existingOperationsTreeRoot = existingOperationsTree.getRoot(); existingOperationsTreeRoot.getDataDefinition().delete(existingOperationsTreeRoot.getId()); }
private boolean deleteBasicProductionCounting(final Entity productionCountingQuantity) { boolean isDeleted = true; Entity basicProductionCounting = productionCountingQuantity .getBelongsToField(ProductionCountingQuantityFields.BASIC_PRODUCTION_COUNTING); if ((basicProductionCounting != null) && checkIfItIsLastProductionCountingQuantity(basicProductionCounting)) { productionCountingQuantity.setField(ProductionCountingQuantityFields.BASIC_PRODUCTION_COUNTING, null); productionCountingQuantity.getDataDefinition().save(productionCountingQuantity); isDeleted = basicProductionCounting.getDataDefinition().delete(basicProductionCounting.getId()).isSuccessfull(); } return isDeleted; }
private void clearStorageLocations(Entity delivery) { EntityList deliveredProducts = delivery.getHasManyField(DeliveryFields.DELIVERED_PRODUCTS); if (deliveredProducts != null) { for (Entity deliveryProduct : deliveredProducts) { deliveryProduct.setField(DeliveredProductFields.STORAGE_LOCATION, null); deliveryProduct.getDataDefinition().save(deliveryProduct); } } } }
private Entity createCalculationOperationComponent(final EntityTreeNode sourceTreeNode, final Entity parent, final DataDefinition calculationOperationComponentDD, final Entity parentEntity) { Entity calculationOperationComponent = calculationOperationComponentDD.create(); calculationOperationComponent.setField("parent", parent); calculationOperationComponent.setField(parentEntity.getDataDefinition().getName(), parentEntity); createOrCopyCalculationOperationComponent(sourceTreeNode, calculationOperationComponent, parentEntity); return calculationOperationComponent; }
private Either<String, Entity> saveOperationComponent(final Entity entity) { Entity savedEntity = entity.getDataDefinition().save(entity); if (savedEntity.isValid()) { return Either.right(savedEntity); } return Either.left(String.format(VALIDATION_ERR_TEMPLATE, entity.getDataDefinition().getName(), entity.getId())); }
private void deleteProductStructureTree(List<Entity> treeEntities) { for (Entity entity : treeEntities) { entity.getDataDefinition().delete(entity.getId()); } }
public void turnOffSoundNotifications(final ViewDefinitionState viewDefinitionState, final ComponentState triggerState, final String args[]) { GridComponent grid = (GridComponent) viewDefinitionState.getComponentByReference("grid"); List<Entity> selectedEntities = grid.getSelectedEntities(); selectedEntities.forEach(entity -> { entity = entity.getDataDefinition().getMasterModelEntity(entity.getId()); entity.setField(MaintenanceEventFields.SOUND_NOTIFICATIONS, false); entity.getDataDefinition().save(entity); }); viewDefinitionState.addMessage("cmmsMachineParts.plannedEventsList.turnedOffSoundNotifications", ComponentState.MessageType.SUCCESS); }
@Override public void checkFields() { DataDefinition dataDefinition = getDataDefinition(); List<String> fieldNames = Lists.newArrayList(getOwnerFieldName(), getSourceStateFieldName(), getTargetStateFieldName(), getStatusFieldName(), getMessagesFieldName(), getPhaseFieldName(), getDateTimeFieldName(), getShiftFieldName(), getWorkerFieldName()); Set<String> uniqueFieldNames = Sets.newHashSet(fieldNames); checkState(fieldNames.size() == uniqueFieldNames.size(), "Describer methods should return unique field names."); Set<String> existingFieldNames = dataDefinition.getFields().keySet(); checkState(existingFieldNames.containsAll(uniqueFieldNames), "DataDefinition for " + dataDefinition.getPluginIdentifier() + '.' + dataDefinition.getName() + " does not have all fields with name specified by this desciber."); }