forked from D-Net/dnet-hadoop
[HostedByMap] changed the application to verify the oaStartDate (year) is previous to the publication date
This commit is contained in:
parent
59e448205f
commit
4175d3c176
|
@ -9,19 +9,29 @@ public class EntityInfo implements Serializable {
|
|||
private String name;
|
||||
private Boolean openAccess;
|
||||
private String hostedById;
|
||||
private Integer oaStartDate;
|
||||
|
||||
public Integer getOaStartDate() {
|
||||
return oaStartDate;
|
||||
}
|
||||
|
||||
public void setOaStartDate(Integer oaStartDate) {
|
||||
this.oaStartDate = oaStartDate;
|
||||
}
|
||||
|
||||
public static EntityInfo newInstance(String id, String journalId, String name) {
|
||||
return newInstance(id, journalId, name, false);
|
||||
return newInstance(id, journalId, name, false, -1);
|
||||
|
||||
}
|
||||
|
||||
public static EntityInfo newInstance(String id, String journalId, String name, Boolean openaccess) {
|
||||
public static EntityInfo newInstance(String id, String journalId, String name, Boolean openaccess, Integer oaStartDate) {
|
||||
EntityInfo pi = new EntityInfo();
|
||||
pi.id = id;
|
||||
pi.journalId = journalId;
|
||||
pi.name = name;
|
||||
pi.openAccess = openaccess;
|
||||
pi.hostedById = "";
|
||||
pi.oaStartDate = oaStartDate;
|
||||
return pi;
|
||||
}
|
||||
|
||||
|
|
|
@ -168,9 +168,13 @@ object Aggregators {
|
|||
}
|
||||
if (!b1.getHostedById.equals("")) {
|
||||
b1.setOpenAccess(b1.getOpenAccess || b2.getOpenAccess)
|
||||
if(b2.getOaStartDate > b1.getOaStartDate)
|
||||
b1.setOaStartDate(b2.getOaStartDate)
|
||||
return b1
|
||||
}
|
||||
b2.setOpenAccess(b1.getOpenAccess || b2.getOpenAccess)
|
||||
if(b1.getOaStartDate > b2.getOaStartDate)
|
||||
b2.setOaStartDate(b1.getOaStartDate)
|
||||
b2
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,15 @@ import eu.dnetlib.dhp.application.ArgumentApplicationParser
|
|||
import eu.dnetlib.dhp.oa.graph.hostedbymap.model.EntityInfo
|
||||
import eu.dnetlib.dhp.schema.common.ModelConstants
|
||||
import eu.dnetlib.dhp.schema.oaf.utils.OafMapperUtils
|
||||
import eu.dnetlib.dhp.schema.oaf.{Instance, OpenAccessRoute, Publication}
|
||||
import eu.dnetlib.dhp.schema.oaf.{AccessRight, Instance, OpenAccessRoute, Publication}
|
||||
import org.apache.commons.io.IOUtils
|
||||
import org.apache.spark.SparkConf
|
||||
import org.apache.spark.sql._
|
||||
import org.json4s.DefaultFormats
|
||||
import org.slf4j.{Logger, LoggerFactory}
|
||||
|
||||
import java.time.LocalDate
|
||||
import java.time.format.DateTimeFormatter
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
object SparkApplyHostedByMapToResult {
|
||||
|
@ -28,24 +31,44 @@ object SparkApplyHostedByMapToResult {
|
|||
inst.getHostedby.setKey(ei.getHostedById)
|
||||
inst.getHostedby.setValue(ei.getName)
|
||||
if (ei.getOpenAccess) {
|
||||
inst.setAccessright(
|
||||
OafMapperUtils.accessRight(
|
||||
ModelConstants.ACCESS_RIGHT_OPEN,
|
||||
"Open Access",
|
||||
ModelConstants.DNET_ACCESS_MODES,
|
||||
ModelConstants.DNET_ACCESS_MODES
|
||||
)
|
||||
)
|
||||
inst.getAccessright.setOpenAccessRoute(OpenAccessRoute.gold)
|
||||
p.setBestaccessright(OafMapperUtils.createBestAccessRights(p.getInstance()));
|
||||
try {
|
||||
val pub_date = LocalDate.parse(p.getDateofacceptance.getValue, DateTimeFormatter.ofPattern("yyyy-MM-dd")).getYear
|
||||
if(ei.getOaStartDate <= pub_date ){
|
||||
setOpenAccessRight(p, inst)
|
||||
}
|
||||
} catch {
|
||||
case e: Exception =>
|
||||
try {
|
||||
val pub_date =
|
||||
LocalDate.parse(p.getDateofacceptance.getValue, DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'")).getYear
|
||||
if(ei.getOaStartDate <= pub_date ){
|
||||
setOpenAccessRight(p, inst)
|
||||
}
|
||||
} catch {
|
||||
case ex: Exception =>
|
||||
setOpenAccessRight(p, inst)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
p
|
||||
})(Encoders.bean(classOf[Publication]))
|
||||
}
|
||||
|
||||
private def setOpenAccessRight(p: Publication, inst: Instance) = {
|
||||
inst.setAccessright(
|
||||
OafMapperUtils.accessRight(
|
||||
ModelConstants.ACCESS_RIGHT_OPEN,
|
||||
"Open Access",
|
||||
ModelConstants.DNET_ACCESS_MODES,
|
||||
ModelConstants.DNET_ACCESS_MODES
|
||||
)
|
||||
)
|
||||
inst.getAccessright.setOpenAccessRoute(OpenAccessRoute.gold)
|
||||
p.setBestaccessright(OafMapperUtils.createBestAccessRights(p.getInstance()));
|
||||
}
|
||||
|
||||
def main(args: Array[String]): Unit = {
|
||||
|
||||
val logger: Logger = LoggerFactory.getLogger(getClass)
|
||||
|
|
|
@ -54,7 +54,7 @@ object SparkPrepareHostedByInfoToApply {
|
|||
|
||||
def toEntityItem(journal_id: String, hbi: HostedByItemType): EntityInfo = {
|
||||
|
||||
EntityInfo.newInstance(hbi.id, journal_id, hbi.officialname, hbi.openAccess)
|
||||
EntityInfo.newInstance(hbi.id, journal_id, hbi.officialname, hbi.openAccess, hbi.oaDate)
|
||||
|
||||
}
|
||||
|
||||
|
@ -69,6 +69,7 @@ object SparkPrepareHostedByInfoToApply {
|
|||
res.setHostedById(ds.getId)
|
||||
res.setOpenAccess(ds.getOpenAccess)
|
||||
res.setName(ds.getName)
|
||||
res.setOaStartDate(ds.getOaStartDate)
|
||||
}
|
||||
res
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue