for (Modification mod :modifications) {
{
Statement stm = mod.getLeftStm();
- sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+
- NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
- truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" +
- stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n");
+ if (stm != null) {
+ sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+
+ NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
+ truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" +
+ mod.getLeftSub() + " " + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n");
+ } else {
+ sb.append(NameUtils.getSafeName(graph, mod.getLeftSub()) + " "+ mod.getLeftSub() + " N/A\n");
+ }
}
{
Statement stm = mod.getRightStm();
- sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+
- NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
- truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" +
- stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n");
+ if (stm != null) {
+ sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+
+ NameUtils.getSafeName(graph, stm.getPredicate()) + " " +
+ truncate(NameUtils.getSafeName(graph, stm.getObject())) + " (" +
+ mod.getRightSub() + " " + stm.getSubject() + " " +stm.getPredicate() + " " + stm.getObject() + ")\n");
+ } else {
+ sb.append(NameUtils.getSafeName(graph, mod.getRightSub()) + " "+ mod.getRightSub() + " N/A\n");
+ }
+
}
}
return sb.toString();
*/
public class GraphComparator {
- private static final boolean DEBUG = true;
+ private static final boolean DEBUG = false;
private Resource r1;
private Resource r2;
if (r1.equals(r2))
continue;
- if (r1.getResourceId() == 610446L)
- System.out.println();
if (processedResources.contains(r1))
continue;
processedResources.add(r1);
throw new DatabaseException("Comparator error: Trying to map " + left + " to " + right + " while mappings " + left + " to " + comparableResources.getRight(left) + " and " + comparableResources.getLeft(right) + " to " + right + " exist.");
} else {
if (DEBUG) System.out.println(left + " = " + right);
- if (left.getResourceId() == 610381L)
- System.out.println();
comparableResources.map(left, right);
}
}
return out;
}
+ public List<Statement> filterAssertedDuplicates(Resource r, List<Statement> in) throws DatabaseException {
+ List<Statement> out = new ArrayList<Statement>();
+ for (int i = 0; i < in.size(); i++) {
+ Statement s = in.get(i);
+ if (!s.isAsserted(r))
+ out.add(s);
+ else {
+ boolean has = false;
+ if (i > 1 && in.get(i-1).getPredicate().equals(s.getPredicate()))
+ has = true;
+ else if (i < in.size()-1 && in.get(i+1).getPredicate().equals(s.getPredicate()))
+ has = true;
+ if (!has)
+ out.add(s);
+ }
+
+ }
+ for (Statement s : in) {
+ if (!s.isAsserted(r))
+ out.add(s);
+
+ }
+ return out;
+ }
+
private String printStatement(ReadGraph graph, Statement s) throws DatabaseException {
ss1 = filterNonTested(ss1);
ss2 = filterNonTested(ss2);
sortStatement(ss1, ss2);
+ // getStatements(r1, b.HasProperty) returns both instance and asserted statements for the same property relation.
+ ss1 = filterAssertedDuplicates(r1, ss1);
+ ss2 = filterAssertedDuplicates(r2, ss2);
int i1 = 0;
int i2 = 0;