From: Michael Ritter Date: Fri, 17 Nov 2023 00:59:27 +0000 (-0700) Subject: CB-21: Include controlled terms for material display (#375) X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=90a62ce0ed1808843358614ffd8461adf9419d49;p=tmp%2Fjakarta-migration.git CB-21: Include controlled terms for material display (#375) --- diff --git a/3rdparty/nuxeo/nuxeo-platform-elasticsearch/src/main/java/org/collectionspace/services/nuxeo/elasticsearch/DefaultESDocumentWriter.java b/3rdparty/nuxeo/nuxeo-platform-elasticsearch/src/main/java/org/collectionspace/services/nuxeo/elasticsearch/DefaultESDocumentWriter.java index d589273bf..91fb3432a 100644 --- a/3rdparty/nuxeo/nuxeo-platform-elasticsearch/src/main/java/org/collectionspace/services/nuxeo/elasticsearch/DefaultESDocumentWriter.java +++ b/3rdparty/nuxeo/nuxeo-platform-elasticsearch/src/main/java/org/collectionspace/services/nuxeo/elasticsearch/DefaultESDocumentWriter.java @@ -60,6 +60,7 @@ public class DefaultESDocumentWriter extends JsonESDocumentWriter { denormMediaRecords(session, csid, tenantId, denormValues); denormAcquisitionRecords(session, csid, tenantId, denormValues); denormExhibitionRecords(session, csid, tenantId, denormValues); + denormMaterialFields(doc, denormValues); // Compute the title of the record for the public browser, and store it so that it can // be used for sorting ES query results. @@ -190,6 +191,36 @@ private void denormExhibitionRecords(CoreSession session, String csid, String te denormValues.putArray("exhibition").addAll(exhibitions); } + /** + * Denormalize the material group list for a collectionobject in order to index the controlled or uncontrolled term + * + * @param doc the collectionobject document + * @param denormValues the json node for denormalized fields + */ + private void denormMaterialFields(DocumentModel doc, ObjectNode denormValues) { + List> materialGroupList = + (List>) doc.getProperty("collectionobjects_common", "materialGroupList"); + + List denormMaterials = new ArrayList<>(); + for (Map materialGroup : materialGroupList) { + String controlledMaterial = (String) materialGroup.get("materialControlled"); + if (controlledMaterial != null) { + final ObjectNode node = objectMapper.createObjectNode(); + node.put("material", RefNameUtils.getDisplayName(controlledMaterial)); + denormMaterials.add(node); + } + + String material = (String) materialGroup.get("material"); + if (material != null) { + final ObjectNode node = objectMapper.createObjectNode(); + node.put("material", material); + denormMaterials.add(node); + } + } + + denormValues.putArray("materialGroupList").addAll(denormMaterials); + } + /** * Compute a title for the public browser. This needs to be indexed in ES so that it can * be used for sorting. (Even if it's just extracting the primary value.) diff --git a/services/common/src/main/cspace/config/services/tenants/anthro/anthro-tenant-bindings.delta.xml b/services/common/src/main/cspace/config/services/tenants/anthro/anthro-tenant-bindings.delta.xml index 8f54548e6..6274f264b 100644 --- a/services/common/src/main/cspace/config/services/tenants/anthro/anthro-tenant-bindings.delta.xml +++ b/services/common/src/main/cspace/config/services/tenants/anthro/anthro-tenant-bindings.delta.xml @@ -31,7 +31,6 @@ "collectionobjects_common:contentConcepts", "collectionobjects_common:fieldCollectionDateGroup", "collectionobjects_common:fieldCollectors", - "collectionobjects_common:materialGroupList", "collectionobjects_common:measuredPartGroupList", "collectionobjects_common:numberOfObjects", "collectionobjects_common:objectHistoryNote", @@ -124,6 +123,15 @@ } } }, + "collectionspace_denorm:materialGroupList": { + "type": "object", + "properties": { + "material": { + "type": "keyword", + "copy_to": "all_field" + } + } + }, "collectionobjects_common:objectNumber": { "type": "keyword", @@ -220,15 +228,6 @@ } } }, - "collectionobjects_common:materialGroupList": { - "type": "object", - "properties": { - "material": { - "type": "keyword", - "copy_to": "all_field" - } - } - }, "collectionobjects_common:colors": { "type": "keyword", "copy_to": "all_field" diff --git a/services/common/src/main/cspace/config/services/tenants/fcart/fcart-tenant-bindings.delta.xml b/services/common/src/main/cspace/config/services/tenants/fcart/fcart-tenant-bindings.delta.xml index bdaaf334c..a91f23fd4 100644 --- a/services/common/src/main/cspace/config/services/tenants/fcart/fcart-tenant-bindings.delta.xml +++ b/services/common/src/main/cspace/config/services/tenants/fcart/fcart-tenant-bindings.delta.xml @@ -25,7 +25,6 @@ "collectionobjects_common:colors", "collectionobjects_common:computedCurrentLocation", "collectionobjects_common:contentConcepts", - "collectionobjects_common:materialGroupList", "collectionobjects_common:measuredPartGroupList", "collectionobjects_common:numberOfObjects", "collectionobjects_common:objectHistoryNote", @@ -115,6 +114,15 @@ } } }, + "collectionspace_denorm:materialGroupList": { + "type": "object", + "properties": { + "material": { + "type": "keyword", + "copy_to": "all_field" + } + } + }, "collectionobjects_common:objectNumber": { "type": "keyword", @@ -205,15 +213,6 @@ } } }, - "collectionobjects_common:materialGroupList": { - "type": "object", - "properties": { - "material": { - "type": "keyword", - "copy_to": "all_field" - } - } - }, "collectionobjects_common:colors": { "type": "keyword", "copy_to": "all_field" diff --git a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml index a0d958a00..bef66254f 100644 --- a/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml +++ b/services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml @@ -1141,7 +1141,6 @@ "collectionobjects_common:colors", "collectionobjects_common:computedCurrentLocation", "collectionobjects_common:contentConcepts", - "collectionobjects_common:materialGroupList", "collectionobjects_common:measuredPartGroupList", "collectionobjects_common:numberOfObjects", "collectionobjects_common:objectHistoryNote", @@ -1230,6 +1229,15 @@ } } }, + "collectionspace_denorm:materialGroupList": { + "type": "object", + "properties": { + "material": { + "type": "keyword", + "copy_to": "all_field" + } + } + }, "collectionobjects_common:objectNumber": { "type": "keyword", @@ -1314,15 +1322,6 @@ } } }, - "collectionobjects_common:materialGroupList": { - "type": "object", - "properties": { - "material": { - "type": "keyword", - "copy_to": "all_field" - } - } - }, "collectionobjects_common:colors": { "type": "keyword", "copy_to": "all_field"