use of org.opengroup.archimate.xmlexchange.XMLModelExporter in project archi by archimatetool.
the class ExportXMLProvider method run.
@Override
public void run(CommandLine commandLine) throws Exception {
if (!hasCorrectOptions(commandLine)) {
return;
}
IArchimateModel model = CommandLineState.getModel();
if (model == null) {
throw new IOException(Messages.ExportXMLProvider_1);
}
// File
String value = commandLine.getOptionValue(OPTION_EXPORT_XML);
if (!StringUtils.isSet(value)) {
logError(Messages.ExportXMLProvider_2);
return;
}
File outputFile = new File(value);
XMLModelExporter exporter = new XMLModelExporter();
// Folders
exporter.setSaveOrganisation(commandLine.hasOption(OPTION_EXPORT_XML_FOLDERS));
// Language
exporter.setLanguageCode(commandLine.getOptionValue(OPTION_EXPORT_XML_LANGUAGE));
logMessage(NLS.bind(Messages.ExportXMLProvider_3, model.getName(), outputFile.getPath()));
exporter.exportModel(model, outputFile);
logMessage(Messages.ExportXMLProvider_4);
// Validate file
logMessage(Messages.ExportXMLProvider_5);
XMLValidator validator = new XMLValidator();
validator.validateXML(outputFile);
logMessage(Messages.ExportXMLProvider_6);
}
Aggregations