Пример #1
0
  @SuppressWarnings("null")
  @Override
  public void notifyObservers(final Object arg) {
    TravelMvcWrapperBean wrapper = null;
    if (arg instanceof TravelMvcWrapperBean) {
      wrapper = (TravelMvcWrapperBean) arg;
    } else if (arg instanceof Object[]) {
      final Object[] args = (Object[]) arg;
      if (args != null && args.length > 0 && args[0] instanceof TravelMvcWrapperBean) {
        wrapper = (TravelMvcWrapperBean) args[0];
      }
    }

    final String eventName = wrapper.getMethodToCall();
    for (final Observer observer : getObservers().get(eventName)) {
      observer.update(this, arg);
    }
    clearChanged();
  }
  @Override
  public void update(Observable arg0, Object arg1) {
    if (!(arg1 instanceof TravelMvcWrapperBean)) {
      return;
    }
    TravelMvcWrapperBean wrapper = (TravelMvcWrapperBean) arg1;

    boolean rulePassed = true;

    // check any business rules
    rulePassed &=
        getRuleService()
            .applyRules(
                new AddDistributionAccountingLineValidationEvent(
                    TemPropertyConstants.ACCOUNT_DISTRIBUTION_NEW_SRC_LINE,
                    wrapper.getTravelDocument(),
                    wrapper));

    if (rulePassed) {
      wrapper.addAccountDistributionsourceAccountingLine(
          wrapper.getAccountDistributionnewSourceLine());
    }
  }