forked from D-Net/dnet-hadoop
resolved ticket #6377
This commit is contained in:
parent
524e5f3092
commit
dbe0d0378e
|
@ -1,9 +1,7 @@
|
|||
|
||||
package eu.dnetlib.dhp.schema.common;
|
||||
|
||||
import eu.dnetlib.dhp.schema.oaf.DataInfo;
|
||||
import eu.dnetlib.dhp.schema.oaf.KeyValue;
|
||||
import eu.dnetlib.dhp.schema.oaf.Qualifier;
|
||||
import eu.dnetlib.dhp.schema.oaf.*;
|
||||
|
||||
public class ModelConstants {
|
||||
|
||||
|
@ -144,6 +142,17 @@ public class ModelConstants {
|
|||
public static final Qualifier MAIN_TITLE_QUALIFIER = qualifier(
|
||||
"main title", "main title", DNET_DATACITE_TITLE, DNET_DATACITE_TITLE);
|
||||
|
||||
|
||||
public static final AccessRight OPEN_ACCESS_RIGHT () {
|
||||
|
||||
final AccessRight result = new AccessRight();
|
||||
result.setClassid(ACCESS_RIGHT_OPEN);
|
||||
result.setClassid(ACCESS_RIGHT_OPEN);
|
||||
result.setSchemeid(ModelConstants.DNET_ACCESS_MODES);
|
||||
result.setSchemename(ModelConstants.DNET_ACCESS_MODES);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Qualifier qualifier(
|
||||
final String classid,
|
||||
final String classname,
|
||||
|
|
|
@ -131,8 +131,6 @@ object DataciteToOAFTransformation {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
def embargo_end(embargo_end_date: String): Boolean = {
|
||||
val dt = LocalDate.parse(embargo_end_date, DateTimeFormatter.ofPattern("[yyyy-MM-dd]"))
|
||||
val td = LocalDate.now()
|
||||
|
@ -230,6 +228,26 @@ object DataciteToOAFTransformation {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* As describe in ticket #6377
|
||||
* when the result come from figshare we need to remove subject
|
||||
* and set Access rights OPEN.
|
||||
* @param r
|
||||
*/
|
||||
def fix_figshare(r: Result): Unit = {
|
||||
|
||||
if (r.getInstance() != null) {
|
||||
val hosted_by_figshare = r.getInstance().asScala.exists(i => i.getHostedby != null && "figshare".equalsIgnoreCase(i.getHostedby.getValue))
|
||||
if (hosted_by_figshare) {
|
||||
r.getInstance().asScala.foreach(i => i.setAccessright(ModelConstants.OPEN_ACCESS_RIGHT()))
|
||||
val l: List[StructuredProperty] = List()
|
||||
r.setSubject(l.asJava)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
def generateOAFDate(dt: String, q: Qualifier): StructuredProperty = {
|
||||
OafMapperUtils.structuredProperty(dt, q, null)
|
||||
}
|
||||
|
@ -331,8 +349,6 @@ object DataciteToOAFTransformation {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
val titles: List[TitleType] = (json \\ "titles").extractOrElse[List[TitleType]](List())
|
||||
|
||||
result.setTitle(titles.filter(t => t.title.nonEmpty).map(t => {
|
||||
|
@ -453,7 +469,7 @@ object DataciteToOAFTransformation {
|
|||
} yield awardUri
|
||||
|
||||
val relations: List[Relation] = awardUris.flatMap(a => get_projectRelation(a, result.getId)).filter(r => r != null)
|
||||
|
||||
fix_figshare(result)
|
||||
result.setId(IdentifierFactory.createIdentifier(result))
|
||||
if (result.getId == null)
|
||||
return List()
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
package eu.dnetlib.dhp.actionmanager.datacite
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper
|
||||
|
||||
import eu.dnetlib.dhp.aggregation.AbstractVocabularyTest
|
||||
import eu.dnetlib.dhp.schema.oaf.Oaf
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.junit.jupiter.api.{BeforeEach, Test}
|
||||
import org.mockito.junit.jupiter.MockitoExtension
|
||||
|
||||
import org.codehaus.jackson.map.ObjectMapper
|
||||
import scala.io.Source
|
||||
|
||||
@ExtendWith(Array(classOf[MockitoExtension]))
|
||||
|
@ -15,7 +15,7 @@ class DataciteToOAFTest extends AbstractVocabularyTest{
|
|||
|
||||
@BeforeEach
|
||||
def setUp() :Unit = {
|
||||
println("Called Method")
|
||||
|
||||
super.setUpVocabulary()
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ class DataciteToOAFTest extends AbstractVocabularyTest{
|
|||
|
||||
val mapper = new ObjectMapper()
|
||||
val res:List[Oaf] =DataciteToOAFTransformation.generateOAF(record, 0L,0L, vocabularies )
|
||||
println (mapper.writeValueAsString(res.head))
|
||||
println (mapper.defaultPrettyPrintingWriter().writeValueAsString(res.head))
|
||||
|
||||
|
||||
}
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue