forked from D-Net/dnet-hadoop
Fixed ticket 6282
This commit is contained in:
parent
f74e464942
commit
f5e7c57654
|
@ -18,6 +18,9 @@ public class ModelConstants {
|
||||||
public static final String PUBMED_CENTRAL_ID = "10|opendoar____::eda80a3d5b344bc40f3bc04f65b7a357";
|
public static final String PUBMED_CENTRAL_ID = "10|opendoar____::eda80a3d5b344bc40f3bc04f65b7a357";
|
||||||
public static final String ARXIV_ID = "10|opendoar____::6f4922f45568161a8cdf4ad2299f6d23";
|
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_SUBJECT_TYPOLOGIES = "dnet:subject_classification_typologies";
|
||||||
public static final String DNET_RESULT_TYPOLOGIES = "dnet:result_typologies";
|
public static final String DNET_RESULT_TYPOLOGIES = "dnet:result_typologies";
|
||||||
public static final String DNET_PUBLICATION_RESOURCE = "dnet:publication_resource";
|
public static final String DNET_PUBLICATION_RESOURCE = "dnet:publication_resource";
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
package eu.dnetlib.doiboost.uw
|
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.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
|
||||||
import org.json4s.DefaultFormats
|
import org.json4s.DefaultFormats
|
||||||
import org.json4s.jackson.JsonMethods.parse
|
import org.json4s.jackson.JsonMethods.parse
|
||||||
|
@ -21,6 +22,31 @@ case class OALocation(evidence:Option[String], host_type:Option[String], is_best
|
||||||
object UnpayWallToOAF {
|
object UnpayWallToOAF {
|
||||||
val logger: Logger = LoggerFactory.getLogger(getClass)
|
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 = {
|
def convertToOAF(input:String):Publication = {
|
||||||
val pub = new Publication
|
val pub = new Publication
|
||||||
|
|
||||||
|
@ -32,13 +58,17 @@ object UnpayWallToOAF {
|
||||||
|
|
||||||
val is_oa = (json\ "is_oa").extract[Boolean]
|
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 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)
|
pub.setPid(List(createSP(doi, "doi", PID_TYPES)).asJava)
|
||||||
|
|
||||||
//IMPORTANT
|
//IMPORTANT
|
||||||
//The old method pub.setId(IdentifierFactory.createIdentifier(pub))
|
//The old method pub.setId(IdentifierFactory.createIdentifier(pub))
|
||||||
//will be replaced using IdentifierFactory
|
//will be replaced using IdentifierFactory
|
||||||
pub.setId(generateIdentifier(pub, doi.toLowerCase))
|
//pub.setId(generateIdentifier(pub, doi.toLowerCase))
|
||||||
pub.setId(IdentifierFactory.createIdentifier(pub))
|
pub.setId(IdentifierFactory.createIdentifier(pub))
|
||||||
|
|
||||||
|
|
||||||
|
@ -61,8 +91,18 @@ object UnpayWallToOAF {
|
||||||
|
|
||||||
if (oaLocation.license.isDefined)
|
if (oaLocation.license.isDefined)
|
||||||
i.setLicense(asField(oaLocation.license.get))
|
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
|
pub
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue