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
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(StatementCollision collision : store.statements.getCollisions()) {\r
problems.add(new Problem(\r
locations.getLocation(collision.subject), \r
- "The same statement is defined twice: " +\r
- store.idToRes(collision.predicate) + ", " +\r
- store.idToRes(collision.object)));\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
public final int subject;\r
public final int predicate;\r
public final int object;\r
+ public final int count;\r
\r
- public StatementCollision(int subject, int predicate, int object) {\r
+ public StatementCollision(int subject, int predicate, int object, int count) {\r
this.subject = subject;\r
this.predicate = predicate;\r
this.object = object;\r
+ this.count = count;\r
}\r
}\r
\r
public boolean execute(int predicate, TIntArrayList objects) {\r
if(objects.size() > 1) {\r
objects.sort();\r
- int oldObject = objects.get(0); \r
+ int oldObject = objects.get(0);\r
+ int collisionCount = 1;\r
for(int i=1;i<objects.size();++i) {\r
int curObject = objects.get(i);\r
- if(curObject == oldObject)\r
- collisions.add(new StatementCollision(subject, predicate, curObject));\r
- oldObject = curObject;\r
+ if(curObject == oldObject) {\r
+ ++collisionCount;\r
+ }\r
+ else {\r
+ if(collisionCount > 1) {\r
+ collisions.add(new StatementCollision(subject, predicate, oldObject, collisionCount));\r
+ collisionCount = 1;\r
+ }\r
+ oldObject = curObject;\r
+ }\r
}\r
+ if(collisionCount > 1)\r
+ collisions.add(new StatementCollision(subject, predicate, oldObject, collisionCount));\r
}\r
return true;\r
}\r