001/** 002 * Copyright 2014 Tampere University of Technology, Pori Department 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package service.tut.pori.contentsuggest; 017 018import service.tut.pori.contentanalysis.MediaObject.MediaObjectType; 019import core.tut.pori.http.Response; 020import core.tut.pori.http.annotations.HTTPAuthenticationParameter; 021import core.tut.pori.http.annotations.HTTPMethodParameter; 022import core.tut.pori.http.annotations.HTTPService; 023import core.tut.pori.http.annotations.HTTPServiceMethod; 024import core.tut.pori.http.parameters.AuthenticationParameter; 025import core.tut.pori.http.parameters.DataGroups; 026import core.tut.pori.http.parameters.Limits; 027import core.tut.pori.http.parameters.StringParameter; 028 029/** 030 * Service for content suggestions 031 * 032 * @see service.tut.pori.contentsuggest.reference.ClientService 033 */ 034@HTTPService(name=Definitions.SERVICE_CS) 035public class ContentSuggestService { 036 037 /** 038 * Autocomplete service method to get suggestions based on the indexed data. 039 * 040 * @see service.tut.pori.contentsuggest.reference.ClientService#suggest(AuthenticationParameter, DataGroups, StringParameter, Limits) 041 * 042 * @param authenticatedUser 043 * @param dataGroups filters based on VisualObjectType. 044 * @param query the term to be searched for. 045 * @param limits paging options 046 * @return response 047 * 048 * @see MediaObjectType 049 */ 050 @HTTPServiceMethod(name = Definitions.METHOD_SUGGEST, acceptedMethods={core.tut.pori.http.Definitions.METHOD_GET}) 051 public Response suggest( 052 @HTTPAuthenticationParameter AuthenticationParameter authenticatedUser, 053 @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required = false) DataGroups dataGroups, 054 @HTTPMethodParameter(name = Definitions.PARAMETER_QUERY, required = true) StringParameter query, 055 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required = false, defaultValue=Definitions.DEFAULT_LIMITS) Limits limits) 056 { 057 return new Response(ContentSuggestCore.suggest(authenticatedUser.getUserIdentity(), dataGroups, limits, query.getValue())); 058 } 059}