use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class ViewRuleAssignmentServlet method processRequest.
@Override
public void processRequest() throws Exception {
FormProcessor fp = new FormProcessor(request);
List<RuleSetBean> ruleSets = getRuleSetService().getRuleSetsByStudy(currentStudy);
ruleSets = getRuleSetService().filterByStatusEqualsAvailableOnlyRuleSetRules(ruleSets);
EntityBeanTable table = fp.getWebEntityBeanTable();
ArrayList allRows = ViewRuleAssignmentRow.generateRowsFromBeans((ArrayList) ruleSets);
String[] columns = { resword.getString("rule_study_event_definition"), resword.getString("CRF_name"), resword.getString("rule_group_label"), resword.getString("rule_item_name"), resword.getString("rule_rules"), resword.getString("rule_ref_oid"), resword.getString("rule_action_type"), resword.getString("actions") };
table.setColumns(new ArrayList(Arrays.asList(columns)));
table.hideColumnLink(4);
table.hideColumnLink(5);
table.hideColumnLink(6);
table.setQuery("ViewRuleAssignment", new HashMap());
// table.addLink(resword.getString("rule_import_rule"), "ImportRule");
table.addLink(resword.getString("test_rule_title"), "TestRule");
table.setRows(allRows);
table.computeDisplay();
request.setAttribute("table", table);
if (request.getParameter("read") != null && request.getParameter("read").equals("true")) {
request.setAttribute("readOnly", true);
}
forwardPage(Page.VIEW_RULE_SETS);
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class StudyEventBeanListener method update.
@Override
public void update(Listener lstnr) {
// System.out.println("Triggering the rules based on event updates");
StudyEventBeanContainer studyEventBeanContainer = (StudyEventBeanContainer) lstnr;
// if (studyEventBeanContainer.getChangeDetails().getStartDateChanged() || studyEventBeanContainer.getChangeDetails().getStatusChanged()){
Integer studyEventDefId = studyEventBeanContainer.getEvent().getStudyEventDefinitionId();
// Integer studySubjectId = studyEventBeanContainer.getEvent().getStudySubjectId();
Integer userId = studyEventBeanContainer.getEvent().getUpdaterId();
Integer studyEventOrdinal = studyEventBeanContainer.getEvent().getSampleOrdinal();
if (userId == 0)
userId = studyEventBeanContainer.getEvent().getOwnerId();
StudyEventBean studyEvent = studyEventBeanContainer.getEvent();
ArrayList<RuleSetBean> ruleSets = (ArrayList<RuleSetBean>) createRuleSet(studyEventDefId);
for (RuleSetBean ruleSet : ruleSets) {
ArrayList<RuleSetBean> ruleSetBeans = new ArrayList();
ExpressionBean eBean = new ExpressionBean();
eBean.setValue(ruleSet.getTarget().getValue() + ".A.B");
ruleSet.setTarget(eBean);
ruleSet.addExpression(getRuleSetService().replaceSEDOrdinal(ruleSet.getTarget(), studyEvent));
ruleSetBeans.add(ruleSet);
// for (RuleSetBean ruleSet : ruleSetBeans){
String targetProperty = ruleSet.getTarget().getValue().substring(ruleSet.getTarget().getValue().indexOf("."));
if ((targetProperty.contains(ExpressionService.STARTDATE + ".A.B") && studyEventBeanContainer.getChangeDetails().getStartDateChanged()) || (targetProperty.contains(ExpressionService.STATUS + ".A.B") && studyEventBeanContainer.getChangeDetails().getStatusChanged())) {
getRuleSetService().runIndividualRulesInBeanProperty(ruleSetBeans, userId, studyEventBeanContainer.getChangeDetails(), studyEventOrdinal);
}
}
// }
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RulesPostImportContainerService method validateRuleSetDefs.
public RulesPostImportContainer validateRuleSetDefs(RulesPostImportContainer importContainer) {
List<RuleSetBean> eventActionsRuleSetBean = getRuleSetDao().findAllEventActions(currentStudy);
for (RuleSetBean ruleSetBean : importContainer.getRuleSets()) {
AuditableBeanWrapper<RuleSetBean> ruleSetBeanWrapper = new AuditableBeanWrapper<RuleSetBean>(ruleSetBean);
ruleSetBeanWrapper.getAuditableBean().setStudy(currentStudy);
if (isRuleSetExpressionValid(ruleSetBeanWrapper)) {
RuleSetBean persistentRuleSetBean = getRuleSetDao().findByExpressionAndStudy(ruleSetBean, currentStudy.getId());
if (persistentRuleSetBean != null) {
List<RuleSetRuleBean> importedRuleSetRules = ruleSetBeanWrapper.getAuditableBean().getRuleSetRules();
if (ruleSetBean.getRunTime() != null) {
if (ruleSetBean.getRunOnSchedule() == null) {
ruleSetBean.setRunOnSchedule(new RunOnSchedule(ruleSetBean.getRunTime()));
}
}
if (ruleSetBean.getRunOnSchedule() != null) {
persistentRuleSetBean.setRunSchedule(true);
if (ruleSetBean.getRunOnSchedule().getRunTime() != null) {
if (isRunTimeValid(ruleSetBeanWrapper, ruleSetBean.getRunOnSchedule().getRunTime())) {
persistentRuleSetBean.setRunTime(ruleSetBean.getRunOnSchedule().getRunTime());
}
} else {
// supposed to act like 23:00
persistentRuleSetBean.setRunTime(null);
}
} else {
persistentRuleSetBean.setRunSchedule(false);
persistentRuleSetBean.setRunTime(null);
}
persistentRuleSetBean.setUpdaterAndDate(getUserAccount());
ruleSetBeanWrapper.setAuditableBean(persistentRuleSetBean);
Iterator<RuleSetRuleBean> itr = importedRuleSetRules.iterator();
while (itr.hasNext()) {
RuleSetRuleBean ruleSetRuleBean = itr.next();
ruleSetRuleBean.setRuleBean(getRuleDao().findByOid(ruleSetRuleBean.getOid(), persistentRuleSetBean.getStudyId()));
// ruleSetRuleBean.setRuleSetBean(ruleSetBeanWrapper.getAuditableBean());
for (RuleSetRuleBean persistentruleSetRuleBean : persistentRuleSetBean.getRuleSetRules()) {
if (persistentruleSetRuleBean.getStatus() != Status.DELETED && ruleSetRuleBean.equals(persistentruleSetRuleBean)) {
persistentruleSetRuleBean.setRuleSetRuleBeanImportStatus(RuleSetRuleBeanImportStatus.EXACT_DOUBLE);
itr.remove();
break;
} else if (persistentruleSetRuleBean.getStatus() != Status.DELETED && ruleSetRuleBean.getRuleBean() != null && ruleSetRuleBean.getRuleBean().equals(persistentruleSetRuleBean.getRuleBean())) {
// persistentruleSetRuleBean.setActions(ruleSetRuleBean.getActions());
persistentruleSetRuleBean.setRuleSetRuleBeanImportStatus(RuleSetRuleBeanImportStatus.TO_BE_REMOVED);
// itr.remove();
break;
}
ruleSetRuleBean.setRuleSetRuleBeanImportStatus(RuleSetRuleBeanImportStatus.LINE);
}
}
ruleSetBeanWrapper.getAuditableBean().addRuleSetRules(importedRuleSetRules);
// ruleSetBeanWrapper.getAuditableBean().setId(persistentRuleSetBean.getId());
} else {
if (importContainer.getValidRuleSetExpressionValues().contains(ruleSetBeanWrapper.getAuditableBean().getTarget().getValue())) {
ruleSetBeanWrapper.error(createError("OCRERR_0031"));
}
ruleSetBeanWrapper.getAuditableBean().setOwner(getUserAccount());
ruleSetBeanWrapper.getAuditableBean().setStudyEventDefinition(getExpressionService().getStudyEventDefinitionFromExpression(ruleSetBean.getTarget().getValue()));
ruleSetBeanWrapper.getAuditableBean().setCrf(getExpressionService().getCRFFromExpression(ruleSetBean.getTarget().getValue()));
ruleSetBeanWrapper.getAuditableBean().setCrfVersion(getExpressionService().getCRFVersionFromExpression(ruleSetBean.getTarget().getValue()));
ruleSetBeanWrapper.getAuditableBean().setItem(getExpressionService().getItemBeanFromExpression(ruleSetBean.getTarget().getValue()));
ruleSetBeanWrapper.getAuditableBean().setItemGroup(getExpressionService().getItemGroupExpression(ruleSetBean.getTarget().getValue()));
if (ruleSetBean.getRunTime() != null) {
if (ruleSetBean.getRunOnSchedule() == null) {
ruleSetBeanWrapper.getAuditableBean().setRunOnSchedule(new RunOnSchedule(ruleSetBean.getRunTime()));
}
}
if (ruleSetBean.getRunOnSchedule() != null) {
ruleSetBeanWrapper.getAuditableBean().setRunSchedule(true);
if (ruleSetBean.getRunOnSchedule().getRunTime() != null) {
//validate Time isRunTimeValid
if (isRunTimeValid(ruleSetBeanWrapper, ruleSetBean.getRunOnSchedule().getRunTime())) {
ruleSetBeanWrapper.getAuditableBean().setRunTime(ruleSetBean.getRunOnSchedule().getRunTime());
}
} else {
// supposed to act like DEFAULT_TIME
ruleSetBeanWrapper.getAuditableBean().setRunTime(null);
}
} else {
ruleSetBeanWrapper.getAuditableBean().setRunSchedule(false);
ruleSetBeanWrapper.getAuditableBean().setRunTime(null);
}
}
isRuleSetRuleValid(importContainer, ruleSetBeanWrapper, eventActionsRuleSetBean);
}
putRuleSetInCorrectContainer(ruleSetBeanWrapper, importContainer);
}
logger.info("# of Valid RuleSetDefs : " + importContainer.getValidRuleSetDefs().size());
logger.info("# of InValid RuleSetDefs : " + importContainer.getInValidRuleSetDefs().size());
logger.info("# of Overwritable RuleSetDefs : " + importContainer.getDuplicateRuleSetDefs().size());
return importContainer;
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetService method getRuleSetById.
/*
* (non-Javadoc)
* @see org.akaza.openclinica.service.rule.RuleSetServiceInterface#getRuleSetById(org.akaza.openclinica.bean.managestudy.StudyBean, java.lang.String,
* org.akaza.openclinica.domain.rule.RuleBean)
*/
public List<RuleSetRuleBean> getRuleSetById(StudyBean study, String id, RuleBean ruleBean) {
logger.debug(" Study Id {} ", study.getId());
RuleSetBean ruleSetBean = getRuleSetDao().findById(Integer.valueOf(id));
return getRuleSetRuleDao().findByRuleSetBeanAndRuleBean(ruleSetBean, ruleBean);
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetService method logExpressions.
private void logExpressions(List<RuleSetBean> validRuleSets) {
if (logger.isDebugEnabled()) {
for (RuleSetBean ruleSetBean : validRuleSets) {
logger.debug("Expression : {} ", ruleSetBean.getTarget().getValue());
List<ExpressionBean> expressions = ruleSetBean.getExpressions();
if (expressions != null) {
for (ExpressionBean expression : expressions) {
logger.debug("Expression post filtering SEDs : {} ", expression.getValue());
}
}
}
}
}
Aggregations