Commit 348c8222 authored by David Hoksza's avatar David Hoksza
Browse files

Comparison of MiriamData takes into account annotator class.

parent f370f158
......@@ -226,7 +226,9 @@ public class MiriamData implements Comparable<MiriamData>, Serializable {
@Override
public int compareTo(MiriamData other) {
return ((dataType + ":" + resource).toLowerCase().compareTo((other.dataType + ":" + other.resource).toLowerCase()));
String name = annotator != null ? annotator.getName() : "";
String otherName = other.annotator != null ? other.annotator.getName() : "";
return (dataType + ":" + resource + ":" + name).toLowerCase().compareTo((other.dataType + ":" + other.resource + ":" + otherName).toLowerCase());
}
/**
......@@ -279,16 +281,6 @@ public class MiriamData implements Comparable<MiriamData>, Serializable {
public void setRelationType(MiriamRelationType relationType) {
this.relationType = relationType;
}
@Override
public String toString() {
if (relationType != null) {
return "[" + relationType.getStringRepresentation() + "] " + dataType + ":" + resource;
} else {
return "[UNKNOWN] " + dataType + ":" + resource;
}
}
/**
*
......@@ -305,4 +297,15 @@ public class MiriamData implements Comparable<MiriamData>, Serializable {
public void setAnnotator(Class<?> annotator) {
this.annotator = annotator;
}
@Override
public String toString() {
String annotatorClass = annotator != null ? ":" +annotator.getName() : "";
if (relationType != null) {
return "[" + relationType.getStringRepresentation() + "] " + dataType + ":" + resource + annotatorClass;
} else {
return "[UNKNOWN] " + dataType + ":" + resource + annotatorClass;
}
}
}
......@@ -116,6 +116,17 @@ public class MiriamDataTest {
try {
MiriamData md = new MiriamData();
assertTrue(md.compareTo(new MiriamData(MiriamType.CAS, "a")) != 0);
MiriamData md1 = new MiriamData(MiriamType.CAS, "a");
MiriamData md2 = new MiriamData(MiriamType.CAS, "a");
assertTrue(md1.compareTo(md2) == 0);
md1.setAnnotator(Integer.class);
assertTrue(md1.compareTo(md2) != 0);
md2.setAnnotator(Integer.class);
assertTrue(md1.compareTo(md2) == 0);
} catch (Exception e) {
e.printStackTrace();
throw e;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment