Search in sources :

Example 11 with RuleBean

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

the class RuleController method create.

@RequestMapping(value = "/studies/{study}/validateRule", method = RequestMethod.POST)
@ResponseBody
public Response create(@RequestBody org.openclinica.ns.rules.v31.Rules rules, Model model, HttpSession session, @PathVariable("study") String studyOid) throws Exception {
    ResourceBundleProvider.updateLocale(new Locale("en_US"));
    RulesPostImportContainer rpic = mapRulesToRulesPostImportContainer(rules);
    StudyDAO studyDao = new StudyDAO(dataSource);
    StudyBean currentStudy = studyDao.findByOid(studyOid);
    UserAccountBean userAccount = getUserAccount();
    mayProceed(userAccount, currentStudy);
    getRulePostImportContainerService(currentStudy, userAccount);
    rpic = getRulePostImportContainerService(currentStudy, userAccount).validateRuleDefs(rpic);
    rpic = getRulePostImportContainerService(currentStudy, userAccount).validateRuleSetDefs(rpic);
    Response response = new Response();
    response.setValid(Boolean.TRUE);
    if (rpic.getInValidRuleDefs().size() > 0 || rpic.getInValidRuleSetDefs().size() > 0) {
        response.setValid(Boolean.FALSE);
        for (AuditableBeanWrapper<RuleBean> beanWrapper : rpic.getInValidRuleDefs()) {
            for (String error : beanWrapper.getImportErrors()) {
                org.openclinica.ns.response.v31.MessagesType messageType = new MessagesType();
                messageType.setMessage(error);
                response.getMessages().add(messageType);
            }
        }
        for (AuditableBeanWrapper<RuleSetBean> beanWrapper : rpic.getInValidRuleSetDefs()) {
            for (String error : beanWrapper.getImportErrors()) {
                org.openclinica.ns.response.v31.MessagesType messageType = new MessagesType();
                messageType.setMessage(error);
                response.getMessages().add(messageType);
            }
        }
    }
    logger.debug("RPIC READY");
    return response;
}
Also used : Locale(java.util.Locale) StudyBean(org.akaza.openclinica.bean.managestudy.StudyBean) MessagesType(org.openclinica.ns.response.v31.MessagesType) RulesTestMessagesType(org.openclinica.ns.rules_test.v31.RulesTestMessagesType) MessagesType(org.openclinica.ns.response.v31.MessagesType) Response(org.openclinica.ns.response.v31.Response) HttpServletResponse(javax.servlet.http.HttpServletResponse) RulesPostImportContainer(org.akaza.openclinica.domain.rule.RulesPostImportContainer) org.openclinica.ns.rules.v31(org.openclinica.ns.rules.v31) UserAccountBean(org.akaza.openclinica.bean.login.UserAccountBean) StudyDAO(org.akaza.openclinica.dao.managestudy.StudyDAO) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) RuleBean(org.akaza.openclinica.domain.rule.RuleBean) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 12 with RuleBean

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

the class RuleSetRuleDaoTest method testFindByRuleSetBeanAndRuleBean.

public void testFindByRuleSetBeanAndRuleBean() {
    // RuleDao ruleDao = (RuleDao) getContext().getBean("ruleDao");
    // RuleSetDao ruleSetDao = (RuleSetDao) getContext().getBean("ruleSetDao");
    // RuleSetRuleDao ruleSetRuleDao = (RuleSetRuleDao) getContext().getBean("ruleSetRuleDao");
    RuleBean persistentRuleBean = ruleDao.findById(-1);
    RuleSetBean persistentRuleSetBean = ruleSetDao.findById(-1);
    List<RuleSetRuleBean> ruleSetRules = ruleSetRuleDao.findByRuleSetBeanAndRuleBean(persistentRuleSetBean, persistentRuleBean);
    assertNotNull("RuleSetRules is null", ruleSetRules);
    assertEquals("The size of RuleSetRules should be 1", new Integer(1), new Integer(ruleSetRules.size()));
}
Also used : RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) RuleBean(org.akaza.openclinica.domain.rule.RuleBean)

Example 13 with RuleBean

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

the class RulesPostImportContainerServiceTest method createRuleBean.

private RuleBean createRuleBean() {
    RuleBean ruleBean = new RuleBean();
    ruleBean.setName("TEST");
    ruleBean.setOid("BOY");
    ruleBean.setDescription("Yellow");
    ruleBean.setExpression(createExpression(Context.OC_RULES_V1, "SE_ED1NONRE.F_AGEN.IG_AGEN_UNGROUPED[1].I_AGEN_PERIODSTART eq \"07/01/2008\" and I_CONC_CON_MED_NAME eq \"Tylenol\""));
    return ruleBean;
}
Also used : RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) RuleBean(org.akaza.openclinica.domain.rule.RuleBean)

Example 14 with RuleBean

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

the class RulesPostImportContainerServiceTest method prepareContainer.

private ArrayList<RuleSetBean> prepareContainer() {
    RulesPostImportContainer container = new RulesPostImportContainer();
    ArrayList<RuleSetBean> ruleSets = new ArrayList<RuleSetBean>();
    ArrayList<RuleBean> ruleDefs = new ArrayList<RuleBean>();
    RuleBean rule = createRuleBean();
    RuleSetBean ruleSet = getRuleSet(rule.getOid(), "SE_REG.STARTDATE", "SE_REG3");
    RuleSetBean ruleSet2 = getRuleSet(rule.getOid(), "SE_REG3.STARTDATE", "SE_REG2");
    ruleSets.add(ruleSet);
    ruleSets.add(ruleSet2);
    // container.setRuleDefs(ruleDefs);
    return ruleSets;
}
Also used : RulesPostImportContainer(org.akaza.openclinica.domain.rule.RulesPostImportContainer) ArrayList(java.util.ArrayList) RuleSetBean(org.akaza.openclinica.domain.rule.RuleSetBean) RuleSetRuleBean(org.akaza.openclinica.domain.rule.RuleSetRuleBean) RuleBean(org.akaza.openclinica.domain.rule.RuleBean)

Example 15 with RuleBean

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

the class RuleDaoTest method testSaveOrUpdate.

public void testSaveOrUpdate() {
    // RuleDao ruleDao = (RuleDao) getContext().getBean("ruleDao");
    RuleBean ruleBean = createRuleBeanStub();
    RuleBean persistentRuleBean = ruleDao.saveOrUpdate(ruleBean);
    RuleBean ruleBean2 = createRuleBeanStub();
    RuleBean persistentRuleBean2 = ruleDao.saveOrUpdate(ruleBean2);
    assertNotNull("Persistent id is null", persistentRuleBean.getId());
    assertNotNull("Persistent id is null", persistentRuleBean2.getId());
}
Also used : RuleBean(org.akaza.openclinica.domain.rule.RuleBean)

Aggregations

RuleBean (org.akaza.openclinica.domain.rule.RuleBean)24 RuleSetRuleBean (org.akaza.openclinica.domain.rule.RuleSetRuleBean)18 RuleSetBean (org.akaza.openclinica.domain.rule.RuleSetBean)15 RuleActionBean (org.akaza.openclinica.domain.rule.action.RuleActionBean)8 ExpressionBean (org.akaza.openclinica.domain.rule.expression.ExpressionBean)8 ExpressionObjectWrapper (org.akaza.openclinica.domain.rule.expression.ExpressionObjectWrapper)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 OpenClinicaSystemException (org.akaza.openclinica.exception.OpenClinicaSystemException)7 OpenClinicaExpressionParser (org.akaza.openclinica.logic.expressionTree.OpenClinicaExpressionParser)7 ItemDataBean (org.akaza.openclinica.bean.submit.ItemDataBean)6 RuleActionRunLogBean (org.akaza.openclinica.domain.rule.action.RuleActionRunLogBean)6 StudyBean (org.akaza.openclinica.bean.managestudy.StudyBean)5 RulesPostImportContainer (org.akaza.openclinica.domain.rule.RulesPostImportContainer)5 ActionProcessor (org.akaza.openclinica.domain.rule.action.ActionProcessor)5 Map (java.util.Map)4 StudyDAO (org.akaza.openclinica.dao.managestudy.StudyDAO)4 Locale (java.util.Locale)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 UserAccountBean (org.akaza.openclinica.bean.login.UserAccountBean)3