-
1. Re: Teiid-embedded (9.0.0CR2) export a VDB to XML
rareddy Jun 24, 2016 4:11 PM (in response to jrod2016)Not with single call, with multiple calls it is possible like
public static void exportVDB(Admin admin, String vdbName, int vdbVersion) throws Exception { VDBMetaData vdb = (VDBMetaData)admin.getVDB(vdbName, vdbVersion); for(Model m:vdb.getModels()) { String ddl = admin.getSchema(vdbName, vdbVersion, m.getName(), null, null); ((ModelMetaData)m).addSourceMetadata("DDL", ddl); } FileOutputStream out = new FileOutputStream(vdbName+"-vdb.xml"); VDBMetadataParser.marshell(vdb, out); out.close(); }
HTH
Ramesh..
-
2. Re: Teiid-embedded (9.0.0CR2) export a VDB to XML
jrod2016 Jun 24, 2016 4:45 PM (in response to rareddy)Hi Ramesh,
Thanks for the prompt reply. This definitely helped. However it seems that the only call required was VDBMetadataParser.marshell(...). I did not need to iterate over the models.
I've included my code below:
Thanks,
John
private void saveVDBSchema(VDBMetaData vdb) {
try {
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
VDBMetadataParser.marshell(vdb, baos);
final String vdbSchemaStr = baos.toString();
// My code goes on to use vdbSchemaStr ...
} catch (XMLStreamException | IOException e) {
logger.error(String.format("Error [%s] while trying to save VDB schema", e.getCause()), e);
throw new RuntimeException(e);
}
}
-
3. Re: Teiid-embedded (9.0.0CR2) export a VDB to XML
rareddy Jun 24, 2016 5:06 PM (in response to jrod2016)Oh! well it looks like it slipped my mind that we added to include the DDL/metadata automatically, originally that is way it was.. Cool