Search in sources :

Example 66 with XmlElement

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

the class Configuration method toDocument.

/**
     * Builds an XML representation of this configuration. This can be used to
     * persist a programmatically generated configuration.
     * 
     * @return the XML representation of this configuration
     */
public Document toDocument() {
    // note that this method will not reconstruct a properties
    // element - that element is only used in XML parsing
    Document document = new Document(XmlConstants.MYBATIS_GENERATOR_CONFIG_PUBLIC_ID, XmlConstants.MYBATIS_GENERATOR_CONFIG_SYSTEM_ID);
    //$NON-NLS-1$
    XmlElement rootElement = new XmlElement("generatorConfiguration");
    document.setRootElement(rootElement);
    for (String classPathEntry : classPathEntries) {
        //$NON-NLS-1$
        XmlElement cpeElement = new XmlElement("classPathEntry");
        //$NON-NLS-1$
        cpeElement.addAttribute(new Attribute("location", classPathEntry));
        rootElement.addElement(cpeElement);
    }
    for (Context context : contexts) {
        rootElement.addElement(context.toXmlElement());
    }
    return document;
}
Also used : Attribute(org.mybatis.generator.api.dom.xml.Attribute) XmlElement(org.mybatis.generator.api.dom.xml.XmlElement) Messages.getString(org.mybatis.generator.internal.util.messages.Messages.getString) Document(org.mybatis.generator.api.dom.xml.Document)

Example 67 with XmlElement

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

the class JavaClientGeneratorConfiguration method toXmlElement.

public XmlElement toXmlElement() {
    //$NON-NLS-1$
    XmlElement answer = new XmlElement("javaClientGenerator");
    if (getConfigurationType() != null) {
        //$NON-NLS-1$
        answer.addAttribute(new Attribute("type", getConfigurationType()));
    }
    if (targetPackage != null) {
        //$NON-NLS-1$
        answer.addAttribute(new Attribute("targetPackage", targetPackage));
    }
    if (targetProject != null) {
        //$NON-NLS-1$
        answer.addAttribute(new Attribute("targetProject", targetProject));
    }
    if (implementationPackage != null) {
        answer.addAttribute(new Attribute("implementationPackage", //$NON-NLS-1$
        targetProject));
    }
    addPropertyXmlElements(answer);
    return answer;
}
Also used : Attribute(org.mybatis.generator.api.dom.xml.Attribute) XmlElement(org.mybatis.generator.api.dom.xml.XmlElement)

Example 68 with XmlElement

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

the class JavaModelGeneratorConfiguration method toXmlElement.

public XmlElement toXmlElement() {
    //$NON-NLS-1$
    XmlElement answer = new XmlElement("javaModelGenerator");
    if (targetPackage != null) {
        //$NON-NLS-1$
        answer.addAttribute(new Attribute("targetPackage", targetPackage));
    }
    if (targetProject != null) {
        //$NON-NLS-1$
        answer.addAttribute(new Attribute("targetProject", targetProject));
    }
    addPropertyXmlElements(answer);
    return answer;
}
Also used : Attribute(org.mybatis.generator.api.dom.xml.Attribute) XmlElement(org.mybatis.generator.api.dom.xml.XmlElement)

Example 69 with XmlElement

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

the class PluginConfiguration method toXmlElement.

public XmlElement toXmlElement() {
    //$NON-NLS-1$
    XmlElement answer = new XmlElement("plugin");
    if (getConfigurationType() != null) {
        //$NON-NLS-1$
        answer.addAttribute(new Attribute("type", getConfigurationType()));
    }
    addPropertyXmlElements(answer);
    return answer;
}
Also used : Attribute(org.mybatis.generator.api.dom.xml.Attribute) XmlElement(org.mybatis.generator.api.dom.xml.XmlElement)

Example 70 with XmlElement

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

the class ResultMapWithBLOBsElementGenerator method addElements.

@Override
public void addElements(XmlElement parentElement) {
    //$NON-NLS-1$
    XmlElement answer = new XmlElement("resultMap");
    answer.addAttribute(new //$NON-NLS-1$
    Attribute(//$NON-NLS-1$
    "id", introspectedTable.getResultMapWithBLOBsId()));
    String returnType;
    if (introspectedTable.getRules().generateRecordWithBLOBsClass()) {
        returnType = introspectedTable.getRecordWithBLOBsType();
    } else {
        // table has BLOBs, but no BLOB class - BLOB fields must be
        // in the base class
        returnType = introspectedTable.getBaseRecordType();
    }
    answer.addAttribute(new //$NON-NLS-1$
    Attribute(//$NON-NLS-1$
    "type", returnType));
    if (!introspectedTable.isConstructorBased()) {
        answer.addAttribute(new //$NON-NLS-1$
        Attribute(//$NON-NLS-1$
        "extends", introspectedTable.getBaseResultMapId()));
    }
    context.getCommentGenerator().addComment(answer);
    if (introspectedTable.isConstructorBased()) {
        addResultMapConstructorElements(answer);
    } else {
        addResultMapElements(answer);
    }
    if (context.getPlugins().sqlMapResultMapWithBLOBsElementGenerated(answer, introspectedTable)) {
        parentElement.addElement(answer);
    }
}
Also used : XmlElement(org.mybatis.generator.api.dom.xml.XmlElement)

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