Example #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();
  }
Example #2
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;
  }