merging from stable_ids branch

This commit is contained in:
Claudio Atzori 2021-04-23 14:03:59 +02:00
parent f3b72d3b7c
commit b5b7da198a
25 changed files with 955 additions and 137 deletions

View File

@ -3,12 +3,13 @@ package eu.dnetlib.dhp.schema.common;
import java.util.Comparator;
import eu.dnetlib.dhp.schema.oaf.AccessRight;
import eu.dnetlib.dhp.schema.oaf.Qualifier;
public class LicenseComparator implements Comparator<Qualifier> {
public class AccessRightComparator<T extends Qualifier> implements Comparator<T> {
@Override
public int compare(Qualifier left, Qualifier right) {
public int compare(T left, T right) {
if (left == null && right == null)
return 0;

View File

@ -1,9 +1,7 @@
package eu.dnetlib.dhp.schema.common;
import eu.dnetlib.dhp.schema.oaf.DataInfo;
import eu.dnetlib.dhp.schema.oaf.KeyValue;
import eu.dnetlib.dhp.schema.oaf.Qualifier;
import eu.dnetlib.dhp.schema.oaf.*;
public class ModelConstants {
@ -11,21 +9,45 @@ public class ModelConstants {
public static final String ORCID_PENDING = "orcid_pending";
public static final String ORCID_CLASSNAME = "Open Researcher and Contributor ID";
public static final String CROSSREF_ID = "10|openaire____::081b82f96300b6a6e3d282bad31cb6e2";
public static final String DATACITE_ID = "10|openaire____::9e3be59865b2c1c335d32dae2fe7b254";
public static final String EUROPE_PUBMED_CENTRAL_ID = "10|opendoar____::8b6dd7db9af49e67306feb59a8bdc52c";
public static final String PUBMED_CENTRAL_ID = "10|opendoar____::eda80a3d5b344bc40f3bc04f65b7a357";
public static final String ARXIV_ID = "10|opendoar____::6f4922f45568161a8cdf4ad2299f6d23";
public static final String OPENORGS_NAME = "OpenOrgs Database";
// VOCABULARY VALUE
public static final String ACCESS_RIGHT_OPEN = "OPEN";
public static final String DNET_SUBJECT_TYPOLOGIES = "dnet:subject_classification_typologies";
public static final String DNET_RESULT_TYPOLOGIES = "dnet:result_typologies";
public static final String DNET_PUBLICATION_RESOURCE = "dnet:publication_resource";
public static final String DNET_ACCESS_MODES = "dnet:access_modes";
public static final String DNET_LANGUAGES = "dnet:languages";
public static final String DNET_PID_TYPES = "dnet:pid_types";
public static final String DNET_DATA_CITE_DATE = "dnet:dataCite_date";
public static final String DNET_DATACITE_DATE = "dnet:dataCite_date";
public static final String DNET_DATACITE_TITLE = "dnet:dataCite_title";
public static final String DNET_DATA_CITE_RESOURCE = "dnet:dataCite_resource";
public static final String DNET_PROVENANCE_ACTIONS = "dnet:provenanceActions";
public static final String DNET_COUNTRY_TYPE = "dnet:countries";
public static final String DNET_REVIEW_LEVELS = "dnet:review_levels";
public static final String DNET_PROGRAMMING_LANGUAGES = "dnet:programming_languages";
public static final String DNET_EXTERNAL_REF_TYPES = "dnet:externalReference_typologies";
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";
public static final String SYSIMPORT_ORCID_NO_DOI = "sysimport:actionset:orcidworks-no-doi";
public static final String USER_CLAIM = "user:claim";
public static final String HARVESTED = "Harvested";
public static final String PROVENANCE_DEDUP = "sysimport:dedup";
public static final Qualifier PROVENANCE_ACTION_SET_QUALIFIER = qualifier(
SYSIMPORT_ACTIONSET, SYSIMPORT_ACTIONSET, DNET_PROVENANCE_ACTIONS, DNET_PROVENANCE_ACTIONS);
public static final String DATASET_RESULTTYPE_CLASSID = "dataset";
public static final String PUBLICATION_RESULTTYPE_CLASSID = "publication";
@ -44,12 +66,12 @@ public class ModelConstants {
public static final String IS_SUPPLEMENTED_BY = "isSupplementedBy";
public static final String PART = "part";
public static final String IS_PART_OF = "isPartOf";
public static final String HAS_PARTS = "hasParts";
public static final String HAS_PART = "hasPart";
public static final String RELATIONSHIP = "relationship";
public static final String CITATION = "citation";
public static final String CITES = "cites";
public static final String IS_CITED_BY = "isCitedBy";
public static final String REVIEW = "review";
public static final String REVIEW = "review"; // subreltype
public static final String REVIEWS = "reviews";
public static final String IS_REVIEWED_BY = "isReviewedBy";
@ -73,7 +95,16 @@ public class ModelConstants {
public static final String IS_AUTHOR_INSTITUTION_OF = "isAuthorInstitutionOf";
public static final String HAS_AUTHOR_INSTITUTION = "hasAuthorInstitution";
public static final String ORG_ORG_RELTYPE = "organizationOrganization";
public static final String DEDUP = "dedup";
public static final String MERGES = "merges";
public static final String IS_MERGED_IN = "isMergedIn";
public static final String SIMILARITY = "similarity";
public static final String IS_SIMILAR_TO = "isSimilarTo";
public static final String IS_DIFFERENT_FROM = "isDifferentFrom";
public static final String UNKNOWN = "UNKNOWN";
public static final String NOT_AVAILABLE = "not available";
@ -102,11 +133,25 @@ public class ModelConstants {
SYSIMPORT_CROSSWALK_ENTITYREGISTRY, SYSIMPORT_CROSSWALK_ENTITYREGISTRY,
DNET_PROVENANCE_ACTIONS, DNET_PROVENANCE_ACTIONS);
public static final String UNKNOWN_REPOSITORY_ORIGINALID = "openaire____::1256f046-bf1f-4afc-8b47-d0b147148b18";
public static final KeyValue UNKNOWN_REPOSITORY = keyValue(
"10|openaire____::55045bd2a65019fd8e6741a755395c8c", "Unknown Repository");
public static final Qualifier UNKNOWN_COUNTRY = qualifier(UNKNOWN, "Unknown", DNET_COUNTRY_TYPE, DNET_COUNTRY_TYPE);
public static final Qualifier MAIN_TITLE_QUALIFIER = qualifier(
"main title", "main title", DNET_DATACITE_TITLE, DNET_DATACITE_TITLE);
public static final AccessRight OPEN_ACCESS_RIGHT() {
final AccessRight result = new AccessRight();
result.setClassid(ACCESS_RIGHT_OPEN);
result.setClassid(ACCESS_RIGHT_OPEN);
result.setSchemeid(ModelConstants.DNET_ACCESS_MODES);
result.setSchemename(ModelConstants.DNET_ACCESS_MODES);
return result;
}
private static Qualifier qualifier(
final String classid,
final String classname,

View File

@ -3,17 +3,19 @@ package eu.dnetlib.dhp.schema.common;
import static com.google.common.base.Preconditions.checkArgument;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.Date;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import org.apache.commons.codec.binary.Hex;
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Maps;
@ -114,67 +116,67 @@ public class ModelSupport {
relationInverseMap
.put(
"projectOrganization_participation_isParticipant", new RelationInverse()
.setRelation("isParticipant")
.setInverse("hasParticipant")
.setRelType("projectOrganization")
.setSubReltype("participation"));
.setRelation(ModelConstants.IS_PARTICIPANT)
.setInverse(ModelConstants.HAS_PARTICIPANT)
.setRelType(ModelConstants.PROJECT_ORGANIZATION)
.setSubReltype(ModelConstants.PARTICIPATION));
relationInverseMap
.put(
"projectOrganization_participation_hasParticipant", new RelationInverse()
.setInverse("isParticipant")
.setRelation("hasParticipant")
.setRelType("projectOrganization")
.setSubReltype("participation"));
.setInverse(ModelConstants.IS_PARTICIPANT)
.setRelation(ModelConstants.HAS_PARTICIPANT)
.setRelType(ModelConstants.PROJECT_ORGANIZATION)
.setSubReltype(ModelConstants.PARTICIPATION));
relationInverseMap
.put(
"resultOrganization_affiliation_hasAuthorInstitution", new RelationInverse()
.setRelation("hasAuthorInstitution")
.setInverse("isAuthorInstitutionOf")
.setRelType("resultOrganization")
.setSubReltype("affiliation"));
.setRelation(ModelConstants.HAS_AUTHOR_INSTITUTION)
.setInverse(ModelConstants.IS_AUTHOR_INSTITUTION_OF)
.setRelType(ModelConstants.RESULT_ORGANIZATION)
.setSubReltype(ModelConstants.AFFILIATION));
relationInverseMap
.put(
"resultOrganization_affiliation_isAuthorInstitutionOf", new RelationInverse()
.setInverse("hasAuthorInstitution")
.setRelation("isAuthorInstitutionOf")
.setRelType("resultOrganization")
.setSubReltype("affiliation"));
.setInverse(ModelConstants.HAS_AUTHOR_INSTITUTION)
.setRelation(ModelConstants.IS_AUTHOR_INSTITUTION_OF)
.setRelType(ModelConstants.RESULT_ORGANIZATION)
.setSubReltype(ModelConstants.AFFILIATION));
relationInverseMap
.put(
"organizationOrganization_dedup_merges", new RelationInverse()
.setRelation("merges")
.setInverse("isMergedIn")
.setRelType("organizationOrganization")
.setSubReltype("dedup"));
.setRelation(ModelConstants.MERGES)
.setInverse(ModelConstants.IS_MERGED_IN)
.setRelType(ModelConstants.ORG_ORG_RELTYPE)
.setSubReltype(ModelConstants.DEDUP));
relationInverseMap
.put(
"organizationOrganization_dedup_isMergedIn", new RelationInverse()
.setInverse("merges")
.setRelation("isMergedIn")
.setRelType("organizationOrganization")
.setSubReltype("dedup"));
.setInverse(ModelConstants.MERGES)
.setRelation(ModelConstants.IS_MERGED_IN)
.setRelType(ModelConstants.ORG_ORG_RELTYPE)
.setSubReltype(ModelConstants.DEDUP));
relationInverseMap
.put(
"organizationOrganization_dedupSimilarity_isSimilarTo", new RelationInverse()
.setInverse("isSimilarTo")
.setRelation("isSimilarTo")
.setRelType("organizationOrganization")
.setSubReltype("dedupSimilarity"));
.setInverse(ModelConstants.IS_SIMILAR_TO)
.setRelation(ModelConstants.IS_SIMILAR_TO)
.setRelType(ModelConstants.ORG_ORG_RELTYPE)
.setSubReltype(ModelConstants.DEDUP));
relationInverseMap
.put(
"resultProject_outcome_isProducedBy", new RelationInverse()
.setRelation("isProducedBy")
.setInverse("produces")
.setRelType("resultProject")
.setSubReltype("outcome"));
.setRelation(ModelConstants.IS_PRODUCED_BY)
.setInverse(ModelConstants.PRODUCES)
.setRelType(ModelConstants.RESULT_PROJECT)
.setSubReltype(ModelConstants.OUTCOME));
relationInverseMap
.put(
"resultProject_outcome_produces", new RelationInverse()
.setInverse("isProducedBy")
.setRelation("produces")
.setRelType("resultProject")
.setSubReltype("outcome"));
.setInverse(ModelConstants.IS_PRODUCED_BY)
.setRelation(ModelConstants.PRODUCES)
.setRelType(ModelConstants.RESULT_PROJECT)
.setSubReltype(ModelConstants.OUTCOME));
relationInverseMap
.put(
"projectPerson_contactPerson_isContact", new RelationInverse()
@ -199,115 +201,108 @@ public class ModelSupport {
relationInverseMap
.put(
"personPerson_dedup_merges", new RelationInverse()
.setInverse("isMergedIn")
.setRelation("merges")
.setInverse(ModelConstants.IS_MERGED_IN)
.setRelation(ModelConstants.MERGES)
.setRelType("personPerson")
.setSubReltype("dedup"));
.setSubReltype(ModelConstants.DEDUP));
relationInverseMap
.put(
"personPerson_dedup_isMergedIn", new RelationInverse()
.setInverse("merges")
.setRelation("isMergedIn")
.setInverse(ModelConstants.MERGES)
.setRelation(ModelConstants.IS_MERGED_IN)
.setRelType("personPerson")
.setSubReltype("dedup"));
.setSubReltype(ModelConstants.DEDUP));
relationInverseMap
.put(
"personPerson_dedupSimilarity_isSimilarTo", new RelationInverse()
.setInverse("isSimilarTo")
.setRelation("isSimilarTo")
.setInverse(ModelConstants.IS_SIMILAR_TO)
.setRelation(ModelConstants.IS_SIMILAR_TO)
.setRelType("personPerson")
.setSubReltype("dedupSimilarity"));
.setSubReltype(ModelConstants.DEDUP));
relationInverseMap
.put(
"datasourceOrganization_provision_isProvidedBy", new RelationInverse()
.setInverse("provides")
.setRelation("isProvidedBy")
.setRelType("datasourceOrganization")
.setSubReltype("provision"));
.setInverse(ModelConstants.PROVIDES)
.setRelation(ModelConstants.IS_PROVIDED_BY)
.setRelType(ModelConstants.DATASOURCE_ORGANIZATION)
.setSubReltype(ModelConstants.PROVISION));
relationInverseMap
.put(
"datasourceOrganization_provision_provides", new RelationInverse()
.setInverse("isProvidedBy")
.setRelation("provides")
.setRelType("datasourceOrganization")
.setSubReltype("provision"));
.setInverse(ModelConstants.IS_PROVIDED_BY)
.setRelation(ModelConstants.PROVIDES)
.setRelType(ModelConstants.DATASOURCE_ORGANIZATION)
.setSubReltype(ModelConstants.PROVISION));
relationInverseMap
.put(
"resultResult_similarity_hasAmongTopNSimilarDocuments", new RelationInverse()
.setInverse("isAmongTopNSimilarDocuments")
.setRelation("hasAmongTopNSimilarDocuments")
.setRelType("resultResult")
.setSubReltype("similarity"));
.setRelType(ModelConstants.RESULT_RESULT)
.setSubReltype(ModelConstants.SIMILARITY));
relationInverseMap
.put(
"resultResult_similarity_isAmongTopNSimilarDocuments", new RelationInverse()
.setInverse("hasAmongTopNSimilarDocuments")
.setRelation("isAmongTopNSimilarDocuments")
.setRelType("resultResult")
.setSubReltype("similarity"));
.setRelType(ModelConstants.RESULT_RESULT)
.setSubReltype(ModelConstants.SIMILARITY));
relationInverseMap
.put(
"resultResult_relationship_isRelatedTo", new RelationInverse()
.setInverse("isRelatedTo")
.setRelation("isRelatedTo")
.setRelType("resultResult")
.setSubReltype("relationship"));
relationInverseMap
.put(
"resultResult_similarity_isAmongTopNSimilarDocuments", new RelationInverse()
.setInverse("hasAmongTopNSimilarDocuments")
.setRelation("isAmongTopNSimilarDocuments")
.setRelType("resultResult")
.setSubReltype("similarity"));
.setInverse(ModelConstants.IS_RELATED_TO)
.setRelation(ModelConstants.IS_RELATED_TO)
.setRelType(ModelConstants.RESULT_RESULT)
.setSubReltype(ModelConstants.RELATIONSHIP));
relationInverseMap
.put(
"resultResult_supplement_isSupplementTo", new RelationInverse()
.setInverse("isSupplementedBy")
.setRelation("isSupplementTo")
.setRelType("resultResult")
.setSubReltype("supplement"));
.setInverse(ModelConstants.IS_SUPPLEMENTED_BY)
.setRelation(ModelConstants.IS_SUPPLEMENT_TO)
.setRelType(ModelConstants.RESULT_RESULT)
.setSubReltype(ModelConstants.SUPPLEMENT));
relationInverseMap
.put(
"resultResult_supplement_isSupplementedBy", new RelationInverse()
.setInverse("isSupplementTo")
.setRelation("isSupplementedBy")
.setRelType("resultResult")
.setSubReltype("supplement"));
.setInverse(ModelConstants.IS_SUPPLEMENT_TO)
.setRelation(ModelConstants.IS_SUPPLEMENTED_BY)
.setRelType(ModelConstants.RESULT_RESULT)
.setSubReltype(ModelConstants.SUPPLEMENT));
relationInverseMap
.put(
"resultResult_part_isPartOf", new RelationInverse()
.setInverse("hasPart")
.setRelation("isPartOf")
.setRelType("resultResult")
.setSubReltype("part"));
.setInverse(ModelConstants.HAS_PART)
.setRelation(ModelConstants.IS_PART_OF)
.setRelType(ModelConstants.RESULT_RESULT)
.setSubReltype(ModelConstants.PART));
relationInverseMap
.put(
"resultResult_part_hasPart", new RelationInverse()
.setInverse("isPartOf")
.setRelation("hasPart")
.setRelType("resultResult")
.setSubReltype("part"));
.setInverse(ModelConstants.IS_PART_OF)
.setRelation(ModelConstants.HAS_PART)
.setRelType(ModelConstants.RESULT_RESULT)
.setSubReltype(ModelConstants.PART));
relationInverseMap
.put(
"resultResult_dedup_merges", new RelationInverse()
.setInverse("isMergedIn")
.setRelation("merges")
.setRelType("resultResult")
.setSubReltype("dedup"));
.setInverse(ModelConstants.IS_MERGED_IN)
.setRelation(ModelConstants.MERGES)
.setRelType(ModelConstants.RESULT_RESULT)
.setSubReltype(ModelConstants.DEDUP));
relationInverseMap
.put(
"resultResult_dedup_isMergedIn", new RelationInverse()
.setInverse("merges")
.setRelation("isMergedIn")
.setRelType("resultResult")
.setSubReltype("dedup"));
.setInverse(ModelConstants.MERGES)
.setRelation(ModelConstants.IS_MERGED_IN)
.setRelType(ModelConstants.RESULT_RESULT)
.setSubReltype(ModelConstants.DEDUP));
relationInverseMap
.put(
"resultResult_dedupSimilarity_isSimilarTo", new RelationInverse()
.setInverse("isSimilarTo")
.setRelation("isSimilarTo")
.setRelType("resultResult")
.setSubReltype("dedupSimilarity"));
.setInverse(ModelConstants.IS_SIMILAR_TO)
.setRelation(ModelConstants.IS_SIMILAR_TO)
.setRelType(ModelConstants.RESULT_RESULT)
.setSubReltype(ModelConstants.DEDUP));
}
@ -381,6 +376,8 @@ public class ModelSupport {
Field.class,
GeoLocation.class,
Instance.class,
AccessRight.class,
OpenAccessRoute.class,
Journal.class,
KeyValue.class,
Oaf.class,
@ -480,6 +477,20 @@ public class ModelSupport {
return ((OafEntity) t).getId();
}
public static String md5(final String s) {
try {
final MessageDigest md = MessageDigest.getInstance("MD5");
md.update(s.getBytes(StandardCharsets.UTF_8));
return new String(Hex.encodeHex(md.digest()));
} catch (final NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
}
}
public static String generateIdentifier(final String originalId, final String nsPrefix) {
return String.format("%s::%s", nsPrefix, md5(originalId));
}
public static String oldest(String dateA, String dateB) throws ParseException {
if (StringUtils.isBlank(dateA)) {

View File

@ -0,0 +1,123 @@
package eu.dnetlib.dhp.schema.mdstore;
import java.io.Serializable;
import eu.dnetlib.dhp.schema.common.ModelSupport;
/**
* This class models a record in a Metadata store collection on HDFS
*/
public class MetadataRecord implements Serializable {
/** The D-Net Identifier associated to the record */
private String id;
/** The original Identifier of the record */
private String originalId;
/** The encoding of the record, should be JSON or XML */
private String encoding;
/**
* The information about the provenance of the record see @{@link Provenance} for the model of this information
*/
private Provenance provenance;
/** The content of the metadata */
private String body;
/** the date when the record has been stored */
private Long dateOfCollection;
/** the date when the record has been stored */
private Long dateOfTransformation;
public MetadataRecord() {
}
public MetadataRecord(
String originalId,
String encoding,
Provenance provenance,
String body,
Long dateOfCollection) {
this.originalId = originalId;
this.encoding = encoding;
this.provenance = provenance;
this.body = body;
this.dateOfCollection = dateOfCollection;
this.id = ModelSupport.generateIdentifier(originalId, this.provenance.getNsPrefix());
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getOriginalId() {
return originalId;
}
public void setOriginalId(String originalId) {
this.originalId = originalId;
}
public String getEncoding() {
return encoding;
}
public void setEncoding(String encoding) {
this.encoding = encoding;
}
public Provenance getProvenance() {
return provenance;
}
public void setProvenance(Provenance provenance) {
this.provenance = provenance;
}
public String getBody() {
return body;
}
public void setBody(String body) {
this.body = body;
}
public Long getDateOfCollection() {
return dateOfCollection;
}
public void setDateOfCollection(Long dateOfCollection) {
this.dateOfCollection = dateOfCollection;
}
public Long getDateOfTransformation() {
return dateOfTransformation;
}
public void setDateOfTransformation(Long dateOfTransformation) {
this.dateOfTransformation = dateOfTransformation;
}
@Override
public boolean equals(Object o) {
if (!(o instanceof MetadataRecord)) {
return false;
}
return ((MetadataRecord) o).getId().equalsIgnoreCase(id);
}
@Override
public int hashCode() {
return id.hashCode();
}
}

View File

@ -0,0 +1,52 @@
package eu.dnetlib.dhp.schema.mdstore;
import java.io.Serializable;
/**
* @author Sandro La Bruzzo
* <p>
* Provenace class models the provenance of the record in the metadataStore It contains the identifier and the
* name of the datasource that gives the record
*/
public class Provenance implements Serializable {
private String datasourceId;
private String datasourceName;
private String nsPrefix;
public Provenance() {
}
public Provenance(String datasourceId, String datasourceName, String nsPrefix) {
this.datasourceId = datasourceId;
this.datasourceName = datasourceName;
this.nsPrefix = nsPrefix;
}
public String getDatasourceId() {
return datasourceId;
}
public void setDatasourceId(String datasourceId) {
this.datasourceId = datasourceId;
}
public String getDatasourceName() {
return datasourceName;
}
public void setDatasourceName(String datasourceName) {
this.datasourceName = datasourceName;
}
public String getNsPrefix() {
return nsPrefix;
}
public void setNsPrefix(String nsPrefix) {
this.nsPrefix = nsPrefix;
}
}

View File

@ -0,0 +1,48 @@
package eu.dnetlib.dhp.schema.oaf;
import java.util.Optional;
/**
* This class models the access rights of research products.
*/
public class AccessRight extends Qualifier {
private OpenAccessRoute openAccessRoute;
public OpenAccessRoute getOpenAccessRoute() {
return openAccessRoute;
}
public void setOpenAccessRoute(OpenAccessRoute openAccessRoute) {
this.openAccessRoute = openAccessRoute;
}
public String toComparableString() {
String s = super.toComparableString();
return Optional
.ofNullable(getOpenAccessRoute())
.map(x -> s + "::" + x.toString())
.orElse(s);
}
@Override
public int hashCode() {
return toComparableString().hashCode();
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
Qualifier other = (Qualifier) obj;
return toComparableString().equals(other.toComparableString());
}
}

View File

@ -12,6 +12,7 @@ public class Author implements Serializable {
private String surname;
// START WITH 1
private Integer rank;
private List<StructuredProperty> pid;

View File

@ -2,6 +2,7 @@
package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
public class ExternalReference implements Serializable {
@ -11,12 +12,12 @@ public class ExternalReference implements Serializable {
// title
private String label;
// alternative labels
private List<String> alternateLabel;
// text()
private String url;
// ?? not mapped yet ??
private String description;
// type
private Qualifier qualifier;
@ -45,6 +46,14 @@ public class ExternalReference implements Serializable {
this.label = label;
}
public List<String> getAlternateLabel() {
return alternateLabel;
}
public void setAlternateLabel(List<String> alternateLabel) {
this.alternateLabel = alternateLabel;
}
public String getUrl() {
return url;
}
@ -53,14 +62,6 @@ public class ExternalReference implements Serializable {
this.url = url;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public Qualifier getQualifier() {
return qualifier;
}
@ -103,7 +104,6 @@ public class ExternalReference implements Serializable {
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)
@ -114,6 +114,7 @@ public class ExternalReference implements Serializable {
public int hashCode() {
return Objects
.hash(
sitename, label, url, description, qualifier, refidentifier, query, dataInfo);
sitename, label, url, qualifier, refidentifier, query, dataInfo);
}
}

View File

@ -8,7 +8,7 @@ public class Instance implements Serializable {
private Field<String> license;
private Qualifier accessright;
private AccessRight accessright;
private Qualifier instancetype;
@ -21,6 +21,10 @@ public class Instance implements Serializable {
private KeyValue collectedfrom;
private List<StructuredProperty> pid;
private List<StructuredProperty> alternateIdentifier;
private Field<String> dateofacceptance;
// ( article | book ) processing charges. Defined here to cope with possible wrongly typed
@ -41,11 +45,11 @@ public class Instance implements Serializable {
this.license = license;
}
public Qualifier getAccessright() {
public AccessRight getAccessright() {
return accessright;
}
public void setAccessright(Qualifier accessright) {
public void setAccessright(AccessRight accessright) {
this.accessright = accessright;
}
@ -89,6 +93,14 @@ public class Instance implements Serializable {
this.collectedfrom = collectedfrom;
}
public List<StructuredProperty> getPid() {
return pid;
}
public void setPid(List<StructuredProperty> pid) {
this.pid = pid;
}
public Field<String> getDateofacceptance() {
return dateofacceptance;
}
@ -97,6 +109,14 @@ public class Instance implements Serializable {
this.dateofacceptance = dateofacceptance;
}
public List<StructuredProperty> getAlternateIdentifier() {
return alternateIdentifier;
}
public void setAlternateIdentifier(List<StructuredProperty> alternateIdentifier) {
this.alternateIdentifier = alternateIdentifier;
}
public Field<String> getProcessingchargeamount() {
return processingchargeamount;
}
@ -149,4 +169,5 @@ public class Instance implements Serializable {
return toComparableString().equals(other.toComparableString());
}
}

View File

@ -0,0 +1,13 @@
package eu.dnetlib.dhp.schema.oaf;
/**
* This Enum models the OpenAccess status, currently including only the values from Unpaywall
*
* https://support.unpaywall.org/support/solutions/articles/44001777288-what-do-the-types-of-oa-status-green-gold-hybrid-and-bronze-mean-
*/
public enum OpenAccessRoute {
gold, green, hybrid, bronze
}

View File

@ -137,7 +137,10 @@ public class Relation extends Oaf {
try {
setValidationDate(ModelSupport.oldest(getValidationDate(), r.getValidationDate()));
} catch (ParseException e) {
throw new IllegalArgumentException(String.format("invalid validation date format in relation [s:%s, t:%s]: %s", getSource(), getTarget(), getValidationDate()));
throw new IllegalArgumentException(String
.format(
"invalid validation date format in relation [s:%s, t:%s]: %s", getSource(), getTarget(),
getValidationDate()));
}
super.mergeFrom(r);

View File

@ -2,12 +2,11 @@
package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
import eu.dnetlib.dhp.schema.common.LicenseComparator;
import eu.dnetlib.dhp.schema.common.AccessRightComparator;
public class Result extends OafEntity implements Serializable {
@ -248,7 +247,7 @@ public class Result extends OafEntity implements Serializable {
instance = mergeLists(instance, r.getInstance());
if (r.getBestaccessright() != null
&& new LicenseComparator().compare(r.getBestaccessright(), bestaccessright) < 0)
&& new AccessRightComparator().compare(r.getBestaccessright(), bestaccessright) < 0)
bestaccessright = r.getBestaccessright();
if (r.getResulttype() != null && compareTrust(this, r) < 0)

View File

@ -2,6 +2,13 @@
package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable;
import java.util.Optional;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.apache.commons.lang3.StringUtils;
import com.google.common.base.Joiner;
public class StructuredProperty implements Serializable {
@ -36,7 +43,12 @@ public class StructuredProperty implements Serializable {
}
public String toComparableString() {
return value != null ? value.toLowerCase() : "";
return Stream
.of(
getQualifier().toComparableString(),
Optional.ofNullable(getValue()).map(String::toLowerCase).orElse(""))
.filter(StringUtils::isNotBlank)
.collect(Collectors.joining("||"));
}
@Override

View File

@ -0,0 +1,79 @@
package eu.dnetlib.dhp.schema.orcid;
import java.io.Serializable;
public class AuthorHistory implements Serializable {
private String creationMethod;
private String completionDate;
private String submissionDate;
private String lastModifiedDate;
private boolean claimed;
private String deactivationDate;
private boolean verifiedEmail;
private boolean verifiedPrimaryEmail;
public String getCreationMethod() {
return creationMethod;
}
public void setCreationMethod(String creationMethod) {
this.creationMethod = creationMethod;
}
public String getCompletionDate() {
return completionDate;
}
public void setCompletionDate(String completionDate) {
this.completionDate = completionDate;
}
public String getSubmissionDate() {
return submissionDate;
}
public void setSubmissionDate(String submissionDate) {
this.submissionDate = submissionDate;
}
public String getLastModifiedDate() {
return lastModifiedDate;
}
public void setLastModifiedDate(String lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
public boolean isClaimed() {
return claimed;
}
public void setClaimed(boolean claimed) {
this.claimed = claimed;
}
public String getDeactivationDate() {
return deactivationDate;
}
public void setDeactivationDate(String deactivationDate) {
this.deactivationDate = deactivationDate;
}
public boolean isVerifiedEmail() {
return verifiedEmail;
}
public void setVerifiedEmail(boolean verifiedEmail) {
this.verifiedEmail = verifiedEmail;
}
public boolean isVerifiedPrimaryEmail() {
return verifiedPrimaryEmail;
}
public void setVerifiedPrimaryEmail(boolean verifiedPrimaryEmail) {
this.verifiedPrimaryEmail = verifiedPrimaryEmail;
}
}

View File

@ -0,0 +1,25 @@
package eu.dnetlib.dhp.schema.orcid;
import java.io.Serializable;
public class AuthorSummary extends OrcidData implements Serializable {
private AuthorData authorData;
private AuthorHistory authorHistory;
public AuthorData getAuthorData() {
return authorData;
}
public void setAuthorData(AuthorData authorData) {
this.authorData = authorData;
}
public AuthorHistory getAuthorHistory() {
return authorHistory;
}
public void setAuthorHistory(AuthorHistory authorHistory) {
this.authorHistory = authorHistory;
}
}

View File

@ -0,0 +1,58 @@
package eu.dnetlib.dhp.schema.orcid;
import java.io.Serializable;
import eu.dnetlib.dhp.schema.orcid.AuthorData;
/**
* This class models the data related to a contributor, that are retrieved from an orcid publication
*/
public class Contributor extends AuthorData implements Serializable {
private String sequence;
private String role;
private transient boolean simpleMatch;
private transient Double score;
private transient boolean bestMatch;
public String getSequence() {
return sequence;
}
public void setSequence(String sequence) {
this.sequence = sequence;
}
public String getRole() {
return role;
}
public void setRole(String role) {
this.role = role;
}
public boolean isSimpleMatch() {
return simpleMatch;
}
public void setSimpleMatch(boolean simpleMatch) {
this.simpleMatch = simpleMatch;
}
public Double getScore() {
return score;
}
public void setScore(Double score) {
this.score = score;
}
public boolean isBestMatch() {
return bestMatch;
}
public void setBestMatch(boolean bestMatch) {
this.bestMatch = bestMatch;
}
}

View File

@ -0,0 +1,38 @@
package eu.dnetlib.dhp.schema.orcid;
import java.io.Serializable;
/**
* This class models the data related to external id, that are retrieved from an orcid publication
*/
public class ExternalId implements Serializable {
private String type;
private String value;
private String relationShip;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getRelationShip() {
return relationShip;
}
public void setRelationShip(String relationShip) {
this.relationShip = relationShip;
}
}

View File

@ -0,0 +1,34 @@
package eu.dnetlib.dhp.schema.orcid;
import java.io.Serializable;
public class OrcidData implements Serializable {
protected String base64CompressData;
protected String statusCode;
protected String downloadDate;
public String getBase64CompressData() {
return base64CompressData;
}
public void setBase64CompressData(String base64CompressData) {
this.base64CompressData = base64CompressData;
}
public String getStatusCode() {
return statusCode;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public String getDownloadDate() {
return downloadDate;
}
public void setDownloadDate(String downloadDate) {
this.downloadDate = downloadDate;
}
}

View File

@ -0,0 +1,38 @@
package eu.dnetlib.dhp.schema.orcid;
import java.io.Serializable;
/**
* This class models the data related to a publication date, that are retrieved from an orcid publication
*/
public class PublicationDate implements Serializable {
private String year;
private String month;
private String day;
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
public String getMonth() {
return month;
}
public void setMonth(String month) {
this.month = month;
}
public String getDay() {
return day;
}
public void setDay(String day) {
this.day = day;
}
}

View File

@ -0,0 +1,79 @@
package eu.dnetlib.dhp.schema.orcid;
import java.io.Serializable;
public class Summary implements Serializable {
private String creationMethod;
private String completionDate;
private String submissionDate;
private String lastModifiedDate;
private boolean claimed;
private String deactivationDate;
private boolean verifiedEmail;
private boolean verifiedPrimaryEmail;
public String getCreationMethod() {
return creationMethod;
}
public void setCreationMethod(String creationMethod) {
this.creationMethod = creationMethod;
}
public String getCompletionDate() {
return completionDate;
}
public void setCompletionDate(String completionDate) {
this.completionDate = completionDate;
}
public String getSubmissionDate() {
return submissionDate;
}
public void setSubmissionDate(String submissionDate) {
this.submissionDate = submissionDate;
}
public String getLastModifiedDate() {
return lastModifiedDate;
}
public void setLastModifiedDate(String lastModifiedDate) {
this.lastModifiedDate = lastModifiedDate;
}
public boolean isClaimed() {
return claimed;
}
public void setClaimed(boolean claimed) {
this.claimed = claimed;
}
public String getDeactivationDate() {
return deactivationDate;
}
public void setDeactivationDate(String deactivationDate) {
this.deactivationDate = deactivationDate;
}
public boolean isVerifiedEmail() {
return verifiedEmail;
}
public void setVerifiedEmail(boolean verifiedEmail) {
this.verifiedEmail = verifiedEmail;
}
public boolean isVerifiedPrimaryEmail() {
return verifiedPrimaryEmail;
}
public void setVerifiedPrimaryEmail(boolean verifiedPrimaryEmail) {
this.verifiedPrimaryEmail = verifiedPrimaryEmail;
}
}

View File

@ -0,0 +1,16 @@
package eu.dnetlib.dhp.schema.orcid;
import java.io.Serializable;
public class Work extends OrcidData implements Serializable {
WorkDetail workDetail;
public WorkDetail getWorkDetail() {
return workDetail;
}
public void setWorkDetail(WorkDetail workDetail) {
this.workDetail = workDetail;
}
}

View File

@ -0,0 +1,109 @@
package eu.dnetlib.dhp.schema.orcid;
import java.io.Serializable;
import java.util.List;
import eu.dnetlib.dhp.schema.orcid.Contributor;
import eu.dnetlib.dhp.schema.orcid.ExternalId;
import eu.dnetlib.dhp.schema.orcid.OrcidData;
import eu.dnetlib.dhp.schema.orcid.PublicationDate;
/**
* This class models the data that are retrieved from orcid publication
*/
public class WorkDetail implements Serializable {
private String oid;
private String id;
private String sourceName;
private String type;
private List<String> titles;
private List<String> urls;
List<ExternalId> extIds;
List<PublicationDate> publicationDates;
List<Contributor> contributors;
public String getOid() {
return oid;
}
public void setOid(String oid) {
this.oid = oid;
}
public String getErrorCode() {
return errorCode;
}
public void setErrorCode(String errorCode) {
this.errorCode = errorCode;
}
private String errorCode;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public List<String> getTitles() {
return titles;
}
public void setTitles(List<String> titles) {
this.titles = titles;
}
public String getSourceName() {
return sourceName;
}
public void setSourceName(String sourceName) {
this.sourceName = sourceName;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public List<String> getUrls() {
return urls;
}
public void setUrls(List<String> urls) {
this.urls = urls;
}
public List<ExternalId> getExtIds() {
return extIds;
}
public void setExtIds(List<ExternalId> extIds) {
this.extIds = extIds;
}
public List<PublicationDate> getPublicationDates() {
return publicationDates;
}
public void setPublicationDates(List<PublicationDate> publicationDates) {
this.publicationDates = publicationDates;
}
public List<Contributor> getContributors() {
return contributors;
}
public void setContributors(List<Contributor> contributors) {
this.contributors = contributors;
}
}

View File

@ -1,6 +1,7 @@
package eu.dnetlib.dhp.schema.scholexplorer
import eu.dnetlib.dhp.schema.oaf.{DataInfo, Field, KeyValue, Qualifier, StructuredProperty}
import eu.dnetlib.dhp.schema.common.ModelConstants
import eu.dnetlib.dhp.schema.oaf.{AccessRight, DataInfo, Field, KeyValue, Qualifier, StructuredProperty}
object OafUtils {
@ -15,13 +16,13 @@ object OafUtils {
}
def generateDataInfo(trust: String = "0.9", invisibile: Boolean = false): DataInfo = {
def generateDataInfo(trust: String = "0.9", invisible: Boolean = false): DataInfo = {
val di = new DataInfo
di.setDeletedbyinference(false)
di.setInferred(false)
di.setInvisible(false)
di.setInvisible(invisible)
di.setTrust(trust)
di.setProvenanceaction(createQualifier("sysimport:actionset", "dnet:provenanceActions"))
di.setProvenanceaction(createQualifier(ModelConstants.SYSIMPORT_ACTIONSET, ModelConstants.DNET_PROVENANCE_ACTIONS))
di
}
@ -39,6 +40,15 @@ object OafUtils {
q
}
def createAccessRight(classId: String, className: String, schemeId: String, schemeName: String): AccessRight = {
val accessRight: AccessRight = new AccessRight
accessRight.setClassid(classId)
accessRight.setClassname(className)
accessRight.setSchemeid(schemeId)
accessRight.setSchemename(schemeName)
accessRight
}
def asField[T](value: T): Field[T] = {
val tmp = new Field[T]

View File

@ -10,6 +10,7 @@ import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.ObjectMapper;
import eu.dnetlib.dhp.schema.common.ModelConstants;
import eu.dnetlib.dhp.schema.oaf.Relation;
/** @author claudio.atzori */
@ -21,9 +22,9 @@ public class AtomicActionTest {
Relation rel = new Relation();
rel.setSource("1");
rel.setTarget("2");
rel.setRelType("resultResult");
rel.setSubRelType("dedup");
rel.setRelClass("merges");
rel.setRelType(ModelConstants.RESULT_RESULT);
rel.setSubRelType(ModelConstants.DEDUP);
rel.setRelClass(ModelConstants.MERGES);
AtomicAction aa1 = new AtomicAction(Relation.class, rel);

View File

@ -12,6 +12,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import eu.dnetlib.dhp.schema.common.ModelConstants;
import eu.dnetlib.dhp.schema.oaf.Qualifier;
import eu.dnetlib.dhp.schema.oaf.StructuredProperty;
@ -20,7 +21,7 @@ public class DLItest {
@Test
public void testMergePublication() throws JsonProcessingException {
DLIPublication a1 = new DLIPublication();
a1.setPid(Arrays.asList(createSP("123456", "pdb", "dnet:pid_types")));
a1.setPid(Arrays.asList(createSP("123456", "pdb", ModelConstants.DNET_PID_TYPES)));
a1.setTitle(Collections.singletonList(createSP("Un Titolo", "title", "dnetTitle")));
a1.setDlicollectedfrom(Arrays.asList(createCollectedFrom("znd", "Zenodo", "complete")));
a1.setCompletionStatus("complete");
@ -30,8 +31,8 @@ public class DLItest {
.setPid(
Arrays
.asList(
createSP("10.11", "doi", "dnet:pid_types"),
createSP("123456", "pdb", "dnet:pid_types")));
createSP("10.11", "doi", ModelConstants.DNET_PID_TYPES),
createSP("123456", "pdb", ModelConstants.DNET_PID_TYPES)));
a.setTitle(Collections.singletonList(createSP("A Title", "title", "dnetTitle")));
a
.setDlicollectedfrom(