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.facebookjazz.reference;
017
018import service.tut.pori.contentanalysis.AsyncTask.TaskType;
019import service.tut.pori.facebookjazz.Definitions;
020import core.tut.pori.http.Response;
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.Limits;
025import core.tut.pori.http.parameters.StringParameter;
026
027/**
028 * Generates example XML output
029 * 
030 */
031@HTTPService(name = service.tut.pori.facebookjazz.reference.Definitions.SERVICE_FBJ_REFERENCE_EXAMPLE)
032public class ExampleService {
033  /**
034   * Generates example weight modifier list
035   * 
036   * @return WeightModifierList
037   * @see service.tut.pori.facebookjazz.WeightModifierList
038   */
039  @HTTPServiceMethod(name = Definitions.ELEMENT_WEIGHT_MODIFIER_LIST)
040  public Response weightModifierList() {
041    Example example = new Example();
042    example.setWeightModifierList(FBJReferenceCore.generateWeighModifierList());
043    return new Response(example);
044  }
045  
046  /**
047   * Generates example weight modifier
048   * 
049   * @return WeightModifier
050   * @see service.tut.pori.facebookjazz.WeightModifier
051   */
052  @HTTPServiceMethod(name = Definitions.ELEMENT_WEIGHT_MODIFIER)
053  public Response weightModifier() {
054    Example example = new Example();
055    example.setWeightModifier(FBJReferenceCore.generateWeighModifier());
056    return new Response(example);
057  }
058  
059  /**
060   * Generates example task response
061   * 
062   * @param limits paging limits
063   * @return FBTaskResponse
064   * @see service.tut.pori.facebookjazz.FBTaskResponse
065   */
066  @HTTPServiceMethod(name = service.tut.pori.contentanalysis.Definitions.ELEMENT_TASK_RESULTS)
067  public Response taskResults(
068      @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits
069      ) 
070  {
071    Example example = new Example();
072    example.setTaskResponse(FBJReferenceCore.generateTaskResponse(limits));
073    return new Response(example);
074  }
075  
076  /**
077   * Generates example task details
078   * 
079   * @param limits paging limits
080   * @param taskType Will default to {@link service.tut.pori.contentanalysis.AsyncTask.TaskType#FACEBOOK_PROFILE_SUMMARIZATION} if missing
081   * @return FBSummarizationTaskDetails
082   * @throws IllegalArgumentException on invalid task type
083   * @see service.tut.pori.facebookjazz.FBSummarizationTaskDetails
084   */
085  @HTTPServiceMethod(name = service.tut.pori.contentanalysis.Definitions.ELEMENT_TASK_DETAILS)
086  public Response taskDetails(
087      @HTTPMethodParameter(name = Limits.PARAMETER_DEFAULT_NAME, required=false, defaultValue="0-0") Limits limits,
088      @HTTPMethodParameter(name = service.tut.pori.facebookjazz.reference.Definitions.PARAMETER_TASK_TYPE, required=false) StringParameter taskType
089      ) throws IllegalArgumentException
090  {
091    Example example = new Example();
092    TaskType type = TaskType.FACEBOOK_PROFILE_SUMMARIZATION;
093    if(taskType.hasValues()){
094      type = TaskType.fromString(taskType.getValue());
095    }
096    switch(type){
097      case FACEBOOK_PROFILE_SUMMARIZATION:
098        example.setTaskDetails(FBJReferenceCore.generateFBSummarizationTaskDetails(limits));
099        break;
100      case FACEBOOK_PROFILE_SUMMARIZATION_FEEDBACK:
101        example.setTaskDetails(FBJReferenceCore.generateFBFeedbackTaskDetails(limits));
102        break;
103      default:
104        throw new IllegalArgumentException("Unsupported task type: "+type.name());
105    }
106    return new Response(example);
107  }
108  
109  /**
110   * Generates example FacebookPhotoTag
111   * 
112   * @return FacebookPhotoTag
113   * @see service.tut.pori.facebookjazz.FacebookPhotoTag
114   */
115  @HTTPServiceMethod(name = Definitions.ELEMENT_PHOTO_TAG)
116  public Response facebookPhotoTag() {
117    Example example = new Example();
118    example.setFacebookPhotoTag(FBJReferenceCore.generateFacebookPhotoTag());
119    return new Response(example);
120  }
121  
122  /**
123   * Generates example FacebookComment
124   * 
125   * @return FacebookComment
126   * @see service.tut.pori.facebookjazz.FacebookComment
127   */
128  @HTTPServiceMethod(name = Definitions.ELEMENT_COMMENT)
129  public Response facebookComment() {
130    Example example = new Example();
131    example.setFacebookComment(FBJReferenceCore.generateFacebookComment());
132    return new Response(example);
133  }
134  
135  /**
136   * Generates example FacebookEvent
137   * 
138   * @return FacebookEvent
139   * @see service.tut.pori.facebookjazz.FacebookEvent
140   */
141  @HTTPServiceMethod(name = Definitions.ELEMENT_EVENT)
142  public Response facebookEvent() {
143    Example example = new Example();
144    example.setFacebookEvent(FBJReferenceCore.generateFacebookEvent());
145    return new Response(example);
146  }
147  
148  /**
149   * Generates example FacebookGroup
150   * 
151   * @return FacebookGroup
152   * @see service.tut.pori.facebookjazz.FacebookGroup
153   */
154  @HTTPServiceMethod(name = Definitions.ELEMENT_GROUP)
155  public Response facebookGroup() {
156    Example example = new Example();
157    example.setFacebookGroup(FBJReferenceCore.generateFacebookGroup());
158    return new Response(example);
159  }
160  
161  /**
162   * Generates example FacebookLocation
163   * 
164   * @return FacebookLocation
165   * @see service.tut.pori.facebookjazz.FacebookLocation
166   */
167  @HTTPServiceMethod(name = Definitions.ELEMENT_LOCATION)
168  public Response facebookLocation() {
169    Example example = new Example();
170    example.setFacebookLocation(FBJReferenceCore.generateFacebookLocation());
171    return new Response(example);
172  }
173  
174  /**
175   * Generates example FacebookPhotoDescription
176   * 
177   * @return FacebookPhotoDescription
178   * @see service.tut.pori.facebookjazz.FacebookPhotoDescription
179   */
180  @HTTPServiceMethod(name = Definitions.ELEMENT_PHOTO_DESCRIPTION)
181  public Response facebookPhotoDescription() {
182    Example example = new Example();
183    example.setFacebookPhotoDescription(FBJReferenceCore.generateFacebookPhotoDescription());
184    return new Response(example);
185  }
186  
187  /**
188   * Generates example FacebookPhotoDescription
189   * 
190   * @return FacebookVideoDescription
191   * @see service.tut.pori.facebookjazz.FacebookVideoDescription
192   */
193  @HTTPServiceMethod(name = Definitions.ELEMENT_VIDEO_DESCRIPTION)
194  public Response facebookVideoDescription() {
195    Example example = new Example();
196    example.setFacebookVideoDescription(FBJReferenceCore.generateFacebookVideoDescription());
197    return new Response(example);
198  }
199  
200  /**
201   * Generates example FacebookProfile
202   * 
203   * @return FacebookProfile
204   * @see service.tut.pori.facebookjazz.FacebookProfile
205   */
206  @HTTPServiceMethod(name = Definitions.ELEMENT_FACEBOOK_PROFILE)
207  public Response facebookProfile() {
208    Example example = new Example();
209    example.setFacebookProfile(FBJReferenceCore.generateFacebookProfile());
210    return new Response(example);
211  }
212  
213  /**
214   * Generates example FacebookRelationship
215   * 
216   * @return FacebookRelationship
217   * @see service.tut.pori.facebookjazz.FacebookRelationship
218   */
219  @HTTPServiceMethod(name = Definitions.ELEMENT_RELATIONSHIP)
220  public Response facebookRelationship() {
221    Example example = new Example();
222    example.setFacebookRelationship(FBJReferenceCore.generateFacebookRelationship());
223    return new Response(example);
224  }
225  
226  /**
227   * Generates example FacebookStatusMessage
228   * 
229   * @return FacebookStatusMessage
230   * @see service.tut.pori.facebookjazz.FacebookStatusMessage
231   */
232  @HTTPServiceMethod(name = Definitions.ELEMENT_STATUS_MESSAGE)
233  public Response facebookStatusMessage() {
234    Example example = new Example();
235    example.setFacebookStatusMessage(FBJReferenceCore.generateFacebookStatusMessage());
236    return new Response(example);
237  }
238  
239  /**
240   * Generates example FacebookUserDetails
241   * 
242   * @return FacebookUserDetails
243   * @see service.tut.pori.facebookjazz.FacebookUserDetails
244   */
245  @HTTPServiceMethod(name = Definitions.ELEMENT_USER_DETAILS)
246  public Response facebookUserDetails() {
247    Example example = new Example();
248    example.setFacebookUserDetails(FBJReferenceCore.generateFacebookUserDetails());
249    return new Response(example);
250  }
251  
252  /**
253   * Generates example FacebookLike
254   * 
255   * @return FacebookLike
256   * @see service.tut.pori.facebookjazz.FacebookLike
257   */
258  @HTTPServiceMethod(name = Definitions.ELEMENT_LIKE)
259  public Response facebookLike() {
260    Example example = new Example();
261    example.setFacebookLike(FBJReferenceCore.generateFacebookLike());
262    return new Response(example);
263  }
264}