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

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


      if (iter.hasNext()) {
        sb.append(", "); //$NON-NLS-1$
      }

      if (sb.length() > 80) {
        answer.addElement(new TextElement(sb.toString()));
        sb.setLength(0);
      }
    }

    if (sb.length() > 0) {
      answer.addElement((new TextElement(sb.toString())));
    }

    if (context.getPlugins().sqlMapBlobColumnListElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
    }
View Full Code Here


    answer.addAttribute(new Attribute("resultMap", introspectedTable.getBaseResultMapId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterType", fqjt)); //$NON-NLS-1$

    context.getCommentGenerator().addComment(answer);

    answer.addElement(new TextElement("select")); //$NON-NLS-1$
    XmlElement ifElement = new XmlElement("if"); //$NON-NLS-1$
    ifElement.addAttribute(new Attribute("test", "distinct")); //$NON-NLS-1$ //$NON-NLS-2$
    ifElement.addElement(new TextElement("distinct")); //$NON-NLS-1$
    answer.addElement(ifElement);

    StringBuilder sb = new StringBuilder();
    if (stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
      sb.append('\'');
      sb.append(introspectedTable.getSelectByExampleQueryId());
      sb.append("' as QUERYID,"); //$NON-NLS-1$
      answer.addElement(new TextElement(sb.toString()));
    }
    answer.addElement(getBaseColumnListElement());

    sb.setLength(0);
    sb.append("from "); //$NON-NLS-1$
    sb.append(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement((new TextElement(sb.toString())));
    answer.addElement(getExampleIncludeElement());

    ifElement = new XmlElement("if"); //$NON-NLS-1$
    ifElement.addAttribute(new Attribute("test", "orderByClause != null")); //$NON-NLS-1$ //$NON-NLS-2$
    ifElement.addElement(new TextElement("order by ${orderByClause}")); //$NON-NLS-1$
    answer.addElement(ifElement);

    if (context.getPlugins().sqlMapSelectByExampleWithoutBLOBsElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
    }
View Full Code Here

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
    sb.append("update "); //$NON-NLS-1$
    sb.append(introspectedTable.getFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    // set up for first column
    sb.setLength(0);
    sb.append("set "); //$NON-NLS-1$

    Iterator<IntrospectedColumn> iter = introspectedTable.getBaseColumns().iterator();
    while (iter.hasNext()) {
      IntrospectedColumn introspectedColumn = iter.next();

      sb.append(MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn));

      if (iter.hasNext()) {
        sb.append(',');
      }

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

      // set up for the next column
      if (iter.hasNext()) {
        sb.setLength(0);
        OutputUtilities.xmlIndent(sb, 1);
      }
    }

    boolean and = false;
    for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
      sb.setLength(0);
      if (and) {
        sb.append("  and "); //$NON-NLS-1$
      } else {
        sb.append("where "); //$NON-NLS-1$
        and = true;
      }

      sb.append(MyBatis3FormattingUtilities.getEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn));
      answer.addElement(new TextElement(sb.toString()));
    }

    if (context.getPlugins().sqlMapUpdateByPrimaryKeyWithoutBLOBsElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
    }
View Full Code Here

    answer.addAttribute(new Attribute("resultMap", introspectedTable.getBaseResultMapId())); //$NON-NLS-1$
    answer.addAttribute(new Attribute("parameterClass", introspectedTable.getExampleType())); //$NON-NLS-1$

    context.getCommentGenerator().addComment(answer);

    answer.addElement(new TextElement("select")); //$NON-NLS-1$
    XmlElement isParameterPresent = new XmlElement("isParameterPresent"); //$NON-NLS-1$
    XmlElement isEqualElement = new XmlElement("isEqual"); //$NON-NLS-1$
    isEqualElement.addAttribute(new Attribute("property", "distinct")); //$NON-NLS-1$ //$NON-NLS-2$
    isEqualElement.addAttribute(new Attribute("compareValue", "true")); //$NON-NLS-1$ //$NON-NLS-2$
    isEqualElement.addElement(new TextElement("distinct")); //$NON-NLS-1$
    isParameterPresent.addElement(isEqualElement);
    answer.addElement(isParameterPresent);

    StringBuilder sb = new StringBuilder();
    if (stringHasValue(introspectedTable.getSelectByExampleQueryId())) {
      sb.append('\'');
      sb.append(introspectedTable.getSelectByExampleQueryId());
      sb.append("' as QUERYID,"); //$NON-NLS-1$
      answer.addElement(new TextElement(sb.toString()));
    }

    answer.addElement(getBaseColumnListElement());

    sb.setLength(0);
    sb.append("from "); //$NON-NLS-1$
    sb.append(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement((new TextElement(sb.toString())));

    XmlElement isParameterPresenteElement = new XmlElement("isParameterPresent"); //$NON-NLS-1$
    answer.addElement(isParameterPresenteElement);

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

    XmlElement isNotNullElement = new XmlElement("isNotNull"); //$NON-NLS-1$
    isNotNullElement.addAttribute(new Attribute("property", "orderByClause")); //$NON-NLS-1$ //$NON-NLS-2$
    isNotNullElement.addElement(new TextElement("order by $orderByClause$")); //$NON-NLS-1$
    isParameterPresenteElement.addElement(isNotNullElement);

    if (context.getPlugins().sqlMapSelectByExampleWithoutBLOBsElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
    }
View Full Code Here

    if (stringHasValue(introspectedTable.getSelectByPrimaryKeyQueryId())) {
      sb.append('\'');
      sb.append(introspectedTable.getSelectByPrimaryKeyQueryId());
      sb.append("' as QUERYID,"); //$NON-NLS-1$
    }
    answer.addElement(new TextElement(sb.toString()));
    answer.addElement(getBaseColumnListElement());
    if (introspectedTable.hasBLOBColumns()) {
      answer.addElement(new TextElement(",")); //$NON-NLS-1$
      answer.addElement(getBlobColumnListElement());
    }

    sb.setLength(0);
    sb.append("from "); //$NON-NLS-1$
    sb.append(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    boolean and = false;
    for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
      sb.setLength(0);
      if (and) {
        sb.append("  and "); //$NON-NLS-1$
      } else {
        sb.append("where "); //$NON-NLS-1$
        and = true;
      }

      sb.append(MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn));
      answer.addElement(new TextElement(sb.toString()));
    }

    if (context.getPlugins().sqlMapSelectByPrimaryKeyElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
    }
View Full Code Here

    context.getCommentGenerator().addComment(answer);

    StringBuilder sb = new StringBuilder();
    sb.append("update "); //$NON-NLS-1$
    sb.append(introspectedTable.getFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    // set up for first column
    sb.setLength(0);
    sb.append("set "); //$NON-NLS-1$

    Iterator<IntrospectedColumn> iter = introspectedTable.getBaseColumns().iterator();
    while (iter.hasNext()) {
      IntrospectedColumn introspectedColumn = iter.next();

      sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn));

      if (iter.hasNext()) {
        sb.append(',');
      }

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

      // set up for the next column
      if (iter.hasNext()) {
        sb.setLength(0);
        OutputUtilities.xmlIndent(sb, 1);
      }
    }

    boolean and = false;
    for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
      sb.setLength(0);
      if (and) {
        sb.append("  and "); //$NON-NLS-1$
      } else {
        sb.append("where "); //$NON-NLS-1$
        and = true;
      }

      sb.append(Ibatis2FormattingUtilities.getEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn));
      answer.addElement(new TextElement(sb.toString()));
    }

    if (context.getPlugins().sqlMapUpdateByPrimaryKeyWithoutBLOBsElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
    }
View Full Code Here

    if (stringHasValue(introspectedTable.getSelectByPrimaryKeyQueryId())) {
      sb.append('\'');
      sb.append(introspectedTable.getSelectByPrimaryKeyQueryId());
      sb.append("' as QUERYID,"); //$NON-NLS-1$
    }
    answer.addElement(new TextElement(sb.toString()));
    answer.addElement(getBaseColumnListElement());
    if (introspectedTable.hasBLOBColumns()) {
      answer.addElement(new TextElement(",")); //$NON-NLS-1$
      answer.addElement(getBlobColumnListElement());
    }

    sb.setLength(0);
    sb.append("from "); //$NON-NLS-1$
    sb.append(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));

    boolean and = false;
    for (IntrospectedColumn introspectedColumn : introspectedTable.getPrimaryKeyColumns()) {
      sb.setLength(0);
      if (and) {
        sb.append("  and "); //$NON-NLS-1$
      } else {
        sb.append("where "); //$NON-NLS-1$
        and = true;
      }

      sb.append(Ibatis2FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn));
      sb.append(" = "); //$NON-NLS-1$
      sb.append(Ibatis2FormattingUtilities.getParameterClause(introspectedColumn));
      answer.addElement(new TextElement(sb.toString()));
    }

    if (context.getPlugins().sqlMapSelectByPrimaryKeyElementGenerated(answer, introspectedTable)) {
      parentElement.addElement(answer);
    }
View Full Code Here

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

        XmlElement includeElement = new XmlElement("include"); //$NON-NLS-1$
        sb.setLength(0);
        sb.append(introspectedTable.getIbatis2SqlMapNamespace());
        sb.append('.');
View Full Code Here

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

        // set up for first column
        sb.setLength(0);
        sb.append("set "); //$NON-NLS-1$

        Iterator<IntrospectedColumn> iter = introspectedTable
                .getNonBLOBColumns().iterator();
        while (iter.hasNext()) {
            IntrospectedColumn introspectedColumn = iter.next();

            sb.append(Ibatis2FormattingUtilities
                    .getAliasedEscapedColumnName(introspectedColumn));
            sb.append(" = "); //$NON-NLS-1$
            sb.append(Ibatis2FormattingUtilities.getParameterClause(
                    introspectedColumn, "record.")); //$NON-NLS-1$

            if (iter.hasNext()) {
                sb.append(',');
            }

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

            // set up for the next column
            if (iter.hasNext()) {
                sb.setLength(0);
                OutputUtilities.xmlIndent(sb, 1);
View Full Code Here

        isEqualElement.addAttribute(new Attribute(
                "property", "oredCriteria[].valid")); //$NON-NLS-1$ //$NON-NLS-2$
        isEqualElement.addAttribute(new Attribute("compareValue", "true")); //$NON-NLS-1$ //$NON-NLS-2$
        outerIterateElement.addElement(isEqualElement);

        isEqualElement.addElement(new TextElement("(")); //$NON-NLS-1$

        XmlElement innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addAttribute(new Attribute(
                "property", "oredCriteria[].criteriaWithoutValue")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addElement(new TextElement(
                "$oredCriteria[].criteriaWithoutValue[]$")); //$NON-NLS-1$
        isEqualElement.addElement(innerIterateElement);

        innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addAttribute(new Attribute(
                "property", "oredCriteria[].criteriaWithSingleValue")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement
                .addElement(new TextElement(
                        "$oredCriteria[].criteriaWithSingleValue[].condition$ #oredCriteria[].criteriaWithSingleValue[].value#")); //$NON-NLS-1$
        isEqualElement.addElement(innerIterateElement);

        innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addAttribute(new Attribute(
                "property", "oredCriteria[].criteriaWithListValue")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addElement(new TextElement(
                "$oredCriteria[].criteriaWithListValue[].condition$")); //$NON-NLS-1$
        XmlElement innerInnerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
        innerInnerIterateElement.addAttribute(new Attribute("property", //$NON-NLS-1$
                "oredCriteria[].criteriaWithListValue[].values")); //$NON-NLS-1$
        innerInnerIterateElement.addAttribute(new Attribute("open", "(")); //$NON-NLS-1$ //$NON-NLS-2$
        innerInnerIterateElement.addAttribute(new Attribute("close", ")")); //$NON-NLS-1$ //$NON-NLS-2$
        innerInnerIterateElement
                .addAttribute(new Attribute("conjunction", ",")); //$NON-NLS-1$ //$NON-NLS-2$
        innerInnerIterateElement.addElement(new TextElement(
                "#oredCriteria[].criteriaWithListValue[].values[]#")); //$NON-NLS-1$
        innerIterateElement.addElement(innerInnerIterateElement);
        isEqualElement.addElement(innerIterateElement);

        innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
        innerIterateElement.addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addAttribute(new Attribute(
                "property", "oredCriteria[].criteriaWithBetweenValue")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addAttribute(new Attribute("conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$
        innerIterateElement.addElement(new TextElement(
                "$oredCriteria[].criteriaWithBetweenValue[].condition$")); //$NON-NLS-1$
        innerIterateElement.addElement(new TextElement(
                "#oredCriteria[].criteriaWithBetweenValue[].values[0]# and")); //$NON-NLS-1$
        innerIterateElement.addElement(new TextElement(
                "#oredCriteria[].criteriaWithBetweenValue[].values[1]#")); //$NON-NLS-1$
        isEqualElement.addElement(innerIterateElement);

        // if any of the columns have a user defined type handler, then we need
        // to add additional inner iterate elements that specify the type
        // handler
        for (IntrospectedColumn introspectedColumn : introspectedTable
                .getNonBLOBColumns()) {
            if (stringHasValue(introspectedColumn
                    .getTypeHandler())) {
                // name the property based on the column name, then
                // add the type handler to the parameter declaration
                StringBuilder sb1 = new StringBuilder();
                StringBuilder sb2 = new StringBuilder();
                innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
                innerIterateElement
                        .addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$

                sb1.append("oredCriteria[]."); //$NON-NLS-1$
                sb1.append(introspectedColumn.getJavaProperty());
                sb1.append("CriteriaWithSingleValue"); //$NON-NLS-1$

                innerIterateElement.addAttribute(new Attribute(
                        "property", sb1.toString())); //$NON-NLS-1$
                innerIterateElement.addAttribute(new Attribute(
                        "conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$

                sb2.append(sb1);

                sb1.insert(0, '$');
                sb1.append("[].condition$ ");//$NON-NLS-1$

                sb2.insert(0, '#');
                sb2.append("[].value,handler=");//$NON-NLS-1$
                sb2.append(introspectedColumn.getTypeHandler());
                sb2.append('#');

                sb1.append(sb2);

                innerIterateElement.addElement(new TextElement(sb1.toString()));
                isEqualElement.addElement(innerIterateElement);

                sb1.setLength(0);
                sb2.setLength(0);
                sb1.append("oredCriteria[]."); //$NON-NLS-1$
                sb1.append(introspectedColumn.getJavaProperty());
                sb1.append("CriteriaWithListValue"); //$NON-NLS-1$

                innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
                innerIterateElement
                        .addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
                innerIterateElement.addAttribute(new Attribute(
                        "property", sb1.toString())); //$NON-NLS-1$
                innerIterateElement.addAttribute(new Attribute(
                        "conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$

                sb2.append('$');
                sb2.append(sb1);
                sb2.append("[].condition$"); //$NON-NLS-1$

                innerIterateElement.addElement(new TextElement(sb2.toString()));

                sb2.setLength(0);
                sb2.append(sb1);
                sb2.append("[].values"); //$NON-NLS-1$

                innerInnerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
                innerInnerIterateElement.addAttribute(new Attribute("property", //$NON-NLS-1$
                        sb2.toString()));
                innerInnerIterateElement
                        .addAttribute(new Attribute("open", "(")); //$NON-NLS-1$ //$NON-NLS-2$
                innerInnerIterateElement.addAttribute(new Attribute(
                        "close", ")")); //$NON-NLS-1$ //$NON-NLS-2$
                innerInnerIterateElement.addAttribute(new Attribute(
                        "conjunction", ",")); //$NON-NLS-1$ //$NON-NLS-2$

                sb2.setLength(0);
                sb2.append('#');
                sb2.append(sb1);
                sb2.append("[].values[],handler="); //$NON-NLS-1$
                sb2.append(introspectedColumn.getTypeHandler());
                sb2.append('#');

                innerInnerIterateElement.addElement(new TextElement(sb2
                        .toString()));
                innerIterateElement.addElement(innerInnerIterateElement);
                isEqualElement.addElement(innerIterateElement);

                sb1.setLength(0);
                sb2.setLength(0);
                sb1.append("oredCriteria[]."); //$NON-NLS-1$
                sb1.append(introspectedColumn.getJavaProperty());
                sb1.append("CriteriaWithBetweenValue"); //$NON-NLS-1$

                innerIterateElement = new XmlElement("iterate"); //$NON-NLS-1$
                innerIterateElement
                        .addAttribute(new Attribute("prepend", "and")); //$NON-NLS-1$ //$NON-NLS-2$
                innerIterateElement.addAttribute(new Attribute(
                        "property", sb1.toString())); //$NON-NLS-1$
                innerIterateElement.addAttribute(new Attribute(
                        "conjunction", "and")); //$NON-NLS-1$ //$NON-NLS-2$

                sb2.append('$');
                sb2.append(sb1);
                sb2.append("[].condition$"); //$NON-NLS-1$

                innerIterateElement.addElement(new TextElement(sb2.toString()));

                sb2.setLength(0);
                sb2.append(sb1);

                sb1.insert(0, '#');
                sb1.append("[].values[0],handler="); //$NON-NLS-1$
                sb1.append(introspectedColumn.getTypeHandler());
                sb1.append("# and"); //$NON-NLS-1$

                sb2.insert(0, '#');
                sb2.append("[].values[1],handler="); //$NON-NLS-1$
                sb2.append(introspectedColumn.getTypeHandler());
                sb2.append('#');

                innerIterateElement.addElement(new TextElement(sb1.toString()));
                innerIterateElement.addElement(new TextElement(sb2.toString()));
                isEqualElement.addElement(innerIterateElement);
            }
        }

        isEqualElement.addElement(new TextElement(")")); //$NON-NLS-1$

        if (context.getPlugins()
                .sqlMapExampleWhereClauseElementGenerated(answer,
                        introspectedTable)) {
            parentElement.addElement(answer);
View Full Code Here

TOP

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

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.