use of org.akaza.openclinica.dao.cache.EhCacheWrapper in project OpenClinica by OpenClinica.
the class SQLFactory method run.
public void run(String dbName, ResourceLoader resourceLoader) {
// we get the type of the database and run the factory, picking
// up all the queries. NOTE that this should only be run
// during the init servlets' action, and then it will
// remain in static memory. tbh 9/8/04
// ssachs 20041011
// modified this section so that files are added using the
// public static final strings above which are not specific to the
// database
// key is the public static final sting used above; value is the actual
// filename
HashMap fileList = new HashMap();
CacheManager cacheManager = new CacheManager();
try {
if (resourceLoader != null && cacheManager != null)
cacheManager = cacheManager.create(resourceLoader.getResource("classpath:org/akaza/openclinica/ehcache.xml").getInputStream());
} catch (CacheException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
EhCacheWrapper ehCache = new EhCacheWrapper("com.akaza.openclinica.dao.core.DAOCache", cacheManager);
setEhCacheWrapper(ehCache);
if ("oracle".equals(dbName)) {
// logger.warn("Oracle Test");
fileList.put(this.DAO_USERACCOUNT, "oracle_useraccount_dao.xml");
fileList.put(this.DAO_ARCHIVED_DATASET_FILE, "oracle_archived_dataset_file_dao.xml");
fileList.put(this.DAO_STUDY, "oracle_study_dao.xml");
fileList.put(this.DAO_STUDYEVENTDEFNITION, "oracle_studyeventdefinition_dao.xml");
fileList.put(this.DAO_STUDYEVENT, "oracle_study_event_dao.xml");
fileList.put(this.DAO_STUDYGROUP, "oracle_study_group_dao.xml");
fileList.put(this.DAO_STUDYGROUPCLASS, "oracle_study_group_class_dao.xml");
fileList.put(this.DAO_STUDYSUBJECT, "oracle_study_subject_dao.xml");
fileList.put(this.DAO_SUBJECT, "oracle_subject_dao.xml");
fileList.put(this.DAO_SUBJECTGROUPMAP, "oracle_subject_group_map_dao.xml");
fileList.put(this.DAO_EVENTDEFINITIONCRF, "oracle_event_definition_crf_dao.xml");
fileList.put(this.DAO_AUDITEVENT, "oracle_audit_event_dao.xml");
fileList.put(this.DAO_AUDIT, "oracle_audit_dao.xml");
fileList.put(this.DAO_ITEM, "oracle_item_dao.xml");
fileList.put(this.DAO_ITEMDATA, "oracle_itemdata_dao.xml");
fileList.put(this.DAO_CRF, "oracle_crf_dao.xml");
fileList.put(this.DAO_CRFVERSION, "oracle_crfversion_dao.xml");
fileList.put(this.DAO_DATASET, "oracle_dataset_dao.xml");
fileList.put(this.DAO_SECTION, "oracle_section_dao.xml");
fileList.put(this.DAO_FILTER, "oracle_filter_dao.xml");
fileList.put(this.DAO_MASKING, "oracle_masking_dao.xml");
fileList.put(this.DAO_EVENTCRF, "oracle_eventcrf_dao.xml");
fileList.put(this.DAO_ITEMFORMMETADATA, "oracle_item_form_metadata_dao.xml");
fileList.put(this.DAO_DISCREPANCY_NOTE, "oracle_discrepancy_note_dao.xml");
fileList.put(this.DAO_STUDY_PARAMETER, "oracle_study_parameter_value_dao.xml");
fileList.put(this.DAO_ITEM_GROUP, "oracle_item_group_dao.xml");
fileList.put(this.DAO_ITEM_GROUP_METADATA, "oracle_item_group_metadata_dao.xml");
fileList.put(this.DAO_RULESET, "oracle_ruleset_dao.xml");
fileList.put(this.DAO_RULE, "oracle_rule_dao.xml");
fileList.put(this.DAO_RULE_ACTION, "oracle_action_dao.xml");
fileList.put(this.DAO_EXPRESSION, "oracle_expression_dao.xml");
fileList.put(this.DAO_RULESET_RULE, "oracle_rulesetrule_dao.xml");
fileList.put(this.DAO_RULESET_AUDIT, "oracle_ruleset_audit_dao.xml");
fileList.put(this.DAO_RULESETRULE_AUDIT, "oracle_rulesetrule_audit_dao.xml");
fileList.put(this.DAO_ODM_EXTRACT, "oracle_odm_extract_dao.xml");
// fileList.put(this.DAO_SUBJECTTRANSFER, "oracle_subjecttransfer_dao.xml");
} else if ("postgres".equals(dbName)) {
fileList.put(this.DAO_USERACCOUNT, "useraccount_dao.xml");
fileList.put(this.DAO_ARCHIVED_DATASET_FILE, "archived_dataset_file_dao.xml");
fileList.put(this.DAO_STUDY, "study_dao.xml");
fileList.put(this.DAO_STUDYEVENTDEFNITION, "studyeventdefinition_dao.xml");
fileList.put(this.DAO_STUDYEVENT, "study_event_dao.xml");
fileList.put(this.DAO_STUDYGROUP, "study_group_dao.xml");
fileList.put(this.DAO_STUDYGROUPCLASS, "study_group_class_dao.xml");
fileList.put(this.DAO_STUDYSUBJECT, "study_subject_dao.xml");
fileList.put(this.DAO_SUBJECT, "subject_dao.xml");
fileList.put(this.DAO_SUBJECTGROUPMAP, "subject_group_map_dao.xml");
fileList.put(this.DAO_EVENTDEFINITIONCRF, "event_definition_crf_dao.xml");
fileList.put(this.DAO_AUDITEVENT, "audit_event_dao.xml");
fileList.put(this.DAO_AUDIT, "audit_dao.xml");
fileList.put(this.DAO_ITEM, "item_dao.xml");
fileList.put(this.DAO_ITEMDATA, "itemdata_dao.xml");
fileList.put(this.DAO_CRF, "crf_dao.xml");
fileList.put(this.DAO_CRFVERSION, "crfversion_dao.xml");
fileList.put(this.DAO_DATASET, "dataset_dao.xml");
fileList.put(this.DAO_SECTION, "section_dao.xml");
fileList.put(this.DAO_FILTER, "filter_dao.xml");
fileList.put(this.DAO_MASKING, "masking_dao.xml");
fileList.put(this.DAO_EVENTCRF, "eventcrf_dao.xml");
fileList.put(this.DAO_ITEMFORMMETADATA, "item_form_metadata_dao.xml");
fileList.put(this.DAO_DISCREPANCY_NOTE, "discrepancy_note_dao.xml");
fileList.put(this.DAO_STUDY_PARAMETER, "study_parameter_value_dao.xml");
fileList.put(this.DAO_ITEM_GROUP, "item_group_dao.xml");
fileList.put(this.DAO_ITEM_GROUP_METADATA, "item_group_metadata_dao.xml");
fileList.put(this.DAO_RULESET, "ruleset_dao.xml");
fileList.put(this.DAO_RULE, "rule_dao.xml");
fileList.put(this.DAO_RULE_ACTION, "action_dao.xml");
fileList.put(this.DAO_EXPRESSION, "expression_dao.xml");
fileList.put(this.DAO_RULESET_RULE, "rulesetrule_dao.xml");
fileList.put(this.DAO_RULESET_AUDIT, "ruleset_audit_dao.xml");
fileList.put(this.DAO_RULESETRULE_AUDIT, "rulesetrule_audit_dao.xml");
fileList.put(this.DAO_SUBJECTTRANSFER, "subjecttransfer_dao.xml");
fileList.put(this.DAO_ODM_EXTRACT, "odm_extract_dao.xml");
// add files here as we port over to postgres, tbh
} else // should be either oracle or postgres, but what if the file is
// gone?
{
// throw an exception here, ssachs
}
Set DAONames = fileList.keySet();
Iterator DAONamesIt = DAONames.iterator();
while (DAONamesIt.hasNext()) {
String DAOName = (String) DAONamesIt.next();
String DAOFileName = (String) fileList.get(DAOName);
DAODigester newDaoDigester = new DAODigester();
try {
if (System.getProperty("catalina.home") == null) {
String path = getPropertiesDir();
newDaoDigester.setInputStream(new FileInputStream(path + DAOFileName));
} else {
String path = CoreResources.PROPERTIES_DIR;
newDaoDigester.setInputStream(resourceLoader.getResource("classpath:properties/" + DAOFileName).getInputStream());
// newDaoDigester.setInputStream(new FileInputStream(path + DAOFileName));
}
try {
newDaoDigester.run();
digesters.put(DAOName, newDaoDigester);
} catch (SAXException saxe) {
saxe.printStackTrace();
}
// end try block for xml
} catch (IOException ioe) {
ioe.printStackTrace();
}
// end try block for files
}
// end for loop
}
Aggregations