public void setResourceLoader(ResourceLoader resourceLoader) { this.resourceLoader = resourceLoader; try { // setPROPERTIES_DIR(); webapp = getWebAppName(resourceLoader.getResource("/").getURI().getPath()); logMe("is web app name null?" + webapp); String dbName = dataInfo.getProperty("dbType"); DATAINFO = dataInfo; dataInfo = setDataInfoProperties(); // weird, but there are references to dataInfo...MainMenuServlet // for instance // setDataInfoPath(); EXTRACTINFO = extractInfo; DB_NAME = dbName; SQLFactory factory = SQLFactory.getInstance(); factory.run(dbName, resourceLoader); copyBaseToDest(resourceLoader); extractProperties = findExtractProperties(); // tbh, following line to be removed // reportUrl(); } catch (OpenClinicaSystemException e) { logger.debug(e.getMessage()); logger.debug(e.toString()); throw new OpenClinicaSystemException(e.getMessage(), e.fillInStackTrace()); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } }
public HashMap<RuleBulkExecuteContainer, HashMap<RuleBulkExecuteContainerTwo, Set<String>>> runRulesBulk( List<RuleSetBean> ruleSets, Boolean dryRun, StudyBean currentStudy, HashMap<String, String> variableAndValue, UserAccountBean ub) { if (variableAndValue == null || variableAndValue.isEmpty()) { logger.warn("You must be executing Rules in Batch"); variableAndValue = new HashMap<String, String>(); } HashMap<RuleBulkExecuteContainer, HashMap<RuleBulkExecuteContainerTwo, Set<String>>> crfViewSpecificOrderedObjects = new HashMap< RuleBulkExecuteContainer, HashMap<RuleBulkExecuteContainerTwo, Set<String>>>(); for (RuleSetBean ruleSet : ruleSets) { for (ExpressionBean expressionBean : ruleSet.getExpressions()) { ruleSet.setTarget(expressionBean); for (RuleSetRuleBean ruleSetRule : ruleSet.getRuleSetRules()) { String result = null; RuleBean rule = ruleSetRule.getRuleBean(); ExpressionObjectWrapper eow = new ExpressionObjectWrapper( ds, currentStudy, rule.getExpression(), ruleSet, variableAndValue); try { OpenClinicaExpressionParser oep = new OpenClinicaExpressionParser(eow); result = oep.parseAndEvaluateExpression(rule.getExpression().getValue()); // Actions List<RuleActionBean> actionListBasedOnRuleExecutionResult = ruleSetRule.getActions(result); if (dryRun && actionListBasedOnRuleExecutionResult.size() > 0) { crfViewSpecificOrderedObjects = populateForCrfBasedRulesView( crfViewSpecificOrderedObjects, ruleSet, rule, result, currentStudy, actionListBasedOnRuleExecutionResult); } // If not a dryRun meaning run Actions if (!dryRun) { for (RuleActionBean ruleAction : actionListBasedOnRuleExecutionResult) { int itemDataBeanId = getExpressionService() .getItemDataBeanFromDb(ruleSet.getTarget().getValue()) .getId(); ruleAction.setCuratedMessage(curateMessage(ruleAction, ruleSetRule)); // getDiscrepancyNoteService().saveFieldNotes(ruleAction.getSummary(), // itemDataBeanId, "ItemData", currentStudy, ub); ActionProcessor ap = ActionProcessorFacade.getActionProcessor(ruleAction.getActionType(), ds); ap.execute( ruleAction, itemDataBeanId, "ItemData", currentStudy, ub, prepareEmailContents(ruleSet, ruleSetRule, currentStudy, ruleAction)); } } } catch (OpenClinicaSystemException osa) { // TODO: Auditing might happen here failed rule logger.warn( "RuleSet with target : {} , Ran Rule : {} , It resulted in an error due to : {}", new Object[] {ruleSet.getTarget().getValue(), rule.getName(), osa.getMessage()}); } } } } logCrfViewSpecificOrderedObjects(crfViewSpecificOrderedObjects); return crfViewSpecificOrderedObjects; }