Oaf validation #10

Open
claudio.atzori wants to merge 5 commits from validation into master
14 changed files with 113 additions and 6 deletions

27
pom.xml
View File

@ -315,6 +315,24 @@
<version>2.4</version> <version>2.4</version>
</dependency> </dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</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>1.2.1</version>
</dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
@ -389,16 +407,19 @@
<groupId>javax.persistence</groupId> <groupId>javax.persistence</groupId>
<artifactId>javax.persistence-api</artifactId> <artifactId>javax.persistence-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.github.victools</groupId> <groupId>com.github.victools</groupId>
<artifactId>jsonschema-generator</artifactId> <artifactId>jsonschema-generator</artifactId>
<version>${jsonschemagenerator.version}</version>
<!-- <scope>test</scope>-->
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.github.imifou</groupId> <groupId>com.github.imifou</groupId>
<artifactId>jsonschema-module-addon</artifactId> <artifactId>jsonschema-module-addon</artifactId>
<version>1.2.1</version>
</dependency> </dependency>
</dependencies> </dependencies>

View File

@ -3,11 +3,14 @@ package eu.dnetlib.dhp.schema.oaf;
import java.util.Optional; import java.util.Optional;
import javax.validation.constraints.NotNull;
/** /**
* This class models the access rights of research products. * This class models the access rights of research products.
*/ */
public class AccessRight extends Qualifier { public class AccessRight extends Qualifier {
@NotNull
private OpenAccessRoute openAccessRoute; private OpenAccessRoute openAccessRoute;
public OpenAccessRoute getOpenAccessRoute() { public OpenAccessRoute getOpenAccessRoute() {

View File

@ -4,8 +4,13 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable; import java.io.Serializable;
import java.util.*; import java.util.*;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
public class Author implements Serializable { public class Author implements Serializable {
@NotBlank
private String fullname; private String fullname;
private String name; private String name;
@ -13,6 +18,8 @@ public class Author implements Serializable {
private String surname; private String surname;
// START WITH 1 // START WITH 1
@NotNull
@Min(1)
private Integer rank; private Integer rank;
private List<StructuredProperty> pid; private List<StructuredProperty> pid;

View File

@ -4,9 +4,15 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
public class Context implements Serializable { public class Context implements Serializable {
@NotBlank
private String id; private String id;
@NotNull
private List<DataInfo> dataInfo; private List<DataInfo> dataInfo;
public String getId() { public String getId() {

View File

@ -4,13 +4,24 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
public class DataInfo implements Serializable { public class DataInfo implements Serializable {
@NotNull
private Boolean invisible = false; private Boolean invisible = false;
@NotNull
private Boolean inferred; private Boolean inferred;
@NotNull
private Boolean deletedbyinference = false; private Boolean deletedbyinference = false;
private String trust; private String trust;
private String inferenceprovenance; private String inferenceprovenance;
@NotNull
private Qualifier provenanceaction; private Qualifier provenanceaction;
public Boolean getInvisible() { public Boolean getInvisible() {

View File

@ -4,8 +4,11 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable; import java.io.Serializable;
import java.util.Objects; import java.util.Objects;
import javax.validation.constraints.NotBlank;
public class Field<T> implements Serializable { public class Field<T> implements Serializable {
@NotBlank
private T value; private T value;
private DataInfo dataInfo; private DataInfo dataInfo;

View File

@ -4,21 +4,30 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
public class Instance implements Serializable { public class Instance implements Serializable {
private Field<String> license; private Field<String> license;
@NotNull
private AccessRight accessright; private AccessRight accessright;
@NotNull
private Qualifier instancetype; private Qualifier instancetype;
@NotNull
private KeyValue hostedby; private KeyValue hostedby;
@NotEmpty
private List<String> url; private List<String> url;
// other research products specifc // other research products specifc
private String distributionlocation; private String distributionlocation;
@NotNull
private KeyValue collectedfrom; private KeyValue collectedfrom;
private List<StructuredProperty> pid; private List<StructuredProperty> pid;
@ -35,6 +44,7 @@ public class Instance implements Serializable {
// typed results // typed results
private Field<String> processingchargecurrency; private Field<String> processingchargecurrency;
@NotNull
private Qualifier refereed; // peer-review status private Qualifier refereed; // peer-review status
private List<Measure> measures; private List<Measure> measures;

View File

@ -3,14 +3,19 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable; import java.io.Serializable;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
public class KeyValue implements Serializable { public class KeyValue implements Serializable {
@NotBlank
private String key; private String key;
@NotBlank
private String value; private String value;
private DataInfo dataInfo; private DataInfo dataInfo;

View File

@ -9,13 +9,21 @@ import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
public abstract class Oaf implements Serializable { public abstract class Oaf implements Serializable {
/** /**
* The list of datasource id/name pairs providing this relationship. * The list of datasource id/name pairs providing this relationship.
*/ */
@Valid
@NotEmpty
protected List<KeyValue> collectedfrom; protected List<KeyValue> collectedfrom;
@Valid
@NotNull
private DataInfo dataInfo; private DataInfo dataInfo;
private Long lastupdatetimestamp; private Long lastupdatetimestamp;

View File

@ -5,14 +5,18 @@ import java.io.Serializable;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.validation.constraints.NotBlank;
public abstract class OafEntity extends Oaf implements Serializable { public abstract class OafEntity extends Oaf implements Serializable {
@NotBlank
private String id; private String id;
private List<String> originalId; private List<String> originalId;
private List<StructuredProperty> pid; private List<StructuredProperty> pid;
@NotBlank
private String dateofcollection; private String dateofcollection;
private String dateoftransformation; private String dateoftransformation;

View File

@ -3,15 +3,24 @@ package eu.dnetlib.dhp.schema.oaf;
import java.io.Serializable; import java.io.Serializable;
import javax.validation.constraints.NotBlank;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
public class Qualifier implements Serializable { public class Qualifier implements Serializable {
@NotBlank
private String classid; private String classid;
@NotBlank
private String classname; private String classname;
@NotBlank
private String schemeid; private String schemeid;
@NotBlank
private String schemename; private String schemename;
public String getClassid() { public String getClassid() {

View File

@ -8,6 +8,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
import javax.validation.constraints.NotBlank;
import eu.dnetlib.dhp.schema.common.ModelSupport; import eu.dnetlib.dhp.schema.common.ModelSupport;
/** /**
@ -21,27 +23,32 @@ public class Relation extends Oaf {
/** /**
* Main relationship classifier, values include 'resultResult', 'resultProject', 'resultOrganization', etc. * Main relationship classifier, values include 'resultResult', 'resultProject', 'resultOrganization', etc.
*/ */
@NotBlank
private String relType; private String relType;
/** /**
* Further classifies a relationship, values include 'affiliation', 'similarity', 'supplement', etc. * Further classifies a relationship, values include 'affiliation', 'similarity', 'supplement', etc.
*/ */
@NotBlank
private String subRelType; private String subRelType;
/** /**
* Indicates the direction of the relationship, values include 'isSupplementTo', 'isSupplementedBy', 'merges, * Indicates the direction of the relationship, values include 'isSupplementTo', 'isSupplementedBy', 'merges,
* 'isMergedIn'. * 'isMergedIn'.
*/ */
@NotBlank
private String relClass; private String relClass;
/** /**
* The source entity id. * The source entity id.
*/ */
@NotBlank
private String source; private String source;
/** /**
* The target entity id. * The target entity id.
*/ */
@NotBlank
private String target; private String target;
/** /**

View File

@ -5,6 +5,10 @@ import java.io.Serializable;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair; import org.apache.commons.lang3.tuple.Pair;
@ -28,15 +32,15 @@ public class Result extends OafEntity implements Serializable {
private List<Author> author; private List<Author> author;
/** /**
* The Resulttype. * The Resulttype, allows subclassing results into publications | datasets | software
*/ */
// resulttype allows subclassing results into publications | datasets | software @Valid
@NotNull
private Qualifier resulttype; private Qualifier resulttype;
/** /**
* The Language. * The Language.
*/ */
// common fields
private Qualifier language; private Qualifier language;
/** /**
@ -112,6 +116,8 @@ public class Result extends OafEntity implements Serializable {
/** /**
* The Bestaccessright. * The Bestaccessright.
*/ */
@Valid
@NotNull
private Qualifier bestaccessright; private Qualifier bestaccessright;
/** /**
@ -127,6 +133,8 @@ public class Result extends OafEntity implements Serializable {
/** /**
* The Instance. * The Instance.
*/ */
@Valid
@NotEmpty
private List<Instance> instance; private List<Instance> instance;
/** /**

View File

@ -6,12 +6,17 @@ import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
public class StructuredProperty implements Serializable { public class StructuredProperty implements Serializable {
@NotBlank
private String value; private String value;
@NotNull
private Qualifier qualifier; private Qualifier qualifier;
private DataInfo dataInfo; private DataInfo dataInfo;