Package org.apache.shindig.social.opensocial.jpa

Examples of org.apache.shindig.social.opensocial.jpa.ActivityDb


    // Build and persist activity test data
    entityManager.persist(buildCanonicalActivity("canonical", "1"));
    entityManager.persist(buildCanonicalActivity("canonical", "2"));

    ActivityDb activity1 = buildActivityTemplate("john.doe", "1");
    activity1.setTitle("yellow");
    activity1.setBody("what a color!");
    entityManager.persist(activity1);

    ActivityDb activity2 = buildActivityTemplate("jane.doe", "1");
    activity2.setBody("and she thinks you look like him");
    List<MediaItem> mediaItems = new ArrayList<MediaItem>();
    MediaItemDb mediaItem1 = new MediaItemDb();
    mediaItem1.setMimeType("image/jpeg");
    mediaItem1.setType(MediaItem.Type.IMAGE);
    mediaItem1.setUrl("http://animals.nationalgeographic.com/staticfiles/NGS/Shared/StaticFiles/animals/images/primary/black-spider-monkey.jpg");
    MediaItemDb mediaItem2 = new MediaItemDb();
    mediaItem2.setMimeType("image/jpeg");
    mediaItem2.setType(MediaItem.Type.IMAGE);
    mediaItem2.setUrl("http://image.guardian.co.uk/sys-images/Guardian/Pix/gallery/2002/01/03/monkey300.jpg");
    mediaItems.add(mediaItem1);
    mediaItems.add(mediaItem2);
    activity2.setMediaItems(mediaItems);
    activity2.setStreamTitle("jane's photos");
    activity2.setTitle("Jane just posted a photo of a monkey");
    entityManager.persist(activity2);

    ActivityDb activity3 = buildActivityTemplate("jane.doe", "2");
    activity3.setBody("or is it you?");
    List<MediaItem> mediaItems2 = new ArrayList<MediaItem>();
    MediaItemDb mediaItem3 = new MediaItemDb();
    mediaItem3.setMimeType("image/jpeg");
    mediaItem3.setType(MediaItem.Type.IMAGE);
    mediaItem3.setUrl("http://www.funnyphotos.net.au/images/fancy-dress-dog-yoda-from-star-wars1.jpg");
    mediaItems2.add(mediaItem3);
    activity3.setMediaItems(mediaItems2);
    activity3.setStreamTitle("jane's photos");
    activity3.setTitle("Jane says George likes yoda!");
    entityManager.persist(activity3);

    // Build and persist application data test data
    ApplicationDb testApplication = new ApplicationDb();
    testApplication.setId("app");
View Full Code Here


    applicationDataMap.setValues(values);
    return applicationDataMap;
  }

  private ActivityDb buildCanonicalActivity(String userId, String id) {
    ActivityDb activity = buildActivityTemplate(userId, id);

    // Common attributes
    activity.setPriority(0.7F);
    activity.setStreamFaviconUrl("http://upload.wikimedia.org/wikipedia/commons/0/02/Nuvola_apps_edu_languages.gif");
    activity.setStreamSourceUrl("http://www.example.org/canonical/streamsource");
    activity.setStreamTitle("All my activities");
    activity.setStreamUrl("http://www.example.org/canonical/activities");

    // Set othe attributes depending on given id
    if ("1".equals(id)) {
      activity.setBody("Went rafting");
      activity.setBodyId("1");
      activity.setExternalId("http://www.example.org/123456");
      List<MediaItem> mediaItems = new ArrayList<MediaItem>();
      MediaItemDb mediaItem1 = new MediaItemDb();
      mediaItem1.setMimeType("image/*");
      mediaItem1.setType(MediaItem.Type.IMAGE);
      mediaItem1.setUrl("http://upload.wikimedia.org/wikipedia/commons/thumb/7/77/Rafting_em_Brotas.jpg/800px-Rafting_em_Brotas.jpg");
      MediaItemDb mediaItem2 = new MediaItemDb();
      mediaItem2.setMimeType("audio/mpeg");
      mediaItem2.setType(MediaItem.Type.AUDIO);
      mediaItem2.setUrl("http://www.archive.org/download/testmp3testfile/mpthreetest.mp3");
      mediaItems.add(mediaItem1);
      mediaItems.add(mediaItem2);
      activity.setMediaItems(mediaItems);
      activity.setPostedTime(1111111111L);
      Map<String, String> templateParams = new MapMaker().makeMap();
      templateParams.put("small", "true");
      templateParams.put("otherContent", "and got wet");
      activity.setTemplateParams(templateParams);
      activity.setTitle("My trip");
      activity.setTitleId("1");
      activity.setUpdated(new Date());
      activity.setUrl("http://www.example.org/canonical/activities/1");

    } else if ("2".equals(id)) {
      activity.setBody("Went skiing");
      activity.setBodyId("2");
      activity.setExternalId("http://www.example.org/123457");
      List<MediaItem> mediaItems = new ArrayList<MediaItem>();
      activity.setMediaItems(mediaItems);
      activity.setPostedTime(1111111112L);
      Map<String, String> templateParams = new MapMaker().makeMap();
      templateParams.put("small", "true");
      templateParams.put("otherContent", "and went fast");
      activity.setTemplateParams(templateParams);
      activity.setTitle("My next trip");
      activity.setTitleId("2");
      activity.setUpdated(new Date());
      activity.setUrl("http://www.example.org/canonical/activities/2");
    }
    return activity;
  }
View Full Code Here

    }
    return activity;
  }

  private ActivityDb buildActivityTemplate(String userId, String id) {
    ActivityDb activity = new ActivityDb();
    activity.setUserId(userId);
    activity.setId(id);
    return activity;
  }
View Full Code Here

    String uid = SPIUtils.getUserList(userId, token);

    try {
      // Map activity into a new ActivityDb instance
      // TODO Could we use dozer to do this mapping instead, for future-proofing reasons?
      ActivityDb activityDb = new ActivityDb();
      activityDb.setPostedTime(new Date().getTime());
      activityDb.setAppId(appId);
      activityDb.setUserId(uid);
      activityDb.setId(activity.getId());
      activityDb.setBodyId(activity.getBodyId());
      activityDb.setBody(activity.getBody());
      activityDb.setExternalId(activity.getExternalId());
      activityDb.setTitleId(activity.getTitleId());
      activityDb.setTitle(activity.getTitle());
      activityDb.setUpdated(new Date());
      activityDb.setPriority(activity.getPriority());
      activityDb.setStreamFaviconUrl(activity.getStreamFaviconUrl());
      activityDb.setStreamSourceUrl(activity.getStreamSourceUrl());
      activityDb.setStreamTitle(activity.getStreamTitle());
      activityDb.setStreamUrl(activity.getStreamUrl());
      activityDb.setUrl(activity.getUrl());
      if(activity.getMediaItems() != null) {
        List<MediaItem> mediaItems = new ArrayList<MediaItem>();
        for(MediaItem m : activity.getMediaItems()) {
          MediaItemDb mediaItem = new MediaItemDb();
          mediaItem.setMimeType(m.getMimeType());
          mediaItem.setType(m.getType());
          mediaItem.setUrl(m.getUrl());
          mediaItems.add(mediaItem);
        }
        activityDb.setMediaItems(mediaItems);
      }
      if (activity.getTemplateParams() != null) {
        activityDb.setTemplateParams(activity.getTemplateParams());
      }

      // TODO How should transactions be managed? Should samples be using warp-persist instead?
      if (!entityManager.getTransaction().isActive()) {
        entityManager.getTransaction().begin();
View Full Code Here

   
    // Build and persist activity test data   
    entityManager.persist(buildCanonicalActivity("canonical", "1"));
    entityManager.persist(buildCanonicalActivity("canonical", "2"));
   
    ActivityDb activity1 = buildActivityTemplate("john.doe", "1");   
    activity1.setTitle("yellow");
    activity1.setBody("what a color!");
    entityManager.persist(activity1);
   
    ActivityDb activity2 = buildActivityTemplate("jane.doe", "1");   
    activity2.setBody("and she thinks you look like him");
    List<MediaItem> mediaItems = new ArrayList<MediaItem>();
    MediaItemDb mediaItem1 = new MediaItemDb();
    mediaItem1.setMimeType("image/jpeg");
    mediaItem1.setType(MediaItem.Type.IMAGE);
    mediaItem1.setUrl("http://animals.nationalgeographic.com/staticfiles/NGS/Shared/StaticFiles/animals/images/primary/black-spider-monkey.jpg");
    MediaItemDb mediaItem2 = new MediaItemDb();
    mediaItem2.setMimeType("image/jpeg");
    mediaItem2.setType(MediaItem.Type.IMAGE);
    mediaItem2.setUrl("http://image.guardian.co.uk/sys-images/Guardian/Pix/gallery/2002/01/03/monkey300.jpg");
    mediaItems.add(mediaItem1);
    mediaItems.add(mediaItem2);
    activity2.setMediaItems(mediaItems);
    activity2.setStreamTitle("jane's photos");
    activity2.setTitle("Jane just posted a photo of a monkey");
    entityManager.persist(activity2);
   
    ActivityDb activity3 = buildActivityTemplate("jane.doe", "2");   
    activity3.setBody("or is it you?");
    List<MediaItem> mediaItems2 = new ArrayList<MediaItem>();
    MediaItemDb mediaItem3 = new MediaItemDb();
    mediaItem3.setMimeType("image/jpeg");
    mediaItem3.setType(MediaItem.Type.IMAGE);
    mediaItem3.setUrl("http://www.funnyphotos.net.au/images/fancy-dress-dog-yoda-from-star-wars1.jpg");
    mediaItems2.add(mediaItem3);
    activity3.setMediaItems(mediaItems2);
    activity3.setStreamTitle("jane's photos");
    activity3.setTitle("Jane says George likes yoda!");
    entityManager.persist(activity3);
   
    // Build and persist application data test data
    ApplicationDb testApplication = new ApplicationDb();
    testApplication.setId("app");
View Full Code Here

    applicationDataMap.setValues(values);
    return applicationDataMap;
  }
 
  private ActivityDb buildCanonicalActivity(String userId, String id) {
    ActivityDb activity = buildActivityTemplate(userId, id);
   
    // Common attributes
    activity.setPriority(0.7F);
    activity.setStreamFaviconUrl("http://upload.wikimedia.org/wikipedia/commons/0/02/Nuvola_apps_edu_languages.gif");
    activity.setStreamSourceUrl("http://www.example.org/canonical/streamsource");
    activity.setStreamTitle("All my activities");
    activity.setStreamUrl("http://www.example.org/canonical/activities");
       
    // Set othe attributes depending on given id
    if ("1".equals(id)) {         
      activity.setBody("Went rafting");
      activity.setBodyId("1");
      activity.setExternalId("http://www.example.org/123456");
      List<MediaItem> mediaItems = new ArrayList<MediaItem>();
      MediaItemDb mediaItem1 = new MediaItemDb();
      mediaItem1.setMimeType("image/*");
      mediaItem1.setType(MediaItem.Type.IMAGE);
      mediaItem1.setUrl("http://upload.wikimedia.org/wikipedia/commons/thumb/7/77/Rafting_em_Brotas.jpg/800px-Rafting_em_Brotas.jpg");
      MediaItemDb mediaItem2 = new MediaItemDb();
      mediaItem2.setMimeType("audio/mpeg");
      mediaItem2.setType(MediaItem.Type.AUDIO);
      mediaItem2.setUrl("http://www.archive.org/download/testmp3testfile/mpthreetest.mp3");
      mediaItems.add(mediaItem1);
      mediaItems.add(mediaItem2);
      activity.setMediaItems(mediaItems);
      activity.setPostedTime(1111111111L);
      Map<String, String> templateParams = new MapMaker().makeMap();
      templateParams.put("small", "true");
      templateParams.put("otherContent", "and got wet");
      activity.setTemplateParams(templateParams);
      activity.setTitle("My trip");
      activity.setTitleId("1");
      activity.setUpdated(new Date());
      activity.setUrl("http://www.example.org/canonical/activities/1");
     
    } else if ("2".equals(id)) {     
      activity.setBody("Went skiing");
      activity.setBodyId("2");
      activity.setExternalId("http://www.example.org/123457");
      List<MediaItem> mediaItems = new ArrayList<MediaItem>();
      activity.setMediaItems(mediaItems);
      activity.setPostedTime(1111111112L);
      Map<String, String> templateParams = new MapMaker().makeMap();
      templateParams.put("small", "true");
      templateParams.put("otherContent", "and went fast");
      activity.setTemplateParams(templateParams);
      activity.setTitle("My next trip");
      activity.setTitleId("2");
      activity.setUpdated(new Date());
      activity.setUrl("http://www.example.org/canonical/activities/2");
    }
    return activity;
  }
View Full Code Here

    }
    return activity;
  }

  private ActivityDb buildActivityTemplate(String userId, String id) {
    ActivityDb activity = new ActivityDb();
    activity.setUserId(userId);
    activity.setId(id);   
    return activity;
  }
View Full Code Here

    String uid = SPIUtils.getUserList(userId, token);

    try {
      // Map activity into a new ActivityDb instance
      // TODO Could we use dozer to do this mapping instead, for future-proofing reasons?
      ActivityDb activityDb = new ActivityDb();
      activityDb.setPostedTime(new Date().getTime());
      activityDb.setAppId(appId);
      activityDb.setUserId(uid);
      activityDb.setId(activity.getId());
      activityDb.setBodyId(activity.getBodyId());
      activityDb.setBody(activity.getBody());
      activityDb.setExternalId(activity.getExternalId());
      activityDb.setTitleId(activity.getTitleId());
      activityDb.setTitle(activity.getTitle());
      activityDb.setUpdated(new Date());
      activityDb.setPriority(activity.getPriority());
      activityDb.setStreamFaviconUrl(activity.getStreamFaviconUrl());
      activityDb.setStreamSourceUrl(activity.getStreamSourceUrl());
      activityDb.setStreamTitle(activity.getStreamTitle());
      activityDb.setStreamUrl(activity.getStreamUrl());
      activityDb.setUrl(activity.getUrl());
      if(activity.getMediaItems() != null) {
        List<MediaItem> mediaItems = new ArrayList<MediaItem>();
        for(MediaItem m : activity.getMediaItems()) {
          MediaItemDb mediaItem = new MediaItemDb();
          mediaItem.setMimeType(m.getMimeType());
          mediaItem.setType(m.getType());
          mediaItem.setUrl(m.getUrl());
          mediaItems.add(mediaItem);
        }
        activityDb.setMediaItems(mediaItems);
      }
      if (activity.getTemplateParams() != null) {
        activityDb.setTemplateParams(activity.getTemplateParams());
      }

      // TODO How should transactions be managed? Should samples be using warp-persist instead?
      if (!entityManager.getTransaction().isActive()) {
        entityManager.getTransaction().begin();
View Full Code Here

    // Build and persist activity test data
    entityManager.persist(buildCanonicalActivity("canonical", "1"));
    entityManager.persist(buildCanonicalActivity("canonical", "2"));

    ActivityDb activity1 = buildActivityTemplate("john.doe", "1");
    activity1.setTitle("yellow");
    activity1.setBody("what a color!");
    entityManager.persist(activity1);

    ActivityDb activity2 = buildActivityTemplate("jane.doe", "1");
    activity2.setBody("and she thinks you look like him");
    List<MediaItem> mediaItems = new ArrayList<MediaItem>();
    MediaItemDb mediaItem1 = new MediaItemDb();
    mediaItem1.setMimeType("image/jpeg");
    mediaItem1.setType(MediaItem.Type.IMAGE);
    mediaItem1.setUrl("http://animals.nationalgeographic.com/staticfiles/NGS/Shared/StaticFiles/animals/images/primary/black-spider-monkey.jpg");
    MediaItemDb mediaItem2 = new MediaItemDb();
    mediaItem2.setMimeType("image/jpeg");
    mediaItem2.setType(MediaItem.Type.IMAGE);
    mediaItem2.setUrl("http://image.guardian.co.uk/sys-images/Guardian/Pix/gallery/2002/01/03/monkey300.jpg");
    mediaItems.add(mediaItem1);
    mediaItems.add(mediaItem2);
    activity2.setMediaItems(mediaItems);
    activity2.setStreamTitle("jane's photos");
    activity2.setTitle("Jane just posted a photo of a monkey");
    entityManager.persist(activity2);

    ActivityDb activity3 = buildActivityTemplate("jane.doe", "2");
    activity3.setBody("or is it you?");
    List<MediaItem> mediaItems2 = new ArrayList<MediaItem>();
    MediaItemDb mediaItem3 = new MediaItemDb();
    mediaItem3.setMimeType("image/jpeg");
    mediaItem3.setType(MediaItem.Type.IMAGE);
    mediaItem3.setUrl("http://www.funnyphotos.net.au/images/fancy-dress-dog-yoda-from-star-wars1.jpg");
    mediaItems2.add(mediaItem3);
    activity3.setMediaItems(mediaItems2);
    activity3.setStreamTitle("jane's photos");
    activity3.setTitle("Jane says George likes yoda!");
    entityManager.persist(activity3);

    // Build and persist application data test data
    ApplicationDb testApplication = new ApplicationDb();
    testApplication.setId("app");
View Full Code Here

    applicationDataMap.setValues(values);
    return applicationDataMap;
  }

  private ActivityDb buildCanonicalActivity(String userId, String id) {
    ActivityDb activity = buildActivityTemplate(userId, id);

    // Common attributes
    activity.setPriority(0.7F);
    activity.setStreamFaviconUrl("http://upload.wikimedia.org/wikipedia/commons/0/02/Nuvola_apps_edu_languages.gif");
    activity.setStreamSourceUrl("http://www.example.org/canonical/streamsource");
    activity.setStreamTitle("All my activities");
    activity.setStreamUrl("http://www.example.org/canonical/activities");

    // Set othe attributes depending on given id
    if ("1".equals(id)) {
      activity.setBody("Went rafting");
      activity.setBodyId("1");
      activity.setExternalId("http://www.example.org/123456");
      List<MediaItem> mediaItems = new ArrayList<MediaItem>();
      MediaItemDb mediaItem1 = new MediaItemDb();
      mediaItem1.setMimeType("image/*");
      mediaItem1.setType(MediaItem.Type.IMAGE);
      mediaItem1.setUrl("http://upload.wikimedia.org/wikipedia/commons/thumb/7/77/Rafting_em_Brotas.jpg/800px-Rafting_em_Brotas.jpg");
      MediaItemDb mediaItem2 = new MediaItemDb();
      mediaItem2.setMimeType("audio/mpeg");
      mediaItem2.setType(MediaItem.Type.AUDIO);
      mediaItem2.setUrl("http://www.archive.org/download/testmp3testfile/mpthreetest.mp3");
      mediaItems.add(mediaItem1);
      mediaItems.add(mediaItem2);
      activity.setMediaItems(mediaItems);
      activity.setPostedTime(1111111111L);
      Map<String, String> templateParams = new MapMaker().makeMap();
      templateParams.put("small", "true");
      templateParams.put("otherContent", "and got wet");
      activity.setTemplateParams(templateParams);
      activity.setTitle("My trip");
      activity.setTitleId("1");
      activity.setUpdated(new Date());
      activity.setUrl("http://www.example.org/canonical/activities/1");

    } else if ("2".equals(id)) {
      activity.setBody("Went skiing");
      activity.setBodyId("2");
      activity.setExternalId("http://www.example.org/123457");
      List<MediaItem> mediaItems = new ArrayList<MediaItem>();
      activity.setMediaItems(mediaItems);
      activity.setPostedTime(1111111112L);
      Map<String, String> templateParams = new MapMaker().makeMap();
      templateParams.put("small", "true");
      templateParams.put("otherContent", "and went fast");
      activity.setTemplateParams(templateParams);
      activity.setTitle("My next trip");
      activity.setTitleId("2");
      activity.setUpdated(new Date());
      activity.setUrl("http://www.example.org/canonical/activities/2");
    }
    return activity;
  }
View Full Code Here

TOP

Related Classes of org.apache.shindig.social.opensocial.jpa.ActivityDb

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.