]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java
Another version of shared ontology import which returns the roots (SCL)
[simantics/platform.git] / bundles / org.simantics.modeling / src / org / simantics / modeling / ModelingUtils.java
index a43220f0677a0efc3b6c54a3f4b2c39caded4b83..2053a8fe3e19619eb47bf8e2df2842c24c38aceb 100644 (file)
@@ -100,6 +100,7 @@ import org.simantics.db.layer0.adapter.impl.ImportAdvisorFactory;
 import org.simantics.db.layer0.genericrelation.DependenciesRelation.DependencyChangesRequest;
 import org.simantics.db.layer0.genericrelation.DependencyChanges;
 import org.simantics.db.layer0.genericrelation.IndexedRelations;
+import org.simantics.db.layer0.migration.MigratedImportResult;
 import org.simantics.db.layer0.migration.MigrationUtils;
 import org.simantics.db.layer0.request.ActivateModel;
 import org.simantics.db.layer0.request.ActiveModels;
@@ -1450,18 +1451,27 @@ public class ModelingUtils {
        
     }
     
-    public static void importSharedOntology(String fileName) throws Exception {
+    public static MigratedImportResult importSharedOntologyWithResult(String fileName) throws Exception {
        try {
                DataContainer dc = DataContainers.readFile(new File(fileName));
                TransferableGraph1 tg = (TransferableGraph1)dc.content.getValue(TransferableGraph1.BINDING);
                Variant draftStatus = dc.metadata.get(DraftStatusBean.EXTENSION_KEY);
-               MigrationUtils.importSharedOntology(Simantics.getSession(), tg, draftStatus == null);
+               return MigrationUtils.importSharedOntology(Simantics.getSession(), tg, draftStatus == null);
        } catch (Exception e) {
                Logger.defaultLogError(e);
                throw e;
        }
     }
     
+    public static void importSharedOntology(String fileName) throws Exception {
+       importSharedOntologyWithResult(fileName);
+    }
+
+    public static List<Resource> importSharedOntology2(String fileName) throws Exception {
+       MigratedImportResult result = importSharedOntologyWithResult(fileName);
+       return new ArrayList<Resource>(result.roots);
+    }
+    
     public static void importSharedOntologyWithUI(ReadGraph graph, final Variable variable) throws DatabaseException {
        
        Display.getDefault().asyncExec(new Runnable() {