Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
memoriav
Memobase 2020
services
postprocessing
rico-edm-transformer
Commits
1b039a77
Commit
1b039a77
authored
Feb 19, 2021
by
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
Changes
4
Pipelines
1
Show whitespace changes
Inline
Side-by-side
src/main/scala/ch/memobase/edm/EDM.scala
View file @
1b039a77
...
...
@@ -25,6 +25,7 @@ import ch.memobase.rdf.Helper
import
ch.memobase.rdf.vocabularies.EDM
import
org.eclipse.rdf4j.model.
{
IRI
,
Model
,
Resource
}
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
java.time.format.DateTimeFormatter
...
...
@@ -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
src/main/scala/ch/memobase/edm/Extractors.scala
View file @
1b039a77
...
...
@@ -173,6 +173,11 @@ object Extractors {
.flatMap(v => v.get("P154").flatMap(vi => Some(vi.str))) */
val
manifestId
:
JObj
=>
Option
[
String
]
=
digitalObject
=>
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
=>
stringValue
(
digitalObject
)(
"@id"
).
flatMap
(
v
=>
Some
(
s
"$v/sequence/default"
))
val
canvasId
:
JObj
=>
Option
[
String
]
=
digitalObject
=>
...
...
src/main/scala/ch/memobase/rdf/vocabularies/VocabularyFactory.scala
View file @
1b039a77
...
...
@@ -32,6 +32,7 @@ sealed abstract class VocabularyFactory(val NAMESPACE: String) {
object
EDM
extends
VocabularyFactory
(
"http://www.europeana.eu/schemas/edm/"
)
{
val
ProvidedCHO
:
IRI
=
getIri
(
"ProvidedCHO"
)
val
WebResource
:
IRI
=
getIri
(
"WebResource"
)
}
...
...
src/test/scala/ch/memobase/edm/ExtractorSpecWebResource.scala
0 → 100644
View file @
1b039a77
/*
* 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
)
}
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment