Example #1
0
  private void SetComplexSlotMention(
      HashMap<String, ArrayList<String>> fieldAnnotationList,
      HashMap<String, String> fieldTypeHasSlotIdMap) {
    for (String type : fieldAnnotationList.keySet()) {
      atts.clear();
      atts.addAttribute(
          "", "", "id", "", fieldTypeHasSlotIdMap.get(type)); // "i2b222009_Instance_990001"
      try {
        hd.startElement("", "", "complexSlotMention", atts);
        atts.clear();

        //				<mentionSlot id="m" />
        HashMap<String, String> maps = new HashMap<String, String>();
        maps.put("f", "fr");
        maps.put("do", "do");
        maps.put("mo", "manner");
        maps.put("r", "reason");
        maps.put("du", "du");
        maps.put("ossd", "other S/S/D");
        maps.put("ad", "adverse");

        String nmType = maps.get(type);
        atts.addAttribute("", "", "id", "", nmType);
        hd.startElement("", "", "mentionSlot", atts);
        hd.endElement("", "mentionSlotn", "");
        atts.clear();
        //
        SetComplexSlotMentionValue(fieldAnnotationList.get(type));

        hd.endElement("", "complexSlotMention", "");
      } catch (SAXException e) {
        e.printStackTrace();
      }
    }
  }
Example #2
0
  private HashMap<String, String> SetHashSlotMention(
      HashMap<String, ArrayList<String>> fieldAnnotationList,
      HashMap<String, String> fieldTypeHasSlotId) {
    // look through annotation id
    HashMap<String, String> slotMap = new HashMap<String, String>();
    for (String type : fieldAnnotationList.keySet()) {

      //			ArrayList<HashMap<String, String>> annotSlotPairList = fieldAnnotationList.get(type);
      //			for(int i = 0; i < annotSlotPairList.size(); i++ ){
      atts.clear();
      String hasSlotMentionId = getKnowtatorArtificialId();
      fieldTypeHasSlotId.put(type, hasSlotMentionId);

      //				add slot mention id to hashtable
      //				HashMap<String,String> AnnotationSlotPair = fieldAnnotationList.get(type).get(i);
      //				String annotionid = AnnotationSlotPair.keySet().toString();
      //				AnnotationSlotPair.put(annotionid, hasSlotMentionId);

      //				fieldAnnotationList.get(type).set(i, AnnotationSlotPair);
      //				end of add slot mention id

      atts.addAttribute("", "", "id", "", hasSlotMentionId);
      try {
        hd.startElement("", "", "hasSlotMention", atts);
        hd.endElement("", "hasSlotMention", "");
        atts.clear();
      } catch (SAXException e) {
        e.printStackTrace();
      }
    }

    return slotMap;
  }
  /**
   * Save the specified object.
   *
   * @param object The object to save.
   * @param hd The XML object.
   */
  public void save(final EncogPersistedObject object, final TransformerHandler hd) {
    try {
      final BasicNeuralDataSet set = (BasicNeuralDataSet) object;

      final AttributesImpl atts = EncogPersistedCollection.createAttributes(object);
      hd.startElement("", "", "BasicNeuralDataSet", atts);

      atts.clear();
      for (final NeuralDataPair pair : set) {
        hd.startElement("", "", this.pairXML, atts);
        hd.startElement("", "", this.inputXML, atts);
        for (int i = 0; i < pair.getInput().size(); i++) {
          hd.startElement("", "", this.valueXML, atts);
          final String data = "" + pair.getInput().getData(i);
          hd.characters(data.toCharArray(), 0, data.length());
          hd.endElement("", "", this.valueXML);
        }
        hd.endElement("", "", this.inputXML);
        hd.startElement("", "", this.idealXML, atts);
        for (int i = 0; i < pair.getIdeal().size(); i++) {
          hd.startElement("", "", this.valueXML, atts);
          final String data = "" + pair.getIdeal().getData(i);
          hd.characters(data.toCharArray(), 0, data.length());
          hd.endElement("", "", this.valueXML);
        }
        hd.endElement("", "", this.idealXML);
        hd.endElement("", "", this.pairXML);
      }

      hd.endElement("", "", "BasicNeuralDataSet");
    } catch (final SAXException e) {
      throw new NeuralNetworkError(e);
    }
  }
  private AttributesImpl createWorkflowAccessBinding(
      AttributesImpl atts, int workflow_id, int role_id) {
    String sql = null;
    String name = null;
    atts.clear();

    sql = "SELECT Name FROM AD_Workflow WHERE AD_Workflow_ID=?";
    name = DB.getSQLValueString(null, sql, workflow_id);
    atts.addAttribute("", "", "workflowname", "CDATA", name);

    sql = "SELECT Name FROM AD_Role WHERE AD_Role_ID=?";
    name = DB.getSQLValueString(null, sql, role_id);
    atts.addAttribute("", "", "rolename", "CDATA", name);

    sql =
        "SELECT isActive FROM AD_Workflow_Access WHERE AD_Workflow_ID="
            + workflow_id
            + " and AD_Role_ID=?";
    String TrueFalse = DB.getSQLValueString(null, sql, role_id);
    atts.addAttribute("", "", "isActive", "CDATA", TrueFalse);

    sql =
        "SELECT isReadWrite FROM AD_Workflow_Access WHERE AD_Workflow_ID="
            + workflow_id
            + " and AD_Role_ID=?";
    String isReadWrite = DB.getSQLValueString(null, sql, role_id);
    atts.addAttribute("", "", "isReadWrite", "CDATA", isReadWrite);

    return atts;
  }
 private AttributesImpl createSQLStatmentBinding(
     AttributesImpl atts, String SqlStatement, String DBType) {
   atts.clear();
   atts.addAttribute("", "", "DBType", "CDATA", DBType);
   atts.addAttribute("", "", "statement", "CDATA", SqlStatement);
   return atts;
 }
Example #6
0
  private void SetFieldClassMentionNode(String instanceId, String fieldClassName) {
    try {
      atts.addAttribute("", "", "id", "", instanceId); // "i2b222009_Instance_990001"
      hd.startElement("", "", "classMention", atts);
      atts.clear();

      atts.addAttribute("", "", "id", "", fieldClassName);
      hd.startElement("", "", "mentionClass", atts);
      hd.characters(fieldClassName.toCharArray(), 0, fieldClassName.length());
      hd.endElement("", "mentionClass", "");
      hd.endElement("", "classMention", "");
      atts.clear();
    } catch (SAXException e) {
      e.printStackTrace();
    }
  }
  public void startElement(String elementName) throws SAXException {
    if (_dom == null) {
      prepareNewDOM();
    }

    maybeEmitStartElement();
    _openElementName = elementName;
    _attributes.clear();
  }
Example #8
0
 //	<annotations textSource="5\501104">
 private void SetAnnotationsNode() {
   try {
     //			atts.addAttribute("", "textSource", "", "", "5" + "\\" + "501104");
     atts.addAttribute("", "textSource", "", "", articleFileName);
     hd.startElement("", "", "annotations", atts);
   } catch (SAXException e) {
     e.printStackTrace();
   }
   atts.clear();
 }
Example #9
0
  private void SetSubMention(String instanceId) {

    atts.addAttribute("", "", "id", "", instanceId);
    try {
      hd.startElement("", "", "mention", atts);
      hd.endElement("", "", "mention");
      atts.clear();
    } catch (SAXException e) {
      e.printStackTrace();
    }
  }
Example #10
0
 private void SetSubSpannedText(String content) {
   //		<spannedText>RECORD #501104</spannedText>
   try {
     hd.startElement("", "", "spannedText", atts);
     hd.characters(content.toCharArray(), 0, content.length());
     hd.endElement("", "", "spannedText");
     atts.clear();
   } catch (SAXException e) {
     e.printStackTrace();
   }
 }
Example #11
0
 private void SetComplexSlotMentionValue(ArrayList<String> ids) {
   for (String id : ids) {
     atts.addAttribute("", "", "value", "", id);
     try {
       hd.startElement("", "", "complexSlotMentionValue", atts);
       atts.clear();
       hd.endElement("", "complexSlotMentionValue", "");
     } catch (SAXException e) {
       e.printStackTrace();
     }
   }
 }
Example #12
0
 // Tag interface
 // -------------------------------------------------------------------------
 public void doTag(XMLOutput output) throws JellyTagException {
   try {
     output.startElement(uri, localName, qname, attributes);
     invokeBody(output);
     output.endElement(uri, localName, qname);
   } catch (SAXException e) {
     throw new JellyTagException(e);
   } finally {
     attributes.clear();
     context = null;
   }
 }
Example #13
0
  @Override
  public String serialize(List<Book> books) throws Exception {
    SAXTransformerFactory factory =
        (SAXTransformerFactory) TransformerFactory.newInstance(); // 取得SAXTransformerFactory实例
    TransformerHandler handler = factory.newTransformerHandler(); // 从factory获取TransformerHandler实例
    Transformer transformer = handler.getTransformer(); // 从handler获取Transformer实例
    transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8"); // 设置输出采用的编码方式
    transformer.setOutputProperty(OutputKeys.INDENT, "yes"); // 是否自动添加额外的空白
    transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); // 是否忽略XML声明

    StringWriter writer = new StringWriter();
    Result result = new StreamResult(writer);
    handler.setResult(result);

    String uri = ""; // 代表命名空间的URI 当URI无值时 须置为空字符串
    String localName = ""; // 命名空间的本地名称(不包含前缀) 当没有进行命名空间处理时 须置为空字符串

    handler.startDocument();
    handler.startElement(uri, localName, "books", null);

    AttributesImpl attrs = new AttributesImpl(); // 负责存放元素的属性信息
    char[] ch = null;
    for (Book book : books) {
      attrs.clear(); // 清空属性列表
      attrs.addAttribute(
          uri,
          localName,
          "id",
          "string",
          String.valueOf(book.getId())); // 添加一个名为id的属性(type影响不大,这里设为string)
      handler.startElement(uri, localName, "book", attrs); // 开始一个book元素
      // 关联上面设定的id属性

      handler.startElement(uri, localName, "name", null); // 开始一个name元素
      // 没有属性
      ch = String.valueOf(book.getName()).toCharArray();
      handler.characters(ch, 0, ch.length); // 设置name元素的文本节点
      handler.endElement(uri, localName, "name");

      handler.startElement(uri, localName, "price", null); // 开始一个price元素
      // 没有属性
      ch = String.valueOf(book.getPrice()).toCharArray();
      handler.characters(ch, 0, ch.length); // 设置price元素的文本节点
      handler.endElement(uri, localName, "price");

      handler.endElement(uri, localName, "book");
    }
    handler.endElement(uri, localName, "books");
    handler.endDocument();

    return writer.toString();
  }
Example #14
0
  private void SetSubSpan(int start, int end) {
    //		<span start="0" end="14" />
    atts.addAttribute("", "", "start", "", Integer.toString(start));
    atts.addAttribute("", "", "end", "", Integer.toString(end));

    try {
      hd.startElement("", "", "span", atts);
      hd.endElement("", "", "span");
      atts.clear();
    } catch (SAXException e) {
      e.printStackTrace();
    }
  }
  private AttributesImpl createRefListBinding(AttributesImpl atts, X_AD_Ref_List m_Ref_List) {
    String sql = null;
    String name = null;
    atts.clear();
    if (m_Ref_List.getAD_Ref_List_ID() <= PackOut.MAX_OFFICIAL_ID)
      atts.addAttribute(
          "", "", "AD_Ref_List_ID", "CDATA", Integer.toString(m_Ref_List.getAD_Ref_List_ID()));
    if (m_Ref_List.getAD_Ref_List_ID() > 0) {
      sql = "SELECT Name FROM AD_Ref_List WHERE AD_Ref_List_ID=?";
      name = DB.getSQLValueString(null, sql, m_Ref_List.getAD_Ref_List_ID());
      if (name != null) atts.addAttribute("", "", "ADReflistNameID", "CDATA", name);
      else atts.addAttribute("", "", "ADReflistNameID", "CDATA", "");
    } else {
      atts.addAttribute("", "", "ADReflistNameID", "CDATA", "");
    }

    if (m_Ref_List.getAD_Reference_ID() > 0) {
      sql = "SELECT Name FROM AD_Reference WHERE AD_Reference_ID=?";
      name = DB.getSQLValueString(null, sql, m_Ref_List.getAD_Reference_ID());
      if (name != null) atts.addAttribute("", "", "ADRefenceNameID", "CDATA", name);
      else atts.addAttribute("", "", "ADRefenceNameID", "CDATA", "");
    } else {
      atts.addAttribute("", "", "ADRefenceNameID", "CDATA", "");
    }

    atts.addAttribute(
        "",
        "",
        "Description",
        "CDATA",
        (m_Ref_List.getDescription() != null ? m_Ref_List.getDescription() : ""));
    atts.addAttribute(
        "",
        "",
        "EntityType",
        "CDATA",
        (m_Ref_List.getEntityType() != null ? m_Ref_List.getEntityType() : ""));
    atts.addAttribute(
        "", "", "Name", "CDATA", (m_Ref_List.getName() != null ? m_Ref_List.getName() : ""));
    atts.addAttribute(
        "", "", "isActive", "CDATA", (m_Ref_List.isActive() == true ? "true" : "false"));
    // atts.addAttribute("","","ValidFrom","CDATA",(m_Ref_List.getValidFrom
    // ().toGMTString() != null ?
    // m_Ref_List.getValidFrom().toGMTString():""));
    // atts.addAttribute("","","ValidTo","CDATA",(m_Ref_List.getValidTo
    // ().toGMTString() != null ?
    // m_Ref_List.getValidTo().toGMTString():""));
    atts.addAttribute(
        "", "", "Value", "CDATA", (m_Ref_List.getValue() != null ? m_Ref_List.getValue() : ""));
    return atts;
  }
 /**
  * Copy an entire Attributes object.
  *
  * <p>It may be more efficient to reuse an existing object rather than constantly allocating new
  * ones.
  *
  * @param atts The attributes to copy.
  */
 public void setAttributes(Attributes atts) {
   clear();
   length = atts.getLength();
   if (length > 0) {
     data = new String[length * 5];
     for (int i = 0; i < length; i++) {
       data[i * 5] = atts.getURI(i);
       data[i * 5 + 1] = atts.getLocalName(i);
       data[i * 5 + 2] = atts.getQName(i);
       data[i * 5 + 3] = atts.getType(i);
       data[i * 5 + 4] = atts.getValue(i);
     }
   }
 }
Example #17
0
 /*     */ public void setAttributes(Attributes atts) /*     */ {
   /* 371 */ clear();
   /* 372 */ this.length = atts.getLength();
   /* 373 */ if (this.length > 0) {
     /* 374 */ this.data = new String[this.length * 5];
     /* 375 */ for (int i = 0; i < this.length; i++) {
       /* 376 */ this.data[(i * 5)] = atts.getURI(i);
       /* 377 */ this.data[(i * 5 + 1)] = atts.getLocalName(i);
       /* 378 */ this.data[(i * 5 + 2)] = atts.getQName(i);
       /* 379 */ this.data[(i * 5 + 3)] = atts.getType(i);
       /* 380 */ this.data[(i * 5 + 4)] = atts.getValue(i);
       /*     */ }
     /*     */ }
   /*     */ }
  public void outputDelimiter(ContentHandler contentHandler, String classes, String id)
      throws SAXException {

    reusableAttributes.clear();
    if (id != null) reusableAttributes.addAttribute("", "id", "id", ContentHandlerHelper.CDATA, id);

    if (classes != null)
      reusableAttributes.addAttribute("", "class", "class", ContentHandlerHelper.CDATA, classes);

    final String delimiterQName = XMLUtils.buildQName(delimiterPrefix, delimiterLocalName);
    contentHandler.startElement(
        delimiterNamespaceURI, delimiterLocalName, delimiterQName, reusableAttributes);
    contentHandler.endElement(delimiterNamespaceURI, delimiterLocalName, delimiterQName);
  }
Example #19
0
  /*
   * @input medication annotation id
   * @input field belonged to medicaiton and its annotation ids
   */
  private void SetMedicationClassMentionNode(
      String medicationId,
      String longMedicationClassName,
      HashMap<String, ArrayList<String>> fieldAnnotationList,
      HashMap<String, String> fieldTypeHasSlotId) {
    try {
      atts.addAttribute("", "", "id", "", medicationId); // "i2b222009_Instance_990001"
      hd.startElement("", "", "classMention", atts);
      atts.clear();

      atts.addAttribute("", "", "id", "", longMedicationClassName);
      hd.startElement("", "", "mentionClass", atts);
      hd.characters(longMedicationClassName.toCharArray(), 0, longMedicationClassName.length());
      hd.endElement("", "mentionClass", "");
      atts.clear();

      SetHashSlotMention(fieldAnnotationList, fieldTypeHasSlotId);

      hd.endElement("", "classMention", "");
      atts.clear();
    } catch (SAXException e) {
      e.printStackTrace();
    }
  }
Example #20
0
  public void endStartTag(String uri, String localName, String prefix) {
    try {
      while (prefixBindings.size() != 0) {
        writer.startPrefixMapping(
            prefixBindings.pop(), // prefix
            prefixBindings.pop() // uri
            );
      }

      writer.startElement(uri, localName, getQName(prefix, localName), attrs);

      attrs.clear();
    } catch (SAXException e) {
      throw new TxwException(e);
    }
  }
  public static void outputItemFullTemplate(
      PipelineContext pipelineContext,
      HandlerContext handlerContext,
      ContentHandler contentHandler,
      String xhtmlPrefix,
      String spanQName,
      XFormsContainingDocument containingDocument,
      AttributesImpl reusableAttributes,
      Attributes attributes,
      String templateId,
      String effectiveId,
      boolean isMultiple,
      String fullItemType)
      throws SAXException {
    reusableAttributes.clear();
    reusableAttributes.addAttribute("", "id", "id", ContentHandlerHelper.CDATA, templateId);
    reusableAttributes.addAttribute(
        "", "class", "class", ContentHandlerHelper.CDATA, "xforms-template");

    contentHandler.startElement(
        XMLConstants.XHTML_NAMESPACE_URI, "span", spanQName, reusableAttributes);
    {
      final String itemEffectiveId = "$xforms-item-effective-id$";
      handleItemFull(
          pipelineContext,
          handlerContext,
          contentHandler,
          reusableAttributes,
          attributes,
          xhtmlPrefix,
          spanQName,
          containingDocument,
          null,
          effectiveId,
          itemEffectiveId,
          isMultiple,
          fullItemType,
          new Item(
              isMultiple,
              false,
              null, // make sure the value "$xforms-template-value$" is not encrypted
              "$xforms-template-label$",
              "$xforms-template-value$"),
          true);
    }
    contentHandler.endElement(XMLConstants.XHTML_NAMESPACE_URI, "span", spanQName);
  }
  private AttributesImpl createFormBinding(AttributesImpl atts, X_AD_Form m_Form) {
    String sql = null;
    String name = null;
    atts.clear();
    if (m_Form.getAD_Form_ID() > 0) {
      sql = "SELECT Name FROM AD_Form WHERE AD_Form_ID=?";
      name = DB.getSQLValueString(null, sql, m_Form.getAD_Form_ID());
      if (name != null) atts.addAttribute("", "", "ADFormNameID", "CDATA", name);
      else atts.addAttribute("", "", "ADFormNameID", "CDATA", "");
    } else {
      atts.addAttribute("", "", "ADFormNameID", "CDATA", "");
    }
    if (m_Form.getAD_Form_ID() <= PackOut.MAX_OFFICIAL_ID)
      atts.addAttribute("", "", "AD_Form_ID", "CDATA", Integer.toString(m_Form.getAD_Form_ID()));

    atts.addAttribute(
        "", "", "Classname", "CDATA", (m_Form.getClassname() != null ? m_Form.getClassname() : ""));
    atts.addAttribute(
        "",
        "",
        "isBetaFunctionality",
        "CDATA",
        (m_Form.isBetaFunctionality() == true ? "true" : "false"));
    atts.addAttribute(
        "",
        "",
        "AccessLevel",
        "CDATA",
        (m_Form.getAccessLevel() != null ? m_Form.getAccessLevel() : ""));
    atts.addAttribute(
        "",
        "",
        "Description",
        "CDATA",
        (m_Form.getDescription() != null ? m_Form.getDescription() : ""));
    atts.addAttribute("", "", "isActive", "CDATA", (m_Form.isActive() == true ? "true" : "false"));
    atts.addAttribute(
        "",
        "",
        "EntityType",
        "CDATA",
        (m_Form.getEntityType() != null ? m_Form.getEntityType() : ""));
    atts.addAttribute("", "", "Help", "CDATA", (m_Form.getHelp() != null ? m_Form.getHelp() : ""));
    atts.addAttribute("", "", "Name", "CDATA", (m_Form.getName() != null ? m_Form.getName() : ""));
    return atts;
  }
Example #23
0
  private void SetSubCreationDate() {
    //		<creationDate>Thu Aug 20 13:19:55 CDT 2009</creationDate>
    try {
      hd.startElement("", "", "creationDate", atts);

      //			DateFormat dateFormat = new SimpleDateFormat ("yyyy/MM/dd HH:mm:ss");
      Date date = new java.util.Date();
      //	        String dateStr = dateFormat.format (date);
      String dateStr = date.toString();

      hd.characters(dateStr.toCharArray(), 0, dateStr.length());
      hd.endElement("", "", "creationDate");
      atts.clear();
    } catch (SAXException e) {
      e.printStackTrace();
    }
  }
Example #24
0
  public void startElement(String nsUri, String local, String qname, Attributes atts)
      throws SAXException {
    // create an attributes set for MSV that doesn't contains xsi:schemaLocation
    xsiLessAtts.clear();
    int len = atts.getLength();
    for (int i = 0; i < len; i++) {
      String aUri = atts.getURI(i);
      String aLocal = atts.getLocalName(i);
      if (aUri.equals("http://www.w3.org/2001/XMLSchema-instance")
          && (aLocal.equals("schemaLocation") || aLocal.equals("noNamespaceSchemaLocation") // ||
          /*aLocal.equals("type")*/ )) continue;

      // we do handle xsi:nil.
      xsiLessAtts.addAttribute(aUri, aLocal, atts.getQName(i), atts.getType(i), atts.getValue(i));
    }

    super.startElement(nsUri, local, qname, xsiLessAtts);
  }
Example #25
0
  private void SetSubAnnotator() {
    // String annotatorInstanceId = "aers51_Instance_60000";
    // Todo: annotatorInstanceId should be changed for different projects.
    //		<annotator id="i2b22009_Instance_90001">Zuofeng Li, UWM Natural Languaguage Processing
    // Group</annotator>
    //      <annotator id="aers51_Instance_10000">Lancet Li, UWM</annotator>
    //				<annotator id="aers51_Instance_60000">ConceptExtractor Li, UWM</annotator>
    atts.addAttribute("", "", "id", "", annotatorInstanceId);

    // String annotator = "Lancet Li, UWM";

    try {
      hd.startElement("", "", "annotator", atts);

      hd.characters(annotatorLongName.toCharArray(), 0, annotatorLongName.length());
      hd.endElement("", "", "span");
      atts.clear();
    } catch (SAXException e) {
      e.printStackTrace();
    }
  }
Example #26
0
  public void generateXML(ContentHandler handler) throws SAXException {
    AttributesImpl attrs = new AttributesImpl();
    attrs.addAttribute("", "", "name", "", getId().getName());
    handler.startElement("", "", "call", attrs);

    super.generateXML(handler);

    if (base instanceof XMLGenerator) {
      handler.startElement("", "", "base", null);
      ((XMLGenerator) base).generateXML(handler);
      handler.endElement("", "", "base");
    }
    if (arguments != null && arguments.size() > 0) {
      attrs.clear();
      attrs.addAttribute("", "", "count", "", "" + arguments.size());
      handler.startElement("", "", "arguments", attrs);
      for (ActualArgument arg : arguments) {
        arg.generateXML(handler);
      }
      handler.endElement("", "", "arguments");
    }
    handler.endElement("", "", "call");
  }
Example #27
0
  /**
   * Switches to the "marshal child texts/elements" mode. This method has to be called after the 1st
   * pass is completed.
   */
  public void endAttributes() throws SAXException {
    // calculate QName of the element
    String uri = getCurrentElementUri();
    String local = getCurrentElementLocal();

    String prefix = nsContext.getPrefix(uri);
    _assert(prefix != null); // since we've declared it, it should be available

    String qname;
    if (prefix.length() != 0) qname = prefix + ':' + local;
    else qname = local;

    // fire startPrefixMapping events
    nsContext.iterateDeclaredPrefixes(startPrefixCallback);

    // fire the startElement event
    writer.startElement(uri, local, qname, attributes);

    // reset attributes
    attributes.clear();

    // prepare to collect texts
    textBuf.setLength(0);
  }
Example #28
0
  private NodeImpl writeReport(ValidationReport report, MemTreeBuilder builder) {

    // start root element
    int nodeNr = builder.startElement("", "report", "report", null);

    // validation status: valid or invalid
    builder.startElement("", "status", "status", null);
    if (report.isValid()) {
      builder.characters("valid");
    } else {
      builder.characters("invalid");
    }
    builder.endElement();

    // namespace when available
    if (report.getNamespaceUri() != null) {
      builder.startElement("", "namespace", "namespace", null);
      builder.characters(report.getNamespaceUri());
      builder.endElement();
    }

    // validation duration
    builder.startElement("", "time", "time", null);
    builder.characters("" + report.getValidationDuration());
    builder.endElement();

    // print exceptions if any
    if (report.getThrowable() != null) {
      builder.startElement("", "exception", "exception", null);
      builder.characters("" + report.getThrowable().getMessage());
      builder.endElement();
    }

    // reusable attributes
    AttributesImpl attribs = new AttributesImpl();

    // iterate validation report items, write message
    List cr = report.getValidationReportItemList();
    for (Iterator iter = cr.iterator(); iter.hasNext(); ) {
      ValidationReportItem vri = (ValidationReportItem) iter.next();

      // construct attributes
      attribs.addAttribute("", "level", "level", "CDATA", vri.getTypeText());
      attribs.addAttribute("", "line", "line", "CDATA", Integer.toString(vri.getLineNumber()));
      attribs.addAttribute(
          "", "column", "column", "CDATA", Integer.toString(vri.getColumnNumber()));

      if (vri.getRepeat() > 1) {
        attribs.addAttribute("", "repeat", "repeat", "CDATA", Integer.toString(vri.getRepeat()));
      }

      // write message
      builder.startElement("", "message", "message", attribs);
      builder.characters(vri.getMessage());
      builder.endElement();

      // Reuse attributes
      attribs.clear();
    }

    // finish root element
    builder.endElement();

    // return result
    return ((DocumentImpl) builder.getDocument()).getNode(nodeNr);
  }
  private AttributesImpl createPrintFormatBinding(
      AttributesImpl atts, X_AD_PrintFormat m_Printformat) {
    String sql = null;
    String name = null;
    atts.clear();
    if (m_Printformat.getAD_PrintFormat_ID() <= PackOut.MAX_OFFICIAL_ID)
      atts.addAttribute(
          "",
          "",
          "AD_PrintFormat_ID",
          "CDATA",
          Integer.toString(m_Printformat.getAD_PrintFormat_ID()));
    if (m_Printformat.getAD_ReportView_ID() > 0) {
      sql = "SELECT Name FROM AD_ReportView WHERE AD_ReportView_ID=?";
      name = DB.getSQLValueString(null, sql, m_Printformat.getAD_ReportView_ID());
      atts.addAttribute("", "", "ADReportviewnameID", "CDATA", name);
    } else atts.addAttribute("", "", "ADReportviewnameID", "CDATA", "");

    if (m_Printformat.getAD_Table_ID() > 0) {
      sql = "SELECT TableName FROM AD_Table WHERE AD_Table_ID=?";
      name = DB.getSQLValueString(null, sql, m_Printformat.getAD_Table_ID());
      atts.addAttribute("", "", "ADTableNameID", "CDATA", name);
    } else atts.addAttribute("", "", "ADTableNameID", "CDATA", "");

    if (m_Printformat.getAD_PrintTableFormat_ID() > 0) {
      sql = "SELECT Name FROM AD_PrintTableFormat WHERE AD_PrintTableFormat_ID=?";
      name = DB.getSQLValueString(null, sql, m_Printformat.getAD_PrintTableFormat_ID());
      atts.addAttribute("", "", "ADPrintTableFormatID", "CDATA", name);
    } else atts.addAttribute("", "", "ADPrintTableFormatID", "CDATA", "");

    if (m_Printformat.getAD_PrintColor_ID() > 0) {
      sql = "SELECT Name FROM AD_PrintColor WHERE AD_PrintColor_ID=?";
      name = DB.getSQLValueString(null, sql, m_Printformat.getAD_PrintColor_ID());
      atts.addAttribute("", "", "ADPrintColorID", "CDATA", name);
    } else atts.addAttribute("", "", "ADPrintColorID", "CDATA", "");

    if (m_Printformat.getAD_PrintFont_ID() > 0) {
      sql = "SELECT Name FROM AD_PrintFont WHERE AD_PrintFont_ID=?";
      name = DB.getSQLValueString(null, sql, m_Printformat.getAD_PrintFont_ID());
      atts.addAttribute("", "", "ADPrintFontID", "CDATA", name);
    } else atts.addAttribute("", "", "ADPrintFontID", "CDATA", "");

    if (m_Printformat.getAD_PrintPaper_ID() > 0) {
      sql = "SELECT Name FROM AD_PrintPaper WHERE AD_PrintPaper_ID=?";
      name = DB.getSQLValueString(null, sql, m_Printformat.getAD_PrintPaper_ID());
      atts.addAttribute("", "", "ADPrintPaperID", "CDATA", name);
    } else atts.addAttribute("", "", "ADPrintPaperID", "CDATA", "");

    atts.addAttribute(
        "",
        "",
        "Description",
        "CDATA",
        (m_Printformat.getDescription() != null ? m_Printformat.getDescription() : ""));
    atts.addAttribute(
        "", "", "Name", "CDATA", (m_Printformat.getName() != null ? m_Printformat.getName() : ""));
    atts.addAttribute(
        "",
        "",
        "PrinterName",
        "CDATA",
        (m_Printformat.getPrinterName() != null ? m_Printformat.getPrinterName() : ""));
    atts.addAttribute("", "", "FooterMargin", "CDATA", "" + m_Printformat.getFooterMargin());
    atts.addAttribute("", "", "HeaderMargin", "CDATA", "" + m_Printformat.getHeaderMargin());
    atts.addAttribute(
        "",
        "",
        "CreateCopy",
        "CDATA",
        (m_Printformat.getCreateCopy() != null ? m_Printformat.getCreateCopy() : ""));
    atts.addAttribute(
        "", "", "isActive", "CDATA", (m_Printformat.isActive() == true ? "true" : "false"));
    atts.addAttribute(
        "", "", "isTableBased", "CDATA", (m_Printformat.isTableBased() == true ? "true" : "false"));
    atts.addAttribute(
        "", "", "isForm", "CDATA", (m_Printformat.isForm() == true ? "true" : "false"));
    atts.addAttribute(
        "",
        "",
        "isStandardHeader",
        "CDATA",
        (m_Printformat.isStandardHeaderFooter() == true ? "true" : "false"));
    atts.addAttribute(
        "", "", "isDefault", "CDATA", (m_Printformat.isDefault() == true ? "true" : "false"));
    return atts;
  }
  private AttributesImpl createProcessBinding(AttributesImpl atts, X_AD_Process m_Process) {
    String sql = null;
    String name = null;
    atts.clear();

    if (m_Process.getAD_Process_ID() <= PackOut.MAX_OFFICIAL_ID)
      atts.addAttribute(
          "", "", "AD_Process_ID", "CDATA", Integer.toString(m_Process.getAD_Process_ID()));

    atts.addAttribute(
        "", "", "Name", "CDATA", (m_Process.getName() != null ? m_Process.getName() : ""));

    if (m_Process.getAD_Workflow_ID() > 0) {
      sql = "SELECT Name FROM AD_Workflow WHERE AD_Workflow_ID=?";
      name = DB.getSQLValueString(null, sql, m_Process.getAD_Workflow_ID());
      atts.addAttribute("", "", "ADWorkflowNameID", "CDATA", name);
    } else atts.addAttribute("", "", "ADWorkflowNameID", "CDATA", "");
    if (m_Process.getAD_Process_ID() > 0) {
      sql = "SELECT Name FROM AD_Process WHERE AD_Process_ID=?";
      name = DB.getSQLValueString(null, sql, m_Process.getAD_Process_ID());
      atts.addAttribute("", "", "ADProcessNameID", "CDATA", name);
    } else atts.addAttribute("", "", "ADProcessNameID", "CDATA", "");
    if (m_Process.getAD_PrintFormat_ID() > 0) {
      sql = "SELECT Name FROM AD_PrintFormat WHERE AD_PrintFormat_ID=?";
      name = DB.getSQLValueString(null, sql, m_Process.getAD_PrintFormat_ID());
      atts.addAttribute("", "", "ADPrintFormatNameID", "CDATA", name);
    } else atts.addAttribute("", "", "ADPrintFormatNameID", "CDATA", "");
    if (m_Process.getAD_ReportView_ID() > 0) {
      sql = "SELECT Name FROM AD_ReportView WHERE AD_ReportView_ID=?";
      name = DB.getSQLValueString(null, sql, m_Process.getAD_ReportView_ID());
      atts.addAttribute("", "", "ADReportViewNameID", "CDATA", name);
    } else atts.addAttribute("", "", "ADReportViewNameID", "CDATA", "");

    if (m_Process.getAD_Form_ID() > 0) {
      sql = "SELECT Name FROM AD_Form WHERE AD_Form_ID=?";
      name = DB.getSQLValueString(null, sql, m_Process.getAD_Form_ID());
      atts.addAttribute("", "", "ADFormNameID", "CDATA", name);
    } else atts.addAttribute("", "", "ADFormNameID", "CDATA", "");

    if (m_Process.getAD_Browse_ID() > 0) {
      sql = "SELECT Name FROM AD_Browse WHERE AD_Browse_ID=?";
      name = DB.getSQLValueString(null, sql, m_Process.getAD_Browse_ID());
      atts.addAttribute("", "", "ADBrowseNameID", "CDATA", name);
    } else atts.addAttribute("", "", "ADBrowseNameID", "CDATA", "");

    atts.addAttribute(
        "",
        "",
        "AccessLevel",
        "CDATA",
        (m_Process.getAccessLevel() != null ? m_Process.getAccessLevel() : ""));
    atts.addAttribute(
        "",
        "",
        "Classname",
        "CDATA",
        (m_Process.getClassname() != null ? m_Process.getClassname() : ""));
    atts.addAttribute(
        "",
        "",
        "Description",
        "CDATA",
        (m_Process.getDescription() != null ? m_Process.getDescription() : ""));
    atts.addAttribute(
        "",
        "",
        "EntityType",
        "CDATA",
        (m_Process.getEntityType() != null ? m_Process.getEntityType() : ""));
    atts.addAttribute(
        "", "", "Help", "CDATA", (m_Process.getHelp() != null ? m_Process.getHelp() : ""));
    atts.addAttribute(
        "",
        "",
        "isBetaFunctionality",
        "CDATA",
        (m_Process.isBetaFunctionality() == true ? "true" : "false"));
    atts.addAttribute(
        "", "", "isDirectPrint", "CDATA", (m_Process.isDirectPrint() == true ? "true" : "false"));
    atts.addAttribute(
        "", "", "isReport", "CDATA", (m_Process.isReport() == true ? "true" : "false"));
    atts.addAttribute(
        "", "", "isActive", "CDATA", (m_Process.isActive() == true ? "true" : "false"));
    atts.addAttribute(
        "",
        "",
        "ProcedureName",
        "CDATA",
        (m_Process.getProcedureName() != null ? m_Process.getProcedureName() : ""));
    atts.addAttribute("", "", "StatisticCount", "CDATA", "0");
    atts.addAttribute("", "", "StatisticSeconds", "CDATA", "0");
    atts.addAttribute(
        "", "", "Value", "CDATA", (m_Process.getValue() != null ? m_Process.getValue() : ""));
    atts.addAttribute(
        "",
        "",
        "WorkflowValue",
        "CDATA",
        (m_Process.getWorkflowValue() != null ? m_Process.getWorkflowValue() : ""));
    atts.addAttribute(
        "",
        "",
        "ShowHelp",
        "CDATA",
        (m_Process.getShowHelp() != null ? m_Process.getShowHelp() : ""));
    atts.addAttribute(
        "",
        "",
        "JasperReport",
        "CDATA",
        (m_Process.getJasperReport() != null ? m_Process.getJasperReport() : ""));
    return atts;
  }