Skip to content

Commit

Permalink
Merge branch 'main' into Aggregation-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
StepanBrychta authored Dec 2, 2024
2 parents 5fab5a7 + cd74c2b commit 2a29a74
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
4 changes: 4 additions & 0 deletions pipeline/terraform/modules/stack/elastic_pipeline.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ module "pipeline_indices" {
locals {
indices = module.pipeline_indices.index_names
service_index_permissions = {
read_only = {
read = ["*"]
write = []
}
transformer = {
read = []
write = [local.indices.source]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ object CalmTransformer
format = Some(CalmFormat(record)),
collectionPath = Some(collectionPath),
referenceNumber = collectionPath.label.map(ReferenceNumber(_)),
subjects = subjects(record),
subjects = CalmSubjects(record),
languages = languages,
items = CalmItems(record),
contributors = CalmContributors(record),
Expand Down Expand Up @@ -259,17 +259,4 @@ object CalmTransformer
)
}
}

def subjects(record: CalmRecord): List[Subject[IdState.Unminted]] =
record
.getList("Subject")
.map {
label =>
val normalisedLabel =
NormaliseText(label, whitelist = NormaliseText.none)
Subject(
label = normalisedLabel,
concepts = List(Concept(normalisedLabel))
)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package weco.pipeline.transformer.calm.transformers

import weco.catalogue.internal_model.identifiers.IdState
import weco.catalogue.internal_model.work.{Concept, Subject}
import weco.catalogue.source_model.calm.CalmRecord
import weco.pipeline.transformer.calm.NormaliseText
import weco.pipeline.transformer.calm.models.CalmRecordOps
import weco.pipeline.transformer.identifiers.LabelDerivedIdentifiers

object CalmSubjects extends CalmRecordOps with LabelDerivedIdentifiers {
def apply(record: CalmRecord): List[Subject[IdState.Unminted]] =
record.getList("Subject").map {
label =>
val normalisedLabel =
NormaliseText(label, whitelist = NormaliseText.none)

val labelDerivedId = identifierFromText(
label = normalisedLabel,
ontologyType = "Concept"
)

Subject(
label = normalisedLabel,
concepts = List(
Concept(
id = labelDerivedId,
label = normalisedLabel
)
),
id = labelDerivedId
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,19 @@ class CalmTransformerTest
"Subject" -> "<i>anatomy</i>",
"CatalogueStatus" -> "Catalogued"
)

CalmTransformer(
record,
version
).right.get.data.subjects should contain theSameElementsAs List(
Subject("anatomy", List(Concept("anatomy"))),
Subject("botany", List(Concept("botany")))
)
"anatomy",
"botany"
).map((strippedSubject: String) => {
val id = labelDerivedConceptIdentifier(strippedSubject)
val concepts = List(Concept(id, strippedSubject))

Subject(id, strippedSubject, concepts)
})
}

it("finds a single language") {
Expand Down

0 comments on commit 2a29a74

Please sign in to comment.