public boolean onDelete(final DataDefinition dataDefinition, final Entity division) { if (division.getHasManyField("operations").isEmpty() && division.getHasManyField("technologyOperationComponents").isEmpty()) { return true; } division.addGlobalError("basic.division.onDelete.error"); return false; }
public boolean onDelete(final DataDefinition dataDefinition, final Entity workstation) { boolean canDelete = workstation.getHasManyField(WorkstationFields.SUBASSEMBLIES).isEmpty(); if (!canDelete) { workstation.addGlobalError("basic.workstation.delete.hasSubassemblies"); } return canDelete; } }
public boolean onDelete(final DataDefinition dataDefinition, final Entity factory) { boolean canDelete = factory.getHasManyField(FactoryFields.DIVISIONS).isEmpty(); if (!canDelete) { factory.addGlobalError("basic.factory.delete.hasDivisions"); } return canDelete; } }
private boolean workersPresent(Entity filterEntity, ViewDefinitionState view) { String selection = filterEntity.getStringField(TimeUsageReportFilterFields.WORKERS_SELECTION); if ("02selected".equals(selection)) { EntityList workers = filterEntity.getHasManyField(TimeUsageReportFilterFields.WORKERS); if (workers.isEmpty()) { view.addMessage("cmmsMachineParts.timeUsageReport.error.noWorkers", MessageType.FAILURE); return false; } return true; } return true; }
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { Long currentUserId = securityService.getCurrentUserId(); if (Objects.nonNull(currentUserId)) { EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS); if (!userLocations.isEmpty()) { Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet()); scb.add(SearchRestrictions.in(LOCATION_ID, locationIds)); } } }
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { Long currentUserId = securityService.getCurrentUserId(); if (Objects.nonNull(currentUserId)) { EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS); if (!userLocations.isEmpty()) { Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet()); scb.add(SearchRestrictions.in(LOCATION_ID, locationIds)); } } }
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { Long currentUserId = securityService.getCurrentUserId(); if (Objects.nonNull(currentUserId)) { EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS); if (!userLocations.isEmpty()) { Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet()); scb.add(SearchRestrictions.in(LOCATION_ID, locationIds)); } } }
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filter) { Long currentUserId = securityService.getCurrentUserId(); if (Objects.nonNull(currentUserId)) { EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS); if (!userLocations.isEmpty()) { Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet()); scb.add(SearchRestrictions.in("locationId", locationIds)); } } }
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { Long currentUserId = securityService.getCurrentUserId(); if (Objects.nonNull(currentUserId)) { EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS); if (!userLocations.isEmpty()) { Set<Long> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .map(Entity::getId).collect(Collectors.toSet()); scb.add(SearchRestrictions.in("location.id", locationIds)); } } }
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { Long currentUserId = securityService.getCurrentUserId(); if (Objects.nonNull(currentUserId)) { EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS); if (!userLocations.isEmpty()) { Set<Long> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .map(Entity::getId).collect(Collectors.toSet()); scb.add(SearchRestrictions.in("location.id", locationIds)); } } }
private void checkIfRealizationExists(Entity event, StateChangeContext stateChangeContext) { if (event.getHasManyField(PlannedEventFields.REALIZATIONS) == null || event.getHasManyField(PlannedEventFields.REALIZATIONS).isEmpty()) { stateChangeContext.addFieldValidationError(PlannedEventFields.REALIZATIONS, "cmmsMachineParts.plannedEvent.state.fieldRequired"); } }
private void restrictToUserLocations(SearchCriteriaBuilder scb) { Long currentUserId = securityService.getCurrentUserId(); if (Objects.nonNull(currentUserId)) { EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS); if (!userLocations.isEmpty()) { Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet()); scb.add(SearchRestrictions.or(SearchRestrictions.in(LOCATION_TO_ID, locationIds), SearchRestrictions.in(LOCATION_FROM_ID, locationIds))); } } }
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { Long currentUserId = securityService.getCurrentUserId(); if (Objects.nonNull(currentUserId)) { EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS); if (!userLocations.isEmpty()) { Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet()); scb.add(SearchRestrictions.or(SearchRestrictions.in(LOCATION_TO_ID, locationIds), SearchRestrictions.in(LOCATION_FROM_ID, locationIds))); } } }
public void restrictToUserLocations(final SearchCriteriaBuilder scb, final FilterValueHolder filterValue) { Long currentUserId = securityService.getCurrentUserId(); if (Objects.nonNull(currentUserId)) { EntityList userLocations = userDataDefinition().get(currentUserId).getHasManyField(UserFieldsMF.USER_LOCATIONS); if (!userLocations.isEmpty()) { Set<Integer> locationIds = userLocations.stream().map(ul -> ul.getBelongsToField(UserLocationFields.LOCATION)) .mapToInt(e -> e.getId().intValue()).boxed().collect(Collectors.toSet()); scb.add(SearchRestrictions.or(SearchRestrictions.in(LOCATION_TO_ID, locationIds), SearchRestrictions.in(LOCATION_FROM_ID, locationIds))); } } }
private void deleteMaterialAvailability(final Entity order) { EntityList orderMaterialAvailability = order.getHasManyField(OrderFieldsPFTD.MATERIAL_AVAILABILITY); if (!orderMaterialAvailability.isEmpty()) { DataDefinition materialAvailabilityDD = dataDefinitionService.get(ProductFlowThruDivisionConstants.PLUGIN_IDENTIFIER, ProductFlowThruDivisionConstants.MODEL_MATERIAL_AVAILABILITY); for (Entity materialAvailability : orderMaterialAvailability) { materialAvailabilityDD.delete(materialAvailability.getId()); } } }
private boolean checkReasonNeeded(final Entity order, final String dateFieldName, final String reasonTypeFieldName, final String messageTranslationKey) { if (order.getField(dateFieldName) != null && order.getHasManyField(reasonTypeFieldName).isEmpty()) { order.addError(order.getDataDefinition().getField(reasonTypeFieldName), messageTranslationKey); return false; } return true; }
public boolean onDelete(final DataDefinition generatorContextDD, final Entity generatorContext) { if(!generatorContext.getDataDefinition().get(generatorContext.getId()).getHasManyField("technologies").isEmpty()){ generatorContext.addGlobalError("technologiesGenerator.generate.deleteContext.error", false); return false; } return true; } }
private boolean checkEffectiveDeviationNeeded(final Entity order, final String dateFieldName, final String reasonTypeFieldName, final String messageTranslationKey, final String differenceAsString) { if (order.getField(dateFieldName) != null && order.getHasManyField(reasonTypeFieldName).isEmpty()) { order.addError(order.getDataDefinition().getField(reasonTypeFieldName), messageTranslationKey, differenceAsString); return false; } return true; }
private List<Entity> generateTree(final Entity product, final List<Entity> tree) { List<Entity> productsChild = product.getHasManyField(ProductFields.PRODUCT_FAMILY_CHILDRENS); for (Entity productEntity : productsChild) { addProduct(tree, productEntity); if (productEntity.getHasManyField(ProductFields.PRODUCT_FAMILY_CHILDRENS) != null && !productEntity.getHasManyField(ProductFields.PRODUCT_FAMILY_CHILDRENS).isEmpty()) { generateTree(productEntity, tree); } } return tree; } }
public void toggleSetField(final ViewDefinitionState view) { FormComponent form = (FormComponent) view.getComponentByReference("form"); Entity opoc = form.getPersistedEntityWithIncludedFormValues(); Entity operationComponent = opoc.getBelongsToField(OperationProductOutComponentFields.OPERATION_COMPONENT); EntityList ordersFromTechnology = operationComponent.getBelongsToField(TechnologyOperationComponentFields.TECHNOLOGY) .getHasManyField(TechnologyFieldsO.ORDERS); if (!ordersFromTechnology.isEmpty()) { hideSetCheckbox(view, true); } }