scholexplorer_incremental_index #14

Merged
sandro.labruzzo merged 12 commits from scholexplorer_incremental_index into master 2022-03-29 11:43:02 +02:00
26 changed files with 3016 additions and 40 deletions

109
pom.xml
View File

@ -138,6 +138,9 @@
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
</plugin>
sandro.labruzzo marked this conversation as resolved
Review

Please cleanup non necessary changes.

Please cleanup non necessary changes.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
@ -279,10 +282,16 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>me.xuender</groupId>
<artifactId>unidecode</artifactId>
<version>${dhp.unidecode.version}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.7.25</version>
<version>${dhp.slf4j.version}</version>
<scope>provided</scope>
</dependency>
@ -295,7 +304,7 @@
<dependency>
<groupId>com.github.sisyphsu</groupId>
<artifactId>dateparser</artifactId>
<version>1.0.7</version>
<version>${dhp.dateparser.version}</version>
</dependency>
<dependency>
@ -307,15 +316,16 @@
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.9</version>
<version>${dhp.commons.codec.version}</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.4</version>
<version>${dhp.commons.io.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
@ -326,34 +336,95 @@
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId>
<version>2.2</version>
<version>${dhp.javax.persistence.api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${dhp.swagger-annotations-version}</version>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
<version>${dhp.swagger.annotations.version}</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>${dhp.validation.api.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.victools</groupId>
<artifactId>jsonschema-generator</artifactId>
<version>${jsonschemagenerator.version}</version>
</dependency>
<dependency>
<groupId>com.github.imifou</groupId>
<artifactId>jsonschema-module-addon</artifactId>
<version>${dhp.jsonschema.module.addon.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>me.xuender</groupId>
<artifactId>unidecode</artifactId>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit-jupiter.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>${mockito-core.version}</version>
<scope>test</scope>
</dependency>
<dependency>
@ -393,18 +464,24 @@
<dependency>
<groupId>com.github.victools</groupId>
<artifactId>jsonschema-generator</artifactId>
<version>${jsonschemagenerator.version}</version>
<!-- <scope>test</scope>-->
</dependency>
<dependency>
<groupId>com.github.imifou</groupId>
<artifactId>jsonschema-module-addon</artifactId>
<version>1.2.1</version>
</dependency>
</dependency>
</dependencies>
<properties>
<dhp.dateparser.version>1.0.7</dhp.dateparser.version>
<dhp.jsonschema.module.addon.version>1.2.1</dhp.jsonschema.module.addon.version>
<dhp.validation.api.version>2.0.1.Final</dhp.validation.api.version>
<dhp.swagger.annotations.version>2.1.12</dhp.swagger.annotations.version>
<dhp.javax.persistence.api.version>2.2</dhp.javax.persistence.api.version>
<dhp.commons.codec.version>1.9</dhp.commons.codec.version>
<dhp.commons.io.version>2.4</dhp.commons.io.version>
<dhp.slf4j.version>1.7.25</dhp.slf4j.version>
<dhp.unidecode.version>0.0.7</dhp.unidecode.version>
<dhp.swagger-annotations-version>1.5.20</dhp.swagger-annotations-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.plugin.version>3.6.0</maven.compiler.plugin.version>

View File

@ -0,0 +1,99 @@
package eu.dnetlib.dhp.schema.sx.api.model.v1;
import java.util.Objects;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
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 ");
}
}

View File

@ -0,0 +1,70 @@
package eu.dnetlib.dhp.schema.sx.api.model.v1;
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")
private String name = null;
@JsonProperty("identifier")
private List<ScholixIdentifier> 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<ScholixIdentifier> getIdentifier() {
return identifier;
}
public ScholixCreator setIdentifier(List<ScholixIdentifier> 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;
}
}

View File

@ -0,0 +1,72 @@
package eu.dnetlib.dhp.schema.sx.api.model.v1;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
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;
}
}

View File

@ -0,0 +1,162 @@
package eu.dnetlib.dhp.schema.sx.api.model.v1;
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")
private List<ScholixIdentifier> identifiers;
@JsonProperty("objectType")
private String objectType;
@JsonProperty("objectSubType")
private String objectSubType;
@JsonProperty("title")
private String title;
@JsonProperty("creator")
private List<ScholixCreator> creator;
@JsonProperty("publicationDate")
private String publicationDate;
@JsonProperty("publisher")
private List<ScholixProvider> publisher;
@Schema(description = "The list of identifiers")
public List<ScholixIdentifier> getIdentifiers() {
return identifiers;
}
public ScholixItem setIdentifiers(List<ScholixIdentifier> 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<ScholixCreator> 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<ScholixCreator> getCreator() {
return creator;
}
public void setCreator(List<ScholixCreator> 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<ScholixProvider> getPublisher() {
return publisher;
}
public ScholixItem setPublisher(List<ScholixProvider> 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;
}
}

View File

@ -0,0 +1,131 @@
package eu.dnetlib.dhp.schema.sx.api.model.v1;
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) {
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<ScholixIdentifier> 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<ScholixIdentifier> 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<ScholixIdentifier> getIdentifier() {
return identifier;
}
public ScholixProvider setIdentifier(List<ScholixIdentifier> 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 ");
}
}

View File

@ -0,0 +1,136 @@
package eu.dnetlib.dhp.schema.sx.api.model.v1;
import static eu.dnetlib.dhp.schema.sx.api.model.v2.RelationshipType.relationMapping;
import java.util.Objects;
import javax.validation.constraints.NotBlank;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
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;
}
}

View File

@ -0,0 +1,186 @@
package eu.dnetlib.dhp.schema.sx.api.model.v1;
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")
private List<ScholixProvider> 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<ScholixProvider> linkProvider ) {
this.linkProvider = linkProvider;
return this;
}
@Schema(description = "An entity responsible for making this record available online")
public List<ScholixProvider> 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<ScholixProvider> 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 links 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 links 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;
}
}

View File

@ -0,0 +1,125 @@
package eu.dnetlib.dhp.schema.sx.api.model.v2;
import java.util.Objects;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
/**
* 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 ");
}
}

View File

@ -0,0 +1,116 @@
package eu.dnetlib.dhp.schema.sx.api.model.v2;
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
*/
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<ScholixType> 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<ScholixType> getResult() {
return result;
}
/**
* Sets result.
*
* @param result the result
*/
public void setResult(List<ScholixType> result) {
this.result = result;
}
}

View File

@ -0,0 +1,109 @@
package eu.dnetlib.dhp.schema.sx.api.model.v2;
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.
*/
public class RelationshipType {
@NotNull
@JsonProperty("Name")
private String name;
@JsonProperty("SubType")
private String subType;
@JsonProperty("SubTypeSchema")
private String subTypeSchema;
public static Map<String, String> 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());
}
}

View File

@ -0,0 +1,88 @@
package eu.dnetlib.dhp.schema.sx.api.model.v2;
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.
*/
public class ScholixCreatorType {
@NotBlank
@JsonProperty("name")
private String name = null;
@NotBlank
@JsonProperty("identifier")
private List<ScholixIdentifierType> 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<ScholixIdentifierType> getIdentifier() {
return identifier;
}
/**
* Sets A List of unique string that identifies the creator
*
* @param identifier the identifier
* @return the identifier
*/
public ScholixCreatorType setIdentifier(List<ScholixIdentifierType> 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;
}
}

View File

@ -0,0 +1,105 @@
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;
/**
* 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;
}
}

View File

@ -0,0 +1,189 @@
package eu.dnetlib.dhp.schema.sx.api.model.v2;
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.
*/
public class ScholixItemType {
@JsonProperty("Identifier")
private List<ScholixIdentifierType> identifier = new ArrayList();
@JsonProperty("Title")
private String title;
@JsonProperty("Type")
private String type;
@JsonProperty("Creator")
private List<ScholixCreatorType> creator = new ArrayList<>();
@JsonProperty("PublicationDate")
private String publicationDate;
@JsonProperty("Publisher")
private List<ScholixLinkProviderType> publisher = new ArrayList<>();
/**
* Gets identifier.
*
* @return the identifier
*/
public List<ScholixIdentifierType> getIdentifier() {
return identifier;
}
/**
* Sets identifier.
*
* @param identifier the identifier
* @return the identifier
*/
public ScholixItemType setIdentifier(List<ScholixIdentifierType> 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<ScholixCreatorType> getCreator() {
return creator;
}
/**
* Sets creator.
*
* @param creator the creator
* @return the creator
*/
public ScholixItemType setCreator(List<ScholixCreatorType> 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<ScholixLinkProviderType> getPublisher() {
return publisher;
}
/**
* Sets publisher.
*
* @param publisher the publisher
* @return the publisher
*/
public ScholixItemType setPublisher(List<ScholixLinkProviderType> 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;
}
}

View File

@ -0,0 +1,88 @@
package eu.dnetlib.dhp.schema.sx.api.model.v2;
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.
*/
public class ScholixLinkProviderType {
@NotBlank
@JsonProperty("name")
private String name = null;
@NotBlank
@JsonProperty("identifier")
private List<ScholixIdentifierType> 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<ScholixIdentifierType> getIdentifier() {
return identifier;
}
/**
* Sets A List of unique string that identifies the object
*
* @param identifier the identifier
* @return the identifier
*/
public ScholixLinkProviderType setIdentifier(List<ScholixIdentifierType> 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;
}
}

View File

@ -0,0 +1,199 @@
package eu.dnetlib.dhp.schema.sx.api.model.v2;
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.
*/
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<ScholixLinkProviderType> 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 links source object
*
* @return the source
*/
@Schema(description = "Root element relative to all properties describing the links 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 links target object
*
* @return the target
*/
@Schema(description = "Gets Root element relative to all properties describing the links 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<ScholixLinkProviderType> getLinkProvider() {
return linkProvider;
}
/**
* Sets link provider.
*
* @param linkProvider the link provider
*/
public void setLinkProvider(List<ScholixLinkProviderType> 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;
}
}

View File

@ -0,0 +1,216 @@
package eu.dnetlib.dhp.schema.sx.api.model.v3;
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.
*/
public class ScholixItemType {
@JsonProperty("Identifier")
private List<ScholixIdentifierType> identifier = new ArrayList();
@JsonProperty("Title")
private String title;
@JsonProperty("Type")
private String type;
@JsonProperty("subType")
private String subType;
@JsonProperty("Creator")
private List<ScholixCreatorType> creator = new ArrayList<>();
@JsonProperty("PublicationDate")
private String publicationDate;
@JsonProperty("Publisher")
private List<ScholixLinkProviderType> publisher = new ArrayList<>();
/**
* Gets identifier.
*
* @return the identifier
*/
public List<ScholixIdentifierType> getIdentifier() {
return identifier;
}
/**
* Sets identifier.
*
* @param identifier the identifier
* @return the identifier
*/
public ScholixItemType setIdentifier(List<ScholixIdentifierType> 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<ScholixCreatorType> getCreator() {
return creator;
}
/**
* Sets creator.
*
* @param creator the creator
* @return the creator
*/
public ScholixItemType setCreator(List<ScholixCreatorType> 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<ScholixLinkProviderType> getPublisher() {
return publisher;
}
/**
* Sets publisher.
*
* @param publisher the publisher
* @return the publisher
*/
public ScholixItemType setPublisher(List<ScholixLinkProviderType> 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;
}
}

View File

@ -0,0 +1,201 @@
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;
/**
* 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<ScholixLinkProviderType> 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 links source object
*
* @return the source
*/
@Schema(description = "Root element relative to all properties describing the links 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 links target object
*
* @return the target
*/
@Schema(description = "Gets Root element relative to all properties describing the links 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<ScholixLinkProviderType> getLinkProvider() {
return linkProvider;
}
/**
* Sets link provider.
*
* @param linkProvider the link provider
*/
public void setLinkProvider(List<ScholixLinkProviderType> 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;
}
}

View File

@ -1,10 +1,17 @@
package eu.dnetlib.dhp.schema.sx.scholix;
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 org.apache.commons.lang3.StringUtils;
public class Scholix implements Serializable, Comparable<Scholix> {
public class Scholix implements Serializable {
private String publicationDate;
private List<ScholixEntityId> publisher;
@ -74,4 +81,54 @@ public class Scholix implements Serializable {
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
@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) {
if (other == null)
return -1;
// Comparing publication date
final int publicationDateCompare =StringUtils.compare(publicationDate, other.getPublicationDate());
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;
final int sourceComparator = compareObjects(source, other.getSource());
if (sourceComparator!= 0)
return sourceComparator;
return compareObjects(target, other.getTarget());
}
}

View File

@ -1,9 +1,14 @@
package eu.dnetlib.dhp.schema.sx.scholix;
import java.io.Serializable;
import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*;
public class ScholixCollectedFrom implements Serializable {
import java.io.Serializable;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
public class ScholixCollectedFrom implements Serializable, Comparable<ScholixCollectedFrom> {
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;
}
}

View File

@ -0,0 +1,59 @@
package eu.dnetlib.dhp.schema.sx.scholix;
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 Unidecode.decode(input).toLowerCase();
}
public static <T extends Comparable<T>> int compareObjects (T left, T right) {
if (left == null && right==null)
return 0;
if(left == null)
return 1;
if (right == null)
return -1;
return left.compareTo(right);
}
public static <T extends Comparable<T>> int compareList (List<T> left, List<T> right) {
if (left == null && right==null)
return 0;
if(left == null)
return 1;
if (right == null)
return -1;
Stream<T> sortedLeft = left.stream().sorted();
Stream<T> sortedRight = right.stream().sorted();
boolean equals = Iterators.elementsEqual(sortedLeft.iterator(), sortedRight.iterator());
return equals? 0: -1;
}
}

View File

@ -1,10 +1,19 @@
package eu.dnetlib.dhp.schema.sx.scholix;
import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeString;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class ScholixEntityId implements Serializable {
import org.apache.commons.lang3.StringUtils;
import com.google.common.collect.Iterators;
public class ScholixEntityId implements Serializable, Comparable<ScholixEntityId> {
private String name;
private List<ScholixIdentifier> identifiers;
@ -31,4 +40,31 @@ public class ScholixEntityId implements Serializable {
public void setIdentifiers(List<ScholixIdentifier> 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() {
if (identifiers != null)
return Objects.hash(normalizeString(name), identifiers.stream().sorted().collect(Collectors.toList()));
else
return Objects.hash(normalizeString(name));
}
@Override
public int compareTo(ScholixEntityId other) {
if (other == null)
return -1;
final int nameComp = StringUtils.compare(normalizeString(name), normalizeString(other.getName()));
if (nameComp != 0)
return nameComp;
return ScholixComparator.compareList(identifiers,other.getIdentifiers());
}
}

View File

@ -1,17 +1,34 @@
package eu.dnetlib.dhp.schema.sx.scholix;
import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.normalizeIdnetifier;
import java.io.Serializable;
import java.util.Objects;
public class ScholixIdentifier implements Serializable {
import org.apache.commons.lang3.StringUtils;
/**
* The type Scholix identifier.
*/
public class ScholixIdentifier implements Serializable, Comparable<ScholixIdentifier> {
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;
@ -19,41 +36,87 @@ public class ScholixIdentifier implements Serializable {
}
/**
* Gets url.
*
* @return the url
*/
public String getUrl() {
return url;
}
/**
* Sets url.
*
* @param url the url
*/
public void setUrl(String url) {
this.url = url;
}
/**
* Gets identifier.
*
* @return the identifier
*/
public String getIdentifier() {
return identifier;
}
/**
* Sets identifier.
*
* @param identifier the identifier
*/
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
/**
* Gets schema.
*
* @return the schema
*/
public String getSchema() {
return schema;
}
/**
* Sets schema.
*
* @param schema the schema
*/
public void setSchema(String schema) {
this.schema = schema;
}
@Override
public int compareTo(ScholixIdentifier other) {
if (other == null)
return -1;
final int idComp = StringUtils.compare(normalizeIdnetifier(identifier), normalizeIdnetifier(other.getIdentifier()));
if (idComp !=0)
return idComp;
final int schemaComp = StringUtils.compare(normalizeIdnetifier(schema), normalizeIdnetifier(other.getSchema()));
if (schemaComp !=0)
return schemaComp;
return StringUtils.compare(normalizeIdnetifier(url), normalizeIdnetifier(other.getUrl()));
}
@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);
return compareTo(that) == 0;
}
@Override
public int hashCode() {
return Objects.hash(identifier, schema);
return Objects.hash(normalizeIdnetifier(identifier), normalizeIdnetifier(schema), normalizeIdnetifier(url));
}
public String getIdentifier() {
return identifier;
}
public void setIdentifier(String identifier) {
this.identifier = identifier;
}
public String getSchema() {
return schema;
}
public void setSchema(String schema) {
this.schema = schema;
}
}

View File

@ -1,9 +1,14 @@
package eu.dnetlib.dhp.schema.sx.scholix;
import java.io.Serializable;
import static eu.dnetlib.dhp.schema.sx.scholix.ScholixComparator.*;
public class ScholixRelationship implements Serializable {
import java.io.Serializable;
import java.util.Objects;
import org.apache.commons.lang3.StringUtils;
public class ScholixRelationship implements Serializable, Comparable<ScholixRelationship> {
private String name;
private String schema;
private String inverse;
@ -40,4 +45,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()));
}
}

View File

@ -1,10 +1,16 @@
package eu.dnetlib.dhp.schema.sx.scholix;
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;
public class ScholixResource implements Serializable {
import org.apache.commons.lang3.StringUtils;
public class ScholixResource implements Serializable, Comparable<ScholixResource> {
private List<ScholixIdentifier> identifier;
private String dnetIdentifier;
@ -87,4 +93,71 @@ public class ScholixResource implements Serializable {
public void setCollectedFrom(List<ScholixCollectedFrom> 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());
}
}

View File

@ -0,0 +1,241 @@
package eu.dnetlib.dhp.schema.sx.scholix;
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 org.junit.jupiter.api.Test;
public class ScholixCompareTest {
private ScholixIdentifier generateMockScholixId(final String baseId ,boolean toUpper, int idCount) {
final String id = String.format("%s.%d",baseId, idCount);
final String schema = "DOI";
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(String name, boolean toUpper, boolean invertOrder, int numberOfIds) {
final List<ScholixIdentifier> 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? name.toUpperCase(): name.toLowerCase(), ids);
}
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(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";
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;
}
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<ScholixIdentifier> 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<ScholixEntityId> 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<ScholixEntityId> 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<ScholixCollectedFrom> 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));
}
@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 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());
}
@Test
public void testCompareScholixRelation() {
final ScholixRelationship left = generateMockScholixRelationships(true);
final ScholixRelationship right = generateMockScholixRelationships(false);
assertEquals(left, right);
assertEquals(left.hashCode(), right.hashCode());
}
}