]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "Query control functions into Simantics/DB"
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Thu, 8 Feb 2018 09:50:52 +0000 (11:50 +0200)
committerGerrit Code Review <gerrit2@www.simantics.org>
Thu, 8 Feb 2018 09:50:52 +0000 (11:50 +0200)
bundles/org.simantics.modeling.tests/pom.xml [new file with mode: 0644]
bundles/org.simantics.modeling.tests/src/org/simantics/modeling/tests/cases/ModelingCommandSequenceTest.java
bundles/org.simantics.modeling/scl/Simantics/SharedOntologies.scl
bundles/org.simantics.modeling/src/org/simantics/modeling/ModelingUtils.java
bundles/org.simantics.scl.runtime/scl/Prelude.scl
bundles/pom.xml
features/org.simantics.sdk.feature/feature.xml

diff --git a/bundles/org.simantics.modeling.tests/pom.xml b/bundles/org.simantics.modeling.tests/pom.xml
new file mode 100644 (file)
index 0000000..917d185
--- /dev/null
@@ -0,0 +1,17 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+       <modelVersion>4.0.0</modelVersion>
+
+       <groupId>org.simantics</groupId>
+       <artifactId>org.simantics.modeling.tests</artifactId>
+       <version>1.0.0-SNAPSHOT</version>
+       <packaging>eclipse-plugin</packaging>
+
+        <parent>
+                <groupId>org.simantics</groupId>
+                <artifactId>org.simantics.root.bundles</artifactId>
+                <version>1.0.0-SNAPSHOT</version>
+        </parent>
+
+</project>
index 7b86380183c7fbf2a231c17547dac3195171c52e..398e370126c0a62b0dfe28e53a913a4f68220bf8 100644 (file)
@@ -11,7 +11,7 @@ import org.simantics.modeling.tests.commands.WaitActiveExperiment;
 import org.simantics.modeling.tests.commands.WaitMapping;
 import org.simantics.modeling.tests.commands.WriteHeapDump;
 
-public class ModelingCommandSequenceTest extends CommandSequenceTest {
+public abstract class ModelingCommandSequenceTest extends CommandSequenceTest {
 
        protected WaitActiveExperiment waitExperiment = new WaitActiveExperiment();
        protected WaitMapping waitMapping = new WaitMapping();
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() {
index 7e558bdc4fd0c5d1216675919f5465b0042391b1..2be6ed745e7a9edf90c5519d99291763c007b33c 100644 (file)
@@ -1305,6 +1305,11 @@ orElse :: Maybe a -> (<e> a) -> <e> a
 orElse (Just x) _   = x
 orElse Nothing  def = def
 
+@inline
+orElseM :: Maybe a -> (<e> Maybe a) -> <e> Maybe a
+orElseM mx@(Just x) _   = mx
+orElseM Nothing     def = def
+
 /// Either ///
 
 """
index 5f42fcdad27f165b8c399e773aa233ed07fd1b18..43a6f72ab40084660b6584dcbe9c5486b286d7b5 100644 (file)
                <module>org.simantics.modeling.ontology</module>
                <module>org.simantics.modeling.template2d.ontology</module>
                <module>org.simantics.modeling.template2d.ui</module>
+               <module>org.simantics.modeling.tests</module>
                <module>org.simantics.modeling.ui</module>
                <module>org.simantics.modeling.ui.workbench</module>
                <module>org.simantics.msvc.runtime</module>
index 134e975819dae7fa5c8e3440796d155529b4bf14..d59a8a7c4c9459ed96ec627e41d65482ec08c250 100644 (file)
          version="0.0.0"
          unpack="false"/>
 
+   <plugin
+         id="org.simantics.modeling.tests"
+         download-size="0"
+         install-size="0"
+         version="0.0.0"
+         unpack="false"/>
+
 </feature>