]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
SimanticsPlatform.startUp ensures updateness of installed feature groups 90/1490/1
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 21 Feb 2018 10:58:32 +0000 (12:58 +0200)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Wed, 21 Feb 2018 10:58:32 +0000 (12:58 +0200)
Previously the installed feature group update code was only executed
when the workspace was first initialized. This does work when new
features are installed into Simantics programs running on existing
workspaces.

refs #7005

Change-Id: I5879c398c966dc5d0e15344569b37610703d5e51

bundles/org.simantics/src/org/simantics/SimanticsPlatform.java

index 91c34f0c788f59f4a35984aa764d184ad2d95f9f..54b96054719e993986a7ab6ad2e938b67fc0e430 100644 (file)
@@ -79,6 +79,7 @@ import org.simantics.db.layer0.util.TGTransferableGraphSource;
 import org.simantics.db.layer0.variable.VariableRepository;
 import org.simantics.db.management.SessionContext;
 import org.simantics.db.request.Read;
+import org.simantics.db.request.Write;
 import org.simantics.db.service.LifecycleSupport.LifecycleListener;
 import org.simantics.db.service.LifecycleSupport.LifecycleState;
 import org.simantics.db.service.QueryControl;
@@ -397,21 +398,18 @@ public class SimanticsPlatform implements LifecycleListener {
                         }
                         throw new PlatformException(sb.toString());
                     }
-                    
+
                     List<GraphBundle> sortedBundles = analyzer.getSortedGraphs();
                     if(!sortedBundles.isEmpty()) {
-                       
-                        session.syncRequest(new WriteRequest() {
-                            @Override
-                            public void perform(WriteGraph graph) throws DatabaseException {
-                                try {
-                                    graph.newClusterSet(graph.getRootLibrary());
-                                } catch (ClusterSetExistException e) {
-                                    // Cluster set exist already, no problem.
-                                }
-                                graph.setClusterSet4NewResource(graph.getRootLibrary());
-                                graph.flushCluster();
+
+                        session.syncRequest((Write) graph -> {
+                            try {
+                                graph.newClusterSet(graph.getRootLibrary());
+                            } catch (ClusterSetExistException e) {
+                                // Cluster set exist already, no problem.
                             }
+                            graph.setClusterSet4NewResource(graph.getRootLibrary());
+                            graph.flushCluster();
                         });
 
                         boolean mergedOntologies = false;
@@ -469,13 +467,10 @@ public class SimanticsPlatform implements LifecycleListener {
                                        }
                                }
                         }
-                        
-                        session.syncRequest(new WriteRequest() {
-                            @Override
-                            public void perform(WriteGraph graph) throws DatabaseException {
-                                graph.setClusterSet4NewResource(graph.getRootLibrary());
-                                graph.flushCluster();
-                            }
+
+                        session.syncRequest((Write) graph -> {
+                            graph.setClusterSet4NewResource(graph.getRootLibrary());
+                            graph.flushCluster();
                         });
 
                         if (mergedOntologies)
@@ -582,15 +577,10 @@ public class SimanticsPlatform implements LifecycleListener {
             Collection<GroupReference> groupsWithoutVersion = GroupReference.stripVersions(publishedFeatureGroups);
 
             try {
-                Transaction.startTransaction(session, true);
-                try {
-                    Projects.setProjectInstalledGroups(writeGraph(), projectResource, groupsWithoutVersion);
-                    Transaction.commit();
-                } finally {
-                    Transaction.endTransaction();
-                }
-                //session.getService( LifecycleSupport.class ).save();
-            } catch(DatabaseException ae) {
+                session.syncRequest(
+                        (Write) graph ->
+                        Projects.setProjectInstalledGroups(graph, projectResource, groupsWithoutVersion));
+            } catch (DatabaseException ae) {
                 throw new PlatformException("Failed to install features", ae);
             }
             progressMonitor.worked(10);
@@ -854,7 +844,7 @@ public class SimanticsPlatform implements LifecycleListener {
         installProject = assertProject(progressMonitor, workspacePolicy, installProject);
 
         // 6. Install all features into project, if in debug mode
-        updateInstalledGroups(progressMonitor, installProject);
+        updateInstalledGroups(progressMonitor, true); //installProject);
         TimeLogger.log("Installed all features into project");
 
         // 7. Assert L0.Session in database for this session
@@ -863,14 +853,9 @@ public class SimanticsPlatform implements LifecycleListener {
         session.getService(XSupport.class).setServiceMode(false, false);
 
         try {
-            session.sync(new WriteRequest() {
-
-                @Override
-                public void perform(WriteGraph graph) throws DatabaseException {
-                    QueryControl qc = graph.getService(QueryControl.class);
-                    qc.flush(graph);
-                }
-
+            session.syncRequest((Write) graph -> {
+                QueryControl qc = graph.getService(QueryControl.class);
+                qc.flush(graph);
             });
             TimeLogger.log("Flushed queries");
         } catch (DatabaseException e) {