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

use short record Id for doc id in ES and later for identifier in

GetRecord
parent e271bf5e
Pipeline #24092 passed with stages
in 7 minutes and 37 seconds
......@@ -46,7 +46,9 @@ class EDM {
val graph = Extractors.jsonGraph(messageValue).get.arr
val digitalObject = Extractors.digitalObject(graph).get
val record = Extractors.record(graph)
val recordId = Extractors.recordId(record.get).get
//val recordId = Extractors.recordId(record.get).get
val shortRecordId = Extractors.recordIdShort(graph)(record.get).get
val choExtraction = createChoObject(graph,record.get,digitalObject)
val webExtraction = createWebResources(graph,record.get,digitalObject)
......@@ -66,7 +68,7 @@ class EDM {
//choExtraction.obj.getModel.addAll(timespanExtraction.obj.getModel)
val esObject = ModelXMLTransformer(model = choExtraction.obj.getModel,
id = recordId,
id = shortRecordId,
recordset = Extractors.recordSetOrInstitution(record)("isPartOf")
.map( ident => EDM.getInstitutionOrRecordsetIdent(ident)),
institution = Extractors.recordSetOrInstitution(record)("heldBy")
......@@ -75,7 +77,7 @@ class EDM {
//todo: by now we do not collect any infos and warnings
ExtractionResult((
recordId,
shortRecordId,
esObject
)
,new ArrayBuffer[String]())
......
......@@ -606,6 +606,20 @@ object Extractors {
val recordId: JObj => Option[String] = record => stringValue(record)("@id").flatMap(Some(_))
val recordIdShort: JArr => JObj => Option[String] =
graph =>
record =>
getAllBlankNodeContent(graph)(record.obj)("identifiedBy")
.filter(obj =>
stringValue(obj)("type") match {
case Some(value) if value == "main" => true
case _ => false
}
).collectFirst {
//todo: a better default as ""
case res => stringValue(res)("identifier").getOrElse("")
}
val recordSource: JObj => Option[String] = record => stringValue(record)("source")
......
......@@ -103,6 +103,16 @@ class CHOSpec extends AnyFunSuite with Matchers{
}
test ("get short record ID") {
val graph = Extractors.jsonGraph(ricoRegulatedBy)
val record = Extractors.record(graph.get.arr).get
val shortRecordId = Extractors.recordIdShort(graph.get.arr)(record)
assert(shortRecordId.isDefined && shortRecordId.get == "bbb-002-387250")
}
test ("get identifier") {
val graph = Extractors.jsonGraph(ricoWithContributors).get.arr
val record = Extractors.record(graph).get.obj
......
Supports Markdown
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