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

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


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

        Future<Person> personFuture = service.getPerson(id, null, 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


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

        Future<Person> personFuture = service.getPerson(id, null, 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

    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", "dev@shindig.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://shindig.apache.org/");
    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.isEmpty()) {
      person = (Person) plist.get(0);
    }
    return ImmediateFuture.newInstance(person);
  }
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 ParseException {
    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 ParseException {
    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("dev@shindig.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://shindig.apache.org/");
    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

    SpiTestUtil.assertPersonEquals(people.get(0), "jane.doe", "Jane Doe");
  }

  @Test
  public void testViewerCanUpdatePerson() throws Exception {
    Person p = SpiTestUtil.buildCanonicalPerson();
    p.setThumbnailUrl("http://newthumbnail.url");
    this.personServiceDb.updatePerson(new UserId(Type.userId, "canonical"),
        p, SpiTestUtil.CANONICAL_PERSON_SECURITY_TOKEN);

    Future<Person> person = this.personServiceDb.getPerson(new UserId(Type.userId, "canonical"), ImmutableSet.of("id","displayName","thumbnailUrl"), SpiTestUtil.DEFAULT_TEST_SECURITY_TOKEN);
    assertEquals("http://newthumbnail.url", person.get().getThumbnailUrl());
View Full Code Here

    assertEquals("http://newthumbnail.url", person.get().getThumbnailUrl());
  }

  @Test
  public void testViewerNotAllowedUpdatePerson() throws Exception {
    Person p = SpiTestUtil.buildCanonicalPerson();
    p.setThumbnailUrl("http://newthumbnail.url");

    try {
      this.personServiceDb.updatePerson(new UserId(Type.userId, "canonical"),
          p, SpiTestUtil.JOHN_DOE_SECURITY_TOKEN);
      org.junit.Assert.fail();
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

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.