<xs:element name="advancedsearch-list-item" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
- <xs:element name="uri" type="xs:anyURI"/>
- <xs:element name="csid" type="xs:string"/>
+ <xs:element name="uri" type="xs:anyURI" nillable="true"/>
+ <xs:element name="csid" type="xs:string" nillable="true"/>
<xs:element name="related" type="xs:boolean" minOccurs="0"/>
- <xs:element name="refName" type="xs:string"/>
- <xs:element name="blobCsid" type="xs:string"/>
- <xs:element name="updatedAt" type="xs:dateTime"/>
- <xs:element name="objectNumber" type="xs:string"/>
- <xs:element name="title" type="xs:string"/>
- <xs:element name="computedCurrentLocation" type="xs:string"/>
- <xs:element name="responsibleDepartment" type="xs:string"/>
- <xs:element name="briefDescription" type="xs:string"/>
+ <xs:element name="refName" type="xs:string" nillable="true"/>
+ <xs:element name="updatedAt" type="xs:dateTime" nillable="true"/>
+ <xs:element name="blobCsid" type="xs:string" nillable="true"/>
+ <xs:element name="blobAltText" type="xs:string" nillable="true"/>
+ <xs:element name="objectNumber" type="xs:string" nillable="true"/>
+ <xs:element name="title" type="xs:string" nillable="true"/>
+ <xs:element name="computedCurrentLocation" type="xs:string" nillable="true"/>
+ <xs:element name="responsibleDepartment" type="xs:string" nillable="true"/>
+ <xs:element name="briefDescription" type="xs:string" nillable="true"/>
- <xs:element name="objectName" type="xs:string"/>
- <xs:element name="objectNameControlled" type="xs:string"/>
- <xs:element name="taxon" type="xs:string"/>
- <xs:element name="form" type="xs:string"/>
- <xs:element name="agent" type="xs:string"/>
- <xs:element name="agentRole" type="xs:string"/>
- <xs:element name="fieldCollector" type="xs:string"/>
- <xs:element name="fieldCollectorRole" type="xs:string"/>
+ <xs:element name="objectName" type="xs:string" nillable="true"/>
+ <xs:element name="objectNameControlled" type="xs:string" nillable="true"/>
+ <xs:element name="taxon" type="xs:string" nillable="true"/>
+ <xs:element name="form" type="xs:string" nillable="true"/>
+ <xs:element name="agent" type="xs:string" nillable="true"/>
+ <xs:element name="agentRole" type="xs:string" nillable="true"/>
+ <xs:element name="fieldCollector" type="xs:string" nillable="true"/>
+ <xs:element name="fieldCollectorRole" type="xs:string" nillable="true"/>
- <xs:element name="fieldCollectionDate" type="xs:string"/>
- <xs:element name="fieldCollectionPlace" type="xs:string"/>
- <xs:element name="fieldCollectionSite" type="xs:string"/>
- <xs:element name="objectProductionDate" type="xs:string"/>
- <xs:element name="objectProductionPlace" type="xs:string"/>
+ <xs:element name="fieldCollectionDate" type="xs:string" nillable="true"/>
+ <xs:element name="fieldCollectionPlace" type="xs:string" nillable="true"/>
+ <xs:element name="fieldCollectionSite" type="xs:string" nillable="true"/>
+ <xs:element name="objectProductionDate" type="xs:string" nillable="true"/>
+ <xs:element name="objectProductionPlace" type="xs:string" nillable="true"/>
- <xs:element name="contentConcepts" type="contentConcepts"/>
- <xs:element name="nagpraCategories" type="nagpraCategories"/>
+ <xs:element name="contentConcepts" type="contentConcepts" nillable="true"/>
+ <xs:element name="nagpraCategories" type="nagpraCategories" nillable="true"/>
</xs:sequence>
</xs:complexType>
</xs:element>
package org.collectionspace.services.advancedsearch;
import java.util.Collections;
-import java.util.List;
+import java.util.Map;
+import java.util.function.Predicate;
import java.util.stream.Collectors;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
for (CSDocumentModelResponse response : collectionObjectList.getResponseList()) {
String csid = response.getCsid();
UriInfoWrapper wrappedUriInfo = new UriInfoWrapper(uriInfo);
- List<String> blobCsids = findBlobCsids(csid, wrappedUriInfo);
+ Map<String, String> blobInfo = findBlobInfo(csid, wrappedUriInfo);
- AdvancedsearchListItem listItem = responseMapper.asListItem(response, blobCsids);
+ AdvancedsearchListItem listItem = responseMapper.asListItem(response, blobInfo);
if (listItem != null) {
if (markRelated != null) {
RelationsCommonList relationsList = relations.getRelationForSubject(markRelated, csid, uriInfo);
* @param wrappedUriInfo The wrapped (mutable) UriInfo of the incoming query that ultimately triggered this call
* @return A possibly-empty list of strings of the blob CSIDs associated with CSID
*/
- private List<String> findBlobCsids(String csid, UriInfoWrapper wrappedUriInfo) {
+ private Map<String, String> findBlobInfo(String csid, UriInfoWrapper wrappedUriInfo) {
MultivaluedMap<String, String> wrappedQueryParams = wrappedUriInfo.getQueryParameters();
wrappedQueryParams.clear();
wrappedQueryParams.add(IQueryManager.SEARCH_RELATED_TO_CSID_AS_SUBJECT, csid);
wrappedQueryParams.add("sortBy", "media_common:title");
AbstractCommonList associatedMedia = mr.getList(wrappedUriInfo);
if (associatedMedia == null || associatedMedia.getListItem() == null) {
- return Collections.emptyList();
+ return Collections.emptyMap();
}
- return associatedMedia.getListItem().stream()
+ Predicate<Element> tagFilter = (element -> MediaJAXBSchema.blobCsid.equals(element.getTagName()) ||
+ MediaJAXBSchema.altText.equals(element.getTagName()));
+ Predicate<Element> tagNotEmpty = (element -> element.getTextContent() != null &&
+ !element.getTextContent().isEmpty());
+
+ return associatedMedia.getListItem().stream()
.filter(item -> item != null && item.getAny() != null)
.flatMap(li -> li.getAny().stream())
- .filter(element -> MediaJAXBSchema.blobCsid.equals(element.getTagName()))
- .map(Element::getTextContent)
- .filter(blobCsid -> blobCsid != null && !blobCsid.isEmpty())
- .collect(Collectors.toList());
+ .filter(tagFilter.and(tagNotEmpty))
+ .collect(Collectors.toMap(Element::getTagName, Element::getTextContent));
}
@Override
import static org.collectionspace.services.client.CollectionSpaceClient.PART_COMMON_LABEL;
import static org.collectionspace.services.client.CollectionSpaceClient.PART_LABEL_SEPARATOR;
-import java.util.List;
+import java.util.Map;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import org.collectionspace.collectionspace_core.CollectionSpaceCore;
+import org.collectionspace.services.MediaJAXBSchema;
import org.collectionspace.services.advancedsearch.AdvancedsearchCommonList.AdvancedsearchListItem;
import org.collectionspace.services.advancedsearch.ObjectFactory;
import org.collectionspace.services.advancedsearch.model.AgentModel;
* @param blobCsids The blobs associated with the object
* @return the advanced search list item
*/
- public AdvancedsearchListItem asListItem(final CSDocumentModelResponse response, final List<String> blobCsids) {
+ public AdvancedsearchListItem asListItem(final CSDocumentModelResponse response,
+ final Map<String, String> blobInfo) {
// todo: what makes sense here?
if (response == null || response.getPayload() == null) {
return objectFactory.createAdvancedsearchCommonListAdvancedsearchListItem();
item.setForm(TaxonModel.preservationForm(collectionObject));
// from media resource
- if (blobCsids.size() > 0) {
- item.setBlobCsid(blobCsids.get(0));
+ if (!blobInfo.isEmpty()) {
+ item.setBlobCsid(blobInfo.get(MediaJAXBSchema.blobCsid));
+ item.setBlobAltText(blobInfo.get(MediaJAXBSchema.altText));
}
} else {
logger.warn("advancedsearch: could not find CollectionobjectsCommon associated with csid {}", csid);
-/**
- *
- */
package org.collectionspace.services;
+/**
+ * Field names for the Media Schema
+ */
public interface MediaJAXBSchema {
- final static String contributor = "contributor";
- final static String copyrightStatement = "copyrightStatement";
- final static String coverage = "coverage";
- final static String creator = "creator";
- final static String dates = "dates";
- final static String dateCreated = "dateCreated";
- final static String dateModified = "dateModified";
- final static String description = "description";
- final static String dimensions = "dimensions";
- final static String filename = "filename";
- final static String format = "format";
- final static String identificationNumber = "identificationNumber";
- final static String languages = "languages";
- final static String location = "location";
- final static String publisher = "publisher";
- final static String relation = "relation";
- final static String rightsHolder = "rightsHolder";
- final static String source = "source";
- final static String subjects = "subjects";
- final static String title = "title";
- final static String type = "type";
- final static String uri = "uri";
- final static String blobCsid = "blobCsid";
+ String altText = "altText";
+ String contributor = "contributor";
+ String copyrightStatement = "copyrightStatement";
+ String coverage = "coverage";
+ String creator = "creator";
+ String dates = "dates";
+ String dateCreated = "dateCreated";
+ String dateModified = "dateModified";
+ String description = "description";
+ String dimensions = "dimensions";
+ String filename = "filename";
+ String format = "format";
+ String identificationNumber = "identificationNumber";
+ String languages = "languages";
+ String location = "location";
+ String publisher = "publisher";
+ String relation = "relation";
+ String rightsHolder = "rightsHolder";
+ String source = "source";
+ String subjects = "subjects";
+ String title = "title";
+ String type = "type";
+ String uri = "uri";
+ String blobCsid = "blobCsid";
}