Search in sources :

Example 1 with EmailActionBean

use of org.akaza.openclinica.bean.rule.action.EmailActionBean 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 2 with EmailActionBean

use of org.akaza.openclinica.bean.rule.action.EmailActionBean 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

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