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;
}
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()));
}
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;
}
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;
}
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());
}
Aggregations