]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/sharedontology/wizard/SharedOntologyExporter.java
Support for creating shared ontology dump to git
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / sharedontology / wizard / SharedOntologyExporter.java
index 410d1797661f7d3e62412cf717268bad5043b370..eae7695747153fdc45ddeb66eda859f49775a7da 100644 (file)
@@ -23,11 +23,14 @@ import org.eclipse.jface.operation.IRunnableWithProgress;
 import org.simantics.Simantics;
 import org.simantics.databoard.binding.error.BindingException;
 import org.simantics.databoard.serialization.SerializationException;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.common.request.UniqueRead;
 import org.simantics.db.common.utils.Logger;
 import org.simantics.db.exception.DatabaseException;
 import org.simantics.graph.refactoring.FixExportedOntology;
 import org.simantics.modeling.ModelingUtils;
 import org.simantics.modeling.ModelingUtils.LibraryInfo;
+import org.simantics.modeling.utils.DumpOntologyStructure;
 import org.simantics.utils.ui.dialogs.ShowMessage;
 import org.slf4j.LoggerFactory;
 
@@ -83,6 +86,17 @@ public class SharedOntologyExporter implements IRunnableWithProgress {
             try {
                 Path input = Paths.get(location.toURI());
                 FixExportedOntology.createTGAndPGraph(input);
+                DumpOntologyStructure data = Simantics.sync(new UniqueRead<DumpOntologyStructure>() {
+
+                    @Override
+                    public DumpOntologyStructure perform(ReadGraph graph) throws DatabaseException {
+                        DumpOntologyStructure result = new DumpOntologyStructure();
+                        result.read(graph, info.library.getResource());
+                        return result;
+                    }
+                    
+                });
+                data.write(new File(new File(location.getParent(), location.getName() + ".dump"), info.library.getName()));
             } catch (Exception e) {
                 LOGGER.error("Could not generate TG and Pgraph", e);
             }