moved data model of API into dhp-schemas

This commit is contained in:
Sandro La Bruzzo 2022-02-28 14:26:55 +01:00
parent 786449a43c
commit 7abf6af997
21 changed files with 8 additions and 1863 deletions

View File

@ -1,9 +1,10 @@
package eu.dnetlib.scholix.api.controller;
import eu.dnetlib.common.controller.AbstractDnetController;
import eu.dnetlib.dhp.schema.sx.api.model.v1.LinkPublisher;
import eu.dnetlib.scholix.api.ScholixException;
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
import eu.dnetlib.scholix.api.model.v1.LinkPublisher;
import io.micrometer.core.annotation.Timed;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;

View File

@ -1,7 +1,7 @@
package eu.dnetlib.scholix.api.controller;
import eu.dnetlib.scholix.api.ScholixException;
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
import eu.dnetlib.scholix.api.model.v2.LinkProviderType;
import eu.dnetlib.dhp.schema.sx.api.model.v2.LinkProviderType;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;

View File

@ -1,7 +1,7 @@
package eu.dnetlib.scholix.api.controller;
import eu.dnetlib.scholix.api.ScholixException;
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
import eu.dnetlib.scholix.api.model.v2.LinkProviderType;
import eu.dnetlib.dhp.schema.sx.api.model.v2.LinkProviderType;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;

View File

@ -5,7 +5,7 @@ import eu.dnetlib.common.controller.AbstractDnetController;
import eu.dnetlib.dhp.schema.sx.scholix.Scholix;
import eu.dnetlib.scholix.api.ScholixException;
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
import eu.dnetlib.scholix.api.model.v1.ScholixV1;
import eu.dnetlib.dhp.schema.sx.api.model.v1.ScholixV1;
import io.micrometer.core.annotation.Timed;
import io.swagger.annotations.Api;
import io.swagger.v3.oas.annotations.Operation;

View File

@ -2,12 +2,11 @@ package eu.dnetlib.scholix.api.controller;
import eu.dnetlib.common.controller.AbstractDnetController;
import eu.dnetlib.dhp.schema.sx.api.model.v2.PageResultType;
import eu.dnetlib.dhp.schema.sx.api.model.v2.ScholixType;
import eu.dnetlib.dhp.schema.sx.scholix.Scholix;
import eu.dnetlib.scholix.api.ScholixAPIVersion;
import eu.dnetlib.scholix.api.ScholixException;
import eu.dnetlib.scholix.api.index.ScholixIndexManager;
import eu.dnetlib.scholix.api.model.v2.PageResultType;
import eu.dnetlib.scholix.api.model.v2.ScholixType;
import io.micrometer.core.annotation.Timed;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

View File

@ -1,97 +0,0 @@
package eu.dnetlib.scholix.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 ");
}
}

View File

@ -1,69 +0,0 @@
package eu.dnetlib.scholix.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<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

@ -1,71 +0,0 @@
package eu.dnetlib.scholix.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;
}
}

View File

@ -1,161 +0,0 @@
package eu.dnetlib.scholix.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<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

@ -1,129 +0,0 @@
package eu.dnetlib.scholix.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<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

@ -1,134 +0,0 @@
package eu.dnetlib.scholix.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.scholix.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;
}
}

View File

@ -1,184 +0,0 @@
package eu.dnetlib.scholix.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<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

@ -1,124 +0,0 @@
package eu.dnetlib.scholix.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 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 ");
}
}

View File

@ -1,114 +0,0 @@
package eu.dnetlib.scholix.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<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

@ -1,109 +0,0 @@
package eu.dnetlib.scholix.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.Collections;
import java.util.HashMap;
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<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

@ -1,86 +0,0 @@
package eu.dnetlib.scholix.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<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

@ -1,105 +0,0 @@
package eu.dnetlib.scholix.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;
import java.util.Objects;
/**
* 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

@ -1,188 +0,0 @@
package eu.dnetlib.scholix.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<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

@ -1,88 +0,0 @@
package eu.dnetlib.scholix.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 javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
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<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

@ -1,196 +0,0 @@
package eu.dnetlib.scholix.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<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

@ -398,7 +398,7 @@
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.plugin.version>3.6.0</maven.compiler.plugin.version>
<java.version>1.8</java.version>
<dhp-schemas-version>2.10.24</dhp-schemas-version>
<dhp-schemas-version>2.10.30-SCHOLEXPLORER-SNAPSHOT</dhp-schemas-version>
<apache.solr.version>7.1.0</apache.solr.version>
<mongodb.driver.version>3.4.2</mongodb.driver.version>
<springfox-version>2.8.0</springfox-version>