public void showReasonForm(
     final StateChangeContext stateChangeContext, final ViewContextHolder viewContext) {
   final Entity order = stateChangeContext.getOwner();
   final Entity parameter = parameterService.getParameter();
   Long differenceForDateFrom = getEffectiveDateFromDifference(parameter, order);
   Long differenceForDateTo = getEffectiveDateToDifference(parameter, order);
   final Entity stateChangeEntity = stateChangeContext.getStateChangeEntity();
   String additionalInfoKey = null;
   String additionalInfo = null;
   // EFFECTIVE_DATE_FROM
   if (parameter.getBooleanField(ParameterFieldsO.REASON_NEEDED_WHEN_DELAYED_EFFECTIVE_DATE_FROM)
       && differenceForDateFrom > 0L) {
     final String differenceAsString =
         TimeConverterService.convertTimeToString(String.valueOf(Math.abs(differenceForDateFrom)));
     additionalInfoKey = "orders.order.stateChange.additionalInfo.startTooLate";
     additionalInfo =
         translationService.translate(
             additionalInfoKey, LocaleContextHolder.getLocale(), differenceAsString);
   }
   if (parameter.getBooleanField(ParameterFieldsO.REASON_NEEDED_WHEN_EARLIER_EFFECTIVE_DATE_FROM)
       && differenceForDateFrom < 0L) {
     final String differenceAsString =
         TimeConverterService.convertTimeToString(String.valueOf(Math.abs(differenceForDateFrom)));
     additionalInfoKey = "orders.order.stateChange.additionalInfo.startTooEarly";
     additionalInfo =
         translationService.translate(
             additionalInfoKey, LocaleContextHolder.getLocale(), differenceAsString);
   }
   // EFFECTIVE_DATE_TO
   if (parameter.getBooleanField(ParameterFieldsO.REASON_NEEDED_WHEN_DELAYED_EFFECTIVE_DATE_TO)
       && differenceForDateTo > 0L) {
     final String differenceAsString =
         TimeConverterService.convertTimeToString(String.valueOf(Math.abs(differenceForDateTo)));
     additionalInfoKey = "orders.order.stateChange.additionalInfo.endTooLate";
     additionalInfo =
         translationService.translate(
             additionalInfoKey, LocaleContextHolder.getLocale(), differenceAsString);
   }
   if (parameter.getBooleanField(ParameterFieldsO.REASON_NEEDED_WHEN_EARLIER_EFFECTIVE_DATE_TO)
       && differenceForDateTo < 0L) {
     final String differenceAsString =
         TimeConverterService.convertTimeToString(String.valueOf(Math.abs(differenceForDateTo)));
     additionalInfoKey = "orders.order.stateChange.additionalInfo.endTooEarly";
     additionalInfo =
         translationService.translate(
             additionalInfoKey, LocaleContextHolder.getLocale(), differenceAsString);
   }
   if (additionalInfo != null) {
     stateChangeEntity.setField(OrderStateChangeFields.ADDITIONAL_INFO, additionalInfo);
     stateChangeContext.save();
   }
   stateChangeContext.setStatus(StateChangeStatus.PAUSED);
   stateChangeContext.save();
   viewContext
       .getViewDefinitionState()
       .openModal(
           "../page/orders/orderStateChangeReasonDialog.html?context={\"form.id\": "
               + stateChangeContext.getStateChangeEntity().getId()
               + "}");
 }
 private void addOrderHeader(final HSSFSheet sheet, final Locale locale) {
   HSSFRow header = sheet.createRow(0);
   HSSFCell cell0 = header.createCell(0);
   cell0.setCellValue(
       translationService.translate(
           "qualityControls.qualityControl.report.product.number", locale));
   xlsHelper.setCellStyle(sheet, cell0);
   HSSFCell cell1 = header.createCell(1);
   cell1.setCellValue(
       translationService.translate(
           "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.number.label",
           locale));
   xlsHelper.setCellStyle(sheet, cell1);
   HSSFCell cell2 = header.createCell(2);
   cell2.setCellValue(
       translationService.translate(
           "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.controlledQuantity.label",
           locale));
   xlsHelper.setCellStyle(sheet, cell2);
   HSSFCell cell3 = header.createCell(3);
   cell3.setCellValue(
       translationService.translate(
           "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.rejectedQuantity.label",
           locale));
   xlsHelper.setCellStyle(sheet, cell3);
   HSSFCell cell4 = header.createCell(4);
   cell4.setCellValue(
       translationService.translate(
           "qualityControls.qualityControlForUnitDetails.window.mainTab.qualityControlForUnit.acceptedDefectsQuantity.label",
           locale));
   xlsHelper.setCellStyle(sheet, cell4);
 }
  @Before
  public final void init() {
    workPlanService = new WorkPlansServiceImpl();

    dataDefinitionService = mock(DataDefinitionService.class);
    TranslationService translationService = mock(TranslationService.class);
    workPlan = mock(Entity.class);
    workPlanDD = mock(DataDefinition.class);

    when(dataDefinitionService.get(
            WorkPlansConstants.PLUGIN_IDENTIFIER, WorkPlansConstants.MODEL_WORK_PLAN))
        .thenReturn(workPlanDD);

    when(translationService.translate(
            Mockito.anyString(), Mockito.any(Locale.class), Mockito.anyString()))
        .thenReturn(TRANSLATED_STRING);

    when(workPlanDD.getName()).thenReturn(WorkPlansConstants.MODEL_WORK_PLAN);
    when(workPlanDD.getPluginIdentifier()).thenReturn(WorkPlansConstants.PLUGIN_IDENTIFIER);
    when(workPlanDD.get(Mockito.anyLong())).thenReturn(workPlan);

    when(workPlan.getDataDefinition()).thenReturn(workPlanDD);
    when(workPlan.getId()).thenReturn(1L);

    ReflectionTestUtils.setField(workPlanService, "dataDefinitionService", dataDefinitionService);
    ReflectionTestUtils.setField(workPlanService, "translationService", translationService);
  }
 private String getOrderDescription(final Entity order, final Locale locale) {
   return order.getStringField("number")
       + " - "
       + order.getStringField("name")
       + "<br/>"
       + translationService.translate("orders.order.state.label", locale)
       + ": "
       + translationService.translate(
           "orders.order.state.value." + order.getStringField("state"), locale);
 }
 @Override
 protected final String addContent(
     final Map<String, Object> model, final HSSFWorkbook workbook, final Locale locale) {
   HSSFSheet sheet =
       workbook.createSheet(
           translationService.translate(
               "qualityControls.qualityControlForUnit.report.title", locale));
   sheet.setZoom(4, 3);
   addOrderHeader(sheet, locale);
   addOrderSeries(model, sheet);
   return translationService.translate(
       "qualityControls.qualityControlForUnit.report.fileName", locale);
 }
  private void setAdditionalInfo(
      final StateChangeContext stateChangeContext, final long difference) {
    if (difference == 0L) {
      return;
    }
    final Entity stateChangeEntity = stateChangeContext.getStateChangeEntity();
    final StateChangeEntityDescriber describer = stateChangeContext.getDescriber();
    final OrderState orderState =
        (OrderState) stateChangeContext.getStateEnumValue(describer.getTargetStateFieldName());

    String additionalInfoKey = null;
    if (OrderState.IN_PROGRESS.equals(orderState)) {
      if (difference < 0L) {
        additionalInfoKey = "orders.order.stateChange.additionalInfo.startTooEarly";
      } else {
        additionalInfoKey = "orders.order.stateChange.additionalInfo.startTooLate";
      }
    } else if (OrderState.COMPLETED.equals(orderState)) {
      if (difference < 0L) {
        additionalInfoKey = "orders.order.stateChange.additionalInfo.endTooEarly";
      } else {
        additionalInfoKey = "orders.order.stateChange.additionalInfo.endTooLate";
      }
    } else {
      return;
    }

    final String differenceAsString =
        TimeConverterService.convertTimeToString(String.valueOf(Math.abs(difference)));
    final String additionalInfo =
        translationService.translate(
            additionalInfoKey, LocaleContextHolder.getLocale(), differenceAsString);
    stateChangeEntity.setField(OrderStateChangeFields.ADDITIONAL_INFO, additionalInfo);
    stateChangeContext.save();
  }
  @RequestMapping(value = "passwordReset", method = RequestMethod.GET)
  public ModelAndView getForgotPasswordFormView(
      @RequestParam(required = false, defaultValue = FALSE) final Boolean iframe,
      @RequestParam(required = false, defaultValue = FALSE) final Boolean popup,
      final Locale locale) {

    ModelAndView mav = new ModelAndView();
    viewParametersAppender.appendCommonViewObjects(mav);
    mav.setViewName("qcadooView/passwordReset");
    mav.addObject("translation", translationService.getMessagesGroup("security", locale));
    mav.addObject("currentLanguage", locale.getLanguage());
    mav.addObject("locales", translationService.getLocales());

    mav.addObject("iframe", iframe);
    mav.addObject("popup", popup);

    return mav;
  }
  public void closeOrder(final StateChangeContext stateChangeContext) {
    final Entity productionTracking = stateChangeContext.getOwner();
    final Entity order = productionTracking.getBelongsToField(ORDER);

    if (!orderClosingHelper.orderShouldBeClosed(productionTracking)) {
      return;
    }
    if (order.getStringField(STATE).equals(COMPLETED.getStringValue())) {
      stateChangeContext.addMessage(
          "productionCounting.order.orderIsAlreadyClosed", StateMessageType.INFO, false);
      return;
    }
    final StateChangeContext orderStateChangeContext =
        stateChangeContextBuilder.build(
            orderStateChangeAspect.getChangeEntityDescriber(),
            order,
            OrderState.COMPLETED.getStringValue());
    orderStateChangeAspect.changeState(orderStateChangeContext);
    Entity orderFromDB = order.getDataDefinition().get(orderStateChangeContext.getOwner().getId());
    if (orderFromDB.getStringField(STATE).equals(COMPLETED.getStringValue())) {
      stateChangeContext.addMessage(
          "productionCounting.order.orderClosed", StateMessageType.INFO, false);
    } else if (StateChangeStatus.PAUSED.equals(orderStateChangeContext.getStatus())) {
      stateChangeContext.addMessage(
          "productionCounting.order.orderWillBeClosedAfterExtSync", StateMessageType.INFO, false);
    } else {
      stateChangeContext.addMessage(
          "productionCounting.order.orderCannotBeClosed", StateMessageType.FAILURE, false);

      List<ErrorMessage> errors = Lists.newArrayList();

      if (!orderFromDB.getErrors().isEmpty()) {
        errors.addAll(order.getErrors().values());
      }
      if (!orderFromDB.getGlobalErrors().isEmpty()) {
        errors.addAll(order.getGlobalErrors());
      }

      if (!errors.isEmpty()) {
        StringBuilder errorMessages = new StringBuilder();

        for (ErrorMessage errorMessage : errors) {
          String translatedErrorMessage =
              translationService.translate(
                  errorMessage.getMessage(), Locale.getDefault(), errorMessage.getVars());
          errorMessages.append(translatedErrorMessage);
          errorMessages.append(", ");
        }

        stateChangeContext.addValidationError(
            "orders.order.orderStates.error", errorMessages.toString());
      }
    }
  }
 public String generateName(final Entity product) {
   LocalDate date = LocalDate.now();
   String currentDateString = String.format("%s.%s", date.getYear(), date.getMonthValue());
   String productName = product.getStringField(ProductFields.NAME);
   String productNumber = product.getStringField(ProductFields.NUMBER);
   return translationService.translate(
       "technologies.operation.name.default",
       LocaleContextHolder.getLocale(),
       productName,
       productNumber,
       currentDateString);
 }
 @Override
 protected void addHeader(final HSSFSheet sheet, final Locale locale, final Entity entity) {
   HSSFRow header = sheet.createRow(0);
   HSSFCell cell0 = header.createCell(0);
   cell0.setCellValue(
       translationService.translate(
           "materialFlow.materialFlow.report.columnHeader.number", locale));
   xlsHelper.setCellStyle(sheet, cell0);
   HSSFCell cell1 = header.createCell(1);
   cell1.setCellValue(
       translationService.translate("materialFlow.materialFlow.report.columnHeader.name", locale));
   xlsHelper.setCellStyle(sheet, cell1);
   HSSFCell cell2 = header.createCell(2);
   cell2.setCellValue(
       translationService.translate(
           "materialFlow.materialFlow.report.columnHeader.quantity", locale));
   xlsHelper.setCellStyle(sheet, cell2);
   HSSFCell cell3 = header.createCell(3);
   cell3.setCellValue(
       translationService.translate("materialFlow.materialFlow.report.columnHeader.unit", locale));
   xlsHelper.setCellStyle(sheet, cell3);
 }
Beispiel #11
0
 @Override
 public String getDescription(Locale locale) {
   return translationService.translate(
       "workPlans.columnForOrders.description.value." + getIdentifier(), locale);
 }
 @Override
 public String getReportTitle(final Locale locale) {
   return translationService.translate("materialFlow.materialFlow.report.title", locale);
 }