use of org.mybatis.generator.api.dom.xml.Attribute in project generator by mybatis.
the class GeneratedKey method toXmlElement.
/**
* To xml element.
*
* @return the xml element
*/
public XmlElement toXmlElement() {
//$NON-NLS-1$
XmlElement xmlElement = new XmlElement("generatedKey");
//$NON-NLS-1$
xmlElement.addAttribute(new Attribute("column", column));
xmlElement.addAttribute(new Attribute("sqlStatement", //$NON-NLS-1$
configuredSqlStatement));
if (stringHasValue(type)) {
//$NON-NLS-1$
xmlElement.addAttribute(new Attribute("type", type));
}
xmlElement.addAttribute(new //$NON-NLS-1$
Attribute(//$NON-NLS-1$
"identity", //$NON-NLS-1$ //$NON-NLS-2$
isIdentity ? "true" : "false"));
return xmlElement;
}
use of org.mybatis.generator.api.dom.xml.Attribute in project generator by mybatis.
the class IgnoredColumn method toXmlElement.
/**
* To xml element.
*
* @return the xml element
*/
public XmlElement toXmlElement() {
//$NON-NLS-1$
XmlElement xmlElement = new XmlElement("ignoreColumn");
//$NON-NLS-1$
xmlElement.addAttribute(new Attribute("column", columnName));
if (stringHasValue(configuredDelimitedColumnName)) {
xmlElement.addAttribute(new Attribute("delimitedColumnName", //$NON-NLS-1$
configuredDelimitedColumnName));
}
return xmlElement;
}
use of org.mybatis.generator.api.dom.xml.Attribute in project generator by mybatis.
the class IgnoredColumnPattern method toXmlElement.
public XmlElement toXmlElement() {
//$NON-NLS-1$
XmlElement xmlElement = new XmlElement("ignoreColumnsByRegex");
//$NON-NLS-1$
xmlElement.addAttribute(new Attribute("pattern", patternRegex));
for (IgnoredColumnException exception : exceptions) {
xmlElement.addElement(exception.toXmlElement());
}
return xmlElement;
}
use of org.mybatis.generator.api.dom.xml.Attribute in project generator by mybatis.
the class Context method toXmlElement.
/**
* Builds an XmlElement representation of this context. Note that the XML
* may not necessarily validate if the context is invalid. Call the
* <code>validate</code> method to check validity of this context.
*
* @return the XML representation of this context
*/
public XmlElement toXmlElement() {
//$NON-NLS-1$
XmlElement xmlElement = new XmlElement("context");
//$NON-NLS-1$
xmlElement.addAttribute(new Attribute("id", id));
if (defaultModelType != ModelType.CONDITIONAL) {
xmlElement.addAttribute(new Attribute("defaultModelType", //$NON-NLS-1$
defaultModelType.getModelType()));
}
if (stringHasValue(introspectedColumnImpl)) {
xmlElement.addAttribute(new Attribute("introspectedColumnImpl", //$NON-NLS-1$
introspectedColumnImpl));
}
if (stringHasValue(targetRuntime)) {
xmlElement.addAttribute(new Attribute("targetRuntime", //$NON-NLS-1$
targetRuntime));
}
addPropertyXmlElements(xmlElement);
for (PluginConfiguration pluginConfiguration : pluginConfigurations) {
xmlElement.addElement(pluginConfiguration.toXmlElement());
}
if (commentGeneratorConfiguration != null) {
xmlElement.addElement(commentGeneratorConfiguration.toXmlElement());
}
if (jdbcConnectionConfiguration != null) {
xmlElement.addElement(jdbcConnectionConfiguration.toXmlElement());
}
if (connectionFactoryConfiguration != null) {
xmlElement.addElement(connectionFactoryConfiguration.toXmlElement());
}
if (javaTypeResolverConfiguration != null) {
xmlElement.addElement(javaTypeResolverConfiguration.toXmlElement());
}
if (javaModelGeneratorConfiguration != null) {
xmlElement.addElement(javaModelGeneratorConfiguration.toXmlElement());
}
if (sqlMapGeneratorConfiguration != null) {
xmlElement.addElement(sqlMapGeneratorConfiguration.toXmlElement());
}
if (javaClientGeneratorConfiguration != null) {
xmlElement.addElement(javaClientGeneratorConfiguration.toXmlElement());
}
for (TableConfiguration tableConfiguration : tableConfigurations) {
xmlElement.addElement(tableConfiguration.toXmlElement());
}
return xmlElement;
}
use of org.mybatis.generator.api.dom.xml.Attribute in project generator by mybatis.
the class MapperConfigPlugin method contextGenerateAdditionalXmlFiles.
@Override
public List<GeneratedXmlFile> contextGenerateAdditionalXmlFiles() {
Document document = new Document(XmlConstants.MYBATIS3_MAPPER_CONFIG_PUBLIC_ID, XmlConstants.MYBATIS3_MAPPER_CONFIG_SYSTEM_ID);
//$NON-NLS-1$
XmlElement root = new XmlElement("configuration");
document.setRootElement(root);
//$NON-NLS-1$
root.addElement(new TextElement("<!--"));
root.addElement(new TextElement(//$NON-NLS-1$
" This file is generated by MyBatis Generator."));
root.addElement(new TextElement(//$NON-NLS-1$
" This file is the shell of a Mapper Config file - in many cases you will need to add"));
root.addElement(new TextElement(//$NON-NLS-1$
" to this file before it is usable by MyBatis."));
StringBuilder sb = new StringBuilder();
//$NON-NLS-1$
sb.append(" This file was generated on ");
sb.append(new Date());
sb.append('.');
root.addElement(new TextElement(sb.toString()));
//$NON-NLS-1$
root.addElement(new TextElement("-->"));
//$NON-NLS-1$
XmlElement mappers = new XmlElement("mappers");
root.addElement(mappers);
XmlElement mapper;
for (String mapperFile : mapperFiles) {
//$NON-NLS-1$
mapper = new XmlElement("mapper");
//$NON-NLS-1$
mapper.addAttribute(new Attribute("resource", mapperFile));
mappers.addElement(mapper);
}
GeneratedXmlFile gxf = new GeneratedXmlFile(document, properties.getProperty("fileName", //$NON-NLS-1$ //$NON-NLS-2$
"MapperConfig.xml"), //$NON-NLS-1$
properties.getProperty("targetPackage"), //$NON-NLS-1$
properties.getProperty("targetProject"), false, context.getXmlFormatter());
List<GeneratedXmlFile> answer = new ArrayList<GeneratedXmlFile>(1);
answer.add(gxf);
return answer;
}
Aggregations