added comparator for refereed field instances

This commit is contained in:
Claudio Atzori 2022-03-23 13:59:40 +01:00
parent 87818acd14
commit d08c2744f5
2 changed files with 47 additions and 0 deletions

View File

@ -57,6 +57,9 @@ public class ModelConstants {
public static final String DNET_RELATION_SUBRELTYPE = "dnet:relation_subRelType";
public static final String DNET_RELATION_RELCLASS = "dnet:relation_relClass";
public static final String PEER_REVIEWED = "nonPeerReviewed";
public static final String NON_PEER_REVIEWED = "nonPeerReviewed";
public static final String SYSIMPORT_CROSSWALK_REPOSITORY = "sysimport:crosswalk:repository";
public static final String SYSIMPORT_CROSSWALK_ENTITYREGISTRY = "sysimport:crosswalk:entityregistry";
public static final String SYSIMPORT_ACTIONSET = "sysimport:actionset";

View File

@ -0,0 +1,44 @@
package eu.dnetlib.dhp.schema.common;
import eu.dnetlib.dhp.schema.oaf.Qualifier;
import java.util.Comparator;
public class RefereedComparator implements Comparator<Qualifier> {
@Override
public int compare(Qualifier left, Qualifier right) {
if (left == null && right == null)
return 0;
if (left == null)
return 1;
if (right == null)
return -1;
String lClass = left.getClassid();
String rClass = right.getClassid();
if (lClass.equals(rClass))
return 0;
if (lClass.equals(ModelConstants.PEER_REVIEWED))
return -1;
if (rClass.equals(ModelConstants.PEER_REVIEWED))
return 1;
if (lClass.equals(ModelConstants.NON_PEER_REVIEWED))
return -1;
if (rClass.equals(ModelConstants.NON_PEER_REVIEWED))
return 1;
if (lClass.equals(ModelConstants.UNKNOWN))
return -1;
if (rClass.equals(ModelConstants.UNKNOWN))
return 1;
// Else (but unlikely), lexicographical ordering will do.
return lClass.compareTo(rClass);
}
}