-package org.simantics.graph.compiler.internal.validation;\r
-\r
-import java.util.Collection;\r
-\r
-import org.simantics.graph.compiler.GraphCompilerPreferences;\r
-import org.simantics.graph.compiler.internal.store.LocationStore;\r
-import org.simantics.graph.compiler.internal.templates.TemplateDefinitionStore;\r
-import org.simantics.graph.query.Res;\r
-import org.simantics.graph.store.GraphStore;\r
-import org.simantics.graph.store.StatementCollision;\r
-import org.simantics.ltk.Problem;\r
-\r
-public class ReportCollisions implements Runnable {\r
- GraphCompilerPreferences preferences;\r
- Collection<Problem> problems;\r
- GraphStore store;\r
-\r
- public ReportCollisions(\r
- GraphCompilerPreferences preferences, Collection<Problem> problems,\r
- GraphStore store) {\r
- this.preferences = preferences;\r
- this.problems = problems;\r
- this.store = store;\r
- }\r
- \r
- private static String abbreviateURI(Res res) {\r
- if(res == null)\r
- return "null";\r
- String uri = res.toString();\r
- return uri.replace("http://www.simantics.org/", "");\r
- }\r
- \r
- @Override\r
- public void run() {\r
- LocationStore locations = store.getStore(LocationStore.class);\r
- for(int c : store.values.getCollisions().toArray())\r
- problems.add(new Problem(\r
- locations.getLocation(c), \r
- "Two literal values are given for the same resource."));\r
- for(int c : store.identities.getCollisions().toArray())\r
- problems.add(new Problem(\r
- locations.getLocation(c), \r
- "Two different identities are given for the same resource."));\r
- for(int c : store.getStore(TemplateDefinitionStore.class).getCollisions().toArray())\r
- problems.add(new Problem(\r
- locations.getLocation(c), \r
- "Two template definitions are given for the same resource."));\r
- if(preferences.validate)\r
- for(StatementCollision collision : store.statements.getCollisions()) {\r
- problems.add(new Problem(\r
- locations.getLocation(collision.subject), \r
- "The same statement is defined " + collision.count + " times: " +\r
- abbreviateURI(store.idToRes(collision.subject)) + ", " +\r
- abbreviateURI(store.idToRes(collision.predicate)) + ", " +\r
- abbreviateURI(store.idToRes(collision.object))));\r
- }\r
- }\r
- \r
-}\r
+package org.simantics.graph.compiler.internal.validation;
+
+import java.util.Collection;
+
+import org.simantics.graph.compiler.GraphCompilerPreferences;
+import org.simantics.graph.compiler.internal.store.LocationStore;
+import org.simantics.graph.compiler.internal.templates.TemplateDefinitionStore;
+import org.simantics.graph.query.Res;
+import org.simantics.graph.store.GraphStore;
+import org.simantics.graph.store.StatementCollision;
+import org.simantics.ltk.Problem;
+
+public class ReportCollisions implements Runnable {
+ GraphCompilerPreferences preferences;
+ Collection<Problem> problems;
+ GraphStore store;
+
+ public ReportCollisions(
+ GraphCompilerPreferences preferences, Collection<Problem> problems,
+ GraphStore store) {
+ this.preferences = preferences;
+ this.problems = problems;
+ this.store = store;
+ }
+
+ private static String abbreviateURI(Res res) {
+ if(res == null)
+ return "null";
+ String uri = res.toString();
+ return uri.replace("http://www.simantics.org/", "");
+ }
+
+ @Override
+ public void run() {
+ LocationStore locations = store.getStore(LocationStore.class);
+ for(int c : store.values.getCollisions().toArray())
+ problems.add(new Problem(
+ locations.getLocation(c),
+ "Two literal values are given for the same resource."));
+ for(int c : store.identities.getCollisions().toArray())
+ problems.add(new Problem(
+ locations.getLocation(c),
+ "Two different identities are given for the same resource."));
+ for(int c : store.getStore(TemplateDefinitionStore.class).getCollisions().toArray())
+ problems.add(new Problem(
+ locations.getLocation(c),
+ "Two template definitions are given for the same resource."));
+ if(preferences.validate)
+ for(StatementCollision collision : store.statements.getCollisions()) {
+ problems.add(new Problem(
+ locations.getLocation(collision.subject),
+ "The same statement is defined " + collision.count + " times: " +
+ abbreviateURI(store.idToRes(collision.subject)) + ", " +
+ abbreviateURI(store.idToRes(collision.predicate)) + ", " +
+ abbreviateURI(store.idToRes(collision.object))));
+ }
+ }
+
+}