Package org.mybatis.generator.api.dom.xml

Examples of org.mybatis.generator.api.dom.xml.XmlElement


  @Override
  public boolean sqlMapDocumentGenerated(Document document,
      IntrospectedTable introspectedTable)
  {
    XmlElement parentElement = document.getRootElement();

    // 生成selectByMap的sql映射
    XmlElement answer = new XmlElement("select"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("id", "selectByMap")); //$NON-NLS-1$
    answer.addAttribute(new Attribute(
        "resultMap", introspectedTable.getBaseResultMapId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterType", "Map")); //$NON-NLS-1$

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
    sb.append("select * from "); //$NON-NLS-1$
    sb.append(introspectedTable
        .getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    XmlElement whereElement = new XmlElement("where"); //$NON-NLS-1$
    for (IntrospectedColumn introspectedColumn : introspectedTable
        .getAllColumns())
    {
      XmlElement isNotNullElement = new XmlElement("if"); //$NON-NLS-1$
      sb.setLength(0);
      sb.append(introspectedColumn.getJavaProperty()); //$NON-NLS-1$
      sb.append(" != null"); //$NON-NLS-1$
      isNotNullElement.addAttribute(new Attribute("test", sb.toString())); //$NON-NLS-1$

      sb.setLength(0);
      sb.append("and ");
      sb.append(MyBatis3FormattingUtilities
          .getAliasedEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      sb.append(MyBatis3FormattingUtilities.getParameterClause(
          introspectedColumn, "")); //$NON-NLS-1$

      isNotNullElement.addElement(new TextElement(sb.toString()));

      whereElement.addElement(isNotNullElement);
    }
    answer.addElement(whereElement);

    parentElement.addElement(answer);

    // 生成selectCountByCriteria的sql映射
    parentElement = document.getRootElement();

    String fqjt = introspectedTable.getExampleType();
    answer = new XmlElement("select"); //$NON-NLS-1$
    answer
        .addAttribute(new Attribute(
            "id", "selectCount" + introspectedTable.getSelectByExampleStatementId().substring(6))); //$NON-NLS-1$
    answer.addAttribute(new Attribute("resultType", "long")); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterType", fqjt)); //$NON-NLS-1$
View Full Code Here


  }
 
  protected XmlElement getExampleIncludeElement(
      IntrospectedTable introspectedTable)
  {
    XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
    ifElement.addAttribute(new Attribute("test", "_parameter != null")); //$NON-NLS-1$ //$NON-NLS-2$

    XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
    includeElement.addAttribute(new Attribute("refid", //$NON-NLS-1$
        introspectedTable.getExampleWhereClauseId()));
    ifElement.addElement(includeElement);

    return ifElement;
  }
View Full Code Here

  }

  protected XmlElement getBaseColumnListElement(
      IntrospectedTable introspectedTable)
  {
    XmlElement answer = new XmlElement("include");
    answer.addAttribute(new Attribute("refid",
        introspectedTable.getBaseColumnListId()));
    return answer;
  }
View Full Code Here

  }

  protected XmlElement getBlobColumnListElement(
      IntrospectedTable introspectedTable)
  {
    XmlElement answer = new XmlElement("include");
    answer.addAttribute(new Attribute("refid",
        introspectedTable.getBlobColumnListId()));
    return answer;
  }
View Full Code Here

   */
  @Override
  public boolean sqlMapSelectByExampleWithBLOBsElementGenerated(
      XmlElement element, IntrospectedTable introspectedTable)
  {
    XmlElement ifElement = new XmlElement("if");
    ifElement.addAttribute(new Attribute("test", "pageSize > 0"));
    ifElement.addElement(new TextElement("limit ${startIndex},${pageSize}"));
    element.addElement(ifElement);
    return true;
  }
View Full Code Here

   */
  @Override
  public boolean sqlMapSelectByExampleWithoutBLOBsElementGenerated(
      XmlElement element, IntrospectedTable introspectedTable)
  {
    XmlElement ifElement = new XmlElement("if");
    ifElement.addAttribute(new Attribute("test", "pageSize > 0"));
    ifElement.addElement(new TextElement("limit ${startIndex},${pageSize}"));
    element.addElement(ifElement);
    return true;
  }
View Full Code Here

  @Override
  public List<GeneratedXmlFile> contextGenerateAdditionalXmlFiles(
      IntrospectedTable introspectedTable)
  {
    XmlElement parent = new XmlElement("struts"); //$NON-NLS-1$
    addPackageElement(parent, introspectedTable, parentModulName);
    Document document = new Document(STRUTS_PUBLIC_ID, STRUTS_SYSTEM_ID);
    document.setRootElement(parent);
    GeneratedXmlFile gxf = new GeneratedXmlFile(document, strutsXmlFileName
        + ".xml", strutsXmlFilePath, targetProject, isMergeable);
View Full Code Here

    String namespace = "/" + recordLowerFullType;
    if (parentModulName != null)
    {
      namespace = "/" + parentModulName + namespace;
    }
    XmlElement pkg = new XmlElement("package"); //$NON-NLS-1$
    pkg.addAttribute(new Attribute("name", recordLowerFullType)); //$NON-NLS-1$
    pkg.addAttribute(new Attribute("namespace", namespace)); //$NON-NLS-1$
    pkg.addAttribute(new Attribute("extends", "default")); //$NON-NLS-1$

    XmlElement action = new XmlElement("action"); //$NON-NLS-1$
    action.addAttribute(new Attribute("name", "*")); //$NON-NLS-1$
    action.addAttribute(new Attribute("class", actionPackge + "." + recordType + "Action")); //$NON-NLS-1$
    action.addAttribute(new Attribute("method", "{1}")); //$NON-NLS-1$
    pkg.addElement(action);

    XmlElement result = new XmlElement("result"); //$NON-NLS-1$
    result.addAttribute(new Attribute("name", "showIndex")); //$NON-NLS-1$
    TextElement text = new TextElement("/WEB-INF/jsp/"
        + recordLowerFullType + "/" + recordLowerFullType + ".jsp");
    result.addElement(text);
    action.addElement(result);

    result = new XmlElement("result"); //$NON-NLS-1$
    result.addAttribute(new Attribute("name", "showAdd")); //$NON-NLS-1$
    text = new TextElement("/WEB-INF/jsp/" + recordLowerFullType + "/add.jsp");
    result.addElement(text);
    action.addElement(result);

    result = new XmlElement("result"); //$NON-NLS-1$
    result.addAttribute(new Attribute("name", "showUpdate")); //$NON-NLS-1$
    text = new TextElement("/WEB-INF/jsp/" + recordLowerFullType + "/update.jsp");
    result.addElement(text);
    action.addElement(result);

    parent.addElement(pkg);
  }
View Full Code Here

  }

  protected XmlElement getBaseColumnListElement(
      IntrospectedTable introspectedTable)
  {
    XmlElement answer = new XmlElement("include"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("refid", //$NON-NLS-1$
        introspectedTable.getBaseColumnListId()));
    return answer;
  }
View Full Code Here

  }

  protected XmlElement getBlobColumnListElement(
      IntrospectedTable introspectedTable)
  {
    XmlElement answer = new XmlElement("include"); //$NON-NLS-1$
    answer.addAttribute(new Attribute("refid", //$NON-NLS-1$
        introspectedTable.getBlobColumnListId()));
    return answer;
  }
View Full Code Here

TOP

Related Classes of org.mybatis.generator.api.dom.xml.XmlElement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.