@Override public int compare(final Entity e1, final Entity e2) { Integer d1 = e1.getIntegerField(TimeGapFields.DURATION); Integer d2 = e2.getIntegerField(TimeGapFields.DURATION); return d1.compareTo(d2); } });
private void fillSuccession(final Map<Entity, Map<String, String>> values, final Entity requestForQuotationOrOfferProduct) { Integer succession = null; if (requestForQuotationOrOfferProduct == null) { succession = 0; } else { succession = requestForQuotationOrOfferProduct.getIntegerField(SUCCESSION); } values.get(requestForQuotationOrOfferProduct).put("succession", succession.toString()); }
private void fillSuccession(final Map<Entity, Map<String, String>> values, final Entity orderedProduct) { Integer succession = null; if (orderedProduct == null) { succession = 0; } else { succession = orderedProduct.getIntegerField(SUCCESSION); } values.get(orderedProduct).put("succession", succession.toString()); }
private Date getDueDateMinusCompanyBuffer(final Date dueDate, final Entity company) { Integer buffer = company.getIntegerField(BUFFER); if (buffer == null) { return dueDate; } else { return new DateTime(dueDate).minusDays(buffer).toDate(); } }
@Override public int getAdditionalRowsFromParameter(String field) { Integer rows = parameterService.getParameter().getIntegerField(field); return rows != null ? rows : 0; }
private int getOrdersIncludePeriod() { Entity parameter = parameterService.getParameter(); Integer includePeriod = parameter.getIntegerField(ParameterFieldsOS.ORDERS_INCLUDE_PERIOD); return includePeriod == null ? 0 : includePeriod; }
private Map<Entity, Integer> getGroupedStaffWorkTimes(Entity event) { List<Entity> staffWorkTimes = event.getHasManyField(MaintenanceEventFields.STAFF_WORK_TIMES); Function<Entity, Entity> toWorker = entity -> entity.getBelongsToField(StaffWorkTimeFields.WORKER); ToIntFunction<Entity> toInt = entity -> entity.getIntegerField(StaffWorkTimeFields.LABOR_TIME); return staffWorkTimes.stream().collect(Collectors.groupingBy(toWorker, Collectors.summingInt(toInt))); }
private Map<Long, Integer> getWorkstationsMapFromOrder(final Entity order) { Map<Long, Integer> workstations = new HashMap<Long, Integer>(); for (Entity operComp : order.getBelongsToField(L_TECHNOLOGY).getHasManyField("operationComponents")) { workstations.put(operComp.getId(), operComp.getIntegerField(TechnologyOperationComponentFields.QUANTITY_OF_WORKSTATIONS)); } return workstations; }
public void redirectToDeliveryDetails(final ViewDefinitionState view, final ComponentState state, final String[] args) { GridComponent grid = (GridComponent) view.getComponentByReference("grid"); if (grid.getSelectedEntities().isEmpty()) { return; } Entity orderedProduct = grid.getSelectedEntities().get(0); Map<String, Object> parameters = Maps.newHashMap(); parameters.put("form.id", orderedProduct.getIntegerField("deliveryId")); String url = "../page/deliveries/deliveryDetails.html"; view.redirectTo(url, false, true, parameters); }
private Interval changeoverToInterval(final Entity changeover, final DateTime endDate) { Integer durationSeconds = changeover.getIntegerField(LineChangeoverNormsFields.DURATION); DateTime startDate; if (durationSeconds > 0) { startDate = endDate.minusSeconds(durationSeconds); } else { startDate = endDate; } return new Interval(startDate, endDate); }
private void setTimeToZeroIfNull(final Entity productionTracking, final String timeFieldName) { Integer time = productionTracking.getIntegerField(timeFieldName); productionTracking.setField(timeFieldName, ObjectUtils.defaultIfNull(time, 0)); }
public DayAndDates getDatesFor(final Entity progressForDay) { int originalDayNumber = progressForDay.getIntegerField(ProgressForDayFields.DAY); Map.Entry<Integer, LocalDate> dayAndDate = daysToDates.ceilingEntry(originalDayNumber); LocalDate effectiveDate = daysToEffectiveDates.ceilingEntry(originalDayNumber).getValue(); /* mutates state */ removeAvailableDates(originalDayNumber); return new DayAndDates(dayAndDate.getKey(), dayAndDate.getValue(), effectiveDate); }
private Map<Entity, Integer> getWorkstationsFromTechnology(final Entity technology, final Entity productionLine) { Map<Entity, Integer> workstations = new HashMap<Entity, Integer>(); for (Entity operComp : technology.getHasManyField(TechnologyFields.OPERATION_COMPONENTS)) { if (parameterService.getParameter().getBooleanField("workstationsQuantityFromProductionLine")) { workstations.put(operComp, productionLinesService.getWorkstationTypesCount(operComp, productionLine)); } else { workstations.put(operComp, operComp.getIntegerField(TechnologyOperationComponentFields.QUANTITY_OF_WORKSTATIONS)); } } return workstations; }
private boolean checkIfOrdersIncludePeriodFilled(final DataDefinition parameterDD, final Entity parameter) { boolean includeRequirements = parameter.getBooleanField(ParameterFieldsOS.INCLUDE_REQUIREMENTS); if (includeRequirements) { Integer ordersIncludePeriod = parameter.getIntegerField(ParameterFieldsOS.ORDERS_INCLUDE_PERIOD); if (ordersIncludePeriod == null || ordersIncludePeriod.compareTo(0) < 0) { parameter.addError(parameterDD.getField(ParameterFieldsOS.ORDERS_INCLUDE_PERIOD), "basic.parameter.ordersInludePeriod.isSmallerThanOne"); return false; } } return true; }
private String generatePostfixForNumber(final Entity parentOrder, final Entity order, final int index) { String postfix = ""; if (parentOrder.getBelongsToField(OrderFieldsOFSPG.PARENT) == null) { postfix = parentOrder.getStringField(OrderFields.NUMBER) + "-" + order.getIntegerField(OrderFieldsOFSPG.LEVEL).toString() + "." + index; } else { String parentOrderNumber = parentOrder.getStringField(OrderFields.NUMBER); postfix = parentOrderNumber + "." + index; } return postfix; }
private Map<Long, Integer> getWorkstationsFromOrder(final Entity order) { Map<Long, Integer> workstations = Maps.newHashMap(); for (Entity technologyOperationComponent : order.getBelongsToField(L_TECHNOLOGY).getHasManyField( TechnologyFields.OPERATION_COMPONENTS)) { workstations.put(technologyOperationComponent.getId(), IntegerUtils.convertNullToZero(technologyOperationComponent .getIntegerField(TechnologyOperationComponentFields.QUANTITY_OF_WORKSTATIONS))); } return workstations; }
public void goToProductionTracking(final ViewDefinitionState view, final ComponentState state, final String[] args) { GridComponent grid = (GridComponent) view.getComponentByReference(L_GRID); if (!grid.getSelectedEntitiesIds().isEmpty()) { String url = "../page/productionCounting/productionTrackingDetails.html"; Entity productionTrackingForProductDto = grid.getSelectedEntities().get(0).getDataDefinition() .get(grid.getSelectedEntities().get(0).getId()); view.redirectTo(url, false, true, ImmutableMap.of("form.id", productionTrackingForProductDto .getIntegerField(ProductionTrackingForProductDtoFields.PRODUCTION_TRACKING_ID))); } }
public static Order from(final Entity projection) { Date dateFrom = projection.getDateField(OrderIntervalsModelHelper.DATE_FROM_ALIAS); Date dateTo = projection.getDateField(OrderIntervalsModelHelper.DATE_TO_ALIAS); Interval interval = new Interval(dateFrom.getTime(), dateTo.getTime()); Long technologyId = (Long) projection.getField(OrderIntervalsModelHelper.TECHNOLOGY_ID_ALIAS); Long technologyGroupId = (Long) projection.getField(OrderIntervalsModelHelper.TECHNOLOGY_GROUP_ID_ALIAS); Integer ownLineChangeoverDuration = projection.getIntegerField(OrderFieldsLCNFO.OWN_LINE_CHANGEOVER_DURATION); Long productionLineId = (Long) projection.getField(OrderIntervalsModelHelper.PRODUCTION_LINE_ID_ALIAS); return new Order(interval, technologyId, technologyGroupId, productionLineId, ownLineChangeoverDuration); }
private void createWorkstationTypeComponentQuantityEntry(Entity entity, Date from, Date to, List<WorkstationTypeComponentQuantity> results) { Date componentDateFrom = entity.getDateField(WorkstationTypeComponentFields.DATE_FROM); Date componentDateTo = entity.getDateField(WorkstationTypeComponentFields.DATE_TO); Integer quantity = entity.getIntegerField(WorkstationTypeComponentFields.QUANTITY); WorkstationTypeComponentQuantity workstationTypeComponentQuantity = new WorkstationTypeComponentQuantity(quantity, resolveDateFrom(from, componentDateFrom), resolveDateTo(to, componentDateTo)); if (componentDateTo == null) { workstationTypeComponentQuantity.setToInfinity(true); } results.add(workstationTypeComponentQuantity); }
private TimeGapsSearchResult performGeneration(final Entity contextEntity) { Integer durationFilterInSeconds = contextEntity.getIntegerField(TimeGapsContextFields.DURATION_FILTER); Duration durationFilter = Seconds.seconds(durationFilterInSeconds).toStandardDuration(); TimeGapsContext context = new TimeGapsContext(extractSearchInterval(contextEntity), findMatchingProductionLines(contextEntity), durationFilter); return timeGapsGenerator.generate(context); }