use of org.openclinica.ns.rules.v31 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.openclinica.ns.rules.v31 in project OpenClinica by OpenClinica.
the class RuleController method validateAndSave.
@RequestMapping(value = "/studies/{study}/validateAndSaveRule", method = RequestMethod.POST)
@ResponseBody
public Response validateAndSave(@RequestBody org.openclinica.ns.rules.v31.Rules rules, Model model, HttpSession session, @PathVariable("study") String studyOid, @RequestParam("ignoreDuplicates") Boolean ignoreDuplicates) 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);
}
}
} else if ((rpic.getDuplicateRuleDefs().size() > 0) && !ignoreDuplicates) {
response.setValid(Boolean.FALSE);
for (AuditableBeanWrapper<RuleBean> beanWrapper : rpic.getDuplicateRuleDefs()) {
org.openclinica.ns.response.v31.MessagesType messageType = new MessagesType();
messageType.setMessage(DUPLICATE_MESSAGE);
response.getMessages().add(messageType);
}
} else {
getRuleSetService().saveImportFromDesigner(rpic);
}
logger.debug("RPIC READY");
return response;
}
Aggregations