コード例 #1
0
 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()
               + "}");
 }
コード例 #2
0
  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();
  }