use of org.akaza.openclinica.service.rule.expression.ExpressionBeanService in project OpenClinica by OpenClinica.
the class BeanPropertyService method runAction.
/**
* Complete adding to this Service to evaluate Event action
* @param ruleActionBean
* @param eow
* @param isTransaction
*/
public void runAction(RuleActionBean ruleActionBean, ExpressionBeanObjectWrapper eow, Integer userId, Boolean isTransaction) {
boolean statusMatch = false;
OpenClinicaExpressionParser oep = new OpenClinicaExpressionParser(eow);
ExpressionBeanService ebs = new ExpressionBeanService(eow);
StudyEvent studyEvent = ebs.getStudyEventFromOID(((EventActionBean) ruleActionBean).getOc_oid_reference());
RuleActionRunBean runOnStatuses = ruleActionBean.getRuleActionRun();
if (studyEvent != null) {
switch(SubjectEventStatus.getByCode(studyEvent.getSubjectEventStatusId())) {
case NOT_SCHEDULED:
if (runOnStatuses.getNot_started())
statusMatch = true;
break;
case SCHEDULED:
if (runOnStatuses.getScheduled())
statusMatch = true;
break;
case DATA_ENTRY_STARTED:
if (runOnStatuses.getData_entry_started())
statusMatch = true;
break;
case COMPLETED:
if (runOnStatuses.getComplete())
statusMatch = true;
break;
case SKIPPED:
if (runOnStatuses.getSkipped())
statusMatch = true;
break;
case STOPPED:
if (runOnStatuses.getStopped())
statusMatch = true;
break;
case SIGNED:
case LOCKED:
default:
statusMatch = false;
break;
}
} else // Special case if destination study event doesn't exist yet, ie not scheduled.
{
if (runOnStatuses.getNot_started())
statusMatch = true;
}
if (statusMatch) {
for (PropertyBean propertyBean : ((EventActionBean) ruleActionBean).getProperties()) {
// This will execute the contents of <ValueExpression>SS.ENROLLMENT_DATE + 2</ValueExpression>
LOGGER.debug("Values:expression??::" + propertyBean.getValueExpression().getValue());
Object result = oep.parseAndEvaluateExpression(propertyBean.getValueExpression().getValue());
executeAction(result, propertyBean, eow, (EventActionBean) ruleActionBean, userId, isTransaction);
}
}
}
Aggregations