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 index 68e37b9b78..1a0117fb96 100644 --- 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 @@ -18,6 +18,9 @@ public class ModelConstants { public static final String PUBMED_CENTRAL_ID = "10|opendoar____::eda80a3d5b344bc40f3bc04f65b7a357"; public static final String ARXIV_ID = "10|opendoar____::6f4922f45568161a8cdf4ad2299f6d23"; + //VOCABULARY VALUE + public static final String ACCESS_RIGHT_OPEN = "OPEN"; + public static final String DNET_SUBJECT_TYPOLOGIES = "dnet:subject_classification_typologies"; public static final String DNET_RESULT_TYPOLOGIES = "dnet:result_typologies"; public static final String DNET_PUBLICATION_RESOURCE = "dnet:publication_resource"; diff --git a/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/uw/UnpayWallToOAF.scala b/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/uw/UnpayWallToOAF.scala index a26f57f0fc..7119bbc123 100644 --- a/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/uw/UnpayWallToOAF.scala +++ b/dhp-workflows/dhp-doiboost/src/main/java/eu/dnetlib/doiboost/uw/UnpayWallToOAF.scala @@ -1,7 +1,8 @@ package eu.dnetlib.doiboost.uw +import eu.dnetlib.dhp.schema.common.ModelConstants import eu.dnetlib.dhp.schema.oaf.utils.IdentifierFactory -import eu.dnetlib.dhp.schema.oaf.{Instance, Publication} +import eu.dnetlib.dhp.schema.oaf.{AccessRight, Instance, OpenAccessRoute, Publication} import org.json4s import org.json4s.DefaultFormats import org.json4s.jackson.JsonMethods.parse @@ -21,6 +22,31 @@ case class OALocation(evidence:Option[String], host_type:Option[String], is_best object UnpayWallToOAF { val logger: Logger = LoggerFactory.getLogger(getClass) + def get_color(is_oa:Boolean, location: OALocation, journal_is_oa:Boolean):Option[OpenAccessRoute] = { + if (is_oa) { + if (location.host_type.isDefined) { + { + if (location.host_type.get.equalsIgnoreCase("repository")) + return Some(OpenAccessRoute.green) + else if (location.host_type.get.equalsIgnoreCase("publisher")) { + if (journal_is_oa) + return Some(OpenAccessRoute.gold) + else { + if (location.license.isDefined) + return Some(OpenAccessRoute.hybrid) + else + return Some(OpenAccessRoute.bronze) + } + + } + } + + } + } + None + } + + def convertToOAF(input:String):Publication = { val pub = new Publication @@ -32,13 +58,17 @@ object UnpayWallToOAF { val is_oa = (json\ "is_oa").extract[Boolean] + val journal_is_oa= (json\ "journal_is_oa").extract[Boolean] + val oaLocation:OALocation = (json \ "best_oa_location").extractOrElse[OALocation](null) + + val colour = get_color(is_oa, oaLocation, journal_is_oa) pub.setPid(List(createSP(doi, "doi", PID_TYPES)).asJava) //IMPORTANT //The old method pub.setId(IdentifierFactory.createIdentifier(pub)) //will be replaced using IdentifierFactory - pub.setId(generateIdentifier(pub, doi.toLowerCase)) + //pub.setId(generateIdentifier(pub, doi.toLowerCase)) pub.setId(IdentifierFactory.createIdentifier(pub)) @@ -61,8 +91,18 @@ object UnpayWallToOAF { if (oaLocation.license.isDefined) i.setLicense(asField(oaLocation.license.get)) - pub.setInstance(List(i).asJava) + + // Ticket #6282 Adding open Access Colour + if (colour.isDefined) { + val a = new AccessRight + a.setClassid(ModelConstants.ACCESS_RIGHT_OPEN) + a.setClassname(ModelConstants.ACCESS_RIGHT_OPEN) + a.setSchemeid(ModelConstants.DNET_ACCESS_MODES) + a.setSchemename(ModelConstants.DNET_ACCESS_MODES) + a.setOpenAccessRoute(colour.get) + } + pub.setInstance(List(i).asJava) pub }