<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
- jaxb:version="2.0" elementFormDefault="unqualified"
+ jaxb:version="2.0"
xmlns="http://collectionspace.org/services/advancedsearch"
targetNamespace="http://collectionspace.org/services/advancedsearch"
version="0.1"
>
- <xs:complexType name="abstractCommonList">
- <xs:annotation>
- <xs:appinfo>
- <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
- </xs:appinfo>
- </xs:annotation>
- </xs:complexType>
-
- <xs:complexType name="responsibleDepartment">
- <xs:sequence>
- <xs:element name="uri" type="xs:anyURI" minOccurs="1"/>
- <xs:element name="csid" type="xs:string" minOccurs="1"/>
- <xs:element name="refName" type="xs:string" minOccurs="1"/>
- <xs:element name="name" type="xs:string" minOccurs="1"/>
- </xs:sequence>
- </xs:complexType>
- <xs:complexType name="responsibleDepartmentsList">
- <xs:sequence>
- <xs:element name="responsibleDepartment" type="responsibleDepartment" minOccurs="0" maxOccurs="unbounded" />
- </xs:sequence>
- </xs:complexType>
-
- <xs:element name="advancedsearch-common-list">
- <xs:complexType>
- <xs:complexContent>
- <xs:extension base="abstractCommonList">
- <xs:sequence>
- <xs:element name="advancedsearch-list-item" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="uri" type="xs:anyURI" minOccurs="1" />
- <xs:element name="csid" type="xs:string" minOccurs="1" />
- <xs:element name="refName" type="xs:string" minOccurs="1" />
- <xs:element name="blobCsid" type="xs:string" minOccurs="1" />
- <xs:element name="updatedAt" type="xs:dateTime" minOccurs="1" />
- <xs:element name="objectId" type="xs:string" minOccurs="1" />
- <xs:element name="objectNumber" type="xs:string" minOccurs="1" />
- <xs:element name="objectName" type="xs:string" minOccurs="1" />
- <xs:element name="title" type="xs:string" minOccurs="1" />
- <xs:element name="computedCurrentLocation" type="xs:string" minOccurs="1" />
- <xs:element name="responsibleDepartments" type="responsibleDepartmentsList" minOccurs="1" />
- <xs:element name="responsibleDepartment" type="xs:string" minOccurs="1" />
- <xs:element name="contentConcepts" type="xs:string" minOccurs="1" />
- <xs:element name="briefDescription" type="xs:string" minOccurs="1" />
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:extension>
- </xs:complexContent>
- </xs:complexType>
- </xs:element>
+ <xs:complexType name="abstractCommonList">
+ <xs:annotation>
+ <xs:appinfo>
+ <jaxb:class ref="org.collectionspace.services.jaxb.AbstractCommonList"/>
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:complexType>
+
+ <xs:complexType name="responsibleDepartment">
+ <xs:sequence>
+ <xs:element name="uri" type="xs:anyURI"/>
+ <xs:element name="csid" type="xs:string"/>
+ <xs:element name="refName" type="xs:string"/>
+ <xs:element name="name" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name="responsibleDepartmentsList">
+ <xs:sequence>
+ <xs:element name="responsibleDepartment" type="responsibleDepartment" minOccurs="0" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:element name="advancedsearch-common-list">
+ <xs:complexType>
+ <xs:complexContent>
+ <xs:extension base="abstractCommonList">
+ <xs:sequence>
+ <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="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="objectId" type="xs:string"/>
+ <xs:element name="objectNumber" type="xs:string"/>
+ <xs:element name="objectName" type="xs:string"/>
+ <xs:element name="title" type="xs:string"/>
+ <xs:element name="computedCurrentLocation" type="xs:string"/>
+ <xs:element name="responsibleDepartments" type="responsibleDepartmentsList"/>
+ <xs:element name="responsibleDepartment" type="xs:string"/>
+ <xs:element name="contentConcepts" type="xs:string"/>
+ <xs:element name="briefDescription" type="xs:string"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ </xs:extension>
+ </xs:complexContent>
+ </xs:complexType>
+ </xs:element>
</xs:schema>
\ No newline at end of file
import java.util.ArrayList;
import java.util.Collections;
-import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
import org.collectionspace.services.common.UriInfoWrapper;
import org.collectionspace.services.common.context.RemoteServiceContextFactory;
import org.collectionspace.services.common.context.ServiceContextFactory;
+import org.collectionspace.services.common.relation.RelationResource;
import org.collectionspace.services.jaxb.AbstractCommonList;
-import org.collectionspace.services.jaxb.AbstractCommonList.ListItem;
-import org.collectionspace.services.jaxb.BlobJAXBSchema;
import org.collectionspace.services.media.MediaResource;
import org.collectionspace.services.nuxeo.client.handler.CSDocumentModelList;
import org.collectionspace.services.nuxeo.client.handler.CSDocumentModelList.CSDocumentModelResponse;
import org.collectionspace.services.nuxeo.client.handler.UnfilteredDocumentModelHandler;
+import org.collectionspace.services.relation.RelationsCommonList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
/**
* This class defines the advanced search endpoints.
private final Logger logger = LoggerFactory.getLogger(AdvancedSearch.class);
private final CollectionObjectResource cor = new CollectionObjectResource();
private final MediaResource mr = new MediaResource();
+ private final RelationResource relations = new RelationResource();
public AdvancedSearch() {
super();
logger.info("advancedsearch called with path: {}", uriInfo.getPath());
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters(true);
logger.info("advancedsearch called with query params: {}", queryParams);
+ final String markRelated = queryParams.getFirst(IQueryManager.MARK_RELATED_TO_CSID_AS_SUBJECT);
cor.setDocumentHandlerClass(UnfilteredDocumentModelHandler.class);
ObjectFactory objectFactory = new ObjectFactory();
logger.warn("advancedsearch: could not find CollectionobjectsCommon associated with csid {}", csid);
}
+ if (markRelated != null) {
+ RelationsCommonList relationsList = relations.getRelationForSubject(markRelated, csid, uriInfo);
+ listItem.setRelated(!relationsList.getRelationListItem().isEmpty());
+ }
}
// NOTE: I think this is necessary for the front end to know what to do with
return resultList;
}
+ public RelationsCommonList getRelationForSubject(String subject, String object, UriInfo uriInfo) {
+ return getRelationList(null, uriInfo, subject, null, null, object, null, false);
+ }
private RelationsCommonList getRelationList(
ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx,
//
// Handle keyword clause
//
- String keywords = uriInfo.getQueryParameters().getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);
+ String keywords = uriInfo.getQueryParameters().getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW);
if (keywords != null && keywords.isEmpty() == false) {
String keywordClause = QueryManager.createWhereClauseFromKeywords(keywords);
handler.getDocumentFilter().appendWhereClause(keywordClause, IQueryManager.SEARCH_QUALIFIER_AND);