Commit d8048d10 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Identifier changes

- Change memoriav id to 'mrv'.
- Add 'oldMemobase' as rico:type for rico:Identifier.
- Record & Instantiation Ids are now generated using the record set id.
- Count is always 1.
- Remove some dead code.
parent 869dc65e
Pipeline #12686 failed with stages
in 2 minutes and 6 seconds
......@@ -24,8 +24,8 @@ import org.memobase.mapping.KEYS
import org.memobase.rdf.NS
import org.memobase.rdf.RICO
class DigitalObject(id: String, institutionId: String, count: Int) : Instantiation(institutionId) {
override val resource: Resource = model.createResource(NS.mbdo + institutionId + "-" + StringHelpers.normalizeId(id) + "-" + count)
class DigitalObject(id: String, recordSetId: String, institutionId: String, count: Int) : Instantiation(institutionId) {
override val resource: Resource = model.createResource(NS.mbdo + recordSetId + "-" + StringHelpers.normalizeId(id) + "-" + count)
init {
addRdfType(RICO.Instantiation)
resource.addProperty(RICO.type, "digitalObject")
......
......@@ -24,8 +24,8 @@ import org.memobase.mapping.KEYS
import org.memobase.rdf.NS
import org.memobase.rdf.RICO
class PhysicalObject(id: String, institutionId: String, count: Int) : Instantiation(institutionId) {
override val resource: Resource = model.createResource(NS.mbpo + institutionId + "-" + StringHelpers.normalizeId(id) + "-" + count)
class PhysicalObject(id: String, recordSetId: String, institutionId: String, count: Int) : Instantiation(institutionId) {
override val resource: Resource = model.createResource(NS.mbpo + recordSetId + "-" + StringHelpers.normalizeId(id) + "-" + count)
init {
addRdfType(RICO.Instantiation)
resource.addProperty(RICO.type, "physicalObject")
......
......@@ -28,7 +28,7 @@ import org.memobase.rdf.RICO
class Record(id: String, type: String, recordSetId: String, institutionId: String, hasSponsoringAgent: Boolean) :
RecordResource(institutionId) {
override val resource: Resource = model.createResource(NS.mbr + institutionId + "-" + StringHelpers.normalizeId(id))
override val resource: Resource = model.createResource(NS.mbr + recordSetId + "-" + StringHelpers.normalizeId(id))
init {
addRdfType(RICO.Record)
resource.addProperty(RICO.type, type)
......
......@@ -44,7 +44,6 @@ class ResourceBuilder(
private var record: Record? = null
private var physicalObject: PhysicalObject? = null
private var digitalObject: DigitalObject? = null
private var count = 0
private var recordId = ""
private var recordTypeValue = ""
private var errorMessage = ""
......@@ -102,8 +101,7 @@ class ResourceBuilder(
fun generatePhysicalObject(): ResourceBuilder {
physicalObject =
if (physicalObjectFieldMappers.isNotEmpty()) {
val physicalObject = PhysicalObject(recordId, institutionId, count)
count += 1
val physicalObject = PhysicalObject(recordId, recordSetId, institutionId, 1)
physicalObjectFieldMappers.forEach {
it.apply(source, physicalObject)
}
......@@ -119,8 +117,7 @@ class ResourceBuilder(
fun generateDigitalObject(): ResourceBuilder {
digitalObject =
if (digitalObjectFieldMappers.isNotEmpty()) {
val digitalObject = DigitalObject(recordId, institutionId, count)
count += 1
val digitalObject = DigitalObject(recordId, recordSetId, institutionId, 1)
digitalObjectFieldMappers.forEach {
it.apply(source, digitalObject)
}
......@@ -157,35 +154,7 @@ class ResourceBuilder(
}
}
fun hasPhysicalObject(): Boolean = physicalObject != null
private fun hasPhysicalObject(): Boolean = physicalObject != null
fun writePhysicalObject(): Pair<KeyValue<String, String>, Report> {
return StringWriter().use { writer ->
RDFDataMgr.write(writer, physicalObject!!.model, RDFFormat.NTRIPLES_UTF8)
return@use Pair(
KeyValue(physicalObject!!.resource.uri, writer.toString().trim()),
Report(
physicalObject!!.resource.uri,
ReportStatus.success,
"Successfully created a physical instantiation from source."
)
)
}
}
fun hasDigitalObject(): Boolean = digitalObject != null
fun writeDigitalObject(): Pair<KeyValue<String, String>, Report> {
return StringWriter().use { writer ->
RDFDataMgr.write(writer, digitalObject!!.model, RDFFormat.NTRIPLES_UTF8)
return@use Pair(
KeyValue(digitalObject!!.resource.uri, writer.toString().trim()),
Report(
digitalObject!!.resource.uri,
ReportStatus.success,
"Successfully created a digital instantiation from source."
)
)
}
}
private fun hasDigitalObject(): Boolean = digitalObject != null
}
\ No newline at end of file
......@@ -27,7 +27,7 @@ import org.memobase.rdf.SCHEMA
object KEYS {
const val memoriavUri = NS.mbcb + "Memoriav"
const val memoriavUri = NS.mbcb + "mrv"
val validRecordTypeValues = listOf("Film", "Foto", "Radio", "Ton", "Tonbildschau", "TV", "Video")
......@@ -120,7 +120,7 @@ object KEYS {
const val identifiers = "identifiers"
const val languages = "languages"
private val identifierTypes = listOf("original", "callNumber", "main")
private val identifierTypes = listOf("original", "callNumber", "main", "oldMemobase")
private val titleTypes = listOf("main", "series", "broadcast")
private val languageTypes = listOf("content", "caption")
......
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