use of org.akaza.openclinica.bean.odmbeans.ODMBean in project OpenClinica by OpenClinica.
the class DownloadStudyMetadataServlet method processRequest.
@Override
public void processRequest() throws Exception {
MetaDataCollector mdc = new MetaDataCollector(sm.getDataSource(), currentStudy, getRuleSetRuleDao());
AdminDataCollector adc = new AdminDataCollector(sm.getDataSource(), currentStudy);
MetaDataCollector.setTextLength(200);
ODMBean odmb = mdc.getODMBean();
odmb.setSchemaLocation("http://www.cdisc.org/ns/odm/v1.3 OpenClinica-ODM1-3-0-OC2-0.xsd");
ArrayList<String> xmlnsList = new ArrayList<String>();
xmlnsList.add("xmlns=\"http://www.cdisc.org/ns/odm/v1.3\"");
// xmlnsList.add("xmlns:OpenClinica=\"http://www.openclinica.org/ns/openclinica_odm/v1.3\"");
xmlnsList.add("xmlns:OpenClinica=\"http://www.openclinica.org/ns/odm_ext_v130/v3.1\"");
xmlnsList.add("xmlns:OpenClinicaRules=\"http://www.openclinica.org/ns/rules/v3.1\"");
odmb.setXmlnsList(xmlnsList);
odmb.setODMVersion("oc1.3");
mdc.setODMBean(odmb);
adc.setOdmbean(odmb);
mdc.collectFileData();
adc.collectFileData();
FullReportBean report = new FullReportBean();
report.setAdminDataMap(adc.getOdmAdminDataMap());
report.setOdmStudyMap(mdc.getOdmStudyMap());
report.setCoreResources(getCoreResources());
report.setOdmBean(mdc.getODMBean());
report.setODMVersion("oc1.3");
report.createStudyMetaOdmXml(Boolean.FALSE);
request.setAttribute("generate", report.getXmlOutput().toString().trim());
Page finalTarget = Page.EXPORT_DATA_CUSTOM;
finalTarget.setFileName("/WEB-INF/jsp/extract/downloadStudyMetadata.jsp");
forwardPage(finalTarget);
}
use of org.akaza.openclinica.bean.odmbeans.ODMBean in project OpenClinica by OpenClinica.
the class OdmFileCreation method createODMFile.
public HashMap<String, Integer> createODMFile(String odmVersion, long sysTimeBegin, String generalFileDir, DatasetBean datasetBean, StudyBean currentStudy, String generalFileDirCopy, ExtractBean eb, Integer currentStudyId, Integer parentStudyId, String studySubjectNumber, boolean zipped, boolean saveToDB, boolean deleteOld, String odmType, UserAccountBean userBean) {
Integer ssNumber = getStudySubjectNumber(studySubjectNumber);
MetaDataCollector mdc = new MetaDataCollector(dataSource, datasetBean, currentStudy, ruleSetRuleDao);
AdminDataCollector adc = new AdminDataCollector(dataSource, datasetBean, currentStudy);
ClinicalDataCollector cdc = new ClinicalDataCollector(dataSource, datasetBean, currentStudy);
MetaDataCollector.setTextLength(200);
if (deleteOld) {
File file = new File(generalFileDir);
if (file.isDirectory()) {
files = file.listFiles();
oldFiles = Arrays.asList(files);
}
}
if (odmVersion != null) {
// by default odmVersion is 1.2
if ("1.3".equals(odmVersion)) {
ODMBean odmb = new ODMBean();
odmb.setSchemaLocation("http://www.cdisc.org/ns/odm/v1.3 ODM1-3-0.xsd");
ArrayList<String> xmlnsList = new ArrayList<String>();
xmlnsList.add("xmlns=\"http://www.cdisc.org/ns/odm/v1.3\"");
odmb.setXmlnsList(xmlnsList);
odmb.setODMVersion("1.3");
mdc.setODMBean(odmb);
adc.setOdmbean(odmb);
cdc.setODMBean(odmb);
} else if ("oc1.2".equals(odmVersion)) {
ODMBean odmb = new ODMBean();
// odmb.setSchemaLocation("http://www.cdisc.org/ns/odm/v1.2 OpenClinica-ODM1-2-1.xsd");
odmb.setSchemaLocation("http://www.cdisc.org/ns/odm/v1.2 OpenClinica-ODM1-2-1-OC1.xsd");
ArrayList<String> xmlnsList = new ArrayList<String>();
xmlnsList.add("xmlns=\"http://www.cdisc.org/ns/odm/v1.2\"");
// xmlnsList.add("xmlns:OpenClinica=\"http://www.openclinica.org/ns/openclinica_odm/v1.2\"");
xmlnsList.add("xmlns:OpenClinica=\"http://www.openclinica.org/ns/odm_ext_v121/v3.1\"");
xmlnsList.add("xmlns:OpenClinicaRules=\"http://www.openclinica.org/ns/rules/v3.1\"");
odmb.setXmlnsList(xmlnsList);
odmb.setODMVersion("oc1.2");
mdc.setODMBean(odmb);
adc.setOdmbean(odmb);
cdc.setODMBean(odmb);
} else if ("oc1.3".equals(odmVersion)) {
ODMBean odmb = mdc.getODMBean();
// odmb.setSchemaLocation("http://www.cdisc.org/ns/odm/v1.3 OpenClinica-ODM1-3-0.xsd");
// odmb.setSchemaLocation("http://www.cdisc.org/ns/odm/v1.3 OpenClinica-ODM1-3-0-OC1.xsd");
odmb.setSchemaLocation("http://www.cdisc.org/ns/odm/v1.3 OpenClinica-ODM1-3-0-OC2-0.xsd");
ArrayList<String> xmlnsList = new ArrayList<String>();
xmlnsList.add("xmlns=\"http://www.cdisc.org/ns/odm/v1.3\"");
// xmlnsList.add("xmlns:OpenClinica=\"http://www.openclinica.org/ns/openclinica_odm/v1.3\"");
xmlnsList.add("xmlns:OpenClinica=\"http://www.openclinica.org/ns/odm_ext_v130/v3.1\"");
xmlnsList.add("xmlns:OpenClinicaRules=\"http://www.openclinica.org/ns/rules/v3.1\"");
odmb.setXmlnsList(xmlnsList);
odmb.setODMVersion("oc1.3");
odmb.setOdmType(odmType);
mdc.setODMBean(odmb);
adc.setOdmbean(odmb);
cdc.setODMBean(odmb);
}
}
// ////////////////////////////////////////
// //////// MetaData Extraction //////////
mdc.collectFileData();
MetaDataReportBean metaReport = new MetaDataReportBean(mdc.getOdmStudyMap(), coreResources);
metaReport.setODMVersion(odmVersion);
metaReport.setOdmBean(mdc.getODMBean());
metaReport.createChunkedOdmXml(Boolean.TRUE);
long sysTimeEnd = System.currentTimeMillis() - sysTimeBegin;
String ODMXMLFileName = mdc.getODMBean().getFileOID() + ".xml";
int fId = createFileK(ODMXMLFileName, generalFileDir, metaReport.getXmlOutput().toString(), datasetBean, sysTimeEnd, ExportFormatBean.XMLFILE, false, zipped, deleteOld, userBean);
if (!"".equals(generalFileDirCopy)) {
int fId2 = createFileK(ODMXMLFileName, generalFileDirCopy, metaReport.getXmlOutput().toString(), datasetBean, sysTimeEnd, ExportFormatBean.XMLFILE, false, zipped, deleteOld, userBean);
}
// ////////////////////////////////////////
// //////// AdminData Extraction //////////
adc.collectFileData();
AdminDataReportBean adminReport = new AdminDataReportBean(adc.getOdmAdminDataMap());
adminReport.setODMVersion(odmVersion);
adminReport.setOdmBean(mdc.getODMBean());
adminReport.createChunkedOdmXml(Boolean.TRUE);
sysTimeEnd = System.currentTimeMillis() - sysTimeBegin;
fId = createFileK(ODMXMLFileName, generalFileDir, adminReport.getXmlOutput().toString(), datasetBean, sysTimeEnd, ExportFormatBean.XMLFILE, false, zipped, deleteOld, userBean);
if (!"".equals(generalFileDirCopy)) {
int fId2 = createFileK(ODMXMLFileName, generalFileDirCopy, adminReport.getXmlOutput().toString(), datasetBean, sysTimeEnd, ExportFormatBean.XMLFILE, false, zipped, deleteOld, userBean);
}
// ////////////////////////////////////////
// //////// ClinicalData Extraction ///////
DatasetDAO dsdao = new DatasetDAO(dataSource);
String sql = eb.getDataset().getSQLStatement();
String st_sed_in = dsdao.parseSQLDataset(sql, true, true);
String st_itemid_in = dsdao.parseSQLDataset(sql, false, true);
int datasetItemStatusId = eb.getDataset().getDatasetItemStatus().getId();
String ecStatusConstraint = dsdao.getECStatusConstraint(datasetItemStatusId);
String itStatusConstraint = dsdao.getItemDataStatusConstraint(datasetItemStatusId);
Iterator<OdmStudyBase> it = cdc.getStudyBaseMap().values().iterator();
while (it.hasNext()) {
JobTerminationMonitor.check();
OdmStudyBase u = it.next();
ArrayList newRows = dsdao.selectStudySubjects(u.getStudy().getId(), 0, st_sed_in, st_itemid_in, dsdao.genDatabaseDateConstraint(eb), ecStatusConstraint, itStatusConstraint);
// /////////////
int fromIndex = 0;
boolean firstIteration = true;
while (fromIndex < newRows.size()) {
JobTerminationMonitor.check();
int toIndex = fromIndex + ssNumber < newRows.size() ? fromIndex + ssNumber : newRows.size() - 1;
List x = newRows.subList(fromIndex, toIndex + 1);
fromIndex = toIndex + 1;
String studySubjectIds = "";
for (int i = 0; i < x.size(); i++) {
StudySubjectBean sub = new StudySubjectBean();
sub = (StudySubjectBean) x.get(i);
studySubjectIds += "," + sub.getId();
}
// for
studySubjectIds = studySubjectIds.replaceFirst(",", "");
ClinicalDataUnit cdata = new ClinicalDataUnit(dataSource, datasetBean, cdc.getOdmbean(), u.getStudy(), cdc.getCategory(), studySubjectIds);
cdata.setCategory(cdc.getCategory());
cdata.collectOdmClinicalData();
FullReportBean report = new FullReportBean();
report.setClinicalData(cdata.getOdmClinicalData());
report.setOdmStudyMap(mdc.getOdmStudyMap());
report.setODMVersion(odmVersion);
// report.setOdmStudy(mdc.getOdmStudy());
report.setOdmBean(mdc.getODMBean());
if (firstIteration && fromIndex >= newRows.size()) {
report.createChunkedOdmXml(Boolean.TRUE, true, true);
firstIteration = false;
} else if (firstIteration) {
report.createChunkedOdmXml(Boolean.TRUE, true, false);
firstIteration = false;
} else if (fromIndex >= newRows.size()) {
report.createChunkedOdmXml(Boolean.TRUE, false, true);
} else {
report.createChunkedOdmXml(Boolean.TRUE, false, false);
}
fId = createFileK(ODMXMLFileName, generalFileDir, report.getXmlOutput().toString(), datasetBean, sysTimeEnd, ExportFormatBean.XMLFILE, false, zipped, deleteOld, userBean);
if (!"".equals(generalFileDirCopy)) {
int fId2 = createFileK(ODMXMLFileName, generalFileDirCopy, report.getXmlOutput().toString(), datasetBean, sysTimeEnd, ExportFormatBean.XMLFILE, false, zipped, deleteOld, userBean);
}
}
}
sysTimeEnd = System.currentTimeMillis() - sysTimeBegin;
fId = createFileK(ODMXMLFileName, generalFileDir, "</ODM>", datasetBean, sysTimeEnd, ExportFormatBean.XMLFILE, saveToDB, zipped, deleteOld, userBean);
if (!"".equals(generalFileDirCopy)) {
int fId2 = createFileK(ODMXMLFileName, generalFileDirCopy, "</ODM>", datasetBean, sysTimeEnd, ExportFormatBean.XMLFILE, false, zipped, deleteOld, userBean);
}
// ////////////////////////////////////////
// //////// pre pagination extraction /////
/*
mdc.collectFileData();
adc.collectOdmAdminDataMap();
cdc.collectOdmClinicalDataMap();
FullReportBean report = new FullReportBean();
report.setClinicalDataMap(cdc.getOdmClinicalDataMap());
report.setAdminDataMap(adc.getOdmAdminDataMap());
report.setOdmStudyMap(mdc.getOdmStudyMap());
report.setOdmBean(mdc.getODMBean());
report.setODMVersion(odmVersion);
report.createOdmXml(Boolean.TRUE);
long sysTimeEnd = System.currentTimeMillis() - sysTimeBegin;
String ODMXMLFileName = mdc.getODMBean().getFileOID() + ".xml";
int fId = this.createFile(ODMXMLFileName, generalFileDir, report.getXmlOutput().toString(), datasetBean, sysTimeEnd, ExportFormatBean.XMLFILE, true);
if (!"".equals(generalFileDirCopy)) {
int fId2 = this.createFile(ODMXMLFileName, generalFileDirCopy, report.getXmlOutput().toString(), datasetBean, sysTimeEnd, ExportFormatBean.XMLFILE, false);
} */
HashMap answerMap = new HashMap<String, Integer>();
// JN: Zipped in the next stage as thats where the ODM file is named and copied over in default categories.
// if(zipped)
// { try {
// zipFile(ODMXMLFileName,generalFileDir);
//
// } catch (IOException e) {
// // TODO Auto-generated catch block
// logger.error(e.getMessage());
// e.printStackTrace();
// }
//
// } // return ODMXMLFileName;
answerMap.put(ODMXMLFileName, new Integer(fId));
return answerMap;
}
use of org.akaza.openclinica.bean.odmbeans.ODMBean in project OpenClinica by OpenClinica.
the class MetadataCollectorResource method collectODMMetadataForClinicalData.
public FullReportBean collectODMMetadataForClinicalData(String studyOID, String formVersionOID, LinkedHashMap<String, OdmClinicalDataBean> clinicalDataMap) {
StudyBean studyBean = getStudyDao().findByOid(studyOID);
if (studyBean != null)
studyBean = populateStudyBean(studyBean);
MetaDataCollector mdc = new MetaDataCollector(this.dataSource, studyBean, getRuleSetRuleDao());
AdminDataCollector adc = new AdminDataCollector(this.dataSource, studyBean);
MetaDataCollector.setTextLength(200);
ODMBean odmb = mdc.getODMBean();
odmb.setSchemaLocation("http://www.cdisc.org/ns/odm/v1.3 OpenClinica-ODM1-3-0-OC2-0.xsd");
ArrayList<String> xmlnsList = new ArrayList<String>();
xmlnsList.add("xmlns=\"http://www.cdisc.org/ns/odm/v1.3\"");
// xmlnsList.add("xmlns:OpenClinica=\"http://www.openclinica.org/ns/openclinica_odm/v1.3\"");
xmlnsList.add("xmlns:OpenClinica=\"http://www.openclinica.org/ns/odm_ext_v130/v3.1\"");
xmlnsList.add("xmlns:OpenClinicaRules=\"http://www.openclinica.org/ns/rules/v3.1\"");
odmb.setXmlnsList(xmlnsList);
odmb.setODMVersion("oc1.3");
mdc.setODMBean(odmb);
adc.setOdmbean(odmb);
if (studyBean == null)
mdc.collectFileData(formVersionOID);
else
mdc.collectFileData();
adc.collectFileData();
FullReportBean report = new FullReportBean();
report.setAdminDataMap(adc.getOdmAdminDataMap());
report.setOdmStudyMap(mdc.getOdmStudyMap());
report.setCoreResources(getCoreResources());
report.setOdmBean(mdc.getODMBean());
// report.setClinicalData(odmClinicalDataBean);
report.setClinicalDataMap(clinicalDataMap);
report.setODMVersion("oc1.3");
return report;
}
use of org.akaza.openclinica.bean.odmbeans.ODMBean in project OpenClinica by OpenClinica.
the class MetadataUnit method collectMetaDataVersion.
/**
* To retrieve the ODM with form version OID as one of the parameters
* @param formVersionOID
*/
private void collectMetaDataVersion(String formVersionOID) {
StudyBean study = studyBase.getStudy();
OdmExtractDAO oedao = new OdmExtractDAO(this.ds);
MetaDataVersionBean metadata = this.odmStudy.getMetaDataVersion();
ODMBean odmBean = new ODMBean();
odmBean.setODMVersion("oc1.3");
setOdmBean(odmBean);
ArrayList<StudyEventDefinitionBean> sedBeansInStudy = (ArrayList<StudyEventDefinitionBean>) studyBase.getSedBeansInStudy();
if (sedBeansInStudy == null || sedBeansInStudy.size() < 1) {
logger.info("null, because there is no study event definition in this study.");
return;
}
if (metadata.getOid() == null || metadata.getOid().length() <= 0) {
metadata.setOid("v1.0.0");
}
if (metadata.getName() == null || metadata.getName().length() <= 0) {
metadata.setName("MetaDataVersion_v1.0.0");
}
oedao.getODMMetadataForForm(metadata, formVersionOID, this.odmBean.getODMVersion());
}
Aggregations