diff --git a/pom.xml b/pom.xml
index 4b499a8..4ceda6a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -137,7 +137,23 @@
maven-dependency-plugin
3.0.0
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 3.0.0
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+ ${dhp.jackson.version}
+
+
+
+
+
+
@@ -229,6 +245,19 @@
${scala.version}
+
+ org.codehaus.mojo
+ exec-maven-plugin
+
+ true
+ eu.dnetlib.dhp.schema.dump.ExecCreateSchemas
+
+ eu.dnetlib.dhp.schema.dump.oaf.GraphResult;eu.dnetlib.dhp.schema.dump.oaf.graph.Organization;eu.dnetlib.dhp.schema.dump.oaf.graph.Project
+
+
+
+
+
@@ -364,13 +393,14 @@
com.github.victools
jsonschema-generator
${jsonschemagenerator.version}
- test
+
com.github.imifou
jsonschema-module-addon
1.2.1
+
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/ExecCreateSchemas.java b/src/main/java/eu/dnetlib/dhp/schema/dump/ExecCreateSchemas.java
new file mode 100644
index 0000000..2b25caf
--- /dev/null
+++ b/src/main/java/eu/dnetlib/dhp/schema/dump/ExecCreateSchemas.java
@@ -0,0 +1,72 @@
+package eu.dnetlib.dhp.schema.dump;
+
+import java.io.*;
+import java.lang.reflect.Type;
+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 {
+
+ 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);
+
+ if(!Files.exists(Paths.get(directory))){
+ Files.createDirectories(Paths.get(directory));
+ }
+
+ if(!Files.exists(Paths.get(directory + filename))) {
+ Files.createFile(Paths.get(directory + filename));
+ }
+
+ File f = new File(directory + 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, "/tmp/jsonschemas/" , "result_schema.json");
+ ecs.generate(ResearchCommunity.class, "/tmp/jsonschemas/" , "community_infrastructure_schema.json");
+ ecs.generate(Datasource.class, "/tmp/jsonschemas/" , "datasource_schema.json");
+ ecs.generate(Project.class, "/tmp/jsonschemas/" , "project_schema.json");
+ ecs.generate(Relation.class, "/tmp/jsonschemas/" , "relation_schema.json");
+ ecs.generate(Organization.class, "/tmp/jsonschemas/" , "organization_schema.json");
+
+ ecs.generate(CommunityResult.class, "/tmp/jsonschemas/" , "community_result_schema.json");
+
+
+
+
+
+ }
+}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/AuthorPidSchemeValue.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/AuthorPidSchemeValue.java
index 3439514..3e22c9f 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/AuthorPidSchemeValue.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/AuthorPidSchemeValue.java
@@ -9,7 +9,7 @@ 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")
+ @JsonSchema(description="The author's pid value in that scheme (i.e. 0000-1111-2222-3333)")
private String value;
public String getScheme() {
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/ControlledField.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/ControlledField.java
deleted file mode 100644
index 978171a..0000000
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/ControlledField.java
+++ /dev/null
@@ -1,43 +0,0 @@
-
-package eu.dnetlib.dhp.schema.dump.oaf;
-
-import java.io.Serializable;
-
-import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
-
-/**
- * To represent the information described by a scheme and a value in that scheme (i.e. doi). It has two parameters: -
- * scheme of type String to store the scheme - value of type String to store the value in that scheme
- */
-public class ControlledField implements Serializable {
- @JsonSchema(description="The scheme used to express the value (i.e. doi)")
- 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 ControlledField newInstance(String scheme, String value) {
- ControlledField cf = new ControlledField();
-
- cf.setScheme(scheme);
- cf.setValue(value);
-
- return cf;
- }
-}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Funder.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Funder.java
index 06af521..674b8b3 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Funder.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Funder.java
@@ -13,7 +13,7 @@ public class Funder implements Serializable {
@JsonSchema(description = "The name of the funder (European Commission)")
private String name;
- @JsonSchema(description = "The jurisdiction of the funder (i.e. EU)")
+ @JsonSchema(description = "Geographical jurisdiction (e.g. for European Commission is EU, for Croatian Science Foundation is HR)")
private String jurisdiction;
public String getJurisdiction() {
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/KeyValue.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/KeyValue.java
deleted file mode 100644
index 849aa4d..0000000
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/KeyValue.java
+++ /dev/null
@@ -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);
- }
-
-}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Qualifier.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Qualifier.java
deleted file mode 100644
index e977ee2..0000000
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/Qualifier.java
+++ /dev/null
@@ -1,43 +0,0 @@
-
-package eu.dnetlib.dhp.schema.dump.oaf;
-
-import java.io.Serializable;
-
-import com.github.imifou.jsonschema.module.addon.annotation.JsonSchema;
-
-/**
- * To represent the information described by a code and a value It has two parameters: - code to store the code
- * (generally the classid of the eu.dnetlib.dhp.schema.oaf.Qualifier element) - label to store the label (generally the
- * classname of the eu.dnetlib.dhp.schema.oaf.Qualifier element
- */
-public class Qualifier implements Serializable {
-
- @JsonSchema(description="A code in vocabulary ")
- private String code; // the classid in the Qualifier
-
- @JsonSchema(description="A label for that code ")
- 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 Qualifier newInstance(String code, String value) {
- Qualifier qualifier = new Qualifier();
- qualifier.setCode(code);
- qualifier.setLabel(value);
- return qualifier;
- }
-}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CfHbKeyValue.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CfHbKeyValue.java
new file mode 100644
index 0000000..68bda2d
--- /dev/null
+++ b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CfHbKeyValue.java
@@ -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);
+ }
+
+}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityInstance.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityInstance.java
index 6a605d7..5e5a87e 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityInstance.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityInstance.java
@@ -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;
}
}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityResult.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityResult.java
index d32247f..d24f1e9 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityResult.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/CommunityResult.java
@@ -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 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;
- protected List collectedfrom;
+ @JsonSchema(description = "Information about the sources from which the record has been collected")
+ protected List 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 instance;
@@ -39,11 +41,11 @@ public class CommunityResult extends Result {
this.instance = instance;
}
- public List getCollectedfrom() {
+ public List getCollectedfrom() {
return collectedfrom;
}
- public void setCollectedfrom(List collectedfrom) {
+ public void setCollectedfrom(List collectedfrom) {
this.collectedfrom = collectedfrom;
}
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Context.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Context.java
index d4c1d40..79c1647 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Context.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Context.java
@@ -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;
public List 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())
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Funder.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Funder.java
index 5ea0d12..5e17e0c 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Funder.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Funder.java
@@ -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() {
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Project.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Project.java
index eed0ae8..88c5216 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Project.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/community/Project.java
@@ -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;
diff --git a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Datasource.java b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Datasource.java
index 7081863..3c2a7b3 100644
--- a/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Datasource.java
+++ b/src/main/java/eu/dnetlib/dhp/schema/dump/oaf/graph/Datasource.java
@@ -7,7 +7,6 @@ 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: -
diff --git a/src/test/java/eu/dnetlib/dhp/schema/oaf/dump/GenerateJsonSchema.java b/src/test/java/eu/dnetlib/dhp/schema/oaf/dump/GenerateJsonSchema.java
index a12f281..cca6d94 100644
--- a/src/test/java/eu/dnetlib/dhp/schema/oaf/dump/GenerateJsonSchema.java
+++ b/src/test/java/eu/dnetlib/dhp/schema/oaf/dump/GenerateJsonSchema.java
@@ -1,5 +1,7 @@
package eu.dnetlib.dhp.schema.oaf.dump;
+import java.io.IOException;
+
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -8,6 +10,7 @@ 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
@@ -42,4 +45,11 @@ class GenerateJsonSchema {
System.out.println(jsonSchema.toString());
}
+
+
+ @Test
+ void generateJsonSchema3() throws IOException {
+
+ ExecCreateSchemas.main(new String[]{});
+ }
}