Search in sources :

Example 11 with EntryType

use of org.jbei.ice.lib.dto.entry.EntryType in project ice by JBEI.

the class SearchResource method search.

/**
     * Keyword search
     *
     * @param queryString keywords to search on
     * @param searchWeb   whether to perform a web of registry search or not
     * @param offset      result start
     * @param limit       result count upper limit
     * @param sort        result sort
     * @param asc         true if return results in ascending order, false otherwise
     * @return wrapper around list of search results conforming to query params
     */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response search(@QueryParam("q") final String queryString, @DefaultValue("false") @QueryParam("webSearch") final boolean searchWeb, @DefaultValue("0") @QueryParam("offset") final int offset, @DefaultValue("15") @QueryParam("limit") final int limit, @DefaultValue("relevance") @QueryParam("sort") final String sort, @DefaultValue("false") @QueryParam("asc") final boolean asc) {
    final String userId = getUserId();
    if (StringUtils.isEmpty(userId) && !searchWeb) {
        return super.respond(Response.Status.FORBIDDEN);
    }
    log(userId, "query \'" + queryString + '\'');
    final SearchQuery query = new SearchQuery();
    query.setQueryString(queryString);
    final SearchQuery.Parameters parameters = query.getParameters();
    parameters.setRetrieveCount(limit);
    parameters.setStart(offset);
    parameters.setSortAscending(asc);
    parameters.setSortField(ColumnField.valueOf(sort.toUpperCase()));
    final List<EntryType> types = Arrays.asList(EntryType.values());
    query.setEntryTypes(types);
    return super.respond(controller.runSearch(userId, query));
}
Also used : SearchQuery(org.jbei.ice.lib.dto.search.SearchQuery) EntryType(org.jbei.ice.lib.dto.entry.EntryType)

Aggregations

EntryType (org.jbei.ice.lib.dto.entry.EntryType)11 Entry (org.jbei.ice.storage.model.Entry)3 HashSet (java.util.HashSet)2 EntryField (org.jbei.ice.lib.dto.entry.EntryField)2 PartData (org.jbei.ice.lib.dto.entry.PartData)2 SequenceInfo (org.jbei.ice.lib.dto.entry.SequenceInfo)2 SearchQuery (org.jbei.ice.lib.dto.search.SearchQuery)2 PartSequence (org.jbei.ice.lib.entry.sequence.PartSequence)2 ByteStreams (com.google.common.io.ByteStreams)1 java.io (java.io)1 File (java.io.File)1 IOException (java.io.IOException)1 URI (java.net.URI)1 Paths (java.nio.file.Paths)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 javax.ws.rs (javax.ws.rs)1 MediaType (javax.ws.rs.core.MediaType)1 Response (javax.ws.rs.core.Response)1