Search in sources :

Example 16 with ExpressionBean

use of org.akaza.openclinica.domain.rule.expression.ExpressionBean in project OpenClinica by OpenClinica.

the class RulesPostImportContainerService method isRuleSetExpressionValid.

private boolean isRuleSetExpressionValid(AuditableBeanWrapper<RuleSetBean> beanWrapper) {
    boolean isValid = true;
    ExpressionBean expressionBean = isExpressionValid(beanWrapper.getAuditableBean().getTarget(), beanWrapper);
    ExpressionObjectWrapper eow = new ExpressionObjectWrapper(ds, currentStudy, expressionBean, ExpressionObjectWrapper.CONTEXT_TARGET);
    ExpressionProcessor ep = ExpressionProcessorFactory.createExpressionProcessor(eow);
    ep.setRespage(respage);
    String errorString = ep.isRuleAssignmentExpressionValid();
    if (errorString != null) {
        beanWrapper.error(errorString);
        isValid = false;
    }
    return isValid;
}
Also used : ExpressionProcessor(org.akaza.openclinica.domain.rule.expression.ExpressionProcessor) ExpressionObjectWrapper(org.akaza.openclinica.domain.rule.expression.ExpressionObjectWrapper) ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean)

Example 17 with ExpressionBean

use of org.akaza.openclinica.domain.rule.expression.ExpressionBean in project OpenClinica by OpenClinica.

the class StudyEventBeanListener method update.

@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);
        }
    }
//	}
}
Also used : ArrayList(java.util.ArrayList) StudyEventBean(org.akaza.openclinica.bean.managestudy.StudyEventBean) StudyEventBeanContainer(org.akaza.openclinica.patterns.ocobserver.StudyEventBeanContainer) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean)

Example 18 with ExpressionBean

use of org.akaza.openclinica.domain.rule.expression.ExpressionBean in project OpenClinica by OpenClinica.

the class RulesPostImportContainerService method isRuleExpressionValid.

private boolean isRuleExpressionValid(AuditableBeanWrapper<RuleBean> ruleBeanWrapper, RuleSetBean ruleSet) {
    boolean isValid = true;
    ExpressionBean expressionBean = isExpressionValid(ruleBeanWrapper.getAuditableBean().getExpression(), ruleBeanWrapper);
    ExpressionObjectWrapper eow = new ExpressionObjectWrapper(ds, currentStudy, expressionBean, ruleSet, ExpressionObjectWrapper.CONTEXT_EXPRESSION);
    ExpressionProcessor ep = ExpressionProcessorFactory.createExpressionProcessor(eow);
    ep.setRespage(respage);
    String errorString = ep.isRuleExpressionValid();
    if (errorString != null) {
        ruleBeanWrapper.error(errorString);
        isValid = false;
    }
    return isValid;
}
Also used : ExpressionProcessor(org.akaza.openclinica.domain.rule.expression.ExpressionProcessor) ExpressionObjectWrapper(org.akaza.openclinica.domain.rule.expression.ExpressionObjectWrapper) ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean)

Example 19 with ExpressionBean

use of org.akaza.openclinica.domain.rule.expression.ExpressionBean in project OpenClinica by OpenClinica.

the class RuleSetService method logExpressions.

private void logExpressions(List<RuleSetBean> validRuleSets) {
    if (logger.isDebugEnabled()) {
        for (RuleSetBean ruleSetBean : validRuleSets) {
            logger.debug("Expression : {} ", ruleSetBean.getTarget().getValue());
            List<ExpressionBean> expressions = ruleSetBean.getExpressions();
            if (expressions != null) {
                for (ExpressionBean expression : expressions) {
                    logger.debug("Expression post filtering SEDs : {} ", expression.getValue());
                }
            }
        }
    }
}
Also used : RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean)

Example 20 with ExpressionBean

use of org.akaza.openclinica.domain.rule.expression.ExpressionBean in project OpenClinica by OpenClinica.

the class RuleSetService method replaceSEDOrdinal.

private ExpressionBean replaceSEDOrdinal(ExpressionBean targetExpression, StudyEventBean studyEvent, String fullExpressionValue) {
    ExpressionBean expression = new ExpressionBean(targetExpression.getContext(), fullExpressionValue);
    expression.setValue(getExpressionService().replaceStudyEventDefinitionOIDWith(fullExpressionValue, String.valueOf(studyEvent.getId())));
    return expression;
}
Also used : ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean)

Aggregations

ExpressionBean (org.akaza.openclinica.domain.rule.expression.ExpressionBean)31 RuleSetBean (org.akaza.openclinica.domain.rule.RuleSetBean)19 ExpressionObjectWrapper (org.akaza.openclinica.domain.rule.expression.ExpressionObjectWrapper)14 ArrayList (java.util.ArrayList)13 RuleActionBean (org.akaza.openclinica.domain.rule.action.RuleActionBean)10 RuleSetRuleBean (org.akaza.openclinica.domain.rule.RuleSetRuleBean)9 RuleBean (org.akaza.openclinica.domain.rule.RuleBean)8 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)8 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)7 HashMap (java.util.HashMap)6 RuleActionRunLogBean (org.akaza.openclinica.domain.rule.action.RuleActionRunLogBean)6 OpenClinicaExpressionParser (org.akaza.openclinica.logic.expressionTree.OpenClinicaExpressionParser)6 ActionProcessor (org.akaza.openclinica.domain.rule.action.ActionProcessor)5 ExpressionProcessor (org.akaza.openclinica.domain.rule.expression.ExpressionProcessor)5 Map (java.util.Map)4 EventActionBean (org.akaza.openclinica.domain.rule.action.EventActionBean)4 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)3 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)3 NotificationActionBean (org.akaza.openclinica.domain.rule.action.NotificationActionBean)3 PropertyBean (org.akaza.openclinica.domain.rule.action.PropertyBean)3