Search in sources :

Example 1 with ExecutionMode

use of org.akaza.openclinica.logic.rulerunner.ExecutionMode in project OpenClinica by OpenClinica.

the class RuleSetService method runRulesInDataEntry.

/*
     * (non-Javadoc)
     * @see org.akaza.openclinica.service.rule.RuleSetServiceInterface#runRulesInDataEntry(java.util.List, java.lang.Boolean,
     * org.akaza.openclinica.bean.managestudy.StudyBean, org.akaza.openclinica.bean.login.UserAccountBean, java.util.HashMap)
     */
public MessageContainer runRulesInDataEntry(List<RuleSetBean> ruleSets, Boolean dryRun, StudyBean currentStudy, UserAccountBean ub, HashMap<String, String> variableAndValue, Phase phase, EventCRFBean ecb, HttpServletRequest request) {
    DataEntryRuleRunner ruleRunner = new DataEntryRuleRunner(dataSource, requestURLMinusServletPath, contextPath, mailSender, ecb);
    dynamicsMetadataService.setExpressionService(getExpressionService());
    ruleRunner.setDynamicsMetadataService(dynamicsMetadataService);
    ruleRunner.setRuleActionRunLogDao(ruleActionRunLogDao);
    // TODO: KK return the new object && Pass in the Execution Mode
    ExecutionMode executionMode = dryRun == true ? ExecutionMode.DRY_RUN : ExecutionMode.SAVE;
    return ruleRunner.runRules(ruleSets, executionMode, currentStudy, variableAndValue, ub, phase, request);
// return new HashMap<String, ArrayList<String>>();
// return runRules(ruleSets, dryRun, currentStudy, c.variableAndValue, ub);
}
Also used : DataEntryRuleRunner(org.akaza.openclinica.logic.rulerunner.DataEntryRuleRunner) ExecutionMode(org.akaza.openclinica.logic.rulerunner.ExecutionMode)

Example 2 with ExecutionMode

use of org.akaza.openclinica.logic.rulerunner.ExecutionMode in project OpenClinica by OpenClinica.

the class RuleSetService method runRulesInBulk.

/*
     * (non-Javadoc)
     * @see org.akaza.openclinica.service.rule.RuleSetServiceInterface#runRulesInBulk(java.util.List, java.lang.Boolean,
     * org.akaza.openclinica.bean.managestudy.StudyBean, org.akaza.openclinica.bean.login.UserAccountBean)
     */
public List<RuleSetBasedViewContainer> runRulesInBulk(List<RuleSetBean> ruleSets, Boolean dryRun, StudyBean currentStudy, UserAccountBean ub, boolean jobTrigger) {
    ruleSets = filterByStatusEqualsAvailable(ruleSets);
    ruleSets = filterRuleSetsByStudyEventOrdinal(ruleSets, null);
    if (jobTrigger) {
        try {
            ruleSets = filterRuleSetsByStudySubject(ruleSets);
        } catch (NumberFormatException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ParseException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    ruleSets = filterRuleSetsByGroupOrdinal(ruleSets);
    RuleSetBulkRuleRunner ruleRunner = new RuleSetBulkRuleRunner(dataSource, requestURLMinusServletPath, contextPath, mailSender);
    dynamicsMetadataService.setExpressionService(getExpressionService());
    ruleRunner.setDynamicsMetadataService(dynamicsMetadataService);
    ruleRunner.setRuleActionRunLogDao(ruleActionRunLogDao);
    ExecutionMode executionMode = dryRun == true ? ExecutionMode.DRY_RUN : ExecutionMode.SAVE;
    System.out.println("in runRulesinBulk method");
    return ruleRunner.runRulesBulkFromRuleSetScreen(ruleSets, executionMode, currentStudy, null, ub);
// return runRulesBulkFromRuleSetScreen(ruleSets, dryRun, currentStudy, null, ub);
}
Also used : RuleSetBulkRuleRunner(org.akaza.openclinica.logic.rulerunner.RuleSetBulkRuleRunner) ExecutionMode(org.akaza.openclinica.logic.rulerunner.ExecutionMode) ParseException(java.text.ParseException)

Example 3 with ExecutionMode

use of org.akaza.openclinica.logic.rulerunner.ExecutionMode in project OpenClinica by OpenClinica.

the class RunRuleServlet method processRequest.

@Override
public void processRequest() throws Exception {
    String action = request.getParameter("action");
    String crfId = request.getParameter("crfId");
    String ruleSetRuleId = request.getParameter("ruleSetRuleId");
    String versionId = request.getParameter("versionId");
    if (StringUtil.isBlank(action)) {
        // TODO : if someone tampers with URL catch here and forwar to correct place
        forwardPage(Page.MENU_SERVLET);
    }
    // Boolean dryRun = action == null || "dryRun".equalsIgnoreCase(action) ? true : false;
    ExecutionMode executionMode = action == null || "dryRun".equalsIgnoreCase(action) ? ExecutionMode.DRY_RUN : ExecutionMode.SAVE;
    String submitLinkParams = "";
    HashMap<RuleBulkExecuteContainer, HashMap<RuleBulkExecuteContainerTwo, Set<String>>> result = null;
    if (ruleSetRuleId != null && versionId != null) {
        submitLinkParams = "ruleSetRuleId=" + ruleSetRuleId + "&versionId=" + versionId + "&action=no";
        result = getRuleSetService().runRulesInBulk(ruleSetRuleId, versionId, executionMode, currentStudy, ub);
    } else {
        submitLinkParams = "crfId=" + crfId + "&action=no";
        result = getRuleSetService().runRulesInBulk(crfId, executionMode, currentStudy, ub);
    }
    request.setAttribute("result", result);
    request.setAttribute("submitLinkParams", submitLinkParams);
    if (executionMode == ExecutionMode.SAVE) {
        forwardPage(Page.LIST_RULE_SETS_SERVLET);
    } else {
        forwardPage(Page.VIEW_EXECUTED_RULES_FROM_CRF);
    }
}
Also used : HashMap(java.util.HashMap) ExecutionMode(org.akaza.openclinica.logic.rulerunner.ExecutionMode) RuleBulkExecuteContainer(org.akaza.openclinica.domain.rule.RuleBulkExecuteContainer)

Aggregations

ExecutionMode (org.akaza.openclinica.logic.rulerunner.ExecutionMode)3 ParseException (java.text.ParseException)1 HashMap (java.util.HashMap)1 RuleBulkExecuteContainer (org.akaza.openclinica.domain.rule.RuleBulkExecuteContainer)1 DataEntryRuleRunner (org.akaza.openclinica.logic.rulerunner.DataEntryRuleRunner)1 RuleSetBulkRuleRunner (org.akaza.openclinica.logic.rulerunner.RuleSetBulkRuleRunner)1