use of org.mybatis.generator.api.dom.xml.XmlElement 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.XmlElement 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.XmlElement 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.XmlElement 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;
}
use of org.mybatis.generator.api.dom.xml.XmlElement in project generator by mybatis.
the class RowBoundsPlugin method copyAndSaveElement.
/**
* Use the method copy constructor to create a new element
*
* @param fullyQualifiedTable
* @param method
*/
private void copyAndSaveElement(XmlElement element, FullyQualifiedTable fqt) {
XmlElement newElement = new XmlElement(element);
// remove old id attribute and add a new one with the new name
for (Iterator<Attribute> iterator = newElement.getAttributes().iterator(); iterator.hasNext(); ) {
Attribute attribute = iterator.next();
if ("id".equals(attribute.getName())) {
//$NON-NLS-1$
iterator.remove();
//$NON-NLS-1$ //$NON-NLS-2$
Attribute newAttribute = new Attribute("id", attribute.getValue() + "WithRowbounds");
newElement.addAttribute(newAttribute);
break;
}
}
// save the new element locally. We'll add it to the document
// later
List<XmlElement> elements = elementsToAdd.get(fqt);
if (elements == null) {
elements = new ArrayList<XmlElement>();
elementsToAdd.put(fqt, elements);
}
elements.add(newElement);
}
Aggregations