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;
}
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);
}
}
// }
}
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;
}
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());
}
}
}
}
}
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;
}
Aggregations