Due to a scheduled upgrade to version 14.10, GitLab will be unavailabe on Monday 30.05., from 19:00 until 20:00.

Commit 273bccd6 authored by Günter Hipler's avatar Günter Hipler
Browse files

adjust Extractors for creators and contributors

parent 6ae70f5f
......@@ -113,12 +113,12 @@ class EDM {
//todo: q.f.S. creator and contributor together with role??
Extractors
.resourceSourceOfRelationCreation(graph)(record.value)("creator")
.foreach(c => cho.addCreator(Some(s"${c._1} / ${c._2}")))
.foreach(c => cho.addCreator(Some(c)))
//add contributors from two different sources
Extractors
.resourceSourceOfRelationCreation(graph)(record.value)("contributor")
.foreach(c => cho.addContributor(Some(s"${c._1} / ${c._2}")))
.foreach(c => cho.addContributor(Some(c)))
Extractors
.resourceContributorRDauP60441(graph)(record.value)
.foreach(c => cho.addContributor(Some(c)))
......
......@@ -266,7 +266,7 @@ object Extractors {
stringValue(v)("name"))
val resourceSourceOfRelationCreation: JArr => mutable.LinkedHashMap[String, JValue] => String => List[(String, String)] =
val resourceSourceOfRelationCreation: JArr => mutable.LinkedHashMap[String, JValue] => String => List[String] =
graph =>
record =>
relationType =>
......@@ -277,7 +277,7 @@ object Extractors {
getBlankNodeContent(graph)(obj)("creationRelationHasTarget")
.flatMap(v => stringValue(v)("name")) match {
case Some(name) =>
Some(obj.getOrElse("name", obj("type")).str, name)
Some(name)
case None => None
}
).toList
......
......@@ -20,7 +20,7 @@
package ch.memobase.rico2edm.edm
import ch.memobase.Utils
import ch.memobase.Utils.loadFile
import ch.memobase.Utils.{loadFile, serializeRDFModel}
import ch.memobase.rico2edm.edm.subjects.ProvidedCHO
import ch.memobase.rico2edm.rdf.writer.RdfXmlWriter
import org.eclipse.rdf4j.rio.Rio
......@@ -93,6 +93,12 @@ class CHOSpec extends AnyFunSuite with Matchers{
assert(contributors.length == 1)
assert(contributors.head._2 == "Valentino Monotti")
/*
val edm = new EDM
val dObj = Extractors.digitalObject(graph).get
println(Utils.serializeRDFModel(edm.createChoObject(graph,record,dObj).obj.getModel))
*/
}
......@@ -111,6 +117,7 @@ class CHOSpec extends AnyFunSuite with Matchers{
test ("get contributors") {
val graph = Extractors.jsonGraph(ricoWithContributors).get.arr
val record = Extractors.record(graph).get.obj
val dObj = Extractors.digitalObject(graph).get
val contributors = Extractors
.resourceSourceOfRelationCreation(graph)(record.value)("contributor")
......@@ -122,8 +129,18 @@ class CHOSpec extends AnyFunSuite with Matchers{
assert(creators.length == 1)
val edm = new EDM
val serEDM = Utils.serializeRDFModel(edm.createChoObject(graph,record,dObj).obj.getModel)
assert(serEDM.contains("""<dc:creator>Studio Radio Lausanne</dc:creator>"""))
assert(serEDM.contains("""<dc:contributor>inconnu</dc:contributor>"""))
assert(serEDM.contains("""<dc:contributor>COTY, René</dc:contributor>"""))
assert(serEDM.contains("""<dc:contributor>PFLIMLIN, Pierre</dc:contributor>"""))
assert(serEDM.contains("""<dc:contributor>Studio Radio Lausanne</dc:contributor>"""))
val graph1 = Extractors.jsonGraph(ricoContributorP60441).get.arr
val record1 = Extractors.record(graph1).get.obj
val dObj1 = Extractors.digitalObject(graph1).get
val creators1 = Extractors
.resourceSourceOfRelationCreation(graph1)(record1.value)("creator")
val contributors1 = Extractors
......@@ -134,6 +151,19 @@ class CHOSpec extends AnyFunSuite with Matchers{
val p60441 = Extractors.resourceContributorRDauP60441(graph1)(record1.value)
assert(p60441.get == "Studio Radio Lausanne")
val edm1 = new EDM
val serializedEdm1 = Utils.serializeRDFModel(edm1.createChoObject(graph1,record1,dObj1).obj.getModel)
assert(serializedEdm1.contains("""<dc:creator>Studio Radio Lausanne</dc:creator>"""))
assert(serializedEdm1.contains("""<dc:contributor>inconnu</dc:contributor>"""))
assert(serializedEdm1.contains("""<dc:contributor>RIGASSI, Vico</dc:contributor>"""))
assert(serializedEdm1.contains("""<dc:contributor>Studio Radio Lausanne</dc:contributor>"""))
}
......
......@@ -67,11 +67,11 @@ class ExtractorSpec extends AnyFunSuite with Matchers{
Extractors
.resourceSourceOfRelationCreation(graph)(record.value)("creator")
.foreach(c => cho.addCreator(Some(s"${c._1} / ${c._2}")))
.foreach(c => cho.addCreator(Some(c)))
Extractors
.resourceSourceOfRelationCreation(graph)(record.value)("contributor")
.foreach(c => cho.addContributor(Some(s"${c._1} / ${c._2}")))
.foreach(c => cho.addContributor(Some(c)))
Extractors
.identifiedBy(graph)(record.value)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment