From 5100527400029c9e38b3dcda913d35fc40b8c604 Mon Sep 17 00:00:00 2001 From: Claudio Atzori Date: Thu, 23 Apr 2020 19:14:37 +0200 Subject: [PATCH] added default value for resulttype field --- .../dhp/schema/common/ModelConstants.java | 40 +++++++++++++++++++ .../eu/dnetlib/dhp/schema/oaf/Dataset.java | 5 +++ .../dhp/schema/oaf/OtherResearchProduct.java | 5 +++ .../dnetlib/dhp/schema/oaf/Publication.java | 5 +++ .../eu/dnetlib/dhp/schema/oaf/Result.java | 3 ++ .../eu/dnetlib/dhp/schema/oaf/Software.java | 5 +++ 6 files changed, 63 insertions(+) create mode 100644 dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java new file mode 100644 index 000000000..dbb080d7c --- /dev/null +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/common/ModelConstants.java @@ -0,0 +1,40 @@ +package eu.dnetlib.dhp.schema.common; + +import eu.dnetlib.dhp.schema.oaf.Qualifier; + +public class ModelConstants { + + public static final String DNET_RESULT_TYPOLOGIES = "dnet:result_typologies"; + + public static final String DATASET_RESULTTYPE_CLASSID = "dataset"; + public static final String PUBLICATION_RESULTTYPE_CLASSID = "publication"; + public static final String SOFTWARE_RESULTTYPE_CLASSID = "software"; + public static final String ORP_RESULTTYPE_CLASSID = "other"; + + public static Qualifier PUBLICATION_DEFAULT_RESULTTYPE = new Qualifier(); + public static Qualifier DATASET_DEFAULT_RESULTTYPE = new Qualifier(); + public static Qualifier SOFTWARE_DEFAULT_RESULTTYPE = new Qualifier(); + public static Qualifier ORP_DEFAULT_RESULTTYPE = new Qualifier(); + + static { + PUBLICATION_DEFAULT_RESULTTYPE.setClassid(PUBLICATION_RESULTTYPE_CLASSID); + PUBLICATION_DEFAULT_RESULTTYPE.setClassname(PUBLICATION_RESULTTYPE_CLASSID); + PUBLICATION_DEFAULT_RESULTTYPE.setSchemeid(DNET_RESULT_TYPOLOGIES); + PUBLICATION_DEFAULT_RESULTTYPE.setSchemename(DNET_RESULT_TYPOLOGIES); + + DATASET_DEFAULT_RESULTTYPE.setClassid(DATASET_RESULTTYPE_CLASSID); + DATASET_DEFAULT_RESULTTYPE.setClassname(DATASET_RESULTTYPE_CLASSID); + DATASET_DEFAULT_RESULTTYPE.setSchemeid(DNET_RESULT_TYPOLOGIES); + DATASET_DEFAULT_RESULTTYPE.setSchemename(DNET_RESULT_TYPOLOGIES); + + SOFTWARE_DEFAULT_RESULTTYPE.setClassid(SOFTWARE_RESULTTYPE_CLASSID); + SOFTWARE_DEFAULT_RESULTTYPE.setClassname(SOFTWARE_RESULTTYPE_CLASSID); + SOFTWARE_DEFAULT_RESULTTYPE.setSchemeid(DNET_RESULT_TYPOLOGIES); + SOFTWARE_DEFAULT_RESULTTYPE.setSchemename(DNET_RESULT_TYPOLOGIES); + + ORP_DEFAULT_RESULTTYPE.setClassid(ORP_RESULTTYPE_CLASSID); + ORP_DEFAULT_RESULTTYPE.setClassname(ORP_RESULTTYPE_CLASSID); + ORP_DEFAULT_RESULTTYPE.setSchemeid(DNET_RESULT_TYPOLOGIES); + ORP_DEFAULT_RESULTTYPE.setSchemename(DNET_RESULT_TYPOLOGIES); + } +} diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java index fef6ed748..ba9a62eb7 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Dataset.java @@ -1,5 +1,6 @@ package eu.dnetlib.dhp.schema.oaf; +import eu.dnetlib.dhp.schema.common.ModelConstants; import java.io.Serializable; import java.util.List; import java.util.Objects; @@ -20,6 +21,10 @@ public class Dataset extends Result implements Serializable { private List geolocation; + public Dataset() { + setResulttype(ModelConstants.DATASET_DEFAULT_RESULTTYPE); + } + public Field getStoragedate() { return storagedate; } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProduct.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProduct.java index 00b24a374..13a8e3c45 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProduct.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/OtherResearchProduct.java @@ -1,5 +1,6 @@ package eu.dnetlib.dhp.schema.oaf; +import eu.dnetlib.dhp.schema.common.ModelConstants; import java.io.Serializable; import java.util.List; import java.util.Objects; @@ -12,6 +13,10 @@ public class OtherResearchProduct extends Result implements Serializable { private List> tool; + public OtherResearchProduct() { + setResulttype(ModelConstants.ORP_DEFAULT_RESULTTYPE); + } + public List> getContactperson() { return contactperson; } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java index 1542b7933..df2ecfa1b 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Publication.java @@ -1,5 +1,6 @@ package eu.dnetlib.dhp.schema.oaf; +import eu.dnetlib.dhp.schema.common.ModelConstants; import java.io.Serializable; import java.util.Objects; @@ -8,6 +9,10 @@ public class Publication extends Result implements Serializable { // publication specific private Journal journal; + public Publication() { + setResulttype(ModelConstants.PUBLICATION_DEFAULT_RESULTTYPE); + } + public Journal getJournal() { return journal; } diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java index f9d9756d5..f18a9fa0c 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Result.java @@ -231,6 +231,9 @@ public class Result extends OafEntity implements Serializable { instance = mergeLists(instance, r.getInstance()); + if (r.getBestaccessright() != null && compareTrust(this, r) < 0) + bestaccessright = r.getBestaccessright(); + if (r.getResulttype() != null && compareTrust(this, r) < 0) resulttype = r.getResulttype(); if (r.getLanguage() != null && compareTrust(this, r) < 0) language = r.getLanguage(); diff --git a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java index a7d36638e..801c1f2f1 100644 --- a/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java +++ b/dhp-schemas/src/main/java/eu/dnetlib/dhp/schema/oaf/Software.java @@ -1,5 +1,6 @@ package eu.dnetlib.dhp.schema.oaf; +import eu.dnetlib.dhp.schema.common.ModelConstants; import java.io.Serializable; import java.util.List; import java.util.Objects; @@ -14,6 +15,10 @@ public class Software extends Result implements Serializable { private Qualifier programmingLanguage; + public Software() { + setResulttype(ModelConstants.SOFTWARE_DEFAULT_RESULTTYPE); + } + public List> getDocumentationUrl() { return documentationUrl; }