Search in sources :

Example 6 with RuleActionBean

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

the class RuleActionDAO method findByPK.

public EntityBean findByPK(int ID) {
    RuleActionBean action = new RuleActionBean();
    this.setTypesExpected();
    HashMap<Integer, Object> variables = new HashMap<Integer, Object>();
    variables.put(new Integer(1), new Integer(ID));
    String sql = digester.getQuery("findByPK");
    ArrayList alist = this.select(sql, variables);
    Iterator it = alist.iterator();
    if (it.hasNext()) {
        action = this.getEntityFromHashMap((HashMap) it.next());
    }
    return action;
}
Also used : RuleActionBean(org.akaza.openclinica.bean.rule.action.RuleActionBean) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 7 with RuleActionBean

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

the class RuleActionDAO method findAll.

public Collection findAll() {
    this.setTypesExpected();
    ArrayList alist = this.select(digester.getQuery("findAll"));
    ArrayList<RuleActionBean> ruleSetBeans = new ArrayList<RuleActionBean>();
    Iterator it = alist.iterator();
    while (it.hasNext()) {
        RuleActionBean ruleSet = this.getEntityFromHashMap((HashMap) it.next());
        ruleSetBeans.add(ruleSet);
    }
    return ruleSetBeans;
}
Also used : RuleActionBean(org.akaza.openclinica.bean.rule.action.RuleActionBean) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator)

Example 8 with RuleActionBean

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

the class RuleActionDAO method create.

public EntityBean create(EntityBean eb) {
    HashMap<Integer, Object> variables = new HashMap<Integer, Object>();
    HashMap<Integer, Object> nullVars = new HashMap<Integer, Object>();
    RuleActionBean ruleAction = null;
    if (eb instanceof DiscrepancyNoteActionBean) {
        DiscrepancyNoteActionBean dnActionBean = (DiscrepancyNoteActionBean) eb;
        Boolean expressionEvaluates = dnActionBean.getExpressionEvaluatesTo() == null ? true : dnActionBean.getExpressionEvaluatesTo();
        variables.put(new Integer(1), new Integer(dnActionBean.getRuleSetRule().getId()));
        variables.put(new Integer(2), dnActionBean.getActionType().getCode());
        variables.put(new Integer(3), expressionEvaluates);
        variables.put(new Integer(4), dnActionBean.getMessage());
        variables.put(new Integer(5), new Integer(dnActionBean.getOwnerId()));
        variables.put(new Integer(6), new Integer(Status.AVAILABLE.getId()));
        executeWithPK(digester.getQuery("create_dn"), variables, nullVars);
        if (isQuerySuccessful()) {
            dnActionBean.setId(getLatestPK());
        }
        ruleAction = dnActionBean;
    }
    if (eb instanceof EmailActionBean) {
        EmailActionBean emailActionBean = (EmailActionBean) eb;
        Boolean expressionEvaluates = emailActionBean.getExpressionEvaluatesTo() == null ? true : emailActionBean.getExpressionEvaluatesTo();
        variables.put(new Integer(1), new Integer(emailActionBean.getRuleSetRule().getId()));
        variables.put(new Integer(2), emailActionBean.getActionType().getCode());
        variables.put(new Integer(3), expressionEvaluates);
        variables.put(new Integer(4), emailActionBean.getMessage());
        variables.put(new Integer(5), emailActionBean.getTo());
        variables.put(new Integer(6), new Integer(emailActionBean.getOwnerId()));
        variables.put(new Integer(7), new Integer(Status.AVAILABLE.getId()));
        executeWithPK(digester.getQuery("create_email"), variables, nullVars);
        if (isQuerySuccessful()) {
            emailActionBean.setId(getLatestPK());
        }
        ruleAction = emailActionBean;
    }
    return ruleAction;
}
Also used : RuleActionBean(org.akaza.openclinica.bean.rule.action.RuleActionBean) DiscrepancyNoteActionBean(org.akaza.openclinica.bean.rule.action.DiscrepancyNoteActionBean) HashMap(java.util.HashMap) EmailActionBean(org.akaza.openclinica.bean.rule.action.EmailActionBean)

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