]> gerrit.simantics Code Review - simantics/platform.git/commitdiff
Block external and excluded seeds in ConsistsOfProcess 26/1926/1
authorAntti Villberg <antti.villberg@semantum.fi>
Sat, 7 Jul 2018 06:11:52 +0000 (09:11 +0300)
committerHannu Niemistö <hannu.niemisto@semantum.fi>
Tue, 17 Jul 2018 10:46:29 +0000 (13:46 +0300)
refs #14162

Change-Id: I3d8048ee763b5e41e0b9835afcb129ad50b88025

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

index 691f8864c94c7e89630ff3e5de840fa92a41aaac..75c75764adb2b5668ef0e8736818cf4718cb6fa9 100644 (file)
@@ -35,14 +35,7 @@ class ConsistsOfProcess {
 
        public static Pair<List<ConsistsOfProcessEntry>,Set<Resource>> walk(ReadGraph graph, ResourceMap<ExtentStatus> status, Collection<SeedSpec> specs, boolean ignoreVirtual) throws DatabaseException {
                
-               Collection<ConsistsOfProcessEntry> entries = new ArrayList<>(specs.size());
-               for(SeedSpec r : specs) {
-                       if(SeedSpecType.INTERNAL.equals(r.specType))
-                           entries.add(new ConsistsOfProcessEntry(null, r.resource, true));
-                       else
-                               entries.add(new ConsistsOfProcessEntry(null, r.resource, false));
-               }
-       ConsistsOfProcess process = new ConsistsOfProcess(graph, status, entries, ignoreVirtual);
+       ConsistsOfProcess process = new ConsistsOfProcess(graph, status, specs, ignoreVirtual);
        return Pair.make(process.result, process.childrenWithNoName);
        
     }
@@ -50,17 +43,15 @@ class ConsistsOfProcess {
     static class ConsistsOfProcessEntry {
        public ConsistsOfProcessEntry parent;
        public Resource resource;
-       public boolean internal;
        public boolean valid = true;
        public String name = null;
-       ConsistsOfProcessEntry(ConsistsOfProcessEntry parent, Resource resource, boolean internal) {
+       ConsistsOfProcessEntry(ConsistsOfProcessEntry parent, Resource resource) {
                this.parent = parent;
                this.resource = resource;
-               this.internal = internal;
        }
     }
        
-    private ConsistsOfProcess(ReadGraph graph, ResourceMap<ExtentStatus> status, final Collection<ConsistsOfProcessEntry> entries, final boolean ignoreVirtual) throws DatabaseException {
+    private ConsistsOfProcess(ReadGraph graph, ResourceMap<ExtentStatus> status, final Collection<SeedSpec> seeds, final boolean ignoreVirtual) throws DatabaseException {
 
                final Layer0 L0 = Layer0.getInstance(graph);
                final DirectQuerySupport dqs = graph.getService(DirectQuerySupport.class);
@@ -128,7 +119,7 @@ class ConsistsOfProcess {
                                        if(ExtentStatus.EXCLUDED.equals(status.get(child))) return;
                                
                                if(!ignoreVirtual || child.isPersistent()) {
-                                       ConsistsOfProcessEntry entry = new ConsistsOfProcessEntry(parent, child, false);
+                                       ConsistsOfProcessEntry entry = new ConsistsOfProcessEntry(parent, child);
                                        dqs.forEachObjectCompiled(graph, child, entry, structure);
                                        dqs.forEachObjectCompiled(graph, child, entry, names);
                                }
@@ -150,11 +141,20 @@ class ConsistsOfProcess {
 
                        @Override
                        public void run(ReadGraph graph) throws DatabaseException {
-                               for(ConsistsOfProcessEntry entry  : entries) {
-                                       dqs.forEachObjectCompiled(graph, entry.resource, entry, structure);
-                                       if(entry.internal) {
-                                               // For roots names are not processed
-                                               dqs.forEachObjectCompiled(graph, entry.resource, entry, names);
+                               for(SeedSpec seed  : seeds) {
+                                       
+                                       if(status != null) {
+                                               ExtentStatus es = status.get(seed.resource);
+                                               if(ExtentStatus.EXCLUDED.equals(es)) continue;
+                                               if(ExtentStatus.EXTERNAL.equals(es)) continue;
+                                       }
+                                       
+                                       ConsistsOfProcessEntry entry = new ConsistsOfProcessEntry(null, seed.resource);
+                                       
+                                       dqs.forEachObjectCompiled(graph, seed.resource, entry, structure);
+                                       if(SeedSpecType.INTERNAL.equals(seed.specType)) {
+                                               // Process names only for internal seeds
+                                               dqs.forEachObjectCompiled(graph, seed.resource, entry, names);
                                        }
                                }
                        }
index 07e4194276113fe56e89f8d756152cb41f285578..85cc8e629a5ffe341c367a3205f9af017f4d58bc 100644 (file)
@@ -39,12 +39,16 @@ 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 org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import gnu.trove.list.array.TIntArrayList;
 import gnu.trove.map.hash.TIntIntHashMap;
 
 public class DomainProcessor3 {
-       
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(DomainProcessor3.class);
+
        public enum ExclusionDecision {
                INCLUDE, EXCLUDE_OBJECT
        }
@@ -115,20 +119,49 @@ public class DomainProcessor3 {
         deadPredicates = cs.createSet();
         strongInverseSet = cs.createSet();
 
+        if(LOGGER.isDebugEnabled()) {
+
+               for(Map.Entry<Resource, ExtentStatus> entry : conf.preStatus.entrySet()) {
+                       LOGGER.debug("prestatus: " + NameUtils.getSafeName(graph, entry.getKey()) + " " + entry.getValue());
+               }
+
+               for(SeedSpec ss : conf.seeds) {
+                       LOGGER.debug("seed: " + NameUtils.getSafeName(graph, ss.resource) + " " + ss.name + " " + ss.specType + " " + ss.type);
+               }
+
+        }
+        
         for(Map.Entry<Resource, ExtentStatus> entry : conf.preStatus.entrySet()) {
             // INTERNAL prestatus shall be ignored. Domain processor will initialize statuses based on seeds.
-            if (entry.getValue().equals(ExtentStatus.INTERNAL)) continue;
-            status.put(entry.getKey(), entry.getValue());
+            if (entry.getValue().equals(ExtentStatus.INTERNAL)) {
+               LOGGER.info("Unexpected INTERNAL preStatus in DomainProcessor3 " + entry.getKey());
+            } else {
+                status.put(entry.getKey(), entry.getValue());
+            }
         }
 
         for(SeedSpec ss : conf.seeds) {
-            if(SeedSpecType.INTERNAL.equals(ss.specType)) continue;
-            // Non-internal resources are not reported as internals by ConsistsOfProcess so they are manually entered into fringe
-            fringe.add(ss.resource);
-            // Roots are classified in status as INTERNAL
-            status.put(ss.resource, ExtentStatus.INTERNAL);
+               ExtentStatus pre = status.get(ss.resource);
+               // INTERNAL seeds are feed into ConsistsOfProcess
+            if(SeedSpecType.INTERNAL.equals(ss.specType)) {
+               if(pre != null && !ExtentStatus.INTERNAL.equals(pre))
+                       LOGGER.info("Internal seed preclassification problem, expected INTERNAL preclassification, got " + pre.name());
+               continue;
+            } else if(SeedSpecType.ROOT.equals(ss.specType)) {
+               //      Non-internal resources are not reported as internals by ConsistsOfProcess so they are manually entered into fringe
+               fringe.add(ss.resource);
+               if(pre != null)
+                       LOGGER.info("Root preclassification problem, expected no preclassification, got " + pre.name());
+               // Roots are classified in status as INTERNAL
+               status.put(ss.resource, ExtentStatus.INTERNAL);
+            } else if(SeedSpecType.ROOT.equals(ss.specType)) {
+               // Special roots e.g. %model are marked as EXTERNAL
+               if(pre != null && !ExtentStatus.EXTERNAL.equals(pre))
+                       LOGGER.info("Special root preclassification problem, expected EXTERNAL preclassification, got " + pre.name());
+               status.put(ss.resource, ExtentStatus.EXTERNAL);
+            }
         }
-
+        
        if(PROFILE)
                startupTime += System.nanoTime();