2021-07-01 14:29:47 +02:00
|
|
|
|
|
|
|
package eu.dnetlib.dhp.schema.sx.scholix;
|
|
|
|
|
2022-03-29 11:12:08 +02:00
|
|
|
import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*;
|
2022-02-21 10:57:47 +01:00
|
|
|
|
2021-07-01 14:29:47 +02:00
|
|
|
import java.io.Serializable;
|
|
|
|
import java.util.List;
|
2022-02-22 17:26:05 +01:00
|
|
|
import java.util.Objects;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
2022-03-29 11:12:08 +02:00
|
|
|
import org.apache.commons.lang3.StringUtils;
|
2021-07-01 14:29:47 +02:00
|
|
|
|
2022-02-21 10:57:47 +01:00
|
|
|
public class Scholix implements Serializable, Comparable<Scholix> {
|
2022-02-22 17:26:05 +01:00
|
|
|
|
2021-07-01 14:29:47 +02:00
|
|
|
private String publicationDate;
|
|
|
|
|
|
|
|
private List<ScholixEntityId> publisher;
|
|
|
|
|
|
|
|
private List<ScholixEntityId> linkprovider;
|
|
|
|
|
|
|
|
private ScholixRelationship relationship;
|
|
|
|
|
|
|
|
private ScholixResource source;
|
|
|
|
|
|
|
|
private ScholixResource target;
|
|
|
|
|
|
|
|
private String identifier;
|
|
|
|
|
|
|
|
public String getPublicationDate() {
|
|
|
|
return publicationDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPublicationDate(String publicationDate) {
|
|
|
|
this.publicationDate = publicationDate;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<ScholixEntityId> getPublisher() {
|
|
|
|
return publisher;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setPublisher(List<ScholixEntityId> publisher) {
|
|
|
|
this.publisher = publisher;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<ScholixEntityId> getLinkprovider() {
|
|
|
|
return linkprovider;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setLinkprovider(List<ScholixEntityId> linkprovider) {
|
|
|
|
this.linkprovider = linkprovider;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ScholixRelationship getRelationship() {
|
|
|
|
return relationship;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRelationship(ScholixRelationship relationship) {
|
|
|
|
this.relationship = relationship;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ScholixResource getSource() {
|
|
|
|
return source;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setSource(ScholixResource source) {
|
|
|
|
this.source = source;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ScholixResource getTarget() {
|
|
|
|
return target;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setTarget(ScholixResource target) {
|
|
|
|
this.target = target;
|
|
|
|
}
|
|
|
|
|
|
|
|
public String getIdentifier() {
|
|
|
|
return identifier;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setIdentifier(String identifier) {
|
|
|
|
this.identifier = identifier;
|
|
|
|
}
|
2022-02-21 10:57:47 +01:00
|
|
|
|
|
|
|
|
2022-02-22 17:26:05 +01:00
|
|
|
@Override
|
|
|
|
public boolean equals(Object o) {
|
|
|
|
if (this == o) return true;
|
|
|
|
if (!(o instanceof Scholix)) return false;
|
|
|
|
Scholix scholix = (Scholix) o;
|
|
|
|
return compareTo(scholix) == 0;
|
|
|
|
}
|
2022-02-21 10:57:47 +01:00
|
|
|
|
2022-02-22 17:26:05 +01:00
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
final int publisherHash = publisher == null ? 0: publisher.stream().sorted().collect(Collectors.toList()).hashCode();
|
|
|
|
final int linkProviderHash = linkprovider == null ? 0: linkprovider.stream().sorted().collect(Collectors.toList()).hashCode();
|
|
|
|
|
|
|
|
return Objects.hash(normalizeString(publicationDate),publisherHash, linkProviderHash, relationship, source, target, normalizeIdnetifier(identifier));
|
|
|
|
}
|
2022-02-21 10:57:47 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int compareTo(Scholix other) {
|
|
|
|
|
|
|
|
if (other == null)
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
// Comparing publication date
|
|
|
|
final int publicationDateCompare =StringUtils.compare(publicationDate, other.getPublicationDate());
|
|
|
|
|
|
|
|
if (publicationDateCompare != 0)
|
|
|
|
return publicationDateCompare;
|
|
|
|
|
2022-02-22 17:26:05 +01:00
|
|
|
final int linkPublisherComparator = compareList(publisher, other.getPublisher());
|
|
|
|
if (linkPublisherComparator!= 0)
|
|
|
|
return linkPublisherComparator;
|
|
|
|
|
|
|
|
final int linkProviderComparator = compareList(linkprovider, other.getLinkprovider());
|
|
|
|
if (linkProviderComparator!= 0)
|
|
|
|
return linkProviderComparator;
|
|
|
|
|
2022-02-21 10:57:47 +01:00
|
|
|
|
2022-02-22 17:26:05 +01:00
|
|
|
final int relsComparator = compareObjects(relationship, other.getRelationship());
|
|
|
|
if (relsComparator!= 0)
|
|
|
|
return relsComparator;
|
2022-02-21 10:57:47 +01:00
|
|
|
|
|
|
|
|
2022-02-22 17:26:05 +01:00
|
|
|
final int sourceComparator = compareObjects(source, other.getSource());
|
|
|
|
if (sourceComparator!= 0)
|
|
|
|
return sourceComparator;
|
2022-02-21 10:57:47 +01:00
|
|
|
|
2022-02-22 17:26:05 +01:00
|
|
|
return compareObjects(target, other.getTarget());
|
2022-02-21 10:57:47 +01:00
|
|
|
}
|
2021-07-01 14:29:47 +02:00
|
|
|
}
|