[Dump-schema] resolved conflicts

This commit is contained in:
Miriam Baglioni 2021-12-14 16:31:31 +01:00
commit 984375cb46
44 changed files with 961 additions and 119 deletions

32
pom.xml
View File

@ -137,7 +137,23 @@
<artifactId>maven-dependency-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>3.0.0</version>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${dhp.jackson.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
@ -229,6 +245,19 @@
<scalaVersion>${scala.version}</scalaVersion>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<includePluginDependencies>true</includePluginDependencies>
<mainClass>eu.dnetlib.dhp.schema.dump.ExecCreateSchemas</mainClass>
<arguments>
<argument>eu.dnetlib.dhp.schema.dump.oaf.GraphResult;eu.dnetlib.dhp.schema.dump.oaf.graph.Organization;eu.dnetlib.dhp.schema.dump.oaf.graph.Project</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
@ -364,13 +393,14 @@
<groupId>com.github.victools</groupId>
<artifactId>jsonschema-generator</artifactId>
<version>${jsonschemagenerator.version}</version>
<scope>test</scope>
<!-- <scope>test</scope>-->
</dependency>
<dependency>
<groupId>com.github.imifou</groupId>
<artifactId>jsonschema-module-addon</artifactId>
<version>1.2.1</version>
</dependency>
</dependencies>
<properties>

View File

@ -0,0 +1,75 @@
package eu.dnetlib.dhp.schema.dump;
import java.io.*;
import java.lang.reflect.Type;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Paths;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.github.imifou.jsonschema.module.addon.AddonModule;
import com.github.victools.jsonschema.generator.*;
import eu.dnetlib.dhp.schema.dump.oaf.community.CommunityResult;
import eu.dnetlib.dhp.schema.dump.oaf.graph.*;
public class ExecCreateSchemas {
final static String DIRECTORY = "/eu/dnetlib/dhp/schema/oaf/dump/jsonschemas/";
SchemaGenerator generator;
private void init(){
AddonModule module = new AddonModule();
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(
new ObjectMapper().enable(SerializationFeature.INDENT_OUTPUT),
SchemaVersion.DRAFT_7,
OptionPreset.PLAIN_JSON)
.with(module)
.with(Option.SCHEMA_VERSION_INDICATOR)
.without(Option.NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS);
SchemaGeneratorConfig config = configBuilder.build();
generator = new SchemaGenerator(config);
}
private void generate(Type targetType, String directory, String filename) throws IOException {
JsonNode jsonSchema = generator.generateSchema(targetType);
String dir = Paths.get(Paths.get(getClass().getResource("/").getPath()).toAbsolutePath() + directory).toString();
if(!Files.exists(Paths.get(dir))){
Files.createDirectories(Paths.get(dir));
}
if(!Files.exists(Paths.get(dir + "/" + filename))) {
Files.createFile(Paths.get(dir + "/" + filename));
}
File f = new File(dir + "/" + filename);
try(PrintWriter writer = new PrintWriter(new BufferedWriter(new FileWriter(f)))) {
writer.println(new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(jsonSchema));
}
}
public static void main(String[] args) throws IOException {
ExecCreateSchemas ecs = new ExecCreateSchemas();
ecs.init();
ecs.generate(GraphResult.class, DIRECTORY , "result_schema.json");
ecs.generate(ResearchCommunity.class, DIRECTORY , "community_infrastructure_schema.json");
ecs.generate(Datasource.class, DIRECTORY , "datasource_schema.json");
ecs.generate(Project.class, DIRECTORY , "project_schema.json");
ecs.generate(Relation.class, DIRECTORY , "relation_schema.json");
ecs.generate(Organization.class, DIRECTORY , "organization_schema.json");
ecs.generate(CommunityResult.class, DIRECTORY , "community_result_schema.json");
}
}

View File

@ -0,0 +1,40 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public class AlternateIdentifier implements Serializable {
@JsonSchema(description="The scheme of the identifier. It can be a persistent identifier (i.e. doi). If it is present in the alternate identifiers " +
"it means it has not been forged by an authority for that pid. For example we collect metadata from an institutional repository that provides " +
"as identifier for the result also the doi")
private String scheme;
@JsonSchema(description="The value expressed in the scheme")
private String value;
public String getScheme() {
return scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static AlternateIdentifier newInstance(String scheme, String value) {
AlternateIdentifier cf = new AlternateIdentifier();
cf.setScheme(scheme);
cf.setValue(value);
return cf;
}
}

View File

@ -3,6 +3,8 @@ package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* Used to represent the generic author of the result. It has six parameters: - name of type String to store the given
* name of the author. The value for this parameter corresponds to eu.dnetlib.dhp.schema.oaf.Author name - surname of

View File

@ -0,0 +1,54 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To represent the generic persistent identifier. It has two parameters:
* - id of type
* eu.dnetlib.dhp.schema.dump.oaf.AuthorPidSchemeValue to store the scheme and value of the Persistent Identifier.
* - provenance of type eu.dnetlib.dhp.schema.dump.oaf.Provenance to store the provenance and trust of the information
*/
public class AuthorPid implements Serializable {
private AuthorPidSchemeValue id;
@JsonSchema(description="The reason why the pid was associated to the author")
private Provenance provenance;
public AuthorPidSchemeValue getId() {
return id;
}
public void setId(AuthorPidSchemeValue pid) {
this.id = pid;
}
public Provenance getProvenance() {
return provenance;
}
public void setProvenance(Provenance provenance) {
this.provenance = provenance;
}
public static AuthorPid newInstance(AuthorPidSchemeValue pid, Provenance provenance) {
AuthorPid p = new AuthorPid();
p.id = pid;
p.provenance = provenance;
return p;
}
public static AuthorPid newInstance(AuthorPidSchemeValue pid) {
AuthorPid p = new AuthorPid();
p.id = pid;
return p;
}
}

View File

@ -0,0 +1,39 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public class AuthorPidSchemeValue implements Serializable {
@JsonSchema(description="The author's pid scheme. OpenAIRE currently supports 'ORCID'")
private String scheme;
@JsonSchema(description="The author's pid value in that scheme (i.e. 0000-1111-2222-3333)")
private String value;
public String getScheme() {
return scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static AuthorPidSchemeValue newInstance(String scheme, String value) {
AuthorPidSchemeValue cf = new AuthorPidSchemeValue();
cf.setScheme(scheme);
cf.setValue(value);
return cf;
}
}

View File

@ -1,16 +1,26 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* BestAccessRight. Used to represent the result best access rights. It extends the eu.dnet.lib.dhp.schema.dump.oaf.Qualifier
* element with a parameter scheme of type String to store the scheme. Values for this element are found against the
* BestAccessRight. Used to represent the result best access rights. Values for this element are found against the
* COAR access right scheme. The classid of the element accessright in eu.dnetlib.dhp.schema.oaf.Result is used to get
* the COAR corresponding code whose value will be used to set the code parameter. The COAR label corresponding to the
* COAR code will be used to set the label parameter. The scheme value will always be the one referring to the COAR
* access right scheme
*/
public class BestAccessRight extends Qualifier {
public class BestAccessRight implements Serializable {
@JsonSchema(description="COAR access mode code: http://vocabularies.coar-repositories.org/documentation/access_rights/")
private String code; // the classid in the Qualifier
@JsonSchema(description="Label for the access mode")
private String label; // the classname in the Qualifier
@JsonSchema(description="Scheme of reference for access right code. Always set to COAR access rights vocabulary: http://vocabularies.coar-repositories.org/documentation/access_rights/")
private String scheme;
public String getScheme() {
@ -21,11 +31,29 @@ public class BestAccessRight extends Qualifier {
this.scheme = scheme;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public static BestAccessRight newInstance(String code, String label, String scheme) {
BestAccessRight ar = new BestAccessRight();
ar.setCode(code);
ar.setLabel(label);
ar.setScheme(scheme);
ar.code = code ;
ar.label = label;
ar.scheme = scheme;
return ar;
}
}

View File

@ -3,6 +3,8 @@ package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To store information about the conference or journal where the result has been presented or published. It contains
* eleven parameters: - name of type String to store the name of the journal or conference. It corresponds to the
@ -22,6 +24,7 @@ import java.io.Serializable;
*/
public class Container implements Serializable {
@JsonSchema(description="Name of the journal or conference")
private String name;
private String issnPrinted;
@ -30,14 +33,19 @@ public class Container implements Serializable {
private String issnLinking;
@JsonSchema(description="End page")
private String ep;
@JsonSchema(description="Journal issue number")
private String iss;
@JsonSchema(description="Start page")
private String sp;
@JsonSchema(description = "Volume")
private String vol;
@JsonSchema(description="Edition of the journal or conference proceeding")
private String edition;
private String conferenceplace;

View File

@ -1,8 +1,12 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* Represents the country associated to this result. It extends eu.dnetlib.dhp.schema.dump.oaf.Qualifier with a
* Represents the country associated to the generic entity. It extends eu.dnetlib.dhp.schema.dump.oaf.Qualifier with a
* provenance parameter of type eu.dnetlib.dhp.schema.dumo.oaf.Provenance. The country in not mapped if its value in the
* result reprensented in the internal format is Unknown. The value for this element correspond to: - code corresponds
* to the classid of eu.dnetlib.dhp.schema.oaf.Country - label corresponds to the classname of
@ -10,28 +14,36 @@ package eu.dnetlib.dhp.schema.dump.oaf;
* dumped is not null. In this case : - provenance corresponds to dataInfo.provenanceaction.classid (to be modified with
* datainfo.provenanceaction.classname) - trust corresponds to dataInfo.trust
*/
public class Country extends Qualifier {
public class Country implements Serializable {
@JsonSchema(description="ISO 3166-1 alpha-2 country code (i.e. IT)")
private String code; // the classid in the Qualifier
private Provenance provenance;
@JsonSchema(description="The label for that code (i.e. Italy)")
private String label; // the classname in the Qualifier
public Provenance getProvenance() {
return provenance;
public String getCode() {
return code;
}
public void setProvenance(Provenance provenance) {
this.provenance = provenance;
public void setCode(String code) {
this.code = code;
}
public static Country newInstance(String code, String label, Provenance provenance) {
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public static Country newInstance(String code, String label) {
Country c = new Country();
c.setProvenance(provenance);
c.setCode(code);
c.setLabel(label);
return c;
}
public static Country newInstance(String code, String label, String provenance, String trust) {
return newInstance(code, label, Provenance.newInstance(provenance, trust));
}
}

View File

@ -3,11 +3,17 @@ package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public class Funder implements Serializable {
@JsonSchema(description = "The short name of the funder (EC)")
private String shortName;
@JsonSchema(description = "The name of the funder (European Commission)")
private String name;
@JsonSchema(description = "Geographical jurisdiction (e.g. for European Commission is EU, for Croatian Science Foundation is HR)")
private String jurisdiction;
public String getJurisdiction() {

View File

@ -1,8 +1,14 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* Represents the manifestations (i.e. different versions) of the result. For example: the pre-print and the published
* versions are two manifestations of the same research result. It has the following parameters: - license of type
@ -22,24 +28,37 @@ import java.util.List;
*/
public class Instance implements Serializable {
private List<KeyValue> measures;
@JsonSchema(description = "Measures computed for this instance, for example Bip!Finder ones")
private List<Measure> measures;
private List<ControlledField> pid;
private List<ResultPid> pid;
private List<ControlledField> alternateIdentifier;
@JsonSchema(description = "All the identifiers other than pids forged by an authorithy for the pid type (i.e. Crossref for DOIs")
private List<AlternateIdentifier> alternateIdentifier;
private String license;
@JsonSchema(description = "The accessRights for this materialization of the result")
private AccessRight accessright;
@JsonSchema(description = "The specific sub-type of this instance (see https://api.openaire.eu/vocabularies/dnet:result_typologies following the links)")
private String type;
@JsonSchema(description = "URLs to the instance. They may link to the actual full-text or to the landing page at the hosting source. ")
private List<String> url;
@JsonSchema(description = "The money spent to make this book or article available in Open Access. Source for this information is the OpenAPC initiative.")
private APC articleprocessingcharge;
@JsonSchema(description = "Date of the research product")
private String publicationdate;// dateofacceptance;
@JsonSchema(description = "If this instance has been peer-reviewed or not. Allowed values are peerReviewed, " +
"nonPeerReviewed, UNKNOWN (as defined in https://api.openaire.eu/vocabularies/dnet:review_levels)")
private String refereed; // peer-review status
public String getLicense() {
return license;
}
@ -96,27 +115,30 @@ public class Instance implements Serializable {
this.articleprocessingcharge = articleprocessingcharge;
}
public List<ControlledField> getPid() {
public List<ResultPid> getPid() {
return pid;
}
public void setPid(List<ControlledField> pid) {
public void setPid(List<ResultPid> pid) {
this.pid = pid;
}
public List<ControlledField> getAlternateIdentifier() {
public List<AlternateIdentifier> getAlternateIdentifier() {
return alternateIdentifier;
}
public void setAlternateIdentifier(List<ControlledField> alternateIdentifier) {
public void setAlternateIdentifier(List<AlternateIdentifier> alternateIdentifier) {
this.alternateIdentifier = alternateIdentifier;
}
public List<KeyValue> getMeasures() {
public List<Measure> getMeasures() {
return measures;
}
public void setMeasures(List<KeyValue> measures) {
public void setMeasures(List<Measure> measures) {
this.measures = measures;
}
}
}

View File

@ -1,48 +0,0 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
/**
* To represent the information described by a key and a value. It has two parameters: - key to store the key (generally
* the OpenAIRE id for some entity) - value to store the value (generally the OpenAIRE name for the key)
*/
public class KeyValue implements Serializable {
private String key;
private String value;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static KeyValue newInstance(String key, String value) {
KeyValue inst = new KeyValue();
inst.key = key;
inst.value = value;
return inst;
}
@JsonIgnore
public boolean isBlank() {
return StringUtils.isBlank(key) && StringUtils.isBlank(value);
}
}

View File

@ -0,0 +1,37 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public class Language implements Serializable {
@JsonSchema(description="alpha-3/ISO 639-2 code of the language")
private String code; // the classid in the Qualifier
@JsonSchema(description="Language label in English")
private String label; // the classname in the Qualifier
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public static Language newInstance(String code, String value) {
Language qualifier = new Language();
qualifier.setCode(code);
qualifier.setLabel(value);
return qualifier;
}
}

View File

@ -0,0 +1,45 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public class Measure implements Serializable {
@JsonSchema(description = "The measure (i.e. popularity)")
private String key;
@JsonSchema(description = "The value for that measure")
private String value;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static Measure newInstance(String key, String value) {
Measure inst = new Measure();
inst.key = key;
inst.value = value;
return inst;
}
@JsonIgnore
public boolean isBlank() {
return StringUtils.isBlank(key) && StringUtils.isBlank(value);
}
}

View File

@ -3,6 +3,8 @@ package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* This class to store the common information about the project that will be dumped for community and for the whole
* graph - private String id to store the id of the project (OpenAIRE id) - private String code to store the grant
@ -10,9 +12,13 @@ import java.io.Serializable;
* the tile of the project
*/
public class Project implements Serializable {
@JsonSchema(description = "The OpenAIRE id for the project")
protected String id;// OpenAIRE id
@JsonSchema(description = "The grant agreement number")
protected String code;
@JsonSchema(description = "The acronym of the project")
protected String acronym;
protected String title;

View File

@ -3,6 +3,8 @@ package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* Indicates the process that produced (or provided) the information, and the trust associated to the information. It
* has two parameters: - provenance of type String to store the provenance of the information, - trust of type String to

View File

@ -4,6 +4,8 @@ package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import java.util.List;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To represent the dumped result. It will be extended in the dump for Research Communities - Research
* Initiative/Infrastructures. It has the following parameters: - author of type

View File

@ -0,0 +1,40 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* Represents the country associated to the generic result. It extends eu.dnetlib.dhp.schema.dump.oaf.Country with a
* provenance parameter of type eu.dnetlib.dhp.schema.dumo.oaf.Provenance. The country is not mapped if its value in the
* result reprensented in the internal format is Unknown. The value for this element correspond to:
* - code corresponds to the classid of eu.dnetlib.dhp.schema.oaf.Country
* - label corresponds to the classname of eu.dnetlib.dhp.schema.oaf.Country
* - provenance set only if the dataInfo associated to the Country of the result to be dumped is not null. In this case:
* - provenance corresponds to dataInfo.provenanceaction.classid (to be modified with datainfo.provenanceaction.classname)
* - trust corresponds to dataInfo.trust
*/
public class ResultCountry extends Country {
@JsonSchema(description="Why this result is associated to the country.")
private Provenance provenance;
public Provenance getProvenance() {
return provenance;
}
public void setProvenance(Provenance provenance) {
this.provenance = provenance;
}
public static ResultCountry newInstance(String code, String label, Provenance provenance) {
ResultCountry c = new ResultCountry();
c.setProvenance(provenance);
c.setCode(code);
c.setLabel(label);
return c;
}
public static ResultCountry newInstance(String code, String label, String provenance, String trust) {
return newInstance(code, label, Provenance.newInstance(provenance, trust));
}
}

View File

@ -0,0 +1,41 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public class ResultPid implements Serializable {
@JsonSchema(description="The scheme of the persistent identifier for the result (i.e. doi). " +
"If the pid is here it means the information for the pid has been collected from an authority for " +
"that pid type (i.e. Crossref/Datacite for doi). The set of authoritative pid is: doi when collected from Crossref or Datacite " +
"pmid when collected from EuroPubmed, arxiv when collected from arXiv, handle from the repositories")
private String scheme;
@JsonSchema(description="The value expressed in the scheme (i.e. 10.1000/182)")
private String value;
public String getScheme() {
return scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static ResultPid newInstance(String scheme, String value) {
ResultPid cf = new ResultPid();
cf.setScheme(scheme);
cf.setValue(value);
return cf;
}
}

View File

@ -3,6 +3,8 @@ package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To represent keywords associated to the result. It has two parameters: - subject of type
* eu.dnetlib.dhp.schema.dump.oaf.ControlledField to describe the subject. It mapped as: - schema it corresponds to

View File

@ -0,0 +1,39 @@
package eu.dnetlib.dhp.schema.dump.oaf;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public class SubjectSchemeValue implements Serializable {
@JsonSchema(description="OpenAIRE subject classification scheme (https://api.openaire.eu/vocabularies/dnet:subject_classification_typologies).")
private String scheme;
@JsonSchema(description="The value for the subject in the selected scheme. When the scheme is 'keyword', it means that the subject is free-text (i.e. not a term from a controlled vocabulary).")
private String value;
public String getScheme() {
return scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static SubjectSchemeValue newInstance(String scheme, String value) {
SubjectSchemeValue cf = new SubjectSchemeValue();
cf.setScheme(scheme);
cf.setValue(value);
return cf;
}
}

View File

@ -0,0 +1,46 @@
package eu.dnetlib.dhp.schema.dump.oaf.community;
import java.io.Serializable;
import org.apache.commons.lang3.StringUtils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public class CfHbKeyValue implements Serializable {
@JsonSchema(description = "the OpenAIRE identifier of the data source")
private String key;
@JsonSchema(description = "the name of the data source")
private String value;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static CfHbKeyValue newInstance(String key, String value) {
CfHbKeyValue inst = new CfHbKeyValue();
inst.key = key;
inst.value = value;
return inst;
}
@JsonIgnore
public boolean isBlank() {
return StringUtils.isBlank(key) && StringUtils.isBlank(value);
}
}

View File

@ -1,8 +1,9 @@
package eu.dnetlib.dhp.schema.dump.oaf.community;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
import eu.dnetlib.dhp.schema.dump.oaf.Instance;
import eu.dnetlib.dhp.schema.dump.oaf.KeyValue;
/**
* It extends eu.dnetlib.dhp.dump.oaf.Instance with values related to the community dump. In the Result dump this
@ -15,22 +16,25 @@ import eu.dnetlib.dhp.schema.dump.oaf.KeyValue;
* collectedfrom.key - value corresponds to collectedfrom.value
*/
public class CommunityInstance extends Instance {
private KeyValue hostedby;
private KeyValue collectedfrom;
@JsonSchema(description = "Information about the source from which the instance can be viewed or downloaded.")
private CfHbKeyValue hostedby;
public KeyValue getHostedby() {
@JsonSchema(description = "Information about the source from which the record has been collected")
private CfHbKeyValue collectedfrom;
public CfHbKeyValue getHostedby() {
return hostedby;
}
public void setHostedby(KeyValue hostedby) {
public void setHostedby(CfHbKeyValue hostedby) {
this.hostedby = hostedby;
}
public KeyValue getCollectedfrom() {
public CfHbKeyValue getCollectedfrom() {
return collectedfrom;
}
public void setCollectedfrom(KeyValue collectedfrom) {
public void setCollectedfrom(CfHbKeyValue collectedfrom) {
this.collectedfrom = collectedfrom;
}
}

View File

@ -5,7 +5,6 @@ import java.util.List;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
import eu.dnetlib.dhp.schema.dump.oaf.KeyValue;
import eu.dnetlib.dhp.schema.dump.oaf.Result;
/**
@ -22,11 +21,14 @@ import eu.dnetlib.dhp.schema.dump.oaf.Result;
*/
public class CommunityResult extends Result {
@JsonSchema(description = "List of projects (i.e. grants) that (co-)funded the production ofn the research results")
private List<Project> projects;
@JsonSchema(description = "Reference to a relevant research infrastructure, initiative or community (RI/RC) among those collaborating with OpenAIRE. Please see https://connect.openaire.eu")
private List<Context> context;
protected List<KeyValue> collectedfrom;
@JsonSchema(description = "Information about the sources from which the record has been collected")
protected List<CfHbKeyValue> collectedfrom;
@JsonSchema(description = "Each instance is one specific materialisation or version of the result. For example, you can have one result with three instance: one is the pre-print, one is the post-print, one is te published version")
private List<CommunityInstance> instance;
@ -39,11 +41,11 @@ public class CommunityResult extends Result {
this.instance = instance;
}
public List<KeyValue> getCollectedfrom() {
public List<CfHbKeyValue> getCollectedfrom() {
return collectedfrom;
}
public void setCollectedfrom(List<KeyValue> collectedfrom) {
public void setCollectedfrom(List<CfHbKeyValue> collectedfrom) {
this.collectedfrom = collectedfrom;
}
@ -64,3 +66,5 @@ public class CommunityResult extends Result {
}
}

View File

@ -6,8 +6,9 @@ import java.util.Objects;
import java.util.Optional;
import java.util.stream.Collectors;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
import eu.dnetlib.dhp.schema.dump.oaf.Provenance;
import eu.dnetlib.dhp.schema.dump.oaf.Qualifier;
/**
* Reference to a relevant research infrastructure, initiative or community (RI/RC) among those collaborating with
@ -21,7 +22,14 @@ import eu.dnetlib.dhp.schema.dump.oaf.Qualifier;
* instantiated if the element datainfo.provenanceaction is not null. In this case - provenance corresponds to
* dataInfo.provenanceaction.classname - trust corresponds to dataInfo.trust
*/
public class Context extends Qualifier {
public class Context {
@JsonSchema(description="Code identifying the RI/RC")
private String code;
@JsonSchema(description="Label of the RI/RC")
private String label;
@JsonSchema(description = "Why this result is associated to the RI/RC.")
private List<Provenance> provenance;
public List<Provenance> getProvenance() {
@ -32,6 +40,23 @@ public class Context extends Qualifier {
this.provenance = provenance;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
@Override
public int hashCode() {
final String p = Optional.ofNullable(getProvenance())

View File

@ -1,6 +1,8 @@
package eu.dnetlib.dhp.schema.dump.oaf.community;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To store information about the funder funding the project related to the result. It has the following parameters: -
* shortName of type String to store the funder short name (e.c. AKA). - name of type String to store the funder name
@ -9,6 +11,7 @@ package eu.dnetlib.dhp.schema.dump.oaf.community;
*/
public class Funder extends eu.dnetlib.dhp.schema.dump.oaf.Funder {
@JsonSchema(description = "Stream of funding (e.g. for European Commission can be H2020 or FP7)")
private String fundingStream;
public String getFundingStream() {

View File

@ -1,6 +1,8 @@
package eu.dnetlib.dhp.schema.dump.oaf.community;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
import eu.dnetlib.dhp.schema.dump.oaf.Provenance;
/**
@ -13,6 +15,7 @@ import eu.dnetlib.dhp.schema.dump.oaf.Provenance;
*/
public class Project extends eu.dnetlib.dhp.schema.dump.oaf.Project {
@JsonSchema(description = "Information about the funder funding the project")
private Funder funder;
private Provenance provenance;

View File

@ -4,8 +4,9 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import java.util.List;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
import eu.dnetlib.dhp.schema.dump.oaf.Container;
import eu.dnetlib.dhp.schema.dump.oaf.ControlledField;
/**
* To store information about the datasource OpenAIRE collects information from. It contains the following parameters: -
@ -33,70 +34,91 @@ import eu.dnetlib.dhp.schema.dump.oaf.ControlledField;
* datasource. It corresponds to description.value of the datasource represented in the internal model
*/
public class Datasource implements Serializable {
@JsonSchema(description = "The OpenAIRE id of the data source")
private String id; // string
@JsonSchema(description = "Original identifiers for the datasource")
private List<String> originalId; // list string
private List<ControlledField> pid; // list<String>
@JsonSchema(description = "Persistent identifiers of the datasource")
private List<DatasourcePid> pid; // list<String>
private ControlledField datasourcetype; // value
@JsonSchema(description = "The type of the datasource. See https://api.openaire.eu/vocabularies/dnet:datasource_typologies")
private DatasourceSchemeValue datasourcetype; // value
@JsonSchema(description = "OpenAIRE guidelines the data source comply with. See also https://guidelines.openaire.eu.")
private String openairecompatibility; // value
@JsonSchema(description = "The official name of the datasource")
private String officialname; // string
@JsonSchema(description = "The English name of the datasource")
private String englishname; // string
private String websiteurl; // string
private String logourl; // string
@JsonSchema(description = "The date of last validation against the OpenAIRE guidelines for the datasource records")
private String dateofvalidation; // string
private String description; // description
@JsonSchema(description = "List of subjects associated to the datasource")
private List<String> subjects; // List<String>
// opendoar specific fields (od*)
@JsonSchema(description = "The languages present in the data source's content, as defined by OpenDOAR.")
private List<String> languages; // odlanguages List<String>
@JsonSchema(description = "Types of content in the data source, as defined by OpenDOAR")
private List<String> contenttypes; // odcontent types List<String>
// re3data fields
@JsonSchema(description = "Releasing date of the data source, as defined by re3data.org")
private String releasestartdate; // string
@JsonSchema(description = "Date when the data source went offline or stopped ingesting new research data. As defined by re3data.org")
private String releaseenddate; // string
@JsonSchema(description = "The URL of a mission statement describing the designated community of the data source. As defined by re3data.org")
private String missionstatementurl; // string
// {open, restricted or closed}
@JsonSchema(description = "Type of access to the data source, as defined by re3data.org. Possible values: " +
"{open, restricted, closed}")
private String accessrights; // databaseaccesstype string
// {open, restricted or closed}
@JsonSchema(description = "Type of data upload. As defined by re3data.org: one of {open, restricted,closed}")
private String uploadrights; // datauploadtype string
// {feeRequired, registration, other}
@JsonSchema(description = "Access restrinctions to the data source, as defined by re3data.org. One of {feeRequired, registration, other}")
private String databaseaccessrestriction; // string
// {feeRequired, registration, other}
@JsonSchema(description = "Upload restrictions applied by the datasource, as defined by re3data.org. One of {feeRequired, registration, other}")
private String datauploadrestriction; // string
@JsonSchema(description = "As defined by redata.org: 'yes' if the data source supports versioning, 'no' otherwise.")
private Boolean versioning; // boolean
@JsonSchema(description = "The URL of the data source providing information on how to cite its items. As defined by re3data.org.")
private String citationguidelineurl; // string
// {yes, no, uknown}
@JsonSchema(description = "The persistent identifier system that is used by the data source. As defined by re3data.org")
private String pidsystems; // string
@JsonSchema(description = "The certificate, seal or standard the data source complies with. As defined by re3data.org.")
private String certificates; // string
private List<Object> policies; //
@JsonSchema(description = "Policies of the data source, as defined in OpenDOAR.")
private List<String> policies; //
@JsonSchema(description = "Information about the journal, if this data source is of type Journal.")
private Container journal; // issn etc del Journal
public String getId() {
return id;
}
@ -113,19 +135,19 @@ public class Datasource implements Serializable {
this.originalId = originalId;
}
public List<ControlledField> getPid() {
public List<DatasourcePid> getPid() {
return pid;
}
public void setPid(List<ControlledField> pid) {
public void setPid(List<DatasourcePid> pid) {
this.pid = pid;
}
public ControlledField getDatasourcetype() {
public DatasourceSchemeValue getDatasourcetype() {
return datasourcetype;
}
public void setDatasourcetype(ControlledField datasourcetype) {
public void setDatasourcetype(DatasourceSchemeValue datasourcetype) {
this.datasourcetype = datasourcetype;
}
@ -297,11 +319,11 @@ public class Datasource implements Serializable {
this.certificates = certificates;
}
public List<Object> getPolicies() {
public List<String> getPolicies() {
return policies;
}
public void setPolicies(List<Object> policiesr3) {
public void setPolicies(List<String> policiesr3) {
this.policies = policiesr3;
}
@ -313,3 +335,5 @@ public class Datasource implements Serializable {
this.journal = journal;
}
}

View File

@ -0,0 +1,40 @@
package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public class DatasourcePid implements Serializable {
@JsonSchema(description="The scheme used to express the value ")
private String scheme;
@JsonSchema(description="The value expressed in the scheme ")
private String value;
public String getScheme() {
return scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static DatasourcePid newInstance(String scheme, String value) {
DatasourcePid cf = new DatasourcePid();
cf.setScheme(scheme);
cf.setValue(value);
return cf;
}
}

View File

@ -0,0 +1,39 @@
package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public //TODO change the DatasourceSchemaValue to DatasourceKeyValue. The scheme is always the dnet one. What we show here is the entry in the scheme (the key) and its understandable value
class DatasourceSchemeValue implements Serializable {
@JsonSchema(description="The scheme used to express the value (i.e. pubsrepository::journal)")
private String scheme;
@JsonSchema(description="The value expressed in the scheme (Journal)")
private String value;
public String getScheme() {
return scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static DatasourceSchemeValue newInstance(String scheme, String value) {
DatasourceSchemeValue cf = new DatasourceSchemeValue();
cf.setScheme(scheme);
cf.setValue(value);
return cf;
}
}

View File

@ -1,6 +1,8 @@
package eu.dnetlib.dhp.schema.dump.oaf.graph;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To store information about the funder funding the project related to the result. It extends
* eu.dnetlib.dhp.schema.dump.oaf.Funder with the following parameter: - - private
@ -8,6 +10,7 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
*/
public class Funder extends eu.dnetlib.dhp.schema.dump.oaf.Funder {
@JsonSchema(description = "Description of the funding stream")
private Fundings funding_stream;
public Fundings getFunding_stream() {

View File

@ -3,6 +3,8 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To store inforamtion about the funding stream. It has two parameters: - private String id to store the id of the
* fundings stream. The id is created by appending the shortname of the funder to the name of each level in the xml
@ -14,6 +16,7 @@ import java.io.Serializable;
*/
public class Fundings implements Serializable {
@JsonSchema(description = "Id of the funding stream")
private String id;
private String description;

View File

@ -3,14 +3,21 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To describe the funded amount. It has the following parameters: - private String currency to store the currency of
* the fund - private float totalcost to store the total cost of the project - private float fundedamount to store the
* funded amount by the funder
*/
public class Granted implements Serializable {
@JsonSchema(description = "The currency of the granted amount (e.g. EUR)")
private String currency;
@JsonSchema(description = "The total cost of the project")
private float totalcost;
@JsonSchema(description = "The funded amount")
private float fundedamount;
public String getCurrency() {

View File

@ -3,6 +3,8 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.util.List;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
import eu.dnetlib.dhp.schema.dump.oaf.Instance;
import eu.dnetlib.dhp.schema.dump.oaf.Result;
@ -12,6 +14,7 @@ import eu.dnetlib.dhp.schema.dump.oaf.Result;
* the same parameter in the result represented in the internal model
*/
public class GraphResult extends Result {
@JsonSchema(description = "Each instance is one specific materialisation or version of the result. For example, you can have one result with three instance: one is the pre-print, one is the post-print, one is te published version")
private List<Instance> instance;
public List<Instance> getInstance() {

View File

@ -3,6 +3,8 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To represent the generic node in a relation. It has the following parameters: - private String id the openaire id of
* the entity in the relation - private String type the type of the entity in the relation. Consider the generic

View File

@ -4,25 +4,36 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import java.util.List;
import eu.dnetlib.dhp.schema.dump.oaf.ControlledField;
import eu.dnetlib.dhp.schema.dump.oaf.Qualifier;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
import eu.dnetlib.dhp.schema.dump.oaf.Country;
/**
* To represent the generic organizaiton. It has the following parameters: - private String legalshortname to store the
* legalshortname of the organizaiton - private String legalname to store the legal name of the organization - private
* String websiteurl to store the websiteurl of the organization - private List<String> alternativenames to store the
* alternative names of the organization - private Qualifier country to store the country of the organization - private
* String id to store the id of the organization - private List<ControlledField> pid to store the list of pids for the
* organization
* To represent the generic organizaiton. It has the following parameters:
* - private String legalshortname to store the legalshortname of the organizaiton
* - private String legalname to store the legal name of the organization
* - private String websiteurl to store the websiteurl of the organization
* - private List<String> alternativenames to store the alternative names of the organization
* - private Country country to store the country of the organization
* - private String id to store the openaire id of the organization
* - private List<OrganizationPid> pid to store the list of pids for the organization
*/
public class Organization implements Serializable {
private String legalshortname;
private String legalname;
private String websiteurl;
@JsonSchema(description="Alternative names that identify the organisation")
private List<String> alternativenames;
private Qualifier country;
@JsonSchema(description="The organisation country")
private Country country;
@JsonSchema(description="The OpenAIRE id for the organisation")
private String id;
private List<ControlledField> pid;
@JsonSchema(description="Persistent identifiers for the organisation i.e. isni 0000000090326370")
private List<OrganizationPid> pid;
public String getLegalshortname() {
return legalshortname;
@ -56,11 +67,11 @@ public class Organization implements Serializable {
this.alternativenames = alternativenames;
}
public Qualifier getCountry() {
public Country getCountry() {
return country;
}
public void setCountry(Qualifier country) {
public void setCountry(Country country) {
this.country = country;
}
@ -72,12 +83,15 @@ public class Organization implements Serializable {
this.id = id;
}
public List<ControlledField> getPid() {
public List<OrganizationPid> getPid() {
return pid;
}
public void setPid(List<ControlledField> pid) {
public void setPid(List<OrganizationPid> pid) {
this.pid = pid;
}
}

View File

@ -0,0 +1,42 @@
package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
public
class OrganizationPid implements Serializable {
@JsonSchema(description="The scheme of the identifier (i.e. isni)")
private String scheme;
@JsonSchema(description="The value in the schema (i.e. 0000000090326370)")
private String value;
public String getScheme() {
return scheme;
}
public void setScheme(String scheme) {
this.scheme = scheme;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static OrganizationPid newInstance(String scheme, String value) {
OrganizationPid cf = new OrganizationPid();
cf.setScheme(scheme);
cf.setValue(value);
return cf;
}
}

View File

@ -3,12 +3,17 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To store information about the ec programme for the project. It has the following parameters: - private String code
* to store the code of the programme - private String description to store the description of the programme
*/
public class Programme implements Serializable {
@JsonSchema(description = "The code of the programme")
private String code;
@JsonSchema(description = "The description of the programme")
private String description;
public String getCode() {

View File

@ -4,6 +4,8 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import java.util.List;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* This is the class representing the Project in the model used for the dumps of the whole graph. At the moment the dump
* of the Projects differs from the other dumps because we do not create relations between Funders (Organization) and
@ -41,6 +43,7 @@ public class Project implements Serializable {
private String code;
private String acronym;
private String title;
private String startdate;
private String enddate;
@ -54,12 +57,15 @@ public class Project implements Serializable {
private boolean openaccessmandatefordataset;
private List<String> subject;
@JsonSchema(description = "Funding information for the project")
private List<Funder> funding;
private String summary;
@JsonSchema(description = "The money granted to the project")
private Granted granted;
@JsonSchema(description = "The h2020 programme funding the project")
private List<Programme> h2020programme;
public String getId() {

View File

@ -3,6 +3,8 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To represent the semantics of the generic relation between two entities. It has the following parameters: - private
* String name to store the semantics of the relation (i.e. isAuthorInstitutionOf). It corresponds to the relclass

View File

@ -4,6 +4,8 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import java.util.Objects;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
import eu.dnetlib.dhp.schema.dump.oaf.Provenance;
/**
@ -13,11 +15,22 @@ import eu.dnetlib.dhp.schema.dump.oaf.Provenance;
* provenance of the relation
*/
public class Relation implements Serializable {
@JsonSchema(description = "The node source in the relation")
private Node source;
@JsonSchema(description = "The node target in the relation")
private Node target;
@JsonSchema(description = "To represent the semantics of a relation between two entities")
private RelType reltype;
@JsonSchema(description = "The reason why OpenAIRE holds the relation ")
private Provenance provenance;
@JsonSchema(description = "True if the relation is related to a project and it has been collected from an authoritative source (i.e. the funder)")
private boolean validated;
@JsonSchema(description = "The date when the relation was collected from OpenAIRE")
private String validationDate;
public Node getSource() {
@ -68,6 +81,7 @@ public class Relation implements Serializable {
return validationDate;
}
@Override
public int hashCode() {

View File

@ -3,11 +3,14 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.util.List;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To represent RC entities. It extends eu.dnetlib.dhp.dump.oaf.grap.ResearchInitiative by adding the parameter subject
* to store the list of subjects related to the community
*/
public class ResearchCommunity extends ResearchInitiative {
@JsonSchema(description = "Only for research communities: the list of the subjects associated to the research community")
private List<String> subject;
public List<String> getSubject() {

View File

@ -3,6 +3,8 @@ package eu.dnetlib.dhp.schema.dump.oaf.graph;
import java.io.Serializable;
import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
/**
* To represent entity of type RC/RI. It has the following parameters, which are mostly derived by the profile
* - private
@ -18,11 +20,22 @@ import java.io.Serializable;
* zenodo_community to store the zenodo community associated to the context (main zenodo community)
*/
public class ResearchInitiative implements Serializable {
@JsonSchema(description = "The OpenAIRE id for the community/research infrastructure")
private String id; // openaireId
@JsonSchema(description = "The acronym of the community")
private String acronym; // context id
@JsonSchema(description = "The long name of the community")
private String name; // context name
@JsonSchema(description = "One of {Research Community, Research infrastructure}")
private String type; // context type: research initiative or research community
@JsonSchema(description = "Description of the research community/research infrastructure")
private String description;
@JsonSchema(description = "The URL of the Zenodo community associated to the Research community/Research infrastructure")
private String zenodo_community;
public String getZenodo_community() {

View File

@ -0,0 +1,55 @@
package eu.dnetlib.dhp.schema.oaf.dump;
import java.io.IOException;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.imifou.jsonschema.module.addon.AddonModule;
import com.github.victools.jsonschema.generator.*;
import eu.dnetlib.dhp.schema.dump.ExecCreateSchemas;
import eu.dnetlib.dhp.schema.dump.oaf.graph.*;
//@Disabled
class GenerateJsonSchema {
@Test
void generateSchema() {
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(SchemaVersion.DRAFT_7,
OptionPreset.PLAIN_JSON)
.with(Option.SCHEMA_VERSION_INDICATOR)
.without(Option.NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS);
configBuilder.forFields().withDescriptionResolver(field -> "Description of " + field.getDeclaredName());
SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(GraphResult.class);
System.out.println(jsonSchema.toString());
}
@Test
void generateSchema2(){
ObjectMapper objectMapper = new ObjectMapper();
AddonModule module = new AddonModule();
SchemaGeneratorConfigBuilder configBuilder = new SchemaGeneratorConfigBuilder(objectMapper,SchemaVersion.DRAFT_7,OptionPreset.PLAIN_JSON)
.with(module)
.with(Option.SCHEMA_VERSION_INDICATOR)
.without(Option.NONPUBLIC_NONSTATIC_FIELDS_WITHOUT_GETTERS);
SchemaGeneratorConfig config = configBuilder.build();
SchemaGenerator generator = new SchemaGenerator(config);
JsonNode jsonSchema = generator.generateSchema(GraphResult.class);
System.out.println(jsonSchema.toString());
}
@Test
void generateJsonSchema3() throws IOException {
ExecCreateSchemas.main(new String[]{});
}
}