use of org.akaza.openclinica.bean.extract.DisplayItemHeaderBean in project OpenClinica by OpenClinica.
the class GenerateExtractFileService method createSPSSFile.
/**
* createSPSSFile, added by tbh, 01/2009
*
* @param db
* @param eb
* @param currentstudyid
* @param parentstudy
* @return
*/
public HashMap<String, Integer> createSPSSFile(DatasetBean db, ExtractBean eb2, StudyBean currentStudy, StudyBean parentStudy, long sysTimeBegin, String generalFileDir, SPSSReportBean answer, String generalFileDirCopy, UserAccountBean userBean) {
setUpResourceBundles();
String SPSSFileName = db.getName() + "_data_spss.dat";
String DDLFileName = db.getName() + "_ddl_spss.sps";
String ZIPFileName = db.getName() + "_spss";
SPSSVariableNameValidator svnv = new SPSSVariableNameValidator();
answer.setDatFileName(SPSSFileName);
// DatasetDAO dsdao = new DatasetDAO(ds);
// create the extract bean here, tbh
// ExtractBean eb = this.generateExtractBean(db, currentStudy,
// parentStudy);
// eb = dsdao.getDatasetData(eb, currentStudy.getId(),
// parentStudy.getId());
// eb.getMetadata();
// eb.computeReport(answer);
// set up items here to get
answer.setItems(eb2.getItemNames());
// itemMetadata
// set up response sets for each item here
ItemDAO itemdao = new ItemDAO(ds);
ItemFormMetadataDAO imfdao = new ItemFormMetadataDAO(ds);
ArrayList items = answer.getItems();
for (int i = 0; i < items.size(); i++) {
DisplayItemHeaderBean dih = (DisplayItemHeaderBean) items.get(i);
ItemBean item = dih.getItem();
ArrayList metas = imfdao.findAllByItemId(item.getId());
// for (int h = 0; h < metas.size(); h++) {
// ItemFormMetadataBean ifmb = (ItemFormMetadataBean)
// metas.get(h);
// logger.info("group name found:
// "+ifmb.getGroupLabel());
// }
// logger.info("crf versionname" +
// meta.getCrfVersionName());
item.setItemMetas(metas);
}
HashMap eventDescs = new HashMap<String, String>();
eventDescs = eb2.getEventDescriptions();
eventDescs.put("SubjID", resword.getString("study_subject_ID"));
eventDescs.put("ProtocolID", resword.getString("protocol_ID_site_ID"));
eventDescs.put("DOB", resword.getString("date_of_birth"));
eventDescs.put("YOB", resword.getString("year_of_birth"));
eventDescs.put("Gender", resword.getString("gender"));
answer.setDescriptions(eventDescs);
ArrayList generatedReports = new ArrayList<String>();
try {
// YW <<
generatedReports.add(answer.getMetadataFile(svnv, eb2).toString());
generatedReports.add(answer.getDataFile().toString());
// YW >>
} catch (IndexOutOfBoundsException i) {
generatedReports.add(answer.getMetadataFile(svnv, eb2).toString());
logger.debug("throw the error here");
}
long sysTimeEnd = System.currentTimeMillis() - sysTimeBegin;
ArrayList titles = new ArrayList();
// YW <<
titles.add(DDLFileName);
titles.add(SPSSFileName);
// YW >>
// create new createFile method that accepts array lists to
// put into zip files
int fId = this.createFile(ZIPFileName, titles, generalFileDir, generatedReports, db, sysTimeEnd, ExportFormatBean.TXTFILE, true, userBean);
if (!"".equals(generalFileDirCopy)) {
int fId2 = this.createFile(ZIPFileName, titles, generalFileDirCopy, generatedReports, db, sysTimeEnd, ExportFormatBean.TXTFILE, false, userBean);
}
// return DDLFileName;
HashMap answerMap = new HashMap<String, Integer>();
answerMap.put(DDLFileName, new Integer(fId));
return answerMap;
}
Aggregations