Beispiel #1
0
  /**
   * (non-Javadoc)
   *
   * <p>Title:toXMLString
   *
   * @return
   * @see com.sogou.qadev.service.cynthia.bean.BaseType#toXMLString()
   */
  public String toXMLString() {
    StringBuffer xmlb = new StringBuffer(64);
    xmlb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>");
    xmlb.append("<template>");
    xmlb.append("<id>").append(this.getId()).append("</id>");
    xmlb.append("<templateTypeId>").append(this.getTemplateTypeId()).append("</templateTypeId>");
    xmlb.append("<name>").append(XMLUtil.toSafeXMLString(this.getName())).append("</name>");
    xmlb.append("<description>")
        .append(XMLUtil.toSafeXMLString(this.getDescription()))
        .append("</description>");
    xmlb.append("<flowId>").append(this.getFlowId()).append("</flowId>");
    if (this.fieldRowList.size() == 0) {
      xmlb.append("<layout><rows></rows></layout>");
    } else {
      xmlb.append("<layout>");
      xmlb.append("<rows>");
      for (FieldRow fieldRow : this.fieldRowList) {
        xmlb.append("<row>");
        for (FieldColumn fieldColumn : fieldRow.getFieldColumns()) {
          xmlb.append("<column>");
          for (Field field : fieldColumn.getFields()) {
            xmlb.append(field.toXMLString());
          }
          xmlb.append("</column>");
        }
        xmlb.append("</row>");
      }
      xmlb.append("</rows>");
      xmlb.append("</layout>");
    }

    xmlb.append("</template>");

    return xmlb.toString();
  }
Beispiel #2
0
  /**
   * @description:init new template xml from node
   * @date:2014-5-6 下午4:36:46
   * @version:v1.0
   * @param node
   */
  protected void initTemplateXml(Node node) {
    try {
      org.w3c.dom.Node templateNode = XMLUtil.getSingleNode(node, "template");
      String idStr = XMLUtil.getSingleNode(templateNode, "id").getTextContent();
      UUID id = DataAccessFactory.getInstance().createUUID(idStr);
      String templateTypeIdStr =
          XMLUtil.getSingleNode(templateNode, "templateTypeId").getTextContent();
      UUID templateTypeId = DataAccessFactory.getInstance().createUUID(templateTypeIdStr);

      String name = XMLUtil.getSingleNode(templateNode, "name").getTextContent();

      this.id = id;
      this.templateTypeId = templateTypeId;
      this.name = name;
      this.description = XMLUtil.getSingleNodeTextContent(templateNode, "description");

      String flowIdStr = XMLUtil.getSingleNode(templateNode, "flowId").getTextContent();
      this.flowId = DataAccessFactory.getInstance().createUUID(flowIdStr);

      List<Node> rowNodes = XMLUtil.getNodes(templateNode, "layout/rows/row");
      for (Node rowNode : rowNodes) {
        List<Node> columnNodes = XMLUtil.getNodes(rowNode, "column");
        FieldRow fieldRow = new FieldRow();
        for (Node columnNode : columnNodes) {
          List<Node> fieldNodes = XMLUtil.getNodes(columnNode, "field");
          FieldColumn fieldColumn = new FieldColumn();
          for (Node fieldNode : fieldNodes) {
            Field tempField = initFieldNode(fieldNode);
            fieldColumn.addField(tempField);
            this.fieldSet.add(tempField);
          }
          fieldRow.addColumn(fieldColumn);
        }

        fieldRowList.add(fieldRow);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Beispiel #3
0
  /**
   * (non-Javadoc)
   *
   * <p>Title:clone
   *
   * @return
   * @see java.lang.Object#clone()
   */
  public Template clone() {
    TemplateImpl templateImpl = new TemplateImpl(this.id, this.templateTypeId);

    templateImpl.flowId = this.flowId;
    templateImpl.name = this.name;
    templateImpl.description = this.description;

    templateImpl.fieldRowList = new ArrayList<FieldRow>();
    for (FieldRow fieldRow : fieldRowList) {
      FieldRow newFieldRow = new FieldRow();
      for (FieldColumn fieldColumn : fieldRow.getFieldColumns()) {
        FieldColumn newFieldColumn = new FieldColumn();
        for (Field field : fieldColumn.getFields()) {
          Field newField = field.clone();
          newFieldColumn.addField(newField);
          templateImpl.fieldSet.add(newField);
        }
        newFieldRow.addColumn(newFieldColumn);
      }
      templateImpl.fieldRowList.add(newFieldRow);
    }

    return templateImpl;
  }