]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Merge "(refs #7371) Support expression cloning for ECHRSelect"
authorHannu Niemistö <hannu.niemisto@semantum.fi>
Tue, 1 Aug 2017 14:45:59 +0000 (17:45 +0300)
committerGerrit Code Review <gerrit2@www.simantics.org>
Tue, 1 Aug 2017 14:45:59 +0000 (17:45 +0300)
31 files changed:
bundles/org.simantics.browsing.ui.model/adapters.xml
bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/HasURITest.java [new file with mode: 0644]
bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/InDevelopmentModeTest.java [new file with mode: 0644]
bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tooltips/DescriptionTooltipRule.java
bundles/org.simantics.db.impl/src/org/simantics/db/impl/ForEachObjectContextProcedure.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/genericrelation/DependenciesRelation.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ConsistsOfProcess.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DomainProcessor3.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/ModelTransferableGraphSource.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/Subgraphs.java
bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/TGRepresentationUtils.java
bundles/org.simantics.db.procore/src/fi/vtt/simantics/procore/internal/QuerySupportImpl.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/IntHash.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ObjectTable.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ResourceElementSmall.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/ResourceTable.java
bundles/org.simantics.db.procore/src/org/simantics/db/procore/cluster/TableIntArraySet.java
bundles/org.simantics.db/src/org/simantics/db/procedure/AsyncContextMultiProcedure.java
bundles/org.simantics.graph/src/org/simantics/graph/representation/PrettyPrintTG.java
bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphQueries.java [new file with mode: 0644]
bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphUtils.java
bundles/org.simantics.modeling.ontology/graph/ModelingViewpoint.pgraph
bundles/org.simantics.modeling/adapters.xml
bundles/org.simantics.modeling/src/org/simantics/modeling/actions/CopyURI.java [new file with mode: 0644]
bundles/org.simantics.tests.modelled.ui.ontology/graph/TestsUI.pgraph
bundles/org.simantics.tests.modelled.ui/scl/Simantics/TestsUI.scl
bundles/org.simantics.tests.modelled.ui/src/org/simantics/tests/modelled/ui/TestsUIUtils.java
bundles/org.simantics.tests.modelled/src/org/simantics/tests/modelled/utils/ModelledSTSTest.java
bundles/org.simantics.viewpoint.ontology/graph/ViewpointTests.pgraph
releng/doc/release.html
releng/doc/release.md

index 50b34347957672a684adf7fb9a5c3c3cc1807964..4276f3febe14de63daf3c8663ab4c7c87a721a17 100644 (file)
             class="org.simantics.browsing.ui.model.tests.FailTest"
             constructor="get">
         </type>
+        <type uri="http://www.simantics.org/Viewpoint-0.0/HasURITest"
+            class="org.simantics.browsing.ui.model.tests.HasURITest"
+            constructor="get">
+        </type>
+        <type uri="http://www.simantics.org/Viewpoint-0.0/InDevelopmentModeTest"
+            class="org.simantics.browsing.ui.model.tests.InDevelopmentModeTest"
+            constructor="get">
+        </type>
     </target>
     
     <target interface="org.simantics.browsing.ui.model.actions.IActionCategory">
diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/HasURITest.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/HasURITest.java
new file mode 100644 (file)
index 0000000..3443625
--- /dev/null
@@ -0,0 +1,51 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.browsing.ui.model.tests;
+
+import org.simantics.db.ReadGraph;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.exception.InvalidVariableException;
+import org.simantics.db.layer0.variable.Variable;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.30.0
+ */
+public enum HasURITest implements Test {
+    INSTANCE;
+
+    public static HasURITest get() {
+        return INSTANCE;
+    }
+
+    @Override
+    public boolean isCompatible(Class<?> contentType) {
+        return contentType.equals(Resource.class) || contentType.equals(Variable.class);
+    }
+
+    @Override
+    public boolean test(ReadGraph graph, Object content) throws DatabaseException {
+        if (content instanceof Resource) {
+            return graph.getPossibleURI((Resource) content) != null;
+        } else if (content instanceof Variable) {
+            try {
+                Variable v = (Variable) content;
+                return v.getURI(graph) != null;
+            } catch (InvalidVariableException e) {
+                return false;
+            }
+        }
+        return false;
+    }
+
+}
diff --git a/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/InDevelopmentModeTest.java b/bundles/org.simantics.browsing.ui.model/src/org/simantics/browsing/ui/model/tests/InDevelopmentModeTest.java
new file mode 100644 (file)
index 0000000..fa85e25
--- /dev/null
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.browsing.ui.model.tests;
+
+import org.eclipse.core.runtime.Platform;
+import org.simantics.db.ReadGraph;
+import org.simantics.db.exception.DatabaseException;
+
+/**
+ * @author Tuukka Lehtonen
+ * @since 1.30.0
+ */
+public enum InDevelopmentModeTest implements Test {
+    INSTANCE;
+
+    public static InDevelopmentModeTest get() {
+        return INSTANCE;
+    }
+
+    @Override
+    public boolean isCompatible(Class<?> contentType) {
+        return true;
+    }
+
+    @Override
+    public boolean test(ReadGraph graph, Object content) throws DatabaseException {
+        return Platform.inDevelopmentMode();
+    }
+
+}
index 7bef8e22c127bf00946f7c35f92c8c3f48bcb403..a9ebb9dfcbe26e2aa4e9ba1ff16d46be1ddb9699 100644 (file)
@@ -18,9 +18,9 @@ import org.simantics.db.layer0.variable.Variable;
 import org.simantics.layer0.Layer0;
 
 public class DescriptionTooltipRule implements TooltipRule {
-    
+
     public static final DescriptionTooltipRule INSTANCE = new DescriptionTooltipRule();
-    
+
     public DescriptionTooltipRule() {
     }
 
@@ -58,28 +58,26 @@ public class DescriptionTooltipRule implements TooltipRule {
     public boolean isCompatible(Class<?> contentType) {
         return (contentType == Resource.class || contentType == Variable.class);
     }
-    
+
     private static String getToolTipContent(ReadGraph graph, NodeContext nodeContext) throws DatabaseException {
         Object input = nodeContext.getConstant(BuiltinKeys.INPUT);
-        String content = null;
         if (input instanceof Variable) {
             Variable var = (Variable) input;
-            Resource res = var.getPredicateResource(graph);
-            Layer0 L0 = Layer0.getInstance(graph);
-            String description = graph.getPossibleRelatedValue2(res, L0.HasDescription);
-            return description;
+            Resource res = var.getPossiblePredicateResource(graph);
+            if (res != null) {
+                Layer0 L0 = Layer0.getInstance(graph);
+                return graph.getPossibleRelatedValue2(res, L0.HasDescription);
+            }
         } else if (input instanceof Resource) {
             Resource res = (Resource) input;
-
             Layer0 L0 = Layer0.getInstance(graph);
-            String description = graph.getPossibleRelatedValue2(res, L0.HasDescription);
-            return description;
+            return graph.getPossibleRelatedValue2(res, L0.HasDescription);
         }
-        return content;
+        return null;
     }
 
     @Override
-    public boolean shouldCreateToolTip(ReadGraph graph  , NodeContext context, Map<Object, Object> auxiliary) throws DatabaseException {
+    public boolean shouldCreateToolTip(ReadGraph graph, NodeContext context, Map<Object, Object> auxiliary) throws DatabaseException {
         String content = getToolTipContent(graph, context);
         if (content == null || content.isEmpty())
             return false;
index 07d385235cfc7d32ccc633e95b66c4f14db8aeda..188917994a26881ccafe58a313ac6cb4559c2a67 100644 (file)
@@ -32,8 +32,8 @@ public final class ForEachObjectContextProcedure<C> implements AsyncContextMulti
        }
 
        @Override
-       public void finished(AsyncReadGraph graph) {
-               user.finished(graph);
+       public void finished(AsyncReadGraph graph, C context) {
+               user.finished(graph, context);
        }
 
        @Override
index 9ec12047c6c501a0dc2a58a836c3f69d073a10fe..4162f91636d0b39dfb193d7bb93c076e9885b849 100644 (file)
@@ -145,7 +145,7 @@ public class DependenciesRelation extends UnsupportedRelation implements Generic
                                }
 
                                @Override
-                               public void finished(AsyncReadGraph graph) {
+                               public void finished(AsyncReadGraph graph, Resource parent) {
                                }
 
                                @Override
index d910f13ff946a77e40d9b2dce830c2020c678f40..a2e64868f7c21d43c1456c4662810c20f6ca4ed6 100644 (file)
@@ -2,6 +2,7 @@ package org.simantics.db.layer0.util;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -17,22 +18,25 @@ import org.simantics.db.procedure.AsyncContextMultiProcedure;
 import org.simantics.db.procedure.Procedure;
 import org.simantics.db.service.DirectQuerySupport;
 import org.simantics.layer0.Layer0;
+import org.simantics.utils.datastructures.Pair;
 
 class ConsistsOfProcess {
 
        final List<InternalEntry> result;
+       final Set<Resource> childrenWithNoName;
        final AsyncContextMultiProcedure<InternalEntry, Resource> structure;
        final AsyncContextMultiProcedure<InternalEntry, Resource> names;
 
-    public static List<InternalEntry> walk(ReadGraph graph, ResourceMap<ExtentStatus> status, Collection<Resource> resources, Set<Resource> exclusions, boolean ignoreVirtual) throws DatabaseException {
+       public static Pair<List<InternalEntry>,Set<Resource>> walk(ReadGraph graph, ResourceMap<ExtentStatus> status, Collection<Resource> resources, Set<Resource> exclusions, boolean ignoreVirtual) throws DatabaseException {
        ConsistsOfProcess process = new ConsistsOfProcess(graph, status, resources, exclusions, ignoreVirtual);
-       return process.result;
+       return Pair.make(process.result, process.childrenWithNoName);
     }
     
     static class InternalEntry {
        public InternalEntry parent;
        public Resource resource;
        public String name;
+       public boolean valid = true;
        InternalEntry(InternalEntry parent, Resource resource, String name) {
                this.parent = parent;
                this.resource = resource;
@@ -46,7 +50,7 @@ class ConsistsOfProcess {
                final DirectQuerySupport dqs = graph.getService(DirectQuerySupport.class);
                
                result = new ArrayList<InternalEntry>();
-               
+               childrenWithNoName = new HashSet<>();
                names = dqs.compileForEachObject(graph, L0.HasName, new AsyncContextMultiProcedure<InternalEntry, Resource>() {
 
                        @Override
@@ -58,8 +62,16 @@ class ConsistsOfProcess {
                                graph.forPossibleValue(nameResource, new Procedure<String>() {
 
                                        @Override
-                                       public void execute(String result) {
-                                               entry.name = result;
+                                       public void execute(String name) {
+                                           if(!entry.valid) return;
+                                           
+                                           if(name == null) {
+                                               entry.valid = false;
+                                           } else if (entry.name != null) {
+                                               entry.valid = false;
+                                           } else {
+                                               entry.name = name;
+                                           }
                                        }
 
                                        @Override
@@ -76,9 +88,19 @@ class ConsistsOfProcess {
                        }
 
                        @Override
-                       public void finished(AsyncReadGraph graph) {
+                       public void finished(AsyncReadGraph graph, InternalEntry entry) {
+                           if(entry.valid) {
+                               if(entry.name != null) {
+                                   result.add(entry);
+                               } else {
+                                   // This one did not have a name - not a valid internal
+                                   childrenWithNoName.add(entry.resource);
+                               }
+                           } else {
+                               // Something wrong has happened. Do not treat as valid internal
+                               childrenWithNoName.add(entry.resource);
+                           }
                        }
-
                });
                
                structure = dqs.compileForEachObject(graph, L0.ConsistsOf, new AsyncContextMultiProcedure<InternalEntry, Resource>() {
@@ -90,16 +112,14 @@ class ConsistsOfProcess {
                                
                                if(!ignoreVirtual || child.isPersistent()) {
                                        InternalEntry entry = new InternalEntry(parent, child, null);
-                                       if(result.add(entry)) {
-                                               dqs.forEachObjectCompiled(graph, child, entry, structure);
-                                               dqs.forEachObjectCompiled(graph, child, entry, names);
-                                       }
+                                       dqs.forEachObjectCompiled(graph, child, entry, structure);
+                                       dqs.forEachObjectCompiled(graph, child, entry, names);
                                }
                                
                        }
 
                        @Override
-                       public void finished(AsyncReadGraph graph) {
+                       public void finished(AsyncReadGraph graph, InternalEntry parent) {
                        }
 
                        @Override
index bd67680db6704f73bbe3a73d69aaa7774f8d3b5f..7a0a5f06bee35eb5c4eebf87691dd8e8bdf97c3a 100644 (file)
@@ -34,6 +34,7 @@ import org.simantics.db.service.TransferableGraphSupport;
 import org.simantics.graph.db.TransferableGraphSource;
 import org.simantics.layer0.Layer0;
 import org.simantics.scl.runtime.function.Function1;
+import org.simantics.utils.datastructures.Pair;
 
 import gnu.trove.list.array.TIntArrayList;
 import gnu.trove.map.hash.TIntIntHashMap;
@@ -504,7 +505,8 @@ public class DomainProcessor3 {
             this.datatypeBinding = Bindings.getBindingUnchecked(Datatype.class);
             this.datatypeSerializer = graph.getService(Databoard.class).getSerializerUnchecked(this.datatypeBinding);
 
-            state.internalEntries = ConsistsOfProcess.walk(graph, status, fringe, exclusions, ignoreVirtual); 
+            Pair<List<InternalEntry>,Set<Resource>> pair = ConsistsOfProcess.walk(graph, status, fringe, exclusions, ignoreVirtual); 
+            state.internalEntries = pair.first;
             
             for(InternalEntry entry : state.internalEntries) {
                Resource r = entry.resource;
@@ -518,6 +520,12 @@ public class DomainProcessor3 {
                 }
             }
 
+            for(Resource unnamedChild : pair.second) {
+                if (status.put(unnamedChild, ExtentStatus.INTERNAL) == null) {
+                    fringe.add(unnamedChild);
+                }
+            }
+            
             if (state.monitor.isCanceled())
                 throw new CancelTransactionException();
 
index f0a0893eb447d40455835d39fdd41cc40d6e3c5f..1d3cf61f54c6c6ad296b06a959f62dac66601537 100644 (file)
@@ -416,8 +416,12 @@ public class ModelTransferableGraphSource implements TransferableGraphSource {
                
                if(state.internalEntries != null) {
                        for(InternalEntry ie : state.internalEntries) {
-                               if(ie.parent != null && ie.name != null) {
-                                       procedure.execute(resolveInternal(graph, support, ie, internalMap));
+                           if(ie.parent != null) {
+                               if(ie.name != null) {
+                                   procedure.execute(resolveInternal(graph, support, ie, internalMap));
+                           } else {
+                               // In this case there is a child that has no HasName => this should be treated as a blank
+                               }
                                } else {
                                        throw new DatabaseException("Invalid internal entry " + ie);
                                }
index c7e697e6291773b58e44d8bd3a8c2afbf0952442..518efc882e45964dafb612ced7068636972a6f6b 100644 (file)
@@ -991,7 +991,8 @@ public class Subgraphs {
              * � All o are internal
              * � All stm are included
                         */
-                       List<InternalEntry> entries = ConsistsOfProcess.walk(graph, null, fringe, exclusions, true); 
+                       Pair<List<InternalEntry>,Set<Resource>> pair = ConsistsOfProcess.walk(graph, null, fringe, exclusions, true);
+                       List<InternalEntry> entries = pair.first;
                        for(InternalEntry entry : entries) {
                                Resource r = entry.resource;
                                if (status.put(r, ExtentStatus.INTERNAL) == null) {
@@ -1003,6 +1004,12 @@ public class Subgraphs {
                                }
                        }
                        
+                       for(Resource unnamedChild : pair.second) {
+                           if (status.put(unnamedChild, ExtentStatus.INTERNAL) == null) {
+                               fringe.add(unnamedChild);
+                           }
+                       }
+                       
                        /*
                         * This loop resolves the transitive closure of all p < IsRelatedTo such that p does not contain the SharedRange tag.
                         * Such resources are guaranteed to be internal.
index ffa39974315a1a06b50c57aada1816ae2677130e..0bd71af863fa4330b94b01969aff6e736c7c46b4 100644 (file)
@@ -14,6 +14,7 @@ package org.simantics.db.layer0.util;
 import java.util.Collections;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.simantics.datatypes.literal.GUID;
 import org.simantics.db.ReadGraph;
@@ -26,6 +27,7 @@ import org.simantics.db.layer0.util.ConsistsOfProcess.InternalEntry;
 import org.simantics.db.layer0.util.DomainProcessor3.ExclusionDecision;
 import org.simantics.layer0.Layer0;
 import org.simantics.scl.runtime.function.Function1;
+import org.simantics.utils.datastructures.Pair;
 
 /**
  * @author Antti Villberg
@@ -63,7 +65,8 @@ public class TGRepresentationUtils {
                         return new GUIDExclusionFunction(graph);
 
                     // The root is OK - check everything beneath
-                    List<InternalEntry> entries = ConsistsOfProcess.walk(graph, null, Collections.singleton(r), Collections.emptySet(), true); 
+                    Pair<List<InternalEntry>,Set<Resource>> pair = ConsistsOfProcess.walk(graph, null, Collections.singleton(r), Collections.emptySet(), true); 
+                    List<InternalEntry> entries = pair.first;
                     for(InternalEntry entry : entries) {
                         if(findByIdentifier(graph, targetRoot, entry.resource))
                             return new GUIDExclusionFunction(graph);
index ea1c779faff615a3fdd256d69c8f95d8dcbb132d..1d3563fc1a3b5fca63688dca04a52c4805bdee50 100644 (file)
@@ -306,7 +306,7 @@ public class QuerySupportImpl implements QuerySupport {
                        
                 }
                        }
-                       procedure.finished(graph);
+                       procedure.finished(graph, context);
 //             graph.dec();
                return;
                
index 69450de7c8efc045e6aa6bab583e1c668f5a3507..c0ead5d073744444305acdf0247903c5f2593337 100644 (file)
@@ -304,7 +304,7 @@ public class IntHash extends IntHashTrait {
 
        }
        
-       procedure.finished(graph);
+       procedure.finished(graph, context);
 //     graph.dec();
        assert(size == count);
        
index 42ca6b018dd9348c5309f75e31084838c862ea73..da3b7903e7e270f2f1f6f5885ba12a3900700690 100644 (file)
@@ -167,7 +167,7 @@ public final class ObjectTable extends Table<int[]> {
        if (ClusterTraits.statementIndexIsDirect(objectIndex)) {
                int key = modifier.execute(objectIndex);
             procedure.execute(graph, context, new ResourceImpl(graph.getResourceSupport(), key));
-               procedure.finished(graph);
+               procedure.finished(graph, context);
 //             graph.dec();
             return;
         }
index 23d15dcfdb13fe6a10a7af104a5537fb18079d22..90519a36c3f6cb5916c7429c5af8e8ca41414deb 100644 (file)
@@ -477,7 +477,7 @@ public final class ResourceElementSmall {
         if (ClusterI.CompleteTypeEnum.NotComplete != pCompleteType) {
             int completeRef = getCompleteObjectRef(table, index);
             if (0 == completeRef) {
-                procedure.finished(graph);
+                procedure.finished(graph, context);
 //                graph.state.dec(0);
                 return; // no objects for given complete type
             }
@@ -496,19 +496,19 @@ public final class ResourceElementSmall {
             } else { // One complete type element. CompleteRef is resource reference.
                 ClusterI.CompleteTypeEnum rCompleteType = ResourceElementSmall.getCompleteType(table, index);
                 if (pCompleteType != rCompleteType) {
-                    procedure.finished(graph);
+                    procedure.finished(graph, context);
 //                    graph.state.dec(0);
                     return; // Complete predicate does not match.
                 }
                 procedure.execute(graph, context, new ResourceImpl(graph.getResourceSupport(), modifier.execute(completeRef)));
             }
-            procedure.finished(graph);
+            procedure.finished(graph, context);
 //            graph.state.dec(0);
             return; // loop finished
         }
         short p1 = getStm1Predicate(table, index);
         if (0 == p1) {
-            procedure.finished(graph);
+            procedure.finished(graph, context);
 //            graph.state.dec(0);
             return; // loop finished, no statements
         }
@@ -525,7 +525,7 @@ public final class ResourceElementSmall {
         }
         short p2 = getStm2Predicate(table, index);
         if (0 == p2 || pRef != p2) {
-            procedure.finished(graph);
+            procedure.finished(graph, context);
 //            graph.state.dec(0);
             return; // loop finished, one statements
         }
@@ -539,7 +539,7 @@ public final class ResourceElementSmall {
 //            return true; // loop broken by procedure
 //        return false; // loop finished
         procedure.execute(graph, context, new ResourceImpl(graph.getResourceSupport(), modifier.execute(o2)));
-        procedure.finished(graph);
+        procedure.finished(graph, context);
 //        graph.state.dec(0);
     }
 
index 84090af415e944ce757687706c2b7f67d646f71d..e997b731870159486a38cfebab9a2b7eb64f7c36 100644 (file)
@@ -514,7 +514,7 @@ final class ResourceElement {
         if (ClusterI.CompleteTypeEnum.NotComplete != pCompleteType) {
             int completeRef = getCompleteObjectRef(table, index);
             if (0 == completeRef) {
-                       procedure.finished(graph);
+                       procedure.finished(graph, context);
 //                     graph.state.dec(0);
                 return; // no objects for given complete type
             }
@@ -543,14 +543,14 @@ final class ResourceElement {
                 ForeachObject t = new ForeachObject();
                 // CompleteRef is complete object set index.
                 ct.foreachComplete(completeRef, t, null, support, modifier);
-                procedure.finished(graph);
+                procedure.finished(graph, context);
 //                graph.state.dec(0);
                 return; // loop finished
             }
             // one complete type element
             ClusterI.CompleteTypeEnum completeType = ClusterTraits.completeReferenceGetType(completeRef);
             if (pCompleteType != completeType) {
-                       procedure.finished(graph);
+                       procedure.finished(graph, context);
 //                     graph.state.dec(0);
                 return;
             }
@@ -562,7 +562,7 @@ final class ResourceElement {
                 int externalRef = ClusterTraits.createForeignReference(clusterIndex, resourceIndex);
                 procedure.execute(graph, context, new ResourceImpl(graph.getResourceSupport(), modifier.execute(externalRef)));
             }
-               procedure.finished(graph);
+               procedure.finished(graph, context);
 //             graph.state.dec(0);
             return; // loop finished
         }
@@ -570,7 +570,7 @@ final class ResourceElement {
         long l = table[i];
         int p1 = (int) (l >>> 32);
         if (0 == p1) {
-               procedure.finished(graph);
+               procedure.finished(graph, context);
 //             graph.state.dec(0);
             return; // loop finished, no statements
         }
@@ -588,13 +588,13 @@ final class ResourceElement {
         long l2 = table[++i];
         int p2 = (int) (l2 >>> 32);
         if (pRef != p2) {
-               procedure.finished(graph);
+               procedure.finished(graph, context);
 //             graph.state.dec(0);
             return; // loop finished, one statements
         }
         int o2 = (int)l2;
         procedure.execute(graph, context, new ResourceImpl(graph.getResourceSupport(), modifier.execute(o2)));
-               procedure.finished(graph);
+               procedure.finished(graph, context);
 //             graph.state.dec(0);
     }
     
index df5920c47b611463a08025aa9428c678666abf1d..2c57f3627323ebdfcb88d050df524c32fd09fcf3 100644 (file)
@@ -184,7 +184,7 @@ final class TableIntArraySet {
             
         }
         
-               procedure.finished(graph);
+               procedure.finished(graph, context);
 //             graph.state.dec(0);
         
     }
index 875ee37abe6dab1cb37e4a6e0568e2c883630bd1..c393d32dad8dc5d9753e8c02f32df2fe8755c687 100644 (file)
@@ -43,7 +43,7 @@ public interface AsyncContextMultiProcedure<Context, Result> {
      * 
      * @param graph asynchronous graph access
      */
-    void finished(AsyncReadGraph graph);
+    void finished(AsyncReadGraph graph, Context context);
 
     /**
      * If an error occurs in the processing of the database request that
index 2d4171e1ce8855f097999eb033b77db3d158de2e..cb06d6addd1604bb13070f5249428816d120bf73 100644 (file)
@@ -11,7 +11,6 @@ import java.nio.file.Paths;
 import java.security.MessageDigest;
 import java.security.NoSuchAlgorithmException;
 import java.util.ArrayList;
-import java.util.Arrays;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
@@ -64,6 +63,8 @@ public class PrettyPrintTG {
 
     private boolean ignoreIdentifiers;
 
+    private TransferableGraphQueries query;
+
     static class ResourceInfo {
         final boolean hasURI;
         String name;
@@ -104,43 +105,51 @@ public class PrettyPrintTG {
         }
     }
 
-    public PrettyPrintTG(StringBuilder b, boolean ignoreIdentifiers) throws NoSuchAlgorithmException {
+    public PrettyPrintTG(TransferableGraph1 tg, StringBuilder b, boolean ignoreIdentifiers) throws NoSuchAlgorithmException {
         output = b;
         m = MessageDigest.getInstance("SHA-256");
         this.ignoreIdentifiers = ignoreIdentifiers;
+        
+        this.query = new TransferableGraphQueries(tg);
     }
 
-    public PrettyPrintTG() throws NoSuchAlgorithmException {
-        this(new StringBuilder(), false);
+    public PrettyPrintTG(TransferableGraph1 tg) throws NoSuchAlgorithmException {
+        this(tg, new StringBuilder(), false);
     }
 
     TreeMap<String, ResourceInfo> orderedInfos = new TreeMap<>();
     TIntObjectHashMap<ResourceInfo> infos = new TIntObjectHashMap<>();
 
-    String tgNodeName(String name) {
+    private static String tgNodeName(String name) {
         if (name.contains(" "))
             return "\"" + name + "\"";
         else
             return name;
     }
 
-    ResourceInfo recurseURI(TransferableGraph1 graph, Identity parent, String parentName, int parentId) {
-        String name = parentName + "." + tgNodeName(TransferableGraphUtils.getName(parent));
-        ResourceInfo info = new ResourceInfo(true, name, parent.resource, parentId);
-        orderedInfos.put(name, info);
-        // infos.put(parent.resource, info);
-        for (Identity child : TransferableGraphUtils.getChildren(graph, parent)) {
-            recurseURI(graph, child, name, info.resource);
-        }
+    private ResourceInfo recurseURI(Map<String, ResourceInfo> infos, Identity identity, String parentName, int parentId) {
+        String name = parentName + "." + tgNodeName(TransferableGraphUtils.getName(identity));
+        int identityResource = identity.resource;
+        ResourceInfo info = new ResourceInfo(true, name, identityResource, parentId);
+        infos.put(name, info);
+        for (Identity child : query.getChildren(identity))
+            recurseURI(infos, child, name, identityResource);
         return info;
     }
 
-    private TreeMap<String, TreeSet<Integer>> sortByPredicateUniqueStatements(TransferableGraph1 graph, int resource) {
+    /**
+     * Sorts statements by predicateURI in natural order
+     * 
+     * @param graph
+     * @param resource
+     * @return
+     */
+    private TreeMap<String, TreeSet<Integer>> sortByPredicateUniqueStatements(int resource) {
         TreeMap<String, TreeSet<Integer>> results = new TreeMap<>();
-        TIntArrayList statements = TransferableGraphUtils.getStatements(graph, resource);
+        TIntArrayList statements = query.getStatements(resource);
         for (int i = 0; i < statements.size(); i += 2) {
             int predicate = statements.get(i);
-            String predicateURI = TransferableGraphUtils.getURI(graph, predicate);
+            String predicateURI = query.getURI(predicate);
             TreeSet<Integer> objects = results.get(predicateURI);
             if (objects == null) {
                 objects = new TreeSet<>();
@@ -151,32 +160,32 @@ public class PrettyPrintTG {
         return results;
     }
 
-    void discoverBlank(TransferableGraph1 graph, int resource, TIntArrayList todo) throws Exception {
+    void discoverBlank(int resource, TIntArrayList todo) throws Exception {
         // TIntArrayList statements =
         // TransferableGraphUtils.getStatements(graph, resource);
         // for(int i=0;i<statements.size();i+=2) {
-        for (TreeSet<Integer> objects : sortByPredicateUniqueStatements(graph, resource).values()) {
+        for (TreeSet<Integer> objects : sortByPredicateUniqueStatements(resource).values()) {
             for (int object : objects) {
                 // int object = statements.get(i+1);
-                Identity objectId = TransferableGraphUtils.getIdentity(graph, object);
+                Identity objectId = query.getIdentity(object);
                 if (objectId != null) {
                     if (objectId.definition instanceof External)
                         continue;
                 }
-                Value value = TransferableGraphUtils.findValue(graph, object);
+                Value value = query.findValue(object);
                 if (value != null) {
                     infos.put(object, new ResourceInfo(false, printValue(value), object, resource));
-                    continue;
-                }
-                ResourceInfo existing = infos.get(object);
-                if (existing == null) {
-
-                    existing = new ResourceInfo(false, "blank" + blankCounter++, object, resource);
-
-                    // System.out.println("created blank" + blankCounter + "
-                    // with object " + object + " resource " + resource);
-                    infos.put(object, existing);
-                    todo.add(object);
+                } else {
+                    ResourceInfo existing = infos.get(object);
+                    if (existing == null) {
+    
+                        existing = new ResourceInfo(false, "blank" + blankCounter++, object, resource);
+    
+                        // System.out.println("created blank" + blankCounter + "
+                        // with object " + object + " resource " + resource);
+                        infos.put(object, existing);
+                        todo.add(object);
+                    }
                 }
             }
         }
@@ -188,10 +197,10 @@ public class PrettyPrintTG {
         return new BigInteger(1, m.digest()).toString(16);
     }
 
-    void discoverOwners(TransferableGraph1 graph, ResourceInfo info) {
+    void discoverOwners(ResourceInfo info) {
         log("Discovering owners for {}", info);
         int resource = info.resource;
-        TIntArrayList statements = TransferableGraphUtils.getStatements(graph, resource);
+        TIntArrayList statements = query.getStatements(resource);
         for (int i = 0; i < statements.size(); i += 2) {
             int predicate = statements.get(i);
             int object = statements.get(i + 1);
@@ -201,7 +210,7 @@ public class PrettyPrintTG {
 
                 // Check if predicate is inverse, this just resolves all
                 // predicates to be inverse with ending "Inverse"..
-                String predicateUri = rewritePredicateURI(graph, predicate);
+                String predicateUri = rewritePredicateURI(predicate);
                 if (!predicateUri.endsWith("Inverse") && !predicateUri.endsWith("Of")) {
                     existing.ownedResourcesWithPredicates.put(resource, predicate);
                     // if (predicateUri.endsWith("Of")) {
@@ -241,7 +250,7 @@ public class PrettyPrintTG {
         }
     }
 
-    public static String getExternalURI(TransferableGraph1 tg, External ext) {
+    public String getExternalURI(External ext) {
         String name = ext.name;
         if (name.contains(" "))
             name = name.replace(" ", "_").replaceAll("@", "_");// name = "\"" +
@@ -249,9 +258,9 @@ public class PrettyPrintTG {
         int parentId = ext.parent;
         // if(parentId == 0) return ext.name;
         // else {
-        Identity id = TransferableGraphUtils.getIdentity(tg, parentId);
+        Identity id = query.getIdentity(parentId);
         if (id.definition instanceof External) {
-            return getExternalURI(tg, (External) id.definition) + "/" + name;
+            return getExternalURI((External) id.definition) + "/" + name;
         } else if (id.definition instanceof Root) {
             Root root = (Root) id.definition;
             return "http:/" + root.name + "/" + name;
@@ -261,20 +270,20 @@ public class PrettyPrintTG {
         // }
     }
 
-    public static String getExternalURI(TransferableGraph1 tg, int resource) {
-        Identity id = TransferableGraphUtils.getIdentity(tg, resource);
+    public String getExternalURI(int resource) {
+        Identity id = query.getIdentity(resource);
         if (id == null)
             return null;
         if (id.definition instanceof External) {
             External ext = (External) id.definition;
-            return getExternalURI(tg, ext);
+            return getExternalURI(ext);
         }
         return null;
     }
 
-    String rewritePredicateURI(TransferableGraph1 graph, int predicate) {
+    String rewritePredicateURI(int predicate) {
 
-        String uri = getExternalURI(graph, predicate);
+        String uri = getExternalURI(predicate);
         if (uri == null) {
             ResourceInfo info = infos.get(predicate);
             if (info != null)
@@ -301,7 +310,7 @@ public class PrettyPrintTG {
             output.append("  ");
     }
 
-    String printBlank(TransferableGraph1 graph, String predicateURI2, ResourceInfo info, int indent) {
+    String printBlank(String predicateURI2, ResourceInfo info, int indent) {
 
         if (info.hasURI)
             return null;
@@ -328,7 +337,7 @@ public class PrettyPrintTG {
         if (info.ownedResourcesWithPredicates.isEmpty()) {
             if (DEBUG)
                 System.out.print("printBlank");
-            String uri = printURI(graph, info, false, indent, false);
+            String uri = printURI(info, false, indent, false);
             if (uri != null)
                 output.append(uri);
         }
@@ -354,14 +363,14 @@ public class PrettyPrintTG {
         return ((predicate & 0xffffffffL) << 32) | (object & 0xffffffffL);
     }
 
-    private void addInlineStatement(TransferableGraph1 graph, Map<String, Set<String>> statements, String predicate,
+    private void addInlineStatement(Map<String, Set<String>> statements, String predicate,
             ResourceInfo objectInfo, int indent) {
         Set<String> objects = statements.get(predicate);
         if (objects == null) {
             objects = new TreeSet<>();
             statements.put(predicate, objects);
         }
-        String uri = printURI(graph, objectInfo, false, indent + 1, true);
+        String uri = printURI(objectInfo, false, indent + 1, true);
         if (uri != null) {
             // TODO: this is not the right place to remove trailing newline
             uri = uri.endsWith("\n") ? uri.substring(0, uri.length() - 2) : uri;
@@ -382,7 +391,7 @@ public class PrettyPrintTG {
         objects.add(object);
     }
 
-    String printURI(TransferableGraph1 graph, ResourceInfo info, boolean requireURI, int indent, boolean inline) {
+    String printURI(ResourceInfo info, boolean requireURI, int indent, boolean inline) {
 
         if (requireURI && !info.hasURI)
             return null;
@@ -393,8 +402,7 @@ public class PrettyPrintTG {
             return null;
 
         Map<String, Set<String>> statements = new TreeMap<>();
-        Identity consistsOf = TransferableGraphUtils.findExternal(graph,
-                "http://www.simantics.org/Layer0-1.1/ConsistsOf");
+        Identity consistsOf = query.findExternalByURI("http://www.simantics.org/Layer0-1.1/ConsistsOf");
         // Identity partOf = TransferableGraphUtils.findExternal(graph,
         // "http://www.simantics.org/Layer0-1.1/PartOf");
         TLongHashSet processed = new TLongHashSet();
@@ -410,9 +418,9 @@ public class PrettyPrintTG {
             processed.add(stmId);
         }
 
-        TreeMap<String, Integer> predicateURIs = new TreeMap<>();
+        TreeMap<String, List<Integer>> predicateURIs = new TreeMap<>();
 
-        TIntArrayList rawStatements = TransferableGraphUtils.getStatements(graph, info.resource);
+        TIntArrayList rawStatements = query.getStatements(info.resource);
         if (DEBUG)
             System.out.println(
                     "rawStatements size for " + info.name + " : " + rawStatements.size() + " " + rawStatements);
@@ -442,32 +450,38 @@ public class PrettyPrintTG {
                 // indent++;
                 // }
             }
-            String predicateURI = rewritePredicateURI(graph, predicate);
-            predicateURIs.put(predicateURI, object);
+            String predicateURI = rewritePredicateURI(predicate);
+            List<Integer> objects = predicateURIs.get(predicateURI);
+            if (objects == null) {
+                objects = new ArrayList<>();
+                predicateURIs.put(predicateURI, objects);
+            }
+            objects.add(object);
         }
-        for (Entry<String, Integer> entry : predicateURIs.entrySet()) {
+        for (Entry<String, List<Integer>> entry : predicateURIs.entrySet()) {
             String predicateURI = entry.getKey();
-            int object = entry.getValue();
-
-            ResourceInfo objectInfo = infos.get(object);
-            if (objectInfo == null) {
-                String objectURI = rewritePredicateURI(graph, object);
-                if (DEBUG)
-                    System.out.println("  adding statement " + predicateURI + " " + objectURI);
-                addStatement(statements, predicateURI, objectURI);
-            } else if (objectInfo.ownedBy.size() == 1 && objectInfo.ownedBy.contains(info)) {
-                // inline printing with _
-                if (DEBUG)
-                    System.out.println("  adding inline statement " + predicateURI + " " + objectInfo.name);
-                addInlineStatement(graph, statements, predicateURI, objectInfo, indent);
-            } else {
-                String objectName = objectInfo.name;
-                if (objectName.startsWith("blank")) {
-                    objectName = getBlankRewrite(objectName);
+            List<Integer> objects = entry.getValue();
+            for (int object : objects) {
+                ResourceInfo objectInfo = infos.get(object);
+                if (objectInfo == null) {
+                    String objectURI = rewritePredicateURI(object);
+                    if (DEBUG)
+                        System.out.println("  adding statement " + predicateURI + " " + objectURI);
+                    addStatement(statements, predicateURI, objectURI);
+                } else if (objectInfo.ownedBy.size() == 1 && objectInfo.ownedBy.contains(info)) {
+                    // inline printing with _
+                    if (DEBUG)
+                        System.out.println("  adding inline statement " + predicateURI + " " + objectInfo.name);
+                    addInlineStatement(statements, predicateURI, objectInfo, indent);
+                } else {
+                    String objectName = objectInfo.name;
+                    if (objectName.startsWith("blank")) {
+                        objectName = getBlankRewrite(objectName);
+                    }
+                    if (DEBUG)
+                        System.out.println("  adding statement " + predicateURI + " " + objectName);
+                    addStatement(statements, predicateURI, objectName);
                 }
-                if (DEBUG)
-                    System.out.println("  adding statement " + predicateURI + " " + objectName);
-                addStatement(statements, predicateURI, objectName);
             }
         }
 
@@ -547,46 +561,37 @@ public class PrettyPrintTG {
             }
         }
 
-        TreeMap<String, Integer> ownedOrdered = new TreeMap<>();
+        TreeMap<String, Set<Integer>> ownedOrdered = new TreeMap<>();
 
         for (int i = 0; i < info.owned.size(); i += 2) {
-            String predicateURI = rewritePredicateURI(graph, info.owned.get(i));
-            ownedOrdered.put(predicateURI, info.owned.get(i + 1));
+            String predicateURI = rewritePredicateURI(info.owned.get(i));
+            Set<Integer> owneds = ownedOrdered.get(predicateURI);
+            if (owneds == null) {
+                owneds = new TreeSet<>();
+                ownedOrdered.put(predicateURI, owneds);
+            }
+            owneds.add(info.owned.get(i + 1));
         }
 
         if (DEBUG)
             System.out.println(info.name + " : " + ownedOrdered.keySet());
 
-        for (Entry<String, Integer> entry : ownedOrdered.entrySet()) {
+        for (Entry<String, Set<Integer>> entry : ownedOrdered.entrySet()) {
             String predicateURI = entry.getKey();
-            int owned = entry.getValue();
-            ResourceInfo ownedInfo = infos.get(owned);
-
-            String blank = printBlank(graph, predicateURI, ownedInfo, indent + 1);
-            if (blank != null) {
-                output.append(blank);
+            Set<Integer> owneds = entry.getValue();
+            for (int owned : owneds) {
+                ResourceInfo ownedInfo = infos.get(owned);
+    
+                String blank = printBlank(predicateURI, ownedInfo, indent + 1);
+                if (blank != null) {
+                    output.append(blank);
+                }
             }
         }
 
         return output.toString();
     }
 
-    void prettyPrint(Path input, Path output) throws Exception {
-
-        System.out.format("Converting exported shared ontology%n\t" + input.toString()
-                + "%nto bundle-compatible ontology%n\t" + output.toString());
-        try (InputStream is = new BufferedInputStream(Files.newInputStream(input), 128 * 1024)) {
-            DataInput dis = new DataInputStream(is);
-            org.simantics.databoard.container.DataContainer container = DataContainers.readFile(dis);
-            Binding binding = TransferableGraph1.BINDING;
-            TransferableGraph1 graph = (TransferableGraph1) container.content.getValue(binding);
-            prettyPrint(graph);
-            Files.write(output, this.output.toString().getBytes());
-
-        }
-
-    }
-
     static Map<String, String> knownOntologies = new HashMap<>();
 
     static {
@@ -607,26 +612,26 @@ public class PrettyPrintTG {
         knownOntologies.put("http://www.semantum.fi/SimupediaWorkbench-1.0", "SIMUPEDIA_WORKBENCH");
     }
 
-    void prettyPrint(TransferableGraph1 graph) throws Exception {
+    void prettyPrint() throws Exception {
         log("Starting prettyPrint for TransferableGraph with {} resources, {} identities, {} statements and {} values",
-                graph.resourceCount, graph.identities, graph.statements.length, graph.values.length);
+                query.getGraph().resourceCount, query.getGraph().identities, query.getGraph().statements.length, query.getGraph().values.length);
 
-        for (Identity id : graph.identities) {
+        query.forIdentities(id -> {
+            int identityResource = id.resource;
             if (id.definition instanceof Internal) {
                 Internal internal = (Internal) id.definition;
-                Identity parent = TransferableGraphUtils.getIdentity(graph, internal.parent);
-                if (parent.definition instanceof External) {
+                Identity parent = query.getIdentity(internal.parent);
+                if (parent.definition instanceof External || parent.definition instanceof Root) {
                     log("Resolving internal identity {}", id);
                     String name = "BASE";
-                    ResourceInfo info = new ResourceInfo(true, name, id.resource, -1);
-                    info.aliasURI = TransferableGraphUtils.getURI(graph, id.resource);
+                    ResourceInfo info = new ResourceInfo(true, name, identityResource, -1);
+                    info.aliasURI = query.getURI(identityResource);
                     info.newResource = true;
                     orderedInfos.put(name, info);
                     // infos.put(id.resource, info);
                     log("    which parent is external {} and has an aliasURI {}", parent, info.aliasURI);
-                    for (Identity child : TransferableGraphUtils.getChildren(graph, id)) {
-                        recurseURI(graph, child, name, info.resource);
-                    }
+                    for (Identity child : query.getChildren(id))
+                        recurseURI(orderedInfos, child, name, identityResource);
                     log("    and has {} children", infos.size());
                 }
             } else if (id.definition instanceof External) {
@@ -640,7 +645,7 @@ public class PrettyPrintTG {
                     String prefix = ext.name.substring(0, index);
                     int index2 = ext.name.indexOf('/', index);
                     String ontology = index2 == -1 ? ext.name : ext.name.substring(0, index2);
-                    String uri = TransferableGraphUtils.getURI(graph, id.resource);
+                    String uri = query.getURI(identityResource);
 
                     log("    which was resolved as URI={} and prefix={}", uri, prefix);
 
@@ -648,7 +653,7 @@ public class PrettyPrintTG {
 
                 } else if (ext.name.contains("-")) {
                     log("Resolving possible ontology {}", ext);
-                    String uri = TransferableGraphUtils.getURI(graph, id.resource);
+                    String uri = query.getURI(identityResource);
                     Matcher m = versionExtractPattern.matcher(uri);
                     if (m.matches()) {
                         if (!ontologies.containsKey(uri)) {
@@ -660,7 +665,8 @@ public class PrettyPrintTG {
                     }
                 }
             }
-        }
+            return true;
+        });
 
         // Discover other resources
         log("Discovering other resources..");
@@ -675,10 +681,10 @@ public class PrettyPrintTG {
 
         while (!todo.isEmpty()) {
             int resource = todo.removeAt(todo.size() - 1);
-            discoverBlank(graph, resource, todo);
+            discoverBlank(resource, todo);
         }
         for (ResourceInfo info : infos.valueCollection())
-            discoverOwners(graph, info);
+            discoverOwners(info);
         // for(ResourceInfo info : infos.valueCollection())
         // fixInstanceOf(graph, info);
 
@@ -697,12 +703,15 @@ public class PrettyPrintTG {
 
                     @Override
                     public boolean execute(int owner, int predicate) {
+                       
                         ResourceInfo ownerInfo = infos.get(owner);
                         ownerInfo.owned.add(predicate);
                         ownerInfo.owned.add(info.resource);
                         return false;
                     }
                 });
+            } else {
+                System.err.println("Here we are with " + info);
             }
         }
 
@@ -717,21 +726,18 @@ public class PrettyPrintTG {
             }
         }
 
-        Identity routeGraphConn = TransferableGraphUtils.findExternal(graph,
-                "http://www.simantics.org/Diagram-2.2/RouteGraphConnection");
-        Identity instanceOf = TransferableGraphUtils.findExternal(graph,
-                "http://www.simantics.org/Layer0-1.1/InstanceOf");
-        Identity diagramConnetionToConnection = TransferableGraphUtils.findExternal(graph,
-                "http://www.simantics.org/Modeling-1.2/DiagramConnectionToConnection");
+        Identity routeGraphConn = query.findExternalByURI("http://www.simantics.org/Diagram-2.2/RouteGraphConnection");
+        Identity instanceOf = query.findExternalByURI("http://www.simantics.org/Layer0-1.1/InstanceOf");
+        Identity diagramConnetionToConnection = query.findExternalByURI("http://www.simantics.org/Modeling-1.2/DiagramConnectionToConnection");
 
+        Identity elemTo = query.findExternalByURI("http://www.simantics.org/Modeling-1.2/ElementToComponent");
         for (ResourceInfo infoo : infos.valueCollection()) {
-            Identity elemTo = TransferableGraphUtils.findExternal(graph, "http://www.simantics.org/Modeling-1.2/ElementToComponent");
             if (elemTo != null) {
-                int elemToComponent = TransferableGraphUtils.getPossibleObject2(graph, infoo.resource, elemTo);
+                int elemToComponent = query.getPossibleObject(infoo.resource, elemTo);
                 if (elemToComponent != TransferableGraphUtils.NOT_FOUND) {
 
-                    Identity component = TransferableGraphUtils.getIdentity(graph, elemToComponent);
-                    Identity internal = TransferableGraphUtils.getIdentity(graph, infoo.resource);
+                    Identity component = query.getIdentity(elemToComponent);
+                    Identity internal = query.getIdentity(infoo.resource);
                     if (internal.definition instanceof Internal && component.definition instanceof Internal) {
                         Internal iComponent = (Internal) component.definition;
                         infoo.name = infoo.name.substring(0, infoo.name.lastIndexOf(".") + 1) + iComponent.name;
@@ -740,29 +746,29 @@ public class PrettyPrintTG {
             }
 
             if (instanceOf != null) {
-                int instOf = TransferableGraphUtils.getPossibleObject2(graph, infoo.resource, instanceOf);
+                int instOf = query.getPossibleObject( infoo.resource, instanceOf);
                 if (instOf != TransferableGraphUtils.NOT_FOUND && routeGraphConn != null) {
                     if (instOf == routeGraphConn.resource) {
                         // Found routegraphconnection, change name
                         // Lets go to configuration
 
-                        int connection = TransferableGraphUtils.getPossibleObject2(graph, infoo.resource,
+                        int connection = query.getPossibleObject( infoo.resource,
                                 diagramConnetionToConnection);
                         if (connection != TransferableGraphUtils.NOT_FOUND) {
                             // Gather all inverse statements to construct unique
                             // name
                             List<String> nameParts = new ArrayList<>();
-                            TIntArrayList statements = TransferableGraphUtils.getStatements(graph, connection);
+                            TIntArrayList statements = query.getStatements(connection);
                             for (int i = 0; i < statements.size(); i += 2) {
                                 int predicate = statements.get(i);
-                                Identity possibleInverse = TransferableGraphUtils.getIdentity(graph, predicate);
+                                Identity possibleInverse = query.getIdentity(predicate);
                                 if (possibleInverse != null) {
                                     int inverseRelation = TransferableGraphUtils.NOT_FOUND;
                                     int parentId = TransferableGraphUtils.NOT_FOUND;
                                     if (possibleInverse.definition instanceof Internal) {
                                         Internal iPossibleInverse = (Internal) possibleInverse.definition;
                                         if (iPossibleInverse.name.equals("Inverse")) {
-                                            inverseRelation = TransferableGraphUtils.getPossibleObject2(graph,
+                                            inverseRelation = query.getPossibleObject(
                                                     connection, possibleInverse);
                                             parentId = iPossibleInverse.parent;
                                         } else {
@@ -771,7 +777,7 @@ public class PrettyPrintTG {
                                     } else if (possibleInverse.definition instanceof External) {
                                         External ePossibleInverse = (External) possibleInverse.definition;
                                         if (ePossibleInverse.name.equals("Inverse")) {
-                                            inverseRelation = TransferableGraphUtils.getPossibleObject2(graph,
+                                            inverseRelation = query.getPossibleObject(
                                                     connection, possibleInverse);
                                             parentId = ePossibleInverse.parent;
                                         } else {
@@ -782,8 +788,8 @@ public class PrettyPrintTG {
                                     }
                                     if (inverseRelation != TransferableGraphUtils.NOT_FOUND) {
                                         // Ok found something
-                                        Identity object = TransferableGraphUtils.getIdentity(graph, inverseRelation);
-                                        Identity parent = TransferableGraphUtils.getIdentity(graph, parentId);
+                                        Identity object = query.getIdentity(inverseRelation);
+                                        Identity parent = query.getIdentity(parentId);
                                         String objectName, parentName;
                                         if (object.definition instanceof Internal) {
                                             objectName = ((Internal) object.definition).name;
@@ -818,7 +824,6 @@ public class PrettyPrintTG {
                             infoo.name = infoo.name.substring(0, infoo.name.lastIndexOf(".") + 1) + name;
                         } else {
                             LOGGER.error("Could not find connection for " + infoo + ". Statements of graph below");
-                            LOGGER.error(Arrays.toString(graph.statements));
                             LOGGER.error("Subject -> Predicate : " + infoo.resource + " -> "
                                     + diagramConnetionToConnection.resource);
                         }
@@ -828,7 +833,7 @@ public class PrettyPrintTG {
         }
         for (ResourceInfo info : infos.valueCollection()) {
             if (info.name.startsWith("blank")) {
-                info.name = "blank" + findHash(graph, info);
+                info.name = "blank" + findHash(info);
             }
         }
 
@@ -839,7 +844,7 @@ public class PrettyPrintTG {
         for (ResourceInfo info : order.values()) {
             if (DEBUG)
                 System.out.print("info ");
-            String uri = printURI(graph, info, true, 0, false);
+            String uri = printURI(info, true, 0, false);
             if (uri != null)
                 output.append(uri);
         }
@@ -854,7 +859,7 @@ public class PrettyPrintTG {
                     // These will be printed later
                     rblanks.put(getBlankRewrite(info.name), info);
                 } else {
-                    String uri = printURI(graph, info, false, 0, false);
+                    String uri = printURI(info, false, 0, false);
                     if (uri != null)
                         output.append(uri);
                 }
@@ -865,7 +870,7 @@ public class PrettyPrintTG {
             if (!info.hasURI && info.ownedResourcesWithPredicates.size() != 1) {
                 if (DEBUG)
                     System.out.print("ownedResources ");
-                String uri = printURI(graph, info, false, 0, false);
+                String uri = printURI(info, false, 0, false);
                 if (uri != null)
                     output.append(uri);
             }
@@ -886,7 +891,7 @@ public class PrettyPrintTG {
 
     }
 
-    private String calculateHash(TransferableGraph1 graph, ResourceInfo info) {
+    private String calculateHash(ResourceInfo info) {
         StringBuilder statementHash = new StringBuilder();
         TreeSet<String> parts = new TreeSet<>();
         for (int i = 0; i < info.owned.size(); i += 2) {
@@ -895,7 +900,7 @@ public class PrettyPrintTG {
             // Lets resolve a unique name for this based on the statements this
             // one has
 
-            String predicatee = rewritePredicateURI(graph, predicate);
+            String predicatee = rewritePredicateURI(predicate);
             ResourceInfo objInfo = infos.get(object);
             parts.add(predicatee + "->" + objInfo.name + ";;;");
         }
@@ -921,14 +926,14 @@ public class PrettyPrintTG {
         return hash;
     }
 
-    private String findHash(TransferableGraph1 graph, ResourceInfo info) {
+    private String findHash(ResourceInfo info) {
         if (info.name.startsWith("blank")) {
             String hash = hashes.get(info.name);
             if (hash == null) {
                 String oldName = info.name;
                 if (DEBUG)
                     System.out.print("calculating hash for " + oldName + " ");
-                hash = calculateHash(graph, info);
+                hash = calculateHash(info);
                 if (hashes.put(oldName, hash) != null) {
                     System.err.println("!!!!A clash occured for " + info + " with hash " + hash);
                 }
@@ -943,19 +948,31 @@ public class PrettyPrintTG {
 
     public static String print(TransferableGraph1 tg, boolean ignoreIdentifiers) throws Exception {
         StringBuilder b = new StringBuilder();
-        new PrettyPrintTG(b, ignoreIdentifiers).prettyPrint(tg);
+        new PrettyPrintTG(tg, b, ignoreIdentifiers).prettyPrint();
         return b.toString();
     }
 
     public static void main(String[] args) throws Exception {
         if (args.length < 1) {
             System.out.println("Required arguments: <input .sharedOntology file> [<output .tg file>]");
-        } else if (args.length < 2) {
-            Path input = Paths.get(args[0]);
-            Path output = input.getParent().resolve(input.getName(input.getNameCount() - 1) + ".fixed");
-            new PrettyPrintTG().prettyPrint(input, output);
+        }
+        Path input;
+        Path output;
+        if (args.length < 2) {
+            input = Paths.get(args[0]);
+            output = input.getParent().resolve(input.getName(input.getNameCount() - 1) + ".fixed");
         } else {
-            new PrettyPrintTG().prettyPrint(Paths.get(args[0]), Paths.get(args[1]));
+            input = Paths.get(args[0]);
+            output = Paths.get(args[1]);
+        }
+        System.out.format("Converting exported shared ontology%n\t" + input.toString()
+        + "%nto bundle-compatible ontology%n\t" + output.toString());
+        try (InputStream is = new BufferedInputStream(Files.newInputStream(input), 128 * 1024)) {
+            DataInput dis = new DataInputStream(is);
+            org.simantics.databoard.container.DataContainer container = DataContainers.readFile(dis);
+            Binding binding = TransferableGraph1.BINDING;
+            TransferableGraph1 graph = (TransferableGraph1) container.content.getValue(binding);
+            new PrettyPrintTG(graph).prettyPrint();
         }
     }
 
diff --git a/bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphQueries.java b/bundles/org.simantics.graph/src/org/simantics/graph/representation/TransferableGraphQueries.java
new file mode 100644 (file)
index 0000000..5d4c185
--- /dev/null
@@ -0,0 +1,205 @@
+package org.simantics.graph.representation;
+
+import java.util.Comparator;
+import java.util.Set;
+import java.util.TreeMap;
+import java.util.TreeSet;
+
+import gnu.trove.impl.Constants;
+import gnu.trove.list.array.TIntArrayList;
+import gnu.trove.map.hash.TIntObjectHashMap;
+import gnu.trove.map.hash.TObjectIntHashMap;
+import gnu.trove.procedure.TObjectProcedure;
+
+public class TransferableGraphQueries {
+
+    private static final int NOT_FOUND = TransferableGraphUtils.NOT_FOUND;
+
+    private final TransferableGraph1 tg;
+
+    private final TIntObjectHashMap<Identity> internalIdentities = new TIntObjectHashMap<>(Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, NOT_FOUND);
+    private final TIntObjectHashMap<Identity> externalIdentities = new TIntObjectHashMap<>(Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, NOT_FOUND);
+    private final TIntObjectHashMap<Identity> rootIdentities = new TIntObjectHashMap<>(Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, NOT_FOUND);
+
+    private final TObjectIntHashMap<String> internalIdentitiesByURI = new TObjectIntHashMap<>();
+    private final TObjectIntHashMap<String> externalIdentitiesByURI = new TObjectIntHashMap<>();
+    private final TObjectIntHashMap<String> rootIdentitiesByURI = new TObjectIntHashMap<>();
+
+    private final TIntObjectHashMap<TIntArrayList> statementsCache = new TIntObjectHashMap<>(Constants.DEFAULT_CAPACITY, Constants.DEFAULT_LOAD_FACTOR, NOT_FOUND);
+    
+    public TransferableGraphQueries(TransferableGraph1 graph) {
+        this.tg = graph;
+        
+        // Calculate internals
+        initializeIdentities();
+    }
+
+    private void initializeIdentities() {
+        for (Identity identity : tg.identities) {
+            IdentityDefinition definition = identity.definition;
+            if (definition instanceof Internal) {
+                Internal internal = (Internal) definition;
+                internalIdentities.put(identity.resource, identity);
+                internalIdentitiesByURI.put(getURI(identity), identity.resource);
+            } else if (definition instanceof External) {
+                External external = (External) definition;
+                externalIdentities.put(identity.resource, identity);
+                externalIdentitiesByURI.put(getURI(identity), identity.resource);
+            } else if (definition instanceof Root) {
+                Root root = (Root) definition;
+                rootIdentities.put(identity.resource, identity);
+                rootIdentitiesByURI.put(getURI(identity), identity.resource);
+            }
+        }
+    }
+
+    public String getURI(Identity identity) {
+        IdentityDefinition definition = identity.definition;
+        if(definition instanceof External) {
+            External def = (External)definition;
+            if(def.parent == -1) return "http:/";
+            else return getURI(def.parent) + "/" + def.name;
+        } else if(definition instanceof Root) {
+            Root def = (Root)definition;
+            if(def.name.isEmpty()) return "http:/";
+            return def.name;
+        } else if (definition instanceof Internal) {
+            Internal def = (Internal)definition;
+            return getURI(def.parent) + "/" + def.name;
+        } else {
+            return "";
+        }
+    }
+
+    public String getURI(int id) {
+        Identity identity = getIdentity(id);
+        if (identity == null)
+            return "<internal reference " + id + ">:";
+        return getURI(identity);
+    }
+
+    private static final Comparator<Identity> IDENTITY_NAME_COMPARATOR = new Comparator<Identity>() {
+        
+        @Override
+        public int compare(Identity o1, Identity o2) {
+            if (o1.definition instanceof Internal && o2.definition instanceof Internal) {
+                Internal i1 = (Internal) o1.definition; 
+                Internal i2 = (Internal) o2.definition;
+                return i1.name.compareTo(i2.name);
+            } else if (o1.definition instanceof External && o2.definition instanceof External) {
+                External e1 = (External) o1.definition;
+                External e2 = (External) o2.definition;
+                return e1.name.compareTo(e2.name);
+            } else {
+                throw new IllegalArgumentException(o1 + " " + o2);
+            }
+        }
+    };
+
+    public Set<Identity> getChildren(Identity parent) {
+        TreeSet<Identity> children = new TreeSet<>(IDENTITY_NAME_COMPARATOR);
+        internalIdentities.forEachEntry((resource, identity) -> {
+            Internal internal = (Internal) identity.definition;
+            if (internal.parent == parent.resource)
+                children.add(identity);
+            return true;
+        });
+        
+        return children;
+    }
+    
+    public Identity findInternalByName(String name) {
+        int internal = internalIdentitiesByURI.get(name);
+        if (internal == NOT_FOUND)
+            return null;
+        return internalIdentities.get(internal);
+    }
+
+    private Identity findExternalByName(String name) {
+        int external = externalIdentitiesByURI.get(name);
+        if (external == NOT_FOUND)
+            return null;
+        return externalIdentities.get(external);
+    }
+
+    private Identity findExternalByNameAndParent(String name, int parent) {
+        Identity external = findExternalByName(name);
+        if (external.resource == parent)
+            return external;
+        return null;
+    }
+
+    public Identity findExternalByURI(String uri) {
+        int v = externalIdentitiesByURI.get(uri);
+        if (v == NOT_FOUND)
+            return null;
+        return externalIdentities.get(v);
+    }
+
+    public Identity findRootByName(String name) {
+        int root = rootIdentitiesByURI.get(name);
+        if (root == NOT_FOUND)
+            return null;
+        return rootIdentities.get(root);
+    }
+    
+    public String getName(Identity identity) {
+        return TransferableGraphUtils.getName(identity);
+    }
+
+    public void forIdentities(TObjectProcedure<Identity> procedure) {
+        for (Identity identity : tg.identities) {
+            if (!procedure.execute(identity)) {
+                break;
+            }
+        }
+    }
+
+    public Identity getIdentity(int resource) {
+        Identity result = rootIdentities.get(resource);
+        if (result == null)
+            result = externalIdentities.get(resource);
+        if (result == null)
+            result = internalIdentities.get(resource);
+        return result;
+    }
+
+    public Value findValue(int object) {
+        return TransferableGraphUtils.findValue(tg, object);
+    }
+
+    public TreeMap<String, TreeSet<Integer>> sortByPredicateUniqueStatements(int resource) {
+        TreeMap<String, TreeSet<Integer>> results = new TreeMap<>();
+        TIntArrayList statements = getStatements(resource);
+        for (int i = 0; i < statements.size(); i += 2) {
+            int predicate = statements.get(i);
+            String predicateURI = getURI(predicate);
+            TreeSet<Integer> objects = results.get(predicateURI);
+            if (objects == null) {
+                objects = new TreeSet<>();
+            }
+            objects.add(statements.get(i + 1));
+            results.put(predicateURI, objects);
+        }
+        return results;
+    }
+
+    public TIntArrayList getStatements(int resource) {
+//        System.out.println("getting statements with " + resource);
+        TIntArrayList statements = statementsCache.get(resource);
+        if (statements == null) {
+            statements = TransferableGraphUtils.getStatements(tg, resource);
+            statementsCache.put(resource, statements);
+        }
+        return statements;
+    }
+
+    public int getPossibleObject(int subject, Identity predicate) {
+        return TransferableGraphUtils.getPossibleObject2(tg, subject, predicate);
+    }
+
+    public TransferableGraph1 getGraph() {
+        return tg;
+    }
+    
+}
index b210d8dd713348cb38fa846f6558509442d05276..10637ad65caf0d861d52e3d1adfffdee66d5f2ca 100644 (file)
@@ -16,156 +16,205 @@ import gnu.trove.map.hash.TIntObjectHashMap;
 
 public class TransferableGraphUtils {
 
-       public static Collection<Identity> getRoots(TransferableGraph1 tg) {
-               
-               ArrayList<Identity> result = new ArrayList<Identity>();
-               for(Identity id : tg.identities) {
-                       if(id.definition instanceof Root) result.add(id);
-               }
-               return result;
-               
-       }
-       
-       public static Identity findRootWithName(TransferableGraph1 tg, String name) {
-               
-               for(Identity id : tg.identities) {
-                       if(id.definition instanceof Root) {
-                               Root ext = (Root)id.definition;
-                               if(ext.name.equals(name)) return id;
-                       }
-               }
-               return null;
-               
-       }
+    public static Collection<Identity> getRoots(TransferableGraph1 tg) {
+        
+        ArrayList<Identity> result = new ArrayList<Identity>();
+        for(Identity id : tg.identities) {
+            if(id.definition instanceof Root) result.add(id);
+        }
+        return result;
+        
+    }
+    
+    public static Identity findRootWithName(TransferableGraph1 tg, String name) {
+        
+        for(Identity id : tg.identities) {
+            if(id.definition instanceof Root) {
+                Root ext = (Root)id.definition;
+                if(ext.name.equals(name)) return id;
+            }
+        }
+        return null;
+        
+    }
 
-       public static Identity findExternalWithName(TransferableGraph1 tg, String name) {
-               
-               for(Identity id : tg.identities) {
-                       if(id.definition instanceof External) {
-                               External ext = (External)id.definition;
-                               if(ext.name.equals(name)) return id;
-                       }
-               }
-               return null;
-               
-       }
+    public static Identity findExternalWithName(TransferableGraph1 tg, String name) {
+        
+        for(Identity id : tg.identities) {
+            if(id.definition instanceof External) {
+                External ext = (External)id.definition;
+                if(ext.name.equals(name)) return id;
+            }
+        }
+        return null;
+        
+    }
+
+    public static Identity findExternalWithNameAndParent(TransferableGraph1 tg, int parent, String name) {
+        
+        for(Identity id : tg.identities) {
+            if(id.definition instanceof External) {
+                External ext = (External)id.definition;
+                if(ext.name.equals(name) && ext.parent == parent) return id;
+            }
+        }
+        return null;
+        
+    }
+    
+    public static Identity findExternal(TransferableGraph1 tg, String uri) {
+        
+        Identity identity = findExternalWithName(tg, "http:/");
+        if(identity == null) identity = findExternalWithName(tg, "");
+        if(identity == null) identity = findRootWithName(tg, "");
+        if("http:/".equals(uri)) return identity;
+        String[] tokens = uri.substring("http://".length()).split("/");
+        for(String token : tokens) {
+            identity = findExternalWithNameAndParent(tg, identity.resource, token);
+            if (identity == null) {
+                return null;
+            }
+        }
+        return identity;
+        
+    }
+    
+    public static Identity getIdentity(TransferableGraph1 tg, int resource) {
+        for(Identity id : tg.identities) {
+            if(id.resource == resource) return id;
+        }
+        return null;
+    }
+    
+    public static TIntArrayList getStatements(TransferableGraph1 tg, int resource) {
+        TIntArrayList result = new TIntArrayList();
+        for(int i=0;i<tg.statements.length;i+=4) {
+            if(tg.statements[i] == resource) {
+                result.add(tg.statements[i+1]);
+                result.add(tg.statements[i+3]);
+            }
+        }
+        return result;
+    }
+
+    public static Collection<Identity> getChildren2(TransferableGraph1 tg, Identity parent) {
+        return getChildren2(tg, parent.resource);
+    }
+    
+    public static Collection<Identity> getChildren2(TransferableGraph1 tg, int parentResource) {
+        TreeMap<String, Identity> result = new TreeMap<>();
+        for (Identity id : tg.identities) {
+            if (id.definition instanceof Internal) {
+                Internal internal = (Internal) id.definition;
+                if (internal.parent == parentResource)
+                    result.put(internal.name, id);
+            }
+        }
+        Identity consistsOf = findExternal(tg, "http://www.simantics.org/Layer0-1.1/ConsistsOf");
+        Identity hasName = findExternal(tg, "http://www.simantics.org/Layer0-1.1/HasName");
+        for (int i = 0; i < tg.statements.length; i += 4) {
+            if (tg.statements[i] == parentResource) {
+                if (tg.statements[i + 1] == consistsOf.resource) {
+                    Identity identity = getIdentity(tg, tg.statements[i + 3]);
+                    if (identity != null) {
+                        if (identity.definition instanceof Internal) {
+                            Internal internal = (Internal) identity.definition;
+                            result.put(internal.name, identity);
+                        }
+                    } else {
+                        int possibleNameResource = getPossibleObject2(tg, tg.statements[i + 3], hasName);
+                        if (possibleNameResource != NOT_FOUND) {
+                            Value value = findValue(tg, possibleNameResource);
+                            if (value != null) {
+                                try {
+                                    String name = (String) value.value.getValue(Bindings.STRING);
+                                    result.put(name, new Identity(tg.statements[i + 3], new Internal(tg.statements[i], name)));
+                                } catch (AdaptException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return result.values();
+    }
 
-       public static Identity findExternalWithNameAndParent(TransferableGraph1 tg, int parent, String name) {
-               
-               for(Identity id : tg.identities) {
-                       if(id.definition instanceof External) {
-                               External ext = (External)id.definition;
-                               if(ext.name.equals(name) && ext.parent == parent) return id;
-                       }
-               }
-               return null;
-               
-       }
-       
-       public static Identity findExternal(TransferableGraph1 tg, String uri) {
-               
-               Identity identity = findExternalWithName(tg, "http:/");
-               if(identity == null) identity = findExternalWithName(tg, "");
-               if(identity == null) identity = findRootWithName(tg, "");
-               if("http:/".equals(uri)) return identity;
-               String[] tokens = uri.substring("http://".length()).split("/");
-               for(String token : tokens) {
-                       identity = findExternalWithNameAndParent(tg, identity.resource, token);
-                       if (identity == null) {
-                           return null;
-                       }
-               }
-               return identity;
-               
-       }
-       
-       public static Identity getIdentity(TransferableGraph1 tg, int resource) {
-               for(Identity id : tg.identities) {
-                       if(id.resource == resource) return id;
-               }
-               return null;
-       }
-       
-       public static TIntArrayList getStatements(TransferableGraph1 tg, int resource) {
-               TIntArrayList result = new TIntArrayList();
-               for(int i=0;i<tg.statements.length;i+=4) {
-                       if(tg.statements[i] == resource) {
-                               result.add(tg.statements[i+1]);
-                               result.add(tg.statements[i+3]);
-                       }
-               }
-               return result;
-       }
-       
-       public static Collection<Identity> getChildren(TransferableGraph1 tg, Identity parent) {
-               TreeMap<String,Identity> result = new TreeMap<>();
-               for(Identity id : tg.identities) {
-                       if(id.definition instanceof Internal) {
-                               Internal internal = (Internal)id.definition;
-                               if(internal.parent == parent.resource) result.put(internal.name, id);
-                       }
-               }
-               Identity consistsOf = findExternal(tg, "http://www.simantics.org/Layer0-1.1/ConsistsOf");
-               Identity hasName = findExternal(tg, "http://www.simantics.org/Layer0-1.1/HasName");
-               for(int i=0;i<tg.statements.length;i+=4) {
-                       if(tg.statements[i] == parent.resource) {
-                               if(tg.statements[i+1] == consistsOf.resource) {
-                                       Identity identity = getIdentity(tg, tg.statements[i+3]);
-                                       if(identity != null) {
-                                               if(identity.definition instanceof Internal) {
-                                                       Internal internal = (Internal)identity.definition;
-                                                       result.put(internal.name, identity);
-                                               }
-                                       } else {
-                                               int possibleNameResource = getPossibleObject(tg, tg.statements[i+3], hasName);
-                                               if(possibleNameResource != 0) {
-                                                       Value value = findValue(tg, possibleNameResource);
-                                                       if(value != null) {
-                                                               try {
-                                                                       String name = (String)value.value.getValue(Bindings.STRING);
-                                                                       result.put(name, new Identity(tg.statements[i+3], new Internal(tg.statements[i], name)));
-                                                               } catch (AdaptException e) {
-                                                                       e.printStackTrace();
-                                                               }
-                                                       }
-                                               }
-                                       }
-                               }
-                       }
-               }
-               return result.values();
-       }
-       
-       public static TIntArrayList getObjects(TransferableGraph1 tg, int subject, Identity predicate) {
-               TIntArrayList result = new TIntArrayList();
-               for(int i=0;i<tg.statements.length;i+=4) {
-                       if(tg.statements[i] == subject && tg.statements[i+1] == predicate.resource) {
-                               result.add(tg.statements[i+3]);
-                       }
-               }
-               return result;
-       }
-       
     /**
      * This implementation is no longer advised to use because it returns 0 as
      * NOT_FOUND which is in fact a valid ID for resource in graph
      */
-       @Deprecated
-       public static int getPossibleObject(TransferableGraph1 tg, int subject, Identity predicate) {
-               int result = 0;
-               for(int i=0;i<tg.statements.length;i+=4) {
-                       if(tg.statements[i] == subject && tg.statements[i+1] == predicate.resource) {
-                               if(result != 0 && tg.statements[i+3] != result) return 0;
-                               result = tg.statements[i+3];
-                       }
-               }
-               return result;
-       }
+    @Deprecated
+    public static Collection<Identity> getChildren(TransferableGraph1 tg, Identity parent) {
+        TreeMap<String,Identity> result = new TreeMap<>();
+        for(Identity id : tg.identities) {
+            if(id.definition instanceof Internal) {
+                Internal internal = (Internal)id.definition;
+                if(internal.parent == parent.resource) result.put(internal.name, id);
+            }
+        }
+        Identity consistsOf = findExternal(tg, "http://www.simantics.org/Layer0-1.1/ConsistsOf");
+        Identity hasName = findExternal(tg, "http://www.simantics.org/Layer0-1.1/HasName");
+        for(int i=0;i<tg.statements.length;i+=4) {
+            if(tg.statements[i] == parent.resource) {
+                if(tg.statements[i+1] == consistsOf.resource) {
+                    Identity identity = getIdentity(tg, tg.statements[i+3]);
+                    if(identity != null) {
+                        if(identity.definition instanceof Internal) {
+                            Internal internal = (Internal)identity.definition;
+                            result.put(internal.name, identity);
+                        }
+                    } else {
+                        int possibleNameResource = getPossibleObject(tg, tg.statements[i+3], hasName);
+                        if(possibleNameResource != 0) {
+                            Value value = findValue(tg, possibleNameResource);
+                            if(value != null) {
+                                try {
+                                    String name = (String)value.value.getValue(Bindings.STRING);
+                                    result.put(name, new Identity(tg.statements[i+3], new Internal(tg.statements[i], name)));
+                                } catch (AdaptException e) {
+                                    e.printStackTrace();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+        return result.values();
+    }
+    
+    public static TIntArrayList getObjects(TransferableGraph1 tg, int subject, Identity predicate) {
+        TIntArrayList result = new TIntArrayList();
+        for(int i=0;i<tg.statements.length;i+=4) {
+            if(tg.statements[i] == subject && tg.statements[i+1] == predicate.resource) {
+                result.add(tg.statements[i+3]);
+            }
+        }
+        return result;
+    }
+    
+    /**
+     * This implementation is no longer advised to use because it returns 0 as
+     * NOT_FOUND which is in fact a valid ID for resource in graph
+     */
+    @Deprecated
+    public static int getPossibleObject(TransferableGraph1 tg, int subject, Identity predicate) {
+        int result = 0;
+        for(int i=0;i<tg.statements.length;i+=4) {
+            if(tg.statements[i] == subject && tg.statements[i+1] == predicate.resource) {
+                if(result != 0 && tg.statements[i+3] != result) return 0;
+                result = tg.statements[i+3];
+            }
+        }
+        return result;
+    }
 
-       public static final int NOT_FOUND = -2;
+    public static final int NOT_FOUND = -2;
 
-       public static int getPossibleObject2(TransferableGraph1 tg, int subject, Identity predicate) {
-           int result = NOT_FOUND;
+    public static int getPossibleObject2(TransferableGraph1 tg, int subject, Identity predicate) {
+        int result = NOT_FOUND;
         for(int i=0;i<tg.statements.length;i+=4) {
             if(tg.statements[i] == subject && tg.statements[i+1] == predicate.resource) {
                 if(result != NOT_FOUND && tg.statements[i+3] != result)
@@ -174,19 +223,19 @@ public class TransferableGraphUtils {
             }
         }
         return result;
-       }
-       
-       /**
-        * @return 0 for presenting not found which is BAD
-        * @see getPossibleObject2
-        */
-       @Deprecated
-       public static int getPossibleObject(TransferableGraph1 tg, Identity subject, String predicate) {
-               Identity p = findExternal(tg, predicate);
-               if(p == null) return 0;
-               return getPossibleObject(tg, subject.resource, p);
-       }
-       
+    }
+    
+    /**
+     * @return 0 for presenting not found which is BAD
+     * @see getPossibleObject2
+     */
+    @Deprecated
+    public static int getPossibleObject(TransferableGraph1 tg, Identity subject, String predicate) {
+        Identity p = findExternal(tg, predicate);
+        if(p == null) return 0;
+        return getPossibleObject(tg, subject.resource, p);
+    }
+    
     public static int getPossibleObject2(TransferableGraph1 tg, Identity subject, String predicate) {
         Identity p = findExternal(tg, predicate);
         if (p == null)
@@ -194,112 +243,112 @@ public class TransferableGraphUtils {
         return getPossibleObject2(tg, subject.resource, p);
     }
 
-       public static Map<Identity, String> getNames(TransferableGraph1 tg, Collection<Identity> ids) {
-               Map<Identity, String> result = new HashMap<Identity, String>();
-               for(Identity id : ids) {
-                       if(id.definition instanceof Internal) {
-                               Internal internal = (Internal)id.definition;
-                               result.put(id, internal.name);
-                       }
-               }
-               return result;
-       }
+    public static Map<Identity, String> getNames(TransferableGraph1 tg, Collection<Identity> ids) {
+        Map<Identity, String> result = new HashMap<Identity, String>();
+        for(Identity id : ids) {
+            if(id.definition instanceof Internal) {
+                Internal internal = (Internal)id.definition;
+                result.put(id, internal.name);
+            }
+        }
+        return result;
+    }
 
-       public static String getName(TransferableGraph1 tg, Identity id) {
-               return getName(id);
-       }
+    public static String getName(TransferableGraph1 tg, Identity id) {
+        return getName(id);
+    }
 
-       public static String getName(Identity id) {
-               if(id.definition instanceof Internal) {
-                       Internal internal = (Internal)id.definition;
-                       return internal.name;
-               } else if(id.definition instanceof External) {
-                       External external = (External)id.definition;
-                       return external.name;
-               } else if(id.definition instanceof Root) {
-                       Root root = (Root)id.definition;
-                       return root.name;
-               } else  {
-                       Optional optional = (Optional)id.definition;
-                       return optional.name;
-               }
-       }
+    public static String getName(Identity id) {
+        if(id.definition instanceof Internal) {
+            Internal internal = (Internal)id.definition;
+            return internal.name;
+        } else if(id.definition instanceof External) {
+            External external = (External)id.definition;
+            return external.name;
+        } else if(id.definition instanceof Root) {
+            Root root = (Root)id.definition;
+            return root.name;
+        } else  {
+            Optional optional = (Optional)id.definition;
+            return optional.name;
+        }
+    }
 
-       public static String getRootType(Identity id) {
-               if(id.definition instanceof Root) {
-                       Root root = (Root)id.definition;
-                       return root.type;
-               } else  {
-                       throw new IllegalArgumentException("Expected root, got " + id);
-               }
-       }
+    public static String getRootType(Identity id) {
+        if(id.definition instanceof Root) {
+            Root root = (Root)id.definition;
+            return root.type;
+        } else  {
+            throw new IllegalArgumentException("Expected root, got " + id);
+        }
+    }
 
-       public static Value findValue(TransferableGraph1 tg, int subject) {
-               for(Value v : tg.values) {
-                       if(v.resource == subject) return v;
-               }
-               return null;
-       }
-       
-       public static String getURI(TransferableGraph1 tg, int id) {
-           return getURI(tg.resourceCount, tg.identities, id);
-       }
-       
-       public static String getURI(int resourceCount, Identity[] identities, int id) {
-           for(Identity identity : identities) {
-               if(identity.resource == id) {
-                   IdentityDefinition definition = identity.definition;
-                   if(definition instanceof External) {
-                       External def = (External)definition;
-                       if(def.parent == -1) return "http:/";
-                       else return getURI(resourceCount, identities, def.parent) + "/" + def.name;
-                   } else if(definition instanceof Root) {
-                       Root def = (Root)definition;
-                       if(def.name.isEmpty()) return "http:/";
-                       return def.name;
-                   } else if (definition instanceof Internal) {
-                       Internal def = (Internal)definition;
-                       return getURI(resourceCount, identities, def.parent) + "/" + def.name;
-                   } else {
-                       return "";
-                   }
-               }
-           }       
-           return "<internal reference " + id + ">:";
-       }
+    public static Value findValue(TransferableGraph1 tg, int subject) {
+        for(Value v : tg.values) {
+            if(v.resource == subject) return v;
+        }
+        return null;
+    }
+    
+    public static String getURI(TransferableGraph1 tg, int id) {
+        return getURI(tg.identities, id);
+    }
+    
+    public static String getURI(Identity[] identities, int id) {
+        for(Identity identity : identities) {
+            if(identity.resource == id) {
+                IdentityDefinition definition = identity.definition;
+                if(definition instanceof External) {
+                    External def = (External)definition;
+                    if(def.parent == -1) return "http:/";
+                    else return getURI(identities, def.parent) + "/" + def.name;
+                } else if(definition instanceof Root) {
+                    Root def = (Root)definition;
+                    if(def.name.isEmpty()) return "http:/";
+                    return def.name;
+                } else if (definition instanceof Internal) {
+                    Internal def = (Internal)definition;
+                    return getURI(identities, def.parent) + "/" + def.name;
+                } else {
+                    return "";
+                }
+            }
+        }       
+        return "<internal reference " + id + ">:";
+    }
 
-       public static TIntObjectMap<Identity> mapIdentities(TransferableGraph1 tg) {
-               return mapIdentities(tg.identities);
-       }
+    public static TIntObjectMap<Identity> mapIdentities(TransferableGraph1 tg) {
+        return mapIdentities(tg.identities);
+    }
 
-       public static TIntObjectMap<Identity> mapIdentities(Identity[] identities) {
-               // Integer.MIN_VALUE cannot be the value of Identity.resource
-               TIntObjectMap<Identity> map = new TIntObjectHashMap<>(identities.length, 0.5f, Integer.MIN_VALUE);
-               for (Identity id : identities)
-                       map.put(id.resource, id);
-               return map;
-       }
+    public static TIntObjectMap<Identity> mapIdentities(Identity[] identities) {
+        // Integer.MIN_VALUE cannot be the value of Identity.resource
+        TIntObjectMap<Identity> map = new TIntObjectHashMap<>(identities.length, 0.5f, Integer.MIN_VALUE);
+        for (Identity id : identities)
+            map.put(id.resource, id);
+        return map;
+    }
 
-       public static String getURI(int resourceCount, TIntObjectMap<Identity> identities, int id) {
-               Identity identity = identities.get(id);
-               if(identity != null) {
-                       IdentityDefinition definition = identity.definition;
-                       if(definition instanceof External) {
-                               External def = (External)definition;
-                               if(def.parent == -1) return "http:/";
-                               else return getURI(resourceCount, identities, def.parent) + "/" + URIStringUtils.escape(def.name);
-                       } else if(definition instanceof Root) {
-                               Root def = (Root)definition;
-                               if(def.name.isEmpty()) return "http:/";
-                               return def.name;
-                       } else if (definition instanceof Internal) {
-                               Internal def = (Internal)definition;
-                               return getURI(resourceCount, identities, def.parent) + "/" + URIStringUtils.escape(def.name);
-                       } else {
-                               return "";
-                       }
-               }
-               return "<internal reference " + id + ">:";
-       }
+    public static String getURI(int resourceCount, TIntObjectMap<Identity> identities, int id) {
+        Identity identity = identities.get(id);
+        if(identity != null) {
+            IdentityDefinition definition = identity.definition;
+            if(definition instanceof External) {
+                External def = (External)definition;
+                if(def.parent == -1) return "http:/";
+                else return getURI(resourceCount, identities, def.parent) + "/" + URIStringUtils.escape(def.name);
+            } else if(definition instanceof Root) {
+                Root def = (Root)definition;
+                if(def.name.isEmpty()) return "http:/";
+                return def.name;
+            } else if (definition instanceof Internal) {
+                Internal def = (Internal)definition;
+                return getURI(resourceCount, identities, def.parent) + "/" + URIStringUtils.escape(def.name);
+            } else {
+                return "";
+            }
+        }
+        return "<internal reference " + id + ">:";
+    }
 
 }
index 0255339ac7bda279053ca6e30b98d744f2362ac2..86171a31a445049705b104c7bfa9b89eb5e42d4c 100644 (file)
@@ -420,10 +420,23 @@ MOD.Contributions.Help : VP.ActionContribution
     VP.ActionContribution.HasCategory VP.EditActionCategory
     VP.ActionContribution.HasNodeType L0.Entity
     VP.ActionContribution.HasAction ACTIONS.Help
-              
+
+MOD.Contributions.CopyURI : VP.ActionContribution
+    L0.HasLabel "Copy URI"
+    VP.ActionContribution.HasImage SILK.clipboard
+    VP.ActionContribution.HasCategory VP.EditActionCategory
+    VP.ActionContribution.HasNodeType L0.Entity
+    VP.ActionContribution.HasNodeType MBC.Variable
+    VP.ActionContribution.HasAction ACTIONS.CopyURI
+    VP.ActionContribution.IsVisibleIf _ : VP.AndTest
+        VP.AndTest.HasTest
+            _ : VP.InDevelopmentModeTest
+            _ : VP.HasURITest
+
 // Actions
 MAC    
     VP.BrowseContext.HasActionContribution MOD.Contributions.Help
+    VP.BrowseContext.HasActionContribution MOD.Contributions.CopyURI
     VP.BrowseContext.HasActionContribution _ : VP.ActionContribution
         L0.HasLabel "Migrate"
         VP.ActionContribution.HasImage SILK.star
@@ -659,6 +672,7 @@ ACTIONS.CompilePGraphs : ACT.Action
 //ACTIONS.MigrateMasterTypical : ACT.Action
 ACTIONS.RenameDiagramComponents : ACT.Action
 ACTIONS.Help : ACT.Action
+ACTIONS.CopyURI : ACT.Action
 
 ACTIONS.NavigateToSubstructure
   @MOD.sclAction "navigateToSubstructureAction"
index 0e3870c356673adc721d392164649b8588d89b73..b74449f822ed4ad9eb5084f70f7a4992fe5f2085 100644 (file)
         </type>
                <resource uri="http://www.simantics.org/Modeling-0.0/ModelingActionContext/Actions/Help"
                        class="org.simantics.modeling.actions.Help" />
+        <resource uri="http://www.simantics.org/Modeling-0.0/ModelingActionContext/Actions/CopyURI"
+            class="org.simantics.modeling.actions.CopyURI" />
     </target>
 
        <target interface="org.simantics.db.layer0.adapter.DropActionFactory">
diff --git a/bundles/org.simantics.modeling/src/org/simantics/modeling/actions/CopyURI.java b/bundles/org.simantics.modeling/src/org/simantics/modeling/actions/CopyURI.java
new file mode 100644 (file)
index 0000000..cdb56be
--- /dev/null
@@ -0,0 +1,60 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Association for Decentralized Information Management
+ * in Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ *     Semantum Oy - initial API and implementation
+ *******************************************************************************/
+package org.simantics.modeling.actions;
+
+import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.dnd.TextTransfer;
+import org.eclipse.swt.dnd.Transfer;
+import org.eclipse.swt.widgets.Display;
+import org.simantics.Simantics;
+import org.simantics.db.Resource;
+import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.layer0.adapter.ActionFactory;
+import org.simantics.db.layer0.request.PossibleURI;
+import org.simantics.db.layer0.request.VariableURI;
+import org.simantics.db.layer0.variable.Variable;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * @author Jani Simomaa
+ * @since 1.30.0
+ */
+public class CopyURI implements ActionFactory {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(CopyURI.class);
+
+    @Override
+    public Runnable create(Object target) {
+        return () -> {
+            try {
+                String uri = getPossibleURI(target);
+                if (uri != null) {
+                    Clipboard cb = new Clipboard(Display.getCurrent());
+                    cb.setContents(new Object[] { uri }, new Transfer[] { TextTransfer.getInstance() });
+                }
+            } catch (Exception e) {
+                LOGGER.error("Could not get URI for input {} to copy to clipboard", target, e);
+            }
+        };
+    }
+
+    private String getPossibleURI(Object input) throws DatabaseException {
+        if (input instanceof Resource) {
+            return Simantics.getSession().syncRequest(new PossibleURI((Resource) input));
+        } else if (input instanceof Variable) {
+            return Simantics.getSession().syncRequest(new VariableURI((Variable) input));
+        }
+        return null;
+    }
+
+}
index a0e60d0b31e2882935a98a802a8bf7f82776757f..bcae4c4805e8f96a48815bc8bb051f9f677af7bf 100644 (file)
@@ -57,6 +57,8 @@ ACTIONS.NewSTSTest
   @MOD.sclAction "createSTSTestAction"
 ACTIONS.RunSTSTest
   @MOD.sclAction "runSTSTestAction"
+ACTIONS.IgnoreSTSTest
+  @MOD.sclAction "ignoreSTSTestAction"
 ACTIONS.NewSTSVariable
   @MOD.sclAction "createSTSVariableAction"
 
@@ -82,6 +84,13 @@ MAC
         VP.ActionContribution.HasNodeType TESTS.STSSuite
         VP.ActionContribution.HasNodeType TESTS.STSTest
         VP.ActionContribution.HasAction ACTIONS.RunSTSTest
+    VP.BrowseContext.HasActionContribution _ : VP.ActionContribution
+        L0.HasLabel "Ignore"
+        VP.ActionContribution.HasImage SILK.control_play
+        VP.ActionContribution.HasCategory VP.EditActionCategory
+        VP.ActionContribution.HasNodeType TESTS.STSSuite
+        VP.ActionContribution.HasNodeType TESTS.STSTest
+        VP.ActionContribution.HasAction ACTIONS.IgnoreSTSTest
     VP.BrowseContext.HasActionContribution _ : VP.ActionContribution
         L0.HasLabel "STS Variable"
         VP.ActionContribution.HasImage SILK.page_white_edit
index 53218224a089feac163ae5e475d245afe05a25e2..0b99fe784fa2239470ef3f93f80b59f5e2ae6bcf 100644 (file)
@@ -7,6 +7,7 @@ createSTSTestAction res = do
 
 importJava "org.simantics.tests.modelled.ui.TestsUIUtils" where
     runSTSTestAction :: Resource -> <Proc> ()
+    ignoreSTSTestAction :: [Resource] -> <Proc> ()
     
 createSTSSuiteAction :: Resource -> <Proc> ()
 createSTSSuiteAction res = do
index 651ee47df7282751f3e891b11dcce3e5588b2caa..b24f445e23c985e317f652f628e435a0135a3b53 100644 (file)
@@ -1,10 +1,16 @@
 package org.simantics.tests.modelled.ui;
 
 import java.io.IOException;
+import java.util.List;
 
 import org.eclipse.e4.ui.model.application.ui.basic.MPart;
+import org.simantics.Simantics;
+import org.simantics.databoard.Bindings;
 import org.simantics.db.Resource;
+import org.simantics.db.WriteGraph;
 import org.simantics.db.exception.DatabaseException;
+import org.simantics.db.request.Write;
+import org.simantics.tests.modelled.ontology.TestsResource;
 import org.simantics.ui.workbench.e4.E4WorkbenchUtils;
 
 public class TestsUIUtils {
@@ -20,4 +26,17 @@ public class TestsUIUtils {
         view.currentTest(test);
         view.execute();
     }
+    
+    public static void ignoreSTSTestAction(List<Resource> tests) throws DatabaseException {
+        Simantics.getSession().syncRequest(new Write() {
+            
+            @Override
+            public void perform(WriteGraph graph) throws DatabaseException {
+                TestsResource TESTS = TestsResource.getInstance(graph);
+                for (Resource test : tests) {
+                    graph.claimLiteral(test, TESTS.ignore, true, Bindings.BOOLEAN);
+                }
+            }
+        });
+    }
 }
index 3ce1b01580c7415d517f712ca499cf4670c8aa45..78964403f95057464a929d8ea81e0622dea54a8b 100644 (file)
@@ -117,7 +117,7 @@ public class ModelledSTSTest {
 //    //                    }
 //    //                }
 //                    return new ModuleCompilationOptions(coverage);
-//                }
+    //                    }
 //            });
             
             SCLReportingHandler handler = (SCLReportingHandler) SCLContext.getCurrent().get(SCLReportingHandler.REPORTING_HANDLER);
index 1eb13238fad88dc387fa517b4940f066e5ac1ffe..4f297e417e744faf85b3a0f9a590a3fcb8698a6c 100644 (file)
@@ -35,3 +35,9 @@ VP.InstanceOfTest <T VP.Test
 
 VP.FailTest <T VP.Test
     L0.HasDescription "A test that is compatible with all content types and always fails, i.e. returns false."
+
+VP.HasURITest <T VP.Test
+    L0.HasDescription "A test that checks the Resource or Variable given as input has a proper URI."
+
+VP.InDevelopmentModeTest <T VP.Test
+    L0.HasDescription "A test that directly invokes org.eclipse.runtime.core.Platform.inDevelopmentMode()."
index 17c7d28f45016120cb6736611260a8f2e648e55a..aaccfc9152e0da5fdae61f9e56275cee47dac70e 100644 (file)
@@ -332,7 +332,7 @@ img {
 <li>Simantics R - <a href="https://www.simantics.org:8088/r/gitweb?p=simantics/r.git;a=summary">simantics/r.git</a></li>\r
 <li>FMIL - <a href="https://www.simantics.org:8088/r/gitweb?p=simantics/fmil.git;a=summary">simantics/fmil.git</a></li>\r
 <li>FMI Studio - <a href="https://www.simantics.org:8088/r/gitweb?p=members/fmi.git;a=summary">members/fmi.git</a></li>\r
-<li>Simupedia - <a href="https://www.simantics.org/svn/members/simupedia">Members SVN</a></li>\r
+<li>Simupedia - <a href="https://www.simantics.org:8088/r/gitweb?p=members/simupedia.git;a=summary">members/simupedia.git</a></li>\r
 </ul>\r
 <p>For simplicity, each of these components are versioned accoring to platform versioning, i.e. for Platform SDK 1.26.0 there will be Simantics Desktop 1.26.0, Sysdyn 1.26.0, and so on.</p>\r
 <hr />\r
@@ -478,7 +478,7 @@ refs #yyyy
 <h2>Tag release/* branches</h2>\r
 <p>When the release branches are ready for the release, tag them with the tag <code>vx.y.z[.w]</code>:</p>\r
 <pre><code>git clone ssh://&lt;user&gt;@www.simantics.org:29418/simantics/platform.git\r
-cd platform    \r
+cd platform\r
 git checkout release/x.y.z[.w]\r
 git tag vx.y.z[.w] -m &quot;Simantics x.y.z[.w] simultaneous release&quot;\r
 git push origin --tags\r
@@ -556,15 +556,15 @@ separate Mediawiki installation.</p>
 </ul>\r
 <h2>Disseminate information about the release</h2>\r
 <ul>\r
-<li><a href="http://dev.simantics.org">Developer Wiki</a>: Update roadmap at http://dev.simantics.org/index.php/Roadmap</li>\r
-<li><a href="https://www.simantics.org/redmine/">Redmine</a>: Post news on the developer/user-visible changes here.</li>\r
+<li><a href="http://dev.simantics.org">Developer Wiki</a>: Update roadmap at <a href="http://dev.simantics.org/index.php/Roadmap">http://dev.simantics.org/index.php/Roadmap</a></li>\r
+<li><a href="https://www.simantics.org/redmine/">Redmine</a>: Post news on the developer/user-visible changes here</li>\r
 <li><a href="https://www.simantics.org">simantics.org</a>: Post news on the release and a link to the redmine post</li>\r
 <li><a href="https://www.simantics.org/members/">Members Wiki</a>: Update frame plan to reflect the realized dates and link to Redmine news</li>\r
 <li><a href="mailto:simantics-developers@simantics.org">mailto:simantics-developers@simantics.org</a> Send &quot;newsletter&quot; to `simantics-developers@simantics.org:</li>\r
 </ul>\r
 <p><strong>Newsletter template:</strong></p>\r
 <pre><code>Hello everyone,\r
-   \r
+\r
 Simantics release x.y.z[.w] has been released. Head over to\r
 https://www.simantics.org/redmine/news/&lt;news number&gt;\r
 for the release news.\r
@@ -583,6 +583,9 @@ Insert some general thoughts on the release...
 <hr />\r
 <h1>TODO</h1>\r
 <ul>\r
+<li>Start using <a href="https://github.com/mbarbero/fr.obeo.releng.targetplatform">https://github.com/mbarbero/fr.obeo.releng.targetplatform</a> to generate <code>.target</code> files. <code>.tpd</code> files allow specifying version ranges instead of specific versions.</li>\r
+</ul>\r
+<ul>\r
 <li>Create a parametrized release train pipeline build in Jenkins that creates all artifacts of a simantics release\r
 <ul>\r
 <li>Desktop, Sysdyn, R, Simupedia, FMIL, FMI Studio</li>\r
@@ -590,12 +593,7 @@ Insert some general thoughts on the release...
 </li>\r
 </ul>\r
 <ul>\r
-<li>\r
-<p>Incorporate tutorial code in the platform repository as a separate folder to allow platform builds to directly ensure that the tutorial code still builds OK</p>\r
-</li>\r
-<li>\r
-<p>Start using https://github.com/mbarbero/fr.obeo.releng.targetplatform to generate <code>.target</code> files. <code>.tpd</code> files allow specifying version ranges instead of specific versions.</p>\r
-</li>\r
+<li>Incorporate tutorial code in the platform repository as a separate folder to allow platform builds to directly ensure that the tutorial code still builds OK</li>\r
 </ul>\r
 \r
 </body>\r
index 79359efd215e1346ee9624f7192c4708960ad86a..871b1d0aa3eb0b56069ee1be66033d91bdec3b03 100644 (file)
@@ -36,7 +36,7 @@ Plug-in components that are part of the release train:
 * Simantics R - [simantics/r.git](https://www.simantics.org:8088/r/gitweb?p=simantics/r.git;a=summary)
 * FMIL - [simantics/fmil.git](https://www.simantics.org:8088/r/gitweb?p=simantics/fmil.git;a=summary)
 * FMI Studio - [members/fmi.git](https://www.simantics.org:8088/r/gitweb?p=members/fmi.git;a=summary)
-* Simupedia - [Members SVN](https://www.simantics.org/svn/members/simupedia)
+* Simupedia - [members/simupedia.git](https://www.simantics.org:8088/r/gitweb?p=members/simupedia.git;a=summary)
 
 For simplicity, each of these components are versioned accoring to platform versioning, i.e. for Platform SDK 1.26.0 there will be Simantics Desktop 1.26.0, Sysdyn 1.26.0, and so on.
 
@@ -246,8 +246,8 @@ separate Mediawiki installation.
 
 ## Disseminate information about the release
 
-* [Developer Wiki](http://dev.simantics.org): Update roadmap at http://dev.simantics.org/index.php/Roadmap
-* [Redmine](https://www.simantics.org/redmine/): Post news on the developer/user-visible changes here.
+* [Developer Wiki](http://dev.simantics.org): Update roadmap at [http://dev.simantics.org/index.php/Roadmap](http://dev.simantics.org/index.php/Roadmap)
+* [Redmine](https://www.simantics.org/redmine/): Post news on the developer/user-visible changes here
 * [simantics.org](https://www.simantics.org): Post news on the release and a link to the redmine post
 * [Members Wiki](https://www.simantics.org/members/): Update frame plan to reflect the realized dates and link to Redmine news
 * [mailto:simantics-developers@simantics.org](mailto:simantics-developers@simantics.org) Send "newsletter" to `simantics-developers@simantics.org:
@@ -278,11 +278,11 @@ Insert some general thoughts on the release...
 
 # TODO
 
-* Create a parametrized release train pipeline build in Jenkins that creates all artifacts of a simantics release
-  * Desktop, Sysdyn, R, Simupedia, FMIL, FMI Studio
+* Start using [https://github.com/mbarbero/fr.obeo.releng.targetplatform](https://github.com/mbarbero/fr.obeo.releng.targetplatform) to generate `.target` files. `.tpd` files allow specifying version ranges instead of specific versions.
 
 
-* Incorporate tutorial code in the platform repository as a separate folder to allow platform builds to directly ensure that the tutorial code still builds OK
+* Create a parametrized release train pipeline build in Jenkins that creates all artifacts of a simantics release
+  * Desktop, Sysdyn, R, Simupedia, FMIL, FMI Studio
 
-* Start using https://github.com/mbarbero/fr.obeo.releng.targetplatform to generate `.target` files. `.tpd` files allow specifying version ranges instead of specific versions.
 
+* Incorporate tutorial code in the platform repository as a separate folder to allow platform builds to directly ensure that the tutorial code still builds OK
\ No newline at end of file