Search in sources :

Example 71 with Emails

use of org.orcid.jaxb.model.record_rc2.Emails in project ORCID-Source by ORCID.

the class PublicV2ApiServiceDelegatorImpl method viewEmails.

@Override
public Response viewEmails(String orcid) {
    Emails emails = emailManagerReadOnly.getPublicEmails(orcid);
    publicAPISecurityManagerV2.filter(emails);
    ElementUtils.setPathToEmail(emails, orcid);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(emails);
    sourceUtilsReadOnly.setSourceName(emails);
    return Response.ok(emails).build();
}
Also used : Emails(org.orcid.jaxb.model.record_v2.Emails)

Example 72 with Emails

use of org.orcid.jaxb.model.record_rc2.Emails in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegatorImpl method viewEmails.

@Override
public Response viewEmails(String orcid) {
    Emails emails = null;
    try {
        // return all emails if client has /email/read-private scope
        orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.EMAIL_READ_PRIVATE);
        emails = emailManagerReadOnly.getEmails(orcid);
        // Lets copy the list so we don't modify the cached collection
        List<Email> filteredList = new ArrayList<Email>(emails.getEmails());
        emails = new Emails();
        emails.setEmails(filteredList);
    } catch (OrcidAccessControlException e) {
        emails = emailManagerReadOnly.getEmails(orcid);
        // Lets copy the list so we don't modify the cached collection
        List<Email> filteredList = new ArrayList<Email>(emails.getEmails());
        emails = new Emails();
        emails.setEmails(filteredList);
        // Filter just in case client doesn't have the /email/read-private
        // scope
        orcidSecurityManager.checkAndFilter(orcid, emails.getEmails(), ScopePathType.ORCID_BIO_READ_LIMITED);
    }
    ElementUtils.setPathToEmail(emails, orcid);
    Api2_0_LastModifiedDatesHelper.calculateLastModified(emails);
    sourceUtils.setSourceName(emails);
    return Response.ok(emails).build();
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Emails(org.orcid.jaxb.model.record_v2.Emails) OrcidAccessControlException(org.orcid.core.exception.OrcidAccessControlException)

Example 73 with Emails

use of org.orcid.jaxb.model.record_rc2.Emails in project ORCID-Source by ORCID.

the class RDFWriterTest method fakeBio.

private Record fakeBio() throws DatatypeConfigurationException {
    Record r = new Record();
    r.setOrcidIdentifier(new OrcidIdentifier());
    r.getOrcidIdentifier().setPath("000-1337");
    r.getOrcidIdentifier().setUri("http://orcid.example.com/000-1337");
    r.setHistory(new History());
    r.getHistory().setCreationMethod(CreationMethod.WEBSITE);
    XMLGregorianCalendar value = dataTypeFactory.newXMLGregorianCalendar(1980, 12, 31, 23, 29, 29, 999, 0);
    r.getHistory().setLastModifiedDate(new LastModifiedDate(value));
    r.getHistory().setClaimed(true);
    r.setPerson(new Person());
    r.getPerson().setBiography(new Biography());
    r.getPerson().setName(new Name());
    r.getPerson().getName().setFamilyName(new FamilyName("Doe"));
    r.getPerson().getName().setCreditName(new CreditName("John F Doe"));
    r.getPerson().getName().setGivenNames(new GivenNames("John"));
    r.getPerson().setOtherNames(new OtherNames());
    r.getPerson().getOtherNames().setOtherNames(new ArrayList<OtherName>());
    OtherName n = new OtherName();
    n.setContent("Johnny");
    n.setVisibility(Visibility.PUBLIC);
    OtherName n1 = new OtherName();
    n1.setContent("Mr Doe");
    n1.setVisibility(Visibility.PUBLIC);
    r.getPerson().getOtherNames().getOtherNames().add(n);
    r.getPerson().getOtherNames().getOtherNames().add(n1);
    r.getPerson().setResearcherUrls(new ResearcherUrls());
    r.getPerson().getResearcherUrls().setResearcherUrls(new ArrayList<ResearcherUrl>());
    ResearcherUrl anonymous = new ResearcherUrl();
    anonymous.setUrl(new Url("http://example.com/anon"));
    anonymous.setVisibility(Visibility.PUBLIC);
    r.getPerson().getResearcherUrls().getResearcherUrls().add(anonymous);
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/myPage", "homePage"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/foaf#me", "FOAF"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/webId", "webID"));
    r.getPerson().getResearcherUrls().getResearcherUrls().add(buildRUrl("http://example.com/other", "other"));
    r.getPerson().setAddresses(new Addresses());
    r.getPerson().getAddresses().setAddress(new ArrayList<Address>());
    Address a = new Address();
    a.setCountry(new Country());
    a.getCountry().setValue(Iso3166Country.GB);
    r.getPerson().getAddresses().getAddress().add(a);
    r.getPerson().setEmails(new Emails());
    r.getPerson().getEmails().setEmails(new ArrayList<Email>());
    Email e = new Email();
    e.setEmail("john@example.org");
    e.setCurrent(true);
    Email e1 = new Email();
    e1.setEmail("doe@example.com");
    e1.setCurrent(true);
    r.getPerson().getEmails().getEmails().add(e);
    r.getPerson().getEmails().getEmails().add(e1);
    return r;
}
Also used : LastModifiedDate(org.orcid.jaxb.model.common_v2.LastModifiedDate) Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) History(org.orcid.jaxb.model.record_v2.History) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) FamilyName(org.orcid.jaxb.model.record_v2.FamilyName) CreditName(org.orcid.jaxb.model.common_v2.CreditName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Addresses(org.orcid.jaxb.model.record_v2.Addresses) OrcidIdentifier(org.orcid.jaxb.model.common_v2.OrcidIdentifier) GivenNames(org.orcid.jaxb.model.record_v2.GivenNames) Biography(org.orcid.jaxb.model.record_v2.Biography) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) Record(org.orcid.jaxb.model.record_v2.Record) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails) CreditName(org.orcid.jaxb.model.common_v2.CreditName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) Country(org.orcid.jaxb.model.common_v2.Country) Iso3166Country(org.orcid.jaxb.model.common_v2.Iso3166Country) Person(org.orcid.jaxb.model.record_v2.Person)

Example 74 with Emails

use of org.orcid.jaxb.model.record_rc2.Emails in project ORCID-Source by ORCID.

the class RDFMessageBodyWriterV2 method describeContactDetails.

private void describeContactDetails(Person orcidPerson, Individual person, OntModel m) {
    if (orcidPerson == null) {
        return;
    }
    Emails emails = orcidPerson.getEmails();
    if (emails != null) {
        for (Email email : emails.getEmails()) {
            if (email.isCurrent()) {
                Individual mbox = m.createIndividual("mailto:" + email.getEmail(), null);
                person.addProperty(FOAF.mbox, mbox);
            }
        }
    }
    Addresses addresses = orcidPerson.getAddresses();
    Address addr = (addresses != null && addresses.getAddress().size() > 0) ? addresses.getAddress().get(0) : null;
    if (addr != null) {
        if (addr.getCountry() != null) {
            String countryCode = addr.getCountry().getValue().name();
            Individual position = m.createIndividual(Geonames.Feature);
            position.addProperty(Geonames.countryCode, countryCode);
            person.addProperty(FOAF.based_near, position);
            Individual country = getCountry(countryCode);
            if (country != null) {
                country = addToModel(position.getOntModel(), country);
                position.addProperty(Geonames.parentCountry, country);
            }
        // TODO: Include URI and (a) full name of country
        // Potential source: geonames.org
        // See https://gist.github.com/stain/7566375
        }
    }
}
Also used : Addresses(org.orcid.jaxb.model.record_v2.Addresses) Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) Individual(org.apache.jena.ontology.Individual) Emails(org.orcid.jaxb.model.record_v2.Emails)

Example 75 with Emails

use of org.orcid.jaxb.model.record_rc2.Emails in project ORCID-Source by ORCID.

the class RecordTest method testViewRecordFromMemberAPI.

@Test
public void testViewRecordFromMemberAPI() throws InterruptedException, JSONException {
    String accessToken = getAccessToken();
    assertNotNull(accessToken);
    ClientResponse response = memberV2ApiClient.viewRecord(getUser1OrcidId(), accessToken);
    assertNotNull(response);
    assertEquals("invalid " + response, 200, response.getStatus());
    Record record = response.getEntity(Record.class);
    assertNotNull(record);
    assertNotNull(record.getOrcidIdentifier());
    assertEquals(getUser1OrcidId(), record.getOrcidIdentifier().getPath());
    // Check the visibility of every activity that exists
    if (record.getActivitiesSummary() != null) {
        // Educations
        if (record.getActivitiesSummary().getEducations() != null) {
            Educations e = record.getActivitiesSummary().getEducations();
            if (e.getSummaries() != null) {
                for (EducationSummary s : e.getSummaries()) {
                    assertNotNull(s.getSource());
                    assertNotNull(s.getVisibility());
                    Visibility v = s.getVisibility();
                    // If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        // Employments
        if (record.getActivitiesSummary().getEmployments() != null) {
            Employments e = record.getActivitiesSummary().getEmployments();
            if (e.getSummaries() != null) {
                for (EmploymentSummary s : e.getSummaries()) {
                    assertNotNull(s.getSource());
                    assertNotNull(s.getVisibility());
                    Visibility v = s.getVisibility();
                    // If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        // Fundings
        if (record.getActivitiesSummary().getFundings() != null) {
            Fundings f = record.getActivitiesSummary().getFundings();
            List<FundingGroup> groups = f.getFundingGroup();
            if (groups != null) {
                for (FundingGroup fGroup : groups) {
                    List<FundingSummary> summaries = fGroup.getFundingSummary();
                    if (summaries != null) {
                        for (FundingSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            // If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
        // PeerReviews
        if (record.getActivitiesSummary().getPeerReviews() != null) {
            PeerReviews p = record.getActivitiesSummary().getPeerReviews();
            List<PeerReviewGroup> groups = p.getPeerReviewGroup();
            if (groups != null) {
                for (PeerReviewGroup pGroup : groups) {
                    List<PeerReviewSummary> summaries = pGroup.getPeerReviewSummary();
                    if (summaries != null) {
                        for (PeerReviewSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            // If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
        // Works
        if (record.getActivitiesSummary().getWorks() != null) {
            Works w = record.getActivitiesSummary().getWorks();
            List<WorkGroup> groups = w.getWorkGroup();
            if (groups != null) {
                for (WorkGroup wGroup : groups) {
                    List<WorkSummary> summaries = wGroup.getWorkSummary();
                    if (summaries != null) {
                        for (WorkSummary s : summaries) {
                            assertNotNull(s.getSource());
                            assertNotNull(s.getVisibility());
                            Visibility v = s.getVisibility();
                            // If the visibility is PRIVATE the client should be the owner
                            if (Visibility.PRIVATE.equals(v)) {
                                assertEquals(getClient1ClientId(), s.getSource().retrieveSourcePath());
                            }
                        }
                    }
                }
            }
        }
    }
    // Check the visibility of every biography elements that exists
    if (record.getPerson() != null) {
        // Address
        if (record.getPerson().getAddresses() != null) {
            Addresses addresses = record.getPerson().getAddresses();
            List<Address> list = addresses.getAddress();
            if (list != null) {
                for (Address o : list) {
                    assertNotNull(o.getSource());
                    assertNotNull(o.getVisibility());
                    Visibility v = o.getVisibility();
                    // If the visibility is PRIVATE the client should be the owner
                    if (Visibility.PRIVATE.equals(v)) {
                        assertEquals(getClient1ClientId(), o.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        // Biography
        if (record.getPerson().getBiography() != null) {
            Biography b = record.getPerson().getBiography();
            if (b != null) {
                assertNotNull(b.getVisibility());
                if (Visibility.PRIVATE.equals(b.getVisibility())) {
                    fail("Visibility is private");
                }
            }
        }
        // Emails
        if (record.getPerson().getEmails() != null) {
            Emails emails = record.getPerson().getEmails();
            List<Email> list = emails.getEmails();
            if (list != null) {
                for (Email e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        fail("Email " + e.getEmail() + " is private");
                    }
                }
            }
        }
        // External identifiers
        if (record.getPerson().getExternalIdentifiers() != null) {
            PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
            List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
            if (list != null) {
                for (PersonExternalIdentifier e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        // Keywords
        if (record.getPerson().getKeywords() != null) {
            Keywords keywords = record.getPerson().getKeywords();
            List<Keyword> list = keywords.getKeywords();
            if (list != null) {
                for (Keyword e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        // Name
        if (record.getPerson().getName() != null) {
            Name name = record.getPerson().getName();
            if (Visibility.PRIVATE.equals(name.getVisibility())) {
                fail("Name is private");
            }
        }
        // Other names
        if (record.getPerson().getOtherNames() != null) {
            OtherNames otherNames = record.getPerson().getOtherNames();
            List<OtherName> list = otherNames.getOtherNames();
            if (list != null) {
                for (OtherName e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
        // Researcher urls
        if (record.getPerson().getResearcherUrls() != null) {
            ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
            List<ResearcherUrl> list = rUrls.getResearcherUrls();
            if (list != null) {
                for (ResearcherUrl e : list) {
                    assertNotNull(e.getVisibility());
                    if (Visibility.PRIVATE.equals(e.getVisibility())) {
                        assertEquals(getClient1ClientId(), e.getSource().retrieveSourcePath());
                    }
                }
            }
        }
    }
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Email(org.orcid.jaxb.model.record_rc3.Email) Keywords(org.orcid.jaxb.model.record_rc3.Keywords) Address(org.orcid.jaxb.model.record_rc3.Address) Fundings(org.orcid.jaxb.model.record.summary_rc3.Fundings) OtherNames(org.orcid.jaxb.model.record_rc3.OtherNames) PeerReviews(org.orcid.jaxb.model.record.summary_rc3.PeerReviews) OtherName(org.orcid.jaxb.model.record_rc3.OtherName) Name(org.orcid.jaxb.model.record_rc3.Name) Addresses(org.orcid.jaxb.model.record_rc3.Addresses) WorkGroup(org.orcid.jaxb.model.record.summary_rc3.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_rc3.WorkSummary) FundingSummary(org.orcid.jaxb.model.record.summary_rc3.FundingSummary) Biography(org.orcid.jaxb.model.record_rc3.Biography) ResearcherUrls(org.orcid.jaxb.model.record_rc3.ResearcherUrls) Record(org.orcid.jaxb.model.record_rc3.Record) ResearcherUrl(org.orcid.jaxb.model.record_rc3.ResearcherUrl) Emails(org.orcid.jaxb.model.record_rc3.Emails) Works(org.orcid.jaxb.model.record.summary_rc3.Works) PeerReviewGroup(org.orcid.jaxb.model.record.summary_rc3.PeerReviewGroup) Keyword(org.orcid.jaxb.model.record_rc3.Keyword) OtherName(org.orcid.jaxb.model.record_rc3.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifier) FundingGroup(org.orcid.jaxb.model.record.summary_rc3.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_rc3.Employments) PersonExternalIdentifiers(org.orcid.jaxb.model.record_rc3.PersonExternalIdentifiers) EducationSummary(org.orcid.jaxb.model.record.summary_rc3.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_rc3.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_rc3.Educations) EmploymentSummary(org.orcid.jaxb.model.record.summary_rc3.EmploymentSummary) Visibility(org.orcid.jaxb.model.common_rc3.Visibility) Test(org.junit.Test)

Aggregations

Emails (org.orcid.jaxb.model.record_v2.Emails)63 Test (org.junit.Test)59 Email (org.orcid.jaxb.model.record_v2.Email)52 Addresses (org.orcid.jaxb.model.record_v2.Addresses)35 Address (org.orcid.jaxb.model.record_v2.Address)34 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)34 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)34 Keywords (org.orcid.jaxb.model.record_v2.Keywords)33 OtherName (org.orcid.jaxb.model.record_v2.OtherName)33 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)33 Biography (org.orcid.jaxb.model.record_v2.Biography)32 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)32 Keyword (org.orcid.jaxb.model.record_v2.Keyword)31 Person (org.orcid.jaxb.model.record_v2.Person)31 PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)31 Name (org.orcid.jaxb.model.record_v2.Name)29 Record (org.orcid.jaxb.model.record_v2.Record)17 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)15 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)15 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)15