package org.collectionspace.services.common.document;\r
\r
import java.util.List;\r
-\r
import javax.ws.rs.core.MultivaluedMap;\r
+import org.collectionspace.services.common.query.IQueryManager;\r
\r
/**\r
* DocumentFilter bundles simple query filtering parameters. \r
this.whereClause = whereClause;\r
}\r
\r
+ public void appendWhereClause(String whereClause) {\r
+ String currentClause = getWhereClause();\r
+ if (currentClause != null) {\r
+ String newClause = currentClause.concat(IQueryManager.SEARCH_TERM_SEPARATOR + whereClause);\r
+ this.setWhereClause(newClause);\r
+ }\r
+ }\r
+ \r
/**\r
* @return the specified (0-based) page offset \r
*/\r
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
+import org.collectionspace.services.VocabularyItemJAXBSchema;
import org.collectionspace.services.common.AbstractCollectionSpaceResource;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentHandler;
import org.collectionspace.services.common.document.DocumentNotFoundException;
+import org.collectionspace.services.common.query.IQueryManager;
import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.common.query.IQueryManager;
import org.collectionspace.services.vocabulary.nuxeo.VocabularyHandlerFactory;
import org.collectionspace.services.vocabulary.nuxeo.VocabularyItemDocumentModelHandler;
import org.collectionspace.services.vocabulary.nuxeo.VocabularyItemHandlerFactory;
@Produces("application/xml")
public VocabularyitemsCommonList getVocabularyItemList(
@PathParam("csid") String parentcsid,
+ @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
@Context UriInfo ui) {
VocabularyitemsCommonList vocabularyItemObjectList = new VocabularyitemsCommonList();
try {
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
DocumentFilter myFilter =
DocumentFilter.CreatePaginatedDocumentFilter(queryParams);
+ // "vocabularyitems_common:inVocabulary='" + parentcsid + "'");
myFilter.setWhereClause(
- "vocabularyitems_common:inVocabulary='" + parentcsid + "'");
+ VocabularyItemJAXBSchema.VOCABULARYITEMS_COMMON + ":" +
+ VocabularyItemJAXBSchema.IN_VOCABULARY + "=" +
+ "'" + parentcsid + "'");
+
+ // AND vocabularyitems_common:displayName LIKE '%partialTerm%'
+ if (partialTerm != null && !partialTerm.isEmpty()) {
+ String ptClause = "AND " +
+ VocabularyItemJAXBSchema.VOCABULARYITEMS_COMMON + ":" +
+ VocabularyItemJAXBSchema.DISPLAY_NAME +
+ " LIKE " +
+ "'%" + partialTerm + "%'";
+ myFilter.appendWhereClause(ptClause);
+ }
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("getVocabularyItemList filtered WHERE clause: " +
+ myFilter.getWhereClause());
+ }
+
handler.setDocumentFilter(myFilter);
getRepositoryClient(ctx).getFiltered(ctx, handler);
+
vocabularyItemObjectList = (VocabularyitemsCommonList) handler.getCommonPartList();
} catch (UnauthorizedException ue) {
Response response = Response.status(