private Map<Entity, Integer> estimateOperationTimeConsumptions(final Entity entity, final BigDecimal plannedQuantity, final boolean includeTpz, final boolean includeAdditionalTime, final Entity productionLine, final boolean maxForWorkstation) { Map<Entity, Integer> operationDurations = new HashMap<Entity, Integer>(); String entityType = entity.getDataDefinition().getName(); Entity technology; List<Entity> operationComponents; if (TechnologiesConstants.MODEL_TECHNOLOGY.equals(entityType)) { technology = entity; operationComponents = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); } else if (L_ORDER.equals(entityType)) { technology = entity.getBelongsToField(TECHNOLOGY); operationComponents = technology.getTreeField(TechnologyFields.OPERATION_COMPONENTS); } else { throw new IllegalStateException("Entity has to be either order or technology"); } Map<Long, BigDecimal> operationRunsFromProductionQuantities = Maps.newHashMap(); productQuantitiesService .getProductComponentQuantities(technology, plannedQuantity, operationRunsFromProductionQuantities); for (Entity operationComponent : operationComponents) { evaluateTimes(operationDurations, operationComponent, includeTpz, includeAdditionalTime, operationRunsFromProductionQuantities, productionLine, maxForWorkstation); } return operationDurations; }