Example usage for org.dom4j Node selectSingleNode

List of usage examples for org.dom4j Node selectSingleNode

Introduction

In this page you can find the example usage for org.dom4j Node selectSingleNode.

Prototype

Node selectSingleNode(String xpathExpression);

Source Link

Document

selectSingleNode evaluates an XPath expression and returns the result as a single Node instance.

Usage

From source file:org.kuali.ext.mm.utility.JpaToOjbMetadata.java

License:Educational Community License

public static void main(String[] args) throws Exception {
    String filename = args[0];//www .j  a  va 2s.  c om

    try {
        SAXReader saxReader = new SAXReader();
        Document document = saxReader.read(filename);

        List<Node> boList = document.selectNodes("//bo");

        for (Node bo : boList) {
            //             String boName = bo.selectSingleNode("@name").getStringValue();
            String className = bo.selectSingleNode("@class").getStringValue();

            Class<? extends PersistableBusinessObject> boClass = (Class<? extends PersistableBusinessObject>) Class
                    .forName(className);
            //              PropertyDescriptor[] props = PropertyUtils.getPropertyDescriptors( boClass );

            StringBuffer sb = new StringBuffer(1000);
            Table tableAnnotation = boClass.getAnnotation(Table.class);

            sb.append("   <class-descriptor class=\"").append(boClass.getName()).append("\" table=\"");
            sb.append(tableAnnotation.name()).append("\">\r\n");

            getClassFields(boClass, sb, null);
            getReferences(boClass, sb);
            sb.append("   </class-descriptor>\r\n");

            System.out.println(sb.toString());

            //            FileWriter outputfile = null;
            //              try
            //              {
            //                 outputfile = new FileWriter(getOutputFilePath(className) + "ojb-" + boName + ".xml");
            //                 outputfile.write(sb.toString());
            //                 System.out.println("Created: " + getOutputFilePath(className) + "ojb-" + boName + ".xml");
            //              }
            //              catch(IOException e)
            //              {
            //                 System.err.println("Error writing bean data to file.");
            //              }
            //              finally {
            //                 outputfile.close();
            //              }
        }
    } catch (DocumentException e) {
        System.err.println("Error parsing xml document.");
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }

}

From source file:org.light.portlets.youtube.YouTubePortlet.java

License:Apache License

public void processAction(ActionRequest request, ActionResponse response)
        throws PortletException, java.io.IOException {
    String action = request.getParameter("action");
    if ("search".equals(action)) {
        String tag = request.getParameter("tag");
        if (tag != null && tag.trim().length() > 0) {
            String url = "http://www.youtube.com/api2_rest?method=youtube.videos.list_by_tag&dev_id=4adPqGmch9M&tag="
                    + tag;/*from  w w  w .j  a v a 2s.  com*/
            HttpServletRequest httpServletRequest = (HttpServletRequest) request
                    .getAttribute("httpServletRequest");
            try {
                URL youTubeUrl = new URL(url);
                URLConnection con = youTubeUrl.openConnection();
                InputStream in = con.getInputStream();
                //                  StringBuffer buffer = new  StringBuffer();
                //                   int i;
                //                  while ((i = in.read()) != -1){
                //                        buffer.append((char) i);
                //                  }
                //                  String text = buffer.toString();               
                //                  Document document = DocumentHelper.parseText(text);
                Document document = new SAXReader().read(in);
                List list1 = document.selectNodes("//ut_response/video_list/video");
                List<VideoBean> videos = new ArrayList<VideoBean>();
                for (Iterator iter = list1.iterator(); iter.hasNext();) {
                    Node node = (Node) iter.next();
                    String author = node.selectSingleNode("author").getStringValue();
                    String id = node.selectSingleNode("id").getStringValue();
                    String title = node.selectSingleNode("title").getStringValue();
                    String desc = node.selectSingleNode("description").getStringValue();
                    String picUrl = node.selectSingleNode("thumbnail_url").getStringValue();
                    String videoUrl = node.selectSingleNode("url").getStringValue();
                    String seconds = node.selectSingleNode("length_seconds").getStringValue();
                    String ratingAvg = node.selectSingleNode("rating_avg").getStringValue();
                    String ratingCount = node.selectSingleNode("rating_count").getStringValue();
                    String viewCount = node.selectSingleNode("view_count").getStringValue();
                    String commentCount = node.selectSingleNode("comment_count").getStringValue();
                    String tags = node.selectSingleNode("tags").getStringValue();
                    VideoBean video = new VideoBean(author, id, title, desc, picUrl, videoUrl, seconds,
                            ratingAvg, ratingCount, viewCount, commentCount, tags);
                    videos.add(video);
                }
                request.getPortletSession().setAttribute("youTubes", videos, PortletSession.APPLICATION_SCOPE);
            } catch (Exception e) {
            }
        } else {
            request.getPortletSession().setAttribute("youTubes", null, PortletSession.APPLICATION_SCOPE);
        }
    }
    if ("author".equals(action)) {
        String searchAuthor = request.getParameter("author");
        String url = "http://www.youtube.com/api2_rest?method=youtube.videos.list_by_user&dev_id=4adPqGmch9M&user="
                + searchAuthor;
        HttpServletRequest httpServletRequest = (HttpServletRequest) request.getAttribute("httpServletRequest");
        try {
            URL youTubeUrl = new URL(url);
            URLConnection con = youTubeUrl.openConnection();
            InputStream in = con.getInputStream();
            Document document = new SAXReader().read(in);
            List list1 = document.selectNodes("//ut_response/video_list/video");
            List<VideoBean> videos = new ArrayList<VideoBean>();
            for (Iterator iter = list1.iterator(); iter.hasNext();) {
                Node node = (Node) iter.next();
                String author = node.selectSingleNode("author").getStringValue();
                String id = node.selectSingleNode("id").getStringValue();
                String title = node.selectSingleNode("title").getStringValue();
                String desc = node.selectSingleNode("description").getStringValue();
                String picUrl = node.selectSingleNode("thumbnail_url").getStringValue();
                String videoUrl = node.selectSingleNode("url").getStringValue();
                String seconds = node.selectSingleNode("length_seconds").getStringValue();
                String ratingAvg = node.selectSingleNode("rating_avg").getStringValue();
                String ratingCount = node.selectSingleNode("rating_count").getStringValue();
                String viewCount = node.selectSingleNode("view_count").getStringValue();
                String commentCount = node.selectSingleNode("comment_count").getStringValue();
                String tags = node.selectSingleNode("tags").getStringValue();
                VideoBean video = new VideoBean(author, id, title, desc, picUrl, videoUrl, seconds, ratingAvg,
                        ratingCount, viewCount, commentCount, tags);
                videos.add(video);
            }
            request.getPortletSession().setAttribute("youTubes", videos, PortletSession.APPLICATION_SCOPE);
        } catch (Exception e) {
        }
    }
    if ("featured".equals(action)) {
        String url = "http://www.youtube.com/api2_rest?method=youtube.videos.list_featured&dev_id=4adPqGmch9M";
        HttpServletRequest httpServletRequest = (HttpServletRequest) request.getAttribute("httpServletRequest");
        try {
            URL youTubeUrl = new URL(url);
            URLConnection con = youTubeUrl.openConnection();
            InputStream in = con.getInputStream();
            Document document = new SAXReader().read(in);
            List list1 = document.selectNodes("//ut_response/video_list/video");
            List<VideoBean> videos = new ArrayList<VideoBean>();
            for (Iterator iter = list1.iterator(); iter.hasNext();) {
                Node node = (Node) iter.next();
                String author = node.selectSingleNode("author").getStringValue();
                String id = node.selectSingleNode("id").getStringValue();
                String title = node.selectSingleNode("title").getStringValue();
                String desc = node.selectSingleNode("description").getStringValue();
                String picUrl = node.selectSingleNode("thumbnail_url").getStringValue();
                String videoUrl = node.selectSingleNode("url").getStringValue();
                String seconds = node.selectSingleNode("length_seconds").getStringValue();
                String ratingAvg = node.selectSingleNode("rating_avg").getStringValue();
                String ratingCount = node.selectSingleNode("rating_count").getStringValue();
                String viewCount = node.selectSingleNode("view_count").getStringValue();
                String commentCount = node.selectSingleNode("comment_count").getStringValue();
                String tags = node.selectSingleNode("tags").getStringValue();
                VideoBean video = new VideoBean(author, id, title, desc, picUrl, videoUrl, seconds, ratingAvg,
                        ratingCount, viewCount, commentCount, tags);
                videos.add(video);
            }
            request.getPortletSession().setAttribute("youTubes", videos, PortletSession.APPLICATION_SCOPE);
        } catch (Exception e) {
        }
    }
    if ("clear".equals(action)) {
        request.getPortletSession().setAttribute("youTubes", null, PortletSession.APPLICATION_SCOPE);
    }
}

From source file:org.metaeffekt.core.inventory.processor.MavenCentralVersionProcessor.java

License:Apache License

private void updateLatestVersion(CloseableHttpClient client, HttpGet request, Artifact artifact,
        final LRUMap queryCache) throws URISyntaxException, IOException, HttpException, DocumentException {

    String artifactId = artifact.getId();
    int index = artifactId.indexOf("-" + artifact.getVersion());
    if (index != -1) {
        artifactId = artifactId.substring(0, index);
    }//w  w  w.j a va  2 s .  c  om
    if (StringUtils.hasText(artifact.getGroupId())) {
        String[] groupIds = artifact.getGroupId().split("\\|");
        String latestVersions = null;
        for (int i = 0; i < groupIds.length; i++) {
            String replacedUri = URI_PATTERN_ARTIFACT_RESOLVE.replaceAll("\\$\\{artifactId\\}",
                    artifactId.replace(" ", "-"));
            replacedUri = replacedUri.replaceAll("\\$\\{groupId\\}", groupIds[i].replace(" ", ""));

            LOG.info("Querying: {}", replacedUri);
            String latestVersion = (String) queryCache.get(replacedUri);
            String latestVersionMethod1 = null;
            if (latestVersion == null) {
                request.setURI(new URI(replacedUri));
                CloseableHttpResponse response = client.execute(request);
                try {
                    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                        SAXReader reader = new SAXReader();
                        Document document = reader.read(response.getEntity().getContent());
                        Node node;
                        LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
                        List<String> timestamps = new ArrayList<String>();
                        @SuppressWarnings("unchecked")
                        List<Node> docNodes = document.selectNodes("//response/result/doc");
                        if (docNodes != null) {
                            for (Object result : docNodes) {
                                Node resultNode = (Node) result;
                                node = resultNode.selectSingleNode("str[@name='v']");
                                String version = node.getText();
                                node = resultNode.selectSingleNode("long[@name='timestamp']");
                                String timestamp = node.getText();

                                // the timestamp alone may have duplicated
                                // therefore we append the version
                                timestamp = timestamp + version;

                                map.put(timestamp, version);
                                timestamps.add(timestamp);
                            }
                            if (!timestamps.isEmpty()) {
                                Collections.sort(timestamps);
                                latestVersionMethod1 = map.get(timestamps.get(timestamps.size() - 1));
                            }
                        }
                    }
                } finally {
                    response.close();
                }

                // method2
                String replacedUri2 = URI_PATTERN_ARTIFACT_RESOLVE_METHOD2.replaceAll("\\$\\{artifactId\\}",
                        artifactId.replace(" ", "-"));
                replacedUri2 = replacedUri2.replaceAll("\\$\\{groupId\\}", groupIds[i].replace(" ", ""));
                request.setURI(new URI(replacedUri2));
                response = client.execute(request);
                String latestVersionMethod2 = null;
                try {
                    if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
                        SAXReader reader = new SAXReader();
                        Document document = reader.read(response.getEntity().getContent());
                        int numEntries = Integer
                                .parseInt(document.selectSingleNode("//response/result").valueOf("@numFound"));

                        if (numEntries == 1) {
                            Node node = document
                                    .selectSingleNode("//response/result/doc/str[@name='latestVersion']");
                            if (node != null) {
                                latestVersionMethod2 = node.getText();
                            }
                        }
                    }
                } finally {
                    response.close();
                }

                if (latestVersionMethod1 != null) {
                    latestVersion = latestVersionMethod1;

                    if (!latestVersionMethod1.equals(latestVersionMethod2)) {
                        latestVersion = latestVersion + "|" + latestVersionMethod2;
                    }
                } else {
                    latestVersion = latestVersionMethod2;
                }

                if (latestVersion == null) {
                    latestVersion = "n.a.";
                }
                if (latestVersions == null) {
                    latestVersions = latestVersion;
                } else {
                    latestVersions += "|" + latestVersion;
                }
                queryCache.put(replacedUri, latestVersions);
            } else {
                latestVersions = latestVersion;
            }
        }
        LOG.info("Latest version: {}", latestVersions);
        artifact.setLatestAvailableVersion(latestVersions);
    }
}

From source file:org.mskcc.cbio.oncokb.quest.VariantAnnotationXMLV2.java

/**
 * This is a hacky way to run VEP. We should switch to web service once that is ready.
 *//*w w w  .  ja  va2 s .c  om*/
private static void runVcf2Maf(String inputXml, Map<Alteration, String> mapAlterationXml, String diagnosis)
        throws IOException, DocumentException, InterruptedException {
    File tmpFile = File.createTempFile("temp-oncokb-input-", ".xml");
    tmpFile.deleteOnExit();
    String inputPath = tmpFile.getAbsolutePath();
    String outputPath = inputPath.substring(0, inputPath.length() - 3) + "oncokb.xml";

    FileWriter writer = new FileWriter(tmpFile);
    writer.append(inputXml);
    writer.close();

    String vepMafXmlPl = System.getenv("VEP_MAF_XML_PL");
    if (null == vepMafXmlPl) {
        throw new IOException("VEP_MAF_XML_PL was not defined");
    }

    Process proc = Runtime.getRuntime().exec(new String[] { "perl", vepMafXmlPl, inputPath });
    proc.waitFor();

    InputStream stderr = proc.getErrorStream();
    InputStreamReader isr = new InputStreamReader(stderr);
    BufferedReader br = new BufferedReader(isr);
    String line = null;
    System.out.println("<ERROR>");
    while ((line = br.readLine()) != null)
        System.out.println(line);
    System.out.println("</ERROR>");
    int exitVal = proc.waitFor();
    System.out.println("Process exitValue: " + exitVal);

    SAXReader reader = new SAXReader();
    Document document = reader.read(outputPath);

    List<Node> variantNodes = document.selectNodes("//document/sample/test/variant");
    for (Node node : variantNodes) {
        String alterationXml = "<variant_type>small_nucleotide_variant</variant_type>\n"
                + node.selectSingleNode("genomic_locus").asXML() + node.selectSingleNode("allele").asXML();

        String geneSymbol = node.selectSingleNode("allele/transcript/hgnc_symbol").getText();
        GeneBo geneBo = ApplicationContextSingleton.getGeneBo();
        Gene gene = geneBo.findGeneByHugoSymbol(geneSymbol);

        String proteinChange = node.selectSingleNode("allele/transcript/hgvs_p_short").getText();

        Alteration alteration = new Alteration();
        alteration.setAlterationType(AlterationType.MUTATION);
        alteration.setGene(gene);
        alteration.setName(proteinChange);

        AlterationUtils.annotateAlteration(alteration, proteinChange);

        mapAlterationXml.put(alteration, alterationXml);
    }

}

From source file:org.mskcc.cbio.oncokb.quest.VariantAnnotationXMLV2.java

private static void handleCNA(Node cnaNode, Map<Alteration, String> mapAlterationXml, String diagnosis) {
    Gene gene = parseGene(cnaNode, "gene");
    if (gene == null) {
        return;//from   w w w .  j  av a 2s. c o  m
    }

    String type = cnaNode.selectSingleNode("type").getText();

    Alteration alteration = new Alteration();
    alteration.setGene(gene);
    alteration.setAlteration(type);
    alteration.setAlterationType(AlterationType.MUTATION); // TODO: this needs to be fixed

    StringBuilder sb = new StringBuilder();
    sb.append("<variant_type>copy_number_alteration</variant_type>\n");
    sb.append(cnaNode.asXML()).append("\n");
    sb.append(VariantAnnotationXML.annotate(alteration, diagnosis));

    mapAlterationXml.put(alteration, sb.toString());
}

From source file:org.mskcc.cbio.oncokb.quest.VariantAnnotationXMLV2.java

private static Gene parseGene(Node node, String genePath) {
    GeneBo geneBo = ApplicationContextSingleton.getGeneBo();
    Gene gene = null;/*from w  ww . ja  v a 2s  .  c  o m*/
    Node entrezGeneIdNode = node.selectSingleNode(genePath + "/entrez_gene_id");
    Node hugoSymbolNode = node.selectSingleNode(genePath + "/hgnc_symbol");
    if (entrezGeneIdNode != null) {
        int entrezId = Integer.parseInt(entrezGeneIdNode.getText());
        gene = geneBo.findGeneByEntrezGeneId(entrezId);
    }

    if (gene == null && hugoSymbolNode != null) {
        String symbol = hugoSymbolNode.getText();
        gene = geneBo.findGeneByHugoSymbol(symbol);
    }

    if (gene == null) {
        // a gene not in system
        gene = new Gene();
        gene.setEntrezGeneId(Integer.parseInt(entrezGeneIdNode.getText()));
        gene.setHugoSymbol(hugoSymbolNode.getText());
    }

    return gene;
}

From source file:org.mskcc.cbio.portal.scripts.ImportCaisesClinicalXML.java

License:Open Source License

static void importData(File xmlFile, int cancerStudyId) throws Exception {
    MySQLbulkLoader.bulkLoadOn();/*w w  w . j ava 2 s.c o m*/

    // add unknow attriutes -- this 
    for (ClinicalAttribute ca : getClinicalAttributes()) {
        if (DaoClinicalAttribute.getDatum(ca.getAttrId()) == null) {
            DaoClinicalAttribute.addDatum(ca);
        }
    }

    SAXReader reader = new SAXReader();
    Document document = reader.read(xmlFile);

    List<Node> patientNodes = document.selectNodes("//Patients/Patient");

    long clinicalEventId = DaoClinicalEvent.getLargestClinicalEventId();
    CancerStudy cancerStudy = DaoCancerStudy.getCancerStudyByInternalId(cancerStudyId);

    Map<String, String> mapSu2cSampleIdSampleId = getMapSu2cSampleIdSampleId(cancerStudyId);

    for (Node patientNode : patientNodes) {
        String patientId = patientNode.selectSingleNode("PtProtocolStudyId").getText();
        Patient patient = DaoPatient.getPatientByCancerStudyAndPatientId(cancerStudyId, patientId);
        if (patient == null) {
            continue;
        }

        System.out.println("Importing " + patientId);

        // processing clinical data
        // patient clinical data
        List<ClinicalData> patientClinicalData = parsePatientClinicalData(patientNode, patientId,
                cancerStudyId);
        for (ClinicalData cd : patientClinicalData) {
            if (DaoClinicalData.getDatum(cancerStudy.getCancerStudyStableId(), cd.getStableId(),
                    cd.getAttrId()) == null) {
                DaoClinicalData.addPatientDatum(patient.getInternalId(), cd.getAttrId(), cd.getAttrVal());
            }
        }
        // sample clinical data
        List<ClinicalData> sampleClinicalData = parseClinicalDataFromSpecimen(patientNode, cancerStudyId,
                mapSu2cSampleIdSampleId);
        for (ClinicalData cd : sampleClinicalData) {
            if (DaoClinicalData.getDatum(cancerStudy.getCancerStudyStableId(), cd.getStableId(),
                    cd.getAttrId()) == null) {
                Sample sample = DaoSample.getSampleByCancerStudyAndSampleId(cancerStudyId, cd.getStableId());
                DaoClinicalData.addSampleDatum(sample.getInternalId(), cd.getAttrId(), cd.getAttrVal());
            }
        }

        // processing timeline data
        List<ClinicalEvent> clinicalEvents = new ArrayList<ClinicalEvent>();
        long diagnositicDate = parseStatusesAndReturnDiagnosisDate(clinicalEvents, patientNode, patientId,
                cancerStudyId);
        parseClinicalEventsFromSpecimen(clinicalEvents, patientNode, patientId, cancerStudyId);
        parseMedicalTherapies(clinicalEvents, patientNode, patientId, cancerStudyId);
        parseRadiationTherapies(clinicalEvents, patientNode, patientId, cancerStudyId);
        parseBrachyTherapies(clinicalEvents, patientNode, patientId, cancerStudyId);
        parseDiagnostics(clinicalEvents, patientNode, patientId, cancerStudyId);
        parseLabTests(clinicalEvents, patientNode, patientId, cancerStudyId);
        for (ClinicalEvent clinicalEvent : clinicalEvents) {
            clinicalEvent.setClinicalEventId(++clinicalEventId);
            if (clinicalEvent.getStartDate() != null) {
                clinicalEvent.setStartDate(clinicalEvent.getStartDate() - diagnositicDate);
            }
            if (clinicalEvent.getStopDate() != null) {
                clinicalEvent.setStopDate(clinicalEvent.getStopDate() - diagnositicDate);
            }
            DaoClinicalEvent.addClinicalEvent(clinicalEvent);
        }
    }

    MySQLbulkLoader.flushAll();
}

From source file:org.mskcc.cbio.portal.scripts.ImportCaisesClinicalXML.java

License:Open Source License

private static List<ClinicalData> parsePatientClinicalData(Node patientNode, String patientId,
        int cancerStudyId) {
    List<ClinicalData> clinicalData = new ArrayList<ClinicalData>();
    //        Node node = patientNode.selectSingleNode("PtProtocolStudyId");
    //        if (node!=null) {
    //            clinicalData.add(new ClinicalData(cancerStudyId, patientId, "PATIENT_ID", node.getText()));
    //        }// w w  w  . j a v a 2  s .c o  m

    Node node = patientNode.selectSingleNode("PtRace");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "RACE", node.getText()));
    }

    node = patientNode.selectSingleNode("PtRegistrationAge");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "AGE", node.getText()));
    }

    node = patientNode.selectSingleNode("Categories/Category/Category");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "PATIENT_CATEGORY", node.getText()));
    }

    node = patientNode.selectSingleNode("ClinicalStages/ClinicalStage/ClinStageT");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "CLIN_T_Stage", node.getText()));
    }

    node = patientNode.selectSingleNode("ClinicalStages/ClinicalStage/ClinStageN");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "CLIN_N_Stage", node.getText()));
    }

    node = patientNode.selectSingleNode("ClinicalStages/ClinicalStage/ClinStageM");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "CLIN_M_Stage", node.getText()));
    }

    node = patientNode.selectSingleNode("Pathologies/Pathology/PathHistology");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "HISTOLOGY", node.getText()));
    }

    node = patientNode.selectSingleNode("Pathologies/Pathology/PathResult");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "PATH_RESULT", node.getText()));
    }

    node = patientNode
            .selectSingleNode("Pathologies/Pathology/PathologyStageGrades/PathologyStageGrade/PathStageT");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "PATH_T_STAGE", node.getText()));
    }

    node = patientNode
            .selectSingleNode("Pathologies/Pathology/PathologyStageGrades/PathologyStageGrade/PathStageN");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "PATH_N_STAGE", node.getText()));
    }

    node = patientNode
            .selectSingleNode("Pathologies/Pathology/PathologyStageGrades/PathologyStageGrade/PathStageM");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "PATH_M_STAGE", node.getText()));
    }

    node = patientNode.selectSingleNode("Pathologies/Pathology/ProstateBiopsyPaths/ProstateBiopsyPath/PathGG1");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "GLEASON_SCORE_1", node.getText()));
    }

    node = patientNode.selectSingleNode("Pathologies/Pathology/ProstateBiopsyPaths/ProstateBiopsyPath/PathGG2");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "GLEASON_SCORE_2", node.getText()));
    }

    node = patientNode.selectSingleNode("Pathologies/Pathology/ProstateBiopsyPaths/ProstateBiopsyPath/PathGGS");
    if (node != null) {
        clinicalData.add(new ClinicalData(cancerStudyId, patientId, "GLEASON_SCORE", node.getText()));
    }

    return clinicalData;
}

From source file:org.mskcc.cbio.portal.scripts.ImportCaisesClinicalXML.java

License:Open Source License

private static void parseMedicalTherapies(List<ClinicalEvent> clinicalEvents, Node patientNode,
        String patientId, int cancerStudyId) {
    List<Node> treatmentNodes = patientNode.selectNodes("MedicalTherapies/MedicalTherapy");

    for (Node treatmentNode : treatmentNodes) {
        Patient patient = DaoPatient.getPatientByCancerStudyAndPatientId(cancerStudyId, patientId);
        ClinicalEvent clinicalEvent = new ClinicalEvent();
        clinicalEvent.setPatientId(patient.getInternalId());
        clinicalEvent.setEventType("TREATMENT");
        clinicalEvent.addEventDatum("TREATMENT_TYPE", "Medical Therapy");

        Node node = treatmentNode.selectSingleNode("MedTxDate");
        if (node == null) {
            System.err.println("no date");
            continue;
        }/*from w ww. ja v  a  2s  .com*/
        clinicalEvent.setStartDate(Long.parseLong(node.getText()));

        node = treatmentNode.selectSingleNode("MedTxStopDate");
        if (node != null) {
            clinicalEvent.setStopDate(Long.parseLong(node.getText()));
        }

        node = treatmentNode.selectSingleNode("MedTxType");
        if (node != null) {
            clinicalEvent.addEventDatum("SUBTYPE", node.getText());
        }

        node = treatmentNode.selectSingleNode("MedTxIndication");
        if (node != null) {
            clinicalEvent.addEventDatum("INDICATION", node.getText());
        }

        node = treatmentNode.selectSingleNode("MedTxAgent");
        if (node != null) {
            clinicalEvent.addEventDatum("AGENT", node.getText());
        }

        node = treatmentNode.selectSingleNode("MedTxDose");
        if (node != null) {
            clinicalEvent.addEventDatum("DOSE", node.getText());
        }

        node = treatmentNode.selectSingleNode("MedTxTotalDose");
        if (node != null) {
            clinicalEvent.addEventDatum("TOTAL_DOSE", node.getText());
        }

        node = treatmentNode.selectSingleNode("MedTxUnits");
        if (node != null) {
            clinicalEvent.addEventDatum("UNIT", node.getText());
        }

        node = treatmentNode.selectSingleNode("MedTxSchedule");
        if (node != null) {
            clinicalEvent.addEventDatum("SCHEDULE", node.getText());
        }

        node = treatmentNode.selectSingleNode("MedTxRoute");
        if (node != null) {
            clinicalEvent.addEventDatum("ROUTE", node.getText());
        }

        clinicalEvents.add(clinicalEvent);
    }
}

From source file:org.mskcc.cbio.portal.scripts.ImportCaisesClinicalXML.java

License:Open Source License

private static void parseRadiationTherapies(List<ClinicalEvent> clinicalEvents, Node patientNode,
        String patientId, int cancerStudyId) {
    List<Node> treatmentNodes = patientNode.selectNodes("RadiationTherapies/RadiationTherapy");

    for (Node treatmentNode : treatmentNodes) {
        Patient patient = DaoPatient.getPatientByCancerStudyAndPatientId(cancerStudyId, patientId);
        ClinicalEvent clinicalEvent = new ClinicalEvent();
        clinicalEvent.setPatientId(patient.getInternalId());
        clinicalEvent.setEventType("TREATMENT");
        clinicalEvent.addEventDatum("TREATMENT_TYPE", "Radiation Therapy");

        Node node = treatmentNode.selectSingleNode("RadTxDate");
        if (node == null) {
            System.err.println("no date");
            continue;
        }/*w w w.j av a 2s. c  o  m*/
        clinicalEvent.setStartDate(Long.parseLong(node.getText()));

        node = treatmentNode.selectSingleNode("RadTxStopDate");
        if (node != null) {
            clinicalEvent.setStopDate(Long.parseLong(node.getText()));
        }

        node = treatmentNode.selectSingleNode("RadTxType");
        if (node != null) {
            clinicalEvent.addEventDatum("SUBTYPE", node.getText());
        }

        node = treatmentNode.selectSingleNode("RadTxIndication");
        if (node != null) {
            clinicalEvent.addEventDatum("INDICATION", node.getText());
        }

        node = treatmentNode.selectSingleNode("RadTxIntent");
        if (node != null) {
            clinicalEvent.addEventDatum("INTENT", node.getText());
        }

        node = treatmentNode.selectSingleNode("RadTxDosePerFraction");
        if (node != null) {
            clinicalEvent.addEventDatum("DOSE_PER_FRACTION", node.getText());
        }

        node = treatmentNode.selectSingleNode("RadTxTotalDose");
        if (node != null) {
            clinicalEvent.addEventDatum("TOTAL_DOSE", node.getText());
        }

        node = treatmentNode.selectSingleNode("RadTxUnits");
        if (node != null) {
            clinicalEvent.addEventDatum("UNIT", node.getText());
        }

        node = treatmentNode.selectSingleNode("RadTxNumFractions");
        if (node != null) {
            clinicalEvent.addEventDatum("NUM_FRACTIONS", node.getText());
        }

        node = treatmentNode.selectSingleNode("RadTxTarget");
        if (node != null) {
            clinicalEvent.addEventDatum("TARGET", node.getText());
        }

        clinicalEvents.add(clinicalEvent);
    }
}