Package org.apache.shindig.social.opensocial.model

Examples of org.apache.shindig.social.opensocial.model.Person


      for (int i = 0; i < people.length(); i++) {
        JSONObject person = people.getJSONObject(i);
        System.out.println("GadgetContainerOpensocialService:" +
                person.get(Person.Field.ID.toString()) +"-"+ id.getUserId(token));
        if (id != null && person.get(Person.Field.ID.toString()).equals(id.getUserId(token))) {
          Person personObj = filterFields(person, fields, Person.class);
          Map<String, Object> appData = getPersonAppData(person.getString(Person.Field.ID
              .toString()), fields);
          personObj.setAppData(appData);

          return ImmediateFuture.newInstance(personObj);
        }
      }
      throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Person '" + id.getUserId(token) + "' not found");
View Full Code Here


    if (!entityManager.getTransaction().isActive()) {
      entityManager.getTransaction().begin();
    }
 
    // Build person with dummy data
    Person canonical = buildCanonicalPerson();   
    Person johnDoe = buildPerson("john.doe", "Johnny", Person.Gender.male, true, "Doe", "John", "John Doe");
    Person janeDoe = buildPerson("jane.doe", "Janey", Person.Gender.female, true, "Doe", "Jane", "Jane Doe");
    Person georgeDoe = buildPerson("george.doe", "Georgey", Person.Gender.male, true, "Doe", "George", "George Doe");
    Person mario = buildPerson("mario.rossi", "Mario", Person.Gender.male, true, "Rossi", "Mario", "Mario Rossi");
    Person maija = buildPerson("maija.m", "Maija", Person.Gender.female, true, "Meik\u00e4l\u00e4inen", "Maija", "Maija Meik\u00e4l\u00e4inen");
   
    // Persist each person
    entityManager.persist(canonical);
    entityManager.persist(johnDoe);
    entityManager.persist(janeDoe);   
View Full Code Here

    return friendDb;
  }

  private Person buildPerson(String id, String displayName, Person.Gender gender, boolean hasApp,
      String familyName, String givenName, String formatted) throws Exception {
    Person person = buildPersonTemplate(id);
    person.setDisplayName(displayName);
    person.setGender(gender);
    person.setHasApp(hasApp);
   
    NameDb name = new NameDb();
    name.setFamilyName(familyName);
    name.setGivenName(givenName);
    name.setFormatted(formatted);
    person.setName(name);
   
    return person;
  }
View Full Code Here

   
    return person;
  }
 
  private Person buildCanonicalPerson() throws Exception {
    Person person = buildPersonTemplate("canonical");
    person.setAboutMe("I have an example of every piece of data");   
    person.setActivities(asList("Coding Shindig"));   
    List<Address> addresses = new ArrayList<Address>();
    PersonAddressDb address = new PersonAddressDb();
    address.setCountry("US");
    address.setLatitude(28.3043F);
    address.setLongitude(143.0859F);
    address.setLocality("who knows");
    address.setPostalCode("12345");
    address.setRegion("Apache, CA");
    address.setStreetAddress("1 OpenStandards Way");
    address.setType("home");
    address.setFormatted("PoBox 3565, 1 OpenStandards Way, Apache, CA");
    // address.setPerson(person);
    addresses.add(address);
    person.setAddresses(addresses);   
    person.setAge(33);
   
    BodyTypeDb bodyType = new BodyTypeDb();
    bodyType.setBuild("svelte");
    bodyType.setEyeColor("blue");
    bodyType.setHairColor("black");
    bodyType.setHeight(1.84F);
    bodyType.setWeight(74F);
    person.setBodyType(bodyType);
   
    person.setBooks(asList("The Cathedral & the Bazaar","Catch 22"));
    person.setCars(asList("beetle","prius"));
    person.setChildren("3");
   
    AddressDb currentLocation = new AddressDb();
    currentLocation.setLatitude(48.858193F);
    currentLocation.setLongitude(2.29419F);
    person.setCurrentLocation(currentLocation);
       
    person.setBirthday(buildDate("1975-01-01"));
    person.setDisplayName("Shin Digg");
    person.setDrinker(new EnumDb<Drinker>(Drinker.SOCIALLY));
   
    List<ListField> emails = new ArrayList<ListField>();
    EmailDb email = new EmailDb();
    email.setValue("shindig-dev@incubator.apache.org");
    email.setType("work");
    emails.add(email);
    person.setEmails(emails);
  
    person.setEthnicity("developer");   
    person.setFashion("t-shirts");   
    person.setFood(asList("sushi","burgers"));   
    person.setGender(Person.Gender.male);
    person.setHappiestWhen("coding");   
    person.setHasApp(true);   
    person.setHeroes(asList("Doug Crockford", "Charles Babbage"));   
    person.setHumor("none to speak of");   
    person.setInterests(asList("PHP","Java"));   
    person.setJobInterests("will work for beer");
   
    List<Organization> organizations = new ArrayList<Organization>();
   
    PersonOrganizationDb organization1 = new PersonOrganizationDb();
    OrganizationAddressDb orgAddress1 = new OrganizationAddressDb();
    orgAddress1.setFormatted("1 Shindig Drive");
    organization1.setAddress(orgAddress1);
    organization1.setDescription("lots of coding");
    organization1.setEndDate(buildDate("2010-10-10"));
    organization1.setField("Software Engineering");
    organization1.setName("Apache.com");
    organization1.setSalary("$1000000000");
    organization1.setStartDate(buildDate("1995-01-01"));
    organization1.setSubField("Development");
    organization1.setTitle("Grand PooBah");
    organization1.setWebpage("http://incubator.apache.org/projects/shindig.html");
    organization1.setType("job");
   
    PersonOrganizationDb organization2 = new PersonOrganizationDb();
    OrganizationAddressDb orgAddress2 = new OrganizationAddressDb();
    orgAddress2.setFormatted("1 Skid Row");
    organization2.setAddress(orgAddress2);
    organization2.setDescription("");
    organization2.setEndDate(buildDate("1995-01-01"));
    organization2.setField("College");
    organization2.setName("School of hard Knocks");
    organization2.setSalary("$100");
    organization2.setStartDate(buildDate("1991-01-01"));
    organization2.setSubField("Lab Tech");
    organization2.setTitle("Gopher");
    organization2.setWebpage("");
    organization2.setType("job");
   
    organizations.add(organization1);
    organizations.add(organization2);
    person.setOrganizations(organizations);
   
    person.setLanguagesSpoken(asList("English","Dutch","Esperanto"));
    person.setUpdated(new Date());
    person.setLivingArrangement("in a house");
       
    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("Iron Man", "Nosferatu"));
    person.setMusic(asList("Chieftains","Beck"));
   
    NameDb name = new NameDb();
    name.setAdditionalName("H");
    name.setFamilyName("Digg");
    name.setGivenName("Shin");
    name.setHonorificPrefix("Sir");
    name.setHonorificSuffix("Social Butterfly");
    name.setFormatted("Sir Shin H. Digg Social Butterfly");
    person.setName(name);
   
    person.setNetworkPresence(new EnumDb<NetworkPresence>(NetworkPresence.ONLINE));
   
    person.setNickname("diggy");
    person.setPets("dog,cat");
   
    List<ListField> phoneNumbers = new ArrayList<ListField>();
    PhoneDb phone1 = new PhoneDb();
    phone1.setValue("111-111-111");
    phone1.setType("work");
    PhoneDb phone2 = new PhoneDb();
    phone2.setValue("999-999-999");
    phone2.setType("mobile");
    phoneNumbers.add(phone1);
    phoneNumbers.add(phone2);
    person.setPhoneNumbers(phoneNumbers);
   
    person.setPoliticalViews("open leaning");   
    person.setProfileSong(buildUrl("http://www.example.org/songs/OnlyTheLonely.mp3", "Feelin' blue", "road"));
    person.setProfileUrl("http://www.example.org/?id=1");
    person.setProfileVideo(buildUrl("http://www.example.org/videos/Thriller.flv", "Thriller", "video"));
  
    person.setQuotes(asList("I am therfore I code", "Doh!"));
    person.setRelationshipStatus("married to my job");
    person.setReligion("druidic");
    person.setRomance("twice a year");
    person.setScaredOf("COBOL");
    person.setSexualOrientation("north");
    person.setSmoker(new EnumDb<Smoker>(Smoker.NO));   
    person.setSports(asList("frisbee","rugby"));
    person.setStatus("happy");
    person.setTags(asList("C#","JSON","template"));
    person.setUtcOffset(-8L);
    person.setTurnOffs(asList("lack of unit tests","cabbage"));
    person.setTurnOns(asList("well document code"));
    person.setTvShows(asList("House","Battlestar Galactica"));
   
    List<Url> urls = new ArrayList<Url>();
    urls.add(buildUrl("http://www.example.org/?id=1", "my profile", "Profile"));
    urls.add(buildUrl("http://www.example.org/pic/?id=1", "my awesome picture", "Thumbnail"));
    person.setUrls(urls);
   
    List<ListField> photos = new ArrayList<ListField>();
    PhotoDb photo = new PhotoDb();
    photo.setValue("http://www.example.org/pic/?id=1");
    photo.setType("thumbnail");
    photos.add(photo);
    person.setPhotos(photos);
   
    return person;
  }
View Full Code Here

    name.setFamilyName("Digg");
    name.setGivenName("Shin");
    name.setHonorificPrefix("Sir");
    name.setHonorificSuffix("Social Butterfly");
   
    Person canonical = new PersonImpl("canonical", "Shin Digg", name);

    canonical.setAboutMe("I have an example of every piece of data");
    canonical.setActivities(Lists.newArrayList("Coding Shindig"));

    Address address = new AddressImpl("PoBox 3565, 1 OpenStandards Way, Apache, CA");
    address.setCountry("US");
    address.setLatitude(28.3043F);
    address.setLongitude(143.0859F);
    address.setLocality("who knows");
    address.setPostalCode("12345");
    address.setRegion("Apache, CA");
    address.setStreetAddress("1 OpenStandards Way");
    address.setType("home");
    address.setFormatted("PoBox 3565, 1 OpenStandards Way, Apache, CA");
    canonical.setAddresses(Lists.newArrayList(address));

    canonical.setAge(33);
    BodyTypeImpl bodyType = new BodyTypeImpl();
    bodyType.setBuild("svelte");
    bodyType.setEyeColor("blue");
    bodyType.setHairColor("black");
    bodyType.setHeight(1.84F);
    bodyType.setWeight(74F);
    canonical.setBodyType(bodyType);

    canonical.setBooks(Lists.newArrayList("The Cathedral & the Bazaar", "Catch 22"));
    canonical.setCars(Lists.newArrayList("beetle", "prius"));
    canonical.setChildren("3");
    AddressImpl location = new AddressImpl();
    location.setLatitude(48.858193F);
    location.setLongitude(2.29419F);
    canonical.setCurrentLocation(location);

    canonical.setBirthday(buildDate("1975-01-01"));
    canonical.setDrinker(new EnumImpl<Drinker>(Drinker.SOCIALLY));
    ListField email = new ListFieldImpl("work", "shindig-dev@incubator.apache.org");
    canonical.setEmails(Lists.newArrayList(email));

    canonical.setEthnicity("developer");
    canonical.setFashion("t-shirts");
    canonical.setFood(Lists.newArrayList("sushi", "burgers"));
    canonical.setGender(Person.Gender.male);
    canonical.setHappiestWhen("coding");
    canonical.setHasApp(true);
    canonical.setHeroes(Lists.newArrayList("Doug Crockford", "Charles Babbage"));
    canonical.setHumor("none to speak of");
    canonical.setInterests(Lists.newArrayList("PHP", "Java"));
    canonical.setJobInterests("will work for beer");

    Organization job1 = new OrganizationImpl();
    job1.setAddress(new AddressImpl("1 Shindig Drive"));
    job1.setDescription("lots of coding");
    job1.setEndDate(buildDate("2010-10-10"));
    job1.setField("Software Engineering");
    job1.setName("Apache.com");
    job1.setSalary("$1000000000");
    job1.setStartDate(buildDate("1995-01-01"));
    job1.setSubField("Development");
    job1.setTitle("Grand PooBah");
    job1.setWebpage("http://incubator.apache.org/projects/shindig.html");
    job1.setType("job");

    Organization job2 = new OrganizationImpl();
    job2.setAddress(new AddressImpl("1 Skid Row"));
    job2.setDescription("");
    job2.setEndDate(buildDate("1995-01-01"));
    job2.setField("College");
    job2.setName("School of hard Knocks");
    job2.setSalary("$100");
    job2.setStartDate(buildDate("1991-01-01"));
    job2.setSubField("Lab Tech");
    job2.setTitle("Gopher");
    job2.setWebpage("");
    job2.setType("job");

    canonical.setOrganizations(Lists.newArrayList(job1, job2));

    canonical.setUpdated(new Date());
    canonical.setLanguagesSpoken(Lists.newArrayList("English", "Dutch", "Esperanto"));
    canonical.setLivingArrangement("in a house");
    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);
    canonical.setLookingFor(lookingFor);
    canonical.setMovies(Lists.newArrayList("Iron Man", "Nosferatu"));
    canonical.setMusic(Lists.newArrayList("Chieftains", "Beck"));
    canonical.setNetworkPresence(new EnumImpl<NetworkPresence>(NetworkPresence.ONLINE));
    canonical.setNickname("diggy");
    canonical.setPets("dog,cat");
    canonical.setPhoneNumbers(Lists.<ListField> newArrayList(new ListFieldImpl("work",
        "111-111-111"), new ListFieldImpl("mobile", "999-999-999")));

    canonical.setPoliticalViews("open leaning");
    canonical.setProfileSong(new UrlImpl("http://www.example.org/songs/OnlyTheLonely.mp3",
        "Feelin' blue", "road"));
    canonical.setProfileVideo(new UrlImpl("http://www.example.org/videos/Thriller.flv",
        "Thriller", "video"));

    canonical.setQuotes(Lists.newArrayList("I am therfore I code", "Doh!"));
    canonical.setRelationshipStatus("married to my job");
    canonical.setReligion("druidic");
    canonical.setRomance("twice a year");
    canonical.setScaredOf("COBOL");
    canonical.setSexualOrientation("north");
    canonical.setSmoker(new EnumImpl<Smoker>(Smoker.NO));
    canonical.setSports(Lists.newArrayList("frisbee", "rugby"));
    canonical.setStatus("happy");
    canonical.setTags(Lists.newArrayList("C#", "JSON", "template"));
    canonical.setThumbnailUrl("http://www.example.org/pic/?id=1");
    canonical.setUtcOffset(-8L);
    canonical.setTurnOffs(Lists.newArrayList("lack of unit tests", "cabbage"));
    canonical.setTurnOns(Lists.newArrayList("well document code"));
    canonical.setTvShows(Lists.newArrayList("House", "Battlestar Galactica"));

    canonical.setUrls(Lists.<Url>newArrayList(
        new UrlImpl("http://www.example.org/?id=1", "my profile", "Profile"),
        new UrlImpl("http://www.example.org/pic/?id=1", "my awesome picture", "Thumbnail")));
   
    return canonical;
  }
View Full Code Here

    Query q = entiyManager.createNamedQuery(PersonDb.FINDBY_PERSONID);
    q.setParameter(PersonDb.PARAM_PERSONID, uid);
    q.setFirstResult(0);
    q.setMaxResults(1);
    List<?> plist = q.getResultList();
    Person person = null;
    if (plist != null && plist.size() > 0) {
      person = (Person) plist.get(0);
    }
    return ImmediateFuture.newInstance(person);
  }
View Full Code Here

  private static final Logger log = Logger.getLogger("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();
    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(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

        if (!idSet.contains(person.get(Person.Field.ID.toString()))) {
          continue;
        }

        // Add group support later
        Person personObj = filterFields(person, fields, Person.class);
        Map<String, Object> appData = getPersonAppData(
            person.getString(Person.Field.ID.toString()), fields);
        personObj.setAppData(appData);

        result.add(personObj);
      }

      if (GroupId.Type.self == groupId.getType() && result.isEmpty()) {
View Full Code Here

      JSONArray people = db.getJSONArray(PEOPLE_TABLE);

      for (int i = 0; i < people.length(); i++) {
        JSONObject person = people.getJSONObject(i);
        if (id != null && person.get(Person.Field.ID.toString()).equals(id.getUserId(token))) {
          Person personObj = filterFields(person, fields, Person.class);
          Map<String, Object> appData = getPersonAppData(person.getString(Person.Field.ID
              .toString()), fields);
          personObj.setAppData(appData);

          return ImmediateFuture.newInstance(personObj);
        }
      }
      throw new ProtocolException(HttpServletResponse.SC_BAD_REQUEST, "Person not found");
View Full Code Here

        expect(repository.get(Long.parseLong(ID_1))).andReturn(dbPerson);
        replay(repository);

        Future<Person> personFuture = service.getPerson(id, fields, token);
        assertThat(personFuture, is(not(nullValue())));
        Person person = personFuture.get();
        assertThat(person, is(not(nullValue())));
        assertThat(person, is(instanceOf(FieldRestrictingPerson.class)));
        assertThat(person.getId(), is(equalTo(ID_1)));
        assertThat(person.getHappiestWhen(), is(equalTo(HAPPIEST_WHEN)));
        assertThat(person.getDisplayName(), is(equalTo(DISPLAY_NAME)));
    }
View Full Code Here

TOP

Related Classes of org.apache.shindig.social.opensocial.model.Person

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.