1 package org.simantics.graph.compiler.internal.validation;
\r
3 import java.util.Collection;
\r
5 import org.simantics.graph.compiler.GraphCompilerPreferences;
\r
6 import org.simantics.graph.compiler.internal.store.LocationStore;
\r
7 import org.simantics.graph.compiler.internal.templates.TemplateDefinitionStore;
\r
8 import org.simantics.graph.store.GraphStore;
\r
9 import org.simantics.graph.store.StatementCollision;
\r
10 import org.simantics.ltk.Problem;
\r
12 public class ReportCollisions implements Runnable {
\r
13 GraphCompilerPreferences preferences;
\r
14 Collection<Problem> problems;
\r
17 public ReportCollisions(
\r
18 GraphCompilerPreferences preferences, Collection<Problem> problems,
\r
20 this.preferences = preferences;
\r
21 this.problems = problems;
\r
27 LocationStore locations = store.getStore(LocationStore.class);
\r
28 for(int c : store.values.getCollisions().toArray())
\r
29 problems.add(new Problem(
\r
30 locations.getLocation(c),
\r
31 "Two literal values are given for the same resource."));
\r
32 for(int c : store.identities.getCollisions().toArray())
\r
33 problems.add(new Problem(
\r
34 locations.getLocation(c),
\r
35 "Two different identities are given for the same resource."));
\r
36 for(int c : store.getStore(TemplateDefinitionStore.class).getCollisions().toArray())
\r
37 problems.add(new Problem(
\r
38 locations.getLocation(c),
\r
39 "Two template definitions are given for the same resource."));
\r
40 if(preferences.validate)
\r
41 for(StatementCollision collision : store.statements.getCollisions()) {
\r
42 problems.add(new Problem(
\r
43 locations.getLocation(collision.subject),
\r
44 "The same statement is defined twice: " +
\r
45 store.idToRes(collision.predicate) + ", " +
\r
46 store.idToRes(collision.object)));
\r