]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Sync git svn branch with SVN repository r33249.
authorTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 27 Sep 2016 22:38:03 +0000 (01:38 +0300)
committerTuukka Lehtonen <tuukka.lehtonen@semantum.fi>
Tue, 27 Sep 2016 22:38:03 +0000 (01:38 +0300)
29 files changed:
bundles/org.simantics.charts/src/org/simantics/charts/ui/CSVExportPage.java
bundles/org.simantics.db.indexing/src/org/simantics/db/indexing/IndexedRelationsSearcherBase.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/changeset/MetadataUtils.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterSetsSupportImpl.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/ClusterSetsSupportImpl2.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/GraphSession.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/GraphSessionVirtual.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplDb.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplSocket.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/SessionImplVirtual.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/VirtualGraphServerSupportImpl.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/XSupportImpl.java
bundles/org.simantics.db.server/src/org/simantics/db/server/internal/SessionI.java
bundles/org.simantics.db/src/org/simantics/db/Database.java
bundles/org.simantics.db/src/org/simantics/db/service/ClusterSetsSupport.java
bundles/org.simantics.db/src/org/simantics/db/service/XSupport.java
bundles/org.simantics.fileimport/build.properties
bundles/org.simantics.fileimport/src/org/simantics/fileimport/FileImportService.java
bundles/org.simantics.fileimport/src/org/simantics/fileimport/dropins/FileImportDropins.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/function/All.java
bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/typicals/NewTypicalDiagramInstance.java
bundles/org.simantics.modeling/src/org/simantics/modeling/SCL.java
bundles/org.simantics.modeling/src/org/simantics/modeling/typicals/TypicalUtil.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/coverage/CoverageBuilder.java
bundles/org.simantics.scl.compiler/src/org/simantics/scl/compiler/module/coverage/CoverageUtils.java
bundles/org.simantics.scl.compiler/tests/org/simantics/scl/compiler/tests/ModuleRegressionTests.java
bundles/org.simantics.scl.runtime/src/org/simantics/scl/runtime/profiling/BranchPoint.java
bundles/org.simantics.workbench/src/org/simantics/workbench/internal/SimanticsWorkbenchAdvisor.java
bundles/org.simantics/src/org/simantics/SimanticsPlatform.java

index b5a177e7ed2a42872a099cd27d5f2be95209c866..0f5a1751d585aab615839a7dbd771d6709745e30 100644 (file)
@@ -27,6 +27,7 @@ import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.wizard.WizardPage;\r
 import org.eclipse.swt.SWT;\r
 import org.eclipse.swt.custom.CCombo;\r
+import org.eclipse.swt.custom.ScrolledComposite;\r
 import org.eclipse.swt.events.ModifyListener;\r
 import org.eclipse.swt.events.SelectionAdapter;\r
 import org.eclipse.swt.events.SelectionEvent;\r
@@ -113,7 +114,12 @@ public class CSVExportPage extends WizardPage {
 \r
     @Override\r
     public void createControl(Composite parent) {\r
-        Composite container = new Composite(parent, SWT.NONE);\r
+        ScrolledComposite scroller = new ScrolledComposite(parent, SWT.V_SCROLL);\r
+        scroller.setExpandHorizontal(true);\r
+        scroller.setExpandVertical(true);\r
+\r
+        Composite container = new Composite(scroller, SWT.NONE);\r
+        scroller.setContent(container);\r
         GridLayoutFactory.swtDefaults().spacing(20, 10).numColumns(3).applyTo(container);\r
         new Label(container, SWT.NONE).setText("Select a model:");\r
         model = new CCombo(container, SWT.BORDER);\r
@@ -128,7 +134,7 @@ public class CSVExportPage extends WizardPage {
         item = new Table(container, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION | SWT.CHECK);\r
         {\r
             item.setToolTipText("Selects the Subscription Items");\r
-            GridDataFactory.fillDefaults().grab(true, false).span(2, 1).hint(SWT.DEFAULT, 105).applyTo(item);\r
+            GridDataFactory.fillDefaults().grab(true, true).span(2, 1).hint(SWT.DEFAULT, 105).applyTo(item);\r
         }\r
         item.addSelectionListener(new SelectionAdapter() {\r
             @Override\r
@@ -292,7 +298,9 @@ public class CSVExportPage extends WizardPage {
 \r
         model.addSelectionListener(s);\r
 \r
-        setControl(container);\r
+        scroller.setMinSize(container.computeSize(SWT.DEFAULT, SWT.DEFAULT));\r
+\r
+        setControl(scroller);\r
         validatePage();\r
         \r
     }\r
index f26f9a9616de93681bad61b7bc204f0142a0068e..4afbb174e0eb565958f51a94c0fdfc836d2219bb 100644 (file)
@@ -705,27 +705,22 @@ abstract public class IndexedRelationsSearcherBase {
                                                                                        mon.worked(1);\r
                                                                                }\r
                                                                        }\r
-\r
-                                                                       s.release();\r
-\r
                                                                } catch (DatabaseException e) {\r
-                                                                       throw new IllegalStateException(e);\r
+                                                                   Logger.defaultLogError("DatabaseException occured during initializing index", e);\r
+                                                               } catch (Throwable t) {\r
+                                                                   Logger.defaultLogError("Fatal error occured during initializing index", t);\r
+                                                               } finally {\r
+                                                                   s.release();\r
                                                                }\r
-                                                               \r
                                                        }\r
-                               \r
                        });\r
-                       \r
                     }\r
-                    \r
                     try {\r
                                                s.acquire(INDEXING_THREAD_COUNT);\r
                                        } catch (InterruptedException e) {\r
                                                e.printStackTrace();\r
                                        }\r
-                    \r
                 }\r
-                \r
             });\r
 \r
             // http://www.gossamer-threads.com/lists/lucene/java-dev/47895\r
index 31f29554ca49fdc5ac738721752022c31d7fec25..ef1753396c1b03b33adbae36432a469068bc6d92 100644 (file)
@@ -122,22 +122,9 @@ public class MetadataUtils {
 //        Map<Long, Map<String,byte[]>> metadatas = getMetadatas(graph, support, revisionId, Long.MAX_VALUE);\r
         \r
         for(Map.Entry<Long, Map<String,byte[]>> e : metadatas.entrySet()) {\r
-//            System.err.println("metadata " + e.getKey() + " " + e.getValue());\r
-//            long csid = e.getKey();\r
+\r
             Map<String,byte[]> metadata = e.getValue();\r
-//          if(metadata == null) \r
-//          continue;\r
-//            if(metadata != null) {\r
-        \r
-//        for(ChangeSetIdentifier csi : csis) {\r
-//            if(csi.getId() < fromRevision) { // TODO remove this test when DB api is fixed\r
-//                System.err.println("ManagementSupport.getChangeSetIdentifiers returned identifiers outside of the requested range.");\r
-//                continue;\r
-//            }\r
-//            Map<String,byte[]> metadata = getMetadata(graph, support, csi);\r
-//            if(metadata == null) \r
-//                continue;\r
-            \r
+\r
             browseChanges: {\r
                 byte[] changesData = metadata.get(DependencyChanges.class.getName());\r
                 if(changesData == null || changesData.length == 0) \r
@@ -152,35 +139,13 @@ public class MetadataUtils {
                             visitor.visit(graph, change, inverted);\r
             }\r
             \r
-            browseUndos: {\r
-                byte[] undoMetadata = metadata.get(UndoMetadata.class.getName());\r
-                if(undoMetadata == null || undoMetadata.length == 0) \r
-                    break browseUndos;\r
+            byte[] undoMetadata = metadata.get(UndoMetadata.class.getName());\r
+            if(undoMetadata != null && undoMetadata.length != 0) { \r
                 UndoMetadata undo = UndoMetadata.deserialise(graph.getSession(), undoMetadata);\r
                 visitDependencyChangesBetween(graph, model, undo.getBeginCSId(), undo.getEndCSId(), visitor, \r
                         undo.isRedo() ? inverted : !inverted);\r
             }\r
         }\r
-       }\r
+    }\r
 \r
-//     public static Map<Resource, Collection<Change>> getDependencyChangeIndexFrom(ReadGraph graph, long revisionId) throws DatabaseException {\r
-//\r
-//             \r
-//             \r
-//             Map<Resource, Collection<Change>> index = new HashMap<Resource, Collection<Change>>();\r
-//\r
-//             for(Map<Resource, Collection<Change>> entry : getDependencyChangesFrom(graph, revisionId)) {\r
-//                     if(DEBUG) System.out.println("getDependencyChangeIndexFrom process " + entry);\r
-//                     Collection<DependencyChangeEntry> list = index.get(entry.getOwner());\r
-//                     if(list == null) {\r
-//                             list = new ArrayList<DependencyChangeEntry>();\r
-//                             index.put(entry.getOwner(), list);\r
-//                     }\r
-//                     list.add(entry);\r
-//             }\r
-//             \r
-//             return index;\r
-//             \r
-//     }\r
-       \r
 }\r
index c2030409580b4a184419bfbce4e83d838539b53b..0f03141ea635376f10c57b11a9992b9cbafd21d7 100644 (file)
@@ -69,8 +69,14 @@ public class ClusterSetsSupportImpl implements ClusterSetsSupport, Disposable {
     public void clear() {\r
        clusterSets.clear();\r
     }\r
+    \r
+    @Override\r
+    public void setReadDirectory(Path read) {\r
+        // TODO Auto-generated method stub\r
+        \r
+    }\r
     @Override\r
-    public void updateReadAndWriteDirectories(Path read, Path write) {\r
+    public void updateWriteDirectory(Path write) {\r
         // Nothing to do here\r
     }\r
     \r
index def2905e362b35d90208a36d131113cb5e32fce0..db28af306b384be7284c9b54741a69e359f2c6db 100644 (file)
@@ -13,8 +13,8 @@ public class ClusterSetsSupportImpl2 implements ClusterSetsSupport, Disposable {
 \r
     final private static boolean DEBUG = false;\r
     final private static Map<String, ClusterSets> sClusterSets = new HashMap<String, ClusterSets>();\r
-    private Path writeDirectory;\r
     private Path readDirectory;\r
+    private Path writeDirectory;\r
     private String databaseId; // Unique identifier for database of session. Initialized in connect. \r
     private ClusterSets clusterSets; // Cluster sets for session. Initialized in connect.\r
     public ClusterSetsSupportImpl2() {\r
@@ -70,17 +70,17 @@ public class ClusterSetsSupportImpl2 implements ClusterSetsSupport, Disposable {
        clusterSets.clear();\r
     }\r
     @Override\r
-    public void updateReadAndWriteDirectories(Path read, Path write) {\r
-        setDirectories(read, write);\r
-    }\r
-    \r
-    private void setDirectories(Path readDirectory, Path writeDirectory) {\r
-        this.readDirectory = readDirectory;\r
-        this.writeDirectory = writeDirectory;\r
+    public void updateWriteDirectory(Path write) {\r
+        this.writeDirectory = write;\r
         if(clusterSets != null) {\r
             clusterSets.setWriteDirectory(writeDirectory.toFile());\r
             clusterSets.touch();\r
         }\r
     }\r
 \r
+    @Override\r
+    public void setReadDirectory(Path read) {\r
+        this.readDirectory = read;\r
+    }\r
+\r
 }\r
index 054ee1d604e5ef8ddb6e0509cf043795a7612d90..58917ae747c7c1fad57995288e745d6b14b7b83a 100644 (file)
@@ -29,13 +29,13 @@ import org.simantics.databoard.binding.impl.TreeMapBinding;
 import org.simantics.databoard.serialization.Serializer;\r
 import org.simantics.db.ChangeSetIdentifier;\r
 import org.simantics.db.Database;\r
-import org.simantics.db.Operation;\r
-import org.simantics.db.SessionReference;\r
 import org.simantics.db.Database.Session.ChangeSetData;\r
 import org.simantics.db.Database.Session.ChangeSetIds;\r
 import org.simantics.db.Database.Session.ClusterChanges;\r
 import org.simantics.db.Database.Session.ClusterIds;\r
 import org.simantics.db.Database.Session.Refresh;\r
+import org.simantics.db.Operation;\r
+import org.simantics.db.SessionReference;\r
 import org.simantics.db.common.UndoContextEx;\r
 import org.simantics.db.common.utils.Logger;\r
 import org.simantics.db.exception.DatabaseException;\r
@@ -49,7 +49,6 @@ import org.simantics.scl.runtime.function.Function1;
 import org.simantics.scl.runtime.function.FunctionImpl1;\r
 import org.simantics.utils.threads.ThreadUtils;\r
 \r
-import fi.vtt.simantics.procore.ProCoreSessionReference;\r
 import gnu.trove.iterator.TLongObjectIterator;\r
 import gnu.trove.map.hash.THashMap;\r
 import gnu.trove.map.hash.TLongObjectHashMap;\r
@@ -725,6 +724,9 @@ public abstract class GraphSession {
             clusters[i] = new ClusterUID(first[i], second[i]);\r
         return clusters;\r
     }\r
+    public boolean rolledback() {\r
+        return dbSession.rolledback();\r
+    }\r
 }\r
 class BuiltinData {\r
     final long                  id;\r
index 6defe634a469e28bc198ab4a1c962a3fead0ccc1..1dc1b015a931b137dd6944cbaddc56566db45690 100644 (file)
@@ -127,6 +127,10 @@ class GraphSessionVirtual extends GraphSession { // Ã„sh! This extends relation
         public boolean refreshEnabled() {\r
             return false;\r
         }\r
+        @Override\r
+        public boolean rolledback() {\r
+            return false;\r
+        }\r
     }\r
     private AtomicLong changeSetId = new AtomicLong(Constants.NullChangeSetId);\r
     private AtomicLong transactionId = new AtomicLong(Constants.NullTransactionId);\r
index 3c0f71eaf645847ad2fb7b50022995354ce2451b..d0e9d55f05fdaf151b55b09471aeb7ecf6fafbd9 100644 (file)
@@ -12,7 +12,6 @@
 package fi.vtt.simantics.procore.internal;\r
 \r
 import java.io.File;\r
-import java.io.IOException;\r
 \r
 import org.simantics.db.Database;\r
 import org.simantics.db.SessionManager;\r
@@ -32,8 +31,6 @@ import org.simantics.db.impl.query.QueryProcessor;
 import org.simantics.db.impl.query.QuerySupport;\r
 import org.simantics.db.service.ServerInformation;\r
 \r
-import fi.vtt.simantics.procore.BackdoorAuthenticator;\r
-\r
 final public class SessionImplDb extends SessionImplSocket {\r
 \r
     /**\r
index 9efb0fc38c8eab1f7414437c40df37b5918267f4..7302d13d45d6b0a9f071945d301ba80eed42f1a2 100644 (file)
@@ -294,7 +294,8 @@ public abstract class SessionImplSocket implements Session, WriteRequestSchedule
         this.clusterControl = new ClusterControlImpl(this);\r
         serviceLocator.registerService(ClusterControl.class, clusterControl);\r
         this.clusterSetsSupport = new ClusterSetsSupportImpl2(); // Using same path as virtual graphs.\r
-        this.clusterSetsSupport.updateReadAndWriteDirectories(t.toPath(), t.toPath());\r
+        this.clusterSetsSupport.setReadDirectory(t.toPath());\r
+        this.clusterSetsSupport.updateWriteDirectory(t.toPath());\r
         serviceLocator.registerService(ClusterSetsSupport.class, clusterSetsSupport);\r
     }\r
 \r
index 1a109d2e0be42ea9b35bf62d2a813a16ae7a4997..377208f22f4001f27d4233b04b3ae24fd25b0e8f 100644 (file)
@@ -53,9 +53,9 @@ public class SessionImplVirtual extends SessionImplSocket {
         // This is used by QueryProcessor among others.\r
         String databaseId = GraphSessionVirtual.serverInfo.databaseId;\r
         String serverId = GraphSessionVirtual.serverInfo.serverId;\r
-        virtualGraphServerSupport.connect(databaseId + "." + serverId);\r
-        virtualGraphImpl = (VirtualGraphImpl)virtualGraphServerSupport.getWorkspacePersistent("virtualGraph" + "." + serverId);\r
         try {\r
+            virtualGraphServerSupport.connect(databaseId + "." + serverId);\r
+            virtualGraphImpl = (VirtualGraphImpl)virtualGraphServerSupport.getWorkspacePersistent("virtualGraph" + "." + serverId);\r
             requestManager = new SessionRequestManager(this, state);\r
             clusterStream = new ClusterStream(this, graphSession, true);\r
             clusterTranslator = new ClusterTranslatorImpl(this);\r
index 6c86c100a0fe0d2a6f78b86250f816bccb26ccb0..227d9bcff1d533b02793c665f0ed214ed4b409cb 100644 (file)
@@ -38,6 +38,7 @@ import org.simantics.db.service.SerialisationSupport;
 import org.simantics.db.service.ServerInformation;\r
 import org.simantics.db.service.TransferableGraphSupport;\r
 import org.simantics.db.service.VirtualGraphSupport;\r
+import org.simantics.db.service.XSupport;\r
 import org.simantics.layer0.Layer0;\r
 import org.simantics.utils.FileUtils;\r
 \r
@@ -63,14 +64,21 @@ public class VirtualGraphServerSupportImpl implements VirtualGraphSupport, Virtu
                this.virtualGraphStoragePath = path;\r
        }\r
 \r
-       void connect(String dbString) {\r
+    void connect(String dbString) throws Exception {\r
+        virtualId = new AtomicInteger(-2);\r
+        this.dbString = dbString;\r
 \r
-               virtualId = new AtomicInteger(-2);\r
-\r
-               this.dbString = dbString;\r
+        XSupport support = session.getService(XSupport.class);\r
+        if (support.rolledback()) {\r
+            for (File file : virtualGraphStoragePath.listFiles()) {\r
+                if (!file.delete()) {\r
+                    throw new IOException("Could not delete file " + file.getAbsolutePath());\r
+                }\r
+            }\r
+        }\r
 \r
                File file = new File(virtualGraphStoragePath, "virtualGraphs." + dbString + ".dat");\r
-\r
+               \r
                //      System.out.println("scanning " + file.getAbsolutePath());\r
 \r
                if(file.exists()) {\r
@@ -84,11 +92,15 @@ public class VirtualGraphServerSupportImpl implements VirtualGraphSupport, Virtu
 \r
                                hasVirtuals = true;\r
 \r
+                               String databaseId = session.getService(ServerInformation.class).getDatabaseId();\r
+                               String matcher = ".W." + databaseId + ".vg.";\r
+                               \r
                                // Load existing workspace persistent graphs\r
                                for(File virtualGraph : virtualGraphStoragePath.listFiles(new FilenameFilter() {\r
                                        @Override\r
                                        public boolean accept(File dir, String name) {\r
-                                               return name.endsWith(".vg");\r
+                                           boolean matches = name.contains(matcher);\r
+                                               return matches;\r
                                        }\r
                                })) {\r
                                        String name = virtualGraph.getName();\r
index 662effbfb0c9a10197f587f75de11382a54bcd4a..f6ca16af49f373c11bb19ec749c6b4fd0c25f6c3 100644 (file)
@@ -157,4 +157,9 @@ public class XSupportImpl implements XSupport {
         Database db = session.graphSession.dbSession.getDatabase();\r
         db.purgeDatabase();\r
     }\r
+\r
+    @Override\r
+    public boolean rolledback() {\r
+        return session.graphSession.rolledback();\r
+    }\r
 }\r
index bb2cdb04059fc21a94c311c01b8d6051f496fe95..04eb991f6455988ca4ef13d5b8009a94ead3f88c 100644 (file)
@@ -232,6 +232,10 @@ public class SessionI implements Session {
     public boolean refreshEnabled() {\r
         return true;\r
     }\r
+    @Override\r
+    public boolean rolledback() {\r
+        return false;\r
+    }\r
 }\r
 class SessionManager {\r
     private ConcurrentHashMap<Client, SessionI> sessionMap = new ConcurrentHashMap<Client, SessionI>();\r
index c72e72b75933b58d5c59f3a21ee72c5f950df7d2..c80abd27d0e456e79aabe07a4881138cbb94804f 100644 (file)
@@ -135,6 +135,7 @@ public interface Database {
         \r
         public <T> T clone(ClusterUID clusterUID, ClusterCreator clusterCreator) throws DatabaseException;\r
         public boolean refreshEnabled();\r
+        public boolean rolledback();\r
     }\r
     public Session newSession(ServiceLocator locator) throws SDBException;\r
     interface Journal {\r
index 78d47ea986a0c84a39f36aae518ec97778b2acb8..e79433870819ef4b0c4709f3396e0dbb3cba7fad 100644 (file)
@@ -12,6 +12,7 @@ public interface ClusterSetsSupport {
     void put(long resourceId, long clusterId);\r
     void save() throws IOException;\r
     void clear();\r
-    void updateReadAndWriteDirectories(Path read, Path write);\r
+    void updateWriteDirectory(Path write);\r
+    void setReadDirectory(Path read);\r
        \r
 }\r
index d365d002a2121699c040043d9565e4649c5f8fd2..d5de101405af8b7e254dc88407ef7f5b3a88df55 100644 (file)
@@ -157,4 +157,6 @@ public interface XSupport {
     throws DatabaseException;\r
     public void purge() throws DatabaseException;\r
 \r
+    public boolean rolledback();\r
+    \r
 }\r
index f760fc2225ebde0b1e2ace2a65f970598c0264c3..770ef5dc728031be8e1add473fb1a71166eeefc9 100644 (file)
@@ -2,8 +2,10 @@ output.. = bin/
 bin.includes = META-INF/,\\r
                .,\\r
                OSGI-INF/,\\r
-               plugin.xml\r
+               plugin.xml,\\r
+               scl/\r
                OSGI-INF/FileReferenceFileImport.xml,\\r
                OSGI-INF/LibraryFolderFileImport.xml,\\r
                scl/\r
 source.. = src/\r
+src.includes = scl/\r
index c65b7c7d835114de7d971e5d7b5fe90d110761f0..1fa4e3f5b2756c3506bf45403845cd4f8387a005 100644 (file)
@@ -133,6 +133,11 @@ public class FileImportService {
                     return;\r
                 service.remove(resource.get());\r
                 removeResourceForPath(file);\r
+                try {\r
+                    Files.delete(file);\r
+                } catch (IOException e) {\r
+                    Files.delete(file);\r
+                }\r
             } catch (Throwable t) {\r
                 if (callback.isPresent()) {\r
                     callback.get().accept(t);\r
index 5942c5deb299956e871f034c86efe78bcd07f358..6c07f92aaffcdfee2e40cab47714a34ec9b41fca 100644 (file)
@@ -5,6 +5,7 @@ import static java.nio.file.StandardWatchEventKinds.ENTRY_DELETE;
 import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY;\r
 import static java.nio.file.StandardWatchEventKinds.OVERFLOW;\r
 \r
+import java.io.FileNotFoundException;\r
 import java.io.IOException;\r
 import java.io.RandomAccessFile;\r
 import java.nio.file.FileSystem;\r
@@ -141,7 +142,7 @@ public class FileImportDropins {
                             }\r
                             \r
                             FileImportService.performFileImport(newPath, Optional.of(t -> {\r
-                                if (t instanceof FileSystemException) {\r
+                                if ((t instanceof FileSystemException) || (t instanceof FileNotFoundException)) {\r
                                     try {\r
                                         syncPath(newPath);\r
                                     } catch (IOException e) {\r
index 6cfd6193c3154cc8cb9e682be58e92a45b8cf428..57c1b040aa380754e8f6fcbe359d1ddd781c6cc9 100644 (file)
@@ -13,7 +13,6 @@ import org.simantics.db.Session;
 import org.simantics.db.common.NamedResource;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.variable.Variable;\r
-import org.simantics.db.procedure.Procedure;\r
 import org.simantics.modeling.typicals.TypicalUtil;\r
 import org.simantics.modeling.ui.typicals.NewTypicalDiagramInstance;\r
 import org.simantics.scenegraph.loader.ScenegraphLoaderUtils;\r
@@ -50,15 +49,10 @@ public class All {
         }\r
         final Collection<NamedResource> namedTypicals = TypicalUtil.toNamedResources(session, typicals);\r
 \r
-        return TypicalUtil.syncExec(new Consumer<Procedure<Resource>>() {\r
-            @Override\r
-            public void accept(final Procedure<Resource> procedure) {\r
-                NewTypicalDiagramInstance.asyncQueryFromList(namedTypicals, selectedTypical -> {\r
-                    if (selectedTypical == null) {\r
-                        procedure.execute(null);\r
-                        return;\r
-                    }\r
-                    try {\r
+        return TypicalUtil.syncExec(procedure ->  {\r
+            NewTypicalDiagramInstance.asyncQueryFromList(namedTypicals, selectedTypical -> {\r
+                try {\r
+                    if (selectedTypical != null) {\r
                         session.syncRequest(TypicalUtil.instantiateTemplate(target, selectedTypical, instance -> {\r
                             try {\r
                                 Set<Resource> customlyNamed = new HashSet<Resource>();\r
@@ -71,14 +65,14 @@ public class All {
                                 procedure.exception(e);\r
                             }\r
                         }));\r
-                    } catch (Throwable e) {\r
-                        procedure.exception(e);\r
-                    } finally {\r
-                        procedure.execute(null);\r
                     }\r
-                });\r
-            }\r
+                } catch (Throwable e) {\r
+                    procedure.exception(e);\r
+                } finally {\r
+                    procedure.execute(null);\r
+                }\r
+            });\r
         });\r
     }\r
 \r
-}
\ No newline at end of file
+}\r
index 2bb0f9dfc706cbdd97261c89e2b6ca70f9ba2af8..25fd46e69dd4fb914a18c78b989dcb34feacac10 100644 (file)
@@ -47,47 +47,44 @@ public class NewTypicalDiagramInstance implements ActionFactory {
 \r
     @Override\r
     public Runnable create(Object target_) {\r
-        final Resource target = (Resource) target_;\r
-        return new Runnable() {\r
-            @Override\r
-            public void run() {\r
-                Job job = new DatabaseJob("Instantiate Typical") {\r
-                    @Override\r
-                    protected IStatus run(IProgressMonitor monitor) {\r
-                        monitor.beginTask("Instantiate Typical...", IProgressMonitor.UNKNOWN);\r
+        Resource target = (Resource) target_;\r
+        return () -> {\r
+            Job job = new DatabaseJob("Instantiate Typical") {\r
+                @Override\r
+                protected IStatus run(IProgressMonitor monitor) {\r
+                    monitor.beginTask("Instantiate Typical...", IProgressMonitor.UNKNOWN);\r
 \r
-                        final Session session = Simantics.getSession();\r
-                        session.markUndoPoint();\r
-                        try {\r
-                            final AtomicReference<Resource> model = new AtomicReference<Resource>();\r
-                            Function2<Resource, Resource, Resource> instantiator = session.syncRequest(new UniqueRead<Function2<Resource, Resource, Resource>>() {\r
-                                @Override\r
-                                public Function2<Resource, Resource, Resource> perform(ReadGraph graph) throws DatabaseException {\r
-                                    model.set( graph.sync(new PossibleModel(target)) );\r
-                                    if (model.get() == null)\r
-                                        throw new CancelTransactionException("Cannot find a model from the input selection. Typical diagram instantiation not possible.");\r
+                    Session session = Simantics.getSession();\r
+                    session.markUndoPoint();\r
+                    try {\r
+                        AtomicReference<Resource> model = new AtomicReference<Resource>();\r
+                        Function2<Resource, Resource, Resource> instantiator = session.syncRequest(new UniqueRead<Function2<Resource, Resource, Resource>>() {\r
+                            @Override\r
+                            public Function2<Resource, Resource, Resource> perform(ReadGraph graph) throws DatabaseException {\r
+                                model.set( graph.sync(new PossibleModel(target)) );\r
+                                if (model.get() == null)\r
+                                    throw new CancelTransactionException("Cannot find a model from the input selection. Typical diagram instantiation not possible.");\r
 \r
-                                    ModelingResources MOD = ModelingResources.getInstance(graph);\r
-                                    Function2<Resource, Resource, Resource> instantiator = graph.getRelatedValue2(model.get(), MOD.StructuralModel_typicalInstantiationFunction);\r
-                                    return instantiator;\r
-                                }\r
-                            });\r
+                                ModelingResources MOD = ModelingResources.getInstance(graph);\r
+                                Function2<Resource, Resource, Resource> instantiator = graph.getRelatedValue2(model.get(), MOD.StructuralModel_typicalInstantiationFunction);\r
+                                return instantiator;\r
+                            }\r
+                        });\r
 \r
-                            instantiator.apply(model.get(), target);\r
+                        instantiator.apply(model.get(), target);\r
 \r
-                            return Status.OK_STATUS;\r
-                        } catch (CancelTransactionException e) {\r
-                            return new Status(IStatus.INFO , Activator.PLUGIN_ID, e.getMessage());\r
-                        } catch (DatabaseException e) {\r
-                            return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);\r
-                        } finally {\r
-                            monitor.done();\r
-                        }\r
+                        return Status.OK_STATUS;\r
+                    } catch (CancelTransactionException e) {\r
+                        return new Status(IStatus.INFO , Activator.PLUGIN_ID, e.getMessage());\r
+                    } catch (DatabaseException e) {\r
+                        return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);\r
+                    } finally {\r
+                        monitor.done();\r
                     }\r
-                };\r
-                //job.setUser(true);\r
-                job.schedule();\r
-            }\r
+                }\r
+            };\r
+            //job.setUser(true);\r
+            job.schedule();\r
         };\r
     }\r
 \r
index 555401327c89b48c4bd7cb73355f35a611710796..52909e018bb36df8d1723d23b37f7321a46d0867 100644 (file)
@@ -17,13 +17,13 @@ import org.simantics.SimanticsPlatform.OntologyRecoveryPolicy;
 import org.simantics.db.ReadGraph;\r
 import org.simantics.db.Resource;\r
 import org.simantics.db.WriteGraph;\r
-import org.simantics.db.common.request.ReadRequest;\r
 import org.simantics.db.common.request.WriteRequest;\r
 import org.simantics.db.exception.DatabaseException;\r
 import org.simantics.db.layer0.request.external.EclipsePreferencePrimitiveRead;\r
 import org.simantics.db.layer0.util.RemoverUtil;\r
 import org.simantics.db.layer0.util.SimanticsClipboard;\r
 import org.simantics.db.service.DebugSupport;\r
+import org.simantics.db.service.ServiceActivityMonitor;\r
 \r
 public class SCL {\r
     public static void killPlatformWrite(WriteGraph graph) throws DatabaseException {\r
@@ -61,29 +61,33 @@ public class SCL {
        //  but unfortunately this does not work either...\r
        // so we synchronize by a familiar write transaction\r
         // And then wait still some more\r
-               for(int i=0;i<3;i++) {\r
-              Simantics.getSession().syncRequest(new WriteRequest() {\r
-                   @Override\r
-                   public void perform(WriteGraph graph) throws DatabaseException {\r
-                   }\r
-\r
-                       @Override\r
-                       public String toString() {\r
-                               return "Utils sync";\r
-                       }\r
-              });\r
-\r
-              // And then wait still some more\r
-              Simantics.getSession().syncRequest(new ReadRequest() {\r
-                  @Override\r
-                  public void run(ReadGraph graph) throws DatabaseException {\r
-                  }\r
-             });\r
-               }\r
+//             for(int i=0;i<3;i++) {\r
+       Simantics.getSession().syncRequest(new WriteRequest() {\r
+            @Override\r
+            public void perform(WriteGraph graph) throws DatabaseException {\r
+            }\r
+\r
+               @Override\r
+               public String toString() {\r
+                       return "Utils sync";\r
+               }\r
+       });\r
+//\r
+//            // And then wait still some more\r
+//            Simantics.getSession().syncRequest(new ReadRequest() {\r
+//                @Override\r
+//                public void run(ReadGraph graph) throws DatabaseException {\r
+//                }\r
+//           });\r
+//             }\r
     }\r
 \r
     public static void syncGraph() throws Exception {\r
-        sync();\r
+        try {\r
+            Simantics.getSession().getService(ServiceActivityMonitor.class).waitForCompletion();\r
+        } catch (InterruptedException e) {\r
+            throw new DatabaseException(e);\r
+        }\r
 \r
                // OK, now the experiment activate job should be scheduled\r
                // Wait for the job to finish\r
index e15f5036d9be684d25fe5f2e7d8b315b229f8b36..952cd286271560e20a712d788d5510fb65ab399a 100644 (file)
@@ -130,21 +130,21 @@ public class TypicalUtil {
         }\r
     };\r
 \r
-    public static Collection<NamedResource> toNamedResources(RequestProcessor processor, final Collection<Resource> rs) throws DatabaseException {\r
+    public static List<NamedResource> toNamedResources(RequestProcessor processor, final Collection<Resource> rs) throws DatabaseException {\r
         return toNamedResources(processor, rs, new TypicalNamingFunction());\r
     }\r
 \r
-    public static Collection<NamedResource> toNamedResources(RequestProcessor processor, final Collection<Resource> rs, final Function2<ReadGraph, Resource, String> namingFunction) throws DatabaseException {\r
-        return processor.syncRequest(new UniqueRead<Collection<NamedResource>>() {\r
+    public static List<NamedResource> toNamedResources(RequestProcessor processor, final Collection<Resource> rs, final Function2<ReadGraph, Resource, String> namingFunction) throws DatabaseException {\r
+        return processor.syncRequest(new UniqueRead<List<NamedResource>>() {\r
             @Override\r
-            public Collection<NamedResource> perform(ReadGraph graph) throws DatabaseException {\r
+            public List<NamedResource> perform(ReadGraph graph) throws DatabaseException {\r
                 return toNamedResources(graph, rs, namingFunction);\r
             }\r
         });\r
     }\r
 \r
-    public static Collection<NamedResource> toNamedResources(ReadGraph graph, Collection<Resource> rs, final Function2<ReadGraph, Resource, String> namingFunction) throws DatabaseException {\r
-        Collection<NamedResource> result = new ArrayList<NamedResource>(rs.size());\r
+    public static List<NamedResource> toNamedResources(ReadGraph graph, Collection<Resource> rs, final Function2<ReadGraph, Resource, String> namingFunction) throws DatabaseException {\r
+        List<NamedResource> result = new ArrayList<>(rs.size());\r
         for (Resource r : rs)\r
             result.add(new NamedResource(namingFunction.apply(graph, r), r));\r
         return result;\r
@@ -157,8 +157,11 @@ public class TypicalUtil {
         return s;\r
     }\r
 \r
-    public static WriteResult<Resource> instantiateTemplate(final Resource target, final NamedResource template,\r
-            final Consumer<Pair<WriteGraph, Resource>> successContinuation) {\r
+    public static WriteResult<Resource> instantiateTemplate(\r
+            Resource target,\r
+            NamedResource template,\r
+            Consumer<Pair<WriteGraph, Resource>> successContinuation)\r
+    {\r
         return new WriteResultRequest<Resource>() {\r
             @Override\r
             public Resource perform(WriteGraph graph) throws DatabaseException {\r
index b3bfcd88902bcaf5f9ce731ee1a2b54f05797b0d..835db7420432aaf018c80051d25b96d8468e8e76 100644 (file)
@@ -10,7 +10,7 @@ public class CoverageBuilder {
     THashMap<String, THashMap<String, BranchPoint[]>> combined =\r
             new THashMap<String, THashMap<String, BranchPoint[]>>();\r
     \r
-    public void addCoverage(Module module) {\r
+    public void addCoverage(Module module, boolean persistOverBranchpointReset) {\r
         THashMap<String, BranchPoint[]> branchPointMap = module.getBranchPoints();\r
         if(branchPointMap == null)\r
             return;\r
@@ -24,25 +24,43 @@ public class CoverageBuilder {
             @Override\r
             public boolean execute(String name, BranchPoint[] branchPoints) {\r
                 BranchPoint[] oldBranchPoints = oldBranchPointMap_.get(name);\r
-                if(oldBranchPoints == null)\r
-                    oldBranchPointMap_.put(name, branchPoints);\r
-                else\r
+                if(oldBranchPoints == null) {\r
+                    if (persistOverBranchpointReset) {\r
+                        // Clone the branchPoints array so that if will last over a reset\r
+                        BranchPoint[] clonedBranchPoints = cloneBranchPoints(branchPoints);\r
+                        oldBranchPointMap_.put(name, clonedBranchPoints);\r
+                    } else {\r
+                        // No need to copy so resetting branchpoints will reset this as well\r
+                        oldBranchPointMap_.put(name, branchPoints);\r
+                    }\r
+                } else {\r
                     combineCounters(oldBranchPoints, branchPoints);\r
+                }\r
                 return true;\r
             }\r
         });\r
     }\r
     \r
+    private static BranchPoint[] cloneBranchPoints(BranchPoint[] oldBranchPoints) {\r
+        BranchPoint[] newBranchPoints = new BranchPoint[oldBranchPoints.length];\r
+        for (int i = 0; i < oldBranchPoints.length; i++) {\r
+            BranchPoint bp = oldBranchPoints[i];\r
+            BranchPoint[] children = cloneBranchPoints(bp.getChildren());\r
+            newBranchPoints[i] = new BranchPoint(bp.getLocation(), bp.getCodeSize(), children);\r
+        }\r
+        return newBranchPoints;\r
+    }\r
+    \r
     private static void combineCounters(BranchPoint[] oldBranchPoints, BranchPoint[] branchPoints) {\r
         if(oldBranchPoints.length != branchPoints.length)\r
             throw new IllegalArgumentException("Incompatible branch points.");\r
         for(int i=0;i<branchPoints.length;++i) {\r
             BranchPoint oldBP = oldBranchPoints[i];\r
             BranchPoint newBP = branchPoints[i];\r
-            if(oldBP.location != newBP.location)\r
+            if(oldBP.getLocation() != newBP.getLocation())\r
                 throw new IllegalArgumentException("Incompatible branch points.");\r
-            oldBP.visitCounter += newBP.visitCounter;\r
-            combineCounters(oldBP.children, newBP.children);\r
+            oldBP.incrementVisitCounter(newBP.getVisitCounter());\r
+            combineCounters(oldBP.getChildren(), newBP.getChildren());\r
         }\r
     }\r
     \r
index a70651cb75fa7e551cb9bd35cf022a0b98d26a88..59eb2abea2596d17bf0472121da80a59e3d8170d 100644 (file)
@@ -20,7 +20,7 @@ public class CoverageUtils {
             int totalFunctionCodeSize = 0;\r
             int uncoveredFunctionCodeSize = 0;\r
             for(BranchPoint branchPoint : entry.getValue()) {\r
-                totalFunctionCodeSize += branchPoint.codeSize;\r
+                totalFunctionCodeSize += branchPoint.getCodeSize();\r
                 uncoveredFunctionCodeSize += uncoveredCodeSize(branchPoint);\r
             }\r
             int coveredFunctionCodeSize = totalFunctionCodeSize - uncoveredFunctionCodeSize;\r
@@ -99,11 +99,11 @@ public class CoverageUtils {
     }\r
 \r
     private static int uncoveredCodeSize(BranchPoint branchPoint) {\r
-        if(branchPoint.visitCounter == 0)\r
-            return branchPoint.codeSize;\r
+        if(branchPoint.getVisitCounter() == 0)\r
+            return branchPoint.getCodeSize();\r
         else {\r
             int sum = 0;\r
-            for(BranchPoint child : branchPoint.children)\r
+            for(BranchPoint child : branchPoint.getChildren())\r
                 sum += uncoveredCodeSize(child);\r
             return sum;\r
         }\r
index 286d0f910868c883ecc2adfb9884ca2a51df6889..b6bc9012408bc4ee4353b8859646b0b1879e3453 100644 (file)
@@ -282,8 +282,8 @@ public class ModuleRegressionTests extends TestBase {
         for(BranchPoint bp : branchPoints) {
             for(int i=0;i<ind;++i)
                 System.out.print("    ");
-            System.out.println(bp.codeSize);
-            printCoverageTree(bp.children, ind+1);
+            System.out.println(bp.getCodeSize());
+            printCoverageTree(bp.getChildren(), ind+1);
         }
     }
 
index 77b8f80ef7f99abf25fd83062c17331b9d60b26c..6b6d12fe49f7d658706a7fdc88d5d3ff6a59b1a5 100644 (file)
@@ -3,9 +3,9 @@ package org.simantics.scl.runtime.profiling;
 public class BranchPoint {
     public static final BranchPoint[] EMPTY_ARRAY = new BranchPoint[0];
     
-    public final long location;
-    public final int codeSize;
-    public final BranchPoint[] children;
+    private final long location;
+    private final int codeSize;
+    private final BranchPoint[] children;
     
     public int visitCounter;
 
@@ -17,7 +17,38 @@ public class BranchPoint {
     
     public void resetVisitCountersRecursively() {
         visitCounter = 0;
-        for(BranchPoint branchPoint : children)
+        for(BranchPoint branchPoint : getChildren())
             branchPoint.resetVisitCountersRecursively();
     }
+
+    public long getLocation() {
+        return location;
+    }
+
+    public int getCodeSize() {
+        return codeSize;
+    }
+    
+    public int getVisitCounter() {
+        return visitCounter;
+    }
+
+    public void incrementVisitCounter(int amount) {
+        visitCounter = visitCounter + amount;
+    }
+
+    public BranchPoint[] getChildren() {
+        return children;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append("BP[visitCounter=").append(visitCounter).append(", codeSize=").append(codeSize).append(", location=").append(location);
+        if (children.length > 0)
+            sb.append(", children=").append(children.length);
+        sb.append("]");
+        return sb.toString();
+    }
+
 }
index 67a8101cf7a87ff7e0a8e9d8e2b68bde52279bef..d75f1e47672941e9f81eaabf8f7efd8b8d8833d6 100644 (file)
@@ -353,7 +353,7 @@ public class SimanticsWorkbenchAdvisor extends WorkbenchAdvisor {
         try {\r
             platformShutdownRunnable.run(null);\r
         } catch (InvocationTargetException e) {\r
-            Activator.logError(getClass().getSimpleName() + ".openWindows failed", e);\r
+            Activator.logError(getClass().getSimpleName() + ".openWindows failed", e.getCause());\r
         } catch (InterruptedException e) {\r
             Activator.logError(getClass().getSimpleName() + ".openWindows failed", e);\r
         }\r
index 1754b00715bd2b6a6669479174845ee4ccb1d1cb..7e6bd9dd9be5c7c134baff73223061f535ce6e92 100644 (file)
@@ -731,7 +731,17 @@ public class SimanticsPlatform implements LifecycleListener {
         // 1. Assert there is a database at <workspace>/db\r
         session = setupDatabase(databaseDriverId, progressMonitor, workspacePolicy, userAgent);\r
         TimeLogger.log("Database setup complete");\r
-\r
+        \r
+        // 1.1 \r
+        XSupport support = session.getService(XSupport.class);\r
+        if (support.rolledback()) {\r
+            try {\r
+                DatabaseIndexing.deleteAllIndexes();\r
+            } catch (IOException e) {\r
+                throw new PlatformException(e);\r
+            }\r
+        }\r
+        \r
         // 2. Assert all graphs, and correct versions, are installed to the database\r
         synchronizeOntologies(progressMonitor, ontologyPolicy, requireSynchronize);\r
         TimeLogger.log("Synchronized ontologies");\r