Search in sources :

Example 6 with Addresses

use of org.orcid.jaxb.model.v3.dev1.record.Addresses in project ORCID-Source by ORCID.

the class PublicV3ApiServiceDelegatorTest method testViewAddresses.

@Test
public void testViewAddresses() {
    Response response = serviceDelegator.viewAddresses(ORCID);
    assertNotNull(response);
    Addresses addresses = (Addresses) response.getEntity();
    assertNotNull(addresses);
    assertNotNull(addresses.getLastModifiedDate());
    assertNotNull(addresses.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/address", addresses.getPath());
    assertEquals(1, addresses.getAddress().size());
    Address address = addresses.getAddress().get(0);
    assertNotNull(address);
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(address.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(9), address.getPutCode());
    assertNotNull(address.getCountry());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Visibility.PUBLIC.value(), address.getVisibility().value());
    assertEquals("/0000-0000-0000-0003/address/9", address.getPath());
    assertEquals("APP-5555555555555555", address.getSource().retrieveSourcePath());
}
Also used : Response(javax.ws.rs.core.Response) Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) Address(org.orcid.jaxb.model.v3.dev1.record.Address) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 7 with Addresses

use of org.orcid.jaxb.model.v3.dev1.record.Addresses in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method filterAddressesTest.

@Test
public void filterAddressesTest() {
    Addresses x = getAddressesElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.PUBLIC);
    assertEquals(3, x.getAddress().size());
    publicAPISecurityManagerV3.filter(x);
    assertEquals(3, x.getAddress().size());
    assertAllArePublic(x.getAddress());
    x = getAddressesElement(Visibility.PUBLIC, Visibility.PUBLIC, Visibility.LIMITED);
    assertEquals(3, x.getAddress().size());
    publicAPISecurityManagerV3.filter(x);
    assertEquals(2, x.getAddress().size());
    assertAllArePublic(x.getAddress());
    x = getAddressesElement(Visibility.PUBLIC, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, x.getAddress().size());
    publicAPISecurityManagerV3.filter(x);
    assertEquals(1, x.getAddress().size());
    assertAllArePublic(x.getAddress());
    x = getAddressesElement(Visibility.PRIVATE, Visibility.LIMITED, Visibility.PRIVATE);
    assertEquals(3, x.getAddress().size());
    publicAPISecurityManagerV3.filter(x);
    assertTrue(x.getAddress().isEmpty());
}
Also used : Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) Test(org.junit.Test)

Example 8 with Addresses

use of org.orcid.jaxb.model.v3.dev1.record.Addresses in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method getAddressesElement.

private Addresses getAddressesElement(Visibility... vs) {
    Addresses elements = new Addresses();
    for (Visibility v : vs) {
        Address element = new Address();
        element.setVisibility(v);
        if (elements.getAddress() == null) {
            elements.setAddress(new ArrayList<Address>());
        }
        elements.getAddress().add(element);
    }
    return elements;
}
Also used : Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) Address(org.orcid.jaxb.model.v3.dev1.record.Address) Visibility(org.orcid.jaxb.model.v3.dev1.common.Visibility)

Example 9 with Addresses

use of org.orcid.jaxb.model.v3.dev1.record.Addresses in project ORCID-Source by ORCID.

the class PublicAPISecurityManagerV3Test method checkIsPublicPersonTest.

@Test
public void checkIsPublicPersonTest() {
    Person p = getPersonElement();
    publicAPISecurityManagerV3.filter(p);
    // Nothing is filtered yet
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Addresses filtered
    p = getPersonElement();
    setVisibility(p.getAddresses().getAddress(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    // --- filtered ---
    assertNotNull(p.getAddresses());
    assertTrue(p.getAddresses().getAddress().isEmpty());
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Bio filtered
    p = getPersonElement();
    p.getBiography().setVisibility(Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNull(p.getBiography());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Emails filtered
    p = getPersonElement();
    setVisibility(p.getEmails().getEmails(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    // --- filtered ---
    assertNotNull(p.getEmails());
    assertTrue(p.getEmails().getEmails().isEmpty());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // External ids filtered
    p = getPersonElement();
    setVisibility(p.getExternalIdentifiers().getExternalIdentifiers(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNotNull(p.getExternalIdentifiers());
    assertTrue(p.getExternalIdentifiers().getExternalIdentifiers().isEmpty());
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Keywords filtered
    p = getPersonElement();
    setVisibility(p.getKeywords().getKeywords(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNotNull(p.getKeywords());
    assertTrue(p.getKeywords().getKeywords().isEmpty());
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Name filtered
    p = getPersonElement();
    p.getName().setVisibility(Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNull(p.getName());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Other names filtered
    p = getPersonElement();
    setVisibility(p.getOtherNames().getOtherNames(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    // --- filtered ---
    assertNotNull(p.getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    p.getResearcherUrls().getResearcherUrls().forEach(e -> assertIsPublic(e));
    // Researcher urls filtered
    p = getPersonElement();
    setVisibility(p.getResearcherUrls().getResearcherUrls(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(p);
    assertEquals(3, p.getAddresses().getAddress().size());
    p.getAddresses().getAddress().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getBiography().getVisibility());
    assertEquals(3, p.getEmails().getEmails().size());
    p.getEmails().getEmails().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    p.getExternalIdentifiers().getExternalIdentifiers().forEach(e -> assertIsPublic(e));
    assertEquals(3, p.getKeywords().getKeywords().size());
    p.getKeywords().getKeywords().forEach(e -> assertIsPublic(e));
    assertEquals(Visibility.PUBLIC, p.getName().getVisibility());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    p.getOtherNames().getOtherNames().forEach(e -> assertIsPublic(e));
    // --- filtered ---
    assertNotNull(p.getResearcherUrls());
    assertTrue(p.getResearcherUrls().getResearcherUrls().isEmpty());
}
Also used : Person(org.orcid.jaxb.model.v3.dev1.record.Person) Test(org.junit.Test)

Example 10 with Addresses

use of org.orcid.jaxb.model.v3.dev1.record.Addresses in project ORCID-Source by ORCID.

the class PersonDetailsManagerReadOnlyImpl method getPublicPersonDetails.

@Override
public Person getPublicPersonDetails(String orcid) {
    long lastModifiedTime = getLastModified(orcid);
    Person person = new Person();
    Name name = recordNameManager.getRecordName(orcid);
    if (Visibility.PUBLIC.equals(name.getVisibility())) {
        person.setName(name);
    }
    Biography bio = biographyManager.getPublicBiography(orcid);
    if (bio != null) {
        person.setBiography(bio);
    }
    Addresses addresses = addressManager.getPublicAddresses(orcid);
    if (addresses.getAddress() != null) {
        Addresses filteredAddresses = new Addresses();
        filteredAddresses.setAddress(new ArrayList<Address>(addresses.getAddress()));
        person.setAddresses(filteredAddresses);
    }
    PersonExternalIdentifiers extIds = externalIdentifierManager.getPublicExternalIdentifiers(orcid);
    if (extIds.getExternalIdentifiers() != null) {
        PersonExternalIdentifiers filteredExtIds = new PersonExternalIdentifiers();
        filteredExtIds.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>(extIds.getExternalIdentifiers()));
        person.setExternalIdentifiers(filteredExtIds);
    }
    Keywords keywords = profileKeywordManager.getPublicKeywords(orcid);
    if (keywords.getKeywords() != null) {
        Keywords filteredKeywords = new Keywords();
        filteredKeywords.setKeywords(new ArrayList<Keyword>(keywords.getKeywords()));
        person.setKeywords(filteredKeywords);
    }
    OtherNames otherNames = otherNameManager.getPublicOtherNames(orcid);
    if (otherNames.getOtherNames() != null) {
        OtherNames filteredOtherNames = new OtherNames();
        filteredOtherNames.setOtherNames(new ArrayList<OtherName>(otherNames.getOtherNames()));
        person.setOtherNames(filteredOtherNames);
    }
    ResearcherUrls rUrls = researcherUrlManager.getPublicResearcherUrls(orcid);
    if (rUrls.getResearcherUrls() != null) {
        ResearcherUrls filteredRUrls = new ResearcherUrls();
        filteredRUrls.setResearcherUrls(new ArrayList<ResearcherUrl>(rUrls.getResearcherUrls()));
        person.setResearcherUrls(filteredRUrls);
    }
    Emails emails = emailManager.getPublicEmails(orcid);
    if (emails.getEmails() != null) {
        Emails filteredEmails = new Emails();
        filteredEmails.setEmails(new ArrayList<Email>(emails.getEmails()));
        person.setEmails(filteredEmails);
    }
    return person;
}
Also used : Keywords(org.orcid.jaxb.model.v3.dev1.record.Keywords) Email(org.orcid.jaxb.model.v3.dev1.record.Email) Address(org.orcid.jaxb.model.v3.dev1.record.Address) Keyword(org.orcid.jaxb.model.v3.dev1.record.Keyword) OtherNames(org.orcid.jaxb.model.v3.dev1.record.OtherNames) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier) OtherName(org.orcid.jaxb.model.v3.dev1.record.OtherName) Name(org.orcid.jaxb.model.v3.dev1.record.Name) Addresses(org.orcid.jaxb.model.v3.dev1.record.Addresses) PersonExternalIdentifiers(org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers) Biography(org.orcid.jaxb.model.v3.dev1.record.Biography) ResearcherUrls(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Emails(org.orcid.jaxb.model.v3.dev1.record.Emails) Person(org.orcid.jaxb.model.v3.dev1.record.Person)

Aggregations

Addresses (org.orcid.jaxb.model.v3.dev1.record.Addresses)50 Address (org.orcid.jaxb.model.v3.dev1.record.Address)44 Test (org.junit.Test)38 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)34 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)33 Keywords (org.orcid.jaxb.model.v3.dev1.record.Keywords)33 PersonExternalIdentifiers (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifiers)33 ResearcherUrls (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrls)33 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)31 Email (org.orcid.jaxb.model.v3.dev1.record.Email)30 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)30 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)30 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)30 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)30 Name (org.orcid.jaxb.model.v3.dev1.record.Name)27 Person (org.orcid.jaxb.model.v3.dev1.record.Person)26 Record (org.orcid.jaxb.model.v3.dev1.record.Record)13 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)13 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)13 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)13