]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
DRYD-1818: Implement image ordering functionality for public browser (#479)
authorSpiros Dimopulos <spiros@wantedpixel.com>
Mon, 13 Oct 2025 06:58:17 +0000 (09:58 +0300)
committerGitHub <noreply@github.com>
Mon, 13 Oct 2025 06:58:17 +0000 (09:58 +0300)
* DRYD-1818: added denormRelatedObjects in DefaultESDocumentWriter to add objectCsid field holding media related objects.

* DRYD-1818: mapped identificationNumber, title as sortable keywords; mapped updatedAt as sortable date field; mapped objectCsid as filterable keyword;

* DRYD-1818: mapped media_common:altText;

* DRYD-1818: fixed trailing comma; updated tenant bindings;

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/bonsai/bonsai-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/lhmc/lhmc-tenant-bindings.delta.xml
services/common/src/main/cspace/config/services/tenants/materials/materials-tenant-bindings.delta.xml
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto-unified.xml

index 43d242e2c157069d3190aef53d74bd7e4ac5a39f..039b2ec96188e7b5a909c4b7dce65e6a969aba3d 100644 (file)
@@ -78,6 +78,13 @@ public class DefaultESDocumentWriter extends JsonESDocumentWriter {
                        List<Map<String, Object>> prodDateGroupList = (List<Map<String, Object>>) doc.getProperty("collectionobjects_common", "objectProductionDateGroupList");
 
                        denormValues.putArray("prodYears").addAll(structDatesToYearNodes(prodDateGroupList));
+               } else if ("Media".equals(docType) && isMediaPublished(doc)) {
+                       CoreSession session = doc.getCoreSession();
+                       String csid = doc.getName();
+                       String tenantId = (String) doc.getProperty("collectionspace_core", "tenantId");
+
+                       // Add media-specific denormalized fields
+                       denormRelatedObjects(session, csid, tenantId, denormValues);
                }
 
                return denormValues;
@@ -135,6 +142,31 @@ public class DefaultESDocumentWriter extends JsonESDocumentWriter {
                denormValues.put("hasMedia", mediaCsids.size() > 0);
        }
 
+       private void denormRelatedObjects(CoreSession session, String csid, String tenantId, ObjectNode denormValues) {
+               // Store the objectCsid of objects that are related to this media.
+
+               String relatedRecordQuery = String.format(
+                               "SELECT * FROM Relation WHERE relations_common:objectCsid = '%s' AND relations_common:subjectDocumentType = 'CollectionObject' AND ecm:currentLifeCycleState = 'project' AND collectionspace_core:tenantId = '%s'",
+                               csid, tenantId);
+               DocumentModelList relationDocs = session.query(relatedRecordQuery);
+               List<JsonNode> objectCsids = new ArrayList<JsonNode>();
+
+               if (relationDocs.size() > 0) {
+                       Iterator<DocumentModel> iterator = relationDocs.iterator();
+
+                       while (iterator.hasNext()) {
+                               DocumentModel relationDoc = iterator.next();
+                               String objectCsid = (String) relationDoc.getProperty("relations_common", "subjectCsid");
+
+                               if (objectCsid != null) {
+                                       objectCsids.add(new TextNode(objectCsid));
+                               }
+                       }
+               }
+
+               denormValues.putArray("objectCsid").addAll(objectCsids);
+       }
+
        private void denormAcquisitionRecords(CoreSession session, String csid, String tenantId, ObjectNode denormValues) {
                // Store the credit lines of acquisition records that are related to this object.
 
index 133938613aa5b97795ff2f02d4cdca3075b33600..ea4c9abfe18dd76293140443949d66d11b5e1651 100644 (file)
                                                        "ecm:currentLifeCycleState",
                                                        "ecm:name",
                                                        "ecm:primaryType",
-                                                       "media_common:blobCsid"
+                                                       "media_common:blobCsid",
+                                                       "media_common:identificationNumber",
+                                                       "media_common:title",
+                                                       "media_common:altText"
                                                ]
                                        },
                                        "properties" : {
                                                        "type": "date",
                                                        "format": "date_time"
                                                },
+                                               "collectionspace_core:updatedAt": {
+                                                       "type": "date",
+                                                       "format": "date_time"
+                                               },
                                                "collectionobjects_common:publishToList": {
                                                        "type": "keyword",
                                                        "fields": {
                                                                }
                                                        }
                                                },
+                                               "collectionspace_denorm:objectCsid": {
+                                                       "type": "keyword"
+                                               },
 
                                                "collectionobjects_common:objectNumber": {
                                                        "type": "keyword",
                                                "media_common:blobCsid": {
                                                        "type": "keyword"
                                                },
+                                               "media_common:identificationNumber": {
+                                                       "type": "keyword",
+                                                       "normalizer": "sorting_normalizer"
+                                               },
+                                               "media_common:altText": {
+                                                       "type": "text"
+                                               },
+                                               "media_common:title": {
+                                                       "type": "keyword",
+                                                       "normalizer": "sorting_normalizer"
+                                               },
                                                "media_common:publishToList": {
                                                        "type": "keyword",
                                                        "fields": {
index 47d06a847258d81a6c07fabb24956752f209c786..127c7ae7c2bddd94b290766403e67635e680d57a 100644 (file)
                                                        "ecm:currentLifeCycleState",
                                                        "ecm:name",
                                                        "ecm:primaryType",
-                                                       "media_common:blobCsid"
+                                                       "media_common:blobCsid",
+                                                       "media_common:identificationNumber",
+                                                       "media_common:title",
+                                                       "media_common:altText"
                                                ]
                                        },
                                        "properties" : {
                                                        "type": "date",
                                                        "format": "date_time"
                                                },
+                                               "collectionspace_core:updatedAt": {
+                                                       "type": "date",
+                                                       "format": "date_time"
+                                               },
                                                "collectionobjects_common:publishToList": {
                                                        "type": "keyword",
                                                        "fields": {
                                                                }
                                                        }
                                                },
+                                               "collectionspace_denorm:objectCsid": {
+                                                       "type": "keyword"
+                                               },
 
                                                "collectionobjects_common:objectNumber": {
                                                        "type": "keyword",
                                                "media_common:blobCsid": {
                                                        "type": "keyword"
                                                },
+                                               "media_common:identificationNumber": {
+                                                       "type": "keyword",
+                                                       "normalizer": "sorting_normalizer"
+                                               },
+                                               "media_common:altText": {
+                                                       "type": "text"
+                                               },
+                                               "media_common:title": {
+                                                       "type": "keyword",
+                                                       "normalizer": "sorting_normalizer"
+                                               },
                                                "media_common:publishToList": {
                                                        "type": "keyword",
                                                        "fields": {
index f7a728c9360409ad460e48e0dbbe275782891b99..65e77ea661f62e14591d14e9d819c9a844ea8c9a 100644 (file)
                                                        "ecm:currentLifeCycleState",
                                                        "ecm:name",
                                                        "ecm:primaryType",
-                                                       "media_common:blobCsid"
+                                                       "media_common:blobCsid",
+                                                       "media_common:identificationNumber",
+                                                       "media_common:title",
+                                                       "media_common:altText"
                                                ]
                                        },
                                        "properties" : {
                                                        "type": "date",
                                                        "format": "date_time"
                                                },
+                                               "collectionspace_core:updatedAt": {
+                                                       "type": "date",
+                                                       "format": "date_time"
+                                               },
                                                "collectionobjects_common:publishToList": {
                                                        "type": "keyword",
                                                        "fields": {
                                                                }
                                                        }
                                                },
-
+                                               "collectionspace_denorm:objectCsid": {
+                                                       "type": "keyword"
+                                               },
                                                "collectionobjects_common:objectNumber": {
                                                        "type": "keyword",
                                                        "copy_to": "all_field"
                                                "media_common:blobCsid": {
                                                        "type": "keyword"
                                                },
+                                               "media_common:identificationNumber": {
+                                                       "type": "keyword",
+                                                       "normalizer": "sorting_normalizer"
+                                               },
+                                               "media_common:altText": {
+                                                       "type": "text"
+                                               },
+                                               "media_common:title": {
+                                                       "type": "keyword",
+                                                       "normalizer": "sorting_normalizer"
+                                               },
                                                "media_common:publishToList": {
                                                        "type": "keyword",
                                                        "fields": {
index ccd9cdffa7cfe37797619dede8c299f835ebcb56..e907d2d101f601522ef61a47e66a78a2723a32af 100644 (file)
                                                        "ecm:currentLifeCycleState",
                                                        "ecm:name",
                                                        "ecm:primaryType",
-                                                       "media_common:blobCsid"
+                                                       "media_common:blobCsid",
+                                                       "media_common:identificationNumber",
+                                                       "media_common:title",
+                                                       "media_common:altText"
                                                ]
                                        },
                                        "properties" : {
                                                        "type": "date",
                                                        "format": "date_time"
                                                },
+                                               "collectionspace_core:updatedAt": {
+                                                       "type": "date",
+                                                       "format": "date_time"
+                                               },
                                                "collectionobjects_common:publishToList": {
                                                        "type": "keyword",
                                                        "fields": {
                                                                }
                                                        }
                                                },
-
+                                               "collectionspace_denorm:objectCsid": {
+                                                       "type": "keyword"
+                                               },
                                                "collectionobjects_common:objectNumber": {
                                                        "type": "keyword",
                                                        "copy_to": "all_field"
                                                "media_common:blobCsid": {
                                                        "type": "keyword"
                                                },
+                                               "media_common:identificationNumber": {
+                                                       "type": "keyword",
+                                                       "normalizer": "sorting_normalizer"
+                                               },
+                                               "media_common:altText": {
+                                                       "type": "text"
+                                               },
+                                               "media_common:title": {
+                                                       "type": "keyword",
+                                                       "normalizer": "sorting_normalizer"
+                                               },
                                                "media_common:publishToList": {
                                                        "type": "keyword",
                                                        "fields": {
index 27679ab6b19354706d5f4c4a2609ce8b2407dceb..3057e9c2f4c8ac228c3eafd4870fae6002fbd907 100644 (file)
                     "collectionobjects_common:rightsGroupList.standardizedRightStatement",
                     "collectionobjects_common:rightsInGroupList.rightReproductionStatement",
                     "media_common:blobCsid",
+                    "media_common:identificationNumber",
+                    "media_common:title",
+                    "media_common:altText",
                     "media_materials:publishToList"
                   ]
                 },
                       }
                     }
                   },
+                  "collectionspace_denorm:objectCsid": {
+                    "type": "keyword"
+                  },
 
                   "collectionspace_core:createdAt": {
                     "type": "date",
                     // From imported data??
                     "format" : "date_time||yyyy-MM-dd'T'HH:mm:ss.SSZZ"
                   },
+                  "collectionspace_core:updatedAt": {
+                    "type": "date",
+                    // Sometimes the timestamp only has a two digit fractional second, instead of three.
+                    // From imported data??
+                    "format" : "date_time||yyyy-MM-dd'T'HH:mm:ss.SSZZ"
+                  },
 
                   "materials_common:shortIdentifier": {
                     "type": "keyword",
                     "type": "text",
                     "copy_to": "all_field"
                   },
-
+                  "media_common:identificationNumber": {
+                    "type": "keyword",
+                    "normalizer": "sorting_normalizer"
+                  },
+                  "media_common:altText": {
+                    "type": "text"
+                  },
+                  "media_common:title": {
+                    "type": "keyword",
+                    "normalizer": "sorting_normalizer"
+                  },
                   "media_materials:publishToList": {
                     "type": "keyword",
                     "fields": {
index 637f0faa0c7696220912be01d39756f0efb92361..7622f7829dadf74663a00a9678da570db6fffa19 100644 (file)
                                                        "ecm:currentLifeCycleState",
                                                        "ecm:name",
                                                        "ecm:primaryType",
-                                                       "media_common:blobCsid"
+                                                       "media_common:blobCsid",
+                                                       "media_common:identificationNumber",
+                                                       "media_common:title",
+                                                       "media_common:altText"
                                                ]
                                        },
                                        "properties" : {
                                                        "type": "date",
                                                        "format": "date_time"
                                                },
+                                               "collectionspace_core:updatedAt": {
+                                                       "type": "date",
+                                                       "format": "date_time"
+                                               },
                                                "collectionobjects_common:publishToList": {
                                                        "type": "keyword",
                                                        "fields": {
                                                                }
                                                        }
                                                },
-
+                                               "collectionspace_denorm:objectCsid": {
+                                                       "type": "keyword"
+                                               },
                                                "collectionobjects_common:objectNumber": {
                                                        "type": "keyword",
                                                        "copy_to": "all_field"
                                                "media_common:blobCsid": {
                                                        "type": "keyword"
                                                },
+                                               "media_common:identificationNumber": {
+                                                       "type": "keyword",
+                                                       "normalizer": "sorting_normalizer"
+                                               },
+                                               "media_common:altText": {
+                                                       "type": "text"
+                                               },
+                                               "media_common:title": {
+                                                       "type": "keyword",
+                                                       "normalizer": "sorting_normalizer"
+                                               },
                                                "media_common:publishToList": {
                                                        "type": "keyword",
                                                        "fields": {