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

start of webresource creation and merging of rdf4j models

parent b70c3c0e
Pipeline #22097 failed with stages
in 5 minutes and 54 seconds
...@@ -25,6 +25,7 @@ import ch.memobase.rdf.Helper ...@@ -25,6 +25,7 @@ import ch.memobase.rdf.Helper
import ch.memobase.rdf.vocabularies.EDM import ch.memobase.rdf.vocabularies.EDM
import org.eclipse.rdf4j.model.{IRI, Model, Resource} import org.eclipse.rdf4j.model.{IRI, Model, Resource}
import org.eclipse.rdf4j.model.impl.{DynamicModelFactory, SimpleValueFactory} import org.eclipse.rdf4j.model.impl.{DynamicModelFactory, SimpleValueFactory}
import org.eclipse.rdf4j.model.util.Values.iri
import org.eclipse.rdf4j.model.vocabulary.{DC, DCTERMS, RDF} import org.eclipse.rdf4j.model.vocabulary.{DC, DCTERMS, RDF}
import java.time.format.DateTimeFormatter import java.time.format.DateTimeFormatter
...@@ -103,7 +104,17 @@ class ProvidedCHO (val id: String) { ...@@ -103,7 +104,17 @@ class ProvidedCHO (val id: String) {
} }
class WebResource class WebResource (val id: String) {
private val model = Helper.getModelWithEDMNamespaces
model.add(iri(id),RDF.TYPE, EDM.WebResource)
def getModel: Model = model
}
class Aggregation class Aggregation
...@@ -173,6 +173,11 @@ object Extractors { ...@@ -173,6 +173,11 @@ object Extractors {
.flatMap(v => v.get("P154").flatMap(vi => Some(vi.str))) */ .flatMap(v => v.get("P154").flatMap(vi => Some(vi.str))) */
val manifestId: JObj => Option[String] = digitalObject => val manifestId: JObj => Option[String] = digitalObject =>
stringValue(digitalObject)("@id").flatMap(v => Some(s"$v/manifest")) stringValue(digitalObject)("@id").flatMap(v => Some(s"$v/manifest"))
val dobjectId: JObj => Option[String] = digitalObject =>
stringValue(digitalObject)("@id").flatMap(Some(_))
val sequenceId: JObj => Option[String] = digitalObject => val sequenceId: JObj => Option[String] = digitalObject =>
stringValue(digitalObject)("@id").flatMap(v => Some(s"$v/sequence/default")) stringValue(digitalObject)("@id").flatMap(v => Some(s"$v/sequence/default"))
val canvasId: JObj => Option[String] = digitalObject => val canvasId: JObj => Option[String] = digitalObject =>
......
...@@ -32,6 +32,7 @@ sealed abstract class VocabularyFactory(val NAMESPACE: String) { ...@@ -32,6 +32,7 @@ sealed abstract class VocabularyFactory(val NAMESPACE: String) {
object EDM extends VocabularyFactory("http://www.europeana.eu/schemas/edm/") { object EDM extends VocabularyFactory("http://www.europeana.eu/schemas/edm/") {
val ProvidedCHO: IRI = getIri("ProvidedCHO") val ProvidedCHO: IRI = getIri("ProvidedCHO")
val WebResource: IRI = getIri("WebResource")
} }
......
/*
* rico2edm
* Copyright (C) 2021 UB Basel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
package ch.memobase.edm
import ch.memobase.Utils.loadFile
import ch.memobase.rdf.writer.RdfXmlWriter
import org.eclipse.rdf4j.rio.Rio
import org.scalatest.funsuite.AnyFunSuite
import org.scalatest.matchers.should.Matchers
class ExtractorSpecWebResource extends AnyFunSuite with Matchers {
private lazy val rawRico = loadFile("src/test/resources/raw1L.json")
private lazy val rawErroneousFile = loadFile("src/test/resources/raw1LError.json")
private lazy val rawRicoIndent = loadFile("src/test/resources/rawIndent.json")
private lazy val graph = Extractors.jsonGraph(rawRico).get
test ("get digital object") {
val dobject = Extractors.digitalObject(graph.arr)
val webresource = Extractors.dobjectId(dobject.get).map(new WebResource(_))
if (webresource.isDefined) {
val record = Extractors.record(graph.arr).get.obj
val cho = new ProvidedCHO(Extractors.recordId(record).get)
cho.addTitel(Extractors.title(record))
cho.addDescription(Extractors.dctAbstract(record))
cho.addDescription(Extractors.scopeAndContent(record))
cho.addDescription(Extractors.descriptiveNote(record))
/*
todo wir können präziser dcterms:temporal, dcterms:created and dcterms:issued verwenden
temporal und issued nutzt Sebastian in IIIF nicht
ich habe das im Beispielrecord auch noch nicht gesehen - gibt es das?
*/
cho.addCreationDate(Extractors.creationDate(graph.arr)(record))
webresource.get.getModel.addAll(cho.getModel)
val rdfWriter = new RdfXmlWriter(System.out)
Rio.write(webresource.get.getModel, rdfWriter)
}
}
}
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