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.facebookjazz.reference;
017
018import java.util.ArrayList;
019import java.util.Arrays;
020import java.util.Date;
021import java.util.EnumSet;
022import java.util.List;
023import java.util.Random;
024import java.util.UUID;
025
026import org.apache.commons.lang3.RandomStringUtils;
027import org.apache.log4j.Logger;
028
029import service.tut.pori.contentanalysis.AsyncTask.TaskType;
030import service.tut.pori.contentanalysis.CAContentCore.ServiceType;
031import service.tut.pori.contentanalysis.CAContentCore.Visibility;
032import service.tut.pori.contentanalysis.Definitions;
033import service.tut.pori.contentanalysis.PhotoList;
034import service.tut.pori.contentanalysis.MediaObject;
035import service.tut.pori.contentanalysis.MediaObject.ConfirmationStatus;
036import service.tut.pori.contentanalysis.MediaObjectList;
037import service.tut.pori.contentanalysis.reference.CAXMLObjectCreator;
038import service.tut.pori.contentstorage.FacebookPhotoStorage;
039import service.tut.pori.facebookjazz.FBFeedbackTaskDetails;
040import service.tut.pori.facebookjazz.FBSummarizationTaskDetails;
041import service.tut.pori.facebookjazz.FBTaskResponse;
042import service.tut.pori.facebookjazz.FacebookComment;
043import service.tut.pori.facebookjazz.FacebookEvent;
044import service.tut.pori.facebookjazz.FacebookEvent.RSVPStatus;
045import service.tut.pori.facebookjazz.FacebookExtractor.ContentType;
046import service.tut.pori.facebookjazz.FacebookGroup;
047import service.tut.pori.facebookjazz.FacebookGroup.Privacy;
048import service.tut.pori.facebookjazz.FacebookLike;
049import service.tut.pori.facebookjazz.FacebookLocation;
050import service.tut.pori.facebookjazz.FacebookPhotoDescription;
051import service.tut.pori.facebookjazz.FacebookPhotoTag;
052import service.tut.pori.facebookjazz.FacebookProfile;
053import service.tut.pori.facebookjazz.FacebookRelationship;
054import service.tut.pori.facebookjazz.FacebookStatusMessage;
055import service.tut.pori.facebookjazz.FacebookUserDetails;
056import service.tut.pori.facebookjazz.FacebookVideoDescription;
057import service.tut.pori.facebookjazz.WeightModifier;
058import service.tut.pori.facebookjazz.WeightModifier.WeightModifierType;
059import service.tut.pori.facebookjazz.WeightModifierList;
060
061import com.restfb.types.CategorizedFacebookType;
062import com.restfb.types.Location;
063import com.restfb.types.NamedFacebookType;
064
065import core.tut.pori.context.ServiceInitializer;
066import core.tut.pori.http.parameters.DataGroups;
067import core.tut.pori.http.parameters.Limits;
068import core.tut.pori.users.UserIdentity;
069
070/**
071 * 
072 * class that can be used to created example objects/object lists
073 * 
074 */
075public class FBJXMLObjectCreator {
076  private static final DataGroups DATA_GROUPS_ALL = new DataGroups(DataGroups.DATA_GROUP_ALL);
077  private static final Logger LOGGER = Logger.getLogger(FBJXMLObjectCreator.class);
078  private static final int TEXT_LENGTH = 64;
079  private static final int WEIGHT_MODIFIER_MAX = 5;
080  private boolean _includeResultInfo = false;
081  private CAXMLObjectCreator _CACreator = null;
082
083  /**
084   * 
085   * @param seed for random generator, or null to use default (system time in nanoseconds)
086   */
087  public FBJXMLObjectCreator(Long seed){
088    if(seed == null){
089      seed = System.nanoTime();
090    }
091    _CACreator = new CAXMLObjectCreator(seed);
092  }
093
094  /**
095   * @see service.tut.pori.contentanalysis.reference.CAXMLObjectCreator#getSeed()
096   * 
097   * @return the seed
098   */
099  public long getSeed() {
100    return _CACreator.getSeed();
101  }
102
103  /**
104   * 
105   * @return randomly generated comment
106   */
107  public FacebookComment createComment(){
108    FacebookComment comment = new FacebookComment();
109    comment.setMessage(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
110    Random r = _CACreator.getRandom();
111    comment.setLikeCount(Math.abs(r.nextLong()));
112    comment.setCreatedTime(CAXMLObjectCreator.createRandomDate(new Date(), r));
113    comment.setFromName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
114    return comment;
115  }
116
117  /**
118   * 
119   * @return randomly generated type
120   */
121  public CategorizedFacebookType createCategorizedFacebookType(){
122    CategorizedFacebookType type = new CategorizedFacebookType();
123    populateCategorizedFacebookType(type);
124    return type;
125  }
126
127  /**
128   * 
129   * @param type
130   */
131  public void populateCategorizedFacebookType(CategorizedFacebookType type){
132    type.setCategory(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
133    populateNamedFacebookType(type);
134  }
135
136  /**
137   * 
138   * @param type
139   */
140  public void populateNamedFacebookType(NamedFacebookType type){
141    type.setName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
142  }
143
144  /**
145   * 
146   * @return randomly generated type
147   */
148  public NamedFacebookType createNamedFacebookType(){
149    NamedFacebookType type = new NamedFacebookType();
150    populateNamedFacebookType(type);
151    return type;
152  }
153
154  /**
155   * 
156   * @return randomly generated id
157   */
158  public long createUserId(){
159    return Math.abs(_CACreator.getRandom().nextLong());
160  }
161
162  /**
163   * 
164   * @return randomly generated list
165   */
166  public WeightModifierList createWeightModifierList(){
167    WeightModifierList modifiers = new WeightModifierList();
168    WeightModifierType[] types = WeightModifierType.values();
169    for(int i=0;i<types.length;++i){
170      modifiers.setWeightModifier(createWeightModifier(types[i]));
171    }
172    return modifiers;
173  }
174  
175  /**
176   * 
177   * @param type if null, the type will be randomly generated
178   * @return randomly generated weight modifier
179   */
180  public WeightModifier createWeightModifier(WeightModifierType type) {
181    if(type == null){
182      type = createWeightModifierType();
183    }
184    return new WeightModifier(type, _CACreator.getRandom().nextInt(WEIGHT_MODIFIER_MAX));
185  }
186  
187  /**
188   * 
189   * @return random weight modifier type
190   */
191  public WeightModifierType createWeightModifierType(){
192    WeightModifierType[] types = WeightModifierType.values();
193    return types[_CACreator.getRandom().nextInt(types.length)];
194  }
195
196  /**
197   * 
198   * @return randomly generated status
199   */
200  public ConfirmationStatus createConfirmationStatus(){
201    return ConfirmationStatus.fromInt(_CACreator.getRandom().nextInt(5)+1);
202  }
203
204  /**
205   * @see service.tut.pori.contentanalysis.reference.CAXMLObjectCreator#createVisibility()
206   * 
207   * @return randomly generated visiblity
208   */
209  public Visibility createVisibility(){
210    return _CACreator.createVisibility();
211  }
212
213  /**
214   * 
215   * @param likeCount
216   * @param eventCount
217   * @param groupCount
218   * @param photoDescriptionCount
219   * @param videoDescriptionCount
220   * @param statusMessageCount
221   * @param tagCount 
222   * @param commentCount 
223   * @return randomly generated details
224   */
225  public FBSummarizationTaskDetails createFBSummarizationTaskDetails(int likeCount, int eventCount, int groupCount, int photoDescriptionCount, int videoDescriptionCount, int statusMessageCount, int tagCount, int commentCount){
226    FBSummarizationTaskDetails details = new FBSummarizationTaskDetails();
227    Random r = _CACreator.getRandom();
228    _CACreator.populateAbstractTaskDetails(Math.abs(r.nextInt()), details, Math.abs(r.nextLong()), TaskType.FACEBOOK_PROFILE_SUMMARIZATION);
229    details.setProfile(createFacebookProfile(likeCount, eventCount, groupCount, photoDescriptionCount, videoDescriptionCount, statusMessageCount, tagCount, commentCount));
230    details.setContentTypes(EnumSet.allOf(ContentType.class));
231    details.setCallbackUri(generateFinishedCallbackUri()); // override the default uri
232    return details;
233  }
234  
235  /**
236   * 
237   * @return the default task finished callback uri
238   */
239  public String generateFinishedCallbackUri(){
240    return ServiceInitializer.getPropertyHandler().getRESTBindContext()+service.tut.pori.facebookjazz.reference.Definitions.SERVICE_FBJ_REFERENCE_SERVER+"/"+Definitions.METHOD_TASK_FINISHED;
241  }
242
243  /**
244   * 
245   * @param likeCount
246   * @param eventCount
247   * @param groupCount
248   * @param photoDescriptionCount
249   * @param videoDescriptionCount
250   * @param statusMessageCount
251   * @param tagCount 
252   * @param commentCount 
253   * @return randombly generated profile
254   */
255  public FacebookProfile createFacebookProfile(int likeCount, int eventCount, int groupCount, int photoDescriptionCount, int videoDescriptionCount, int statusMessageCount, int tagCount, int commentCount){
256    FacebookProfile profile = new FacebookProfile(createFacebookUserDetails());
257
258    if(likeCount > 0){
259      ArrayList<FacebookLike> likes = new ArrayList<>(likeCount);
260      for(int i=0;i<likeCount;++i){
261        likes.add(createFacebookLike());
262      }
263      profile.setLikes(likes);
264    }
265
266    if(statusMessageCount > 0){
267      ArrayList<FacebookStatusMessage> messages = new ArrayList<>(statusMessageCount);
268      for(int i=0;i<statusMessageCount;++i){
269        messages.add(createFacebookStatusMessage(commentCount));
270      }
271      profile.setStatusMessages(messages);
272    }
273
274    if(eventCount > 0){
275      ArrayList<FacebookEvent> events = new ArrayList<>(eventCount);
276      for(int i=0;i<eventCount;++i){
277        events.add(createFacebookEvent());
278      }
279      profile.setEvents(events);
280    }
281
282    if(photoDescriptionCount > 0){
283      ArrayList<FacebookPhotoDescription> descs = new ArrayList<>(photoDescriptionCount);
284      for(int i=0;i<photoDescriptionCount;++i){
285        descs.add(createFacebookPhotoDescription(commentCount, tagCount));
286      }
287      profile.setPhotoDescriptions(descs);
288    }
289
290    if(groupCount > 0){
291      ArrayList<FacebookGroup> groups = new ArrayList<>(groupCount);
292      for(int i=0;i<groupCount;++i){
293        groups.add(createFacebookGroup());
294      }
295      profile.setGroups(groups);
296    }
297
298    if(videoDescriptionCount > 0){
299      ArrayList<FacebookVideoDescription> descs = new ArrayList<>(videoDescriptionCount);
300      for(int i=0;i<videoDescriptionCount;++i){
301        descs.add(createFacebookVideoDescription(commentCount));
302      }
303      profile.setVideoDescriptions(descs);
304    }
305
306    return profile;
307  }
308
309  /**
310   * 
311   * @param commentCount 
312   * @return randomly generated description
313   */
314  public FacebookVideoDescription createFacebookVideoDescription(int commentCount){
315    FacebookVideoDescription vid = new FacebookVideoDescription();
316
317    Random r = _CACreator.getRandom();
318    vid.setLikeCount(Math.abs(r.nextLong()));
319
320    vid.setId(String.valueOf(Math.abs(r.nextLong())));
321
322    vid.setDescriptionComments(new ArrayList<>(Arrays.asList(createFacebookComment(),createFacebookComment())));
323
324    vid.setFromName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
325
326    Date updated = CAXMLObjectCreator.createRandomDate(new Date(),r);
327    vid.setUpdatedTime(updated);
328
329    vid.setCreatedTime(CAXMLObjectCreator.createRandomDate(updated,r));
330
331    vid.setDescription(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
332
333    vid.setDescriptionComments(createFacebookComments(commentCount));
334    return vid;
335  }
336
337  /**
338   * 
339   * @param commentCount 
340   * @param tagCount 
341   * @return randomly generated description
342   */
343  public FacebookPhotoDescription createFacebookPhotoDescription(int commentCount, int tagCount){
344    FacebookPhotoDescription d = new FacebookPhotoDescription();
345
346    Random r = _CACreator.getRandom();
347    Date updated = CAXMLObjectCreator.createRandomDate(new Date(),r);
348    d.setUpdatedTime(updated);
349
350    d.setCreatedTime(CAXMLObjectCreator.createRandomDate(updated,r));
351
352    d.addLike(createNamedFacebookType());
353
354    d.setDescription(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
355
356    d.setFromName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
357    
358    d.setId(String.valueOf(Math.abs(r.nextLong())));
359
360    d.setFacebookLocation(createFacebookLocation());
361
362    d.setPhotoGUID(UUID.randomUUID().toString());
363    d.setServiceType(FacebookPhotoStorage.SERVICE_TYPE);
364
365    d.setDescriptionComments(createFacebookComments(commentCount));
366    if(tagCount < 1){
367      LOGGER.debug("Tag count < 1.");
368    }else{
369      for(int i=0;i<tagCount;++i){
370        d.addTag(createFacebookPhotoTag());
371      }
372    }
373    return d;
374  }
375
376  /**
377   * 
378   * @return randomly generated photo tag
379   */
380  public FacebookPhotoTag createFacebookPhotoTag() {
381    FacebookPhotoTag tag = new FacebookPhotoTag();
382    tag.setName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
383    tag.setServiceType(FacebookPhotoStorage.SERVICE_TYPE);
384    return tag;
385  }
386
387  /**
388   * 
389   * @return randomly generated event
390   */
391  public FacebookEvent createFacebookEvent(){
392    FacebookEvent event = new FacebookEvent();
393
394    event.setDescription(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
395
396    Random r = _CACreator.getRandom();
397    Date endTime = CAXMLObjectCreator.createRandomDate(new Date(), r);
398    event.setStartTime(CAXMLObjectCreator.createRandomDate(endTime, r));
399
400    event.setEventStatus(createRSVPStatus());
401
402    event.setPrivacy(createPrivacy());
403
404    event.setUpdatedTime(CAXMLObjectCreator.createRandomDate(new Date(), r));
405
406    event.setName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
407
408    event.setFacebookLocation(createFacebookLocation());
409
410    event.setEventOwnerName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
411
412    return event;
413  }
414
415  /**
416   * 
417   * @return randomly generated status
418   */
419  public RSVPStatus createRSVPStatus(){
420    RSVPStatus[] statuses = RSVPStatus.values();
421    return statuses[_CACreator.getRandom().nextInt(statuses.length)];
422  }
423
424  /**
425   * 
426   * @return randomly generated privacy
427   */
428  public Privacy createPrivacy(){
429    Privacy[] priv = Privacy.values();
430    return priv[_CACreator.getRandom().nextInt(priv.length)];
431  }
432
433  /**
434   * 
435   * @param commentCount 
436   * @return randomly generated message
437   */
438  public FacebookStatusMessage createFacebookStatusMessage(int commentCount){
439    FacebookStatusMessage message = new FacebookStatusMessage();
440    message.setMessage(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
441
442    message.setFromName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
443
444    message.setUpdatedTime(CAXMLObjectCreator.createRandomDate(new Date(), _CACreator.getRandom()));
445
446    message.addLike(createNamedFacebookType());
447
448    message.setMessageComments(createFacebookComments(commentCount));
449
450    message.setMessageComments(createFacebookComments(commentCount));
451    return message;
452  }
453
454  /**
455   * 
456   * @param count
457   * @return list of comment or null if count was &lt; 1
458   */
459  public List<FacebookComment> createFacebookComments(int count){
460    if(count < 1){
461      LOGGER.debug("Count < 1.");
462      return null;
463    }
464    List<FacebookComment> comments = new ArrayList<>(count);
465    for(int i=0;i<count;++i){
466      comments.add(createFacebookComment());
467    }
468    return comments;
469  }
470
471  /**
472   * 
473   * @return randomly generated comment
474   */
475  public FacebookComment createFacebookComment(){
476    FacebookComment comment = new FacebookComment();
477    Random r = _CACreator.getRandom();
478    comment.setCreatedTime(CAXMLObjectCreator.createRandomDate(new Date(), r));
479    comment.setFromName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
480    comment.setMessage(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
481    comment.setLikeCount(Math.abs(r.nextLong()));
482    return comment;
483  }
484
485  /**
486   * 
487   * @return randomly generated details
488   */
489  public FacebookUserDetails createFacebookUserDetails(){
490    FacebookUserDetails details = new FacebookUserDetails();
491    details.setUserId(_CACreator.createUserIdentity());
492
493    details.setBio(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
494
495    details.setFirstName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
496
497    details.setMiddleName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
498
499    details.setLastName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
500
501    details.setGender(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
502
503    details.setHometownName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
504
505    Random r = _CACreator.getRandom();
506    details.setUpdatedTime(CAXMLObjectCreator.createRandomDate(new Date(), r));
507
508    details.setBirthdayAsDate(CAXMLObjectCreator.createRandomDate(new Date(), r));
509
510    details.setRelationshipStatus(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
511
512    details.setSignificantOther(createNamedFacebookType());
513
514    details.setFacebookLocation(createFacebookLocation());
515
516    details.setReligion(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
517
518    details.setPolitical(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
519    
520    details.setId(String.valueOf(Math.abs(r.nextLong())));
521
522    return details;
523  }
524
525  /**
526   * 
527   * @return randomly generated like
528   */
529  public FacebookLike createFacebookLike(){
530    return new FacebookLike(createCategorizedFacebookType());
531  }
532
533  /**
534   * 
535   * @return randomly generated relationship
536   */
537  public FacebookRelationship createFacebookRelationship(){
538    FacebookRelationship ship = new FacebookRelationship();
539    ship.setType(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
540    ship.setWith(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
541    return ship;
542  }
543
544  /**
545   * 
546   * @return randomly generated location
547   */
548  public FacebookLocation createFacebookLocation(){
549    FacebookLocation loc = new FacebookLocation(createLocation());
550    loc.setName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
551    return loc;
552  }
553  
554  /**
555   * 
556   * @return randomly generated location
557   */
558  public Location createLocation(){
559    Location loc = new Location();
560    loc.setCountry(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
561    loc.setState(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
562    loc.setCity(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
563    return loc;
564  }
565
566  /**
567   * 
568   * @return randomly generated group
569   */
570  public FacebookGroup createFacebookGroup(){
571    FacebookGroup group = new FacebookGroup();
572    group.setDescription(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
573
574    group.setPrivacy(createPrivacy());
575
576    group.setUpdatedTime(CAXMLObjectCreator.createRandomDate(new Date(), _CACreator.getRandom()));
577
578    group.setName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
579
580    group.setGroupOwnerName(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
581
582    group.setFacebookLocation(createFacebookLocation());
583
584    return group;
585
586  }
587
588  /**
589   * @return the includeResultInfo
590   */
591  public boolean isIncludeResultInfo() {
592    return _includeResultInfo;
593  }
594
595  /**
596   * @param includeResultInfo the includeResultInfo to set
597   */
598  public void setIncludeResultInfo(boolean includeResultInfo) {
599    _includeResultInfo = includeResultInfo;
600  }
601
602  /**
603   * @see service.tut.pori.contentanalysis.reference.CAXMLObjectCreator#createBackendId()
604   * 
605   * @return randomly generated back-end id
606   */
607  public Integer createBackendId() {
608    return _CACreator.createBackendId();
609  }
610
611  /**
612   * 
613   * @param backendId
614   * @param dataGroups
615   * @param limits
616   * @param userId
617   * @return randomly generated tag list
618   */
619  public MediaObjectList createTagList(Integer backendId, DataGroups dataGroups, Limits limits, UserIdentity userId) {
620    MediaObjectList objects = _CACreator.createMediaObjectList(null, dataGroups, limits, EnumSet.of(ServiceType.FACEBOOK_JAZZ));
621    if(!MediaObjectList.isEmpty(objects)){  
622      userId = UserIdentity.isValid(userId) ? userId : _CACreator.createUserIdentity();
623      backendId = createBackendId();
624      for(MediaObject o : objects.getMediaObjects()){
625        o.setOwnerUserId(userId);
626        o.setBackendId(backendId);
627      }
628    }
629    return objects;
630  }
631
632  /**
633   * 
634   * @param dataGroups
635   * @param limits
636   * @param taskId randomly generated if null
637   * @param taskType randomly generated if null
638   * @return randomly generated task response
639   */
640  public FBTaskResponse createTaskResponse(DataGroups dataGroups, Limits limits, Long taskId, TaskType taskType) {
641    FBTaskResponse r = new FBTaskResponse();
642    Random random = _CACreator.getRandom();
643    r.setTaskId((taskId == null ? Math.abs(random.nextLong()) : taskId));
644    Integer backendId = Math.abs(random.nextInt());
645    r.setBackendId(backendId);
646    r.setMessage(RandomStringUtils.randomAlphabetic(TEXT_LENGTH));
647    r.setTaskType((taskType == null ? _CACreator.createTaskType() : taskType));
648    r.setStatus(_CACreator.createTaskStatus());
649    PhotoList photoList = _CACreator.createPhotoList(null, dataGroups, limits, null, _CACreator.createUserIdentity());
650    if(!PhotoList.isEmpty(photoList)){
651      for(service.tut.pori.contentanalysis.Photo p : photoList.getPhotos()){ // make sure all media objects have the same back-end id as the task has, and that service types match
652        MediaObjectList mediaObjectList = p.getMediaObjects();
653        p.setServiceType(ServiceType.FACEBOOK_PHOTO);
654        if(!MediaObjectList.isEmpty(mediaObjectList)){
655          for(MediaObject vo : mediaObjectList.getMediaObjects()){
656            vo.setBackendId(backendId);
657            vo.setServiceType(ServiceType.FACEBOOK_JAZZ);
658          }
659        }
660      }
661      r.setPhotoList(photoList);
662    }
663    MediaObjectList mediaObjectList = _CACreator.createMediaObjectList(null, dataGroups, limits, EnumSet.of(ServiceType.FACEBOOK_JAZZ));
664    if(!MediaObjectList.isEmpty(mediaObjectList)){
665      for(MediaObject vo : mediaObjectList.getMediaObjects()){ // make sure all media objects have the same back-end id as the task has
666        vo.setBackendId(backendId);
667      }
668      r.setMediaObjects(mediaObjectList);
669    }
670    return r;
671  }
672
673  /**
674   * 
675   * @param objectCount
676   * @return randomly generated task details
677   */
678  public FBFeedbackTaskDetails createFBFeedbackTaskDetails(int objectCount) {
679    if(objectCount < 1){
680      LOGGER.warn("Object count was < 1.");
681      return null;
682    }
683    FBFeedbackTaskDetails details = new FBFeedbackTaskDetails();
684    Random r = _CACreator.getRandom();
685    _CACreator.populateAbstractTaskDetails(Math.abs(r.nextInt()), details, Math.abs(r.nextLong()), TaskType.FACEBOOK_PROFILE_SUMMARIZATION_FEEDBACK);
686    details.setTags(_CACreator.createMediaObjectList(null, DATA_GROUPS_ALL, new Limits(0, objectCount-1), null));
687    details.setCallbackUri(generateFinishedCallbackUri());
688    return details;
689  }
690}