use of org.mybatis.generator.api.dom.xml.Document in project generator by mybatis.
the class SqlMapGenerator method getDocument.
@Override
public Document getDocument() {
Document document = new Document(XmlConstants.IBATIS2_SQL_MAP_PUBLIC_ID, XmlConstants.IBATIS2_SQL_MAP_SYSTEM_ID);
document.setRootElement(getSqlMapElement());
if (!context.getPlugins().sqlMapDocumentGenerated(document, introspectedTable)) {
document = null;
}
return document;
}
use of org.mybatis.generator.api.dom.xml.Document in project generator by mybatis.
the class IntrospectedTableIbatis2Java2Impl method getGeneratedXmlFiles.
@Override
public List<GeneratedXmlFile> getGeneratedXmlFiles() {
List<GeneratedXmlFile> answer = new ArrayList<GeneratedXmlFile>();
Document document = sqlMapGenerator.getDocument();
GeneratedXmlFile gxf = new GeneratedXmlFile(document, getIbatis2SqlMapFileName(), getIbatis2SqlMapPackage(), context.getSqlMapGeneratorConfiguration().getTargetProject(), true, context.getXmlFormatter());
if (context.getPlugins().sqlMapGenerated(gxf, this)) {
answer.add(gxf);
}
return answer;
}
use of org.mybatis.generator.api.dom.xml.Document in project generator by mybatis.
the class XMLMapperGenerator method getDocument.
@Override
public Document getDocument() {
Document document = new Document(XmlConstants.MYBATIS3_MAPPER_PUBLIC_ID, XmlConstants.MYBATIS3_MAPPER_SYSTEM_ID);
document.setRootElement(getSqlMapElement());
if (!context.getPlugins().sqlMapDocumentGenerated(document, introspectedTable)) {
document = null;
}
return document;
}
use of org.mybatis.generator.api.dom.xml.Document 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;
}
use of org.mybatis.generator.api.dom.xml.Document 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