use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RulesPostImportContainerService method validateRuleSetRuleDefs.
public RulesPostImportContainer validateRuleSetRuleDefs(RulesPostImportContainer importContainer, RuleSetRuleBean ruleSetRuleForm) {
RuleSetBean ruleSetBean = ruleSetRuleForm.getRuleSetBean();
RuleSetRuleBean ruleSetRuleBean = ruleSetRuleForm;
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();
persistentRuleSetBean.setUpdaterAndDate(getUserAccount());
ruleSetBeanWrapper.setAuditableBean(persistentRuleSetBean);
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 {
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()));
}
List<RuleSetBean> eventActionsRuleSetBean = getRuleSetDao().findAllEventActions(currentStudy);
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 RulesPostImportContainerService method getExpressionService.
private ExpressionService getExpressionService() {
expressionService = this.expressionService != null ? expressionService : new ExpressionService(new ExpressionObjectWrapper(ds, currentStudy, (ExpressionBean) null, (RuleSetBean) null));
expressionService.setExpressionWrapper(new ExpressionObjectWrapper(ds, currentStudy, (ExpressionBean) null, (RuleSetBean) null));
return expressionService;
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class StudyEventBeanListener method createRuleSet.
private List<RuleSetBean> createRuleSet(Integer studyEventDefId) {
List<RuleSetBean> ruleSetsDB = getRuleSetDao().findAllByStudyEventDefIdWhereItemIsNull(studyEventDefId);
List<RuleSetBean> ruleSetCopies = new ArrayList<RuleSetBean>();
for (RuleSetBean ruleSetDB : ruleSetsDB) {
RuleSetBean ruleSetCopy = (RuleSetBean) SerializationUtils.clone(ruleSetDB);
ruleSetCopies.add(ruleSetCopy);
}
return ruleSetCopies;
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetService method getRuleSetsByCrfStudyAndStudyEventDefinition.
/*
* (non-Javadoc)
* @see
* org.akaza.openclinica.service.rule.RuleSetServiceInterface#getRuleSetsByCrfStudyAndStudyEventDefinition(org.akaza.openclinica.bean.managestudy.StudyBean,
* org.akaza.openclinica.bean.managestudy.StudyEventDefinitionBean, org.akaza.openclinica.bean.submit.CRFVersionBean)
*/
public List<RuleSetBean> getRuleSetsByCrfStudyAndStudyEventDefinition(StudyBean study, StudyEventDefinitionBean sed, CRFVersionBean crfVersion) {
CRFBean crf = getCrfDao().findByVersionId(crfVersion.getId());
logger.debug("crfVersionID : " + crfVersion.getId() + " studyId : " + study.getId() + " studyEventDefinition : " + sed.getId());
List<RuleSetBean> ruleSets = getRuleSetDao().findByCrfVersionOrCrfAndStudyAndStudyEventDefinition(crfVersion, crf, study, sed);
logger.info("getRuleSetsByCrfStudyAndStudyEventDefinition() : ruleSets Size {} : ", ruleSets.size());
if (ruleSets != null && ruleSets.size() > 0) {
for (RuleSetBean ruleSetBean : ruleSets) {
getObjects(ruleSetBean);
}
} else {
ruleSets = new ArrayList<RuleSetBean>();
}
return ruleSets;
// return eagerFetchRuleSet(ruleSets);
}
use of org.akaza.openclinica.domain.rule.RuleSetBean in project OpenClinica by OpenClinica.
the class RuleSetService method filterRuleSetsByGroupOrdinal.
/*
* (non-Javadoc)
* @see org.akaza.openclinica.service.rule.RuleSetServiceInterface#filterRuleSetsByGroupOrdinal(java.util.List)
*/
public List<RuleSetBean> filterRuleSetsByGroupOrdinal(List<RuleSetBean> ruleSets) {
for (RuleSetBean ruleSetBean : ruleSets) {
List<ExpressionBean> expressionsWithCorrectGroupOrdinal = new ArrayList<ExpressionBean>();
for (ExpressionBean expression : ruleSetBean.getExpressions()) {
String studyEventId = getExpressionService().getStudyEventDefinitionOrdninalCurated(expression.getValue());
String itemOid = getExpressionService().getItemOid(expression.getValue());
String itemGroupOid = getExpressionService().getItemGroupOid(expression.getValue());
String groupOrdinal = getExpressionService().getGroupOrdninalCurated(expression.getValue());
List<ItemDataBean> itemDatas = getItemDataDao().findByStudyEventAndOids(Integer.valueOf(studyEventId), itemOid, itemGroupOid);
logger.debug("studyEventId {} , itemOid {} , itemGroupOid {} , groupOrdinal {} , itemDatas {}", new Object[] { studyEventId, itemOid, itemGroupOid, groupOrdinal, itemDatas.size() });
// case 1 : group ordinal = ""
if (groupOrdinal.equals("") && itemDatas.size() > 0) {
for (int k = 0; k < itemDatas.size(); k++) {
ExpressionBean expBean = new ExpressionBean();
expBean.setValue(getExpressionService().replaceGroupOidOrdinalInExpression(expression.getValue(), k + 1));
expBean.setContext(expression.getContext());
expressionsWithCorrectGroupOrdinal.add(expBean);
}
}
// case 2 : group ordinal = x and itemDatas should be size >= x
if (!groupOrdinal.equals("") && itemDatas.size() >= Integer.valueOf(groupOrdinal)) {
ExpressionBean expBean = new ExpressionBean();
expBean.setValue(getExpressionService().replaceGroupOidOrdinalInExpression(expression.getValue(), null));
expBean.setContext(expression.getContext());
expressionsWithCorrectGroupOrdinal.add(expBean);
}
}
ruleSetBean.setExpressions(expressionsWithCorrectGroupOrdinal);
}
logExpressions(ruleSets);
return ruleSets;
}
Aggregations