List of usage examples for org.dom4j DocumentHelper createDocument
public static Document createDocument()
From source file:gestionecassa.backends.XmlDataBackend.java
License:Open Source License
@Override public void saveListOfOrders(String id, Collection<Order> list) throws IOException { String fileName = xmlDataPath + id + ".xml"; Document document = DocumentHelper.createDocument(); Element root = document.addElement("orders"); for (Order order : list) { addOrderToElement(root, order);/*from ww w .j av a 2 s .com*/ } // for debug purposes OutputFormat format = OutputFormat.createPrettyPrint(); // lets write to a file XMLWriter writer = new XMLWriter(new FileWriter(fileName), format); //XMLWriter writer = new XMLWriter(new FileWriter(fileName)); writer.write(document); writer.close(); }
From source file:gestionecassa.XmlPreferencesHandler.java
License:Open Source License
/** * Saves options to a file given by the option type * @param preferences /*from w w w . ja va2 s. c om*/ * @throws IOException */ public void savePrefs(DataType preferences) throws IOException { Document document = DocumentHelper.createDocument(); Element root = document.addElement("config"); root.addAttribute("version", preferences.getVersion()); root.addAttribute("application", preferences.getApplication()); for (Field field : preferences.getClass().getFields()) { try { root.addElement(field.getName()).addText(field.get(preferences) + ""); } catch (IllegalArgumentException ex) { logger.warn("campo sbagliato", ex); } catch (IllegalAccessException ex) { logger.warn("campo sbagliato", ex); } } // lets write to a file OutputFormat format = OutputFormat.createPrettyPrint(); XMLWriter writer = new XMLWriter(new FileWriter(preferences.getFileName()), format); writer.write(document); writer.close(); }
From source file:gov.nih.nci.caintegrator.application.report.LevelOfExpressionIHCReport.java
License:BSD License
/** * @param finding//w w w. jav a2 s .c om * @param filterMapParams * @return Document */ public static Document getReportXML(Finding finding, Map filterMapParams) { Document document = DocumentHelper.createDocument(); Element report = document.addElement("Report"); Element cell = null; Element data = null; Element dataRow = null; //ADD BASIC ATTRIBUTED report.addAttribute("reportType", "levelExpression"); report.addAttribute("groupBy", "none"); String queryName = finding.getTaskId(); report.addAttribute("queryName", queryName); report.addAttribute("sessionId", "the session id"); StringBuffer sb = new StringBuffer(); /* ************************************************************************************************* * * PROCESS QUERY DETAILS * * ************************************************************************************************* * */ LevelOfExpressionIHCFindingCriteria criteria = (LevelOfExpressionIHCFindingCriteria) finding.getQueryDTO(); ArrayList<String> queryDetails = new ArrayList(); if (criteria != null) { String tmp = ""; ArrayList<String> tmpCollection = new ArrayList<String>(); tmp = criteria.getQueryName() != null ? criteria.getQueryName() : ""; queryDetails.add("Query Name: " + tmp); tmp = ""; if (criteria.getProteinBiomarkerCrit() != null && criteria.getProteinBiomarkerCrit().getProteinNameCollection() != null && !criteria.getProteinBiomarkerCrit().getProteinNameCollection().isEmpty()) { Set<String> biomarkers = criteria.getProteinBiomarkerCrit().getProteinNameCollection(); tmpCollection = new ArrayList<String>(biomarkers); for (String bm : tmpCollection) { if (bm != tmpCollection.get(0)) { tmp += ", " + bm; } else { tmp += bm; } } } queryDetails.add("Biomarker(s): " + tmp); tmpCollection.clear(); tmp = ""; if (criteria.getSpecimenCriteria() != null && criteria.getSpecimenCriteria().getTimeCourseCollection() != null && !criteria.getSpecimenCriteria().getTimeCourseCollection().isEmpty()) { Set<String> timepoints = criteria.getSpecimenCriteria().getTimeCourseCollection(); tmpCollection = new ArrayList<String>(timepoints); TimepointStringComparator ts = new TimepointStringComparator(); Collections.sort(tmpCollection, ts); for (String tc : tmpCollection) { if (tc != tmpCollection.get(0)) { tmp += ", " + tc; } else { tmp += tc; } } } queryDetails.add("Timepoint(s): " + tmp); tmpCollection.clear(); tmp = ""; if (criteria.getStainIntensityCollection() != null && !criteria.getStainIntensityCollection().isEmpty()) { Set<String> intensity = (Set<String>) criteria.getStainIntensityCollection(); tmpCollection = new ArrayList<String>(intensity); for (String in : tmpCollection) { if (in != tmpCollection.get(0)) { tmp += ", " + in; } else { tmp += in; } } } queryDetails.add("Intensity: " + tmp); tmpCollection.clear(); tmp = ""; tmp = criteria.getPercentPositiveRangeMin() != null ? criteria.getPercentPositiveRangeMin().toString() : ""; queryDetails.add("% Positive Min: " + tmp); tmp = ""; tmp = criteria.getPercentPositiveRangeMax() != null ? criteria.getPercentPositiveRangeMax().toString() : ""; queryDetails.add("% Positive Max: " + tmp); tmp = ""; if (criteria.getStainLocalizationCollection() != null && !criteria.getStainLocalizationCollection().isEmpty()) { Set<String> locale = (Set<String>) criteria.getStainLocalizationCollection(); tmpCollection = new ArrayList<String>(locale); for (String lc : tmpCollection) { if (lc != tmpCollection.get(0)) { tmp += ", " + lc; } else { tmp += lc; } } } queryDetails.add("Localization: " + tmp); tmpCollection.clear(); tmp = ""; } String qd = ""; for (String q : queryDetails) { qd += q + " ||| "; } /* ************************************************************************************************************** * * BUILD REPORT AS XML * * ************************************************************************************************************** */ //GET FINDINGS, CAST TO APPROPRIATE FINDINGS AND ADD TO ARRAYLIST (RESULTS) ArrayList dFindings = new ArrayList(finding.getDomainFindings()); ArrayList<LevelOfExpressionIHCFinding> domainFindings = new ArrayList<LevelOfExpressionIHCFinding>( dFindings); ArrayList<LevelOfExpressionIHCFindingReportBean> results = new ArrayList<LevelOfExpressionIHCFindingReportBean>(); for (LevelOfExpressionIHCFinding loef : domainFindings) { LevelOfExpressionIHCFindingReportBean reportBean = new LevelOfExpressionIHCFindingReportBean(loef); results.add(reportBean); } if (!results.isEmpty()) { //SORT THE ARRAYLIST(RESULTS) BY PATIENT DID PatientComparator p = new PatientComparator(); Collections.sort(results, p); //CREATE A HASHMAP SORTED BY PATIENT DID AS THE KEY AND THE ARRAYLIST OF REPORTBEANS AS THE VALUE Map<String, ArrayList<LevelOfExpressionIHCFindingReportBean>> reportBeanMap = new HashMap<String, ArrayList<LevelOfExpressionIHCFindingReportBean>>(); int j = results.size(); for (int i = 0; i < results.size(); i++) { boolean found = false; Set<String> keys = reportBeanMap.keySet(); int key = keys.size(); if (!keys.isEmpty()) { for (String k : keys) { String s = results.get(i).getSpecimenIdentifier() + "_" + results.get(i).getBiomarkerName(); if (s.equals(k)) { found = true; reportBeanMap.get(k).add(results.get(i)); break; } } if (!found) { reportBeanMap.put( results.get(i).getSpecimenIdentifier() + "_" + results.get(i).getBiomarkerName(), new ArrayList<LevelOfExpressionIHCFindingReportBean>()); reportBeanMap.get( results.get(i).getSpecimenIdentifier() + "_" + results.get(i).getBiomarkerName()) .add(results.get(i)); } } else { reportBeanMap.put( results.get(i).getSpecimenIdentifier() + "_" + results.get(i).getBiomarkerName(), new ArrayList<LevelOfExpressionIHCFindingReportBean>()); reportBeanMap .get(results.get(i).getSpecimenIdentifier() + "_" + results.get(i).getBiomarkerName()) .add(results.get(i)); } // } //IF THE USER SELECTED TIMEPOINTS FOR WHICH THAT PATIENT DID DID NOT HAVE DATA, CREATE NULL BEANS SO AS TO RENDER A READABLE REPORT Set<String> b = reportBeanMap.keySet(); for (String g : b) { while (reportBeanMap.get(g) .size() < (reportBeanMap.get(g).get(0).getTimepointHeaders(criteria).size())) { reportBeanMap.get(g) .add(new LevelOfExpressionIHCFindingReportBean(new LevelOfExpressionIHCFinding())); } } //ADD QUERY DETAILS Element details = report.addElement("Query_details"); cell = details.addElement("Data"); cell.addText(qd); cell = null; //ADD HEADERS THAT ARE TIMEPOINT-INDEPENDENT (PATIENT AND BIOMARKER) Element headerRow = report.addElement("Row").addAttribute("name", "headerRow"); ArrayList<String> ntpHeaders = results.get(0).getNonTimepointHeaders(); for (String ntpHeader : ntpHeaders) { cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "ntpHeader"); data = cell.addElement("Data").addAttribute("type", "header").addText(ntpHeader); data = null; cell = null; } //ADD HEADERS THAT ARE TIMEPOINT DEPENDENT ArrayList<String> headers = results.get(0).getHeaders(); for (String header : headers) { cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(header); data = null; cell = null; } //ADD TIMEPOINT SUBHEADERS ArrayList<String> tpHeaders = results.get(0).getTimepointHeaders(criteria); //ArrayList<String> localizations = results.get(0).getTimepointHeaders(criteria); TimepointStringComparator ts = new TimepointStringComparator(); Collections.sort(tpHeaders, ts); Element tpHeaderRow = report.addElement("Row").addAttribute("name", "tpHeaderRow"); // for(String tpHeader : tpHeaders){ for (int i = 0; i < tpHeaders.size(); i++) { cell = tpHeaderRow.addElement("Cell").addAttribute("type", "header") .addAttribute("class", "firstTP").addAttribute("group", "tpHeader"); data = cell.addElement("Data").addAttribute("type", "header").addText(tpHeaders.get(i)); data = null; cell = null; } Set<String> keys = reportBeanMap.keySet(); // ADD DATA ROWS for (String key : keys) { String tp = reportBeanMap.get(key).get(0).getTimepoint(); Collection<String> localizationCollection = criteria.getStainLocalizationCollection(); Collection<String> intensityCollection = criteria.getStainIntensityCollection(); String localization = reportBeanMap.get(key).get(0).getStainLocalization(); String intensity = reportBeanMap.get(key).get(0).getStainIntensity(); if (tpHeaders.contains(tp) && (localizationCollection == null || (localizationCollection != null && localizationCollection.contains(localization))) && (intensityCollection == null || (intensityCollection != null && intensityCollection.contains(intensity)))) { dataRow = report.addElement("Row").addAttribute("name", "dataRow"); cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "sample") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "selectable") .addText(reportBeanMap.get(key).get(0).getPatientDID()); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBeanMap.get(key).get(0).getBiomarkerName()); data = null; cell = null; //GRAB EACH REPORT BEAN IN EACH ARRAYLIST AND MATCH UP TO THE APPROPRIATE TIMEPOINT AS A MAP WITH THE TIMEPOINT AS KEY AND REPORTBEAN THE VALUE ArrayList<LevelOfExpressionIHCFindingReportBean> myList = reportBeanMap.get(key); Map<String, LevelOfExpressionIHCFindingReportBean> myMap = new HashMap<String, LevelOfExpressionIHCFindingReportBean>(); ArrayList<LevelOfExpressionIHCFindingReportBean> mySortedMap = new ArrayList<LevelOfExpressionIHCFindingReportBean>(); for (LevelOfExpressionIHCFindingReportBean ggg : myList) { for (int i = 0; i < tpHeaders.size(); i++) { if (ggg.getTimepoint().equalsIgnoreCase(tpHeaders.get(i))) { myMap.put(tpHeaders.get(i), ggg); break; } else if (ggg.getTimepoint().equals("--")) { if (!myMap.containsKey(tpHeaders.get(i))) { myMap.put(tpHeaders.get(i), ggg); break; } } } } //SORT MAP BY TIMEPOINT SO THAT THE REPORT BEAN DATA CAN EASILY BE DISPLAYED UNDER THE APPROPRIATE TIEMPOINT for (int i = 0; i < tpHeaders.size(); i++) { for (String k : myMap.keySet()) { if (k.equalsIgnoreCase(tpHeaders.get(i))) { mySortedMap.add(myMap.get(k)); } } } //ITERATE OVER THE MAP FOR EACH DATA FIELD WITH ITS CORRESPONDING TIMEPOINT AND BUILD DATA ROWS for (LevelOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getPercentPositive()); data = null; cell = null; } for (LevelOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getStainIntensity()); data = null; cell = null; } for (LevelOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getStainLocalization()); data = null; cell = null; } for (LevelOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getInvasivePresentation()); data = null; cell = null; } for (LevelOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getOverallExpression()); data = null; cell = null; } } } } else { //TODO: handle this error sb.append("<br><Br>Level of Expression is empty<br>"); } return document; }
From source file:gov.nih.nci.caintegrator.application.report.LossOfExpressionIHCReport.java
License:BSD License
public static Document getReportXML(Finding finding, Map filterMapParams) { Document document = DocumentHelper.createDocument(); Element report = document.addElement("Report"); Element cell = null;// w ww .j a va 2 s. co m Element data = null; Element dataRow = null; //ADD BASIC ATTRIBUTED report.addAttribute("reportType", "IHC Loss Of Expression"); report.addAttribute("groupBy", "none"); String queryName = finding.getTaskId(); report.addAttribute("queryName", queryName); report.addAttribute("sessionId", "the session id"); StringBuffer sb = new StringBuffer(); /* ************************************************************************************************* * * PROCESS QUERY DETAILS * * ************************************************************************************************* * */ LossOfExpressionIHCFindingCriteria criteria = (LossOfExpressionIHCFindingCriteria) finding.getQueryDTO(); ArrayList<String> queryDetails = new ArrayList(); if (criteria != null) { String tmp = ""; ArrayList<String> tmpCollection = new ArrayList<String>(); tmp = criteria.getQueryName() != null ? criteria.getQueryName() : ""; queryDetails.add("Query Name: " + tmp); tmp = ""; if (criteria.getProteinBiomarkerCrit() != null && criteria.getProteinBiomarkerCrit().getProteinNameCollection() != null && !criteria.getProteinBiomarkerCrit().getProteinNameCollection().isEmpty()) { Set<String> biomarkers = criteria.getProteinBiomarkerCrit().getProteinNameCollection(); tmpCollection = new ArrayList<String>(biomarkers); for (String bm : tmpCollection) { if (bm != tmpCollection.get(0)) { tmp += ", " + bm; } else { tmp += bm; } } } queryDetails.add("Biomarker(s): " + tmp); tmpCollection.clear(); tmp = ""; if (criteria.getSpecimenCriteria() != null && criteria.getSpecimenCriteria().getTimeCourseCollection() != null && !criteria.getSpecimenCriteria().getTimeCourseCollection().isEmpty()) { Set<String> timepoints = criteria.getSpecimenCriteria().getTimeCourseCollection(); tmpCollection = new ArrayList<String>(timepoints); TimepointStringComparator ts = new TimepointStringComparator(); Collections.sort(tmpCollection, ts); for (String tc : tmpCollection) { if (tc != tmpCollection.get(0)) { tmp += ", " + tc; } else { tmp += tc; } } } queryDetails.add("Timepoint(s): " + tmp); tmpCollection.clear(); tmp = ""; if (criteria.getBenignSumOperator() != null && criteria.getBenignSum() != null) { tmp = criteria.getBenignSumOperator() + " " + criteria.getBenignSum().toString(); } queryDetails.add("Benign Sum: " + tmp); tmp = ""; if (criteria.getInvasiveSumOperator() != null && criteria.getInvasiveSum() != null) { tmp = criteria.getInvasiveSumOperator() + " " + criteria.getInvasiveSum().toString(); } queryDetails.add("Invasive Sum: " + tmp); tmp = ""; if (criteria.getResultCodeCollection() != null && !criteria.getResultCodeCollection().isEmpty()) { Set<String> resultCodes = (Set<String>) criteria.getResultCodeCollection(); tmpCollection = new ArrayList<String>(resultCodes); for (String rc : tmpCollection) { if (rc != tmpCollection.get(0)) { tmp += ", " + rc; } else { tmp += rc; } } } queryDetails.add("Loss Result: " + tmp); tmpCollection.clear(); tmp = ""; } String qd = ""; for (String q : queryDetails) { qd += q + " ||| "; } /* ************************************************************************************************************** * * BUILD REPORT AS XML * * ************************************************************************************************************** */ //GET FINDINGS, CAST TO APPROPRIATE FINDINGS AND ADD TO ARRAYLIST (RESULTS) ArrayList dFindings = new ArrayList(finding.getDomainFindings()); ArrayList<LossOfExpressionIHCFinding> domainFindings = new ArrayList<LossOfExpressionIHCFinding>(dFindings); ArrayList<LossOfExpressionIHCFindingReportBean> results = new ArrayList<LossOfExpressionIHCFindingReportBean>(); for (LossOfExpressionIHCFinding loef : domainFindings) { LossOfExpressionIHCFindingReportBean reportBean = new LossOfExpressionIHCFindingReportBean(loef); results.add(reportBean); } if (!results.isEmpty()) { //SORT THE ARRAYLIST(RESULTS) BY PATIENT DID PatientComparator p = new PatientComparator(); Collections.sort(results, p); //CREATE A HASHMAP SORTED BY PATIENT DID AS THE KEY AND THE ARRAYLIST OF REPORTBEANS AS THE VALUE Map<String, ArrayList<LossOfExpressionIHCFindingReportBean>> reportBeanMap = new HashMap<String, ArrayList<LossOfExpressionIHCFindingReportBean>>(); for (int i = 0; i < results.size(); i++) { boolean found = false; Set<String> keys = reportBeanMap.keySet(); if (!keys.isEmpty()) { for (String k : keys) { String s = results.get(i).getSpecimenIdentifier() + "_" + results.get(i).getBiomarkerName(); if (s.equals(k)) { found = true; reportBeanMap.get(k).add(results.get(i)); break; } } if (!found) { reportBeanMap.put( results.get(i).getSpecimenIdentifier() + "_" + results.get(i).getBiomarkerName(), new ArrayList<LossOfExpressionIHCFindingReportBean>()); reportBeanMap.get( results.get(i).getSpecimenIdentifier() + "_" + results.get(i).getBiomarkerName()) .add(results.get(i)); } } else { reportBeanMap.put( results.get(i).getSpecimenIdentifier() + "_" + results.get(i).getBiomarkerName(), new ArrayList<LossOfExpressionIHCFindingReportBean>()); reportBeanMap .get(results.get(i).getSpecimenIdentifier() + "_" + results.get(i).getBiomarkerName()) .add(results.get(i)); } } //IF THE USER SELECTED TIMEPOINTS FOR WHICH THAT PATIENT DID DID NOT HAVE DATA, CREATE NULL BEANS SO AS TO RENDER A READABLE REPORT Set<String> b = reportBeanMap.keySet(); for (String g : b) { while (reportBeanMap.get(g) .size() < (reportBeanMap.get(g).get(0).getTimepointHeaders(criteria).size())) { reportBeanMap.get(g) .add(new LossOfExpressionIHCFindingReportBean(new LossOfExpressionIHCFinding())); } } //ADD QUERY DETAILS Element details = report.addElement("Query_details"); cell = details.addElement("Data"); cell.addText(qd); cell = null; //ADD HEADERS THAT ARE TIMEPOINT-INDEPENDENT (PATIENT AND BIOMARKER) Element headerRow = report.addElement("Row").addAttribute("name", "headerRow"); ArrayList<String> ntpHeaders = results.get(0).getNonTimepointHeaders(); for (String ntpHeader : ntpHeaders) { cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "ntpHeader"); data = cell.addElement("Data").addAttribute("type", "header").addText(ntpHeader); data = null; cell = null; } //ADD HEADERS THAT ARE TIMEPOINT DEPENDENT ArrayList<String> headers = results.get(0).getHeaders(); for (String header : headers) { cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(header); data = null; cell = null; } //ADD TIMEPOINT SUBHEADERS ArrayList<String> tpHeaders = results.get(0).getTimepointHeaders(criteria); TimepointStringComparator ts = new TimepointStringComparator(); Collections.sort(tpHeaders, ts); Element tpHeaderRow = report.addElement("Row").addAttribute("name", "tpHeaderRow"); // for(String tpHeader : tpHeaders){ for (int i = 0; i < tpHeaders.size(); i++) { cell = tpHeaderRow.addElement("Cell").addAttribute("type", "header") .addAttribute("class", "firstTP").addAttribute("group", "tpHeader"); data = cell.addElement("Data").addAttribute("type", "header").addText(tpHeaders.get(i)); data = null; cell = null; } Set<String> keys = reportBeanMap.keySet(); // ADD DATA ROWS for (String key : keys) { String tp = reportBeanMap.get(key).get(0).getTimepoint(); Integer invasiveSumCrit = criteria.getInvasiveSum(); String invasiveSumOpCrit = criteria.getInvasiveSumOperator(); String invasiveSum = reportBeanMap.get(key).get(0).getInvasiveSum(); String invasiveSumOp = reportBeanMap.get(key).get(0).getInvasiveSumOperator(); int j = 0; if (invasiveSumCrit != null && invasiveSumOpCrit != null) { j = new Integer(invasiveSum).compareTo(invasiveSumCrit); } Integer benignSumCrit = criteria.getBenignSum(); String benignSumOpCrit = criteria.getBenignSumOperator(); String benignSum = reportBeanMap.get(key).get(0).getBenignSum(); String benignSumOp = reportBeanMap.get(key).get(0).getBenignSumOperator(); int h = 0; if (benignSumCrit != null && benignSumOpCrit != null) { h = new Integer(benignSum).compareTo(benignSumCrit); } Collection<String> resultCodeCollection = criteria.getResultCodeCollection(); String resultCode = reportBeanMap.get(key).get(0).getLossResult(); // filter time points, invasice sum, benign sum, and result code to match what were in the search criteria if (tpHeaders.contains(tp) && (resultCodeCollection == null || (resultCodeCollection != null && resultCodeCollection.contains(resultCode))) && ((invasiveSumCrit == null && invasiveSumOpCrit == null) || (invasiveSumCrit != null && (invasiveSumOpCrit != null && invasiveSumOpCrit.equals("=")) && invasiveSumCrit.toString().equals(invasiveSum)) || (invasiveSumCrit != null && (invasiveSumOpCrit != null && invasiveSumOpCrit.equals(">=")) && j >= 0) || (invasiveSumCrit != null && (invasiveSumOpCrit != null && invasiveSumOpCrit.equals("<=")) && j <= 0)) && ((benignSumCrit == null && benignSumOpCrit == null) || (benignSumCrit != null && (benignSumOpCrit != null && benignSumOpCrit.equals("=")) && benignSumCrit.toString().equals(benignSum)) || (benignSumCrit != null && (benignSumOpCrit != null && benignSumOpCrit.equals(">=")) && h >= 0) || (benignSumCrit != null && (benignSumOpCrit != null && benignSumOpCrit.equals("<=")) && h <= 0))) { dataRow = report.addElement("Row").addAttribute("name", "dataRow"); cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "sample") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "selectable") .addText(reportBeanMap.get(key).get(0).getPatientDID()); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBeanMap.get(key).get(0).getBiomarkerName()); data = null; cell = null; //GRAB EACH REPORT BEAN IN EACH ARRAYLIST AND MATCH UP TO THE APPROPRIATE TIMEPOINT AS A MAP WITH THE TIMEPOINT AS KEY AND REPORTBEAN THE VALUE ArrayList<LossOfExpressionIHCFindingReportBean> myList = reportBeanMap.get(key); Map<String, LossOfExpressionIHCFindingReportBean> myMap = new HashMap<String, LossOfExpressionIHCFindingReportBean>(); ArrayList<LossOfExpressionIHCFindingReportBean> mySortedMap = new ArrayList<LossOfExpressionIHCFindingReportBean>(); for (LossOfExpressionIHCFindingReportBean ggg : myList) { for (int i = 0; i < tpHeaders.size(); i++) { if (ggg.getTimepoint().equalsIgnoreCase(tpHeaders.get(i))) { myMap.put(tpHeaders.get(i), ggg); break; } else if (ggg.getTimepoint().equals("--")) { if (!myMap.containsKey(tpHeaders.get(i))) { myMap.put(tpHeaders.get(i), ggg); break; } } } } //SORT MAP BY TIMEPOINT SO THAT THE REPORT BEAN DATA CAN EASILY BE DISPLAYED UNDER THE APPROPRIATE TIEMPOINT for (int i = 0; i < tpHeaders.size(); i++) { for (String k : myMap.keySet()) { if (k.equalsIgnoreCase(tpHeaders.get(i))) { mySortedMap.add(myMap.get(k)); } } } //ITERATE OVER THE MAP FOR EACH DATA FIELD WITH ITS CORRESPONDING TIMEPOINT AND BUILD DATA ROWS for (LossOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getBenignPresentValue()); data = null; cell = null; } if (invasiveSumOp.equals("--")) { for (LossOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data") .addAttribute("class", "data").addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getInvasiveSum()); data = null; cell = null; } } for (LossOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getBenignSum()); data = null; cell = null; } for (LossOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getInvasiveBenignDiff()); data = null; cell = null; } for (LossOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getComments()); data = null; cell = null; } for (LossOfExpressionIHCFindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getLossResult()); data = null; cell = null; } } } } else { //TODO: handle this error sb.append("<br><Br>Loss of Expression is empty<br>"); } return document; }
From source file:gov.nih.nci.caintegrator.application.report.P53Report.java
License:BSD License
/** * @param finding//from ww w. j av a2s . c o m * @param filterMapParams * @return Document */ public static Document getReportXML(Finding finding, Map filterMapParams) { Document document = DocumentHelper.createDocument(); Element report = document.addElement("Report"); Element cell = null; Element data = null; Element dataRow = null; //ADD BASIC ATTRIBUTED report.addAttribute("reportType", "p53Mutation"); report.addAttribute("groupBy", "none"); String queryName = finding.getTaskId(); report.addAttribute("queryName", queryName); report.addAttribute("sessionId", "the session id"); StringBuffer sb = new StringBuffer(); /* ************************************************************************************************* * * PROCESS QUERY DETAILS * * ************************************************************************************************* * */ P53FindingCriteria criteria = (P53FindingCriteria) finding.getQueryDTO(); ArrayList<String> queryDetails = new ArrayList(); if (criteria != null) { String tmp = ""; ArrayList<String> tmpCollection = new ArrayList<String>(); tmp = criteria.getQueryName() != null ? criteria.getQueryName() : ""; queryDetails.add("Query Name: " + tmp); tmp = ""; if (criteria.getSpecimenCriteria() != null && criteria.getSpecimenCriteria().getTimeCourseCollection() != null && !criteria.getSpecimenCriteria().getTimeCourseCollection().isEmpty()) { Set<String> timepoints = criteria.getSpecimenCriteria().getTimeCourseCollection(); tmpCollection = new ArrayList<String>(timepoints); TimepointStringComparator ts = new TimepointStringComparator(); Collections.sort(tmpCollection, ts); for (String tc : tmpCollection) { if (tc != tmpCollection.get(0)) { tmp += ", " + tc; } else { tmp += tc; } } } queryDetails.add("Timepoint(s): " + tmp); tmpCollection.clear(); tmp = ""; if (criteria.getMutationStatusCollection() != null && !criteria.getMutationStatusCollection().isEmpty()) { Set<String> mutationStatus = (Set<String>) criteria.getMutationStatusCollection(); tmpCollection = new ArrayList<String>(mutationStatus); for (String in : tmpCollection) { if (in != tmpCollection.get(0)) { tmp += ", " + in; } else { tmp += in; } } } queryDetails.add("Mutation Status: " + tmp); tmpCollection.clear(); tmp = ""; if (criteria.getMutationTypeCollection() != null && !criteria.getMutationTypeCollection().isEmpty()) { Set<String> mutationType = (Set<String>) criteria.getMutationTypeCollection(); tmpCollection = new ArrayList<String>(mutationType); for (String lc : tmpCollection) { if (lc != tmpCollection.get(0)) { tmp += ", " + lc; } else { tmp += lc; } } } queryDetails.add("Mutation Type: " + tmp); tmpCollection.clear(); tmp = ""; } String qd = ""; for (String q : queryDetails) { qd += q + " ||| "; } /* ************************************************************************************************************** * * BUILD REPORT AS XML * * ************************************************************************************************************** */ //GET FINDINGS, CAST TO APPROPRIATE FINDINGS AND ADD TO ARRAYLIST (RESULTS) ArrayList dFindings = new ArrayList(finding.getDomainFindings()); ArrayList<P53MutationFinding> domainFindings = new ArrayList<P53MutationFinding>(dFindings); ArrayList<P53FindingReportBean> results = new ArrayList<P53FindingReportBean>(); for (P53MutationFinding p53f : domainFindings) { P53FindingReportBean reportBean = new P53FindingReportBean(p53f); results.add(reportBean); } if (!results.isEmpty()) { //SORT THE ARRAYLIST(RESULTS) BY PATIENT DID PatientComparator p = new PatientComparator(); Collections.sort(results, p); //CREATE A HASHMAP SORTED BY PATIENT DID AS THE KEY AND THE ARRAYLIST OF REPORTBEANS AS THE VALUE // Map<String,ArrayList<P53FindingReportBean>> reportBeanMap = new HashMap<String,ArrayList<P53FindingReportBean>>(); Map<String, ArrayList<P53FindingReportBean>> reportBeanMap = new HashMap<String, ArrayList<P53FindingReportBean>>(); int j = results.size(); for (int i = 0; i < results.size(); i++) { boolean found = false; Set<String> keys = reportBeanMap.keySet(); int key = keys.size(); if (!keys.isEmpty()) { for (String k : keys) { String s = results.get(i).getSpecimenIdentifier(); if (s.equals(k)) { found = true; reportBeanMap.get(k).add(results.get(i)); break; } } if (!found) { reportBeanMap.put(results.get(i).getSpecimenIdentifier(), new ArrayList<P53FindingReportBean>()); reportBeanMap.get(results.get(i).getSpecimenIdentifier()).add(results.get(i)); } } else { reportBeanMap.put(results.get(i).getSpecimenIdentifier(), new ArrayList<P53FindingReportBean>()); reportBeanMap.get(results.get(i).getSpecimenIdentifier()).add(results.get(i)); } // } //IF THE USER SELECTED TIMEPOINTS FOR WHICH THAT PATIENT DID DID NOT HAVE DATA, CREATE NULL BEANS SO AS TO RENDER A READABLE REPORT Set<String> b = reportBeanMap.keySet(); for (String g : b) { while (reportBeanMap.get(g) .size() < (reportBeanMap.get(g).get(0).getTimepointHeaders(criteria).size())) { reportBeanMap.get(g).add(new P53FindingReportBean(new P53MutationFinding())); } } //ADD QUERY DETAILS Element details = report.addElement("Query_details"); cell = details.addElement("Data"); cell.addText(qd); cell = null; //ADD HEADERS THAT ARE TIMEPOINT-INDEPENDENT (PATIENT) Element headerRow = report.addElement("Row").addAttribute("name", "headerRow"); ArrayList<String> ntpHeaders = results.get(0).getNonTimepointHeaders(); for (String ntpHeader : ntpHeaders) { // on the report page, should not display labtrak id if (!ntpHeader.equalsIgnoreCase("LabTrak ID")) { cell = headerRow.addElement("Cell").addAttribute("type", "header") .addAttribute("class", "header").addAttribute("group", "ntpHeader"); data = cell.addElement("Data").addAttribute("type", "header").addText(ntpHeader); data = null; cell = null; } } //ADD HEADERS THAT ARE TIMEPOINT DEPENDENT ArrayList<String> headers = results.get(0).getHeaders(); for (String header : headers) { cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText(header); data = null; cell = null; } //ADD TIMEPOINT SUBHEADERS ArrayList<String> tpHeaders = results.get(0).getTimepointHeaders(criteria); TimepointStringComparator ts = new TimepointStringComparator(); Collections.sort(tpHeaders, ts); Element tpHeaderRow = report.addElement("Row").addAttribute("name", "tpHeaderRow"); // this is leave the first space empty cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "ntpHeader"); data = cell.addElement("Data").addAttribute("type", "header").addText(""); System.out.println(")))" + data.toString()); data = null; cell = null; for (int i = 0; i < tpHeaders.size(); i++) { cell = tpHeaderRow.addElement("Cell").addAttribute("type", "header") .addAttribute("class", "firstTP").addAttribute("group", "tpHeader"); data = cell.addElement("Data").addAttribute("type", "header").addText(tpHeaders.get(i)); data = null; cell = null; } Set<String> keys = reportBeanMap.keySet(); // ADD DATA ROWS for (String key : keys) { String tp = reportBeanMap.get(key).get(0).getTimepoint(); Collection<String> mutationStatusCollection = criteria.getMutationStatusCollection(); Collection<String> mutationTypeCollection = criteria.getMutationTypeCollection(); String mutationStatus = reportBeanMap.get(key).get(0).getMutationStatus(); String mutationType = reportBeanMap.get(key).get(0).getMutationType(); if (tpHeaders.contains(tp) && (mutationStatusCollection == null || (mutationStatusCollection != null && mutationStatusCollection.contains(mutationStatus))) && (mutationTypeCollection == null || (mutationTypeCollection != null && mutationTypeCollection.contains(mutationType)))) { dataRow = report.addElement("Row").addAttribute("name", "dataRow"); cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "sample") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "selectable") .addText(reportBeanMap.get(key).get(0).getPatientDID()); data = null; cell = null; //GRAB EACH REPORT BEAN IN EACH ARRAYLIST AND MATCH UP TO THE APPROPRIATE TIMEPOINT AS A MAP WITH THE TIMEPOINT AS KEY AND REPORTBEAN THE VALUE ArrayList<P53FindingReportBean> myList = reportBeanMap.get(key); Map<String, P53FindingReportBean> myMap = new HashMap<String, P53FindingReportBean>(); ArrayList<P53FindingReportBean> mySortedMap = new ArrayList<P53FindingReportBean>(); for (P53FindingReportBean ggg : myList) { for (int i = 0; i < tpHeaders.size(); i++) { if (ggg.getTimepoint().equalsIgnoreCase(tpHeaders.get(i))) { myMap.put(tpHeaders.get(i), ggg); break; } else if (ggg.getTimepoint().equals("--")) { if (!myMap.containsKey(tpHeaders.get(i))) { myMap.put(tpHeaders.get(i), ggg); break; } } } } //SORT MAP BY TIMEPOINT SO THAT THE REPORT BEAN DATA CAN EASILY BE DISPLAYED UNDER THE APPROPRIATE TIEMPOINT for (int i = 0; i < tpHeaders.size(); i++) { for (String k : myMap.keySet()) { if (k.equalsIgnoreCase(tpHeaders.get(i))) { mySortedMap.add(myMap.get(k)); } } } //ITERATE OVER THE MAP FOR EACH DATA FIELD WITH ITS CORRESPONDING TIMEPOINT AND BUILD DATA ROWS for (P53FindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getMutationStatus()); data = null; cell = null; } for (P53FindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getMutationType()); data = null; cell = null; } for (P53FindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getExonOrIntronLocation()); data = null; cell = null; } for (P53FindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getBaseChange()); data = null; cell = null; } for (P53FindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getCodonAminoacidChange()); data = null; cell = null; } for (P53FindingReportBean reportBean : mySortedMap) { cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(reportBean.getProteinStructuralDomain()); data = null; cell = null; } } } } else { //TODO: handle this error sb.append("<br><Br>Level of Expression is empty<br>"); } return document; }
From source file:gov.nih.nci.ispy.web.reports.quick.QuickClinicalReport.java
License:BSD License
public static StringBuffer quickSampleReport(String sessionId, String taskId) { BusinessTierCache cacheManager = ApplicationFactory.getBusinessTierCache(); ISPYClinicalFinding clinicalFinding = (ISPYClinicalFinding) cacheManager .getObjectFromSessionCache(sessionId, taskId); StringBuffer html = new StringBuffer(); List<PatientData> patientsData = clinicalFinding.getPatientData(); if (!patientsData.isEmpty()) { ImagingFileBasedQueryService iqs = (ImagingFileBasedQueryService) ImagingFileBasedQueryService .getInstance();/* ww w.ja va 2 s . co m*/ Document document = DocumentHelper.createDocument(); Element table = document.addElement("table").addAttribute("id", "reportTable").addAttribute("class", "report"); Element tr = null; Element td = null; tr = table.addElement("tr").addAttribute("class", "header"); // String longHeaders = "ISPY_ID, NCIA_IMAGE, INST_ID, AGE, AGECAT, RACE_ID, SSTAT, SURVDTD, CHEMOCAT, CHEMO, TAM, HERCEPTIN, DOSEDENSEANTHRA, DOSEDENSETAXANE, MENOSTATUS, SENTINELNODESAMPLE, SENTINELNODERESULT, HIST_TYPE_INV_OS, HISTOLOGICGRADEOS, ER_TS, PGR_TS, ERPOS, PGRPOS, HER2COMMUNITYPOS, HER2COMMUNITYMETHOD, SURGERYLUMPECTOMY, SURGERYMASTECTOMY, HISTOLOGICTYPEPS, INITLUMP_FUPMAST, SURGERY, REASON_NO_SURG, RTTHERAPY, RTBREAST, RTBOOST, RTAXILLA, RTSNODE, RTIMAMNODE, RTCHESTW, RTOTHER, TSIZECLINICAL, NSIZECLINICAL, STAGETE, STAGENE, STAGEME, CLINICALSTAGE, CLINRESPT1_T2, CLINRESPT1_T3, CLINRESPT1_T4, Morphologic pattern at T1, LES_T1, LES_T2, LES_T3, LES_T4, LD_T1, LD_T2, LD_T3, LD_T4, MRI % change T1_T2, MRI % change T1_T3, MRI % change T1_T4," + // "MRI % change T2_T3, MRI % change T2_T4, MRI % change T3_T4, DCISONLYPS, PTUMOR1SZCM_MICRO_1, HISTOLOGICGRADEPS, NUMPOSNODESPS, NODESEXAMINEDPS, PATHOLOGYSTAGEPS,InSituHistoPS, InvDzHistoPS, InvDzMultiFoc, InvDzCellularity, SurgMargins, yT, yN, yM, RCBIndex, localProgTimeD (days), distProgTimeD (days)"; // 04-17-2010, delete following columns: HISTOLOGICTYPEPS, LES_T1, LES_T2, LES_T3, LES_T4, LD_T1, LD_T2, LD_T3, LD_T4, String longHeaders = "ISPY_ID, NCIA_IMAGE, INST_ID, AGE, AGECAT, RACE_ID, SSTAT, SURVDTD, CHEMOCAT, CHEMO, TAM, HERCEPTIN, DOSEDENSEANTHRA, DOSEDENSETAXANE, MENOSTATUS, SENTINELNODESAMPLE, SENTINELNODERESULT, HIST_TYPE_INV_OS, HISTOLOGICGRADEOS, ER_TS, PGR_TS, ERPOS, PGRPOS, HER2COMMUNITYPOS, HER2COMMUNITYMETHOD, SURGERYLUMPECTOMY, SURGERYMASTECTOMY, INITLUMP_FUPMAST, SURGERY, REASON_NO_SURG, RTTHERAPY, RTBREAST, RTBOOST, RTAXILLA, RTSNODE, RTIMAMNODE, RTCHESTW, RTOTHER, TSIZECLINICAL, NSIZECLINICAL, STAGETE, STAGENE, STAGEME, CLINICALSTAGE, CLINRESPT1_T2, CLINRESPT1_T3, CLINRESPT1_T4, Morphologic pattern at T1, MRI % change T1_T2, MRI % change T1_T3, MRI % change T1_T4," + "MRI % change T2_T3, MRI % change T2_T4, MRI % change T3_T4, DCISONLYPS, PTUMOR1SZCM_MICRO_1, HISTOLOGICGRADEPS, NUMPOSNODESPS, NODESEXAMINEDPS, PATHOLOGYSTAGEPS,InSituHistoPS, InvDzHistoPS, InvDzMultiFoc, InvDzCellularity, SurgMargins, yT, yN, yM, RCBIndex, localProgTimeD (days), distProgTimeD (days)"; String[] heads = StringUtils.split(longHeaders, ","); for (String h : heads) { td = tr.addElement("td").addAttribute("class", "header").addText(h.trim()); } for (PatientData pd : patientsData) { tr = table.addElement("tr").addAttribute("class", "data"); String tmp = ""; String dv = "-"; if (pd == null) { for (int i = 0; i < heads.length - 2; i++) { td = tr.addElement("td").addAttribute("class", "header").addText(dv); } } else if (pd != null) { tmp = pd.getISPY_ID() != null ? pd.getISPY_ID() : dv; td = tr.addElement("td").addText(tmp).addAttribute("name", "patient") .addAttribute("class", "patient").addAttribute("id", tmp).addElement("input") .addAttribute("type", "checkbox").addAttribute("name", "checkable") .addAttribute("class", "saveElement").addAttribute("value", pd.getISPY_ID()); if (iqs.hasImagingData(pd.getISPY_ID())) { String link = iqs.buildImagingLink(pd); try { String encodedLink = URLEncoder.encode(link, "UTF-8"); td = tr.addElement("td").addElement("a") .addAttribute("onclick", "javascript:window.open('" + link + "','new','toolbar=yes,width=800,height=600,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');") .addElement("img").addAttribute("src", "images/nciaLink.png"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { td = tr.addElement("td").addText(dv); } tmp = pd.getInst_ID() != null ? pd.getInst_ID() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getPatientAge() != null ? pd.getPatientAge().toString() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getAgeCategory() != null ? pd.getAgeCategory().toString() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRace() != null ? pd.getRace().toString() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSSTAT() != null ? pd.getSSTAT() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSURVDTD() != null ? pd.getSURVDTD() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getChemoCat() != null ? pd.getChemoCat() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getChemo() != null ? pd.getChemo() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getTAM() != null ? pd.getTAM() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getHerceptin() != null ? pd.getHerceptin() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getDosedenseanthra() != null ? pd.getDosedenseanthra() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getDosedensetaxane() != null ? pd.getDosedensetaxane() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMenoStatus() != null ? pd.getMenoStatus() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSentinelNodeSample() != null ? pd.getSentinelNodeSample() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSentinelNodeResult() != null ? pd.getSentinelNodeResult() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getHistTypeOfInvasiveTumor() != null ? pd.getHistTypeOfInvasiveTumor() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getHistologicGradeOS() != null ? pd.getHistologicGradeOS() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getER_TS() != null ? pd.getER_TS() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getPGR_TS() != null ? pd.getPGR_TS() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getERpos() != null ? pd.getERpos() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getPgRpos() != null ? pd.getPgRpos() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getHER2CommunityPOS() != null ? pd.getHER2CommunityPOS() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getHER2CommunityMethod() != null ? pd.getHER2CommunityMethod() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSurgeryLumpectomy() != null ? pd.getSurgeryLumpectomy() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSurgeryMastectomy() != null ? pd.getSurgeryMastectomy() : dv; td = tr.addElement("td").addText(tmp); //04-17-2010, delete HISTOLOGICTYPEPS // tmp = pd.getHistTypePS()!=null ? pd.getHistTypePS() : dv; // td = tr.addElement("td").addText(tmp); tmp = pd.getINITLUMP_FUPMAST() != null ? pd.getINITLUMP_FUPMAST() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSurgery() != null ? pd.getSurgery() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getReasonNoSurg() != null ? pd.getReasonNoSurg() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTTherapy() != null ? pd.getRTTherapy() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTBreast() != null ? pd.getRTBreast() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTBOOST() != null ? pd.getRTBOOST() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTAXILLA() != null ? pd.getRTAXILLA() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTSNODE() != null ? pd.getRTSNODE() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTIMAMNODE() != null ? pd.getRTIMAMNODE() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTChestW() != null ? pd.getRTChestW() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTOTHER() != null ? pd.getRTOTHER() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getTSizeClinical() != null ? pd.getTSizeClinical() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getNSizeClinical() != null ? pd.getNSizeClinical() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getStageTE() != null ? pd.getStageTE() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getStageNE() != null ? pd.getStageNE() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSTAGEME() != null ? pd.getSTAGEME() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getClinicalStageStr() != null ? pd.getClinicalStageStr() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getClinRespT1_T2() != null ? pd.getClinRespT1_T2() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getClinRespT1_T3() != null ? pd.getClinRespT1_T3() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getClinRespT1_T4() != null ? pd.getClinRespT1_T4() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMorphology() != null ? pd.getMorphology().toString() : dv; td = tr.addElement("td").addText(tmp); // 04-17-2010, delete LES_T1, LES_T2, LES_T3, LES_T4, LD_T1, LD_T2, LD_T3, LD_T4 // tmp = pd.getLES_T1()!=null ? pd.getLES_T1() : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLES_T2()!=null ? pd.getLES_T2() : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLES_T3()!=null ? pd.getLES_T3() : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLES_T4()!=null ? pd.getLES_T4() : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLdT1()!=null ? Double.toString(pd.getLdT1()) : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLdT2()!=null ? Double.toString(pd.getLdT2()) : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLdT3()!=null ? Double.toString(pd.getLdT3()) : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLdT4()!=null ? Double.toString(pd.getLdT4()) : dv; // td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT1_T2() != null ? String.valueOf(pd.getMriPctChangeT1_T2()) : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT1_T3() != null ? String.valueOf(pd.getMriPctChangeT1_T3()) : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT1_T4() != null ? String.valueOf(pd.getMriPctChangeT1_T4()) : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT2_T3() != null ? Double.toString(pd.getMriPctChangeT2_T3()) : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT2_T4() != null ? Double.toString(pd.getMriPctChangeT2_T4()) : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT3_T4() != null ? Double.toString(pd.getMriPctChangeT3_T4()) : dv; td = tr.addElement("td").addText(tmp); // dispaly path data // change dcisonly to dcisonlyps tmp = pd.getDCISOnlyPS() != null ? pd.getDCISOnlyPS() : dv; td = tr.addElement("td").addText(tmp); // Ptumor1szcm_micro_1 tmp = pd.getPtumor1szcm_micro_1() != null ? pd.getPtumor1szcm_micro_1().toString() : dv; td = tr.addElement("td").addText(tmp); // HistologicGradePS tmp = pd.getHistologicGradePS() != null ? pd.getHistologicGradePS() : dv; td = tr.addElement("td").addText(tmp); //NumPosNodes tmp = pd.getNumPosNodesPS() != null ? pd.getNumPosNodesPS() : dv; td = tr.addElement("td").addText(tmp); //NodesExamined tmp = pd.getNodesExaminedPS() != null ? pd.getNodesExaminedPS() : dv; td = tr.addElement("td").addText(tmp); // PathologyStage tmp = pd.getPathologyStagePS() != null ? pd.getPathologyStagePS() : dv; td = tr.addElement("td").addText(tmp); // InSituHisto tmp = pd.getInSituHistoPS() != null ? pd.getInSituHistoPS() : dv; td = tr.addElement("td").addText(tmp); // invDzHisto tmp = pd.getInvDzHistoPS() != null ? pd.getInvDzHistoPS() : dv; td = tr.addElement("td").addText(tmp); //invDzMultiFoc tmp = pd.getInvDzMultiFoc() != null ? pd.getInvDzMultiFoc() : dv; td = tr.addElement("td").addText(tmp); //invDzCellularity tmp = pd.getInvDzCellularity() != null ? pd.getInvDzCellularity() : dv; td = tr.addElement("td").addText(tmp); //surgMargins tmp = pd.getSurgMargins() != null ? pd.getSurgMargins() : dv; td = tr.addElement("td").addText(tmp); //yT tmp = pd.getYT() != null ? pd.getYT() : dv; td = tr.addElement("td").addText(tmp); //yN tmp = pd.getYN() != null ? pd.getYN() : dv; td = tr.addElement("td").addText(tmp); //yM tmp = pd.getYM() != null ? pd.getYM() : dv; td = tr.addElement("td").addText(tmp); // rcb index tmp = pd.getRcbIndexSize() != null ? pd.getRcbIndexSize() : dv; td = tr.addElement("td").addText(tmp); //localProgTimeD:days tmp = (pd.getLocalProgTimeD() != null && pd.getLocalProgTimeD().toString().indexOf("-") == -1) ? pd.getLocalProgTimeD().toString() : dv; td = tr.addElement("td").addText(tmp); //distProgTimeD:days tmp = pd.getDistProgTimeD() != null ? pd.getDistProgTimeD().toString() : dv; td = tr.addElement("td").addText(tmp); } } html.append(document.asXML()); } else { html.append("No Data for selected clinical parameters"); } return html; }
From source file:gov.nih.nci.ispy.web.reports.quick.QuickClinicalReport.java
License:BSD License
public static StringBuffer quickSampleReport(List<String> sampleIds, String sessionId, String taskId) { Set set = new HashSet(); set.addAll(sampleIds);//from w w w. j a v a2 s . c om if (set.size() < sampleIds.size()) { sampleIds.clear(); sampleIds.addAll(set); } String dv = "-"; StringBuffer html = new StringBuffer(); Document document = DocumentHelper.createDocument(); if (sampleIds != null) { try { IdMapperFileBasedService idMapper = IdMapperFileBasedService.getInstance(); ImagingFileBasedQueryService iqs = (ImagingFileBasedQueryService) ImagingFileBasedQueryService .getInstance(); //List<RegistrantInfo> registrants = List<SampleInfo> samples = idMapper.getSampleInfoForLabtrackIds(sampleIds); //List<ClinicalData> clinicalDataList = new ArrayList<ClinicalData>(); ClinicalDataService cqs = ClinicalDataServiceFactory.getInstance(); List<PatientData> pdList = new ArrayList<PatientData>(); if (samples.isEmpty()) { html.append("No Data"); return html; } //WHEN switching to the new PatientData method of getting data //remove the for loop below /* for (SampleInfo si : samples) { clinicalDataList.add(cqs.getClinicalDataForPatientDID(si.getISPYId(), si.getTimepoint())); } */ if (sampleIds != null) { int count = 0; Element table = document.addElement("table").addAttribute("id", "reportTable") .addAttribute("class", "report"); Element tr = null; Element td = null; tr = table.addElement("tr").addAttribute("class", "header"); //String longHeaders = "ISPY_ID, LabTrak ID, NCIA_IMAGE, INST_ID, AGE, AGECAT, RACE_ID, SSTAT, SURVDTD, CHEMOCAT, CHEMO, TAM, HERCEPTIN, MENOSTATUS, SENTINELNODESAMPLE, SENTINELNODERESULT, HIST_TYPE_INV_OS, HISTOLOGICGRADEOS, ER_TS, PGR_TS, HER2COMMUNITYPOS, HER2COMMUNITYMETHOD, SURGERYLUMPECTOMY, SURGERYMASTECTOMY, HISTOLOGICTYPEPS, INITLUMP_FUPMAST, SURGERY, DCISONLYPS, PTUMOR1SZCM_MICRO, HISTOLOGICGRADEPS, NUMPOSNODESPS, NODESEXAMINEDPS, PATHOLOGYSTAGEPS, REASON_NO_SURG, RTTHERAPY, RTBREAST, RTBOOST, RTAXILLA, RTSNODE, RTIMAMNODE, RTCHESTW, RTOTHER, TSIZECLINICAL, NSIZECLINICAL, STAGETE, STAGENE, STAGEME, CLINICALSTAGE, CLINRESPT1_T2, CLINRESPT1_T3, CLINRESPT1_T4, Morphologic pattern at T1, LES_T1, LES_T2, LES_T3, LES_T4, LD_T1, LD_T2, LD_T3, LD_T4, MRI % change T1_T2, MRI % change T1_T3, MRI % change T1_T4," + //"MRI % change T2_T3, MRI % change T2_T4, MRI % change T3_T4"; // String longHeaders = "ISPY_ID, LabTrak ID, NCIA_IMAGE, INST_ID, AGE, AGECAT, RACE_ID, SSTAT, SURVDTD, CHEMOCAT, CHEMO, TAM, HERCEPTIN, DOSEDENSEANTHRA, DOSEDENSETAXANE, MENOSTATUS, SENTINELNODESAMPLE, SENTINELNODERESULT, HIST_TYPE_INV_OS, HISTOLOGICGRADEOS, ER_TS, PGR_TS, HER2COMMUNITYPOS, HER2COMMUNITYMETHOD, SURGERYLUMPECTOMY, SURGERYMASTECTOMY, HISTOLOGICTYPEPS, INITLUMP_FUPMAST, SURGERY, DCISONLYPS, PTUMOR1SZCM_MICRO, HISTOLOGICGRADEPS, NUMPOSNODESPS, NODESEXAMINEDPS, PATHOLOGYSTAGEPS, REASON_NO_SURG, RTTHERAPY, RTBREAST, RTBOOST, RTAXILLA, RTSNODE, RTIMAMNODE, RTCHESTW, RTOTHER, TSIZECLINICAL, NSIZECLINICAL, STAGETE, STAGENE, STAGEME, CLINICALSTAGE, CLINRESPT1_T2, CLINRESPT1_T3, CLINRESPT1_T4, Morphologic pattern at T1, LES_T1, LES_T2, LES_T3, LES_T4, LD_T1, LD_T2, LD_T3, LD_T4, MRI % change T1_T2, MRI % change T1_T3, MRI % change T1_T4," + // "MRI % change T2_T3, MRI % change T2_T4, MRI % change T3_T4"; // these are the fields from the new clincial data and pathology data file: 10/22-2007, this method is used when trying to obtain clincial data from hoa reports // String longHeaders = "ISPY_ID, LabTrak ID, NCIA_IMAGE, INST_ID, AGE, AGECAT, RACE_ID, SSTAT, SURVDTD, CHEMOCAT, CHEMO, TAM, HERCEPTIN, DOSEDENSEANTHRA, DOSEDENSETAXANE, MENOSTATUS, SENTINELNODESAMPLE, SENTINELNODERESULT, HIST_TYPE_INV_OS, HISTOLOGICGRADEOS, ER_TS, PGR_TS, ERPOS, PGRPOS, HER2COMMUNITYPOS, HER2COMMUNITYMETHOD, SURGERYLUMPECTOMY, SURGERYMASTECTOMY, HISTOLOGICTYPEPS, INITLUMP_FUPMAST, SURGERY, REASON_NO_SURG, RTTHERAPY, RTBREAST, RTBOOST, RTAXILLA, RTSNODE, RTIMAMNODE, RTCHESTW, RTOTHER, TSIZECLINICAL, NSIZECLINICAL, STAGETE, STAGENE, STAGEME, CLINICALSTAGE, CLINRESPT1_T2, CLINRESPT1_T3, CLINRESPT1_T4, Morphologic pattern at T1, LES_T1, LES_T2, LES_T3, LES_T4, LD_T1, LD_T2, LD_T3, LD_T4, MRI % change T1_T2, MRI % change T1_T3, MRI % change T1_T4," + // "MRI % change T2_T3, MRI % change T2_T4, MRI % change T3_T4, DCISONLYPS, PTUMOR1SZCM_MICRO_1, HISTOLOGICGRADEPS, NUMPOSNODESPS, NODESEXAMINEDPS, PATHOLOGYSTAGEPS,InSituHistoPS, InvDzHistoPS, InvDzMultiFoc, InvDzCellularity, SurgMargins, yT, yN, yM, RCBIndex,localProgTimeD (ays),distProgTimeD (days)"; // 04/17/2010, delete HISTOLOGICTYPEPS, LES_T1, LES_T2, LES_T3, LES_T4, LD_T1, LD_T2, LD_T3, LD_T4, String longHeaders = "ISPY_ID, LabTrak ID, NCIA_IMAGE, INST_ID, AGE, AGECAT, RACE_ID, SSTAT, SURVDTD, CHEMOCAT, CHEMO, TAM, HERCEPTIN, DOSEDENSEANTHRA, DOSEDENSETAXANE, MENOSTATUS, SENTINELNODESAMPLE, SENTINELNODERESULT, HIST_TYPE_INV_OS, HISTOLOGICGRADEOS, ER_TS, PGR_TS, ERPOS, PGRPOS, HER2COMMUNITYPOS, HER2COMMUNITYMETHOD, SURGERYLUMPECTOMY, SURGERYMASTECTOMY, INITLUMP_FUPMAST, SURGERY, REASON_NO_SURG, RTTHERAPY, RTBREAST, RTBOOST, RTAXILLA, RTSNODE, RTIMAMNODE, RTCHESTW, RTOTHER, TSIZECLINICAL, NSIZECLINICAL, STAGETE, STAGENE, STAGEME, CLINICALSTAGE, CLINRESPT1_T2, CLINRESPT1_T3, CLINRESPT1_T4, Morphologic pattern at T1, MRI % change T1_T2, MRI % change T1_T3, MRI % change T1_T4," + "MRI % change T2_T3, MRI % change T2_T4, MRI % change T3_T4, DCISONLYPS, PTUMOR1SZCM_MICRO_1, HISTOLOGICGRADEPS, NUMPOSNODESPS, NODESEXAMINEDPS, PATHOLOGYSTAGEPS,InSituHistoPS, InvDzHistoPS, InvDzMultiFoc, InvDzCellularity, SurgMargins, yT, yN, yM, RCBIndex,localProgTimeD (ays),distProgTimeD (days)"; String[] heads = StringUtils.split(longHeaders, ","); for (String h : heads) { td = tr.addElement("td").addAttribute("class", "header").addText(h.trim()); } for (SampleInfo si : samples) { if (si != null) { //PatientData pd = cqs.getPatientDataForPatientDID(si.getISPYId()); Set<String> ispyIds = new HashSet<String>(); ispyIds.add(si.getISPYId()); ISPYclinicalDataQueryDTO dto = new ISPYclinicalDataQueryDTO(); dto.setRestrainingSamples(ispyIds); dto.setReturnAll(false); Set<PatientData> pdSet = cqs.getClinicalData(dto); for (PatientData pd : pdSet) { pdList.add(pd); tr = table.addElement("tr").addAttribute("class", "data"); String tmp = ""; tmp = si.getISPYId() != null ? si.getISPYId() : dv; td = tr.addElement("td").addText(tmp).addAttribute("name", "patient") .addAttribute("class", "patient").addAttribute("id", tmp) .addElement("input").addAttribute("type", "checkbox") .addAttribute("name", "checkable").addAttribute("class", "saveElement") .addAttribute("value", pd.getISPY_ID()); tmp = si.getLabtrackId() != null ? si.getLabtrackId() : dv; td = tr.addElement("td").addText(tmp); if (pd == null) { for (int i = 0; i < heads.length - 2; i++) { td = tr.addElement("td").addAttribute("class", "header").addText(dv); } } else if (pd != null) { // tmp = pd.getDataExtractDT()!=null ? pd.getDataExtractDT() : dv; // td = tr.addElement("td").addText(tmp); if (iqs.hasImagingData(pd.getISPY_ID())) { String link = iqs.buildImagingLink(pd); try { String encodedLink = URLEncoder.encode(link, "UTF-8"); td = tr.addElement("td").addElement("a") .addAttribute("onclick", "javascript:window.open('" + link + "','new','toolbar=yes,width=800,height=600,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes');") .addElement("img").addAttribute("src", "images/nciaLink.png"); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { td = tr.addElement("td").addText(dv); } tmp = pd.getInst_ID() != null ? pd.getInst_ID() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getPatientAge() != null ? pd.getPatientAge().toString() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getAgeCategory() != null ? pd.getAgeCategory().toString() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRace() != null ? pd.getRace().toString() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSSTAT() != null ? pd.getSSTAT() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSURVDTD() != null ? pd.getSURVDTD() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getChemoCat() != null ? pd.getChemoCat() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getChemo() != null ? pd.getChemo() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getTAM() != null ? pd.getTAM() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getHerceptin() != null ? pd.getHerceptin() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getDosedenseanthra() != null ? pd.getDosedenseanthra() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getDosedensetaxane() != null ? pd.getDosedensetaxane() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMenoStatus() != null ? pd.getMenoStatus() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSentinelNodeSample() != null ? pd.getSentinelNodeSample() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSentinelNodeResult() != null ? pd.getSentinelNodeResult() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getHistTypeOfInvasiveTumor() != null ? pd.getHistTypeOfInvasiveTumor() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getHistologicGradeOS() != null ? pd.getHistologicGradeOS() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getER_TS() != null ? pd.getER_TS() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getPGR_TS() != null ? pd.getPGR_TS() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getERpos() != null ? pd.getERpos() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getPgRpos() != null ? pd.getPgRpos() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getHER2CommunityPOS() != null ? pd.getHER2CommunityPOS() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getHER2CommunityMethod() != null ? pd.getHER2CommunityMethod() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSurgeryLumpectomy() != null ? pd.getSurgeryLumpectomy() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSurgeryMastectomy() != null ? pd.getSurgeryMastectomy() : dv; td = tr.addElement("td").addText(tmp); //04-17-2010, delete HISTOLOGICTYPEPS // tmp = pd.getHistTypePS()!=null ? pd.getHistTypePS() : dv; // td = tr.addElement("td").addText(tmp); tmp = pd.getINITLUMP_FUPMAST() != null ? pd.getINITLUMP_FUPMAST() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSurgery() != null ? pd.getSurgery() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getReasonNoSurg() != null ? pd.getReasonNoSurg() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTTherapy() != null ? pd.getRTTherapy() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTBreast() != null ? pd.getRTBreast() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTBOOST() != null ? pd.getRTBOOST() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTAXILLA() != null ? pd.getRTAXILLA() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTSNODE() != null ? pd.getRTSNODE() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTIMAMNODE() != null ? pd.getRTIMAMNODE() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTChestW() != null ? pd.getRTChestW() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getRTOTHER() != null ? pd.getRTOTHER() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getTSizeClinical() != null ? pd.getTSizeClinical() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getNSizeClinical() != null ? pd.getNSizeClinical() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getStageTE() != null ? pd.getStageTE() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getStageNE() != null ? pd.getStageNE() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getSTAGEME() != null ? pd.getSTAGEME() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getClinicalStageStr() != null ? pd.getClinicalStageStr() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getClinRespT1_T2() != null ? pd.getClinRespT1_T2() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getClinRespT1_T3() != null ? pd.getClinRespT1_T3() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getClinRespT1_T4() != null ? pd.getClinRespT1_T4() : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMorphology() != null ? pd.getMorphology().toString() : dv; td = tr.addElement("td").addText(tmp); // 04-17-2010, delete LES_T1, LES_T2, LES_T3, LES_T4, LD_T1, LD_T2, LD_T3, LD_T4 // tmp = pd.getLES_T1()!=null ? pd.getLES_T1() : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLES_T2()!=null ? pd.getLES_T2() : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLES_T3()!=null ? pd.getLES_T3() : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLES_T4()!=null ? pd.getLES_T4() : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLdT1()!=null ? Double.toString(pd.getLdT1()) : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLdT2()!=null ? Double.toString(pd.getLdT2()) : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLdT3()!=null ? Double.toString(pd.getLdT3()) : dv; // td = tr.addElement("td").addText(tmp); // // tmp = pd.getLdT4()!=null ? Double.toString(pd.getLdT4()) : dv; // td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT1_T2() != null ? String.valueOf(pd.getMriPctChangeT1_T2()) : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT1_T3() != null ? String.valueOf(pd.getMriPctChangeT1_T3()) : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT1_T4() != null ? String.valueOf(pd.getMriPctChangeT1_T4()) : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT2_T3() != null ? Double.toString(pd.getMriPctChangeT2_T3()) : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT2_T4() != null ? Double.toString(pd.getMriPctChangeT2_T4()) : dv; td = tr.addElement("td").addText(tmp); tmp = pd.getMriPctChangeT3_T4() != null ? Double.toString(pd.getMriPctChangeT3_T4()) : dv; td = tr.addElement("td").addText(tmp); // dispaly path data // dcisonly tmp = pd.getDCISOnlyPS() != null ? pd.getDCISOnlyPS() : dv; td = tr.addElement("td").addText(tmp); // Ptumor1szcm_micro_1 tmp = pd.getPtumor1szcm_micro_1() != null ? pd.getPtumor1szcm_micro_1().toString() : dv; td = tr.addElement("td").addText(tmp); // HistologicGradePS tmp = pd.getHistologicGradePS() != null ? pd.getHistologicGradePS() : dv; td = tr.addElement("td").addText(tmp); //NumPosNodes tmp = pd.getNumPosNodesPS() != null ? pd.getNumPosNodesPS() : dv; td = tr.addElement("td").addText(tmp); //NodesExamined tmp = pd.getNodesExaminedPS() != null ? pd.getNodesExaminedPS() : dv; td = tr.addElement("td").addText(tmp); // PathologyStage tmp = pd.getPathologyStagePS() != null ? pd.getPathologyStagePS() : dv; td = tr.addElement("td").addText(tmp); // InSituHisto tmp = pd.getInSituHistoPS() != null ? pd.getInSituHistoPS() : dv; td = tr.addElement("td").addText(tmp); // invDzHisto tmp = pd.getInvDzHistoPS() != null ? pd.getInvDzHistoPS() : dv; td = tr.addElement("td").addText(tmp); //invDzMultiFoc tmp = pd.getInvDzMultiFoc() != null ? pd.getInvDzMultiFoc() : dv; td = tr.addElement("td").addText(tmp); //invDzCellularity tmp = pd.getInvDzCellularity() != null ? pd.getInvDzCellularity() : dv; td = tr.addElement("td").addText(tmp); //surgMargins tmp = pd.getSurgMargins() != null ? pd.getSurgMargins() : dv; td = tr.addElement("td").addText(tmp); //yT tmp = pd.getYT() != null ? pd.getYT() : dv; td = tr.addElement("td").addText(tmp); //yN tmp = pd.getYN() != null ? pd.getYN() : dv; td = tr.addElement("td").addText(tmp); //yM tmp = pd.getYM() != null ? pd.getYM() : dv; td = tr.addElement("td").addText(tmp); // rcb index tmp = pd.getRcbIndexSize() != null ? pd.getRcbIndexSize() : dv; td = tr.addElement("td").addText(tmp); // LocalProgTimeD tmp = pd.getLocalProgTimeD() != null ? pd.getLocalProgTimeD().toString() : dv; td = tr.addElement("td").addText(tmp); // DistProgTimeD tmp = pd.getDistProgTimeD() != null ? pd.getDistProgTimeD().toString() : dv; td = tr.addElement("td").addText(tmp); } } } } if (!pdList.isEmpty()) { ISPYClinicalFinding clinicalFinding = new ISPYClinicalFinding(sessionId, taskId, null, FindingStatus.Running); clinicalFinding.setPatientData(pdList); FindingReportBean frb = new FindingReportBean(); frb.setFinding(clinicalFinding); ApplicationFactory.getPresentationTierCache().addPersistableToSessionCache( clinicalFinding.getSessionId(), clinicalFinding.getTaskId(), frb); } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } return html.append(document.asXML()); }
From source file:gov.nih.nci.ispy.web.reports.quick.QuickReporterReport.java
License:BSD License
public static StringBuffer quickReporterReport(List<String> reporters, String session, String taskId) { StringBuffer html = new StringBuffer(); Document document = DocumentHelper.createDocument(); Element table = document.addElement("table").addAttribute("id", "reportTable").addAttribute("class", "report"); Element tr = null;//from ww w .j av a2 s . c om Element td = null; tr = table.addElement("tr").addAttribute("class", "header"); td = tr.addElement("td").addAttribute("class", "header").addText("Reporter"); td = tr.addElement("td").addAttribute("class", "header").addText("Gene Symbol"); td = tr.addElement("td").addAttribute("class", "header").addText("GenBank AccId"); td = tr.addElement("td").addAttribute("class", "header").addText("LocusLink"); if (reporters != null) { try { GeneExprAnnotationService geService = GeneExprAnnotationServiceFactory.getInstance(); List<ReporterAnnotation> reporterAnnotations = geService.getAnnotationsListForReporters(reporters); for (ReporterAnnotation reporterAnnotation : reporterAnnotations) { if (reporterAnnotation != null) { tr = table.addElement("tr").addAttribute("class", "data"); //String reporter = reporterAnnotation.getReporter()!=null ? reporterAnnotation.getReporter().getValue().toString() : "N/A"; td = tr.addElement("td").addText(reporterAnnotation.getReporterId()); //html.append("ReporterID :" +reporterResultset.getReporter().getValue().toString() + "<br/>"); Collection<String> geneSymbols = (Collection<String>) reporterAnnotation.getGeneSymbols(); String genes = ""; if (geneSymbols != null) { genes = StringUtils.join(geneSymbols.toArray(), ","); } if (!genes.equals("")) { td = tr.addElement("td").addText(genes).addAttribute("class", "gene") .addAttribute("name", "gene").addAttribute("id", genes).addElement("input") .addAttribute("type", "checkbox").addAttribute("name", "checkable") .addAttribute("class", "saveElement").addAttribute("value", genes); } else { td = tr.addElement("td").addText(genes).addAttribute("class", "gene") .addAttribute("name", "gene").addAttribute("id", genes); } Collection<String> genBank_AccIDS = (Collection<String>) reporterAnnotation .getGenbankAccessions(); String accs = ""; if (genBank_AccIDS != null) { accs = StringUtils.join(genBank_AccIDS.toArray(), ","); } td = tr.addElement("td").addText(accs); Collection<String> locusLinkIDs = (Collection<String>) reporterAnnotation.getLocusLinkIds(); String ll = ""; if (locusLinkIDs != null) { ll = StringUtils.join(locusLinkIDs.toArray(), ","); } td = tr.addElement("td").addText(ll); } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } //return html; return html.append(document.asXML()); }
From source file:gov.nih.nci.ispy.web.xml.ClassComparisonReport.java
License:BSD License
public static Document getReportXML(Finding finding, Map filterMapParams, boolean allAnnotations) { allAnnotations = true; //force this for now ISPY prerelease - RCL 3/2 DecimalFormat resultFormat = new DecimalFormat("0.0000"); DecimalFormat sciFormat = new DecimalFormat("0.00E0"); DecimalFormat tmpsciFormat = new DecimalFormat("###0.0000#####################"); /*/* w w w .ja v a 2 s.co m*/ * this is for filtering, we will want a p-value filter for CC */ ArrayList filter_string = new ArrayList(); // hashmap of genes | reporters | cytobands String filter_type = "show"; // show | hide String filter_element = "none"; // none | gene | reporter | cytoband if (filterMapParams.containsKey("filter_string") && filterMapParams.get("filter_string") != null) filter_string = (ArrayList) filterMapParams.get("filter_string"); if (filterMapParams.containsKey("filter_type") && filterMapParams.get("filter_type") != null) filter_type = (String) filterMapParams.get("filter_type"); if (filterMapParams.containsKey("filter_element") && filterMapParams.get("filter_element") != null) filter_element = (String) filterMapParams.get("filter_element"); String defaultV = "--"; String delim = " | "; Document document = DocumentHelper.createDocument(); Element report = document.addElement("Report"); Element cell = null; Element data = null; Element dataRow = null; //add the atts report.addAttribute("reportType", "Class Comparison"); //fudge these for now report.addAttribute("groupBy", "none"); String queryName = "none"; queryName = finding.getTaskId(); //set the queryName to be unique for session/cache access report.addAttribute("queryName", queryName); report.addAttribute("sessionId", "the session id"); report.addAttribute("creationTime", "right now"); StringBuffer sb = new StringBuffer(); int recordCount = 0; int totalSamples = 0; //TODO: instance of ClassComparisonFinding ccf = (ClassComparisonFinding) finding; //process the query details ArrayList<String> queryDetails = new ArrayList(); ClassComparisonQueryDTO ccdto = (ClassComparisonQueryDTO) ccf.getQueryDTO(); String reporterType = ccdto.getArrayPlatformDE().getValueObject(); if (ccdto != null) { String tmp = ""; tmp = ccdto.getQueryName() != null ? ccdto.getQueryName() : ""; queryDetails.add("Query Name: " + tmp); tmp = ccdto.getArrayPlatformDE() != null ? ccdto.getArrayPlatformDE().getValue().toString() : ""; queryDetails.add("Array Platform: " + tmp); tmp = ""; List<ClinicalQueryDTO> grps = ccdto.getComparisonGroups() != null ? ccdto.getComparisonGroups() : new ArrayList(); Collection grs = new ArrayList(); for (ClinicalQueryDTO cdto : grps) { if (cdto.getQueryName() != null) grs.add(cdto.getQueryName()); } tmp += StringUtils.join(grs.toArray(), ", ") + " (baseline)"; queryDetails.add("Groups: " + tmp); /* noHTMLString = noHTMLString.replaceAll("<", "{"); noHTMLString = noHTMLString.replaceAll(">", "}"); noHTMLString = noHTMLString.replaceAll(" ", " "); */ tmp = ccdto.getExprFoldChangeDE() != null ? ccdto.getExprFoldChangeDE().getValue().toString() : ""; queryDetails.add("Fold Change: " + tmp); //queryDetails.add("Institutions: " + ccdto.getInstitutionDEs()); tmp = ccdto.getMultiGroupComparisonAdjustmentTypeDE() != null ? ccdto.getMultiGroupComparisonAdjustmentTypeDE().getValue().toString() : ""; queryDetails.add("Multi Group: " + tmp); tmp = ccdto.getStatisticalSignificanceDE() != null ? ccdto.getStatisticalSignificanceDE().getValue().toString() : ""; queryDetails.add("Stat Sig.: " + tmp); tmp = ccdto.getStatisticTypeDE() != null ? ccdto.getStatisticTypeDE().getValue().toString() : ""; queryDetails.add("Stat Type: " + tmp); } /* queryDetails.add("Analysis Result name: " + ccform.getAnalysisResultName()); queryDetails.add("Array Platform: " + ccform.getArrayPlatform()); queryDetails.add("Baseline group: " + ccform.getBaselineGroup()); queryDetails.add("Comparison Groups: " + ccform.getSelectedGroups()[0].toString()); queryDetails.add("Comparison Adjustment: " + ccform.getComparisonAdjustment()); //queryDetails.add("Comp. Adj. Coll: " + ccform.getComparisonAdjustmentCollection()); //queryDetails.add("Existing Groups: " + ccform.getExistingGroups()); //queryDetails.add("Existing group list: " + ccform.getExistingGroupsList()); //queryDetails.add("Fold Change: " + ccform.getFoldChange()); queryDetails.add("Fold Change auto: " + ccform.getFoldChangeAuto()); //queryDetails.add("Fold change auto list: " + ccform.getFoldChangeAutoList()); //queryDetails.add("Fold change manual: " + ccform.getFoldChangeManual()); queryDetails.add("Stastic: " + ccform.getStatistic()); queryDetails.add("Stastical method: " + ccform.getStatisticalMethod()); //queryDetails.add("Stastical method coll.: " + ccform.getStatisticalMethodCollection()); queryDetails.add("Stastical significance: " + ccform.getStatisticalSignificance()); */ String qd = ""; for (String q : queryDetails) { qd += q + " ||| "; } if (ccf != null) { Element details = report.addElement("Query_details"); cell = details.addElement("Data"); cell.addText(qd); cell = null; Element headerRow = report.addElement("Row").addAttribute("name", "headerRow"); cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Reporter"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Group Avg"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); String isAdj = ccf.arePvaluesAdjusted() ? " (Adjusted) " : ""; data = cell.addElement("Data").addAttribute("type", "header").addText("P-Value" + isAdj); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Fold Change"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "header") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Gene Symbol"); data = null; cell = null; //starting annotations...get them only if allAnnotations == true if (allAnnotations) { cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("GenBank Acc"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Locus link"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("GO Id"); data = null; cell = null; cell = headerRow.addElement("Cell").addAttribute("type", "header").addAttribute("class", "csv") .addAttribute("group", "header"); data = cell.addElement("Data").addAttribute("type", "header").addText("Pathways"); data = null; cell = null; } /* done with the headerRow and SampleRow Elements, time to add data rows */ /* Map<String,ReporterResultset> reporterResultsetMap = null; reporterResultsetMap = ccf.getReporterAnnotationsMap(); */ List<ClassComparisonResultEntry> classComparisonResultEntrys = ccf.getResultEntries(); List<String> reporterIds = new ArrayList<String>(); for (ClassComparisonResultEntry classComparisonResultEntry : classComparisonResultEntrys) { if (classComparisonResultEntry.getReporterId() != null) { reporterIds.add(classComparisonResultEntry.getReporterId()); } } Map reporterResultsetMap = null; try { GeneExprAnnotationService geService = GeneExprAnnotationServiceFactory.getInstance(); reporterResultsetMap = geService.getAnnotationsMapForReporters(reporterIds); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } /* //new stuff AnnotationHandler h = new AnnotationHandler(); Map reporterResultsetMap = null; if(allAnnotations){ //Map<String, ReporterAnnotations> reporterResultsetMap = null; try { reporterResultsetMap = h.getAllAnnotationsFor(reporterIds); } catch (Exception e) { e.printStackTrace(); } } else { //Map<String, String> reporterResultsetMap = null; try { reporterResultsetMap = h.getGeneSymbolsFor(reporterIds); } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } */ /* //this looks like a failsafe for the old method if(reporterResultsetMap == null) { try { reporterResultsetMap = GeneExprAnnotationService.getAnnotationsMapForReporters(reporterIds); } catch(Exception e){} } */ for (ClassComparisonResultEntry ccre : ccf.getResultEntries()) { dataRow = report.addElement("Row").addAttribute("name", "dataRow"); cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "reporter") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", reporterType).addText(ccre.getReporterId()); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(resultFormat.format(ccre.getMeanGrp1()) + " / " + resultFormat.format(ccre.getMeanBaselineGrp())); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "pval").addAttribute("class", "data") .addAttribute("group", "data"); //String pv = (ccre.getPvalue() == null) ? String.valueOf(ccre.getPvalue()) : "N/A"; String pv = defaultV; BigDecimal bigd; try { bigd = new BigDecimal(ccre.getPvalue()); pv = bigd.toPlainString(); } catch (Exception e) { //missing value } data = cell.addElement("Data").addAttribute("type", "header").addText(pv); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "data") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header") .addText(String.valueOf(resultFormat.format(ccre.getFoldChange()))); data = null; cell = null; //if only showing genes if (!allAnnotations && reporterResultsetMap != null) { String reporterId = ccre.getReporterId().toUpperCase().trim(); String genes = reporterResultsetMap.get(reporterId) != null ? (String) reporterResultsetMap.get(reporterId) : defaultV; cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "gene") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header").addText(genes); data = null; cell = null; } else { //get the gene symbols for this reporter //ccre.getReporterId() String genes = defaultV; //start annotations String accIds = defaultV; String llink = defaultV; String go = defaultV; String pw = defaultV; if (reporterResultsetMap != null) { // && reporterIds != null //int count = 0; String reporterId = ccre.getReporterId().toUpperCase().trim(); //ReporterResultset reporterResultset = reporterResultsetMap.get(reporterId); ReporterAnnotation ra = (ReporterAnnotation) reporterResultsetMap.get(reporterId); //Collection<String> geneSymbols = (Collection<String>)reporterResultset.getAssiciatedGeneSymbols(); if (ra != null) { List geneSymbols = ra.getGeneSymbols(); //if(geneSymbols != null) // genes = geneSymbols.toString(); if (geneSymbols != null) { genes = StringUtils.join(geneSymbols.toArray(), delim); } Collection<String> genBank_AccIDS = (Collection<String>) ra.getGenbankAccessions(); if (genBank_AccIDS != null) { accIds = StringUtils.join(genBank_AccIDS.toArray(), delim); } Collection<String> locusLinkIDs = (Collection<String>) ra.getLocusLinkIds(); if (locusLinkIDs != null) { llink = StringUtils.join(locusLinkIDs.toArray(), delim); } Collection<String> goIds = (Collection<String>) ra.getGOIds(); if (goIds != null) { go = StringUtils.join(goIds.toArray(), delim); } Collection<String> pathways = (Collection<String>) ra.getPathwayIds(); if (pathways != null) { pw = StringUtils.join(pathways.toArray(), delim); } } } cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "gene") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header").addText(genes); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "csv") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header").addText(accIds); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "csv") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header").addText(llink); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "csv") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header").addText(go); data = null; cell = null; cell = dataRow.addElement("Cell").addAttribute("type", "data").addAttribute("class", "csv") .addAttribute("group", "data"); data = cell.addElement("Data").addAttribute("type", "header").addText(pw); data = null; cell = null; } } } else { //TODO: handle this error sb.append("<br><Br>Class Comparison is empty<br>"); } return document; }
From source file:gov.nih.nci.rembrandt.web.reports.quick.QuickClinicalReport.java
License:BSD License
public static StringBuffer quickSampleReport(List<String> sampleIds) { StringBuffer html = new StringBuffer(); Document document = DocumentHelper.createDocument(); String dv = "--"; if (sampleIds != null) { Map<String, SampleResultset> sampleResultsetMap; try {// w w w.ja va 2 s .c om sampleResultsetMap = ClinicalDataValidator.getClinicalAnnotationsMapForSamples(sampleIds); if (sampleResultsetMap != null && sampleIds != null) { int count = 0; Element table = document.addElement("table").addAttribute("id", "reportTable") .addAttribute("class", "report"); Element tr = null; Element td = null; tr = table.addElement("tr").addAttribute("class", "header"); List<String> heads = new ArrayList<String>(); heads = ClinicalSampleReport.getClinicalHeaderValues(); for (String h : heads) { td = tr.addElement("td").addAttribute("class", "header").addText(h); } for (String sampleId : sampleIds) { SampleResultset sampleResultset = sampleResultsetMap.get(sampleId); //lose this if (sampleResultset != null && sampleResultset.getSampleIDDE() != null) { System.out.println(++count + " SampleID :" + sampleResultset.getSampleIDDE().getValue().toString()); } //end lose if (sampleResultset != null) { List dataRows = new ArrayList(); dataRows = ClinicalSampleReport.getClinicalRowValues(sampleResultset); tr = table.addElement("tr").addAttribute("class", "data"); for (int i = 0; i < dataRows.size(); i++) { td = tr.addElement("td").addText(DEUtils.checkNull(dataRows.get(i))); } /* String sid = sampleResultset.getSampleIDDE()!=null && sampleResultset.getSampleIDDE().getValue() != null ?sampleResultset.getSampleIDDE().getValue().toString() : dv; td = tr.addElement("td").addText(sid); String dis = sampleResultset.getDisease() != null && sampleResultset.getDisease().getValue() != null ?sampleResultset.getDisease().getValue().toString() : dv; td = tr.addElement("td").addText(dis); String gen = sampleResultset.getGenderCode() != null && sampleResultset.getGenderCode().getValue() != null ? sampleResultset.getGenderCode().getValue().toString() : dv; td = tr.addElement("td").addText(gen); String age = sampleResultset.getAgeGroup() != null && sampleResultset.getAgeGroup().getValue() != null ? sampleResultset.getAgeGroup().getValue().toString() : dv; td = tr.addElement("td").addText(age); String slength = sampleResultset.getSurvivalLength() != null ? String.valueOf(sampleResultset.getSurvivalLength()) : dv; td = tr.addElement("td").addText(slength); */ } } } } catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace(); } } return html.append(document.asXML()); }