diff --git a/CHANGES.md b/CHANGES.md
index 7cfb486..6df1fa4 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -2,41 +2,42 @@
## Changelog
-| **Version** | **Changes** | **Readiness** |
-|-------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
-| 3.17.1 | [Graph model]
- added fulltext field on the instance level.
- added extra organization specific PID types
| beta |
-| 3.16.0 | [Graph model] - added entity level measures.
| beta |
-| 3.15.0 | [Graph model] - added w3id as PID type, with ROHub as authority.
| beta |
-| 3.14.0 | [Graph model] - introduced specific type for result.subject
| beta |
-| 2.13.0 | [Scholexplorer] - update swagger annotation jar version to be compatible with new implementation of openAPI ui
| beta |
-| 2.12.1 | [Graph model] - added field oafEntity.eoscifguidelines
| production |
-| 2.12.0 | [Graph model] - Introducing EOSC Services as datasources
| production |
-| 2.11.33 | [Scholexplorer] - Moved Scholix API Data model into dhp-schemas
- implementation of the compareTo method on Scholix objects and all model properties
- Unit Test to verify that compareTo works on different case
| production |
-| 2.10.31 | [Minor] NPE checks | production |
-| 2.10.30 | [Minor] added comparator for refereed field instances | production |
-| 2.10.29 | [Merge Result] merge logics changed to consider invisble in dataInfo | production |
-| 2.10.28 | [Graph Model] Added APC information at the level of the result | production |
-| 2.10.27 | [Graph Model] change name and id of OpenAPC datasource | production |
-| 2.10.26 | [Graph Model] OpenAIRE ids of the delegated authorities and enrichment providers in the identifier creation strategy | production |
-| 2.10.25 | [Graph model]implemented enrichment on Result specializing in the method mergefrom. | production |
-| 2.10.24 | [Graph model]added utility method and constants for checking weather is an OafEntity represents an enrichment. | production |
-| 2.9.24 | [Dump model]change the names of the classes to be able to automatically create the json schema with specific descriptions | production |
-| 2.9.23 | [Graph model]
Added Instance.measures field, allowing to maintain the association between them and the individual result instance[Dump model]added json schemas | production |
-| 2.8.22 | [Graph model]
minor: added serializable to the Measures model class[Dump model]added dedicated BestAccessRight class, used at the result level instead of AccessRight | production |
-| 2.8.21 | [Graph model]
added the following relation terms Describes/IsDescribedBy, IsMetadataFor/IsMetadataOf, HasAssociationWith/HasAssociationWith, IsRequiredBy/Requires. All these are used in combination with the relation subRelType "relationship" | production |
-| 2.8.20 | [Graph model]
added constants declaring the values used for hierarchical relationships among the organizations IsParentOf / IsChildOf | production |
-| 2.7.18-19 | [Dump model]
include validation info in relations
[Graph model]
added constants declaring vocabulary names for relation fields | production |
-| 2.7.17 | [Dump model]
aligned the graph dump schema to mirror the changes in the model
1. Added openaccessroute at the level of the instance inside the AccessRight element;
2. Added pid and the alternate identifiers at the level of the instance;
3. Added the bipFinder measures | production |
-| 2.7.16 | [Graph model]
Updated the casing of the following terms (`relation.relClass`):
1. `isRelatedTo -> IsRelatedTo`
Added the following `relClass` terms:
1. `IsAmongTopNSimilarDocuments`
2. `HasAmongTopNSimilarDocuments` | production |
-| 2.7.15 | 1. added support for delegated authorities
2. fixed regex for DOI cleaning | production |
-| 2.7.14 | [Graph model]
Relation types are now inspired by the Datacite definitions https://schema.datacite.org/meta/kernel-4.4/doc/DataCite-MetadataKernel_v4.4.pdf
The changes involve the values stored in `relation.subRelType` and `relation.relClass`:
Updated the casing of the following terms (`relation.relClass`):
1. `isSupplementTo -> IsSupplementTo` / `isSupplementedBy -> IsSupplementedBy`
2. `isPartOf -> IsPartOf` / `hasPart -> HasPart`
3. `cites -> Cites` / `isCitedBy -> IsCitedBy`
4. `reviews -> Reviews` / `isReviewedBy -> IsReviewedBy`
Added the following terms [`subRelType: relClass / relClass (inverse)`]:
1. `relationship: References / IsReferencedBy`
2. `relationship: IsIdenticalTo`
3. `relationship: IsContinuedBy / Continues`
4. `relationship: IsDocumentedBy / Documents`
5. `relationship: Documents / IsDocumentedBy`
6. `relationship: IsCompiledBy / Compiles`
7. `version: IsPreviousVersionOf / IsNewVersionOf`
8. `version: IsSourceOf / IsDerivedFrom`
9. `version: IsVariantFormOf / IsOriginalFormOf`
10. `version: IsObsoletedBy / Obsoletes`
11. `version: IsVersionOf / HasVersion` | production |
-| 2.6.14 | [Scholexplorer]
1. Added model classes for Scholexplorer, package `eu.dnetlib.dhp.schema.sx` | production |
-| 2.6.13 | 1. `Result.mergeFrom` handles field `dateOfAcceptance` | production |
-| 2.5.12 | 1. delegating the date parsing to https://github.com/sisyphsu/dateparser | production |
-| 2.5.[11-9] | 1. support for more date formats
2. enable the possibility to extend the date formats used to parse `Relation.validationDate` | production |
-| 2.4.8 | 1. added constant for ORCID datasource name | production |
-| 2.4.7 | refactoring | production |
-| 2.3.6 | [Aggregation]
1. introduced MetadataStoreManager (MdSM) model classes | production |
-| 2.2.5 | [Graph model]
1. introduced fields `Instance.pid` and `Instance.alternateIdentifier`
2. `LicenseComparator` renamed as `AccessRightComparator`
3. introduced `AccessRight` model class defining the `OpenAccessRoute` field to keep track of the OpenAccess color at the `Instance` level
4. `ExternalReference` cleanup (removed description, added alternateLabel(s))
5. added several ModelConstants
[Aggregation]
7. introduced MDStore record model classes
8. Introduced ORCID specific model classes | production |
-| 2.2.4 | 1. ORCID specific model classes backported in the version used in PROD
2. added constant for dnet:externalReference_typologies
3. added constant for ORCID datasource name
4. `Result.mergeFrom` handles field `dateOfAcceptance` | production |
+| **Version** | **Changes** | **Readiness** |
+|-------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|
+| 4.17.1 | [Graph model] - added InstaceTypeMapping field on the instance level.
- new result level fields to support the activities in the Irish tender `isGreen`, `openAccessColor`, `isInDiamondJournal`, `publiclyFunded`
| beta |
+| 3.17.1 | [Graph model] - added fulltext field on the instance level.
- added extra organization specific PID types
| production |
+| 3.16.0 | [Graph model] - added entity level measures.
| production |
+| 3.15.0 | [Graph model] - added w3id as PID type, with ROHub as authority.
| production |
+| 3.14.0 | [Graph model] - introduced specific type for result.subject
| production |
+| 2.13.0 | [Scholexplorer] - update swagger annotation jar version to be compatible with new implementation of openAPI ui
| production |
+| 2.12.1 | [Graph model] - added field oafEntity.eoscifguidelines
| production |
+| 2.12.0 | [Graph model] - Introducing EOSC Services as datasources
| production |
+| 2.11.33 | [Scholexplorer] - Moved Scholix API Data model into dhp-schemas
- implementation of the compareTo method on Scholix objects and all model properties
- Unit Test to verify that compareTo works on different case
| production |
+| 2.10.31 | [Minor] NPE checks | production |
+| 2.10.30 | [Minor] added comparator for refereed field instances | production |
+| 2.10.29 | [Merge Result] merge logics changed to consider invisble in dataInfo | production |
+| 2.10.28 | [Graph Model] Added APC information at the level of the result | production |
+| 2.10.27 | [Graph Model] change name and id of OpenAPC datasource | production |
+| 2.10.26 | [Graph Model] OpenAIRE ids of the delegated authorities and enrichment providers in the identifier creation strategy | production |
+| 2.10.25 | [Graph model]implemented enrichment on Result specializing in the method mergefrom. | production |
+| 2.10.24 | [Graph model]added utility method and constants for checking weather is an OafEntity represents an enrichment. | production |
+| 2.9.24 | [Dump model]change the names of the classes to be able to automatically create the json schema with specific descriptions | production |
+| 2.9.23 | [Graph model]
Added Instance.measures field, allowing to maintain the association between them and the individual result instance[Dump model]added json schemas | production |
+| 2.8.22 | [Graph model]
minor: added serializable to the Measures model class[Dump model]added dedicated BestAccessRight class, used at the result level instead of AccessRight | production |
+| 2.8.21 | [Graph model]
added the following relation terms Describes/IsDescribedBy, IsMetadataFor/IsMetadataOf, HasAssociationWith/HasAssociationWith, IsRequiredBy/Requires. All these are used in combination with the relation subRelType "relationship" | production |
+| 2.8.20 | [Graph model]
added constants declaring the values used for hierarchical relationships among the organizations IsParentOf / IsChildOf | production |
+| 2.7.18-19 | [Dump model]
include validation info in relations
[Graph model]
added constants declaring vocabulary names for relation fields | production |
+| 2.7.17 | [Dump model]
aligned the graph dump schema to mirror the changes in the model
1. Added openaccessroute at the level of the instance inside the AccessRight element;
2. Added pid and the alternate identifiers at the level of the instance;
3. Added the bipFinder measures | production |
+| 2.7.16 | [Graph model]
Updated the casing of the following terms (`relation.relClass`):
1. `isRelatedTo -> IsRelatedTo`
Added the following `relClass` terms:
1. `IsAmongTopNSimilarDocuments`
2. `HasAmongTopNSimilarDocuments` | production |
+| 2.7.15 | 1. added support for delegated authorities
2. fixed regex for DOI cleaning | production |
+| 2.7.14 | [Graph model]
Relation types are now inspired by the Datacite definitions https://schema.datacite.org/meta/kernel-4.4/doc/DataCite-MetadataKernel_v4.4.pdf
The changes involve the values stored in `relation.subRelType` and `relation.relClass`:
Updated the casing of the following terms (`relation.relClass`):
1. `isSupplementTo -> IsSupplementTo` / `isSupplementedBy -> IsSupplementedBy`
2. `isPartOf -> IsPartOf` / `hasPart -> HasPart`
3. `cites -> Cites` / `isCitedBy -> IsCitedBy`
4. `reviews -> Reviews` / `isReviewedBy -> IsReviewedBy`
Added the following terms [`subRelType: relClass / relClass (inverse)`]:
1. `relationship: References / IsReferencedBy`
2. `relationship: IsIdenticalTo`
3. `relationship: IsContinuedBy / Continues`
4. `relationship: IsDocumentedBy / Documents`
5. `relationship: Documents / IsDocumentedBy`
6. `relationship: IsCompiledBy / Compiles`
7. `version: IsPreviousVersionOf / IsNewVersionOf`
8. `version: IsSourceOf / IsDerivedFrom`
9. `version: IsVariantFormOf / IsOriginalFormOf`
10. `version: IsObsoletedBy / Obsoletes`
11. `version: IsVersionOf / HasVersion` | production |
+| 2.6.14 | [Scholexplorer]
1. Added model classes for Scholexplorer, package `eu.dnetlib.dhp.schema.sx` | production |
+| 2.6.13 | 1. `Result.mergeFrom` handles field `dateOfAcceptance` | production |
+| 2.5.12 | 1. delegating the date parsing to https://github.com/sisyphsu/dateparser | production |
+| 2.5.[11-9] | 1. support for more date formats
2. enable the possibility to extend the date formats used to parse `Relation.validationDate` | production |
+| 2.4.8 | 1. added constant for ORCID datasource name | production |
+| 2.4.7 | refactoring | production |
+| 2.3.6 | [Aggregation]
1. introduced MetadataStoreManager (MdSM) model classes | production |
+| 2.2.5 | [Graph model]
1. introduced fields `Instance.pid` and `Instance.alternateIdentifier`
2. `LicenseComparator` renamed as `AccessRightComparator`
3. introduced `AccessRight` model class defining the `OpenAccessRoute` field to keep track of the OpenAccess color at the `Instance` level
4. `ExternalReference` cleanup (removed description, added alternateLabel(s))
5. added several ModelConstants
[Aggregation]
7. introduced MDStore record model classes
8. Introduced ORCID specific model classes | production |
+| 2.2.4 | 1. ORCID specific model classes backported in the version used in PROD
2. added constant for dnet:externalReference_typologies
3. added constant for ORCID datasource name
4. `Result.mergeFrom` handles field `dateOfAcceptance` | production |
diff --git a/pom.xml b/pom.xml
index 93b3207..6272e36 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
eu.dnetlib.dhp
dhp-schemas
jar
- 3.17.3-SNAPSHOT
+ 4.17.2-SNAPSHOT
diff --git a/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java b/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java
index e47ae97..2c046f8 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java
@@ -62,7 +62,9 @@ public class ModelConstants {
public static final String DNET_RELATION_RELTYPE = "dnet:relation_relType";
public static final String DNET_RELATION_SUBRELTYPE = "dnet:relation_subRelType";
public static final String DNET_RELATION_RELCLASS = "dnet:relation_relClass";
-
+ public static final String OPENAIRE_COAR_RESOURCE_TYPES_3_1 = "openaire::coar_resource_types_3_1";
+ public static final String OPENAIRE_USER_RESOURCE_TYPES = "openaire::user_resource_types";
+ public static final String OPENAIRE_META_RESOURCE_TYPE = "openaire::meta_resource_types";
public static final String PEER_REVIEWED_CLASSNAME = "nonPeerReviewed";
public static final String NON_PEER_REVIEWED_CLASSNAME = "nonPeerReviewed";
public static final String PEER_REVIEWED_CLASSID = "0001";
diff --git a/src/main/java/eu/dnetlib/dhp/schema/oaf/Instance.java b/src/main/java/eu/dnetlib/dhp/schema/oaf/Instance.java
index 42b8931..095eae5 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/oaf/Instance.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/oaf/Instance.java
@@ -12,6 +12,8 @@ public class Instance implements Serializable {
private Qualifier instancetype;
+ private List instanceTypeMapping;
+
private KeyValue hostedby;
private List url;
@@ -68,6 +70,14 @@ public class Instance implements Serializable {
this.instancetype = instancetype;
}
+ public List getInstanceTypeMapping() {
+ return instanceTypeMapping;
+ }
+
+ public void setInstanceTypeMapping(List instanceTypeMapping) {
+ this.instanceTypeMapping = instanceTypeMapping;
+ }
+
public KeyValue getHostedby() {
return hostedby;
}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/oaf/InstanceTypeMapping.java b/src/main/java/eu/dnetlib/dhp/schema/oaf/InstanceTypeMapping.java
new file mode 100644
index 0000000..ac8e6a2
--- /dev/null
+++ b/src/main/java/eu/dnetlib/dhp/schema/oaf/InstanceTypeMapping.java
@@ -0,0 +1,61 @@
+package eu.dnetlib.dhp.schema.oaf;
+
+import java.io.Serializable;
+
+/**
+ * Defines a mapping between the original resource types and the type code and label available in a given vocabulary.
+ */
+public class InstanceTypeMapping implements Serializable {
+
+ /**
+ * Original resource type, typically mapped from dc:type, datacite:resourceType.
+ */
+ private String originalType;
+
+ /**
+ * Contains the code of the resource type resulted from the mapping.
+ */
+ private String typeCode;
+
+ /**
+ * Contains the label of the resource type resulted from the mapping.
+ */
+ private String typeLabel;
+
+ /**
+ * Contains name of the vocabulary used to produce this resource type mapping.
+ */
+ private String vocabularyName;
+
+ public String getOriginalType() {
+ return originalType;
+ }
+
+ public void setOriginalType(String originalType) {
+ this.originalType = originalType;
+ }
+
+ public String getTypeCode() {
+ return typeCode;
+ }
+
+ public void setTypeCode(String typeCode) {
+ this.typeCode = typeCode;
+ }
+
+ public String getTypeLabel() {
+ return typeLabel;
+ }
+
+ public void setTypeLabel(String typeLabel) {
+ this.typeLabel = typeLabel;
+ }
+
+ public String getVocabularyName() {
+ return vocabularyName;
+ }
+
+ public void setVocabularyName(String vocabularyName) {
+ this.vocabularyName = vocabularyName;
+ }
+}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/oaf/OpenAccessColor.java b/src/main/java/eu/dnetlib/dhp/schema/oaf/OpenAccessColor.java
new file mode 100644
index 0000000..3e4b250
--- /dev/null
+++ b/src/main/java/eu/dnetlib/dhp/schema/oaf/OpenAccessColor.java
@@ -0,0 +1,11 @@
+
+package eu.dnetlib.dhp.schema.oaf;
+
+/**
+ * The OpenAccess color meant to be used on the result level
+ */
+public enum OpenAccessColor {
+
+ gold, hybrid, bronze
+
+}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java b/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java
index ba253c0..50578eb 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java
@@ -1,14 +1,19 @@
package eu.dnetlib.dhp.schema.oaf;
+import static java.util.Objects.*;
+
import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;
+import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
import eu.dnetlib.dhp.schema.common.AccessRightComparator;
import eu.dnetlib.dhp.schema.common.ModelConstants;
import eu.dnetlib.dhp.schema.oaf.utils.CleaningFunctions;
@@ -21,17 +26,13 @@ public class Result extends OafEntity implements Serializable {
/**
* ( article | book ) processing charges.
*/
-
private Field processingchargeamount;
-
/**
* currency - alphabetic code describe in ISO-4217.
*/
private Field processingchargecurrency;
-
-
/**
* The Author.
*/
@@ -43,6 +44,11 @@ public class Result extends OafEntity implements Serializable {
// resulttype allows subclassing results into publications | datasets | software
private Qualifier resulttype;
+ /**
+ * Temporary field suporting the analysis of the new COAR-based resource types
+ */
+ private Qualifier metaResourceType;
+
/**
* The Language.
*/
@@ -144,7 +150,15 @@ public class Result extends OafEntity implements Serializable {
*/
private List eoscifguidelines;
+ @JsonProperty("isGreen")
+ private Boolean isGreen;
+ private OpenAccessColor openAccessColor;
+
+ @JsonProperty("isInDiamondJournal")
+ private Boolean isInDiamondJournal;
+
+ private Boolean publiclyFunded;
public Field getProcessingchargeamount() {
return processingchargeamount;
@@ -198,6 +212,14 @@ public class Result extends OafEntity implements Serializable {
this.resulttype = resulttype;
}
+ public Qualifier getMetaResourceType() {
+ return metaResourceType;
+ }
+
+ public void setMetaResourceType(Qualifier metaResourceType) {
+ this.metaResourceType = metaResourceType;
+ }
+
/**
* Gets language.
*
@@ -548,6 +570,38 @@ public class Result extends OafEntity implements Serializable {
this.eoscifguidelines = eoscifguidelines;
}
+ public Boolean getIsGreen() {
+ return isGreen;
+ }
+
+ public void setIsGreen(Boolean green) {
+ isGreen = green;
+ }
+
+ public OpenAccessColor getOpenAccessColor() {
+ return openAccessColor;
+ }
+
+ public void setOpenAccessColor(OpenAccessColor openAccessColor) {
+ this.openAccessColor = openAccessColor;
+ }
+
+ public Boolean getIsInDiamondJournal() {
+ return isInDiamondJournal;
+ }
+
+ public void setIsInDiamondJournal(Boolean inDiamondJournal) {
+ isInDiamondJournal = inDiamondJournal;
+ }
+
+ public Boolean getPubliclyFunded() {
+ return publiclyFunded;
+ }
+
+ public void setPubliclyFunded(Boolean publiclyFunded) {
+ this.publiclyFunded = publiclyFunded;
+ }
+
/**
* Is an enrichment boolean.
*
@@ -560,7 +614,6 @@ public class Result extends OafEntity implements Serializable {
&& ModelConstants.PROVENANCE_ENRICH.equalsIgnoreCase(e.getDataInfo().getProvenanceaction().getClassid());
}
-
/**
* Normalize pid string.
*
@@ -684,11 +737,11 @@ public class Result extends OafEntity implements Serializable {
//ENRICH measures
if (enrichment.getMeasures()!=null)
- if (currentInstance.getMeasures() == null)
+ if (currentInstance.getMeasures() == null) {
currentInstance.setMeasures(enrichment.getMeasures());
- else
+ } else {
enrichment.getMeasures().forEach(currentInstance.getMeasures()::add);
-
+ }
}
@@ -712,11 +765,11 @@ public class Result extends OafEntity implements Serializable {
toEnrichInstances.forEach(i -> {
final List e = findEnrichmentsByPID(i.getPid(), ri);
- if (e!= null && e.size()> 0) {
+ if (e!= null && !e.isEmpty()) {
e.forEach(enr -> applyEnrichment(i, enr));
} else {
final List a = findEnrichmentsByPID(i.getAlternateIdentifier(), ri);
- if (a!= null && a.size()> 0) {
+ if (a!= null && !a.isEmpty()) {
a.forEach(enr -> applyEnrichment(i, enr));
}
}
@@ -735,15 +788,25 @@ public class Result extends OafEntity implements Serializable {
Result r = (Result) e;
- if(processingchargeamount == null || StringUtils.isBlank(processingchargeamount.getValue() )){
+ if(processingchargeamount == null || StringUtils.isBlank(processingchargeamount.getValue())){
processingchargeamount = r.getProcessingchargeamount();
processingchargecurrency = r.getProcessingchargecurrency();
}
-
-
eoscifguidelines = mergeLists(eoscifguidelines, r.getEoscifguidelines());
+ setIsGreen(mergeBooleanOR(getIsGreen(), r.getIsGreen()));
+
+ setIsInDiamondJournal(mergeBooleanOR(getIsInDiamondJournal(), r.getIsInDiamondJournal()));
+
+ setPubliclyFunded(mergeBooleanOR(getPubliclyFunded(), r.getPubliclyFunded()));
+
+ if (Boolean.logicalXor(nonNull(getOpenAccessColor()), nonNull(r.getOpenAccessColor()))) {
+ setOpenAccessColor(ObjectUtils.firstNonNull(getOpenAccessColor(), r.getOpenAccessColor()));
+ } else if (!Objects.equals(getOpenAccessColor(), r.getOpenAccessColor())) {
+ setOpenAccessColor(null);
+ }
+
if( !isAnEnrichment(this) && !isAnEnrichment(e))
instance = mergeLists(instance, r.getInstance());
else {
@@ -764,8 +827,8 @@ public class Result extends OafEntity implements Serializable {
if (r.getLanguage() != null && compareTrust(this, r) < 0)
language = r.getLanguage();
- if (Objects.nonNull(r.getDateofacceptance())) {
- if (Objects.isNull(getDateofacceptance())) {
+ if (nonNull(r.getDateofacceptance())) {
+ if (isNull(getDateofacceptance())) {
dateofacceptance = r.getDateofacceptance();
} else if (compareTrust(this, r) < 0) {
dateofacceptance = r.getDateofacceptance();
@@ -832,6 +895,16 @@ public class Result extends OafEntity implements Serializable {
externalReference = mergeLists(externalReference, r.getExternalReference());
}
+ private Boolean mergeBooleanOR(Boolean a, Boolean b) {
+ if (Boolean.logicalXor(isNull(a), isNull(b))) {
+ return ObjectUtils.firstNonNull(a, b);
+ } else if (nonNull(a) & nonNull(b)) {
+ return a || b;
+ } else {
+ return null;
+ }
+ }
+
/**
* Longest lists list.
*
diff --git a/src/test/java/eu/dnetlib/dhp/schema/oaf/MergeTest.java b/src/test/java/eu/dnetlib/dhp/schema/oaf/MergeTest.java
index 4479ea1..a4c0d4c 100644
--- a/src/test/java/eu/dnetlib/dhp/schema/oaf/MergeTest.java
+++ b/src/test/java/eu/dnetlib/dhp/schema/oaf/MergeTest.java
@@ -143,20 +143,16 @@ class MergeTest {
List publications = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/publication_apc.json", Publication.class);
System.out.println(publications.size());
publications.forEach(p -> assertEquals(1, p.getInstance().size()));
- publications.forEach(p -> assertTrue(p.getProcessingchargeamount() != null ));
- publications.forEach(p -> assertTrue(p.getProcessingchargecurrency() != null ));
+ publications.forEach(p -> assertNotNull(p.getProcessingchargeamount()));
+ publications.forEach(p -> assertNotNull(p.getProcessingchargecurrency()));
publications.forEach(p -> assertTrue(StringUtils.isNotBlank(p.getProcessingchargeamount().getValue() )));
publications.forEach(p -> assertTrue(StringUtils.isNotBlank(p.getProcessingchargecurrency().getValue() )));
- publications.forEach(p -> p.getInstance().stream()
- .forEach(i -> assertTrue(i.getProcessingchargeamount() != null)));
- publications.forEach(p -> p.getInstance().stream()
- .forEach(i -> assertTrue(i.getProcessingchargecurrency() != null)));
+ publications.forEach(p -> p.getInstance().forEach(i -> assertNotNull(i.getProcessingchargeamount())));
+ publications.forEach(p -> p.getInstance().forEach(i -> assertNotNull(i.getProcessingchargecurrency())));
- publications.forEach(p -> p.getInstance().stream()
- .forEach(i -> assertTrue(StringUtils.isNotBlank(i.getProcessingchargeamount().getValue()))));
- publications.forEach(p -> p.getInstance().stream()
- .forEach(i -> assertTrue(StringUtils.isNotBlank(i.getProcessingchargecurrency().getValue()))));
+ publications.forEach(p -> p.getInstance().forEach(i -> assertTrue(StringUtils.isNotBlank(i.getProcessingchargeamount().getValue()))));
+ publications.forEach(p -> p.getInstance().forEach(i -> assertTrue(StringUtils.isNotBlank(i.getProcessingchargecurrency().getValue()))));
Result p1 = publications.get(0);
Result p2 = publications.get(1);
@@ -168,24 +164,25 @@ class MergeTest {
assertEquals(2 , p1.getInstance().size());
- p1.getInstance().stream().forEach(i -> assertTrue(i.getProcessingchargeamount() != null));
- p1.getInstance().stream().forEach(i -> assertTrue(i.getProcessingchargecurrency() != null));
+ p1.getInstance().forEach(i -> assertNotNull(i.getProcessingchargeamount()));
+ p1.getInstance().forEach(i -> assertNotNull(i.getProcessingchargecurrency()));
- p1.getInstance().stream().anyMatch(i -> i.getProcessingchargeamount().getValue().equals("2000.47"));
- p1.getInstance().stream().anyMatch(i -> i.getProcessingchargeamount().getValue().equals("1721.47"));
+ assertTrue(p1.getInstance().stream().anyMatch(i -> i.getProcessingchargeamount().getValue().equals("2000.47")));
+ assertTrue(p1.getInstance().stream().anyMatch(i -> i.getProcessingchargeamount().getValue().equals("1721.47")));
- p1.getInstance().stream().anyMatch(i -> i.getProcessingchargecurrency().getValue().equals("EUR"));
- p1.getInstance().stream().anyMatch(i -> i.getProcessingchargecurrency().getValue().equals("USD"));
+ assertTrue(p1.getInstance().stream().anyMatch(i -> i.getProcessingchargecurrency().getValue().equals("EUR")));
+ assertTrue(p1.getInstance().stream().anyMatch(i -> i.getProcessingchargecurrency().getValue().equals("USD")));
System.out.println(new ObjectMapper().writeValueAsString(p1));
}
+
@Test
void testAPCMerge2() throws Exception {
List publications = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/publication_apc2.json", Publication.class);
System.out.println(publications.size());
publications.forEach(p -> assertEquals(1, p.getInstance().size()));
- assertTrue(publications.get(0).getProcessingchargeamount() != null );
- assertTrue(publications.get(0).getProcessingchargecurrency() != null );
- assertTrue(publications.get(1).getProcessingchargeamount() == null );
+ assertNotNull(publications.get(0).getProcessingchargeamount());
+ assertNotNull(publications.get(0).getProcessingchargecurrency());
+ assertNull(publications.get(1).getProcessingchargeamount());
Result p1 = publications.get(1);
Result p2 = publications.get(0);
@@ -198,9 +195,9 @@ class MergeTest {
assertEquals("EUR", p1.getProcessingchargecurrency().getValue());
assertEquals(2 , p1.getInstance().size());
- p1.getInstance().stream().anyMatch(i -> i.getProcessingchargeamount() != null);
+ assertTrue(p1.getInstance().stream().anyMatch(i -> i.getProcessingchargeamount() != null));
- p1.getInstance().stream().anyMatch(i -> i.getProcessingchargecurrency() != null);
+ assertTrue(p1.getInstance().stream().anyMatch(i -> i.getProcessingchargecurrency() != null));
assertEquals("1721.47", p1.getInstance().stream().filter(i -> i.getProcessingchargeamount() != null)
.collect(Collectors.toList()).get(0).getProcessingchargeamount().getValue());
@@ -217,16 +214,47 @@ class MergeTest {
assertEquals("EUR", p2.getProcessingchargecurrency().getValue());
assertEquals(2 , p2.getInstance().size());
- p2.getInstance().stream().anyMatch(i -> i.getProcessingchargeamount() != null);
+ assertTrue(p2.getInstance().stream().anyMatch(i -> i.getProcessingchargeamount() != null));
- p2.getInstance().stream().anyMatch(i -> i.getProcessingchargecurrency() != null);
+ assertTrue(p2.getInstance().stream().anyMatch(i -> i.getProcessingchargecurrency() != null));
assertEquals("1721.47", p2.getInstance().stream().filter(i -> i.getProcessingchargeamount() != null)
.collect(Collectors.toList()).get(0).getProcessingchargeamount().getValue());
assertEquals("EUR", p2.getInstance().stream().filter(i -> i.getProcessingchargeamount() != null)
.collect(Collectors.toList()).get(0).getProcessingchargecurrency().getValue());
+ }
+ @Test
+ void test_merge_irish_1() throws Exception {
+ List publications = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/publication_irish_tender_1.json", Publication.class);
+
+ Publication p = new Publication();
+
+ publications.forEach(p::mergeFrom);
+
+ assertNotNull(p);
+
+ assertTrue(p.getIsGreen());
+ assertTrue(p.getIsInDiamondJournal());
+ assertFalse(p.getPubliclyFunded());
+ assertEquals(OpenAccessColor.gold, p.getOpenAccessColor());
+ }
+
+ @Test
+ void test_merge_irish_2() throws Exception {
+ List publications = loadResourceResult("/eu/dnetlib/dhp/schema/oaf/utils/publication_irish_tender_2.json", Publication.class);
+
+ Publication p = new Publication();
+
+ publications.forEach(p::mergeFrom);
+
+ assertNotNull(p);
+
+ assertTrue(p.getIsGreen());
+ assertTrue(p.getIsInDiamondJournal());
+ assertFalse(p.getPubliclyFunded());
+ assertNull(p.getOpenAccessColor());
}
/**
@@ -274,7 +302,6 @@ class MergeTest {
updatePidIntoPublicationInstance(publications, enrichment, true);
applyAndVerifyEnrichment( enrichment, publications);
-
}
diff --git a/src/test/resources/eu/dnetlib/dhp/schema/oaf/utils/publication_irish_tender_1.json b/src/test/resources/eu/dnetlib/dhp/schema/oaf/utils/publication_irish_tender_1.json
new file mode 100644
index 0000000..08a7bc5
--- /dev/null
+++ b/src/test/resources/eu/dnetlib/dhp/schema/oaf/utils/publication_irish_tender_1.json
@@ -0,0 +1,3 @@
+{"id":"50|DansKnawCris::0829b5191605bdbea36d6502b8c1ce1f", "resulttype" : { "classid" : "publication" }, "pid":[{"qualifier":{"classid":"doi"},"value":"10.1016/j.cmet.2011.03.013"},{"qualifier":{"classid":"urn"},"value":"urn:nbn:nl:ui:29-f3ed5f9e-edf6-457e-8848-61b58a4075e2"},{"qualifier":{"classid":"scp-number"},"value":"79953761260"},{"qualifier":{"classid":"pmc"},"value":"21459329"}], "collectedfrom" : [ { "key" : "10|openaire____::081b82f96300b6a6e3d282bad31cb6e2", "value" : "Crossref"} ], "isGreen": null, "openAccessColor": "gold", "isInDiamondJournal": null, "publiclyFunded": null}
+{"id":"50|DansKnawCris::0829b5191605bdbea36d6502b8c1ce1g", "resulttype" : { "classid" : "publication" }, "isGreen": true, "openAccessColor": "gold", "isInDiamondJournal": true, "publiclyFunded": false }
+{"id":"50|DansKnawCris::0829b5191605bdbea36d6502b8c1ce1h", "resulttype" : { "classid" : "publication" }, "isGreen": false, "openAccessColor": null, "isInDiamondJournal": true, "publiclyFunded": false }
\ No newline at end of file
diff --git a/src/test/resources/eu/dnetlib/dhp/schema/oaf/utils/publication_irish_tender_2.json b/src/test/resources/eu/dnetlib/dhp/schema/oaf/utils/publication_irish_tender_2.json
new file mode 100644
index 0000000..c9554d1
--- /dev/null
+++ b/src/test/resources/eu/dnetlib/dhp/schema/oaf/utils/publication_irish_tender_2.json
@@ -0,0 +1,3 @@
+{"id":"50|DansKnawCris::0829b5191605bdbea36d6502b8c1ce1f", "resulttype" : { "classid" : "publication" }, "pid":[{"qualifier":{"classid":"doi"},"value":"10.1016/j.cmet.2011.03.013"},{"qualifier":{"classid":"urn"},"value":"urn:nbn:nl:ui:29-f3ed5f9e-edf6-457e-8848-61b58a4075e2"},{"qualifier":{"classid":"scp-number"},"value":"79953761260"},{"qualifier":{"classid":"pmc"},"value":"21459329"}], "collectedfrom" : [ { "key" : "10|openaire____::081b82f96300b6a6e3d282bad31cb6e2", "value" : "Crossref"} ], "isGreen": null, "openAccessColor": "gold", "isInDiamondJournal": null, "publiclyFunded": null}
+{"id":"50|DansKnawCris::0829b5191605bdbea36d6502b8c1ce1g", "resulttype" : { "classid" : "publication" }, "isGreen": true, "openAccessColor": "bronze", "isInDiamondJournal": true, "publiclyFunded": false }
+{"id":"50|DansKnawCris::0829b5191605bdbea36d6502b8c1ce1h", "resulttype" : { "classid" : "publication" }, "isGreen": false, "openAccessColor": null, "isInDiamondJournal": true, "publiclyFunded": false }
\ No newline at end of file