Exemple #1
0
  public String setXmlContent() {
    // if (!xmlContent.equals("")) {
    // return "";
    // }
    // calling getTermInfo to get the xml content
    try {
      GetTermInfoType termInfoType = new GetTermInfoType();

      termInfoType.setMax(null); // Integer.parseInt(System.getProperty(
      // "OntMax")));
      termInfoType.setHiddens(Boolean.parseBoolean("true"));
      termInfoType.setSynonyms(Boolean.parseBoolean("false"));

      // log.info("sent : " + parentType.getMax() +
      // System.getProperty("OntMax") + System.getProperty("OntHiddens")
      // + System.getProperty("OntSynonyms") );

      // parentType.setMax(150);
      termInfoType.setBlob(true);
      // parentType.setType("all");

      termInfoType.setSelf(fullname());

      // Long time = System.currentTimeMillis();
      // log.info("making web service call " + time);
      GetTermInfoResponseMessage msg = new GetTermInfoResponseMessage();
      StatusType procStatus = null;
      // while(procStatus == null ||
      // !procStatus.getType().equals("DONE")){
      String response = OntServiceDriver.getTermInfo(termInfoType, "");
      log.debug("Ontology service getTermInfo response: " + response);

      procStatus = msg.processResult(response);
      // log.info(procStatus.getType());
      // log.info(procStatus.getValue());
      if (!procStatus.getType().equals("DONE")) {
        return "error";
      }
      ConceptsType allConcepts = msg.doReadConcepts();
      // List<ConceptType> concepts = allConcepts.getConcept();
      StringWriter strWriter = new StringWriter();
      try {
        // strWriter = new StringWriter();
        DndType dnd = new DndType();
        edu.harvard.i2b2.crcxmljaxb.datavo.vdo.ObjectFactory vdoOf =
            new edu.harvard.i2b2.crcxmljaxb.datavo.vdo.ObjectFactory();
        dnd.getAny().add(vdoOf.createConcepts(allConcepts));

        edu.harvard.i2b2.crcxmljaxb.datavo.dnd.ObjectFactory of =
            new edu.harvard.i2b2.crcxmljaxb.datavo.dnd.ObjectFactory();
        PatientMappingJAXBUtil.getJAXBUtil().marshaller(of.createPluginDragDrop(dnd), strWriter);

      } catch (JAXBUtilException e) {
        // log.error("Error marshalling Ont drag text");
        return "error";
      }

      log.debug("Node xml set to: " + strWriter.toString());
      xmlContent(strWriter.toString());
      return "";
    } catch (Exception e) {
      e.printStackTrace();
      return "error";
    }
  }
Exemple #2
0
  public void updateNodeMetaDataXML() {
    try {
      boolean hasValue = false;

      SAXBuilder parser = new SAXBuilder();
      GetTermInfoType vocab = new GetTermInfoType();
      vocab.setHiddens(true);
      vocab.setSynonyms(false);
      vocab.setMax(200);
      vocab.setType("default");
      vocab.setBlob(true);

      vocab.setSelf(this.fullname());
      String xmlContent = OntServiceDriver.getTermInfo(vocab, "");

      GetTermInfoResponseMessage msg = new GetTermInfoResponseMessage();
      StatusType procStatus = null;
      // while(procStatus == null ||
      // !procStatus.getType().equals("DONE")){
      // String response = OntServiceDriver.getTermInfo(termInfoType, "");
      // log.debug("Ontology service getTermInfo response: " + response);

      procStatus = msg.processResult(xmlContent);
      // log.info(procStatus.getType());
      // log.info(procStatus.getValue());
      // if (!procStatus.getType().equals("DONE")) {
      // return "error";
      // }
      ConceptsType allConcepts = msg.doReadConcepts();
      StringWriter strWriter = new StringWriter();
      try {
        // strWriter = new StringWriter();
        DndType dnd = new DndType();
        edu.harvard.i2b2.crcxmljaxb.datavo.vdo.ObjectFactory vdoOf =
            new edu.harvard.i2b2.crcxmljaxb.datavo.vdo.ObjectFactory();
        dnd.getAny().add(vdoOf.createConcepts(allConcepts));

        edu.harvard.i2b2.crcxmljaxb.datavo.dnd.ObjectFactory of =
            new edu.harvard.i2b2.crcxmljaxb.datavo.dnd.ObjectFactory();
        PatientMappingJAXBUtil.getJAXBUtil().marshaller(of.createPluginDragDrop(dnd), strWriter);

      } catch (JAXBUtilException e) {
        // log.error("Error marshalling Ont drag text");
        // return "error";
      }

      log.debug("Node xml set to: " + strWriter.toString());
      xmlContent(strWriter.toString());

      java.io.StringReader xmlStringReader = new java.io.StringReader(xmlContent);
      org.jdom.Document tableDoc = parser.build(xmlStringReader);

      org.jdom.Element elementMsgBody =
          tableDoc.getRootElement().getChild("message_body"); // , Namespace.getNamespace(
      // "http://www.i2b2.org/xsd/cell/ont/1.1/"
      // ));
      org.jdom.Element tableXml =
          elementMsgBody.getChild(
              "concepts", Namespace.getNamespace("http://www.i2b2.org/xsd/cell/ont/1.1/"));

      List conceptChildren = tableXml.getChildren();
      for (Iterator itr = conceptChildren.iterator(); itr.hasNext(); ) {
        Element conceptXml = (org.jdom.Element) itr.next();
        // String conceptText = conceptXml.getText().trim();

        Element conTableXml = conceptXml; // .getChildren().get(0);
        org.jdom.Element nameXml = conTableXml.getChild("name");
        String c_name = nameXml.getText();
        // titleName(c_name);

        // Element visualAttribs = conTableXml
        // .getChild("visualattributes");
        // String sVisualAttribs = visualAttribs.getText().trim();

        Element metadataAttribs = conTableXml.getChild("metadataxml");
        Element valuedataAttribs = metadataAttribs.getChild("ValueMetadata");

        if ((metadataAttribs != null) && (valuedataAttribs != null)) {
          log.debug("Has value");
          hasValue = true;
          this.hasValue(hasValue);
          Element dataTypeElement = valuedataAttribs.getChild("DataType");
          if (dataTypeElement != null && dataTypeElement.getTextTrim().equalsIgnoreCase("Enum")) {
            // add text values to node data
            this.valueModel().hasEnumValue(true);
            Element enumElement = valuedataAttribs.getChild("EnumValues");
            for (int i = 0; i < enumElement.getChildren().size(); i++) {
              Element valElement = (Element) enumElement.getChildren().get(i);
              String valString = new String(valElement.getTextTrim());
              this.valueModel().enumValues.add(valString);
            }
            log.debug("Got vals: " + this.valueModel().enumValues.size());
          } else if (dataTypeElement != null
              && (dataTypeElement.getTextTrim().equalsIgnoreCase("String")
                  || dataTypeElement.getTextTrim().equalsIgnoreCase("LargeString"))) {
            // add text values to node data
            this.valueModel().hasStringValue(true);
            Element maxLengthElement = valuedataAttribs.getChild("MaxStringLength");
            String valString = new String(maxLengthElement.getTextTrim());
            if (!valString.equalsIgnoreCase("")) {
              valueModel().searchStrLength(Integer.parseInt(valString));
            }
            if (dataTypeElement.getTextTrim().equalsIgnoreCase("LargeString")) {
              this.valueModel().isLongText(true);
            }
            /*Element enumElement = valuedataAttribs
            		.getChild("EnumValues");
            for (int i = 0; i < enumElement.getChildren().size(); i++) {
            	Element valElement = (Element) enumElement
            			.getChildren().get(i);
            	String valString = new String(valElement
            			.getTextTrim());
            	String valDisplayString = new String(valElement
            			.getAttributeValue("description"));
            	if(valDisplayString.equalsIgnoreCase("")) {
            		valDisplayString = valString;
            	}
            	modifierValuePropertyData.enumValues.add(valString);
            	modifierValuePropertyData.enumValueNames.add(valDisplayString);
            }
            log.debug("Got vals: "
            		+ this.modifierValuePropertyData.enumValues.size());*/
          }

          if (valuedataAttribs.getChild("Oktousevalues") != null
              && valuedataAttribs.getChild("Oktousevalues").getText().equalsIgnoreCase("Y")) {
            this.valueModel().okToUseValue(true);
          }

          if (valuedataAttribs.getChild("Flagstouse") == null
              || valuedataAttribs.getChild("Flagstouse").getText().equalsIgnoreCase("")) {
            this.valueModel().okToUseValueFlag(false);
          }

          Element unitElement = valuedataAttribs.getChild("UnitValues");
          if (unitElement != null) {
            for (int i = 0; i < unitElement.getChildren().size(); i++) {
              Element element = (Element) unitElement.getChildren().get(i);
              if (element.getName().equalsIgnoreCase("NormalUnits")
                  || element.getName().equalsIgnoreCase("EqualUnits")) {
                String unitString = new String(element.getTextTrim());
                // this.valueModel().units.add(new UnitsData(unitString, 1, false));
              } else if (element.getName().equalsIgnoreCase("ConvertingUnits")) {
                Element cunitElement = element.getChild("Units");
                String unitString = new String(cunitElement.getTextTrim());
                Element mfElement = element.getChild("MultiplyingFactor");
                // double mf = Double.parseDouble(mfElement.getTextTrim());
                // this.valueModel.units.add(new UnitsData(unitString, mf, true));
              }
            }
            log.debug("Got vals: " + this.valueModel().enumValues.size());
          }
        }
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }