From f7454a9ed8531be70c3b84f5afb6924a9a07fda1 Mon Sep 17 00:00:00 2001 From: pjacewicz Date: Wed, 11 Mar 2020 16:57:28 +0100 Subject: [PATCH] Added equals and hashCode for OAF types --- .../eu/dnetlib/dhp/schema/oaf/Author.java | 19 +++++++ .../eu/dnetlib/dhp/schema/oaf/Country.java | 15 ++++++ .../eu/dnetlib/dhp/schema/oaf/DataInfo.java | 19 +++++++ .../eu/dnetlib/dhp/schema/oaf/Dataset.java | 21 ++++++++ .../eu/dnetlib/dhp/schema/oaf/Datasource.java | 49 +++++++++++++++++++ .../dhp/schema/oaf/ExternalReference.java | 21 ++++++++ .../eu/dnetlib/dhp/schema/oaf/ExtraInfo.java | 18 +++++++ .../eu/dnetlib/dhp/schema/oaf/Journal.java | 25 ++++++++++ .../dnetlib/dhp/schema/oaf/OAIProvenance.java | 14 ++++++ .../java/eu/dnetlib/dhp/schema/oaf/Oaf.java | 15 ++++++ .../eu/dnetlib/dhp/schema/oaf/OafEntity.java | 19 +++++++ .../dnetlib/dhp/schema/oaf/Organization.java | 30 ++++++++++++ .../dhp/schema/oaf/OriginDescription.java | 19 +++++++ .../dhp/schema/oaf/OtherResearchProduct.java | 17 +++++++ .../eu/dnetlib/dhp/schema/oaf/Project.java | 40 +++++++++++++++ .../dnetlib/dhp/schema/oaf/Publication.java | 13 +++++ .../eu/dnetlib/dhp/schema/oaf/Relation.java | 19 +++++++ .../eu/dnetlib/dhp/schema/oaf/Result.java | 34 +++++++++++++ .../eu/dnetlib/dhp/schema/oaf/Software.java | 18 +++++++ 19 files changed, 425 insertions(+) diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Author.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Author.java index 3e6621e3f..93ab60b05 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Author.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Author.java @@ -2,6 +2,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; import java.util.List; +import java.util.Objects; public class Author implements Serializable { @@ -64,4 +65,22 @@ public class Author implements Serializable { public void setAffiliation(List> affiliation) { this.affiliation = affiliation; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Author author = (Author) o; + return Objects.equals(fullname, author.fullname) && + Objects.equals(name, author.name) && + Objects.equals(surname, author.surname) && + Objects.equals(rank, author.rank) && + Objects.equals(pid, author.pid) && + Objects.equals(affiliation, author.affiliation); + } + + @Override + public int hashCode() { + return Objects.hash(fullname, name, surname, rank, pid, affiliation); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Country.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Country.java index e81120e42..b2da92c43 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Country.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Country.java @@ -1,5 +1,7 @@ package eu.dnetlib.dhp.schema.oaf; +import java.util.Objects; + public class Country extends Qualifier { private DataInfo dataInfo; @@ -12,4 +14,17 @@ public class Country extends Qualifier { this.dataInfo = dataInfo; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Country country = (Country) o; + return Objects.equals(dataInfo, country.dataInfo); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), dataInfo); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/DataInfo.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/DataInfo.java index 16683cf30..49a186701 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/DataInfo.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/DataInfo.java @@ -2,6 +2,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; import java.util.List; +import java.util.Objects; public class DataInfo implements Serializable { @@ -60,4 +61,22 @@ public class DataInfo implements Serializable { public void setProvenanceaction(Qualifier provenanceaction) { this.provenanceaction = provenanceaction; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + DataInfo dataInfo = (DataInfo) o; + return Objects.equals(invisible, dataInfo.invisible) && + Objects.equals(inferred, dataInfo.inferred) && + Objects.equals(deletedbyinference, dataInfo.deletedbyinference) && + Objects.equals(trust, dataInfo.trust) && + Objects.equals(inferenceprovenance, dataInfo.inferenceprovenance) && + Objects.equals(provenanceaction, dataInfo.provenanceaction); + } + + @Override + public int hashCode() { + return Objects.hash(invisible, inferred, deletedbyinference, trust, inferenceprovenance, provenanceaction); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java index 27bee998e..f33b11d21 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java @@ -2,6 +2,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; import java.util.List; +import java.util.Objects; public class Dataset extends Result implements Serializable { @@ -96,4 +97,24 @@ public class Dataset extends Result implements Serializable { mergeOAFDataInfo(d); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Dataset dataset = (Dataset) o; + return Objects.equals(storagedate, dataset.storagedate) && + Objects.equals(device, dataset.device) && + Objects.equals(size, dataset.size) && + Objects.equals(version, dataset.version) && + Objects.equals(lastmetadataupdate, dataset.lastmetadataupdate) && + Objects.equals(metadataversionnumber, dataset.metadataversionnumber) && + Objects.equals(geolocation, dataset.geolocation); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), storagedate, device, size, version, lastmetadataupdate, metadataversionnumber, geolocation); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java index 032468de2..08936cc29 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Datasource.java @@ -2,6 +2,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; import java.util.List; +import java.util.Objects; public class Datasource extends OafEntity implements Serializable { @@ -424,4 +425,52 @@ public class Datasource extends OafEntity implements Serializable { mergeOAFDataInfo(e); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Datasource that = (Datasource) o; + return Objects.equals(datasourcetype, that.datasourcetype) && + Objects.equals(openairecompatibility, that.openairecompatibility) && + Objects.equals(officialname, that.officialname) && + Objects.equals(englishname, that.englishname) && + Objects.equals(websiteurl, that.websiteurl) && + Objects.equals(logourl, that.logourl) && + Objects.equals(contactemail, that.contactemail) && + Objects.equals(namespaceprefix, that.namespaceprefix) && + Objects.equals(latitude, that.latitude) && + Objects.equals(longitude, that.longitude) && + Objects.equals(dateofvalidation, that.dateofvalidation) && + Objects.equals(description, that.description) && + Objects.equals(subjects, that.subjects) && + Objects.equals(odnumberofitems, that.odnumberofitems) && + Objects.equals(odnumberofitemsdate, that.odnumberofitemsdate) && + Objects.equals(odpolicies, that.odpolicies) && + Objects.equals(odlanguages, that.odlanguages) && + Objects.equals(odcontenttypes, that.odcontenttypes) && + Objects.equals(accessinfopackage, that.accessinfopackage) && + Objects.equals(releasestartdate, that.releasestartdate) && + Objects.equals(releaseenddate, that.releaseenddate) && + Objects.equals(missionstatementurl, that.missionstatementurl) && + Objects.equals(dataprovider, that.dataprovider) && + Objects.equals(serviceprovider, that.serviceprovider) && + Objects.equals(databaseaccesstype, that.databaseaccesstype) && + Objects.equals(datauploadtype, that.datauploadtype) && + Objects.equals(databaseaccessrestriction, that.databaseaccessrestriction) && + Objects.equals(datauploadrestriction, that.datauploadrestriction) && + Objects.equals(versioning, that.versioning) && + Objects.equals(citationguidelineurl, that.citationguidelineurl) && + Objects.equals(qualitymanagementkind, that.qualitymanagementkind) && + Objects.equals(pidsystems, that.pidsystems) && + Objects.equals(certificates, that.certificates) && + Objects.equals(policies, that.policies) && + Objects.equals(journal, that.journal); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), datasourcetype, openairecompatibility, officialname, englishname, websiteurl, logourl, contactemail, namespaceprefix, latitude, longitude, dateofvalidation, description, subjects, odnumberofitems, odnumberofitemsdate, odpolicies, odlanguages, odcontenttypes, accessinfopackage, releasestartdate, releaseenddate, missionstatementurl, dataprovider, serviceprovider, databaseaccesstype, datauploadtype, databaseaccessrestriction, datauploadrestriction, versioning, citationguidelineurl, qualitymanagementkind, pidsystems, certificates, policies, journal); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExternalReference.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExternalReference.java index 006658133..24c94065b 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExternalReference.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExternalReference.java @@ -1,6 +1,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; +import java.util.Objects; public class ExternalReference implements Serializable { // source @@ -90,4 +91,24 @@ public class ExternalReference implements Serializable { public void setDataInfo(DataInfo dataInfo) { this.dataInfo = dataInfo; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ExternalReference that = (ExternalReference) o; + return Objects.equals(sitename, that.sitename) && + Objects.equals(label, that.label) && + Objects.equals(url, that.url) && + Objects.equals(description, that.description) && + Objects.equals(qualifier, that.qualifier) && + Objects.equals(refidentifier, that.refidentifier) && + Objects.equals(query, that.query) && + Objects.equals(dataInfo, that.dataInfo); + } + + @Override + public int hashCode() { + return Objects.hash(sitename, label, url, description, qualifier, refidentifier, query, dataInfo); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExtraInfo.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExtraInfo.java index 028b812a5..46107b214 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExtraInfo.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/ExtraInfo.java @@ -1,6 +1,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; +import java.util.Objects; public class ExtraInfo implements Serializable { private String name; @@ -53,4 +54,21 @@ public class ExtraInfo implements Serializable { public void setValue(String value) { this.value = value; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ExtraInfo extraInfo = (ExtraInfo) o; + return Objects.equals(name, extraInfo.name) && + Objects.equals(typology, extraInfo.typology) && + Objects.equals(provenance, extraInfo.provenance) && + Objects.equals(trust, extraInfo.trust) && + Objects.equals(value, extraInfo.value); + } + + @Override + public int hashCode() { + return Objects.hash(name, typology, provenance, trust, value); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java index 06e5ca7dc..e3c80b120 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Journal.java @@ -1,6 +1,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; +import java.util.Objects; public class Journal implements Serializable { @@ -123,4 +124,28 @@ public class Journal implements Serializable { public void setDataInfo(DataInfo dataInfo) { this.dataInfo = dataInfo; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Journal journal = (Journal) o; + return Objects.equals(name, journal.name) && + Objects.equals(issnPrinted, journal.issnPrinted) && + Objects.equals(issnOnline, journal.issnOnline) && + Objects.equals(issnLinking, journal.issnLinking) && + Objects.equals(ep, journal.ep) && + Objects.equals(iss, journal.iss) && + Objects.equals(sp, journal.sp) && + Objects.equals(vol, journal.vol) && + Objects.equals(edition, journal.edition) && + Objects.equals(conferenceplace, journal.conferenceplace) && + Objects.equals(conferencedate, journal.conferencedate) && + Objects.equals(dataInfo, journal.dataInfo); + } + + @Override + public int hashCode() { + return Objects.hash(name, issnPrinted, issnOnline, issnLinking, ep, iss, sp, vol, edition, conferenceplace, conferencedate, dataInfo); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OAIProvenance.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OAIProvenance.java index bb97654b9..52ddf27d8 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OAIProvenance.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OAIProvenance.java @@ -1,6 +1,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; +import java.util.Objects; public class OAIProvenance implements Serializable { @@ -13,4 +14,17 @@ public class OAIProvenance implements Serializable { public void setOriginDescription(OriginDescription originDescription) { this.originDescription = originDescription; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + OAIProvenance that = (OAIProvenance) o; + return Objects.equals(originDescription, that.originDescription); + } + + @Override + public int hashCode() { + return Objects.hash(originDescription); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java index cc2ab8428..64217e5d8 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Oaf.java @@ -1,6 +1,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; +import java.util.Objects; public abstract class Oaf implements Serializable { @@ -43,4 +44,18 @@ public abstract class Oaf implements Serializable { return extractTrust(a).compareTo(extractTrust(b)); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Oaf oaf = (Oaf) o; + return Objects.equals(dataInfo, oaf.dataInfo) && + Objects.equals(lastupdatetimestamp, oaf.lastupdatetimestamp); + } + + @Override + public int hashCode() { + return Objects.hash(dataInfo, lastupdatetimestamp); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java index 8a86f822d..cd196243a 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OafEntity.java @@ -116,5 +116,24 @@ public abstract class OafEntity extends Oaf implements Serializable { return Arrays.stream(lists).filter(Objects::nonNull).flatMap(List::stream).distinct().collect(Collectors.toList()); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + OafEntity oafEntity = (OafEntity) o; + return Objects.equals(id, oafEntity.id) && + Objects.equals(originalId, oafEntity.originalId) && + Objects.equals(collectedfrom, oafEntity.collectedfrom) && + Objects.equals(pid, oafEntity.pid) && + Objects.equals(dateofcollection, oafEntity.dateofcollection) && + Objects.equals(dateoftransformation, oafEntity.dateoftransformation) && + Objects.equals(extraInfo, oafEntity.extraInfo) && + Objects.equals(oaiprovenance, oafEntity.oaiprovenance); + } + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), id, originalId, collectedfrom, pid, dateofcollection, dateoftransformation, extraInfo, oaiprovenance); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Organization.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Organization.java index b0dffb485..ab3730f52 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Organization.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Organization.java @@ -2,6 +2,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; import java.util.List; +import java.util.Objects; public class Organization extends OafEntity implements Serializable { @@ -188,4 +189,33 @@ public class Organization extends OafEntity implements Serializable { country = o.getCountry() != null && compareTrust(this, e)<0 ? o.getCountry() :country; mergeOAFDataInfo(o); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Organization that = (Organization) o; + return Objects.equals(legalshortname, that.legalshortname) && + Objects.equals(legalname, that.legalname) && + Objects.equals(alternativeNames, that.alternativeNames) && + Objects.equals(websiteurl, that.websiteurl) && + Objects.equals(logourl, that.logourl) && + Objects.equals(eclegalbody, that.eclegalbody) && + Objects.equals(eclegalperson, that.eclegalperson) && + Objects.equals(ecnonprofit, that.ecnonprofit) && + Objects.equals(ecresearchorganization, that.ecresearchorganization) && + Objects.equals(echighereducation, that.echighereducation) && + Objects.equals(ecinternationalorganizationeurinterests, that.ecinternationalorganizationeurinterests) && + Objects.equals(ecinternationalorganization, that.ecinternationalorganization) && + Objects.equals(ecenterprise, that.ecenterprise) && + Objects.equals(ecsmevalidated, that.ecsmevalidated) && + Objects.equals(ecnutscode, that.ecnutscode) && + Objects.equals(country, that.country); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), legalshortname, legalname, alternativeNames, websiteurl, logourl, eclegalbody, eclegalperson, ecnonprofit, ecresearchorganization, echighereducation, ecinternationalorganizationeurinterests, ecinternationalorganization, ecenterprise, ecsmevalidated, ecnutscode, country); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java index a990cee6f..8038242ca 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OriginDescription.java @@ -1,6 +1,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; +import java.util.Objects; public class OriginDescription implements Serializable { @@ -63,4 +64,22 @@ public class OriginDescription implements Serializable { public void setMetadataNamespace(String metadataNamespace) { this.metadataNamespace = metadataNamespace; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + OriginDescription that = (OriginDescription) o; + return Objects.equals(harvestDate, that.harvestDate) && + Objects.equals(altered, that.altered) && + Objects.equals(baseURL, that.baseURL) && + Objects.equals(identifier, that.identifier) && + Objects.equals(datestamp, that.datestamp) && + Objects.equals(metadataNamespace, that.metadataNamespace); + } + + @Override + public int hashCode() { + return Objects.hash(harvestDate, altered, baseURL, identifier, datestamp, metadataNamespace); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProduct.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProduct.java index 72bec727e..9d93d73d3 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProduct.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProduct.java @@ -2,6 +2,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; import java.util.List; +import java.util.Objects; public class OtherResearchProduct extends Result implements Serializable { @@ -46,4 +47,20 @@ public class OtherResearchProduct extends Result implements Serializable { tool = mergeLists(tool, o.getTool()); mergeOAFDataInfo(e); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + OtherResearchProduct that = (OtherResearchProduct) o; + return Objects.equals(contactperson, that.contactperson) && + Objects.equals(contactgroup, that.contactgroup) && + Objects.equals(tool, that.tool); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), contactperson, contactgroup, tool); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Project.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Project.java index 0bc11bb41..8d9b8fd2d 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Project.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Project.java @@ -2,6 +2,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; import java.util.List; +import java.util.Objects; public class Project extends OafEntity implements Serializable { @@ -299,4 +300,43 @@ public class Project extends OafEntity implements Serializable { fundedamount= p.getFundedamount()!= null && compareTrust(this,e)<0?p.getFundedamount():fundedamount; mergeOAFDataInfo(e); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Project project = (Project) o; + return Objects.equals(websiteurl, project.websiteurl) && + Objects.equals(code, project.code) && + Objects.equals(acronym, project.acronym) && + Objects.equals(title, project.title) && + Objects.equals(startdate, project.startdate) && + Objects.equals(enddate, project.enddate) && + Objects.equals(callidentifier, project.callidentifier) && + Objects.equals(keywords, project.keywords) && + Objects.equals(duration, project.duration) && + Objects.equals(ecsc39, project.ecsc39) && + Objects.equals(oamandatepublications, project.oamandatepublications) && + Objects.equals(ecarticle29_3, project.ecarticle29_3) && + Objects.equals(subjects, project.subjects) && + Objects.equals(fundingtree, project.fundingtree) && + Objects.equals(contracttype, project.contracttype) && + Objects.equals(optional1, project.optional1) && + Objects.equals(optional2, project.optional2) && + Objects.equals(jsonextrainfo, project.jsonextrainfo) && + Objects.equals(contactfullname, project.contactfullname) && + Objects.equals(contactfax, project.contactfax) && + Objects.equals(contactphone, project.contactphone) && + Objects.equals(contactemail, project.contactemail) && + Objects.equals(summary, project.summary) && + Objects.equals(currency, project.currency) && + Objects.equals(totalcost, project.totalcost) && + Objects.equals(fundedamount, project.fundedamount); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), websiteurl, code, acronym, title, startdate, enddate, callidentifier, keywords, duration, ecsc39, oamandatepublications, ecarticle29_3, subjects, fundingtree, contracttype, optional1, optional2, jsonextrainfo, contactfullname, contactfax, contactphone, contactemail, summary, currency, totalcost, fundedamount); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java index bb6990c1d..0e3291e16 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java @@ -1,6 +1,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; +import java.util.Objects; public class Publication extends Result implements Serializable { @@ -26,5 +27,17 @@ public class Publication extends Result implements Serializable { mergeOAFDataInfo(e); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Publication that = (Publication) o; + return Objects.equals(journal, that.journal); + } + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), journal); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java index 24a363bec..466062e8a 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Relation.java @@ -2,6 +2,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -80,4 +81,22 @@ public class Relation extends Oaf { .collect(Collectors.toList())); } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Relation relation = (Relation) o; + return Objects.equals(relType, relation.relType) && + Objects.equals(subRelType, relation.subRelType) && + Objects.equals(relClass, relation.relClass) && + Objects.equals(source, relation.source) && + Objects.equals(target, relation.target) && + Objects.equals(collectedFrom, relation.collectedFrom); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), relType, subRelType, relClass, source, target, collectedFrom); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java index 5cb04da5e..3c32d02c7 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java @@ -3,6 +3,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; import java.util.Comparator; import java.util.List; +import java.util.Objects; public abstract class Result extends OafEntity implements Serializable { @@ -278,4 +279,37 @@ public abstract class Result extends OafEntity implements Serializable { return a.size() > b.size() ? a : b; } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Result result = (Result) o; + return Objects.equals(author, result.author) && + Objects.equals(resulttype, result.resulttype) && + Objects.equals(language, result.language) && + Objects.equals(country, result.country) && + Objects.equals(subject, result.subject) && + Objects.equals(title, result.title) && + Objects.equals(relevantdate, result.relevantdate) && + Objects.equals(description, result.description) && + Objects.equals(dateofacceptance, result.dateofacceptance) && + Objects.equals(publisher, result.publisher) && + Objects.equals(embargoenddate, result.embargoenddate) && + Objects.equals(source, result.source) && + Objects.equals(fulltext, result.fulltext) && + Objects.equals(format, result.format) && + Objects.equals(contributor, result.contributor) && + Objects.equals(resourcetype, result.resourcetype) && + Objects.equals(coverage, result.coverage) && + Objects.equals(bestaccessright, result.bestaccessright) && + Objects.equals(context, result.context) && + Objects.equals(externalReference, result.externalReference) && + Objects.equals(instance, result.instance); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), author, resulttype, language, country, subject, title, relevantdate, description, dateofacceptance, publisher, embargoenddate, source, fulltext, format, contributor, resourcetype, coverage, bestaccessright, context, externalReference, instance); + } } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java index 7f835fdf8..655ea1665 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java @@ -2,6 +2,7 @@ package eu.dnetlib.dhp.schema.oaf; import java.io.Serializable; import java.util.List; +import java.util.Objects; public class Software extends Result implements Serializable { @@ -59,4 +60,21 @@ public class Software extends Result implements Serializable { mergeOAFDataInfo(e); } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + if (!super.equals(o)) return false; + Software software = (Software) o; + return Objects.equals(documentationUrl, software.documentationUrl) && + Objects.equals(license, software.license) && + Objects.equals(codeRepositoryUrl, software.codeRepositoryUrl) && + Objects.equals(programmingLanguage, software.programmingLanguage); + } + + @Override + public int hashCode() { + return Objects.hash(super.hashCode(), documentationUrl, license, codeRepositoryUrl, programmingLanguage); + } }