Search in sources :

Example 41 with XmlElement

use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.

the class UpdateByExampleWithBLOBsElementGenerator method addElements.

@Override
public void addElements(XmlElement parentElement) {
    //$NON-NLS-1$
    XmlElement answer = new XmlElement("update");
    answer.addAttribute(new //$NON-NLS-1$
    Attribute(//$NON-NLS-1$
    "id", introspectedTable.getUpdateByExampleWithBLOBsStatementId()));
    //$NON-NLS-1$ //$NON-NLS-2$
    answer.addAttribute(new Attribute("parameterType", "map"));
    context.getCommentGenerator().addComment(answer);
    StringBuilder sb = new StringBuilder();
    //$NON-NLS-1$
    sb.append("update ");
    sb.append(introspectedTable.getAliasedFullyQualifiedTableNameAtRuntime());
    answer.addElement(new TextElement(sb.toString()));
    // set up for first column
    sb.setLength(0);
    //$NON-NLS-1$
    sb.append("set ");
    Iterator<IntrospectedColumn> iter = ListUtilities.removeGeneratedAlwaysColumns(introspectedTable.getAllColumns()).iterator();
    while (iter.hasNext()) {
        IntrospectedColumn introspectedColumn = iter.next();
        sb.append(MyBatis3FormattingUtilities.getAliasedEscapedColumnName(introspectedColumn));
        //$NON-NLS-1$
        sb.append(" = ");
        sb.append(MyBatis3FormattingUtilities.getParameterClause(introspectedColumn, //$NON-NLS-1$
        "record."));
        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);
        }
    }
    answer.addElement(getUpdateByExampleIncludeElement());
    if (context.getPlugins().sqlMapUpdateByExampleWithBLOBsElementGenerated(answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
Also used : IntrospectedColumn(org.mybatis.generator.api.IntrospectedColumn) TextElement(org.mybatis.generator.api.dom.xml.TextElement) Attribute(org.mybatis.generator.api.dom.xml.Attribute) XmlElement(org.mybatis.generator.api.dom.xml.XmlElement)

Example 42 with XmlElement

use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.

the class AntFileGenerator method getTargetElement.

private XmlElement getTargetElement() {
    //$NON-NLS-1$
    XmlElement targetElement = new XmlElement("target");
    //$NON-NLS-1$ //$NON-NLS-2$
    targetElement.addAttribute(new Attribute("name", "generate"));
    addSqlTaskIfNecessary(targetElement);
    targetElement.addElement(getGenerateTask());
    return targetElement;
}
Also used : Attribute(org.mybatis.generator.api.dom.xml.Attribute) XmlElement(org.mybatis.generator.api.dom.xml.XmlElement)

Example 43 with XmlElement

use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.

the class AntFileGenerator method getProjectElement.

private XmlElement getProjectElement() {
    //$NON-NLS-1$
    XmlElement projectElement = new XmlElement("project");
    //$NON-NLS-1$ //$NON-NLS-2$
    projectElement.addAttribute(new Attribute("default", "generate"));
    projectElement.addElement(getTargetElement());
    return projectElement;
}
Also used : Attribute(org.mybatis.generator.api.dom.xml.Attribute) XmlElement(org.mybatis.generator.api.dom.xml.XmlElement)

Example 44 with XmlElement

use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.

the class AntFileGenerator method getGenerateTask.

private XmlElement getGenerateTask() {
    //$NON-NLS-1$
    XmlElement generateTask = new XmlElement("mybatis.generate");
    //$NON-NLS-1$
    generateTask.addAttribute(new Attribute("configfile", getConfigFile()));
    return generateTask;
}
Also used : Attribute(org.mybatis.generator.api.dom.xml.Attribute) XmlElement(org.mybatis.generator.api.dom.xml.XmlElement)

Example 45 with XmlElement

use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.

the class NewConfigFileWizard method openContentStream.

/**
     * We will initialize file contents with a sample text.
     */
private InputStream openContentStream() {
    Document document = new Document(XmlConstants.MYBATIS_GENERATOR_CONFIG_PUBLIC_ID, XmlConstants.MYBATIS_GENERATOR_CONFIG_SYSTEM_ID);
    //$NON-NLS-1$
    XmlElement generatorConfiguration = new XmlElement("generatorConfiguration");
    document.setRootElement(generatorConfiguration);
    //$NON-NLS-1$
    XmlElement context = new XmlElement("context");
    //$NON-NLS-1$ //$NON-NLS-2$
    context.addAttribute(new Attribute("id", "context1"));
    generatorConfiguration.addElement(context);
    //$NON-NLS-1$
    XmlElement jdbcConnection = new XmlElement("jdbcConnection");
    //$NON-NLS-1$ //$NON-NLS-2$
    jdbcConnection.addAttribute(new Attribute("driverClass", "???"));
    //$NON-NLS-1$ //$NON-NLS-2$
    jdbcConnection.addAttribute(new Attribute("connectionURL", "???"));
    //$NON-NLS-1$ //$NON-NLS-2$
    jdbcConnection.addAttribute(new Attribute("userId", "???"));
    //$NON-NLS-1$ //$NON-NLS-2$
    jdbcConnection.addAttribute(new Attribute("password", "???"));
    context.addElement(jdbcConnection);
    //$NON-NLS-1$
    XmlElement javaModelGenerator = new XmlElement("javaModelGenerator");
    //$NON-NLS-1$ //$NON-NLS-2$
    javaModelGenerator.addAttribute(new Attribute("targetPackage", "???"));
    //$NON-NLS-1$ //$NON-NLS-2$
    javaModelGenerator.addAttribute(new Attribute("targetProject", "???"));
    context.addElement(javaModelGenerator);
    //$NON-NLS-1$
    XmlElement sqlMapGenerator = new XmlElement("sqlMapGenerator");
    //$NON-NLS-1$ //$NON-NLS-2$
    sqlMapGenerator.addAttribute(new Attribute("targetPackage", "???"));
    //$NON-NLS-1$ //$NON-NLS-2$
    sqlMapGenerator.addAttribute(new Attribute("targetProject", "???"));
    context.addElement(sqlMapGenerator);
    //$NON-NLS-1$
    XmlElement javaClientGenerator = new XmlElement("javaClientGenerator");
    //$NON-NLS-1$ //$NON-NLS-2$
    javaClientGenerator.addAttribute(new Attribute("targetPackage", "???"));
    //$NON-NLS-1$ //$NON-NLS-2$
    javaClientGenerator.addAttribute(new Attribute("targetProject", "???"));
    //$NON-NLS-1$ //$NON-NLS-2$
    javaClientGenerator.addAttribute(new Attribute("type", "XMLMAPPER"));
    context.addElement(javaClientGenerator);
    //$NON-NLS-1$
    XmlElement table = new XmlElement("table");
    //$NON-NLS-1$ //$NON-NLS-2$
    table.addAttribute(new Attribute("schema", "???"));
    //$NON-NLS-1$ //$NON-NLS-2$
    table.addAttribute(new Attribute("tableName", "???"));
    //$NON-NLS-1$
    XmlElement columnOverride = new XmlElement("columnOverride");
    //$NON-NLS-1$ //$NON-NLS-2$
    columnOverride.addAttribute(new Attribute("column", "???"));
    //$NON-NLS-1$ //$NON-NLS-2$
    columnOverride.addAttribute(new Attribute("property", "???"));
    table.addElement(columnOverride);
    context.addElement(table);
    return new ByteArrayInputStream(document.getFormattedContent().getBytes());
}
Also used : Attribute(org.mybatis.generator.api.dom.xml.Attribute) ByteArrayInputStream(java.io.ByteArrayInputStream) XmlElement(org.mybatis.generator.api.dom.xml.XmlElement) Document(org.mybatis.generator.api.dom.xml.Document)

Aggregations

XmlElement (org.mybatis.generator.api.dom.xml.XmlElement)88 Attribute (org.mybatis.generator.api.dom.xml.Attribute)74 TextElement (org.mybatis.generator.api.dom.xml.TextElement)44 IntrospectedColumn (org.mybatis.generator.api.IntrospectedColumn)34 FullyQualifiedJavaType (org.mybatis.generator.api.dom.java.FullyQualifiedJavaType)5 Messages.getString (org.mybatis.generator.internal.util.messages.Messages.getString)5 ArrayList (java.util.ArrayList)4 Document (org.mybatis.generator.api.dom.xml.Document)4 GeneratedKey (org.mybatis.generator.config.GeneratedKey)4 FullyQualifiedTable (org.mybatis.generator.api.FullyQualifiedTable)3 Date (java.util.Date)2 GeneratedXmlFile (org.mybatis.generator.api.GeneratedXmlFile)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1