forked from D-Net/dnet-hadoop
fixed merging method
This commit is contained in:
parent
e208b03755
commit
1372a4d1bf
|
@ -17,26 +17,30 @@ import eu.dnetlib.dhp.utils.DHPUtils;
|
||||||
|
|
||||||
public class OafMapperUtils {
|
public class OafMapperUtils {
|
||||||
|
|
||||||
public static Oaf merge(final Oaf o1, final Oaf o2) {
|
public static Oaf merge(final Oaf left, final Oaf right) {
|
||||||
if (ModelSupport.isSubClass(o1, OafEntity.class)) {
|
if (ModelSupport.isSubClass(left, OafEntity.class)) {
|
||||||
return mergeEntities((OafEntity) o1, (OafEntity) o2);
|
return mergeEntities((OafEntity) left, (OafEntity) right);
|
||||||
} else if (ModelSupport.isSubClass(o1, Relation.class)) {
|
} else if (ModelSupport.isSubClass(left, Relation.class)) {
|
||||||
((Relation) o1).mergeFrom((Relation) o2);
|
((Relation) left).mergeFrom((Relation) right);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("invalid Oaf type:" + left.getClass().getCanonicalName());
|
||||||
}
|
}
|
||||||
throw new RuntimeException("invalid Oaf type:" + o1.getClass().getCanonicalName());
|
return left;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static OafEntity mergeEntities(OafEntity e1, OafEntity e2) {
|
public static OafEntity mergeEntities(OafEntity left, OafEntity right) {
|
||||||
if (ModelSupport.isSubClass(e1, Result.class)) {
|
if (ModelSupport.isSubClass(left, Result.class)) {
|
||||||
return mergeResults((Result) e1, (Result) e2);
|
return mergeResults((Result) left, (Result) right);
|
||||||
} else if (ModelSupport.isSubClass(e1, Datasource.class)) {
|
} else if (ModelSupport.isSubClass(left, Datasource.class)) {
|
||||||
((Datasource) e1).mergeFrom((Datasource) e2);
|
((Datasource) left).mergeFrom((Datasource) right);
|
||||||
} else if (ModelSupport.isSubClass(e1, Organization.class)) {
|
} else if (ModelSupport.isSubClass(left, Organization.class)) {
|
||||||
((Organization) e1).mergeFrom((Organization) e2);
|
((Organization) left).mergeFrom((Organization) right);
|
||||||
} else if (ModelSupport.isSubClass(e1, Project.class)) {
|
} else if (ModelSupport.isSubClass(left, Project.class)) {
|
||||||
((Project) e1).mergeFrom((Project) e2);
|
((Project) left).mergeFrom((Project) right);
|
||||||
|
} else {
|
||||||
|
throw new RuntimeException("invalid OafEntity subtype:" + left.getClass().getCanonicalName());
|
||||||
}
|
}
|
||||||
throw new RuntimeException("invalid OafEntity subtype:" + e1.getClass().getCanonicalName());
|
return left;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Result mergeResults(Result r1, Result r2) {
|
public static Result mergeResults(Result r1, Result r2) {
|
||||||
|
|
Loading…
Reference in New Issue