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.video.reference; 017 018import service.tut.pori.contentanalysis.AsyncTask.TaskType; 019import service.tut.pori.contentanalysis.Definitions; 020import service.tut.pori.contentanalysis.video.DeletedVideoList; 021import service.tut.pori.contentanalysis.video.VideoList; 022import core.tut.pori.http.Response; 023import core.tut.pori.http.annotations.HTTPMethodParameter; 024import core.tut.pori.http.annotations.HTTPService; 025import core.tut.pori.http.annotations.HTTPServiceMethod; 026import core.tut.pori.http.parameters.DataGroups; 027import core.tut.pori.http.parameters.Limits; 028import core.tut.pori.http.parameters.StringParameter; 029 030/** 031 * Generates example XML output 032 * 033 */ 034@HTTPService(name = service.tut.pori.contentanalysis.video.reference.Definitions.SERVICE_VCA_REFERENCE_EXAMPLE) 035public class ExampleService { 036 /** 037 * Generates example video 038 * @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, StringParameter)}. 039 * @return Video 040 * @see service.tut.pori.contentanalysis.video.Video 041 */ 042 @HTTPServiceMethod(name = service.tut.pori.contentanalysis.video.Definitions.ELEMENT_VIDEO) 043 public Response video( 044 @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required=false) DataGroups dataGroups) 045 { 046 Example example = new Example(); 047 example.setVideo(VideoReferenceCore.generateVideo(dataGroups)); 048 return new Response(example); 049 } 050 051 /** 052 * Generates example video list 053 * @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)}. 054 * @param limits paging limits 055 * @return VideoList 056 * @see service.tut.pori.contentanalysis.video.VideoList 057 */ 058 @HTTPServiceMethod(name = service.tut.pori.contentanalysis.video.Definitions.ELEMENT_VIDEOLIST) 059 public Response videoList( 060 @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required=false) DataGroups dataGroups, 061 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 062 ) 063 { 064 Example example = new Example(); 065 example.setVideoList(VideoReferenceCore.generateVideoList(dataGroups, limits, VideoList.class)); 066 return new Response(example); 067 } 068 069 /** 070 * Generates example time code 071 * @return Timecode 072 * @see service.tut.pori.contentanalysis.video.Timecode 073 */ 074 @HTTPServiceMethod(name = service.tut.pori.contentanalysis.video.Definitions.ELEMENT_TIMECODE) 075 public Response timecode() { 076 Example example = new Example(); 077 example.setTimecode(VideoReferenceCore.generateTimecode()); 078 return new Response(example); 079 } 080 081 /** 082 * Generates example time code list 083 * @param limits paing limits 084 * @return TimecodeList 085 * @see service.tut.pori.contentanalysis.video.TimecodeList 086 */ 087 @HTTPServiceMethod(name = service.tut.pori.contentanalysis.video.Definitions.ELEMENT_TIMECODELIST) 088 public Response timecodeList( 089 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits) 090 { 091 Example example = new Example(); 092 example.setTimecodeList(VideoReferenceCore.generateTimecodeList(limits)); 093 return new Response(example); 094 } 095 096 /** 097 * Generates example video options 098 * @return VideoOptions 099 * @see service.tut.pori.contentanalysis.video.VideoParameters 100 */ 101 @HTTPServiceMethod(name = Definitions.ELEMENT_TASK_PARAMETERS) 102 public Response analysisParameters() { 103 Example example = new Example(); 104 example.setVideoOptions(VideoReferenceCore.generateVideoOptions()); 105 return new Response(example); 106 } 107 108 /** 109 * Generates example deleted video list 110 * @param limits paging limits 111 * @return DeletedVideoList 112 * @see service.tut.pori.contentanalysis.video.DeletedVideoList 113 */ 114 @HTTPServiceMethod(name = service.tut.pori.contentanalysis.video.Definitions.ELEMENT_DELETED_VIDEOLIST) 115 public Response deletedVideoList( 116 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 117 ) 118 { 119 Example example = new Example(); 120 example.setVideoList(VideoReferenceCore.generateVideoList(null, limits, DeletedVideoList.class)); 121 return new Response(example); 122 } 123 124 /** 125 * Generates example task response 126 * 127 * @param limits paging limits 128 * @return VideoTaskResponse 129 * @see service.tut.pori.contentanalysis.video.VideoTaskResponse 130 */ 131 @HTTPServiceMethod(name = Definitions.ELEMENT_TASK_RESULTS) 132 public Response taskResults( 133 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits 134 ) 135 { 136 Example example = new Example(); 137 example.setTaskResponse(VideoReferenceCore.generateTaskResponse(limits)); 138 return new Response(example); 139 } 140 141 /** 142 * Generates example task details 143 * @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)}. 144 * @param limits paging limits 145 * @param taskType Will default to {@link service.tut.pori.contentanalysis.AsyncTask.TaskType#ANALYSIS}, if missing 146 * @return VideoTaskDetails 147 * @see service.tut.pori.contentanalysis.video.VideoTaskDetails 148 */ 149 @HTTPServiceMethod(name = Definitions.ELEMENT_TASK_DETAILS) 150 public Response taskDetails( 151 @HTTPMethodParameter(name = DataGroups.PARAMETER_DEFAULT_NAME, required=false) DataGroups dataGroups, 152 @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits, 153 @HTTPMethodParameter(name = service.tut.pori.contentanalysis.video.reference.Definitions.PARAMETER_TASK_TYPE, required=false) StringParameter taskType 154 ) 155 { 156 Example example = new Example(); 157 TaskType type = TaskType.ANALYSIS; 158 if(taskType.hasValues()){ 159 type = TaskType.fromString(taskType.getValue()); 160 } 161 example.setTaskDetails(VideoReferenceCore.generateVideoTaskDetails(dataGroups, limits, type)); 162 163 return new Response(example); 164 } 165}