use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class ViewRuleAssignmentTableFactory method setDataAndLimitVariables.
@Override
public void setDataAndLimitVariables(TableFacade tableFacade) {
// initialize i18n
resword = ResourceBundleProvider.getWordsBundle(getLocale());
Limit limit = tableFacade.getLimit();
ViewRuleAssignmentFilter viewRuleAssignmentFilter = getViewRuleAssignmentFilter(limit);
ViewRuleAssignmentSort viewRuleAssignmentSort = getViewRuleAssignmentSort(limit);
viewRuleAssignmentFilter.addFilter("studyId", currentStudy.getId());
if (viewRuleAssignmentSort.getSorts().size() == 0) {
viewRuleAssignmentSort.addSort("itemName", "asc");
}
Boolean ruleSetRuleStatusFilterNotSelected = true;
for (ViewRuleAssignmentFilter.Filter filter : viewRuleAssignmentFilter.getFilters()) {
if (filter.getProperty().equals("ruleSetRuleStatus")) {
ruleSetRuleStatusFilterNotSelected = false;
}
}
if (ruleSetRuleStatusFilterNotSelected) {
viewRuleAssignmentFilter.addFilter("ruleSetRuleStatus", "1");
}
/*
* Because we are using the State feature (via stateAttr) we can do a check to see if we have a complete limit
* already. See the State feature for more details Very important to set the totalRow before trying to get the row
* start and row end variables. Very important to set the totalRow before trying to get the row start and row end
* variables.
*/
if (!limit.isComplete()) {
int totalRows = getRuleSetService().getCountWithFilter(viewRuleAssignmentFilter);
tableFacade.setTotalRows(totalRows);
}
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
Collection<RuleSetRuleBean> items = getRuleSetService().getWithFilterAndSort(viewRuleAssignmentFilter, viewRuleAssignmentSort, rowStart, rowEnd);
HashMap<Integer, RuleSetBean> ruleSets = new HashMap<Integer, RuleSetBean>();
Collection<HashMap<Object, Object>> theItems = new ArrayList<HashMap<Object, Object>>();
ruleSetRuleIds = new ArrayList<Integer>();
for (RuleSetRuleBean ruleSetRuleBean : items) {
RuleSetBean ruleSetBean = null;
ruleSetRuleIds.add(ruleSetRuleBean.getId());
if (ruleSets.containsKey(ruleSetRuleBean.getRuleSetBean().getId())) {
ruleSetBean = ruleSets.get(ruleSetRuleBean.getRuleSetBean().getId());
} else {
ruleSetBean = ruleSetRuleBean.getRuleSetBean();
getRuleSetService().getObjects(ruleSetBean);
ruleSets.put(ruleSetBean.getId(), ruleSetBean);
}
HashMap<Object, Object> theItem = new HashMap<Object, Object>();
theItem.put("ruleSetRunSchedule", ruleSetBean.isRunSchedule());
theItem.put("ruleSetRunTime", ruleSetBean.getRunTime());
theItem.put("ruleSetId", ruleSetBean.getId());
theItem.put("ruleSetRuleId", ruleSetRuleBean.getId());
theItem.put("ruleId", ruleSetRuleBean.getRuleBean().getId());
theItem.put("ruleSetRule", ruleSetRuleBean);
theItem.put("targetValue", ruleSetBean.getTarget().getValue());
theItem.put("studyEventDefinitionName", ruleSetBean.getStudyEventDefinitionName());
theItem.put("crf", ruleSetBean.getCrf());
theItem.put("crfVersion", ruleSetBean.getCrfVersion());
theItem.put("item", ruleSetBean.getItem());
theItem.put("crfName", ruleSetBean.getCrfName());
theItem.put("crfVersionName", ruleSetBean.getCrfVersionName());
theItem.put("groupLabel", ruleSetBean.getGroupLabel());
theItem.put("itemName", ruleSetBean.getItemName());
theItem.put("ruleSetRules", ruleSetBean.getRuleSetRules());
theItem.put("ruleName", ruleSetRuleBean.getRuleBean().getName());
theItem.put("ruleExpressionValue", ruleSetRuleBean.getRuleBean().getExpression().getValue());
theItem.put("ruleOid", ruleSetRuleBean.getRuleBean().getOid());
theItem.put("ruleDescription", ruleSetRuleBean.getRuleBean().getDescription());
theItem.put("theActions", ruleSetRuleBean.getActions());
theItem.put("ruleSetRuleStatus", "");
theItem.put("validations", "");
theItem.put("actionExecuteOn", "");
theItem.put("actionType", "XXXXXXXXX");
theItem.put("actionSummary", "");
theItems.add(theItem);
}
// Do not forget to set the items back on the tableFacade.
tableFacade.setItems(theItems);
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class ViewRuleSetAuditServlet method processRequest.
@Override
public void processRequest() throws Exception {
String ruleSetId = request.getParameter(RULESET_ID);
if (ruleSetId == null) {
addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
forwardPage(Page.CRF_LIST);
} else {
RuleSetBean ruleSetBean = getRuleSetService().getRuleSetById(currentStudy, ruleSetId);
List<RuleSetAuditBean> ruleSetAudits = getRuleSetAuditDao().findAllByRuleSet(ruleSetBean);
List<RuleSetRuleAuditBean> ruleSetRuleAudits = getRuleSetRuleAuditDao().findAllByRuleSet(ruleSetBean);
for (RuleSetRuleAuditBean ruleSetRuleAuditBean : ruleSetRuleAudits) {
ruleSetRuleAuditBean.setUpdater((UserAccountBean) getUserAccountDAO().findByPK(ruleSetRuleAuditBean.getUpdaterId()));
}
for (RuleSetAuditBean ruleSetAudit : ruleSetAudits) {
ruleSetAudit.setUpdater((UserAccountBean) getUserAccountDAO().findByPK(ruleSetAudit.getUpdaterId()));
}
request.setAttribute(RULESET, ruleSetBean);
request.setAttribute(RULESETAUDITS, ruleSetAudits);
request.setAttribute(RULESETRULEAUDITS, ruleSetRuleAudits);
forwardPage(Page.VIEW_RULESET_AUDITS);
}
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class ViewRuleSetServlet method processRequest.
@Override
public void processRequest() throws Exception {
String ruleSetId = request.getParameter(RULESET_ID);
if (ruleSetId == null) {
addPageMessage(respage.getString("please_choose_a_CRF_to_view"));
forwardPage(Page.CRF_LIST);
} else {
RuleSetBean ruleSetBean = getRuleSetService().getRuleSetById(currentStudy, ruleSetId);
Boolean firstTime = true;
String validRuleSetRuleIds = "";
for (int j = 0; j < ruleSetBean.getRuleSetRules().size(); j++) {
RuleSetRuleBean rsr = ruleSetBean.getRuleSetRules().get(j);
if (rsr.getStatus() == Status.AVAILABLE) {
if (firstTime) {
validRuleSetRuleIds += rsr.getId();
firstTime = false;
} else {
validRuleSetRuleIds += "," + rsr.getId();
}
}
}
CoreResources core = (CoreResources) SpringServletAccess.getApplicationContext(context).getBean("coreResources");
String designerUrl = core.getField("designer.url") + "access?host=" + getHostPathFromSysUrl(core.getField("sysURL.base"), request.getContextPath()) + "&app=" + getContextPath(request);
UserAccountBean currentUser = (UserAccountBean) request.getSession().getAttribute("userBean");
request.setAttribute("designerUrl", designerUrl);
request.setAttribute("currentStudy", currentStudy.getOid());
request.setAttribute("providerUser", currentUser.getName());
request.setAttribute("validRuleSetRuleIds", validRuleSetRuleIds);
request.setAttribute("ruleSetRuleBeans", orderRuleSetRulesByStatus(ruleSetBean));
request.setAttribute(RULESET, ruleSetBean);
forwardPage(Page.VIEW_RULES);
}
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class UpdateRuleSetRuleServlet method processRequest.
@Override
public void processRequest() throws Exception {
String ruleSetId = request.getParameter(RULESET_ID);
String ruleSetRuleId = request.getParameter(RULESETRULE_ID);
String source = request.getParameter("source");
String action = request.getParameter(ACTION);
Status status = null;
String pageMessage = "";
if (ruleSetRuleId != null) {
RuleSetRuleBean ruleSetRule = getRuleSetRuleDao().findById(Integer.valueOf(ruleSetRuleId));
if (ruleSetRuleId != null && action.equals("remove")) {
status = Status.DELETED;
updateRuleSetRule(ruleSetRule, status);
pageMessage = "view_rules_remove_confirmation";
} else if (ruleSetRuleId != null && action.equals("restore")) {
status = Status.AVAILABLE;
ruleSetRule.getRuleSetBean().setStatus(Status.AVAILABLE);
updateRuleSetRule(ruleSetRule, status);
pageMessage = "view_rules_restore_confirmation";
}
}
if (ruleSetRuleId == null && ruleSetId != null && action.equals("remove")) {
RuleSetBean rs = getRuleSetDao().findById(Integer.valueOf(ruleSetId));
for (RuleSetRuleBean theRuleSetRule : rs.getRuleSetRules()) {
if (theRuleSetRule.getStatus() != Status.DELETED) {
status = Status.DELETED;
updateRuleSetRule(theRuleSetRule, status);
}
}
pageMessage = "view_rules_remove_confirmation";
}
addPageMessage(resword.getString(pageMessage));
if (source != null && source.equals("ViewRuleSet")) {
context.getRequestDispatcher("/ViewRuleSet?ruleSetId=" + ruleSetId).forward(request, response);
} else {
forwardPage(Page.LIST_RULE_SETS_SERVLET);
}
}
use of org.akaza.openclinica.domain.rule.RuleSetBean 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;
}
Aggregations