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

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


  private static final Log log = LogFactory.getLog("shindig-db-test");

  public Person createPerson(int i, long key, Random random) {

    Person person = new PersonDb();
    person.setAboutMe("About Me " + i);
    String personId = getPersonId(i, key);

    person.setId(personId);
    person.setActivities(getList("Activities"));
    int age = random.nextInt(105);
    Calendar c = new GregorianCalendar();
    c.setTimeInMillis(System.currentTimeMillis());
    c.add(Calendar.YEAR, -age);
    c.add(Calendar.MONTH, 12 - i % 12);
    List<Address> a = Lists.newArrayList();
    a.add(getNewPersonAddress(i));
    a.add(getNewPersonAddress(i + 2));
    person.setAddresses(a);
    person.setAge(random.nextInt(105));
    person.setBodyType(getNewBodyType(i));
    person.setBooks(getList("Books"));
    person.setCars(getList("Cars"));
    person.setChildren("Yes");
    person.setCurrentLocation(getNewAddress(i + 5));
    person.setBirthday(c.getTime());
    person.setDrinker(new EnumImpl<Drinker>(Drinker.OCCASIONALLY));
    List<ListField> emails = Lists.newArrayList();
    emails.add(getNewEmail(i));
    emails.add(getNewEmail(i + 1));
    person.setEmails(emails);
    person.setEthnicity("ethinicity");
    person.setFashion("fashion");
    person.setFood(getList("Food"));
    person.setGender(Gender.female);
    person.setHappiestWhen("sailing");
    person.setHeroes(getList("Heroes"));
    person.setHumor("hahaha");
    person.setInterests(getList("Interests"));
    person.setIsOwner(true);
    person.setIsViewer(true);
    person.setJobInterests("job interest");
    List<Organization> organizations = Lists.newArrayList();
    organizations.add(getPersonOrganization(i, "job"));
    organizations.add(getPersonOrganization(i + 1, "job"));
    organizations.add(getPersonOrganization(i + 2, "job"));
    person.setOrganizations(organizations);
    person.setLanguagesSpoken(getList("LanguagesSpoken"));
    person.setLivingArrangement("living Arrangement");
    List<Enum<LookingFor>> lookingFor = Lists.newArrayList();
    lookingFor.add(new EnumImpl<LookingFor>(LookingFor.RANDOM));
    lookingFor.add(new EnumImpl<LookingFor>(LookingFor.NETWORKING));
    person.setLookingFor(lookingFor);
    person.setMovies(getList("Movies"));
    person.setMusic(getList("music"));
    person.setName(getNewName(i));
    person.setNickname("NickName");
    person.setPets("Pets");
    List<ListField> phoneNumbers = Lists.newArrayList();
    phoneNumbers.add(getNewPhone(i));
    phoneNumbers.add(getNewPhone(i * 3));

    person.setPhoneNumbers(phoneNumbers);
    person.setPoliticalViews("politicalViews");
    person.setProfileSong(getNewUrl(i));
    person.setProfileUrl("Profile URL");
    person.setProfileVideo(getNewUrl(i * 2));
    person.setQuotes(getList("Quites"));
    person.setRelationshipStatus("relationship");
    person.setReligion("religion");
    person.setRomance("romance");
    person.setScaredOf("scaredOf");
    List<Organization> organizations2 = person.getOrganizations();
    organizations2.add(getPersonOrganization(i + 5, "school"));
    organizations2.add(getPersonOrganization(i + 6, "school"));
    organizations2.add(getPersonOrganization(i + 7, "school"));
    person.setOrganizations(organizations2);
    person.setSexualOrientation("sexualOrientation");
    person.setSmoker(new EnumImpl<Smoker>(Smoker.QUITTING));
    person.setSports(getList("Sports"));
    person.setStatus("Status");
    person.setTags(getList("tags"));

    List<ListField> photos = Lists.newArrayList();
    photos.add(getNewPhoto(i));
    photos.add(getNewPhoto(i * 3));

    person.setPhotos(photos);
    person.setUtcOffset(1L);
    person.setTurnOffs(getList("TurnOff"));
    person.setTurnOns(getList("TurnOns"));
    person.setTvShows(getList("TvShows"));
    person.setUpdated(new Date());
    List<Url> urls = Lists.newArrayList();
    urls.add(getNewUrl(i * 4));
    urls.add(getNewUrl(i * 5));
    urls.add(getNewUrl(i * 6));
    person.setUrls(urls);

    // TODO: setActivity
    // TODO: person.setAccounts(accounts);
    // TODO: person.setActivities(activities);
    // TODO: person.setAddresses(addresses);
View Full Code Here


        populateDatabase();
    }

    private void populateDatabase() {
        PersonDb person = new PersonDb();
        person.setId("canonical");
        Name name = new RaveNameImpl();
        name.setFamilyName("canonical");
        name.setGivenName("canonical");
        person.setName(name);
        person.setDrinker(new EnumDb<Drinker>(Drinker.NO));
        person.setGender(Gender.male);
        person.setNetworkPresence(new EnumDb<NetworkPresence>(NetworkPresence.ONLINE));
        person.setAboutMe("About me");
        person.setAge(25);
        person.setBirthday(new Date());
        person.setNickname("hoosier");
        person.setSmoker(new EnumDb<Smoker>(Smoker.NO));

        // EntityManager em = emf.createEntityManager();
        EntityManager em = getEntityManager();
        em.getTransaction().begin();
        em.persist(person);
View Full Code Here

   
    return person;
  }
 
  private Person buildPersonTemplate(String personId) {
    PersonDb person = new PersonDb();
    person.setId(personId);
    person.setAboutMe("");
   
    person.setActivities(asList(""));
   
    List<Address> addresses = new ArrayList<Address>();
    PersonAddressDb address = new PersonAddressDb();
    address.setCountry("");
    address.setLatitude(0F);
    address.setLongitude(0F);
    address.setLocality("");
    address.setPostalCode("");
    address.setRegion("");
    address.setStreetAddress("");
    address.setType("");
    address.setFormatted("");
    // TODO This causes problems when converting back to json.
    // address.setPerson(person);
    addresses.add(address);
    person.setAddresses(addresses);
   
    person.setAge(0);
   
    BodyTypeDb bodyType = new BodyTypeDb();
    bodyType.setBuild("");
    bodyType.setEyeColor("");
    bodyType.setHairColor("");
    bodyType.setHeight(0F);
    bodyType.setWeight(0F);
    person.setBodyType(bodyType);
   
    person.setBooks(asList(""));
    person.setCars(asList(""));
    person.setChildren("");
   
    AddressDb currentLocation = new AddressDb();
    currentLocation.setLatitude(0F);
    currentLocation.setLongitude(0F);
    person.setCurrentLocation(currentLocation);
   
    person.setBirthday(new Date());
    person.setDisplayName("");
    person.setDrinker(new EnumDb<Drinker>(Drinker.SOCIALLY));
   
    List<ListField> emails = new ArrayList<ListField>();
    EmailDb email = new EmailDb();
    email.setValue("");
    email.setType("");
    emails.add(email);
    person.setEmails(emails);
   
    person.setEthnicity("");   
    person.setFashion("");   
    person.setFood(asList(""));   
    person.setGender(Person.Gender.male);
    person.setHappiestWhen("");   
    person.setHasApp(true);   
    person.setHeroes(asList(""));   
    person.setHumor("");   
    person.setInterests(asList(""));   
    person.setJobInterests("");
   
    List<Organization> organizations = new ArrayList<Organization>();
   
    PersonOrganizationDb organization1 = new PersonOrganizationDb();
    OrganizationAddressDb orgAddress1 = new OrganizationAddressDb();
    orgAddress1.setFormatted("");
    organization1.setAddress(orgAddress1);
    organization1.setDescription("");
    organization1.setEndDate(new Date());
    organization1.setField("");
    organization1.setName("");
    organization1.setSalary("");
    organization1.setStartDate(new Date());
    organization1.setSubField("");
    organization1.setTitle("");
    organization1.setWebpage("");
    organization1.setType("");   
   
    organizations.add(organization1);
    person.setOrganizations(organizations);
   
    person.setLanguagesSpoken(asList(""));
    person.setUpdated(new Date());
    person.setLivingArrangement("");
       
    List<Enum<LookingFor>> lookingFor = Lists.newArrayList();
    Enum<LookingFor> lookingForOne = new EnumImpl<LookingFor>(LookingFor.RANDOM);
    Enum<LookingFor> lookingForTwo = new EnumImpl<LookingFor>(LookingFor.NETWORKING);
    lookingFor.add(lookingForOne);
    lookingFor.add(lookingForTwo);
    person.setLookingFor(lookingFor);
   
    person.setMovies(asList(""));
    person.setMusic(asList(""));
   
    NameDb name = new NameDb();
    name.setAdditionalName("");
    name.setFamilyName("");
    name.setGivenName("");
    name.setHonorificPrefix("");
    name.setHonorificSuffix("");
    name.setFormatted("");
    person.setName(name);
   
    person.setNetworkPresence(new EnumDb<NetworkPresence>(NetworkPresence.ONLINE));
    person.setNickname("");
    person.setPets("");
   
    List<ListField> phoneNumbers = new ArrayList<ListField>();
    PhoneDb phone1 = new PhoneDb();
    phone1.setValue("");
    phone1.setType("");
    PhoneDb phone2 = new PhoneDb();
    phone2.setValue("");
    phone2.setType("");
    phoneNumbers.add(phone1);
    phoneNumbers.add(phone2);
    person.setPhoneNumbers(phoneNumbers);
   
    person.setPoliticalViews("");   
    person.setProfileSong(buildUrl("", "Link Text", "URL"));
    person.setProfileUrl("");
    person.setProfileVideo(buildUrl("", "Link Text", "URL"));
    person.setQuotes(asList(""));
    person.setRelationshipStatus("");
    person.setReligion("");
    person.setRomance("");
    person.setScaredOf("");
    person.setSexualOrientation("");
    person.setSmoker(new EnumDb<Smoker>(Smoker.NO));   
    person.setSports(asList(""));
    person.setStatus("");
    person.setTags(asList(""));
    person.setUtcOffset(-8L);
    person.setTurnOffs(asList(""));
    person.setTurnOns(asList(""));
    person.setTvShows(asList(""));
   
    List<Url> urls = new ArrayList<Url>();
    urls.add(buildUrl("", "", "Profile"));
    urls.add(buildUrl("", "", "Thumbnail"));
    person.setUrls(urls);
   
    List<ListField> photos = new ArrayList<ListField>();
    PhotoDb photo = new PhotoDb();
    photo.setValue("");
    photo.setType("thumbnail");
    photos.add(photo);
    person.setPhotos(photos);
   
    return person;
  }
View Full Code Here

TOP

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

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.