X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics%2Fsrc%2Forg%2Fsimantics%2FSimanticsPlatform.java;h=211b286a9401e290c0f5819bf9c5d76c035f9a5b;hp=91c34f0c788f59f4a35984aa764d184ad2d95f9f;hb=571533bb34f06bbe3e868dd730d4cf5e793039a4;hpb=ce7ffc15e6ebcdb21089ac862aa5af01da89d454 diff --git a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java index 91c34f0c7..211b286a9 100644 --- a/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java +++ b/bundles/org.simantics/src/org/simantics/SimanticsPlatform.java @@ -65,7 +65,6 @@ import org.simantics.db.VirtualGraph; import org.simantics.db.WriteGraph; import org.simantics.db.common.request.ObjectsWithType; import org.simantics.db.common.request.Queries; -import org.simantics.db.common.request.WriteRequest; import org.simantics.db.common.request.WriteResultRequest; import org.simantics.db.common.utils.Transaction; import org.simantics.db.exception.ClusterSetExistException; @@ -79,6 +78,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 +397,18 @@ public class SimanticsPlatform implements LifecycleListener { } throw new PlatformException(sb.toString()); } - + List 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 +466,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 +576,10 @@ public class SimanticsPlatform implements LifecycleListener { Collection 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 +843,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 +852,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) { @@ -929,6 +913,12 @@ public class SimanticsPlatform implements LifecycleListener { // #7650: improve shutdown robustness in all applications that use the platform Runtime.getRuntime().addShutdownHook(shutdownHook); + // Discard database session undo history at this point to prevent + // the user from undoing any initialization operations performed + // by the platform startup. + SimanticsPlatform.INSTANCE.discardSessionUndoHistory(); + TimeLogger.log("Discarded session undo history"); + return sessionContext; }