use of org.akaza.openclinica.domain.rule.RuleSetRuleBean in project OpenClinica by OpenClinica.
the class Key method runRulesBulkOLD.
@Deprecated
public HashMap<RuleBulkExecuteContainer, HashMap<RuleBulkExecuteContainerTwo, Set<String>>> runRulesBulkOLD(List<RuleSetBean> ruleSets, ExecutionMode executionMode, StudyBean currentStudy, HashMap<String, String> variableAndValue, UserAccountBean ub) {
if (variableAndValue == null || variableAndValue.isEmpty()) {
logger.warn("You must be executing Rules in Batch");
variableAndValue = new HashMap<String, String>();
}
HashMap<RuleBulkExecuteContainer, HashMap<RuleBulkExecuteContainerTwo, Set<String>>> crfViewSpecificOrderedObjects = new HashMap<RuleBulkExecuteContainer, HashMap<RuleBulkExecuteContainerTwo, Set<String>>>();
for (RuleSetBean ruleSet : ruleSets) {
for (ExpressionBean expressionBean : ruleSet.getExpressions()) {
ruleSet.setTarget(expressionBean);
for (RuleSetRuleBean ruleSetRule : ruleSet.getRuleSetRules()) {
String result = null;
RuleBean rule = ruleSetRule.getRuleBean();
ExpressionObjectWrapper eow = new ExpressionObjectWrapper(ds, currentStudy, rule.getExpression(), ruleSet, variableAndValue);
try {
OpenClinicaExpressionParser oep = new OpenClinicaExpressionParser(eow);
result = (String) oep.parseAndEvaluateExpression(rule.getExpression().getValue());
// Actions
List<RuleActionBean> actionListBasedOnRuleExecutionResult = ruleSetRule.getActions(result, Phase.BATCH);
ItemDataBean itemData = getExpressionService().getItemDataBeanFromDb(ruleSet.getTarget().getValue());
if (itemData != null) {
Iterator<RuleActionBean> itr = actionListBasedOnRuleExecutionResult.iterator();
while (itr.hasNext()) {
RuleActionBean ruleActionBean = itr.next();
RuleActionRunLogBean ruleActionRunLog = new RuleActionRunLogBean(ruleActionBean.getActionType(), itemData, itemData.getValue(), ruleSetRule.getRuleBean().getOid());
if (getRuleActionRunLogDao().findCountByRuleActionRunLogBean(ruleActionRunLog) > 0) {
itr.remove();
}
}
}
List<RuleActionBean> actionBeansToShow = new ArrayList<RuleActionBean>();
if (actionListBasedOnRuleExecutionResult.size() > 0) {
//if (!dryRun) {
for (RuleActionBean ruleAction : actionListBasedOnRuleExecutionResult) {
ruleAction.setCuratedMessage(curateMessage(ruleAction, ruleSetRule));
// getDiscrepancyNoteService().saveFieldNotes(ruleAction.getSummary(), itemDataBeanId, "ItemData", currentStudy, ub);
ActionProcessor ap = ActionProcessorFacade.getActionProcessor(ruleAction.getActionType(), ds, getMailSender(), dynamicsMetadataService, ruleSet, getRuleActionRunLogDao(), ruleSetRule);
RuleActionBean rab = ap.execute(RuleRunnerMode.RULSET_BULK, executionMode, ruleAction, itemData, DiscrepancyNoteBean.ITEM_DATA, currentStudy, ub, prepareEmailContents(ruleSet, ruleSetRule, currentStudy, ruleAction));
if (rab != null) {
actionBeansToShow.add(ruleAction);
}
}
if (actionBeansToShow.size() > 0) {
crfViewSpecificOrderedObjects = populateForCrfBasedRulesView(crfViewSpecificOrderedObjects, ruleSet, rule, result, currentStudy, actionBeansToShow);
}
}
} catch (OpenClinicaSystemException osa) {
String errorMessage = "RuleSet with target : " + ruleSet.getTarget().getValue() + " , Ran Rule : " + rule.getName() + " , It resulted in an error due to : " + osa.getMessage();
// log error
logger.warn(errorMessage);
}
}
}
}
logCrfViewSpecificOrderedObjects(crfViewSpecificOrderedObjects);
return crfViewSpecificOrderedObjects;
}
use of org.akaza.openclinica.domain.rule.RuleSetRuleBean in project OpenClinica by OpenClinica.
the class ViewCRFServlet method createFromRuleSet.
private List<TableColumnHolder> createFromRuleSet(RuleSetBean ruleSet, FormLayoutBean version) {
List<TableColumnHolder> tchs = new ArrayList<TableColumnHolder>();
for (RuleSetRuleBean ruleSetRule : ruleSet.getRuleSetRules()) {
String ruleExpression = ruleSetRule.getRuleBean().getExpression().getValue();
String ruleName = ruleSetRule.getRuleBean().getName();
TableColumnHolder tch = new TableColumnHolder(version.getName(), version.getId(), ruleName, ruleExpression, ruleSetRule.getActions(), ruleSetRule.getId());
tchs.add(tch);
}
return tchs;
}
use of org.akaza.openclinica.domain.rule.RuleSetRuleBean in project OpenClinica by OpenClinica.
the class RemoveRuleSetServlet method processRequest.
@Override
public void processRequest() throws Exception {
String ruleSetId = request.getParameter(RULESET_ID);
String action = request.getParameter(ACTION);
if (ruleSetId == null) {
addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
forwardPage(Page.CRF_LIST);
} else {
RuleSetBean ruleSetBean = null;
ruleSetBean = getRuleSetService().getRuleSetById(currentStudy, ruleSetId);
if (action != null && action.equals("confirm")) {
request.setAttribute(RULESET, ruleSetBean);
forwardPage(Page.REMOVE_RULE_SET);
} else {
for (RuleSetRuleBean ruleSetRuleBean : ruleSetBean.getRuleSetRules()) {
if (ruleSetRuleBean.getStatus() != Status.DELETED) {
ruleSetRuleBean.setStatus(Status.DELETED);
ruleSetRuleBean.setUpdater(ub);
ruleSetRuleBean = getRuleSetRuleDao().saveOrUpdate(ruleSetRuleBean);
createRuleSetRuleAuditBean(ruleSetRuleBean, ub, Status.DELETED);
}
}
forwardPage(Page.LIST_RULE_SETS_SERVLET);
}
}
}
Aggregations