@Override
  public void update(Listener lstnr) {

    //	System.out.println("Triggering the rules based on event updates");
    StudyEventBeanContainer studyEventBeanContainer = (StudyEventBeanContainer) lstnr;

    //	if (studyEventBeanContainer.getChangeDetails().getStartDateChanged() ||
    // studyEventBeanContainer.getChangeDetails().getStatusChanged()){

    Integer studyEventDefId = studyEventBeanContainer.getEvent().getStudyEventDefinitionId();
    //		Integer studySubjectId = studyEventBeanContainer.getEvent().getStudySubjectId();
    Integer userId = studyEventBeanContainer.getEvent().getUpdaterId();
    Integer studyEventOrdinal = studyEventBeanContainer.getEvent().getSampleOrdinal();
    if (userId == 0) userId = studyEventBeanContainer.getEvent().getOwnerId();
    StudyEventBean studyEvent = studyEventBeanContainer.getEvent();

    ArrayList<RuleSetBean> ruleSets = (ArrayList<RuleSetBean>) createRuleSet(studyEventDefId);
    for (RuleSetBean ruleSet : ruleSets) {
      ArrayList<RuleSetBean> ruleSetBeans = new ArrayList();
      ExpressionBean eBean = new ExpressionBean();
      eBean.setValue(ruleSet.getTarget().getValue() + ".A.B");
      ruleSet.setTarget(eBean);
      ruleSet.addExpression(getRuleSetService().replaceSEDOrdinal(ruleSet.getTarget(), studyEvent));
      ruleSetBeans.add(ruleSet);

      // for (RuleSetBean ruleSet : ruleSetBeans){
      String targetProperty =
          ruleSet.getTarget().getValue().substring(ruleSet.getTarget().getValue().indexOf("."));

      if ((targetProperty.contains(ExpressionService.STARTDATE + ".A.B")
              && studyEventBeanContainer.getChangeDetails().getStartDateChanged())
          || (targetProperty.contains(ExpressionService.STATUS + ".A.B")
              && studyEventBeanContainer.getChangeDetails().getStatusChanged())) {

        getRuleSetService()
            .runIndividualRulesInBeanProperty(
                ruleSetBeans,
                userId,
                studyEventBeanContainer.getChangeDetails(),
                studyEventOrdinal);
      }
    }
    //	}

  }
  @Override
  public void onApplicationEvent(final OnStudyEventUpdated event) {

    LOGGER.debug("listening");
    if (event.getContainer().getChangeDetails().getStartDateChanged()
        || event.getContainer().getChangeDetails().getStatusChanged()) {

      StudyEvent studyEvent = event.getContainer().getEvent();

      Integer studyEventDefId = studyEvent.getStudyEventDefinition().getStudyEventDefinitionId();
      Integer studyEventOrdinal = studyEvent.getSampleOrdinal();
      //	Integer studySubjectId =
      // event.getContainer().getEvent().getStudySubject().getStudySubjectId();
      Integer userId = studyEvent.getUpdateId();

      if (userId == null && studyEvent.getUserAccount() != null)
        userId = studyEvent.getUserAccount().getUserId();

      StudyEventBean studyEventBean = new StudyEventBean();
      studyEventBean.setId(studyEvent.getStudyEventId());

      ArrayList<RuleSetBean> ruleSets = (ArrayList<RuleSetBean>) createRuleSet(studyEventDefId);
      for (RuleSetBean ruleSet : ruleSets) {
        ArrayList<RuleSetBean> ruleSetBeans = new ArrayList();
        ExpressionBean eBean = new ExpressionBean();
        eBean.setValue(ruleSet.getTarget().getValue() + ".A.B");
        ruleSet.setTarget(eBean);
        ruleSet.addExpression(
            getRuleSetService().replaceSEDOrdinal(ruleSet.getTarget(), studyEventBean));
        ruleSetBeans.add(ruleSet);

        getRuleSetService()
            .runIndividualRulesInBeanProperty(
                ruleSetBeans, userId, event.getContainer().getChangeDetails(), studyEventOrdinal);
      }

      //  	  }
    }
  }