Search in sources :

Example 1 with RuleActionBean

use of org.akaza.openclinica.bean.rule.action.RuleActionBean in project OpenClinica by OpenClinica.

the class RuleSetRuleBean method getAllActionsWithEvaluatesToAsKey.

public HashMap<String, ArrayList<RuleActionBean>> getAllActionsWithEvaluatesToAsKey(String actionEvaluatesTo) {
    HashMap<String, ArrayList<RuleActionBean>> h = new HashMap<String, ArrayList<RuleActionBean>>();
    for (RuleActionBean action : actions) {
        String key = action.getExpressionEvaluatesTo().toString();
        if (actionEvaluatesTo == null || actionEvaluatesTo.equals(key)) {
            if (h.containsKey(key)) {
                h.get(key).add(action);
            } else {
                ArrayList<RuleActionBean> a = new ArrayList<RuleActionBean>();
                a.add(action);
                h.put(key, a);
            }
        }
    }
    return h;
}
Also used : RuleActionBean(org.akaza.openclinica.bean.rule.action.RuleActionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 2 with RuleActionBean

use of org.akaza.openclinica.bean.rule.action.RuleActionBean in project OpenClinica by OpenClinica.

the class RuleSetRuleBean method getAllActionsWithEvaluatesToAsKey.

public HashMap<String, ArrayList<RuleActionBean>> getAllActionsWithEvaluatesToAsKey() {
    HashMap<String, ArrayList<RuleActionBean>> h = new HashMap<String, ArrayList<RuleActionBean>>();
    for (RuleActionBean action : actions) {
        String key = action.getExpressionEvaluatesTo().toString();
        if (h.containsKey(key)) {
            h.get(key).add(action);
        } else {
            ArrayList<RuleActionBean> a = new ArrayList<RuleActionBean>();
            a.add(action);
            h.put(key, a);
        }
    }
    return h;
}
Also used : RuleActionBean(org.akaza.openclinica.bean.rule.action.RuleActionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 3 with RuleActionBean

use of org.akaza.openclinica.bean.rule.action.RuleActionBean in project OpenClinica by OpenClinica.

the class RuleActionDAO method findByRuleSetRule.

public ArrayList<RuleActionBean> findByRuleSetRule(RuleSetRuleBean ruleSetRule) {
    this.setTypesExpected();
    HashMap<Integer, Object> variables = new HashMap<Integer, Object>();
    Integer ruleSetRuleId = Integer.valueOf(ruleSetRule.getId());
    variables.put(new Integer(1), ruleSetRuleId);
    String sql = digester.getQuery("findByRuleSetRule");
    ArrayList<?> alist = this.select(sql, variables);
    ArrayList<RuleActionBean> ruleActionBeans = new ArrayList<RuleActionBean>();
    Iterator<?> it = alist.iterator();
    while (it.hasNext()) {
        RuleActionBean ruleActionBean = this.getEntityFromHashMap((HashMap<?, ?>) it.next());
        ruleActionBean.setRuleSetRule(ruleSetRule);
        ruleActionBeans.add(ruleActionBean);
    }
    return ruleActionBeans;
}
Also used : RuleActionBean(org.akaza.openclinica.bean.rule.action.RuleActionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Example 4 with RuleActionBean

use of org.akaza.openclinica.bean.rule.action.RuleActionBean in project OpenClinica by OpenClinica.

the class RuleActionDAO method getEntityFromHashMap.

public RuleActionBean getEntityFromHashMap(HashMap hm) {
    int actionTypeId = ((Integer) hm.get("action_type")).intValue();
    ActionType actionType = ActionType.getByCode(actionTypeId);
    RuleActionBean ruleAction = null;
    switch(actionType) {
        case FILE_DISCREPANCY_NOTE:
            ruleAction = new DiscrepancyNoteActionBean();
            ((DiscrepancyNoteActionBean) ruleAction).setMessage(((String) hm.get("message")));
        case EMAIL:
            ruleAction = new EmailActionBean();
            ((EmailActionBean) ruleAction).setMessage(((String) hm.get("message")));
            ((EmailActionBean) ruleAction).setTo(((String) hm.get("email_to")));
    }
    this.setEntityAuditInformation(ruleAction, hm);
    ruleAction.setActionType(actionType);
    ruleAction.setId(((Integer) hm.get("rule_action_id")).intValue());
    ruleAction.setExpressionEvaluatesTo(((Boolean) hm.get("expression_evaluates_to")).booleanValue());
    return ruleAction;
}
Also used : RuleActionBean(org.akaza.openclinica.bean.rule.action.RuleActionBean) DiscrepancyNoteActionBean(org.akaza.openclinica.bean.rule.action.DiscrepancyNoteActionBean) ActionType(org.akaza.openclinica.bean.rule.action.ActionType) EmailActionBean(org.akaza.openclinica.bean.rule.action.EmailActionBean)

Example 5 with RuleActionBean

use of org.akaza.openclinica.bean.rule.action.RuleActionBean in project OpenClinica by OpenClinica.

the class RuleSetRuleBean method getActionsAsKeyPair.

public HashMap<String, ArrayList<String>> getActionsAsKeyPair(String actionEvaluatesTo) {
    HashMap<String, ArrayList<String>> h = new HashMap<String, ArrayList<String>>();
    for (RuleActionBean action : actions) {
        String key = action.getExpressionEvaluatesTo().toString();
        if (actionEvaluatesTo.equals(key)) {
            if (h.containsKey(key)) {
                h.get(key).add(action.getSummary());
            } else {
                ArrayList<String> a = new ArrayList<String>();
                a.add(action.getSummary());
                h.put(key, a);
            }
        }
    }
    return h;
}
Also used : RuleActionBean(org.akaza.openclinica.bean.rule.action.RuleActionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList)

Aggregations

RuleActionBean (org.akaza.openclinica.bean.rule.action.RuleActionBean)8 ArrayList (java.util.ArrayList)6 HashMap (java.util.HashMap)6 Iterator (java.util.Iterator)2 DiscrepancyNoteActionBean (org.akaza.openclinica.bean.rule.action.DiscrepancyNoteActionBean)2 EmailActionBean (org.akaza.openclinica.bean.rule.action.EmailActionBean)2 ActionType (org.akaza.openclinica.bean.rule.action.ActionType)1