From fb05d15ff23e3f95ff1a169c0ecdcd5dcd163ea2 Mon Sep 17 00:00:00 2001 From: Sandro La Bruzzo Date: Mon, 21 Feb 2022 10:57:47 +0100 Subject: [PATCH 1/8] implemented comparable interface on few fields --- .../dhp/schema/sx/scholix/Scholix.java | 26 +++++++++- .../schema/sx/scholix/ScholixComparator.java | 37 ++++++++++++++ .../schema/sx/scholix/ScholixEntityId.java | 44 +++++++++++++++- .../schema/sx/scholix/ScholixIdentifier.java | 50 +++++++++++++------ .../schema/sx/scholix/ScholixCompareTest.java | 48 ++++++++++++++++++ 5 files changed, 188 insertions(+), 17 deletions(-) create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java create mode 100644 src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java index ca01cb5..fbf3c58 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java @@ -1,10 +1,12 @@ package eu.dnetlib.dhp.schema.sx.scholix; +import org.apache.commons.lang3.StringUtils; + import java.io.Serializable; import java.util.List; -public class Scholix implements Serializable { +public class Scholix implements Serializable, Comparable { private String publicationDate; private List publisher; @@ -74,4 +76,26 @@ public class Scholix implements Serializable { public void setIdentifier(String identifier) { this.identifier = identifier; } + + + + + @Override + public int compareTo(Scholix other) { + + if (other == null) + return -1; + + // Comparing publication date + final int publicationDateCompare =StringUtils.compare(publicationDate, other.getPublicationDate()); + + if (publicationDateCompare != 0) + return publicationDateCompare; + + + + + + return 0; + } } diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java new file mode 100644 index 0000000..40c2ff2 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java @@ -0,0 +1,37 @@ +package eu.dnetlib.dhp.schema.sx.scholix; + +import org.apache.commons.lang3.StringUtils; + +import java.text.Normalizer; +import java.util.List; + +public class ScholixComparator { + + + public static String normalizeString(final String input) { + if (input == null) + return null; + + return Normalizer.normalize(input, Normalizer.Form.NFD) + .toLowerCase() + .replaceAll("[^a-zA-Z0-9]", ""); + } + + + public static int compareScholixEntityId(final List first, final List second) { + return 0; + } + + public static int compareString(final String first, final String second) { + + + if (first == null && second == null) + return 0; + if (first==null ) + return 1; + if (second == null) + return -1; + return first.compareTo(second); + } + +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java index e4bcee3..376eff8 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java @@ -1,10 +1,17 @@ package eu.dnetlib.dhp.schema.sx.scholix; +import com.google.common.collect.Iterators; +import org.apache.commons.lang3.StringUtils; + import java.io.Serializable; import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; -public class ScholixEntityId implements Serializable { +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeString; + +public class ScholixEntityId implements Serializable, Comparable { private String name; private List identifiers; @@ -31,4 +38,39 @@ public class ScholixEntityId implements Serializable { public void setIdentifiers(List identifiers) { this.identifiers = identifiers; } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ScholixEntityId that = (ScholixEntityId) o; + return compareTo(that)==0; + } + + @Override + public int hashCode() { + return Objects.hash(name, identifiers); + } + + @Override + public int compareTo(ScholixEntityId other) { + final int nameComp = StringUtils.compare(normalizeString(name), normalizeString(other.getName())); + if (nameComp != 0) + return nameComp; + if (identifiers == null && other.getIdentifiers() == null) + return 0; + if (identifiers == null) + return 1; + if (other.getIdentifiers() == null) + return -1; + if (identifiers.size()!= other.getIdentifiers().size()) + return -1; + + Stream sortedLeft = identifiers.stream().sorted(); + Stream sortedRight = other.getIdentifiers().stream().sorted(); + + boolean equalsStream = Iterators.elementsEqual(sortedLeft.iterator(), sortedRight.iterator()); + + return equalsStream?0:-1; + } } diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java index 8fc8b08..18c3bbb 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java @@ -1,10 +1,15 @@ package eu.dnetlib.dhp.schema.sx.scholix; +import com.google.common.collect.ComparisonChain; +import org.apache.commons.lang3.StringUtils; + + +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeString; import java.io.Serializable; import java.util.Objects; -public class ScholixIdentifier implements Serializable { +public class ScholixIdentifier implements Serializable, Comparable { private String identifier; private String schema; private String url; @@ -27,20 +32,6 @@ public class ScholixIdentifier implements Serializable { this.url = url; } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - ScholixIdentifier that = (ScholixIdentifier) o; - return identifier.equals(that.identifier) && schema.equals(that.schema); - } - - @Override - public int hashCode() { - return Objects.hash(identifier, schema); - } - public String getIdentifier() { return identifier; } @@ -56,4 +47,33 @@ public class ScholixIdentifier implements Serializable { public void setSchema(String schema) { this.schema = schema; } + + @Override + public int compareTo(ScholixIdentifier o) { + final int idComp = StringUtils.compare(normalizeString(identifier), normalizeString(o.getIdentifier())); + if (idComp !=0) + return idComp; + final int schemaComp = StringUtils.compare(normalizeString(schema), normalizeString(o.getSchema())); + if (schemaComp !=0) + return schemaComp; + final int urlComp = StringUtils.compare(normalizeString(url), normalizeString(o.getUrl())); + return urlComp; + } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + ScholixIdentifier that = (ScholixIdentifier) o; + return compareTo(that) == 0; + } + + + @Override + public int hashCode() { + return Objects.hash(normalizeString(identifier), normalizeString(schema), normalizeString(url)); + } + + } diff --git a/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java b/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java new file mode 100644 index 0000000..30b64a5 --- /dev/null +++ b/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java @@ -0,0 +1,48 @@ +package eu.dnetlib.dhp.schema.sx.scholix; + +import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + +public class ScholixCompareTest { + + @Test + public void testNormalization() { + final String input = "Tĥïŝ ĩš â fůňķŷ Šťŕĭńġhttps://doi.org/< >10.11646/zootaxa.5099.1.3"; + final String expected = "thisisafunkystringhttpsdoiorg1011646zootaxa509913"; + final String normalized = ScholixComparator.normalizeString(input); + assertEquals(normalized, expected); + } + + + + @Test + public void testScholixIdentifierComparison() { + final String id = "10.11646/zootaxa.5099.1.3"; + final String schema = "DOI"; + final String url ="http://dx.dOI.org/10.11646/Zootaxa.5099.1.3"; + + final ScholixIdentifier left = new ScholixIdentifier(); + left.setIdentifier(id.toUpperCase()); + left.setSchema(schema.toUpperCase()); + left.setUrl(url.toUpperCase()); + + + final ScholixIdentifier right = new ScholixIdentifier(); + right.setIdentifier(id.toUpperCase()); + right.setSchema(schema.toUpperCase()); + right.setUrl(url.toLowerCase()); + + + assertEquals(0,left.compareTo(right)); + + assertEquals(left, right); + assertEquals(left.hashCode(), right.hashCode()); + + + left.setIdentifier(null); + + assertEquals(-1, left.compareTo(right)); + + + } +} -- 2.17.1 From dc514a7281a8fe98475b41e8c1f6a9f5d0937ad8 Mon Sep 17 00:00:00 2001 From: Sandro La Bruzzo Date: Tue, 22 Feb 2022 17:26:05 +0100 Subject: [PATCH 2/8] implemented comparable on each element of scholix --- pom.xml | 15 ++ .../dhp/schema/sx/scholix/Scholix.java | 35 ++++- .../sx/scholix/ScholixCollectedFrom.java | 47 +++++- .../schema/sx/scholix/ScholixComparator.java | 57 ++++--- .../schema/sx/scholix/ScholixEntityId.java | 23 +-- .../schema/sx/scholix/ScholixIdentifier.java | 62 ++++++-- .../sx/scholix/ScholixRelationship.java | 38 ++++- .../schema/sx/scholix/ScholixResource.java | 75 +++++++++- .../schema/sx/scholix/ScholixCompareTest.java | 139 +++++++++++++++--- 9 files changed, 423 insertions(+), 68 deletions(-) diff --git a/pom.xml b/pom.xml index 0ebb86f..a615670 100644 --- a/pom.xml +++ b/pom.xml @@ -138,6 +138,9 @@ maven-dependency-plugin 3.0.0 + + + org.codehaus.mojo exec-maven-plugin @@ -279,6 +282,12 @@ + + me.xuender + unidecode + 0.0.7 + + org.slf4j jcl-over-slf4j @@ -316,6 +325,7 @@ 2.4 + com.fasterxml.jackson.core jackson-databind @@ -335,6 +345,11 @@ + + me.xuender + unidecode + + org.junit.jupiter junit-jupiter diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java index fbf3c58..95338ea 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java @@ -5,8 +5,13 @@ import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; public class Scholix implements Serializable, Comparable { + private String publicationDate; private List publisher; @@ -78,7 +83,21 @@ public class Scholix implements Serializable, Comparable { } + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof Scholix)) return false; + Scholix scholix = (Scholix) o; + return compareTo(scholix) == 0; + } + @Override + public int hashCode() { + final int publisherHash = publisher == null ? 0: publisher.stream().sorted().collect(Collectors.toList()).hashCode(); + final int linkProviderHash = linkprovider == null ? 0: linkprovider.stream().sorted().collect(Collectors.toList()).hashCode(); + + return Objects.hash(normalizeString(publicationDate),publisherHash, linkProviderHash, relationship, source, target, normalizeIdnetifier(identifier)); + } @Override public int compareTo(Scholix other) { @@ -92,10 +111,24 @@ public class Scholix implements Serializable, Comparable { if (publicationDateCompare != 0) return publicationDateCompare; + final int linkPublisherComparator = compareList(publisher, other.getPublisher()); + if (linkPublisherComparator!= 0) + return linkPublisherComparator; + + final int linkProviderComparator = compareList(linkprovider, other.getLinkprovider()); + if (linkProviderComparator!= 0) + return linkProviderComparator; + final int relsComparator = compareObjects(relationship, other.getRelationship()); + if (relsComparator!= 0) + return relsComparator; - return 0; + final int sourceComparator = compareObjects(source, other.getSource()); + if (sourceComparator!= 0) + return sourceComparator; + + return compareObjects(target, other.getTarget()); } } diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCollectedFrom.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCollectedFrom.java index e8e4551..cd415de 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCollectedFrom.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCollectedFrom.java @@ -1,9 +1,14 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import java.io.Serializable; +import org.apache.commons.lang3.StringUtils; -public class ScholixCollectedFrom implements Serializable { +import java.io.Serializable; +import java.util.Objects; + +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; + +public class ScholixCollectedFrom implements Serializable, Comparable { private ScholixEntityId provider; private String provisionMode; @@ -42,4 +47,42 @@ public class ScholixCollectedFrom implements Serializable { public void setCompletionStatus(String completionStatus) { this.completionStatus = completionStatus; } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ScholixCollectedFrom)) return false; + ScholixCollectedFrom that = (ScholixCollectedFrom) o; + return compareTo(that)==0; + } + + @Override + public int hashCode() { + return Objects.hash(provider, normalizeString(provisionMode), normalizeString(completionStatus)); + } + + @Override + public int compareTo(ScholixCollectedFrom other) { + if (other == null) + return -1; + + int provModeCompare = StringUtils.compare(normalizeString(provisionMode),normalizeString(other.getProvisionMode()) ); + int compStatusCompare =StringUtils.compare(normalizeString(completionStatus),normalizeString(other.getCompletionStatus()) ); + + if (provider == null && other.getProvider() == null) + return provModeCompare == 0 ? compStatusCompare: provModeCompare; + + + if (provider == null) + return 1; + if (other.getProvider() == null) + return -1; + + int provCompare = provider.compareTo(other.getProvider()); + + if (provCompare == 0) + return provModeCompare == 0 ? compStatusCompare: provModeCompare; + return provCompare; + } } diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java index 40c2ff2..55c7c0e 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java @@ -1,37 +1,58 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import org.apache.commons.lang3.StringUtils; - import java.text.Normalizer; import java.util.List; +import java.util.stream.Stream; + +import com.google.common.collect.Iterators; +import me.xuender.unidecode.Unidecode; public class ScholixComparator { + public static String normalizeIdnetifier(final String input) { + if (input == null) + return null; + + return Normalizer.normalize(input, Normalizer.Form.NFD) + .toLowerCase(); + } + + public static String normalizeString(final String input) { if (input == null) return null; - - return Normalizer.normalize(input, Normalizer.Form.NFD) - .toLowerCase() - .replaceAll("[^a-zA-Z0-9]", ""); + return Unidecode.decode(input).toLowerCase(); } - public static int compareScholixEntityId(final List first, final List second) { - return 0; - } - - public static int compareString(final String first, final String second) { - - - if (first == null && second == null) + public static > int compareObjects (T left, T right) { + if (left == null && right==null) return 0; - if (first==null ) + if(left == null) return 1; - if (second == null) - return -1; - return first.compareTo(second); + if (right == null) + return -1; + return left.compareTo(right); } + public static > int compareList (List left, List right) { + + if (left == null && right==null) + return 0; + if(left == null) + return 1; + if (right == null) + return -1; + + Stream sortedLeft = left.stream().sorted(); + Stream sortedRight = right.stream().sorted(); + boolean equals = Iterators.elementsEqual(sortedLeft.iterator(), sortedRight.iterator()); + + return equals? 0: -1; + + + } + + } diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java index 376eff8..266b946 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.StringUtils; import java.io.Serializable; import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; import java.util.stream.Stream; import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeString; @@ -49,28 +50,20 @@ public class ScholixEntityId implements Serializable, Comparable sortedLeft = identifiers.stream().sorted(); - Stream sortedRight = other.getIdentifiers().stream().sorted(); - - boolean equalsStream = Iterators.elementsEqual(sortedLeft.iterator(), sortedRight.iterator()); - - return equalsStream?0:-1; } } diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java index 18c3bbb..f8b0cf1 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java @@ -1,22 +1,33 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import com.google.common.collect.ComparisonChain; import org.apache.commons.lang3.StringUtils; - - -import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeString; import java.io.Serializable; import java.util.Objects; +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeIdnetifier; + +/** + * The type Scholix identifier. + */ public class ScholixIdentifier implements Serializable, Comparable { private String identifier; private String schema; private String url; + /** + * Instantiates a new Scholix identifier. + */ public ScholixIdentifier() { } + /** + * Instantiates a new Scholix identifier. + * + * @param identifier the identifier + * @param schema the schema + * @param url the url + */ public ScholixIdentifier(String identifier, String schema, String url) { this.identifier = identifier; this.schema = schema; @@ -24,40 +35,71 @@ public class ScholixIdentifier implements Serializable, Comparable { private String name; private String schema; private String inverse; @@ -40,4 +44,34 @@ public class ScholixRelationship implements Serializable { public void setInverse(String inverse) { this.inverse = inverse; } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ScholixRelationship)) return false; + ScholixRelationship that = (ScholixRelationship) o; + return this.compareTo(that) ==0; + } + + @Override + public int hashCode() { + return Objects.hash(normalizeString(getName()), normalizeString(getSchema()), normalizeString(getInverse())); + } + + @Override + public int compareTo(ScholixRelationship other) { + if (other == null) + return -1; + + final int nameCompare = StringUtils.compare(normalizeString(name), normalizeString(other.getName())); + if (nameCompare!= 0 ) + return nameCompare; + + final int schemaCompare = StringUtils.compare(normalizeString(schema), normalizeString(other.getSchema())); + if (schemaCompare!= 0 ) + return schemaCompare; + + return StringUtils.compare(normalizeString(inverse), normalizeString(other.getInverse())); + } } diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixResource.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixResource.java index 569b1f3..d7b61ad 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixResource.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixResource.java @@ -1,10 +1,16 @@ package eu.dnetlib.dhp.schema.sx.scholix; +import org.apache.commons.lang3.StringUtils; + import java.io.Serializable; import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; -public class ScholixResource implements Serializable { +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; + +public class ScholixResource implements Serializable, Comparable { private List identifier; private String dnetIdentifier; @@ -87,4 +93,71 @@ public class ScholixResource implements Serializable { public void setCollectedFrom(List collectedFrom) { this.collectedFrom = collectedFrom; } + + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof ScholixResource)) return false; + ScholixResource that = (ScholixResource) o; + return compareTo(that) == 0; + } + + @Override + public int hashCode() { + int idHash = identifier == null ? 0 : identifier.stream().sorted().collect(Collectors.toList()).hashCode(); + int creatorHash = creator == null ? 0 : creator.stream().sorted().collect(Collectors.toList()).hashCode(); + + int publisherHash = publisher == null ? 0 : publisher.stream().sorted().collect(Collectors.toList()).hashCode(); + int collectedFromHash = collectedFrom == null ? 0 : collectedFrom.stream().sorted().collect(Collectors.toList()).hashCode(); + + return Objects.hash(idHash, normalizeIdnetifier(dnetIdentifier), normalizeString(objectType), + normalizeString(objectSubType), normalizeString(title),creatorHash, normalizeString(publicationDate), publisherHash, collectedFromHash); + } + + @Override + public int compareTo(ScholixResource other) { + if (other == null) + return -1; + final int compIdentifiers = compareList(identifier, other.getIdentifier()); + if (compIdentifiers!= 0) + return compIdentifiers; + + final int dnetIdComp = StringUtils.compare(dnetIdentifier, other.getDnetIdentifier()); + + if (dnetIdComp != 0) + return dnetIdComp; + + final int objTypeComparator = StringUtils.compare(normalizeString(objectType), normalizeString(other.getObjectType())); + + if (objTypeComparator != 0) + return objTypeComparator; + + + final int objSubTypeComparator = StringUtils.compare(normalizeString(objectSubType), normalizeString(other.getObjectSubType())); + + if (objSubTypeComparator != 0) + return objSubTypeComparator; + + + final int titleComparator = StringUtils.compare(normalizeString(title), normalizeString(other.getTitle())); + + if (titleComparator != 0) + return titleComparator; + + final int creatorComparator = compareList(creator, other.getCreator()); + if (creatorComparator!= 0) + return creatorComparator; + + final int pubDateComparator = StringUtils.compare(normalizeString(publicationDate), normalizeString(other.getPublicationDate())); + if (pubDateComparator!= 0) + return pubDateComparator; + + final int publisherComparator = compareList(publisher, other.getPublisher()); + if (publisherComparator!= 0) + return publisherComparator; + + return compareList(collectedFrom, other.getCollectedFrom()); + + } } diff --git a/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java b/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java index 30b64a5..53a489d 100644 --- a/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java +++ b/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java @@ -1,37 +1,91 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import static org.junit.jupiter.api.Assertions.*; import org.junit.jupiter.api.Test; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + public class ScholixCompareTest { - @Test - public void testNormalization() { - final String input = "Tĥïŝ ĩš â fůňķŷ Šťŕĭńġhttps://doi.org/< >10.11646/zootaxa.5099.1.3"; - final String expected = "thisisafunkystringhttpsdoiorg1011646zootaxa509913"; - final String normalized = ScholixComparator.normalizeString(input); - assertEquals(normalized, expected); + + + + + + + private ScholixIdentifier generateMockScholixId(boolean toUpper, int idCount) { + + final String id = String.format("10.11646/zootaxa.5099.1.%d", idCount); + final String schema = "DOI"; + final String url =String.format("http://dx.dOI.org/10.11646/Zootaxa.5099.1.%d", idCount); + + final ScholixIdentifier result = new ScholixIdentifier(); + result.setIdentifier(toUpper ? id.toUpperCase(): id.toLowerCase()); + result.setSchema(toUpper ? schema.toUpperCase():schema.toLowerCase()); + result.setUrl(toUpper ? url.toUpperCase():url.toLowerCase()); + return result; + + } + + + private ScholixEntityId generateMockScholixEntityId(boolean toUpper, boolean invertOrder, int numberOfIds) { + + final String datasourceName = "Datacite"; + + final List ids = new ArrayList<>(); + + if (!invertOrder) { + for (int i = 0; i < numberOfIds; i++) { + ids.add(generateMockScholixId(toUpper, i)); + } + } + else { + for (int i = numberOfIds-1; i >=0; i--) { + ids.add(generateMockScholixId(toUpper, i)); + } + } + + return new ScholixEntityId(toUpper? datasourceName.toUpperCase(): datasourceName.toLowerCase(), ids); + } + + private ScholixCollectedFrom generateMockScholixCollectedFrom(boolean toUpper, boolean invertOrder, int numberOfIds) { + + final ScholixCollectedFrom result = new ScholixCollectedFrom(); + final String completionStatus = "complete"; + final String provisionMode = "collected"; + result.setProvider(generateMockScholixEntityId(toUpper, invertOrder, numberOfIds)); + result.setCompletionStatus(toUpper ? completionStatus.toUpperCase(): completionStatus.toLowerCase()); + result.setProvisionMode(toUpper ? provisionMode.toUpperCase(): provisionMode.toLowerCase()); + return result; + } + + private ScholixRelationship generateMockScholixRelationships(boolean toUpper) { + + final String name = "IsRelatedTo"; + final String inverse = "RelatedTo"; + final String schema = "datacite"; + + final ScholixRelationship rel = new ScholixRelationship(); + + rel.setName(toUpper? name.toUpperCase():name.toLowerCase()); + rel.setInverse(toUpper? inverse.toUpperCase():inverse.toLowerCase()); + rel.setSchema(toUpper? schema.toUpperCase():schema.toLowerCase()); + + return rel; } @Test public void testScholixIdentifierComparison() { - final String id = "10.11646/zootaxa.5099.1.3"; - final String schema = "DOI"; - final String url ="http://dx.dOI.org/10.11646/Zootaxa.5099.1.3"; - final ScholixIdentifier left = new ScholixIdentifier(); - left.setIdentifier(id.toUpperCase()); - left.setSchema(schema.toUpperCase()); - left.setUrl(url.toUpperCase()); + final ScholixIdentifier left = generateMockScholixId(true, 1); - final ScholixIdentifier right = new ScholixIdentifier(); - right.setIdentifier(id.toUpperCase()); - right.setSchema(schema.toUpperCase()); - right.setUrl(url.toLowerCase()); - + final ScholixIdentifier right = generateMockScholixId(false,1); assertEquals(0,left.compareTo(right)); @@ -45,4 +99,51 @@ public class ScholixCompareTest { } + + + @Test + public void testScholixEntityIDComparison() { + + final ScholixEntityId first =generateMockScholixEntityId(true,false,10); + final ScholixEntityId second =generateMockScholixEntityId(false,true,10); + assertEquals(first,second); + assertEquals(first.hashCode(), second.hashCode()); + + } + + + @Test + public void testScholixCollectedFromComparison() { + final ScholixCollectedFrom cfLeft = generateMockScholixCollectedFrom(true, true, 20); + + + + final ScholixCollectedFrom cfRight = generateMockScholixCollectedFrom(false, false, 20); + + assertEquals(cfLeft, cfRight); + + assertEquals(cfLeft.hashCode(), cfRight.hashCode()); + + cfRight.setCompletionStatus(null); + + assertNotEquals(cfLeft, cfRight); + + + } + + + @Test + public void testCompareScholixRelation() { + + + final ScholixRelationship left = generateMockScholixRelationships(true); + final ScholixRelationship right = generateMockScholixRelationships(false); + + assertEquals(left, right); + assertEquals(left.hashCode(), right.hashCode()); + + + + } + } -- 2.17.1 From 88a347d9780c25c360583e60005e0b9da8584ea0 Mon Sep 17 00:00:00 2001 From: Sandro La Bruzzo Date: Wed, 23 Feb 2022 10:42:23 +0100 Subject: [PATCH 3/8] implemented unitTest to verify if compare works --- .../schema/sx/scholix/ScholixCompareTest.java | 156 ++++++++++++++---- 1 file changed, 123 insertions(+), 33 deletions(-) diff --git a/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java b/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java index 53a489d..2762873 100644 --- a/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java +++ b/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java @@ -1,39 +1,34 @@ package eu.dnetlib.dhp.schema.sx.scholix; import org.junit.jupiter.api.Test; - import java.util.ArrayList; import java.util.List; - +import java.util.stream.Collectors; +import java.util.stream.IntStream; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; public class ScholixCompareTest { + private ScholixIdentifier generateMockScholixId(final String baseId ,boolean toUpper, int idCount) { - - - - - - private ScholixIdentifier generateMockScholixId(boolean toUpper, int idCount) { - - final String id = String.format("10.11646/zootaxa.5099.1.%d", idCount); + final String id = String.format("%s.%d",baseId, idCount); final String schema = "DOI"; - final String url =String.format("http://dx.dOI.org/10.11646/Zootaxa.5099.1.%d", idCount); + final String url =String.format("http://dx.dOI.org/%s.%d",baseId, idCount); final ScholixIdentifier result = new ScholixIdentifier(); result.setIdentifier(toUpper ? id.toUpperCase(): id.toLowerCase()); result.setSchema(toUpper ? schema.toUpperCase():schema.toLowerCase()); result.setUrl(toUpper ? url.toUpperCase():url.toLowerCase()); return result; - } + private ScholixIdentifier generateMockScholixId(boolean toUpper, int idCount) { + return generateMockScholixId("10.11646/zootaxa.5099.1", toUpper, idCount); + } - private ScholixEntityId generateMockScholixEntityId(boolean toUpper, boolean invertOrder, int numberOfIds) { + private ScholixEntityId generateMockScholixEntityId(String name, boolean toUpper, boolean invertOrder, int numberOfIds) { - final String datasourceName = "Datacite"; final List ids = new ArrayList<>(); @@ -48,20 +43,30 @@ public class ScholixCompareTest { } } - return new ScholixEntityId(toUpper? datasourceName.toUpperCase(): datasourceName.toLowerCase(), ids); + return new ScholixEntityId(toUpper? name.toUpperCase(): name.toLowerCase(), ids); } - private ScholixCollectedFrom generateMockScholixCollectedFrom(boolean toUpper, boolean invertOrder, int numberOfIds) { + private ScholixEntityId generateMockScholixEntityId(boolean toUpper, boolean invertOrder, int numberOfIds) { + + return generateMockScholixEntityId("datacite", toUpper, invertOrder,numberOfIds); + } + + private ScholixCollectedFrom generateMockScholixCollectedFrom(final String dsName , final boolean toUpper, final boolean invertOrder, final int numberOfIds) { final ScholixCollectedFrom result = new ScholixCollectedFrom(); final String completionStatus = "complete"; final String provisionMode = "collected"; - result.setProvider(generateMockScholixEntityId(toUpper, invertOrder, numberOfIds)); + result.setProvider(generateMockScholixEntityId(dsName,toUpper, invertOrder, numberOfIds)); result.setCompletionStatus(toUpper ? completionStatus.toUpperCase(): completionStatus.toLowerCase()); result.setProvisionMode(toUpper ? provisionMode.toUpperCase(): provisionMode.toLowerCase()); return result; } + + private ScholixCollectedFrom generateMockScholixCollectedFrom(boolean toUpper, boolean invertOrder, int numberOfIds) { + return generateMockScholixCollectedFrom("datasource", toUpper, invertOrder,numberOfIds); + } + private ScholixRelationship generateMockScholixRelationships(boolean toUpper) { final String name = "IsRelatedTo"; @@ -78,26 +83,86 @@ public class ScholixCompareTest { } + private ScholixResource generateMockScholixResource(final String sourceBase, boolean toUpper, int idCount, boolean invertOrder, int numEntityIds) { + final ScholixResource resource = new ScholixResource(); + final String baseSourceId = "%s_10.1000/ID_%d/"; + final String creatorBase ="Creator %d"; + final String publisherBase ="Publisher %d"; + final String collectedFromBase ="Datasource %d"; + final String title = String.format("Resource %s Title 1", sourceBase); + final List ids = IntStream.range(0,numEntityIds) + .mapToObj(i -> String.format(baseSourceId,sourceBase, i)) + .map(s ->generateMockScholixId(s, toUpper, idCount)) + .collect(Collectors.toList()); + resource.setIdentifier(ids); + resource.setDnetIdentifier("dnetId"); + + resource.setObjectType("dataset"); + resource.setObjectSubType("dataset"); + resource.setTitle(title); + final List creators = IntStream.range(0,numEntityIds) + .mapToObj(i -> String.format(creatorBase, i)) + .map(s ->generateMockScholixEntityId(s, toUpper,invertOrder,idCount)) + .collect(Collectors.toList()); + resource.setCreator(creators); + resource.setPublicationDate("22-02-2022"); + + + final List publishers = IntStream.range(0,numEntityIds) + .mapToObj(i -> String.format(publisherBase, i)) + .map(s ->generateMockScholixEntityId(s, toUpper,invertOrder,idCount)) + .collect(Collectors.toList()); + resource.setPublisher(publishers); + + + final List collectedFroms = IntStream.range(0,numEntityIds) + .mapToObj(i -> String.format(collectedFromBase, i)) + .map(s -> generateMockScholixCollectedFrom(s,toUpper, invertOrder, idCount)) + .collect(Collectors.toList()); + + resource.setCollectedFrom(collectedFroms); + return resource; + } + + + + private Scholix generateMockScholix( boolean toUpper, int idCount, boolean invertOrder, int numEntityIds) { + final Scholix result = new Scholix(); + result.setPublicationDate("2022-02-22"); + + final String id = "dnetID"; + final String publisherBase ="Publisher %d"; + + result.setPublisher(IntStream.range(0,numEntityIds) + .mapToObj(i -> String.format(publisherBase, i)) + .map(s ->generateMockScholixEntityId(s, toUpper,invertOrder,idCount)) + .collect(Collectors.toList())); + + result.setLinkprovider(IntStream.range(0,numEntityIds) + .mapToObj(i -> String.format(publisherBase, i)) + .map(s ->generateMockScholixEntityId(s, toUpper,invertOrder,idCount)) + .collect(Collectors.toList())); + + result.setRelationship(generateMockScholixRelationships(toUpper)); + result.setSource(generateMockScholixResource("source", toUpper, idCount,invertOrder, numEntityIds)); + result.setTarget(generateMockScholixResource("target", toUpper, idCount,invertOrder, numEntityIds)); + + result.setIdentifier(toUpper?id.toUpperCase():id.toLowerCase()); + return result; + } + + @Test public void testScholixIdentifierComparison() { final ScholixIdentifier left = generateMockScholixId(true, 1); - - final ScholixIdentifier right = generateMockScholixId(false,1); - assertEquals(0,left.compareTo(right)); - assertEquals(left, right); assertEquals(left.hashCode(), right.hashCode()); - - left.setIdentifier(null); - assertEquals(-1, left.compareTo(right)); - - } @@ -116,8 +181,6 @@ public class ScholixCompareTest { public void testScholixCollectedFromComparison() { final ScholixCollectedFrom cfLeft = generateMockScholixCollectedFrom(true, true, 20); - - final ScholixCollectedFrom cfRight = generateMockScholixCollectedFrom(false, false, 20); assertEquals(cfLeft, cfRight); @@ -127,6 +190,35 @@ public class ScholixCompareTest { cfRight.setCompletionStatus(null); assertNotEquals(cfLeft, cfRight); + } + + @Test + public void testCompareScholixResource() { + final ScholixResource left = generateMockScholixResource("source",true,5, true,5); + final ScholixResource right = generateMockScholixResource("source",false,5, false,5); + assertEquals(left,right); + assertEquals(left.hashCode(), right.hashCode()); + final ScholixResource different = generateMockScholixResource("source",false,4, false,5); + assertNotEquals(different,right); + assertNotEquals(different,left); + assertNotEquals(left.hashCode(), different.hashCode()); + assertNotEquals(right.hashCode(), different.hashCode()); + } + + + @Test + public void testCompareScholix() { + + final Scholix left = generateMockScholix(true,5, true,5); + final Scholix right = generateMockScholix(false,5, false,5); + assertEquals(left,right); + assertEquals(left.hashCode(), right.hashCode()); + final Scholix different = generateMockScholix(true,4, false,5); + + assertNotEquals(different,right); + assertNotEquals(different,left); + assertNotEquals(left.hashCode(), different.hashCode()); + assertNotEquals(right.hashCode(), different.hashCode()); } @@ -134,16 +226,14 @@ public class ScholixCompareTest { @Test public void testCompareScholixRelation() { - - final ScholixRelationship left = generateMockScholixRelationships(true); final ScholixRelationship right = generateMockScholixRelationships(false); - assertEquals(left, right); assertEquals(left.hashCode(), right.hashCode()); - - } + + + } -- 2.17.1 From a92be975013922fa51b6b298b0e873a23b4bd103 Mon Sep 17 00:00:00 2001 From: Sandro La Bruzzo Date: Mon, 28 Feb 2022 12:11:24 +0100 Subject: [PATCH 4/8] moved scholix API data model from dnet-applications to dhp-schemas --- pom.xml | 18 ++ .../schema/sx/api/model/v1/LinkPublisher.java | 97 ++++++++ .../sx/api/model/v1/ScholixCreator.java | 69 ++++++ .../sx/api/model/v1/ScholixIdentifier.java | 71 ++++++ .../schema/sx/api/model/v1/ScholixItem.java | 161 +++++++++++++ .../sx/api/model/v1/ScholixProvider.java | 129 +++++++++++ .../sx/api/model/v1/ScholixRelationship.java | 134 +++++++++++ .../dhp/schema/sx/api/model/v1/ScholixV1.java | 184 +++++++++++++++ .../sx/api/model/v2/LinkProviderType.java | 123 ++++++++++ .../sx/api/model/v2/PageResultType.java | 114 ++++++++++ .../sx/api/model/v2/RelationshipType.java | 107 +++++++++ .../sx/api/model/v2/ScholixCreatorType.java | 86 +++++++ .../api/model/v2/ScholixIdentifierType.java | 104 +++++++++ .../sx/api/model/v2/ScholixItemType.java | 188 +++++++++++++++ .../api/model/v2/ScholixLinkProviderType.java | 86 +++++++ .../schema/sx/api/model/v2/ScholixType.java | 197 ++++++++++++++++ .../sx/api/model/v3/ScholixItemType.java | 215 ++++++++++++++++++ .../schema/sx/api/model/v3/ScholixType.java | 199 ++++++++++++++++ 18 files changed, 2282 insertions(+) create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/LinkPublisher.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixCreator.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixIdentifier.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixItem.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixProvider.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixRelationship.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixV1.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/LinkProviderType.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/PageResultType.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/RelationshipType.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixCreatorType.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixIdentifierType.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixItemType.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixLinkProviderType.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixType.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixItemType.java create mode 100644 src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixType.java diff --git a/pom.xml b/pom.xml index a615670..1b691d5 100644 --- a/pom.xml +++ b/pom.xml @@ -349,6 +349,24 @@ me.xuender unidecode + + io.swagger + swagger-annotations + 1.5.20 + + + io.swagger.core.v3 + swagger-annotations + 2.1.12 + + + + + javax.validation + validation-api + 2.0.1.Final + + org.junit.jupiter diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/LinkPublisher.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/LinkPublisher.java new file mode 100644 index 0000000..91c3f97 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/LinkPublisher.java @@ -0,0 +1,97 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.Objects; + +public class LinkPublisher { + @NotBlank + @JsonProperty("name") + private String name = null; + + @NotBlank + @JsonProperty("totalRelationships") + private Integer totalRelationships = null; + + public LinkPublisher name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @Schema(description = "The Publisher Name") + + @Size(max=300) public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public LinkPublisher totalRelationships(Integer totalRelationships) { + this.totalRelationships = totalRelationships; + return this; + } + + /** + * Get totalRelationships + * @return totalRelationships + **/ + @Schema(description = "Total number of relationships that the publisher provides") + + public Integer getTotalRelationships() { + return totalRelationships; + } + + public void setTotalRelationships(Integer totalRelationships) { + this.totalRelationships = totalRelationships; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LinkPublisher linkPublisher = (LinkPublisher) o; + return Objects.equals(this.name, linkPublisher.name) && + Objects.equals(this.totalRelationships, linkPublisher.totalRelationships); + } + + @Override + public int hashCode() { + return Objects.hash(name, totalRelationships); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LinkPublisher {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" totalRelationships: ").append(toIndentedString(totalRelationships)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} \ No newline at end of file diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixCreator.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixCreator.java new file mode 100644 index 0000000..da53442 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixCreator.java @@ -0,0 +1,69 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.List; +import java.util.stream.Collectors; + +public class ScholixCreator { + + @JsonProperty("name") + private String name = null; + + @JsonProperty("identifier") + private List identifier = null; + + public ScholixCreator name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @Schema(required = true, description = "The name of the Object Creator") + public String getName() { + return name; + } + + public ScholixCreator setName(String name) { + this.name = name; + return this; + } + + + /** + * Get identifier + * @return identifier + **/ + @Schema(description = "A unique string that identifies the Object Creator") + public List getIdentifier() { + return identifier; + } + + public ScholixCreator setIdentifier(List identifier) { + this.identifier = identifier; + return this; + } + + public static ScholixCreator fromScholixEntityId(final ScholixEntityId provider) { + if (provider == null) + return null; + ScholixCreator instance = new ScholixCreator().setName(provider.getName()); + + + if (provider.getIdentifiers()!= null && provider.getIdentifiers().size()>0) + instance.setIdentifier(provider.getIdentifiers() + .stream() + .map(i ->new ScholixIdentifier() + .setIdentifier(i.getIdentifier()) + .setSchema(i.getSchema())) + .collect(Collectors.toList())); + return instance; + + + } +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixIdentifier.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixIdentifier.java new file mode 100644 index 0000000..752aa82 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixIdentifier.java @@ -0,0 +1,71 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.Objects; + +public class ScholixIdentifier { + + @JsonProperty("identifier") + private String identifier = null; + + @JsonProperty("schema") + private String schema = null; + + + + public ScholixIdentifier Identifier(String ID) { + this.identifier = ID; + return this; + } + + /** + * Get ID + * @return ID + **/ + @Schema(description = "The value of the Identifier") + public String getIdentifier() { + return identifier; + } + + public ScholixIdentifier setIdentifier(String identifier) { + this.identifier = identifier; + return this; + } + + public ScholixIdentifier Schema(String idScheme) { + this.schema = idScheme; + return this; + } + + /** + * Get the Schema + * @return Schema + **/ + @Schema(description = "The Schema URL of the identifier type") + + public String getSchema() { + return schema; + } + + public ScholixIdentifier setSchema(String schema) { + this.schema = schema; + return this; + } + + public static ScholixIdentifier fromScholixIdentifier(eu.dnetlib.dhp.schema.sx.scholix.ScholixIdentifier input) { + if (input == null) + return null; + + final ScholixIdentifier result = new ScholixIdentifier(); + result.setSchema(input.getSchema()); + result.setIdentifier(input.getIdentifier()); + return result; + + + + } + + +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixItem.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixItem.java new file mode 100644 index 0000000..bd84344 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixItem.java @@ -0,0 +1,161 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.scholix.ScholixResource; +import io.swagger.v3.oas.annotations.media.Schema; + +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class ScholixItem { + + @JsonProperty("identifiers") + private List identifiers; + + @JsonProperty("objectType") + private String objectType; + + @JsonProperty("objectSubType") + private String objectSubType; + + @JsonProperty("title") + private String title; + + @JsonProperty("creator") + private List creator; + + @JsonProperty("publicationDate") + private String publicationDate; + + @JsonProperty("publisher") + private List publisher; + + @Schema(description = "The list of identifiers") + public List getIdentifiers() { + return identifiers; + } + + public ScholixItem setIdentifiers(List identifiers) { + this.identifiers = identifiers; + return this; + } + + public ScholixItem objectType(String objectType) { + this.objectType = objectType; + return this; + } + + @Schema(description = "Describes the nature of the object (its intended usage)") + public String getObjectType() { + return objectType; + } + + public void setObjectType(String objectType) { + this.objectType = objectType; + } + + public ScholixItem objectSubType(String objectSubType) { + this.objectSubType = objectSubType; + return this; + } + + @Schema(description = "The sub-type of Object") + public String getObjectSubType() { + return objectSubType; + } + + public void setObjectSubType(String objectSubType) { + this.objectSubType = objectSubType; + } + + public ScholixItem title(String title) { + this.title = title; + return this; + } + + @Schema(description = "The name of the object") + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public ScholixItem creator(List creator) { + this.creator = creator; + return this; + } + + public ScholixItem addCreatorInstance(ScholixCreator creatorInstance) { + if(this.creator == null) + this.creator = new ArrayList<>(); + this.creator.add(creatorInstance); + return this; + } + + @Schema(description = "Party responsible for the creation of the object") + public List getCreator() { + return creator; + } + + public void setCreator(List creator) { + this.creator = creator; + } + + @Schema(description = "The date the object was formally issued, published or distributed") + public String getPublicationDate() { + return publicationDate; + } + + public void setPublicationDate(String publicationDate) { + this.publicationDate = publicationDate; + } + + @Schema(description = "The list name of the publisher of the object") + public List getPublisher() { + return publisher; + } + + public ScholixItem setPublisher(List publisher) { + this.publisher = publisher; + return this; + } + + public static ScholixItem fromScholixResource(final ScholixResource input) { + if (input == null) + return null; + + + final ScholixItem result = new ScholixItem(); + + if (input.getIdentifier()!= null) + result.setIdentifiers( + input.getIdentifier().stream() + .map(ScholixIdentifier::fromScholixIdentifier) + .collect(Collectors.toList()) + ); + + result.setTitle(input.getTitle()); + result.setObjectType(input.getObjectType()); + result.setObjectSubType(input.getObjectSubType()); + result.setPublicationDate(input.getPublicationDate()); + if(input.getPublisher()!= null) + result.setPublisher(input.getPublisher().stream() + .map(ScholixProvider::fromScholixEntityId) + .collect(Collectors.toList()) + ); + + + if (input.getCreator()!= null) + result.setCreator(input.getCreator().stream() + .map(ScholixCreator::fromScholixEntityId) + .collect(Collectors.toList()) + ); + + return result; + + } +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixProvider.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixProvider.java new file mode 100644 index 0000000..fd700ef --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixProvider.java @@ -0,0 +1,129 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.Valid; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class ScholixProvider { + + public static ScholixProvider fromScholixEntityId(final ScholixEntityId provider) { + if (provider == null) + return null; + ScholixProvider instance = new ScholixProvider().setName(provider.getName()); + + + if (provider.getIdentifiers()!= null && provider.getIdentifiers().size()>0) + instance.setIdentifier(provider.getIdentifiers() + .stream() + .map(i ->new ScholixIdentifier() + .setIdentifier(i.getIdentifier()) + .setSchema(i.getSchema())) + .collect(Collectors.toList())); + return instance; + + + } + + + @JsonProperty("name") + private String name = null; + + @JsonProperty("identifier") + @Valid + private List identifier = null; + + public ScholixProvider name(String name) { + this.name = name; + return this; + } + + /** + * Get the provider name + * @return name + **/ + @Schema(description = "The provider name") + + public String getName() { + return name; + } + + public ScholixProvider setName(String name) { + this.name = name; + return this; + } + + public ScholixProvider identifier(List identifier) { + this.identifier = identifier; + return this; + } + + public ScholixProvider addIdentifierItem(ScholixIdentifier identifierItem) { + if (this.identifier == null) { + this.identifier = new ArrayList<>(); + } + this.identifier.add(identifierItem); + return this; + } + + /** + * Get identifier + * @return identifier + **/ + @Schema(description = "the identifiers of the provider") + @Valid + public List getIdentifier() { + return identifier; + } + + public ScholixProvider setIdentifier(List identifier) { + this.identifier = identifier; + return this; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScholixProvider scholixProviderType = (ScholixProvider) o; + return Objects.equals(this.name, scholixProviderType.name) && + Objects.equals(this.identifier, scholixProviderType.identifier); + } + + @Override + public int hashCode() { + return Objects.hash(name, identifier); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ScholixProviderType {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" identifiers: ").append(toIndentedString(identifier)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixRelationship.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixRelationship.java new file mode 100644 index 0000000..4d357f2 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixRelationship.java @@ -0,0 +1,134 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotBlank; +import java.util.Objects; + +import static eu.dnetlib.dhp.schema.sx.api.model.v2.RelationshipType.relationMapping; + +public class ScholixRelationship { + + @JsonProperty("name") + private String name = null; + + @JsonProperty("schema") + private String schema = null; + + @NotBlank + @JsonProperty("inverseRelationship") + private String inverseRelationship = null; + + public ScholixRelationship name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * @return name + **/ + @Schema(required = true, description = "The relationship type chosen from a Scholix controlled vocabulary") + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public ScholixRelationship schema(String schema) { + this.schema = schema; + return this; + } + + /** + * Get The name of the schema or controlled list from which Relationship Sub-type is sourced + * @return subType + **/ + @Schema(description = "The name of the schema or controlled list from which Relationship Sub-type is sourced") + public String getSchema() { + return schema; + } + + public void setSchema(String schema) { + this.schema = schema; + } + + public ScholixRelationship inverseRelationship(String inverseRelationship) { + this.inverseRelationship = inverseRelationship; + return this; + } + + /** + * Get inverseRelationship + * @return inverseRelationship + **/ + @Schema(description = "The value of the inverse relation") + + public String getInverseRelationship() { + return inverseRelationship; + } + + public void setInverseRelationship(String inverseRelationship) { + this.inverseRelationship = inverseRelationship; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScholixRelationship relationshipType = (ScholixRelationship) o; + return Objects.equals(this.name, relationshipType.name) && + Objects.equals(this.schema, relationshipType.schema) && + Objects.equals(this.inverseRelationship, relationshipType.inverseRelationship); + } + + @Override + public int hashCode() { + return Objects.hash(name, schema, inverseRelationship); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class RelationshipType {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" subType: ").append(toIndentedString(schema)).append("\n"); + sb.append(" subTypeSchema: ").append(toIndentedString(inverseRelationship)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + public static ScholixRelationship fromScholixIndexRelationship(eu.dnetlib.dhp.schema.sx.scholix.ScholixRelationship inputRel) { + if(inputRel==null) + return null; + + ScholixRelationship result = new ScholixRelationship(); + + result.setName(relationMapping.getOrDefault(inputRel.getName(), "IsRelatedTo")); + result.setInverseRelationship(relationMapping.getOrDefault(inputRel.getInverse(), "IsRelatedTo")); + result.setSchema(inputRel.getSchema()); + return result; + + } + +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixV1.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixV1.java new file mode 100644 index 0000000..3cd3e7b --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixV1.java @@ -0,0 +1,184 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v1; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.scholix.Scholix; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +public class ScholixV1 implements Serializable { + + @JsonProperty("linkProvider") + private List linkProvider; + + @JsonProperty("publicationDate") + private String publicationDate; + + @NotBlank + @JsonProperty("relationship") + private ScholixRelationship relationship; + + @NotBlank + @JsonProperty("source") + private ScholixItem source; + + @NotBlank + @JsonProperty("target") + private ScholixItem target; + + + + public ScholixV1 linkProvider (final List linkProvider ) { + this.linkProvider = linkProvider; + return this; + } + + @Schema(description = "An entity responsible for making this record available online") + public List getLinkProvider() { + return linkProvider; + } + + public ScholixV1 addLinkProviderItem(ScholixProvider linkProviderItem) { + if (this.linkProvider == null) { + this.linkProvider = new ArrayList<>(); + } + this.linkProvider.add(linkProviderItem); + return this; + } + + public void setLinkProvider(List linkProvider) { + this.linkProvider = linkProvider; + } + + @Schema(description = "date of formal issuance (e.g., publication) of the resource; generally different from source object and target object publication dates") + public String getPublicationDate() { + return publicationDate; + } + + public ScholixV1 publicationDate(String publicationDate) { + this.publicationDate = publicationDate; + return this; + } + + public void setPublicationDate(String publicationDate) { + this.publicationDate = publicationDate; + } + + @Schema(description = "Semantics of the relationship from source to target") + public ScholixRelationship getRelationship() { + return relationship; + } + + public ScholixV1 relationship(ScholixRelationship relationship) { + this.relationship = relationship; + return this; + } + + public void setRelationship(ScholixRelationship relationship) { + this.relationship = relationship; + } + + @Schema(description = "Root element relative to all properties describing the link’s source object.") + public ScholixItem getSource() { + return source; + } + + + public ScholixV1 source(ScholixItem source) { + this.source = source; + return this; + } + public void setSource(ScholixItem source) { + this.source = source; + } + + @Schema(description = "Root element relative to all properties describing the link’s target object.") + public ScholixItem getTarget() { + return target; + } + + public ScholixV1 target(ScholixItem target) { + this.target = target; + return this; + } + + public void setTarget(ScholixItem target) { + this.target = target; + } + + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ScholixV1 scholixV1 = (ScholixV1) o; + return Objects.equals(this.linkProvider, scholixV1.getLinkProvider()) && + Objects.equals(this.publicationDate, scholixV1.getPublicationDate()) && + Objects.equals(this.relationship, scholixV1.getRelationship()) && + Objects.equals(this.source, scholixV1.getSource()) && + Objects.equals(this.target, scholixV1.getTarget()); + } + + @Override + public int hashCode() { + return Objects.hash(linkProvider, publicationDate, relationship, source, target); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ScholixV1 {\n"); + + sb.append(" linkProvider: ").append(toIndentedString(linkProvider)).append("\n"); + sb.append(" publicationDate: ").append(toIndentedString(publicationDate)).append("\n"); + sb.append(" relationship: ").append(toIndentedString(relationship)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" target: ").append(toIndentedString(target)).append("\n"); + + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static ScholixV1 fromScholix(Scholix input) { + if (input == null) + return null; + final ScholixV1 result = new ScholixV1(); + + + if (input.getLinkprovider()!= null) + result.setLinkProvider(input.getLinkprovider() + .stream() + .map(ScholixProvider::fromScholixEntityId) + .collect(Collectors.toList())); + + result.setPublicationDate(input.getPublicationDate()); + + result.setRelationship(ScholixRelationship.fromScholixIndexRelationship(input.getRelationship())); + + result.setSource(ScholixItem.fromScholixResource(input.getSource())); + result.setTarget(ScholixItem.fromScholixResource(input.getTarget())); + return result; + } +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/LinkProviderType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/LinkProviderType.java new file mode 100644 index 0000000..01c9adb --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/LinkProviderType.java @@ -0,0 +1,123 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v2; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import java.util.Objects; + +/** + * The type Link provider type. + */ +public class LinkProviderType { + @NotBlank + @JsonProperty("name") + private String name = null; + + @NotBlank + @JsonProperty("totalRelationships") + private Integer totalRelationships = null; + + /** + * Name link provider type. + * + * @param name the name + * @return the link provider type + */ + public LinkProviderType name(String name) { + this.name = name; + return this; + } + + /** + * Get name + * + * @return name name + */ + @Schema(description = "The Publisher Name") + @Size(max=300) + public String getName() { + return name; + } + + /** + * Sets name. + * + * @param name the name + */ + public void setName(String name) { + this.name = name; + } + + /** + * Total relationships link provider type. + * + * @param totalRelationships the total relationships + * @return the link provider type + */ + public LinkProviderType totalRelationships(Integer totalRelationships) { + this.totalRelationships = totalRelationships; + return this; + } + + /** + * Get totalRelationships + * + * @return totalRelationships total relationships + */ + @Schema(description = "Total number of relationships that the publisher provides") + public Integer getTotalRelationships() { + return totalRelationships; + } + + /** + * Sets total relationships. + * + * @param totalRelationships the total relationships + */ + public void setTotalRelationships(Integer totalRelationships) { + this.totalRelationships = totalRelationships; + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + LinkProviderType linkPublisher = (LinkProviderType) o; + return Objects.equals(this.name, linkPublisher.name) && + Objects.equals(this.totalRelationships, linkPublisher.totalRelationships); + } + + @Override + public int hashCode() { + return Objects.hash(name, totalRelationships); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class LinkPublisher {\n"); + + sb.append(" name: ").append(toIndentedString(name)).append("\n"); + sb.append(" totalRelationships: ").append(toIndentedString(totalRelationships)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } +} \ No newline at end of file diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/PageResultType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/PageResultType.java new file mode 100644 index 0000000..8ebbbf5 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/PageResultType.java @@ -0,0 +1,114 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v2; + +import com.fasterxml.jackson.annotation.JsonProperty; +import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +/** + * The main class that show the page result from the method + * /l2/links + */ +public class PageResultType implements Serializable { + + @NotBlank + @JsonProperty("currentPage") + @ApiModelProperty(position = 0) + private Integer currentPage = 0; + + @NotBlank + @JsonProperty("totalLinks") + @ApiModelProperty(position = 1) + private Integer totalLinks= 0; + + @NotBlank + @JsonProperty("totalPages") + @ApiModelProperty(position = 2) + private Integer totalPages = 0; + + @NotBlank + @JsonProperty("result") + @ApiModelProperty(position = 3) + private List result = new ArrayList<>(); + + + /** + * Gets current page. + * + * @return the current page + */ + @Schema(description = "The Current page of the results") + public Integer getCurrentPage() { + return currentPage; + } + + /** + * Sets current page. + * + * @param currentPage the current page + */ + public void setCurrentPage(Integer currentPage) { + this.currentPage = currentPage; + } + + /** + * Gets total links. + * + * @return the total links + */ + @Schema(description = "The total number of Links found by the query") + public Integer getTotalLinks() { + return totalLinks; + } + + /** + * Sets total links. + * + * @param totalLinks the total links + */ + public void setTotalLinks(Integer totalLinks) { + this.totalLinks = totalLinks; + } + + /** + * Gets total pages. + * + * @return the total pages + */ + @Schema(description = "The Total number of pages") + public Integer getTotalPages() { + return totalPages; + } + + /** + * Sets total pages. + * + * @param totalPages the total pages + */ + public void setTotalPages(Integer totalPages) { + this.totalPages = totalPages; + } + + /** + * Gets result. + * + * @return the result + */ + @Schema(description = "The First page of Scholix results") + public List getResult() { + return result; + } + + /** + * Sets result. + * + * @param result the result + */ + public void setResult(List result) { + this.result = result; + } +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/RelationshipType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/RelationshipType.java new file mode 100644 index 0000000..a6f37a5 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/RelationshipType.java @@ -0,0 +1,107 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v2; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.scholix.ScholixRelationship; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotNull; +import java.util.Map; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +/** + * The type Relationship type. + */ +public class RelationshipType { + + @NotNull + @JsonProperty("Name") + private String name; + + @JsonProperty("SubType") + private String subType; + + @JsonProperty("SubTypeSchema") + private String subTypeSchema; + + + public static Map relationMapping = Stream.of(new String[][] { + { "issupplementto", "IsSupplementTo" }, + { "issupplementedby", "IsSupplementedBy" }, + { "references", "References" }, + { "isreferencedby", "IsReferencedBy" }, + }).collect(Collectors.toMap(data -> data[0], data -> data[1])); + + + /** + * Gets The relationship type chosen from a Scholix controlled vocabulary + * + * @return the name + */ + @Schema(description = "The relationship type chosen from a Scholix controlled vocabulary") + public String getName() { + return name; + } + + /** + * Sets The relationship type chosen from a Scholix controlled vocabulary + * + * @param name the name + * @return the RelationshipType instance + */ + public RelationshipType setName(String name) { + this.name = name; + return this; + } + + /** + * Gets The sub-type of RelationshipType.Name + * + * @return the sub type + */ + @Schema(description = "The sub-type of RelationshipType.Name") + public String getSubType() { + return subType; + } + + /** + * Sets The sub-type of RelationshipType.Name + * + * @param subType the sub type + * @return the RelationshipType instance + */ + public RelationshipType setSubType(String subType) { + this.subType = subType; + return this; + } + + /** + * Gets The name of the schema or controlled list from which RelationshipSub-type is sourced. + * + * @return the sub type schema + */ + @Schema(description = "The name of the schema or controlled list from which RelationshipSub-type is sourced") + public String getSubTypeSchema() { + return subTypeSchema; + } + + /** + * Sets The name of the schema or controlled list from which RelationshipSub-type is sourced. + * + * @param subTypeSchema the sub type schema + * @return the RelationshipType instance + */ + public RelationshipType setSubTypeSchema(String subTypeSchema) { + this.subTypeSchema = subTypeSchema; + return this; + } + + public static RelationshipType fromScholixRelationship(ScholixRelationship inputRels) { + + return new RelationshipType() + .setName(relationMapping.getOrDefault(inputRels.getName(), "IsRelatedTo")) + .setSubType(inputRels.getName()) + .setSubTypeSchema(inputRels.getSchema()); + + } +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixCreatorType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixCreatorType.java new file mode 100644 index 0000000..e06f9c2 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixCreatorType.java @@ -0,0 +1,86 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v2; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotBlank; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The type Scholix creator type. + */ +public class ScholixCreatorType { + + @NotBlank + @JsonProperty("name") + private String name = null; + + + @NotBlank + @JsonProperty("identifier") + private List identifier = new ArrayList<>(); + + /** + * Gets A List of unique string that identifies the creator + * + * @return the identifier + */ + @Schema(description = "A List of unique string that identifies the creator") + public List getIdentifier() { + return identifier; + } + + /** + * Sets A List of unique string that identifies the creator + * + * @param identifier the identifier + * @return the identifier + */ + public ScholixCreatorType setIdentifier(List identifier) { + this.identifier = identifier; + return this; + } + + + /** + * Gets The name of the Object Creator + * + * @return the name + */ + @Schema(description = "The name of the Object Creator") + public String getName() { + return name; + } + + /** + * Sets The name of the Object Creator + * + * @param name the name + * @return the name + */ + public ScholixCreatorType setName(String name) { + this.name = name; + return this; + } + + public static ScholixCreatorType fromScholixEntityId(final ScholixEntityId inputCreator) { + if (inputCreator == null) + return null; + ScholixCreatorType instance = new ScholixCreatorType().setName(inputCreator.getName()); + + + if (inputCreator.getIdentifiers()!= null && inputCreator.getIdentifiers().size()>0) + instance.setIdentifier(inputCreator.getIdentifiers() + .stream() + .map(i ->new ScholixIdentifierType() + .setId(i.getIdentifier()) + .setIdScheme(i.getSchema())) + .collect(Collectors.toList())); + return instance; + + + } +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixIdentifierType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixIdentifierType.java new file mode 100644 index 0000000..e85dcd4 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixIdentifierType.java @@ -0,0 +1,104 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v2; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.scholix.ScholixIdentifier; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotBlank; + +/** + * The type Scholix identifier type. + */ +public class ScholixIdentifierType { + + @NotBlank + @JsonProperty("ID") + private String id = null; + + @NotBlank + @JsonProperty("IDScheme") + private String idScheme = null; + + @NotBlank + @JsonProperty("IDURL") + private String idURL = null; + + + /** + * Gets The identifier + * + * @return the id + */ + @Schema(description = "The identifier") + public String getId() { + return id; + } + + /** + * Sets The identifier + * + * @param id the id + * @return the id + */ + public ScholixIdentifierType setId(String id) { + this.id = id; + return this; + } + + /** + * Gets The scheme or namespace of the identifier string + * + * @return the id scheme + */ + @Schema(description = "The scheme or namespace of the identifier string") + public String getIdScheme() { + return idScheme; + } + + /** + * Sets The scheme or namespace of the identifier string + * + * @param idScheme the id scheme + * @return the id scheme + */ + public ScholixIdentifierType setIdScheme(String idScheme) { + this.idScheme = idScheme; + return this; + } + + /** + * Gets An internet resolvable form of the identifier + * + * @return the id url + */ + @Schema(description = "An internet resolvable form of the identifier") + public String getIdURL() { + return idURL; + } + + /** + * Sets An internet resolvable form of the identifier + * + * @param idURL the id url + * @return the id url + */ + public ScholixIdentifierType setIdURL(String idURL) { + this.idURL = idURL; + return this; + } + + + public static ScholixIdentifierType fromScholixIdentifier(ScholixIdentifier input) { + if (input== null) + return null; + final ScholixIdentifierType instance = new ScholixIdentifierType(); + + instance.setId(input.getIdentifier()); + instance.setIdScheme(input.getSchema()); + instance.setIdURL(input.getUrl()); + return instance; + } + + + +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixItemType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixItemType.java new file mode 100644 index 0000000..a053d13 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixItemType.java @@ -0,0 +1,188 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v2; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.scholix.ScholixResource; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The type Scholix item type. + */ +public class ScholixItemType { + + @JsonProperty("Identifier") + private List identifier = new ArrayList(); + + @JsonProperty("Title") + private String title; + + @JsonProperty("Type") + private String type; + + @JsonProperty("Creator") + private List creator = new ArrayList<>(); + + @JsonProperty("PublicationDate") + private String publicationDate; + + @JsonProperty("Publisher") + private List publisher = new ArrayList<>(); + + + /** + * Gets identifier. + * + * @return the identifier + */ + public List getIdentifier() { + return identifier; + } + + /** + * Sets identifier. + * + * @param identifier the identifier + * @return the identifier + */ + public ScholixItemType setIdentifier(List identifier) { + this.identifier = identifier; + return this; + } + + /** + * Gets title. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Sets title. + * + * @param title the title + * @return the title + */ + public ScholixItemType setTitle(String title) { + this.title = title; + return this; + } + + /** + * Gets type. + * + * @return the type + */ + public String getType() { + return type; + } + + /** + * Sets type. + * + * @param type the type + * @return the type + */ + public ScholixItemType setType(String type) { + this.type = type; + return this; + } + + /** + * Gets creator. + * + * @return the creator + */ + public List getCreator() { + return creator; + } + + /** + * Sets creator. + * + * @param creator the creator + * @return the creator + */ + public ScholixItemType setCreator(List creator) { + this.creator = creator; + return this; + } + + /** + * Gets publication date. + * + * @return the publication date + */ + public String getPublicationDate() { + return publicationDate; + } + + /** + * Sets publication date. + * + * @param publicationDate the publication date + * @return the publication date + */ + public ScholixItemType setPublicationDate(String publicationDate) { + this.publicationDate = publicationDate; + return this; + } + + /** + * Gets publisher. + * + * @return the publisher + */ + public List getPublisher() { + return publisher; + } + + /** + * Sets publisher. + * + * @param publisher the publisher + * @return the publisher + */ + public ScholixItemType setPublisher(List publisher) { + this.publisher = publisher; + return this; + } + + + + public static ScholixItemType fromScholixResource(final ScholixResource input) { + if (input == null) + return null; + final ScholixItemType instance = new ScholixItemType(); + instance.setType("publication".equalsIgnoreCase(input.getObjectType())?"literature": "dataset"); + instance.setTitle(input.getTitle()); + + if (input.getIdentifier()!= null) + instance.setIdentifier(input.getIdentifier() + .stream() + .map(ScholixIdentifierType::fromScholixIdentifier ) + .collect(Collectors.toList()) + ); + + + if (input.getPublisher()!= null) { + instance.setPublisher( + input.getPublisher().stream() + .map(ScholixLinkProviderType::fromScholixEntityId) + .collect(Collectors.toList()) + ); + } + + instance.setPublicationDate(input.getPublicationDate()); + if(input.getCreator()!=null) + instance.setCreator(input.getCreator() + .stream() + .map(ScholixCreatorType::fromScholixEntityId) + .collect(Collectors.toList())); + + return instance; + } +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixLinkProviderType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixLinkProviderType.java new file mode 100644 index 0000000..7b7acb6 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixLinkProviderType.java @@ -0,0 +1,86 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v2; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotBlank; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The type Scholix link provider type. + */ +public class ScholixLinkProviderType { + @NotBlank + @JsonProperty("name") + private String name = null; + + + @NotBlank + @JsonProperty("identifier") + private List identifier = new ArrayList<>(); + + /** + * Gets A List of unique string that identifies the object + * + * @return the identifier + */ + @Schema(description = "A List of unique string that identifies the object") + public List getIdentifier() { + return identifier; + } + + /** + * Sets A List of unique string that identifies the object + * + * @param identifier the identifier + * @return the identifier + */ + public ScholixLinkProviderType setIdentifier(List identifier) { + this.identifier = identifier; + return this; + } + + + /** + * Gets The name of the Provider + * + * @return the name + */ + @Schema(description = "The name of the Provider") + public String getName() { + return name; + } + + /** + * Sets The name of the Provider + * + * @param name the name + * @return the name + */ + public ScholixLinkProviderType setName(String name) { + this.name = name; + return this; + } + + + public static ScholixLinkProviderType fromScholixEntityId(final ScholixEntityId provider) { + if (provider == null) + return null; + ScholixLinkProviderType instance = new ScholixLinkProviderType().setName(provider.getName()); + + + if (provider.getIdentifiers()!= null && provider.getIdentifiers().size()>0) + instance.setIdentifier(provider.getIdentifiers() + .stream() + .map(i ->new ScholixIdentifierType() + .setId(i.getIdentifier()) + .setIdScheme(i.getSchema())) + .collect(Collectors.toList())); + return instance; + + + } +} \ No newline at end of file diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixType.java new file mode 100644 index 0000000..0306120 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixType.java @@ -0,0 +1,197 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v2; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.scholix.Scholix; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The type Scholix type. + */ +public class ScholixType implements Serializable { + + + @NotBlank + @JsonProperty("RelationshipType") + private RelationshipType relationshipType ; + + @NotBlank + @JsonProperty("source") + private ScholixItemType source ; + + @NotBlank + @JsonProperty("target") + private ScholixItemType target ; + + @JsonProperty("HarvestDate") + private String harvestDate ; + + + @JsonProperty("LicenseURL") + private String licenseURL ; + + @JsonProperty("LinkProvider") + private List linkProvider ; + + @JsonProperty("LinkPublicationDate") + private String linkPublicationDate ; + + + /** + * Gets the nature of the relationship between the source object and target object in this Link Information Package + * + * @return the relationship type + */ + @Schema(description = "The nature of the relationship between the source object and target object in this Link Information Package") + public RelationshipType getRelationshipType() { + return relationshipType; + } + + /** + * Sets relationship type. + * + * @param relationshipType the relationship type + */ + public void setRelationshipType(RelationshipType relationshipType) { + this.relationshipType = relationshipType; + } + + /** + * Gets Root element relative to all properties describing the link’s source object + * + * @return the source + */ + @Schema(description = "Root element relative to all properties describing the link’s source object") + public ScholixItemType getSource() { + return source; + } + + /** + * Sets source. + * + * @param source the source + */ + public void setSource(ScholixItemType source) { + this.source = source; + } + + /** + * Gets Root element relative to all properties describing the link’s target object + * + * @return the target + */ + @Schema(description = "Gets Root element relative to all properties describing the link’s target object") + public ScholixItemType getTarget() { + return target; + } + + /** + * Sets target. + * + * @param target the target + */ + public void setTarget(ScholixItemType target) { + this.target = target; + } + + /** + * Gets harvest date. + * + * @return the harvest date + */ + public String getHarvestDate() { + return harvestDate; + } + + /** + * Sets harvest date. + * + * @param harvestDate the harvest date + */ + public void setHarvestDate(String harvestDate) { + this.harvestDate = harvestDate; + } + + /** + * Gets The URL of the license for the Scholix Link Information Package + * + * @return the license url + */ + @Schema(description = "The URL of the license for the Scholix Link Information Package") + public String getLicenseURL() { + return licenseURL; + } + + /** + * Sets license url. + * + * @param licenseURL the license url + */ + public void setLicenseURL(String licenseURL) { + this.licenseURL = licenseURL; + } + + /** + * Gets The source(s) of this Link Information Package. + * + * @return the link provider + */ + @Schema(description = "The source(s) of this Link Information Package") + public List getLinkProvider() { + return linkProvider; + } + + /** + * Sets link provider. + * + * @param linkProvider the link provider + */ + public void setLinkProvider(List linkProvider) { + this.linkProvider = linkProvider; + } + + /** + * Gets Date when this Link Information Package was first formally issued from this current Provider + * + * @return the link publication date + */ + @Schema(description = "Date when this Link Information Package was first formally issued from this current Provider") + + public String getLinkPublicationDate() { + return linkPublicationDate; + } + + /** + * Sets link publication date. + * + * @param linkPublicationDate the link publication date + */ + public void setLinkPublicationDate(String linkPublicationDate) { + this.linkPublicationDate = linkPublicationDate; + } + + + + public static ScholixType fromScholix(Scholix input) { + final ScholixType instance = new ScholixType(); + instance.setLinkPublicationDate(input.getPublicationDate()); + instance.setHarvestDate(input.getPublicationDate()); + instance.setRelationshipType(RelationshipType.fromScholixRelationship(input.getRelationship())); + + if(input.getLinkprovider()!= null && input.getLinkprovider().size()>0) + instance.setLinkProvider(input.getLinkprovider() + .stream() + .map(ScholixLinkProviderType::fromScholixEntityId) + .collect(Collectors.toList()) + ); + + + instance.setSource(ScholixItemType.fromScholixResource(input.getSource())); + instance.setTarget(ScholixItemType.fromScholixResource(input.getTarget())); + return instance; + } +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixItemType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixItemType.java new file mode 100644 index 0000000..0fb6a65 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixItemType.java @@ -0,0 +1,215 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v3; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixCreatorType; +import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixIdentifierType; +import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixLinkProviderType; +import eu.dnetlib.dhp.schema.sx.scholix.ScholixResource; + +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The type Scholix item type. + */ +public class ScholixItemType { + + @JsonProperty("Identifier") + private List identifier = new ArrayList(); + + @JsonProperty("Title") + private String title; + + @JsonProperty("Type") + private String type; + + @JsonProperty("subType") + private String subType; + + @JsonProperty("Creator") + private List creator = new ArrayList<>(); + + @JsonProperty("PublicationDate") + private String publicationDate; + + @JsonProperty("Publisher") + private List publisher = new ArrayList<>(); + + + /** + * Gets identifier. + * + * @return the identifier + */ + public List getIdentifier() { + return identifier; + } + + /** + * Sets identifier. + * + * @param identifier the identifier + * @return the identifier + */ + public ScholixItemType setIdentifier(List identifier) { + this.identifier = identifier; + return this; + } + + /** + * Gets title. + * + * @return the title + */ + public String getTitle() { + return title; + } + + /** + * Sets title. + * + * @param title the title + * @return the title + */ + public ScholixItemType setTitle(String title) { + this.title = title; + return this; + } + + /** + * Gets type. + * + * @return the type + */ + public String getSubType() { + return subType; + } + + /** + * Sets sub Type. + * + * @param subType the subType + * @return the title + */ + public ScholixItemType setSubType(String subType) { + this.subType = subType; + return this; + } + + /** + * Gets type. + * + * @return the type + */ + public String getType() { + return type; + } + + + /** + * Sets type. + * + * @param type the type + * @return the type + */ + public ScholixItemType setType(String type) { + this.type = type; + return this; + } + + /** + * Gets creator. + * + * @return the creator + */ + public List getCreator() { + return creator; + } + + /** + * Sets creator. + * + * @param creator the creator + * @return the creator + */ + public ScholixItemType setCreator(List creator) { + this.creator = creator; + return this; + } + + /** + * Gets publication date. + * + * @return the publication date + */ + public String getPublicationDate() { + return publicationDate; + } + + /** + * Sets publication date. + * + * @param publicationDate the publication date + * @return the publication date + */ + public ScholixItemType setPublicationDate(String publicationDate) { + this.publicationDate = publicationDate; + return this; + } + + /** + * Gets publisher. + * + * @return the publisher + */ + public List getPublisher() { + return publisher; + } + + /** + * Sets publisher. + * + * @param publisher the publisher + * @return the publisher + */ + public ScholixItemType setPublisher(List publisher) { + this.publisher = publisher; + return this; + } + + + + public static ScholixItemType fromScholixResource(final ScholixResource input) { + if (input == null) + return null; + final ScholixItemType instance = new ScholixItemType(); + instance.setType("publication".equalsIgnoreCase(input.getObjectType())?"literature": "dataset"); + instance.setTitle(input.getTitle()); + + if (input.getIdentifier()!= null) + instance.setIdentifier(input.getIdentifier() + .stream() + .map(ScholixIdentifierType::fromScholixIdentifier ) + .collect(Collectors.toList()) + ); + + + if (input.getPublisher()!= null) { + instance.setPublisher( + input.getPublisher().stream() + .map(ScholixLinkProviderType::fromScholixEntityId) + .collect(Collectors.toList()) + ); + } + + instance.setPublicationDate(input.getPublicationDate()); + if(input.getCreator()!=null) + instance.setCreator(input.getCreator() + .stream() + .map(ScholixCreatorType::fromScholixEntityId) + .collect(Collectors.toList())); + + return instance; + } +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixType.java new file mode 100644 index 0000000..aa41988 --- /dev/null +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixType.java @@ -0,0 +1,199 @@ +package eu.dnetlib.dhp.schema.sx.api.model.v3; + +import com.fasterxml.jackson.annotation.JsonProperty; +import eu.dnetlib.dhp.schema.sx.api.model.v2.RelationshipType; +import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixLinkProviderType; +import eu.dnetlib.dhp.schema.sx.scholix.Scholix; +import io.swagger.v3.oas.annotations.media.Schema; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; + +/** + * The type Scholix type. + */ +public class ScholixType implements Serializable { + + + @NotBlank + @JsonProperty("RelationshipType") + private RelationshipType relationshipType ; + + @NotBlank + @JsonProperty("source") + private ScholixItemType source ; + + @NotBlank + @JsonProperty("target") + private ScholixItemType target ; + + @JsonProperty("HarvestDate") + private String harvestDate ; + + + @JsonProperty("LicenseURL") + private String licenseURL ; + + @JsonProperty("LinkProvider") + private List linkProvider ; + + @JsonProperty("LinkPublicationDate") + private String linkPublicationDate ; + + + /** + * Gets the nature of the relationship between the source object and target object in this Link Information Package + * + * @return the relationship type + */ + @Schema(description = "The nature of the relationship between the source object and target object in this Link Information Package") + public RelationshipType getRelationshipType() { + return relationshipType; + } + + /** + * Sets relationship type. + * + * @param relationshipType the relationship type + */ + public void setRelationshipType(RelationshipType relationshipType) { + this.relationshipType = relationshipType; + } + + /** + * Gets Root element relative to all properties describing the link’s source object + * + * @return the source + */ + @Schema(description = "Root element relative to all properties describing the link’s source object") + public ScholixItemType getSource() { + return source; + } + + /** + * Sets source. + * + * @param source the source + */ + public void setSource(ScholixItemType source) { + this.source = source; + } + + /** + * Gets Root element relative to all properties describing the link’s target object + * + * @return the target + */ + @Schema(description = "Gets Root element relative to all properties describing the link’s target object") + public ScholixItemType getTarget() { + return target; + } + + /** + * Sets target. + * + * @param target the target + */ + public void setTarget(ScholixItemType target) { + this.target = target; + } + + /** + * Gets harvest date. + * + * @return the harvest date + */ + public String getHarvestDate() { + return harvestDate; + } + + /** + * Sets harvest date. + * + * @param harvestDate the harvest date + */ + public void setHarvestDate(String harvestDate) { + this.harvestDate = harvestDate; + } + + /** + * Gets The URL of the license for the Scholix Link Information Package + * + * @return the license url + */ + @Schema(description = "The URL of the license for the Scholix Link Information Package") + public String getLicenseURL() { + return licenseURL; + } + + /** + * Sets license url. + * + * @param licenseURL the license url + */ + public void setLicenseURL(String licenseURL) { + this.licenseURL = licenseURL; + } + + /** + * Gets The source(s) of this Link Information Package. + * + * @return the link provider + */ + @Schema(description = "The source(s) of this Link Information Package") + public List getLinkProvider() { + return linkProvider; + } + + /** + * Sets link provider. + * + * @param linkProvider the link provider + */ + public void setLinkProvider(List linkProvider) { + this.linkProvider = linkProvider; + } + + /** + * Gets Date when this Link Information Package was first formally issued from this current Provider + * + * @return the link publication date + */ + @Schema(description = "Date when this Link Information Package was first formally issued from this current Provider") + + public String getLinkPublicationDate() { + return linkPublicationDate; + } + + /** + * Sets link publication date. + * + * @param linkPublicationDate the link publication date + */ + public void setLinkPublicationDate(String linkPublicationDate) { + this.linkPublicationDate = linkPublicationDate; + } + + + + public static ScholixType fromScholix(Scholix input) { + final ScholixType instance = new ScholixType(); + instance.setLinkPublicationDate(input.getPublicationDate()); + instance.setHarvestDate(input.getPublicationDate()); + instance.setRelationshipType(RelationshipType.fromScholixRelationship(input.getRelationship())); + + if(input.getLinkprovider()!= null && input.getLinkprovider().size()>0) + instance.setLinkProvider(input.getLinkprovider() + .stream() + .map(ScholixLinkProviderType::fromScholixEntityId) + .collect(Collectors.toList()) + ); + + + instance.setSource(ScholixItemType.fromScholixResource(input.getSource())); + instance.setTarget(ScholixItemType.fromScholixResource(input.getTarget())); + return instance; + } +} -- 2.17.1 From 986f60b5fedf4939ecda987b2db2d22c58b584ed Mon Sep 17 00:00:00 2001 From: Sandro La Bruzzo Date: Tue, 29 Mar 2022 11:12:08 +0200 Subject: [PATCH 5/8] code formatted --- pom.xml | 2 +- .../dhp/schema/sx/api/model/v1/LinkPublisher.java | 10 ++++++---- .../dhp/schema/sx/api/model/v1/ScholixCreator.java | 9 +++++---- .../schema/sx/api/model/v1/ScholixIdentifier.java | 7 ++++--- .../dhp/schema/sx/api/model/v1/ScholixItem.java | 9 +++++---- .../schema/sx/api/model/v1/ScholixProvider.java | 12 +++++++----- .../sx/api/model/v1/ScholixRelationship.java | 10 ++++++---- .../dhp/schema/sx/api/model/v1/ScholixV1.java | 12 +++++++----- .../schema/sx/api/model/v2/LinkProviderType.java | 10 ++++++---- .../dhp/schema/sx/api/model/v2/PageResultType.java | 12 +++++++----- .../schema/sx/api/model/v2/RelationshipType.java | 12 +++++++----- .../schema/sx/api/model/v2/ScholixCreatorType.java | 12 +++++++----- .../sx/api/model/v2/ScholixIdentifierType.java | 5 +++-- .../schema/sx/api/model/v2/ScholixItemType.java | 7 ++++--- .../sx/api/model/v2/ScholixLinkProviderType.java | 14 ++++++++------ .../dhp/schema/sx/api/model/v2/ScholixType.java | 12 +++++++----- .../schema/sx/api/model/v3/ScholixItemType.java | 13 +++++++------ .../dhp/schema/sx/api/model/v3/ScholixType.java | 12 +++++++----- .../eu/dnetlib/dhp/schema/sx/scholix/Scholix.java | 4 ++-- .../schema/sx/scholix/ScholixCollectedFrom.java | 4 ++-- .../dhp/schema/sx/scholix/ScholixComparator.java | 1 + .../dhp/schema/sx/scholix/ScholixEntityId.java | 7 ++++--- .../dhp/schema/sx/scholix/ScholixIdentifier.java | 5 +++-- .../dhp/schema/sx/scholix/ScholixRelationship.java | 5 +++-- .../dhp/schema/sx/scholix/ScholixResource.java | 4 ++-- .../dhp/schema/sx/scholix/ScholixCompareTest.java | 8 +++++--- 26 files changed, 126 insertions(+), 92 deletions(-) diff --git a/pom.xml b/pom.xml index 1b691d5..828e19d 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,4 @@ - + 4.0.0 diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/LinkPublisher.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/LinkPublisher.java index 91c3f97..3582da3 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/LinkPublisher.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/LinkPublisher.java @@ -1,11 +1,13 @@ package eu.dnetlib.dhp.schema.sx.api.model.v1; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; +import java.util.Objects; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; -import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.v3.oas.annotations.media.Schema; public class LinkPublisher { @NotBlank @@ -94,4 +96,4 @@ public class LinkPublisher { } return o.toString().replace("\n", "\n "); } -} \ No newline at end of file +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixCreator.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixCreator.java index da53442..d0c9943 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixCreator.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixCreator.java @@ -1,12 +1,13 @@ package eu.dnetlib.dhp.schema.sx.api.model.v1; -import com.fasterxml.jackson.annotation.JsonProperty; -import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; -import io.swagger.v3.oas.annotations.media.Schema; - import java.util.List; import java.util.stream.Collectors; +import com.fasterxml.jackson.annotation.JsonProperty; + +import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; +import io.swagger.v3.oas.annotations.media.Schema; + public class ScholixCreator { @JsonProperty("name") diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixIdentifier.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixIdentifier.java index 752aa82..167230b 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixIdentifier.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixIdentifier.java @@ -1,10 +1,11 @@ package eu.dnetlib.dhp.schema.sx.api.model.v1; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; - import java.util.Objects; +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.v3.oas.annotations.media.Schema; + public class ScholixIdentifier { @JsonProperty("identifier") diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixItem.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixItem.java index bd84344..a98f780 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixItem.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixItem.java @@ -1,14 +1,15 @@ package eu.dnetlib.dhp.schema.sx.api.model.v1; -import com.fasterxml.jackson.annotation.JsonProperty; -import eu.dnetlib.dhp.schema.sx.scholix.ScholixResource; -import io.swagger.v3.oas.annotations.media.Schema; - import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; +import com.fasterxml.jackson.annotation.JsonProperty; + +import eu.dnetlib.dhp.schema.sx.scholix.ScholixResource; +import io.swagger.v3.oas.annotations.media.Schema; + public class ScholixItem { @JsonProperty("identifiers") diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixProvider.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixProvider.java index fd700ef..58c8af9 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixProvider.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixProvider.java @@ -1,15 +1,17 @@ package eu.dnetlib.dhp.schema.sx.api.model.v1; -import com.fasterxml.jackson.annotation.JsonProperty; -import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.Valid; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; +import javax.validation.Valid; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; +import io.swagger.v3.oas.annotations.media.Schema; + public class ScholixProvider { public static ScholixProvider fromScholixEntityId(final ScholixEntityId provider) { diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixRelationship.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixRelationship.java index 4d357f2..0337253 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixRelationship.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixRelationship.java @@ -1,12 +1,14 @@ package eu.dnetlib.dhp.schema.sx.api.model.v1; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; +import static eu.dnetlib.dhp.schema.sx.api.model.v2.RelationshipType.relationMapping; -import javax.validation.constraints.NotBlank; import java.util.Objects; -import static eu.dnetlib.dhp.schema.sx.api.model.v2.RelationshipType.relationMapping; +import javax.validation.constraints.NotBlank; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.v3.oas.annotations.media.Schema; public class ScholixRelationship { diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixV1.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixV1.java index 3cd3e7b..ac28653 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixV1.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v1/ScholixV1.java @@ -1,16 +1,18 @@ package eu.dnetlib.dhp.schema.sx.api.model.v1; -import com.fasterxml.jackson.annotation.JsonProperty; -import eu.dnetlib.dhp.schema.sx.scholix.Scholix; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.NotBlank; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; +import javax.validation.constraints.NotBlank; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import eu.dnetlib.dhp.schema.sx.scholix.Scholix; +import io.swagger.v3.oas.annotations.media.Schema; + public class ScholixV1 implements Serializable { @JsonProperty("linkProvider") diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/LinkProviderType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/LinkProviderType.java index 01c9adb..510d53e 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/LinkProviderType.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/LinkProviderType.java @@ -1,11 +1,13 @@ package eu.dnetlib.dhp.schema.sx.api.model.v2; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.v3.oas.annotations.media.Schema; +import java.util.Objects; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; -import java.util.Objects; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.v3.oas.annotations.media.Schema; /** * The type Link provider type. @@ -120,4 +122,4 @@ public class LinkProviderType { } return o.toString().replace("\n", "\n "); } -} \ No newline at end of file +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/PageResultType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/PageResultType.java index 8ebbbf5..f804865 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/PageResultType.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/PageResultType.java @@ -1,14 +1,16 @@ package eu.dnetlib.dhp.schema.sx.api.model.v2; -import com.fasterxml.jackson.annotation.JsonProperty; -import io.swagger.annotations.ApiModelProperty; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.NotBlank; import java.io.Serializable; import java.util.ArrayList; import java.util.List; +import javax.validation.constraints.NotBlank; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import io.swagger.annotations.ApiModelProperty; +import io.swagger.v3.oas.annotations.media.Schema; + /** * The main class that show the page result from the method * /l2/links diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/RelationshipType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/RelationshipType.java index a6f37a5..8dd4545 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/RelationshipType.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/RelationshipType.java @@ -1,14 +1,16 @@ package eu.dnetlib.dhp.schema.sx.api.model.v2; -import com.fasterxml.jackson.annotation.JsonProperty; -import eu.dnetlib.dhp.schema.sx.scholix.ScholixRelationship; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.NotNull; import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; +import javax.validation.constraints.NotNull; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import eu.dnetlib.dhp.schema.sx.scholix.ScholixRelationship; +import io.swagger.v3.oas.annotations.media.Schema; + /** * The type Relationship type. */ diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixCreatorType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixCreatorType.java index e06f9c2..6e5713a 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixCreatorType.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixCreatorType.java @@ -1,14 +1,16 @@ package eu.dnetlib.dhp.schema.sx.api.model.v2; -import com.fasterxml.jackson.annotation.JsonProperty; -import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.NotBlank; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import javax.validation.constraints.NotBlank; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; +import io.swagger.v3.oas.annotations.media.Schema; + /** * The type Scholix creator type. */ diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixIdentifierType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixIdentifierType.java index e85dcd4..a6f0dec 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixIdentifierType.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixIdentifierType.java @@ -1,11 +1,12 @@ package eu.dnetlib.dhp.schema.sx.api.model.v2; +import javax.validation.constraints.NotBlank; + import com.fasterxml.jackson.annotation.JsonProperty; + import eu.dnetlib.dhp.schema.sx.scholix.ScholixIdentifier; import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotBlank; - /** * The type Scholix identifier type. */ diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixItemType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixItemType.java index a053d13..d86da31 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixItemType.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixItemType.java @@ -1,12 +1,13 @@ package eu.dnetlib.dhp.schema.sx.api.model.v2; -import com.fasterxml.jackson.annotation.JsonProperty; -import eu.dnetlib.dhp.schema.sx.scholix.ScholixResource; - import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import com.fasterxml.jackson.annotation.JsonProperty; + +import eu.dnetlib.dhp.schema.sx.scholix.ScholixResource; + /** * The type Scholix item type. */ diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixLinkProviderType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixLinkProviderType.java index 7b7acb6..f2a5afb 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixLinkProviderType.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixLinkProviderType.java @@ -1,14 +1,16 @@ package eu.dnetlib.dhp.schema.sx.api.model.v2; -import com.fasterxml.jackson.annotation.JsonProperty; -import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.NotBlank; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import javax.validation.constraints.NotBlank; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import eu.dnetlib.dhp.schema.sx.scholix.ScholixEntityId; +import io.swagger.v3.oas.annotations.media.Schema; + /** * The type Scholix link provider type. */ @@ -83,4 +85,4 @@ public class ScholixLinkProviderType { } -} \ No newline at end of file +} diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixType.java index 0306120..ed05a27 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixType.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v2/ScholixType.java @@ -1,14 +1,16 @@ package eu.dnetlib.dhp.schema.sx.api.model.v2; -import com.fasterxml.jackson.annotation.JsonProperty; -import eu.dnetlib.dhp.schema.sx.scholix.Scholix; -import io.swagger.v3.oas.annotations.media.Schema; - -import javax.validation.constraints.NotBlank; import java.io.Serializable; import java.util.List; import java.util.stream.Collectors; +import javax.validation.constraints.NotBlank; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import eu.dnetlib.dhp.schema.sx.scholix.Scholix; +import io.swagger.v3.oas.annotations.media.Schema; + /** * The type Scholix type. */ diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixItemType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixItemType.java index 0fb6a65..79a5740 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixItemType.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixItemType.java @@ -1,15 +1,16 @@ package eu.dnetlib.dhp.schema.sx.api.model.v3; -import com.fasterxml.jackson.annotation.JsonProperty; -import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixCreatorType; -import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixIdentifierType; -import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixLinkProviderType; -import eu.dnetlib.dhp.schema.sx.scholix.ScholixResource; - import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; +import com.fasterxml.jackson.annotation.JsonProperty; + +import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixCreatorType; +import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixIdentifierType; +import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixLinkProviderType; +import eu.dnetlib.dhp.schema.sx.scholix.ScholixResource; + /** * The type Scholix item type. */ diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixType.java b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixType.java index aa41988..90722a5 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixType.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/api/model/v3/ScholixType.java @@ -1,16 +1,18 @@ package eu.dnetlib.dhp.schema.sx.api.model.v3; +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; + +import javax.validation.constraints.NotBlank; + import com.fasterxml.jackson.annotation.JsonProperty; + import eu.dnetlib.dhp.schema.sx.api.model.v2.RelationshipType; import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixLinkProviderType; import eu.dnetlib.dhp.schema.sx.scholix.Scholix; import io.swagger.v3.oas.annotations.media.Schema; -import javax.validation.constraints.NotBlank; -import java.io.Serializable; -import java.util.List; -import java.util.stream.Collectors; - /** * The type Scholix type. */ diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java index 95338ea..ec8bcc9 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/Scholix.java @@ -1,14 +1,14 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import org.apache.commons.lang3.StringUtils; +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; import java.io.Serializable; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; +import org.apache.commons.lang3.StringUtils; public class Scholix implements Serializable, Comparable { diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCollectedFrom.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCollectedFrom.java index cd415de..832617d 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCollectedFrom.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCollectedFrom.java @@ -1,12 +1,12 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import org.apache.commons.lang3.StringUtils; +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; import java.io.Serializable; import java.util.Objects; -import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; +import org.apache.commons.lang3.StringUtils; public class ScholixCollectedFrom implements Serializable, Comparable { diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java index 55c7c0e..f71c9b5 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixComparator.java @@ -5,6 +5,7 @@ import java.util.List; import java.util.stream.Stream; import com.google.common.collect.Iterators; + import me.xuender.unidecode.Unidecode; public class ScholixComparator { diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java index 266b946..3753e6d 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixEntityId.java @@ -1,8 +1,7 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import com.google.common.collect.Iterators; -import org.apache.commons.lang3.StringUtils; +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeString; import java.io.Serializable; import java.util.List; @@ -10,7 +9,9 @@ import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; -import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeString; +import org.apache.commons.lang3.StringUtils; + +import com.google.common.collect.Iterators; public class ScholixEntityId implements Serializable, Comparable { private String name; diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java index f8b0cf1..9e1a0a2 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixIdentifier.java @@ -1,11 +1,12 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import org.apache.commons.lang3.StringUtils; +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeIdnetifier; + import java.io.Serializable; import java.util.Objects; -import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeIdnetifier; +import org.apache.commons.lang3.StringUtils; /** * The type Scholix identifier. diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixRelationship.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixRelationship.java index deeaab8..f05a16d 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixRelationship.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixRelationship.java @@ -1,11 +1,12 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import org.apache.commons.lang3.StringUtils; +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; import java.io.Serializable; import java.util.Objects; -import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; + +import org.apache.commons.lang3.StringUtils; public class ScholixRelationship implements Serializable, Comparable { private String name; diff --git a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixResource.java b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixResource.java index d7b61ad..55ef84e 100644 --- a/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixResource.java +++ b/src/main/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixResource.java @@ -1,14 +1,14 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import org.apache.commons.lang3.StringUtils; +import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; import java.io.Serializable; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; -import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*; +import org.apache.commons.lang3.StringUtils; public class ScholixResource implements Serializable, Comparable { diff --git a/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java b/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java index 2762873..cf534c9 100644 --- a/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java +++ b/src/test/java/eu/dnetlib/dhp/schema/sx/scholix/ScholixCompareTest.java @@ -1,12 +1,14 @@ package eu.dnetlib.dhp.schema.sx.scholix; -import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotEquals; + import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertNotEquals; + +import org.junit.jupiter.api.Test; public class ScholixCompareTest { -- 2.17.1 From 0798a35924c3914f58b0c0cd897f449821c45e84 Mon Sep 17 00:00:00 2001 From: Sandro La Bruzzo Date: Tue, 29 Mar 2022 11:18:30 +0200 Subject: [PATCH 6/8] removed wrong string --- pom.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 828e19d..b740d66 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,4 @@ - + 4.0.0 @@ -352,7 +352,7 @@ io.swagger swagger-annotations - 1.5.20 + ${dhp.swagger-annotations-version} io.swagger.core.v3 @@ -438,6 +438,7 @@ + 1.5.20 UTF-8 UTF-8 3.6.0 -- 2.17.1 From f8d7a15c3265ed6a2f3bfd437703d8a2484e4128 Mon Sep 17 00:00:00 2001 From: Sandro La Bruzzo Date: Tue, 29 Mar 2022 11:29:05 +0200 Subject: [PATCH 7/8] converted all explicit dependencies version to maven property --- pom.xml | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index b740d66..346ea56 100644 --- a/pom.xml +++ b/pom.xml @@ -285,13 +285,13 @@ me.xuender unidecode - 0.0.7 + ${dhp.unidecode.version} org.slf4j jcl-over-slf4j - 1.7.25 + ${dhp.slf4j.version} provided @@ -304,7 +304,7 @@ com.github.sisyphsu dateparser - 1.0.7 + ${dhp.dateparser.version} @@ -316,13 +316,13 @@ commons-codec commons-codec - 1.9 + ${dhp.commons.codec.version} commons-io commons-io - 2.4 + ${dhp.commons.io.version} @@ -336,7 +336,7 @@ javax.persistence javax.persistence-api - 2.2 + ${dhp.javax.persistence.api.version} provided @@ -357,14 +357,14 @@ io.swagger.core.v3 swagger-annotations - 2.1.12 + ${dhp.swagger.annotations.version} javax.validation validation-api - 2.0.1.Final + ${dhp.validation.api.version} @@ -432,12 +432,23 @@ com.github.imifou jsonschema-module-addon - 1.2.1 + ${dhp.jsonschema.module.addon.version} + + + 1.0.7 + 1.2.1 + 2.0.1.Final + 2.1.12 + 2.2 + 1.9 + 2.4 + 1.7.25 + 0.0.7 1.5.20 UTF-8 UTF-8 -- 2.17.1 From 0be00f4361a78f03560c39390923f84dc044ab79 Mon Sep 17 00:00:00 2001 From: Sandro La Bruzzo Date: Tue, 29 Mar 2022 11:39:48 +0200 Subject: [PATCH 8/8] moved all dependency with version under dependency-management section --- pom.xml | 70 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 51 insertions(+), 19 deletions(-) diff --git a/pom.xml b/pom.xml index 91b2e45..66a26ce 100644 --- a/pom.xml +++ b/pom.xml @@ -340,6 +340,55 @@ provided + + io.swagger + swagger-annotations + ${dhp.swagger-annotations-version} + + + io.swagger.core.v3 + swagger-annotations + ${dhp.swagger.annotations.version} + + + + javax.validation + validation-api + ${dhp.validation.api.version} + + + + org.junit.jupiter + junit-jupiter + ${junit-jupiter.version} + test + + + + org.mockito + mockito-core + ${mockito-core.version} + test + + + + org.mockito + mockito-junit-jupiter + ${mockito-core.version} + test + + + + com.github.victools + jsonschema-generator + ${jsonschemagenerator.version} + + + com.github.imifou + jsonschema-module-addon + ${dhp.jsonschema.module.addon.version} + + @@ -352,41 +401,30 @@ io.swagger swagger-annotations - ${dhp.swagger-annotations-version} + io.swagger.core.v3 swagger-annotations - ${dhp.swagger.annotations.version} - javax.validation validation-api - ${dhp.validation.api.version} - - org.junit.jupiter junit-jupiter - ${junit-jupiter.version} - test org.mockito mockito-core - ${mockito-core.version} - test org.mockito mockito-junit-jupiter - ${mockito-core.version} - test @@ -426,20 +464,14 @@ com.github.victools jsonschema-generator - ${jsonschemagenerator.version} - com.github.imifou jsonschema-module-addon - ${dhp.jsonschema.module.addon.version} - - + - - 1.0.7 1.2.1 2.0.1.Final -- 2.17.1