Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public ObjectNode getDenormValues(DocumentModel doc) {
denormConceptFields(doc, denormValues);
denormMaterialFields(doc, denormValues);
denormObjectNameFields(doc, denormValues);
denormPriorityImageList(doc, session, tenantId, 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.
Expand Down Expand Up @@ -209,6 +210,56 @@ private void denormExhibitionRecords(CoreSession session, String csid, String te
denormValues.putArray("exhibition").addAll(exhibitions);
}

/**
* Denormalize the csid, blob csid, title, and alt text of each media record referenced by
* the priorityImageList field of a collectionobject, so that the priority/sort
* order set by the user can be displayed and searched.
*
* @param doc the collectionobject document
* @param session the current session
* @param tenantId the tenant id
* @param denormValues the json node for denormalized fields
*/
private void denormPriorityImageList(DocumentModel doc, CoreSession session, String tenantId, ObjectNode denormValues) {
List<String> priorityImageList = (List<String>) doc.getProperty("collectionobjects_common", "priorityImageList");
List<JsonNode> priorityImages = new ArrayList<>();

if (priorityImageList != null) {
for (String priorityImage : priorityImageList) {
if (StringUtils.isNotEmpty(priorityImage)) {
String mediaCsid = null;

try {
mediaCsid = RefNameUtils.parseAuthorityInfo(priorityImage).csid;
} catch (IllegalArgumentException e) {
// Not a parseable refName; nothing to denormalize for this entry.
}

if (mediaCsid != null) {
DocumentModel mediaDoc = getRecordByCsid(session, tenantId, "Media", mediaCsid);

if (mediaDoc != null && isMediaPublished(mediaDoc)) {
String blobCsid = (String) mediaDoc.getProperty("media_common", "blobCsid");
String title = (String) mediaDoc.getProperty("media_common", "title");
String altText = (String) mediaDoc.getProperty("media_common", "altText");

ObjectNode priorityImageNode = objectMapper.createObjectNode();

priorityImageNode.put("csid", mediaCsid);
priorityImageNode.put("blobCsid", blobCsid);
priorityImageNode.put("title", title);
priorityImageNode.put("altText", altText);

priorityImages.add(priorityImageNode);
}
}
}
}
}

denormValues.putArray("priorityImageList").addAll(priorityImages);
}

/**
* Denormalize the material group list for a collectionobject in order to index the controlled or uncontrolled term
*
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## 9.0.0
* Add home location to collectionobject schema and advanced search
* Denormalize priority image list

## 8.3.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,7 @@
"collectionobjects_common:objectStatusList",
"collectionobjects_common:otherNumberList",
"collectionobjects_common:ownersContributionNote",
"collectionobjects_common:priorityImageList",
"collectionobjects_common:publishedRelatedLinkGroupList",
"collectionobjects_common:publishToList",
"collectionobjects_common:responsibleDepartments",
Expand Down Expand Up @@ -1417,6 +1418,35 @@
"type": "keyword",
"copy_to": "all_field"
},
"collectionobjects_common:priorityImageList": {
"type": "keyword",
"copy_to": "all_field",
"fields": {
"displayName": {
"type": "keyword",
"normalizer": "refname_displayname_normalizer"
}
}
},
"collectionspace_denorm:priorityImageList": {
"type": "object",
"properties": {
"csid": {
"type": "keyword"
},
"blobCsid": {
"type": "keyword"
},
"title": {
"type": "text",
"copy_to": "all_field"
},
"altText": {
"type": "text",
"copy_to": "all_field"
}
}
},
"collectionobjects_common:contentConcepts": {
"type": "keyword",
"copy_to": "all_field",
Expand Down