Search in sources :

Example 21 with RuleSetBean

use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.

the class RuleSetService method solidifyGroupOrdinalsUsingFormProperties.

/*
     * (non-Javadoc)
     * @see org.akaza.openclinica.service.rule.RuleSetServiceInterface#solidifyGroupOrdinalsUsingFormProperties(java.util.List, java.util.HashMap)
     */
public List<RuleSetBean> solidifyGroupOrdinalsUsingFormProperties(List<RuleSetBean> ruleSets, HashMap<String, Integer> grouped) {
    for (RuleSetBean ruleSet : ruleSets) {
        ArrayList<ExpressionBean> expressionsWithCorrectGroupOrdinal = new ArrayList<ExpressionBean>();
        for (ExpressionBean expression : ruleSet.getExpressions()) {
            logger.debug("solidifyGroupOrdinals: Expression Value : " + expression.getValue());
            String groupOIDConcatItemOID = getExpressionService().getGroupOidConcatWithItemOid(expression.getValue());
            String itemOID = getExpressionService().getItemOid(expression.getValue());
            String groupOrdinal = getExpressionService().getGroupOrdninalCurated(expression.getValue());
            if (grouped.containsKey(groupOIDConcatItemOID) && groupOrdinal.equals("")) {
                for (int i = 0; i < grouped.get(groupOIDConcatItemOID); i++) {
                    ExpressionBean expBean = new ExpressionBean();
                    expBean.setValue(getExpressionService().replaceGroupOidOrdinalInExpression(expression.getValue(), i + 1));
                    expBean.setContext(expression.getContext());
                    expressionsWithCorrectGroupOrdinal.add(expBean);
                }
            } else if (grouped.containsKey(groupOIDConcatItemOID) && !groupOrdinal.equals("")) {
                ExpressionBean expBean = new ExpressionBean();
                expBean.setValue(expression.getValue());
                expBean.setContext(expression.getContext());
                expressionsWithCorrectGroupOrdinal.add(expBean);
            } else if (grouped.containsKey(itemOID)) {
                ExpressionBean expBean = new ExpressionBean();
                expBean.setValue(getExpressionService().replaceGroupOidOrdinalInExpression(expression.getValue(), null));
                expBean.setContext(expression.getContext());
                expressionsWithCorrectGroupOrdinal.add(expBean);
            }
        }
        ruleSet.setExpressions(expressionsWithCorrectGroupOrdinal);
        for (ExpressionBean expressionBean : ruleSet.getExpressions()) {
            logger.debug("expressionBean value : {} ", expressionBean.getValue());
        }
    }
    return ruleSets;
}
Also used : ArrayList(java.util.ArrayList) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) ExpressionBean(org.akaza.openclinica.domain.rule.expression.ExpressionBean)

Example 22 with RuleSetBean

use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.

the class RuleSetAuditDaoTest method testFindAllByRuleSet.

public void testFindAllByRuleSet() {
    //RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
    // RuleSetAuditDao ruleSetAuditDao = (RuleSetAuditDao) getContext().getBean("ruleSetAuditDao");
    RuleSetBean ruleSet = ruleSetDao.findById(-1);
    List<RuleSetAuditBean> ruleSetAudits = ruleSetAuditDao.findAllByRuleSet(ruleSet);
    assertNotNull("ruleSetAudits is null", ruleSetAudits);
    assertEquals("The size of the ruleSetAudits is not 2", new Integer(2), Integer.valueOf(ruleSetAudits.size()));
}
Also used : RuleSetAuditBean(org.akaza.openclinica.domain.rule.RuleSetAuditBean) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean)

Example 23 with RuleSetBean

use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.

the class RuleSetRuleAuditDaoTest method testFindAllByRuleSet.

public void testFindAllByRuleSet() {
    //   RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
    //   RuleSetRuleAuditDao ruleSetRuleAuditDao = (RuleSetRuleAuditDao) getContext().getBean("ruleSetRuleAuditDao");
    RuleSetBean ruleSet = ruleSetDao.findById(-1);
    List<RuleSetRuleAuditBean> ruleSetRuleAudits = ruleSetRuleAuditDao.findAllByRuleSet(ruleSet);
    assertNotNull("ruleSetAudits is null", ruleSetRuleAudits);
    assertEquals("The size of the ruleSetRuleAudits is not 2", new Integer(2), Integer.valueOf(ruleSetRuleAudits.size()));
}
Also used : RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) RuleSetRuleAuditBean(org.akaza.openclinica.domain.rule.RuleSetRuleAuditBean)

Example 24 with RuleSetBean

use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.

the class RuleSetDaoTest method testSaveOrUpdate.

public void testSaveOrUpdate() {
    // RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
    //   RuleDao ruleDao = (RuleDao) getContext().getBean("ruleDao");
    RuleBean persistantRuleBean = ruleDao.findById(1);
    RuleSetBean ruleSetBean = createStubRuleSetBean(persistantRuleBean);
    ruleSetBean = ruleSetDao.saveOrUpdate(ruleSetBean);
    assertNotNull("Persistant id is null", ruleSetBean.getId());
}
Also used : RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) RuleBean(org.akaza.openclinica.domain.rule.RuleBean)

Example 25 with RuleSetBean

use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.

the class RuleSetDaoTest method testFindByExpression.

public void testFindByExpression() {
    RuleSetBean ruleSet = createStubRuleSetBean();
    //   RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
    RuleSetBean persistentRuleSet = ruleSetDao.findByExpression(ruleSet);
    assertNotNull("The returned ruleSet was null", persistentRuleSet);
    assertEquals("The id of returned object should be -1 ", persistentRuleSet.getId(), new Integer(-1));
}
Also used : RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean)

Aggregations

RuleSetBean (org.akaza.openclinica.domain.rule.RuleSetBean)67 ArrayList (java.util.ArrayList)28 RuleSetRuleBean (org.akaza.openclinica.domain.rule.RuleSetRuleBean)26 ExpressionBean (org.akaza.openclinica.domain.rule.expression.ExpressionBean)19 RuleBean (org.akaza.openclinica.domain.rule.RuleBean)15 HashMap (java.util.HashMap)13 ExpressionObjectWrapper (org.akaza.openclinica.domain.rule.expression.ExpressionObjectWrapper)11 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)9 RuleActionBean (org.akaza.openclinica.domain.rule.action.RuleActionBean)9 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)8 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)7 Map (java.util.Map)6 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)6 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)6 OpenClinicaExpressionParser (org.akaza.openclinica.logic.expressionTree.OpenClinicaExpressionParser)6 StudyEventBean (org.akaza.openclinica.bean.managestudy.StudyEventBean)5 CRFVersionBean (org.akaza.openclinica.bean.submit.CRFVersionBean)5 RulesPostImportContainer (org.akaza.openclinica.domain.rule.RulesPostImportContainer)5 RuleActionRunLogBean (org.akaza.openclinica.domain.rule.action.RuleActionRunLogBean)5 Locale (java.util.Locale)4