Commit 812e958d authored by Jonas Waeber's avatar Jonas Waeber
Browse files

Rename KEYS to Constants

parent 346ddef1
...@@ -20,7 +20,7 @@ package org.memobase ...@@ -20,7 +20,7 @@ package org.memobase
import ch.memobase.settings.SettingsLoader import ch.memobase.settings.SettingsLoader
import kotlin.system.exitProcess import kotlin.system.exitProcess
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import org.memobase.helpers.KEYS.SettingsProps import org.memobase.helpers.Constants.SettingsProps
class App { class App {
companion object { companion object {
......
...@@ -36,7 +36,7 @@ import org.memobase.helpers.FacetBuildHelpers ...@@ -36,7 +36,7 @@ import org.memobase.helpers.FacetBuildHelpers
import org.memobase.helpers.Filter import org.memobase.helpers.Filter
import org.memobase.helpers.InstitutionAndRecordSetExtractionHelper.extractInstitution import org.memobase.helpers.InstitutionAndRecordSetExtractionHelper.extractInstitution
import org.memobase.helpers.InstitutionAndRecordSetExtractionHelper.extractRecordSet import org.memobase.helpers.InstitutionAndRecordSetExtractionHelper.extractRecordSet
import org.memobase.helpers.KEYS import org.memobase.helpers.Constants
import org.memobase.helpers.TranslationMappers import org.memobase.helpers.TranslationMappers
import org.memobase.model.DocumentsSearchDoc import org.memobase.model.DocumentsSearchDoc
import org.memobase.model.EnrichedDigitalMetadata import org.memobase.model.EnrichedDigitalMetadata
...@@ -59,39 +59,39 @@ class DocumentsSearchDocBuilder( ...@@ -59,39 +59,39 @@ class DocumentsSearchDocBuilder(
val physicalObject = val physicalObject =
input.values.firstOrNull { it["@type"] == NS.rico + "Instantiation" && it["type"] == "physicalObject" } input.values.firstOrNull { it["@type"] == NS.rico + "Instantiation" && it["type"] == "physicalObject" }
val keywordIds = Extract.identifiers(record[KEYS.hasSubject]) val keywordIds = Extract.identifiers(record[Constants.hasSubject])
val genreIds = Extract.identifiers(record[KEYS.hasGenre]) val genreIds = Extract.identifiers(record[Constants.hasGenre])
val publishedByIds = Extract.identifiers(record[KEYS.publishedBy]) val publishedByIds = Extract.identifiers(record[Constants.publishedBy])
val producerIds = Extract.identifiers(record[KEYS.producer]) val producerIds = Extract.identifiers(record[Constants.producer])
val spatialIds = Extract.identifiers(record[KEYS.spatial]) val spatialIds = Extract.identifiers(record[Constants.spatial])
val placeOfCaptureIds = Extract.identifiers(record[KEYS.placeOfCapture]) val placeOfCaptureIds = Extract.identifiers(record[Constants.placeOfCapture])
val dateCreatedIds = Extract.identifiers(record[KEYS.created]) val dateCreatedIds = Extract.identifiers(record[Constants.created])
val dateIssuedIds = Extract.identifiers(record[KEYS.issued]) val dateIssuedIds = Extract.identifiers(record[Constants.issued])
val temporalIds = Extract.identifiers(record[KEYS.temporal]) val temporalIds = Extract.identifiers(record[Constants.temporal])
val personFacetBuilder = PersonFacetBuilder() val personFacetBuilder = PersonFacetBuilder()
val subjectPersonBuilder = AgentContainerBuilder(keywordIds, KEYS.Person, null, input) val subjectPersonBuilder = AgentContainerBuilder(keywordIds, Constants.Person, null, input)
val publisherPersonBuilder = AgentContainerBuilder(publishedByIds, KEYS.Person, null, input) val publisherPersonBuilder = AgentContainerBuilder(publishedByIds, Constants.Person, null, input)
val producersPersonBuilder = AgentContainerBuilder(producerIds, KEYS.Person, null, input) val producersPersonBuilder = AgentContainerBuilder(producerIds, Constants.Person, null, input)
val contributorPersonBuilder = AgentContainerBuilder(emptyList(), KEYS.Person, KEYS.contributor, input) val contributorPersonBuilder = AgentContainerBuilder(emptyList(), Constants.Person, Constants.contributor, input)
val creatorPersonBuilder = AgentContainerBuilder(emptyList(), KEYS.Person, KEYS.creator, input) val creatorPersonBuilder = AgentContainerBuilder(emptyList(), Constants.Person, Constants.creator, input)
val subjectCorporateBodyBuilder = AgentContainerBuilder(keywordIds, KEYS.CorporateBody, null, input) val subjectCorporateBodyBuilder = AgentContainerBuilder(keywordIds, Constants.CorporateBody, null, input)
val publisherCorporateBodyBuilder = AgentContainerBuilder(publishedByIds, KEYS.CorporateBody, null, input) val publisherCorporateBodyBuilder = AgentContainerBuilder(publishedByIds, Constants.CorporateBody, null, input)
val producersCorporateBodyBuilder = AgentContainerBuilder(producerIds, KEYS.CorporateBody, null, input) val producersCorporateBodyBuilder = AgentContainerBuilder(producerIds, Constants.CorporateBody, null, input)
val contributorCorporateBodyBuilder = val contributorCorporateBodyBuilder =
AgentContainerBuilder(emptyList(), KEYS.CorporateBody, KEYS.contributor, input) AgentContainerBuilder(emptyList(), Constants.CorporateBody, Constants.contributor, input)
val creatorCorporateBodyBuilder = AgentContainerBuilder(emptyList(), KEYS.CorporateBody, KEYS.creator, input) val creatorCorporateBodyBuilder = AgentContainerBuilder(emptyList(), Constants.CorporateBody, Constants.creator, input)
val subjectAgentBuilder = AgentContainerBuilder(keywordIds, KEYS.Agent, null, input) val subjectAgentBuilder = AgentContainerBuilder(keywordIds, Constants.Agent, null, input)
val publisherAgentBuilder = AgentContainerBuilder(publishedByIds, KEYS.Agent, null, input) val publisherAgentBuilder = AgentContainerBuilder(publishedByIds, Constants.Agent, null, input)
val producersAgentBuilder = AgentContainerBuilder(producerIds, KEYS.Agent, null, input) val producersAgentBuilder = AgentContainerBuilder(producerIds, Constants.Agent, null, input)
val contributorAgentBuilder = AgentContainerBuilder(emptyList(), KEYS.Agent, KEYS.contributor, input) val contributorAgentBuilder = AgentContainerBuilder(emptyList(), Constants.Agent, Constants.contributor, input)
val creatorAgentBuilder = AgentContainerBuilder(emptyList(), KEYS.Agent, KEYS.creator, input) val creatorAgentBuilder = AgentContainerBuilder(emptyList(), Constants.Agent, Constants.creator, input)
val placesRelatedBuilder = FacettedContainerBuilder(spatialIds, KEYS.Place, KEYS.name, FacetBuildHelpers::place) val placesRelatedBuilder = FacettedContainerBuilder(spatialIds, Constants.Place, Constants.name, FacetBuildHelpers::place)
val placeCapturedBuilder = val placeCapturedBuilder =
FacettedContainerBuilder(placeOfCaptureIds, KEYS.Place, KEYS.name, FacetBuildHelpers::place) FacettedContainerBuilder(placeOfCaptureIds, Constants.Place, Constants.name, FacetBuildHelpers::place)
val placeFacetBuilder = PlaceFacetBuilder() val placeFacetBuilder = PlaceFacetBuilder()
...@@ -104,9 +104,9 @@ class DocumentsSearchDocBuilder( ...@@ -104,9 +104,9 @@ class DocumentsSearchDocBuilder(
val digitalIdentifierReferences = Extract.identifiers(digitalObject?.get("identifiedBy")) val digitalIdentifierReferences = Extract.identifiers(digitalObject?.get("identifiedBy"))
val digitalIdentifierEntities = mutableListOf<JsonObject>() val digitalIdentifierEntities = mutableListOf<JsonObject>()
val formats = EnrichedFacetContainerBuilder(emptyList(), NS.rico + KEYS.CarrierType, KEYS.name, input) val formats = EnrichedFacetContainerBuilder(emptyList(), NS.rico + Constants.CarrierType, Constants.name, input)
val languages = EnrichedFacetContainerBuilder(emptyList(), NS.rico + KEYS.Language, KEYS.name, input) val languages = EnrichedFacetContainerBuilder(emptyList(), NS.rico + Constants.Language, Constants.name, input)
val genres = EnrichedFacetContainerBuilder(genreIds, NS.skos + KEYS.Concept, KEYS.prefLabel, input) val genres = EnrichedFacetContainerBuilder(genreIds, NS.skos + Constants.Concept, Constants.prefLabel, input)
for (item in input.entries) { for (item in input.entries) {
for (builder: IFieldBuilder in listOf( for (builder: IFieldBuilder in listOf(
...@@ -166,7 +166,7 @@ class DocumentsSearchDocBuilder( ...@@ -166,7 +166,7 @@ class DocumentsSearchDocBuilder(
val usageDigital = Extract.typedEntityByType(digitalRules, "type", "usage", "sameAs").flatMap { it.toList() } val usageDigital = Extract.typedEntityByType(digitalRules, "type", "usage", "sameAs").flatMap { it.toList() }
val locator = try { val locator = try {
val value = Extract.extractIdValue(digitalIdentifierEntities, KEYS.IdentifierType.main) val value = Extract.extractIdValue(digitalIdentifierEntities, Constants.IdentifierType.main)
if (value == null) if (value == null)
"" ""
else else
...@@ -208,7 +208,7 @@ class DocumentsSearchDocBuilder( ...@@ -208,7 +208,7 @@ class DocumentsSearchDocBuilder(
} }
} }
val type = record[KEYS.ricoType].let { val type = record[Constants.ricoType].let {
if (it == null) { if (it == null) {
translationMappers.getDocumentType("Andere") translationMappers.getDocumentType("Andere")
} else { } else {
...@@ -224,13 +224,13 @@ class DocumentsSearchDocBuilder( ...@@ -224,13 +224,13 @@ class DocumentsSearchDocBuilder(
broadcastTitle = Extract.typedEntityByType(recordTitles, "type", "broadcast", "title"), broadcastTitle = Extract.typedEntityByType(recordTitles, "type", "broadcast", "title"),
type = type, type = type,
sourceID = try { sourceID = try {
Extract.extractIdValue(recordIdentifiers, KEYS.IdentifierType.original) ?: "NoSourceIdFound" Extract.extractIdValue(recordIdentifiers, Constants.IdentifierType.original) ?: "NoSourceIdFound"
} catch (ex: NoSuchElementException) { } catch (ex: NoSuchElementException) {
log.error("No source id found for record $key.") log.error("No source id found for record $key.")
"NoSourceIdFound" "NoSourceIdFound"
}, },
oldMemobaseId = try { oldMemobaseId = try {
Extract.extractIdValue(recordIdentifiers, KEYS.IdentifierType.oldMemobase) ?: "" Extract.extractIdValue(recordIdentifiers, Constants.IdentifierType.oldMemobase) ?: ""
} catch (ex: NoSuchElementException) { } catch (ex: NoSuchElementException) {
log.warn("No old memobase id found for record $key.") log.warn("No old memobase id found for record $key.")
"" ""
...@@ -263,9 +263,9 @@ class DocumentsSearchDocBuilder( ...@@ -263,9 +263,9 @@ class DocumentsSearchDocBuilder(
rightsHolder = Extract.typedEntityByType(recordRules, "type", "holder", "name"), rightsHolder = Extract.typedEntityByType(recordRules, "type", "holder", "name"),
conditionsOfUse = Extract.languageContainer( conditionsOfUse = Extract.languageContainer(
"conditionsOfUse (record id: $key)", "conditionsOfUse (record id: $key)",
record[KEYS.conditionsOfUse] record[Constants.conditionsOfUse]
), ),
memoriavClaim = record[KEYS.sponsoredBy] != null, memoriavClaim = record[Constants.sponsoredBy] != null,
format = formats.build(), format = formats.build(),
language = languages.build(), language = languages.build(),
...@@ -274,7 +274,7 @@ class DocumentsSearchDocBuilder( ...@@ -274,7 +274,7 @@ class DocumentsSearchDocBuilder(
keywords = subjects.flatMap { keywords = subjects.flatMap {
Extract.languageContainer( Extract.languageContainer(
"hasSubject (record id: $key)", "hasSubject (record id: $key)",
it[KEYS.prefLabel] it[Constants.prefLabel]
) )
}.let { }.let {
if (it.isEmpty()) if (it.isEmpty())
...@@ -309,7 +309,7 @@ class DocumentsSearchDocBuilder( ...@@ -309,7 +309,7 @@ class DocumentsSearchDocBuilder(
// DIGITAL // DIGITAL
accessDigital = accessDigital, accessDigital = accessDigital,
durationDigital = Extract.listOfStrings(digitalObject?.get("duration")), durationDigital = Extract.listOfStrings(digitalObject?.get("duration")),
colourDigital = Extract.listOfStrings(digitalObject?.get(KEYS.color)), colourDigital = Extract.listOfStrings(digitalObject?.get(Constants.color)),
digitalObjectNote = Extract.languageContainer("descriptiveNote", digitalObject?.get("descriptiveNote")), digitalObjectNote = Extract.languageContainer("descriptiveNote", digitalObject?.get("descriptiveNote")),
locator = if (addLocator) locator else null, locator = if (addLocator) locator else null,
mediaLocation = mediaLocation, mediaLocation = mediaLocation,
...@@ -346,7 +346,7 @@ class DocumentsSearchDocBuilder( ...@@ -346,7 +346,7 @@ class DocumentsSearchDocBuilder(
originalInstitution = elasticSearchWrapper.getExtraInstitutionsFromRecordSet(recordSetId, "original"), originalInstitution = elasticSearchWrapper.getExtraInstitutionsFromRecordSet(recordSetId, "original"),
masterInstitution = elasticSearchWrapper.getExtraInstitutionsFromRecordSet(recordSetId, "master"), masterInstitution = elasticSearchWrapper.getExtraInstitutionsFromRecordSet(recordSetId, "master"),
published = (record[KEYS.isPublished] as Boolean?) ?: false, published = (record[Constants.isPublished] as Boolean?) ?: false,
suggest = suggestContainerBuilder.build()[0] suggest = suggestContainerBuilder.build()[0]
) )
} }
......
...@@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager ...@@ -26,7 +26,7 @@ import org.apache.logging.log4j.LogManager
import org.memobase.helpers.Date import org.memobase.helpers.Date
import org.memobase.helpers.ElasticSearchWrapper import org.memobase.helpers.ElasticSearchWrapper
import org.memobase.helpers.Extract import org.memobase.helpers.Extract
import org.memobase.helpers.KEYS import org.memobase.helpers.Constants
import org.memobase.helpers.TranslationMappers import org.memobase.helpers.TranslationMappers
import org.memobase.model.FacetContainer import org.memobase.model.FacetContainer
import org.memobase.model.InstitutionSearchDoc import org.memobase.model.InstitutionSearchDoc
...@@ -51,23 +51,23 @@ class InstitutionSearchDocBuilder( ...@@ -51,23 +51,23 @@ class InstitutionSearchDocBuilder(
input.values.forEach { input.values.forEach {
when { when {
it[KEYS.ricoType] == KEYS.LocationType.canton -> { it[Constants.ricoType] == Constants.LocationType.canton -> {
cantons.add(FacetContainer(extractAdminUnit(it, "canton", "NoCantonFound"), null, emptyList())) cantons.add(FacetContainer(extractAdminUnit(it, "canton", "NoCantonFound"), null, emptyList()))
} }
it[KEYS.ricoType] == KEYS.LocationType.municipality -> { it[Constants.ricoType] == Constants.LocationType.municipality -> {
municipalities.add(extractAdminUnit(it, "municipality", "NoCityFound")) municipalities.add(extractAdminUnit(it, "municipality", "NoCityFound"))
} }
it[KEYS.ricoType] == KEYS.IdentifierType.main -> { it[Constants.ricoType] == Constants.IdentifierType.main -> {
identifiers.add(it) identifiers.add(it)
} }
it[KEYS.atType] == NS.rico + KEYS.Place -> { it[Constants.atType] == NS.rico + Constants.Place -> {
addresses.addAll(Extract.listOfStrings(it[KEYS.wikidataAddresses])) addresses.addAll(Extract.listOfStrings(it[Constants.wikidataAddresses]))
postalCodes.addAll(Extract.listOfStrings(it[KEYS.wikidataPostalCodes])) postalCodes.addAll(Extract.listOfStrings(it[Constants.wikidataPostalCodes]))
} }
} }
} }
val type = institution[KEYS.wikidataInstance].let { val type = institution[Constants.wikidataInstance].let {
when (it) { when (it) {
is String -> listOf(translationMappers.getInstitutionType(it)) is String -> listOf(translationMappers.getInstitutionType(it))
is JsonArray<*> -> it.map { any -> translationMappers.getInstitutionType(any as String) } is JsonArray<*> -> it.map { any -> translationMappers.getInstitutionType(any as String) }
...@@ -78,15 +78,15 @@ class InstitutionSearchDocBuilder( ...@@ -78,15 +78,15 @@ class InstitutionSearchDocBuilder(
} }
} }
val name = extractLanguageContainer(institution[KEYS.name], "NoNameFound") val name = extractLanguageContainer(institution[Constants.name], "NoNameFound")
val description = extractLanguageContainer(institution[KEYS.descriptiveNote], "NoDescriptionFound") val description = extractLanguageContainer(institution[Constants.descriptiveNote], "NoDescriptionFound")
val id = Extract.extractIdValue(identifiers, KEYS.IdentifierType.main) ?: "NoIdentifierFound" val id = Extract.extractIdValue(identifiers, Constants.IdentifierType.main) ?: "NoIdentifierFound"
val recordSetUris = Extract.listOfStrings(institution[KEYS.isHolderOf]) val recordSetUris = Extract.listOfStrings(institution[Constants.isHolderOf])
val recordSetIds = recordSetUris.map { it.substringAfterLast("/") } val recordSetIds = recordSetUris.map { it.substringAfterLast("/") }
return InstitutionSearchDoc( return InstitutionSearchDoc(
institutionId = id, institutionId = id,
published = institution[KEYS.isPublished].let { published = institution[Constants.isPublished].let {
when (it) { when (it) {
is Boolean -> it is Boolean -> it
is String -> it.toBoolean() is String -> it.toBoolean()
...@@ -102,10 +102,10 @@ class InstitutionSearchDocBuilder( ...@@ -102,10 +102,10 @@ class InstitutionSearchDocBuilder(
documentType = recordSetIds.flatMap { documentType = recordSetIds.flatMap {
elasticSearchWrapper.getDocumentTypesFromRecords( elasticSearchWrapper.getDocumentTypesFromRecords(
it, it,
KEYS.QueryFields.recordSetFacet Constants.QueryFields.recordSetFacet
) )
}.distinctBy { it.filter }, }.distinctBy { it.filter },
keyVisualLink = institution[KEYS.wikidataImage].let { if (it != null) it as String else "NoKeyVisualLinkDefined" }, keyVisualLink = institution[Constants.wikidataImage].let { if (it != null) it as String else "NoKeyVisualLinkDefined" },
canton = cantons, canton = cantons,
city = municipalities, city = municipalities,
address = addresses, address = addresses,
...@@ -149,7 +149,7 @@ class InstitutionSearchDocBuilder( ...@@ -149,7 +149,7 @@ class InstitutionSearchDocBuilder(
} }
private fun extractAdminUnit(item: JsonObject, parent: String, placeholder: String): LanguageContainer { private fun extractAdminUnit(item: JsonObject, parent: String, placeholder: String): LanguageContainer {
return item[KEYS.name].let { name -> return item[Constants.name].let { name ->
Extract.languageContainer(parent, name).let { Extract.languageContainer(parent, name).let {
when { when {
it.isEmpty() -> LanguageContainer.placeholder(placeholder) it.isEmpty() -> LanguageContainer.placeholder(placeholder)
......
...@@ -32,7 +32,7 @@ import org.apache.kafka.streams.kstream.Predicate ...@@ -32,7 +32,7 @@ import org.apache.kafka.streams.kstream.Predicate
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import org.memobase.helpers.ElasticSearchWrapper import org.memobase.helpers.ElasticSearchWrapper
import org.memobase.helpers.JSON import org.memobase.helpers.JSON
import org.memobase.helpers.KEYS.SettingsProps import org.memobase.helpers.Constants.SettingsProps
import org.memobase.helpers.TranslationMappers import org.memobase.helpers.TranslationMappers
import org.memobase.helpers.UpdateQueryBuilder import org.memobase.helpers.UpdateQueryBuilder
import org.memobase.model.DocumentsSearchDoc import org.memobase.model.DocumentsSearchDoc
......
...@@ -31,7 +31,7 @@ import org.memobase.helpers.Date ...@@ -31,7 +31,7 @@ import org.memobase.helpers.Date
import org.memobase.helpers.ElasticSearchWrapper import org.memobase.helpers.ElasticSearchWrapper
import org.memobase.helpers.Extract import org.memobase.helpers.Extract
import org.memobase.helpers.JSON import org.memobase.helpers.JSON
import org.memobase.helpers.KEYS import org.memobase.helpers.Constants
import org.memobase.model.FacetContainer import org.memobase.model.FacetContainer
import org.memobase.model.IntegerRange import org.memobase.model.IntegerRange
import org.memobase.model.LanguageContainer import org.memobase.model.LanguageContainer
...@@ -60,48 +60,48 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW ...@@ -60,48 +60,48 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW
val originalInstitutions = mutableListOf<FacetContainer>() val originalInstitutions = mutableListOf<FacetContainer>()
input.values.forEach { input.values.forEach {
when { when {
it[RICO.type.localName] == KEYS.LanguageType.metadata -> { it[RICO.type.localName] == Constants.LanguageType.metadata -> {
metadataLanguages.add(it) metadataLanguages.add(it)
} }
it[KEYS.atType] == RICO.Identifier.uri && it[RICO.type.localName] == KEYS.IdentifierType.callNumber -> { it[Constants.atType] == RICO.Identifier.uri && it[RICO.type.localName] == Constants.IdentifierType.callNumber -> {
originalCallNumbers.add(it[RICO.identifier.localName] as String) originalCallNumbers.add(it[RICO.identifier.localName] as String)
} }
it[KEYS.atType] == RICO.Identifier.uri && it[RICO.type.localName] == KEYS.IdentifierType.original -> { it[Constants.atType] == RICO.Identifier.uri && it[RICO.type.localName] == Constants.IdentifierType.original -> {
originalIdNumbers.add(it[RICO.identifier.localName] as String) originalIdNumbers.add(it[RICO.identifier.localName] as String)
} }
it[KEYS.atType] == RICO.Title.uri && it[Constants.atType] == RICO.Title.uri &&
it[RICO.type.localName] == KEYS.TitleTypes.original -> { it[RICO.type.localName] == Constants.TitleTypes.original -> {
originalTitles = originalTitles.add(it[RICO.title.localName]) originalTitles = originalTitles.add(it[RICO.title.localName])
} }
it[KEYS.atType] == RICO.CorporateBody.uri && it[Constants.atType] == RICO.CorporateBody.uri &&
it[RICO.type.localName] == KEYS.CorporateBodyType.memoriavProject -> { it[RICO.type.localName] == Constants.CorporateBodyType.memoriavProject -> {
projectTitles = projectTitles.add(it[RICO.title.localName]) projectTitles = projectTitles.add(it[RICO.title.localName])
} }
it[KEYS.atType] == RICO.RecordSet.uri && it[RICO.type.localName] == RecordSet.related -> { it[Constants.atType] == RICO.RecordSet.uri && it[RICO.type.localName] == RecordSet.related -> {
relatedRecordSets = relatedRecordSets.add(it[RICO.title.localName]) relatedRecordSets = relatedRecordSets.add(it[RICO.title.localName])
} }
it[KEYS.atType] == RICO.Record.uri -> { it[Constants.atType] == RICO.Record.uri -> {
if (it[RICO.type.localName] == RICO.Types.Record.publication) { if (it[RICO.type.localName] == RICO.Types.Record.publication) {
publicationTitles = publicationTitles.add(it[RICO.title.localName]) publicationTitles = publicationTitles.add(it[RICO.title.localName])
} else if (it[RICO.type.localName] == RICO.Types.Record.related) { } else if (it[RICO.type.localName] == RICO.Types.Record.related) {
relatedDocumentTitles = relatedDocumentTitles.add(it[RICO.title.localName]) relatedDocumentTitles = relatedDocumentTitles.add(it[RICO.title.localName])
} }
} }
it[KEYS.atType] == RICO.RecordResourceHoldingRelation.uri it[Constants.atType] == RICO.RecordResourceHoldingRelation.uri
&& it[RICO.type.localName] == RICO.Types.RecordResourceHoldingRelation.access -> { && it[RICO.type.localName] == RICO.Types.RecordResourceHoldingRelation.access -> {
val value = it[RICO.recordResourceHoldingRelationHasSource.localName] as String val value = it[RICO.recordResourceHoldingRelationHasSource.localName] as String
val id = value.substringAfterLast("/") val id = value.substringAfterLast("/")
val names = elasticSearchWrapper.getInstitutionName(id) val names = elasticSearchWrapper.getInstitutionName(id)
accessInstitutions.add(names) accessInstitutions.add(names)
} }
it[KEYS.atType] == RICO.RecordResourceHoldingRelation.uri it[Constants.atType] == RICO.RecordResourceHoldingRelation.uri
&& it[RICO.type.localName] == RICO.Types.RecordResourceHoldingRelation.master -> { && it[RICO.type.localName] == RICO.Types.RecordResourceHoldingRelation.master -> {
val value = it[RICO.recordResourceHoldingRelationHasSource.localName] as String val value = it[RICO.recordResourceHoldingRelationHasSource.localName] as String
val id = value.substringAfterLast("/") val id = value.substringAfterLast("/")
val names = elasticSearchWrapper.getInstitutionName(id) val names = elasticSearchWrapper.getInstitutionName(id)
masterInstitutions.add(names) masterInstitutions.add(names)
} }
it[KEYS.atType] == RICO.RecordResourceHoldingRelation.uri it[Constants.atType] == RICO.RecordResourceHoldingRelation.uri
&& it[RICO.type.localName] == RICO.Types.RecordResourceHoldingRelation.original -> { && it[RICO.type.localName] == RICO.Types.RecordResourceHoldingRelation.original -> {
val value = it[RICO.recordResourceHoldingRelationHasSource.localName] as String val value = it[RICO.recordResourceHoldingRelationHasSource.localName] as String
val id = value.substringAfterLast("/") val id = value.substringAfterLast("/")
...@@ -137,7 +137,7 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW ...@@ -137,7 +137,7 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW
} else { } else {
null null
} }
val uri = recordSet[KEYS.entityId] as String val uri = recordSet[Constants.entityId] as String
val id = uri.substringAfterLast("/") val id = uri.substringAfterLast("/")
val institutions = when (val value = recordSet[RICO.heldBy.localName]) { val institutions = when (val value = recordSet[RICO.heldBy.localName]) {
is String -> listOf(value) is String -> listOf(value)
...@@ -163,7 +163,7 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW ...@@ -163,7 +163,7 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW
return RecordSetSearchDoc( return RecordSetSearchDoc(
recordSetId = id, recordSetId = id,
published = recordSet[KEYS.isPublished].let { published = recordSet[Constants.isPublished].let {
when (it) { when (it) {
is Boolean -> it is Boolean -> it
is String -> it.toBoolean() is String -> it.toBoolean()
...@@ -175,16 +175,16 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW ...@@ -175,16 +175,16 @@ class RecordSetSearchDocBuilder(private val elasticSearchWrapper: ElasticSearchW
}, },
periodOfTimeAsYear = date, periodOfTimeAsYear = date,
institution = institutionIds.map { elasticSearchWrapper.getInstitutionName(it) }, institution = institutionIds.map { elasticSearchWrapper.getInstitutionName(it) },
supportedByMemoriav = recordSet[KEYS.sponsoredBy] != null, supportedByMemoriav = recordSet[Constants.sponsoredBy] != null,
name = name, name = name,
documentType = elasticSearchWrapper.getDocumentTypesFromRecords(id, KEYS.QueryFields.recordSetFacet), documentType = elasticSearchWrapper.getDocumentTypesFromRecords(id, Constants.QueryFields.recordSetFacet),
keyVisualLink = recordSet[KEYS.wikidataImage].let { if (it != null) it as String else "NoKeyVisualLinkDefined" }, keyVisualLink = recordSet[Constants.wikidataImage].let { if (it != null) it as String else "NoKeyVisualLinkDefined" },
numberOfDocuments = elasticSearchWrapper.countNumberOfDocuments(id), numberOfDocuments = elasticSearchWrapper.countNumberOfDocuments(id),
lastUpdatedDate = Date.now, lastUpdatedDate = Date.now,
languageOfMetadata = metadataLanguages.map { languageOfMetadata = metadataLanguages.map {
FacetContainer( FacetContainer(
extractLanguageContainer(it[KEYS.name], "NoMetadataLanguageSet"), extractLanguageContainer(it[Constants.name], "NoMetadataLanguageSet"),
it[KEYS.sameAs].let { wikidataUri -> it[Constants.sameAs].let { wikidataUri ->
when (wikidataUri) { when (wikidataUri) {
is String -> wikidataUri.substringAfterLast("/") is String -> wikidataUri.substringAfterLast("/")
else -> null else -> null
......
...@@ -32,7 +32,7 @@ import org.elasticsearch.client.RestClient ...@@ -32,7 +32,7 @@ import org.elasticsearch.client.RestClient
import org.elasticsearch.client.RestHighLevelClient import org.elasticsearch.client.RestHighLevelClient
import org.elasticsearch.client.indices.GetIndexRequest import org.elasticsearch.client.indices.GetIndexRequest
import org.memobase.helpers.ElasticSearchWrapper import org.memobase.helpers.ElasticSearchWrapper
import org.memobase.helpers.KEYS.SettingsProps import org.memobase.helpers.Constants.SettingsProps
import org.memobase.helpers.TranslationMappers import org.memobase.helpers.TranslationMappers
class Service(settings: SettingsLoader) { class Service(settings: SettingsLoader) {
...@@ -40,7 +40,7 @@ class Service(settings: SettingsLoader) { ...@@ -40,7 +40,7 @@ class Service(settings: SettingsLoader) {
const val name = "search-doc-service" const val name = "search-doc-service"
} }
private val log = LogManager.getLogger("SearchDocServiceService") private val log = LogManager.getLogger("SearchDocService")
private val appSettings = settings.appSettings private val appSettings = settings.appSettings
private val documentMapperPath = appSettings.getProperty(SettingsProps.documentTypeLabelsPath) private val documentMapperPath = appSettings.getProperty(SettingsProps.documentTypeLabelsPath)
......
...@@ -23,7 +23,7 @@ import com.beust.klaxon.JsonObject ...@@ -23,7 +23,7 @@ import com.beust.klaxon.JsonObject
import org.apache.logging.log4j.LogManager import org.apache.logging.log4j.LogManager
import org.memobase.helpers.Extract import org.memobase.helpers.Extract
import org.memobase.helpers.FacetBuildHelpers import org.memobase.helpers.FacetBuildHelpers
import org.memobase.helpers.KEYS import org.memobase.helpers.Constants
import org.memobase.model.AgentWithRelationContainer import org.memobase.model.AgentWithRelationContainer
import org.memobase.model.LanguageContainer import org.memobase.model.LanguageContainer