Another version of shared ontology import which returns the roots (SCL) 27/1427/1
authorJussi Koskela <jussi.koskela@semantum.fi>
Wed, 7 Feb 2018 10:53:58 +0000 (12:53 +0200)
committerJussi Koskela <jussi.koskela@semantum.fi>
Wed, 7 Feb 2018 10:53:58 +0000 (12:53 +0200)
refs #7749

Change-Id: I01079e807e23efa123d3ac025ddc793f663b8017

bundles/org.simantics.modeling/scl/Simantics/SharedOntologies.scl
bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java

index 6b365d04ad984483872bfb06f49f5084ff1e5278..212a4fbaf0011b130f69efdd2c772d0f3b58ac2b 100644 (file)
@@ -129,6 +129,7 @@ querySharedOntologyType dummy = do
 importJava "org.simantics.modeling.ModelingUtils" where
     importSharedOntologyWithUI :: Variable -> <ReadGraph> ()
     importSharedOntology :: String -> ()
+    importSharedOntology2 :: String -> <Proc> [Resource]
     createSharedOntologyWithUI :: Resource -> <ReadGraph> ()
     unlinkSharedOntologyWithUI :: Variable -> [Resource] -> <ReadGraph> ()
     createNewVersionWithUI :: Resource -> <ReadGraph> ()
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() {