]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CB-21: Include controlled terms for material display (#375)
authorMichael Ritter <mikejritter@users.noreply.github.com>
Fri, 17 Nov 2023 00:59:27 +0000 (17:59 -0700)
committerGitHub <noreply@github.com>
Fri, 17 Nov 2023 00:59:27 +0000 (19:59 -0500)
3rdparty/nuxeo/nuxeo-platform-elasticsearch/src/main/java/org/collectionspace/services/nuxeo/elasticsearch/DefaultESDocumentWriter.java
services/common/src/main/cspace/config/services/tenants/anthro/anthro-tenant-bindings.delta.xml
services/common/src/main/cspace/config/services/tenants/fcart/fcart-tenant-bindings.delta.xml
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml

index d589273bfd21ced1f92125ecfe772cab509b7595..91fb3432a0238cb6da9d23108b0eec46d4db9d29 100644 (file)
@@ -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<Map<String, Object>> materialGroupList =
+                       (List<Map<String, Object>>) doc.getProperty("collectionobjects_common", "materialGroupList");
+
+               List<JsonNode> denormMaterials = new ArrayList<>();
+               for (Map<String, Object> 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.)
index 8f54548e675bc1f078c34bf76b985fe6e8f4ba9c..6274f264bb34f4d6c9d6959c193e24e41498d569 100644 (file)
@@ -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",
                                                                }
                                                        }
                                                },
+                                               "collectionspace_denorm:materialGroupList": {
+                                                       "type": "object",
+                                                       "properties": {
+                                                               "material": {
+                                                                       "type": "keyword",
+                                                                       "copy_to": "all_field"
+                                                               }
+                                                       }
+                                               },
 
                                                "collectionobjects_common:objectNumber": {
                                                        "type": "keyword",
                                                                }
                                                        }
                                                },
-                                               "collectionobjects_common:materialGroupList": {
-                                                       "type": "object",
-                                                       "properties": {
-                                                               "material": {
-                                                                       "type": "keyword",
-                                                                       "copy_to": "all_field"
-                                                               }
-                                                       }
-                                               },
                                                "collectionobjects_common:colors": {
                                                        "type": "keyword",
                                                        "copy_to": "all_field"
index bdaaf334c9b58b3fe833d047335aee6e12fcfdf3..a91f23fd411430b313f400415f43527c9f83f43f 100644 (file)
@@ -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",
                                                                }
                                                        }
                                                },
+                                               "collectionspace_denorm:materialGroupList": {
+                                                       "type": "object",
+                                                       "properties": {
+                                                               "material": {
+                                                                       "type": "keyword",
+                                                                       "copy_to": "all_field"
+                                                               }
+                                                       }
+                                               },
 
                                                "collectionobjects_common:objectNumber": {
                                                        "type": "keyword",
                                                                }
                                                        }
                                                },
-                                               "collectionobjects_common:materialGroupList": {
-                                                       "type": "object",
-                                                       "properties": {
-                                                               "material": {
-                                                                       "type": "keyword",
-                                                                       "copy_to": "all_field"
-                                                               }
-                                                       }
-                                               },
                                                "collectionobjects_common:colors": {
                                                        "type": "keyword",
                                                        "copy_to": "all_field"
index a0d958a00c9a4c9319eea8ca150c3feba8f97ed5..bef66254f28576819cf0a8153f291820fc703b44 100644 (file)
                                                        "collectionobjects_common:colors",
                                                        "collectionobjects_common:computedCurrentLocation",
                                                        "collectionobjects_common:contentConcepts",
-                                                       "collectionobjects_common:materialGroupList",
                                                        "collectionobjects_common:measuredPartGroupList",
                                                        "collectionobjects_common:numberOfObjects",
                                                        "collectionobjects_common:objectHistoryNote",
                                                                }
                                                        }
                                                },
+                                               "collectionspace_denorm:materialGroupList": {
+                                                       "type": "object",
+                                                       "properties": {
+                                                               "material": {
+                                                                       "type": "keyword",
+                                                                       "copy_to": "all_field"
+                                                               }
+                                                       }
+                                               },
 
                                                "collectionobjects_common:objectNumber": {
                                                        "type": "keyword",
                                                                }
                                                        }
                                                },
-                                               "collectionobjects_common:materialGroupList": {
-                                                       "type": "object",
-                                                       "properties": {
-                                                               "material": {
-                                                                       "type": "keyword",
-                                                                       "copy_to": "all_field"
-                                                               }
-                                                       }
-                                               },
                                                "collectionobjects_common:colors": {
                                                        "type": "keyword",
                                                        "copy_to": "all_field"