public int compare(Procedure o1, Procedure o2) {
return (o1.getProcedureName().compareTo(o2.getProcedureName()));
}
});
ObjectFactory factory = new ObjectFactory();
DialectType dType = factory.createDialectType();
dType.setType(dbType.name());
for (Procedure proc : sorted) {
if (proc.getStatments().isEmpty()) continue;
ProcedureType pType = factory.createProcedureType();
pType.setName(proc.getProcedureName());
for (Entry<String, SQLStmt> e : proc.getStatments().entrySet()) {
StatementType sType = factory.createStatementType();
sType.setName(e.getKey());
sType.setValue(e.getValue().getOriginalSQL());
pType.getStatement().add(sType);
} // FOR (stmt)
dType.getProcedure().add(pType);
} // FOR
DialectsType dialects = factory.createDialectsType();
dialects.getDialect().add(dType);
StringWriter st = new StringWriter();
try {
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.marshal(factory.createDialects(dialects), st);
} catch (JAXBException ex) {
throw new RuntimeException("Failed to generate XML", ex);
}
return (st.toString());