In order to mitigate against the brute force attacks against Gitlab accounts, we are moving to all edu-ID Logins. We would like to remind you to link your account with your edu-id. Login will be possible only by edu-ID after November 30, 2021. Here you can find the instructions for linking your account.

If you don't have a SWITCH edu-ID, you can create one with this guide here

kind regards

This Server has been upgraded to GitLab release 14.2.6

Commit 81fc5335 authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Refactor entity collection to extract from record only

parent 2b158896
......@@ -29,12 +29,15 @@ class SearchDocTransform {
private val log = LogManager.getLogger("SearchDocTransform")
fun transform(input: Map<String, JsonObject>): SearchDoc {
val record = input["record"] ?: error("No record defined in this message.")
val digitalObject = input.values.firstOrNull { it["@type"] == "rico:Instantiation" && it["rico:type"] == "digitalObject" }
val physicalObject = input.values.firstOrNull { it["@type"] == "rico:Instantiation" && it["rico:type"] == "physicalObject" }
val id = record["@id"] as String
val identifiers = input.values.filter { item -> item["@type"] == "rico:Identifier" }
val titles = input.values.filter { item -> item["@type"] == "rico:Title" }
val languages = input.values.filter { item -> item["@type"] == "rico:Language" }
val rules = input.values.filter { item -> item["@type"] == "rico:Rule" }
val recordIdentifiers = Extract.getEntitiesFromIds("rico:identifiedBy", record, input)
val recordTitles = Extract.getEntitiesFromIds("rico:hasTitle", record, input)
val recordLanguages = Extract.getEntitiesFromIds("rico:hasLanguage", record, input)
val recordRules = Extract.getEntitiesFromIds("rico:regulatedBy", record, input)
val datesCreated = Extract.getEntitiesFromIds("dct:created", record, input)
val datesIssued = Extract.getEntitiesFromIds("dct:issued", record, input)
......@@ -51,12 +54,12 @@ class SearchDocTransform {
Extract.getEntitiesFromIds("rico:recordResourceOrInstantiationIsSourceOfCreationRelation", record, input)
return SearchDoc(
title = Extract.typedEntityByType(titles, "rico:type", "main", "rico:title"),
seriesTitle = Extract.typedEntityByType(titles, "rico:type", "series", "rico:title"),
broadcastTitle = Extract.typedEntityByType(titles, "rico:type", "broadcast", "rico:title"),
title = Extract.typedEntityByType(recordTitles, "rico:type", "main", "rico:title"),
seriesTitle = Extract.typedEntityByType(recordTitles, "rico:type", "series", "rico:title"),
broadcastTitle = Extract.typedEntityByType(recordTitles, "rico:type", "broadcast", "rico:title"),
type = record["rico:type"] as String,
sourceID = try {
Extract.extractSourceId(identifiers)
Extract.extractSourceId(recordIdentifiers)
} catch (ex: NoSuchElementException) {
log.error("No source id found for record $id")
"NoSourceIdFound"
......@@ -84,11 +87,11 @@ class SearchDocTransform {
placeCapture = Extract.extractPlaces(placeCaptured),
placeRelated = Extract.extractPlaces(placesRelated),
place = Extract.facetEntity(placeCaptured + placesRelated, "rico:name"),
rightsHolder = Extract.typedEntityByType(rules, "rico:type", "holder", "rico:name"),
rightsHolder = Extract.typedEntityByType(recordRules, "rico:type", "holder", "rico:name"),
memoriavClaim = record["rdau:P60451"] != null,
languageCaption = Extract.typedEntityByType(languages, "rico:type", "caption", "rico:name"),
languageContent = Extract.typedEntityByType(languages, "rico:type", "content", "rico:name"),
language = Extract.facetEntity(languages, "rico:name"),
languageCaption = Extract.typedEntityByType(recordLanguages, "rico:type", "caption", "rico:name"),
languageContent = Extract.typedEntityByType(recordLanguages, "rico:type", "content", "rico:name"),
language = Extract.facetEntity(recordLanguages, "rico:name"),
genre = Extract.facetEntity(genre, "skos:prefLabel"),
keywords = Extract.facetEntity(subjects, "skos:prefLabel"),
agentSubject = Extract.typedEntityByType(subjects, "@type", "rico:Agent", "rico:name"),
......@@ -138,7 +141,24 @@ class SearchDocTransform {
),
persons = emptyList(),
corporateBodies = emptyList(),
agents = emptyList()
agents = emptyList(),
accessDigital = emptyList(),
callNumber = emptyList(),
accessPhysical = emptyList(),
access = emptyList(),
colourDigital = emptyList(),
colourPhysical = emptyList(),
digitalObjectNote = emptyList(),
durationDigital = emptyList(),
durationPhysical = emptyList(),
locator = emptyList(),
physicalCharacteristics = emptyList(),
physicalObjectNote = emptyList(),
usageConditionsDigital = emptyList(),
usageConditionsPhysical = emptyList(),
usageDigital = emptyList(),
usageDigitalGroup = emptyList(),
usagePhysical = emptyList()
)
}
}
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