001/** 002 * Copyright 2015 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.contentanalysis.reference; 017 018import service.tut.pori.contentanalysis.AsyncTask.TaskType; 019import service.tut.pori.contentanalysis.Definitions; 020import service.tut.pori.contentanalysis.DeletedPhotoList; 021import service.tut.pori.contentanalysis.DissimilarPhotoList; 022import service.tut.pori.contentanalysis.PhotoList; 023import service.tut.pori.contentanalysis.ReferencePhotoList; 024import service.tut.pori.contentanalysis.SimilarPhotoList; 025import core.tut.pori.http.Response; 026import core.tut.pori.http.annotations.HTTPMethodParameter; 027import core.tut.pori.http.annotations.HTTPService; 028import core.tut.pori.http.annotations.HTTPServiceMethod; 029import core.tut.pori.http.parameters.DataGroups; 030import core.tut.pori.http.parameters.Limits; 031import core.tut.pori.http.parameters.StringParameter; 032 033/** 034 * Generates example XML output 035 * 036 */ 037@HTTPService(name = service.tut.pori.contentanalysis.reference.Definitions.SERVICE_CA_REFERENCE_EXAMPLE) 038public class ExampleService { 039 /** 040 * Generates example feedback list 041 * 042 * @param limits paging limits 043 * @return FeedbackList 044 * @see service.tut.pori.contentanalysis.PhotoFeedbackList 045 */ 046 @HTTPServiceMethod(name = Definitions.ELEMENT_FEEDBACKLIST) 047 public Response feedbackList( 048 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 049 ) 050 { 051 Example example = new Example(); 052 example.setFeedbackList(CAReferenceCore.generateFeedbackList(limits)); 053 return new Response(example); 054 } 055 056 /** 057 * Generates example photo 058 * @param dataGroups For supported data groups, see {@link service.tut.pori.contentanalysis.reference.ClientService#retrieveMediaObjects(core.tut.pori.http.parameters.AuthenticationParameter, DataGroups, Limits, core.tut.pori.http.parameters.IntegerParameter, core.tut.pori.http.parameters.StringParameter)}. 059 * @return Photo 060 * @see service.tut.pori.contentanalysis.Photo 061 */ 062 @HTTPServiceMethod(name = Definitions.ELEMENT_PHOTO) 063 public Response photo( 064 @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required=false) DataGroups dataGroups) 065 { 066 Example example = new Example(); 067 example.setPhoto(CAReferenceCore.generatePhoto(dataGroups)); 068 return new Response(example); 069 } 070 071 /** 072 * Generates example photo list 073 * @param dataGroups For supported data groups, see {@link service.tut.pori.contentanalysis.reference.ClientService#retrieveMediaObjects(core.tut.pori.http.parameters.AuthenticationParameter, DataGroups, Limits, core.tut.pori.http.parameters.IntegerParameter, core.tut.pori.http.parameters.StringParameter)}. 074 * @param limits paging limits 075 * @return PhotoList 076 * @see service.tut.pori.contentanalysis.PhotoList 077 */ 078 @HTTPServiceMethod(name = Definitions.ELEMENT_PHOTOLIST) 079 public Response photoList( 080 @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required=false) DataGroups dataGroups, 081 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 082 ) 083 { 084 Example example = new Example(); 085 example.setPhotoList(CAReferenceCore.generatePhotoList(dataGroups, limits, PhotoList.class)); 086 return new Response(example); 087 } 088 089 /** 090 * Generates example deleted photo list 091 * 092 * @param limits paging limits 093 * @return DeletedPhotoList 094 * @see service.tut.pori.contentanalysis.DeletedPhotoList 095 */ 096 @HTTPServiceMethod(name = Definitions.ELEMENT_DELETED_PHOTOLIST) 097 public Response deletedPhotoList( 098 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 099 ) 100 { 101 Example example = new Example(); 102 example.setPhotoList(CAReferenceCore.generatePhotoList(null, limits, DeletedPhotoList.class)); 103 return new Response(example); 104 } 105 106 /** 107 * Generates example dissimilar photo list 108 * 109 * @param limits paging limits 110 * @return DissimilarPhotoList 111 * @see service.tut.pori.contentanalysis.DissimilarPhotoList 112 */ 113 @HTTPServiceMethod(name = Definitions.ELEMENT_DISSIMILAR_PHOTOLIST) 114 public Response dissimilarPhotoList( 115 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 116 ) 117 { 118 Example example = new Example(); 119 example.setPhotoList(CAReferenceCore.generatePhotoList(null, limits, DissimilarPhotoList.class)); 120 return new Response(example); 121 } 122 123 /** 124 * Generates example similar photo list 125 * 126 * @param limits paging limits 127 * @return SimilarPhotoList 128 * @see service.tut.pori.contentanalysis.SimilarPhotoList 129 */ 130 @HTTPServiceMethod(name = Definitions.ELEMENT_SIMILAR_PHOTOLIST) 131 public Response similarPhotoList( 132 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 133 ) 134 { 135 Example example = new Example(); 136 example.setPhotoList(CAReferenceCore.generatePhotoList(null, limits, SimilarPhotoList.class)); 137 return new Response(example); 138 } 139 140 /** 141 * Generates example reference photo list 142 * 143 * @param limits paging limits 144 * @return ReferencePhotoList 145 * @see service.tut.pori.contentanalysis.ReferencePhotoList 146 */ 147 @HTTPServiceMethod(name = Definitions.ELEMENT_REFERENCE_PHOTOLIST) 148 public Response referencePhotoList( 149 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 150 ) 151 { 152 Example example = new Example(); 153 example.setPhotoList(CAReferenceCore.generatePhotoList(null, limits, ReferencePhotoList.class)); 154 return new Response(example); 155 } 156 157 /** 158 * Generates example media object list 159 * @param dataGroups For supported data groups, see {@link service.tut.pori.contentanalysis.reference.ClientService#retrieveMediaObjects(core.tut.pori.http.parameters.AuthenticationParameter, DataGroups, Limits, core.tut.pori.http.parameters.IntegerParameter, core.tut.pori.http.parameters.StringParameter)}. 160 * @param limits paging limits 161 * @return MediaObjectList 162 * @see service.tut.pori.contentanalysis.MediaObjectList 163 */ 164 @HTTPServiceMethod(name = Definitions.ELEMENT_MEDIA_OBJECTLIST) 165 public Response mediaObjectList( 166 @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required=false) DataGroups dataGroups, 167 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 168 ) 169 { 170 Example example = new Example(); 171 example.setMediaObjectList(CAReferenceCore.generateMediaObjectList(dataGroups, limits)); 172 return new Response(example); 173 } 174 175 /** 176 * Generates example media object 177 * @param dataGroups For supported data groups, see {@link service.tut.pori.contentanalysis.reference.ClientService#retrieveMediaObjects(core.tut.pori.http.parameters.AuthenticationParameter, DataGroups, Limits, core.tut.pori.http.parameters.IntegerParameter, core.tut.pori.http.parameters.StringParameter)}. 178 * @return MediaObject 179 * @see service.tut.pori.contentanalysis.MediaObject 180 */ 181 @HTTPServiceMethod(name = Definitions.ELEMENT_MEDIA_OBJECT) 182 public Response mediaObject( 183 @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required=false) DataGroups dataGroups) 184 { 185 Example example = new Example(); 186 example.setMediaObject(CAReferenceCore.generateMediaObject(dataGroups)); 187 return new Response(example); 188 } 189 190 /** 191 * Generates example visual shape 192 * 193 * @return VisualShape 194 * @see service.tut.pori.contentanalysis.VisualShape 195 */ 196 @HTTPServiceMethod(name = Definitions.ELEMENT_VISUAL_SHAPE) 197 public Response visualShape() { 198 Example example = new Example(); 199 example.setVisualShape(CAReferenceCore.generateVisualShape()); 200 return new Response(example); 201 } 202 203 /** 204 * Generates example task response 205 * 206 * @param limits paging limits 207 * @return TaskResponse 208 * @see service.tut.pori.contentanalysis.PhotoTaskResponse 209 */ 210 @HTTPServiceMethod(name = Definitions.ELEMENT_TASK_RESULTS) 211 public Response taskResults( 212 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 213 ) 214 { 215 Example example = new Example(); 216 example.setTaskResponse(CAReferenceCore.generateTaskResponse(limits)); 217 return new Response(example); 218 } 219 220 /** 221 * Generates example task details 222 * @param dataGroups For supported data groups, see {@link service.tut.pori.contentanalysis.reference.ClientService#retrieveMediaObjects(core.tut.pori.http.parameters.AuthenticationParameter, DataGroups, Limits, core.tut.pori.http.parameters.IntegerParameter, core.tut.pori.http.parameters.StringParameter)}. 223 * @param limits paging limits 224 * @param taskType Will default to {@link service.tut.pori.contentanalysis.AsyncTask.TaskType#ANALYSIS}, if missing 225 * @return PhotoTaskDetails 226 * @see service.tut.pori.contentanalysis.PhotoTaskDetails 227 */ 228 @HTTPServiceMethod(name = Definitions.ELEMENT_TASK_DETAILS) 229 public Response taskDetails( 230 @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required=false) DataGroups dataGroups, 231 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits, 232 @HTTPMethodParameter(name = service.tut.pori.contentanalysis.reference.Definitions.PARAMETER_TASK_TYPE, required=false) StringParameter taskType 233 ) 234 { 235 Example example = new Example(); 236 TaskType type = TaskType.ANALYSIS; 237 if(taskType.hasValues()){ 238 type = TaskType.fromString(taskType.getValue()); 239 } 240 example.setTaskDetails(CAReferenceCore.generatePhotoTaskDetails(dataGroups, limits, type)); 241 242 return new Response(example); 243 } 244 245 /** 246 * Generates example back-end status list list 247 * 248 * @param limits paging limits 249 * @return BackendStatusList 250 * @see service.tut.pori.contentanalysis.BackendStatusList 251 */ 252 @HTTPServiceMethod(name = Definitions.ELEMENT_BACKEND_STATUS_LIST) 253 public Response backendStatusList( 254 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 255 ) 256 { 257 Example example = new Example(); 258 example.setBackendStatusList(CAReferenceCore.generateBackendStatusList(limits)); 259 return new Response(example); 260 } 261 262 /** 263 * Generates example back-end status 264 * 265 * @return BackendStatus 266 * @see service.tut.pori.contentanalysis.BackendStatus 267 */ 268 @HTTPServiceMethod(name = Definitions.ELEMENT_BACKEND_STATUS) 269 public Response backendStatus() { 270 Example example = new Example(); 271 example.setBackendStatus(CAReferenceCore.generateBackendStatus()); 272 return new Response(example); 273 } 274 275 /** 276 * Generates example AnalysisBackend 277 * 278 * @return AnalysisBackend 279 * @see service.tut.pori.contentanalysis.AnalysisBackend 280 */ 281 @HTTPServiceMethod(name = Definitions.ELEMENT_BACKEND) 282 public Response analysisBackend() { 283 Example example = new Example(); 284 example.setAnalysisBackend(CAReferenceCore.generateAnalysisBackend()); 285 return new Response(example); 286 } 287 288 /** 289 * Generates example result info 290 * 291 * @return BackendStatus 292 * @see service.tut.pori.contentanalysis.ResultInfo 293 */ 294 @HTTPServiceMethod(name = Definitions.ELEMENT_RESULT_INFO) 295 public Response resultInfo() { 296 Example example = new Example(); 297 example.setResultInfo(CAReferenceCore.generateResultInfo()); 298 return new Response(example); 299 } 300 301 /** 302 * Generates example analysis parameters 303 * @return AnalysisParameters 304 * @see service.tut.pori.contentanalysis.PhotoParameters 305 */ 306 @HTTPServiceMethod(name = Definitions.ELEMENT_TASK_PARAMETERS) 307 public Response analysisParameters() { 308 Example example = new Example(); 309 example.setAnalysisParameters(CAReferenceCore.generateAnalysisParameters()); 310 return new Response(example); 311 } 312}