]> gerrit.simantics Code Review - simantics/platform.git/blobdiff - bundles/org.simantics.db.layer0/src/org/simantics/db/layer0/util/DomainProcessor3.java
Mark SPECIAL_ROOTs as EXTERNAL in DomainProcessor3 - fixed condition
[simantics/platform.git] / bundles / org.simantics.db.layer0 / src / org / simantics / db / layer0 / util / DomainProcessor3.java
index c7bc380e5435cbe5e359185448d006de8eda7a45..5c2cd05c9ef8cc2b949cd0b543a6a3ffc7e5ec0a 100644 (file)
@@ -30,6 +30,8 @@ import org.simantics.db.exception.DatabaseException;
 import org.simantics.db.layer0.adapter.SubgraphExtent.ExtentStatus;
 import org.simantics.db.layer0.util.ConsistsOfProcess.ConsistsOfProcessEntry;
 import org.simantics.db.layer0.util.ModelTransferableGraphSourceRequest.Expansion3;
+import org.simantics.db.layer0.util.TransferableGraphConfiguration2.SeedSpec;
+import org.simantics.db.layer0.util.TransferableGraphConfiguration2.SeedSpec.SeedSpecType;
 import org.simantics.db.service.CollectionSupport;
 import org.simantics.db.service.SerialisationSupport;
 import org.simantics.db.service.TransferableGraphSupport;
@@ -37,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
        }
@@ -113,10 +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()) {
-            status.put(entry.getKey(), entry.getValue());
+            // INTERNAL prestatus shall be ignored. Domain processor will initialize statuses based on seeds.
+            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) {
+               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.SPECIAL_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();