use of org.mybatis.generator.api.dom.xml.Document in project generator by mybatis.
the class IntrospectedTableMyBatis3Impl method getGeneratedXmlFiles.
/* (non-Javadoc)
* @see org.mybatis.generator.api.IntrospectedTable#getGeneratedXmlFiles()
*/
@Override
public List<GeneratedXmlFile> getGeneratedXmlFiles() {
List<GeneratedXmlFile> answer = new ArrayList<GeneratedXmlFile>();
if (xmlMapperGenerator != null) {
Document document = xmlMapperGenerator.getDocument();
GeneratedXmlFile gxf = new GeneratedXmlFile(document, getMyBatis3XmlMapperFileName(), getMyBatis3XmlMapperPackage(), 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 SimpleXMLMapperGenerator 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 AntFileGenerator method getAntFileContent.
public String getAntFileContent() {
Document document = new Document();
document.setRootElement(getProjectElement());
return document.getFormattedContent();
}
use of org.mybatis.generator.api.dom.xml.Document 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());
}
use of org.mybatis.generator.api.dom.xml.Document in project generator by mybatis.
the class XmlFileMergerTest method testThatFilesAreTheSameAfterMerge.
@Test
public void testThatFilesAreTheSameAfterMerge() throws Exception {
DefaultXmlFormatter xmlFormatter = new DefaultXmlFormatter();
Properties p = new Properties();
p.setProperty(PropertyRegistry.COMMENT_GENERATOR_SUPPRESS_DATE, "true");
CommentGenerator commentGenerator = new DefaultCommentGenerator();
commentGenerator.addConfigurationProperties(p);
Document document = new Document(XmlConstants.MYBATIS3_MAPPER_PUBLIC_ID, XmlConstants.MYBATIS3_MAPPER_SYSTEM_ID);
document.setRootElement(getSqlMapElement(commentGenerator));
GeneratedXmlFile generatedFile1 = new GeneratedXmlFile(document, "TestMapper.xml", "org.mybatis.test", "src", true, xmlFormatter);
InputSource is1 = new InputSource(new StringReader(generatedFile1.getFormattedContent()));
GeneratedXmlFile generatedFile2 = new GeneratedXmlFile(document, "TestMapper.xml", "org.mybatis.test", "src", true, xmlFormatter);
InputSource is2 = new InputSource(new StringReader(generatedFile2.getFormattedContent()));
String mergedSource = XmlFileMergerJaxp.getMergedSource(is1, is2, "TestMapper.xml");
assertEquals(generatedFile1.getFormattedContent(), mergedSource);
}
Aggregations