Beispiel #1
0
  @Override
  public void registerDeliveryDayHandler(final IDeliveryDayHandler handler) {
    Check.assumeNotNull(handler, "handler not null");
    deliveryDayHandlers.addDeliveryDayHandler(handler);

    if (handler instanceof IDeliveryDayCreateHandler) {
      final IDeliveryDayCreateHandler createHandler = (IDeliveryDayCreateHandler) handler;
      final DeliveryDayAllocableInterceptor interceptor =
          new DeliveryDayAllocableInterceptor(createHandler);
      final DeliveryDayAllocableInterceptor interceptorOld =
          tableName2deliveryDayAllocableInteceptor.get(interceptor.getModelTableName());
      if (interceptorOld != null) {
        throw new AdempiereException(
            "Cannot register create handler interceptor '"
                + interceptor
                + " because an old one was already registered: "
                + interceptorOld);
      }

      Services.get(IModelInterceptorRegistry.class).addModelInterceptor(interceptor);
    }
  }
Beispiel #2
0
  private I_M_DeliveryDay_Alloc createDeliveryDayAlloc(
      final IContextAware context,
      final I_M_DeliveryDay deliveryDay,
      final IDeliveryDayAllocable deliveryDayAllocable) {
    Check.assume(
        !deliveryDay.isProcessed(), "Delivery day shall not be processed: {0}", deliveryDay);

    final String tableName = deliveryDayAllocable.getTableName();
    final int adTableId = Services.get(IADTableDAO.class).retrieveTableId(tableName);

    final I_M_DeliveryDay_Alloc deliveryDayAlloc =
        InterfaceWrapperHelper.newInstance(I_M_DeliveryDay_Alloc.class, context);
    deliveryDayAlloc.setAD_Org_ID(deliveryDayAllocable.getAD_Org_ID());
    deliveryDayAlloc.setM_DeliveryDay(deliveryDay);
    deliveryDayAlloc.setAD_Table_ID(adTableId);
    deliveryDayAlloc.setRecord_ID(deliveryDayAllocable.getRecord_ID());
    deliveryDayAlloc.setM_Product_ID(deliveryDayAllocable.getM_Product_ID());

    deliveryDayHandlers.updateDeliveryDayAllocFromModel(deliveryDayAlloc, deliveryDayAllocable);

    InterfaceWrapperHelper.save(deliveryDayAlloc);

    return deliveryDayAlloc;
  }