From: Jussi Koskela Date: Wed, 7 Feb 2018 10:53:58 +0000 (+0200) Subject: Another version of shared ontology import which returns the roots (SCL) X-Git-Tag: v1.43.0~136^2~601 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=9ad7e1083f6c05bc19febf7b40bfe41db26c3877;p=simantics%2Fplatform.git Another version of shared ontology import which returns the roots (SCL) refs #7749 Change-Id: I01079e807e23efa123d3ac025ddc793f663b8017 --- diff --git a/bundles/org.simantics.modeling/scl/Simantics/SharedOntologies.scl b/bundles/org.simantics.modeling/scl/Simantics/SharedOntologies.scl index 6b365d04a..212a4fbaf 100644 --- a/bundles/org.simantics.modeling/scl/Simantics/SharedOntologies.scl +++ b/bundles/org.simantics.modeling/scl/Simantics/SharedOntologies.scl @@ -129,6 +129,7 @@ querySharedOntologyType dummy = do importJava "org.simantics.modeling.ModelingUtils" where importSharedOntologyWithUI :: Variable -> () importSharedOntology :: String -> () + importSharedOntology2 :: String -> [Resource] createSharedOntologyWithUI :: Resource -> () unlinkSharedOntologyWithUI :: Variable -> [Resource] -> () createNewVersionWithUI :: Resource -> () diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java index a43220f06..2053a8fe3 100644 --- a/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java +++ b/bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java @@ -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 importSharedOntology2(String fileName) throws Exception { + MigratedImportResult result = importSharedOntologyWithResult(fileName); + return new ArrayList(result.roots); + } + public static void importSharedOntologyWithUI(ReadGraph graph, final Variable variable) throws DatabaseException { Display.getDefault().asyncExec(new Runnable() {