Search in sources :

Example 66 with PersonExternalIdentifier

use of org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier 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_v2.Email) Keywords(org.orcid.jaxb.model.record_v2.Keywords) Address(org.orcid.jaxb.model.record_v2.Address) Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Addresses(org.orcid.jaxb.model.record_v2.Addresses) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) 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) Works(org.orcid.jaxb.model.record.summary_v2.Works) PeerReviewGroup(org.orcid.jaxb.model.record.summary_v2.PeerReviewGroup) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) FundingGroup(org.orcid.jaxb.model.record.summary_v2.FundingGroup) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Test(org.junit.Test)

Example 67 with PersonExternalIdentifier

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

the class RecordTest method testViewRecordFromPublicAPI.

@Test
public void testViewRecordFromPublicAPI() {
    ClientResponse response = publicV2ApiClient.viewRecordXML(getUser1OrcidId());
    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) {
        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());
                        assertEquals(Visibility.PUBLIC, s.getVisibility());
                    }
                }
            }
            // Employments
            if (record.getActivitiesSummary().getEmployments() != null) {
                Employments e = record.getActivitiesSummary().getEmployments();
                if (e.getSummaries() != null) {
                    for (EmploymentSummary s : e.getSummaries()) {
                        assertNotNull(s.getSource());
                        assertEquals(Visibility.PUBLIC, s.getVisibility());
                    }
                }
            }
            // 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());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
            // 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());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
            // 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());
                                assertEquals(Visibility.PUBLIC, s.getVisibility());
                            }
                        }
                    }
                }
            }
        }
    }
    // 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());
                    assertEquals(Visibility.PUBLIC, o.getVisibility());
                }
            }
        }
        // Biography
        if (record.getPerson().getBiography() != null) {
            Biography b = record.getPerson().getBiography();
            if (b != null) {
                assertNotNull(b.getVisibility());
                assertEquals(Visibility.PUBLIC, b.getVisibility());
            }
        }
        // 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());
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        // External identifiers
        if (record.getPerson().getExternalIdentifiers() != null) {
            PersonExternalIdentifiers extIds = record.getPerson().getExternalIdentifiers();
            List<PersonExternalIdentifier> list = extIds.getExternalIdentifiers();
            if (list != null) {
                for (PersonExternalIdentifier e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        // Keywords
        if (record.getPerson().getKeywords() != null) {
            Keywords keywords = record.getPerson().getKeywords();
            List<Keyword> list = keywords.getKeywords();
            if (list != null) {
                for (Keyword e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        // Name
        if (record.getPerson().getName() != null) {
            Name name = record.getPerson().getName();
            assertEquals(Visibility.PUBLIC, name.getVisibility());
        }
        // Other names
        if (record.getPerson().getOtherNames() != null) {
            OtherNames otherNames = record.getPerson().getOtherNames();
            List<OtherName> list = otherNames.getOtherNames();
            if (list != null) {
                for (OtherName e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
        // Researcher urls
        if (record.getPerson().getResearcherUrls() != null) {
            ResearcherUrls rUrls = record.getPerson().getResearcherUrls();
            List<ResearcherUrl> list = rUrls.getResearcherUrls();
            if (list != null) {
                for (ResearcherUrl e : list) {
                    assertEquals(Visibility.PUBLIC, e.getVisibility());
                }
            }
        }
    }
}
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) Test(org.junit.Test)

Example 68 with PersonExternalIdentifier

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

the class BlackBoxBaseRC4 method createExternalIdentifier.

/**
 * EXTERNAL IDENTIFIERS
 *
 * External identifiers can't be added through the UI
 */
public Long createExternalIdentifier(String value, String userOrcid, String accessToken) {
    PersonExternalIdentifier e = new PersonExternalIdentifier();
    e.setValue(value);
    e.setType("test");
    e.setUrl(new Url("http://test.orcid.org"));
    e.setRelationship(Relationship.SELF);
    ClientResponse response = memberV2ApiClient.createExternalIdentifier(userOrcid, e, accessToken);
    assertNotNull(response);
    assertEquals(ClientResponse.Status.CREATED.getStatusCode(), response.getStatus());
    return getPutCodeFromResponse(response);
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier) ResearcherUrl(org.orcid.jaxb.model.record_rc4.ResearcherUrl) Url(org.orcid.jaxb.model.common_rc4.Url)

Example 69 with PersonExternalIdentifier

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

the class OrcidRecordToSolrDocument method convert.

public OrcidSolrDocument convert(Record record, List<Funding> fundings) {
    OrcidSolrDocument profileIndexDocument = new OrcidSolrDocument();
    profileIndexDocument.setOrcid(record.getOrcidIdentifier().getPath());
    if (record.getHistory() != null) {
        if (record.getHistory().getLastModifiedDate() != null) {
            profileIndexDocument.setProfileLastModifiedDate(record.getHistory().getLastModifiedDate().getValue().toGregorianCalendar().getTime());
        }
        if (record.getHistory().getSubmissionDate() != null) {
            profileIndexDocument.setProfileSubmissionDate(record.getHistory().getSubmissionDate().getValue().toGregorianCalendar().getTime());
        }
    }
    if (record.getDeprecated() != null) {
        profileIndexDocument.setPrimaryRecord(record.getDeprecated().getPrimaryRecord() != null ? record.getDeprecated().getPrimaryRecord().getOrcidIdentifier().getPath() : null);
    }
    if (record.getPerson() != null) {
        if (record.getPerson().getName() != null) {
            profileIndexDocument.setFamilyName(record.getPerson().getName().getFamilyName() != null ? record.getPerson().getName().getFamilyName().getContent() : null);
            profileIndexDocument.setGivenNames(record.getPerson().getName().getGivenNames() != null ? record.getPerson().getName().getGivenNames().getContent() : null);
            profileIndexDocument.setCreditName(record.getPerson().getName().getCreditName() != null ? record.getPerson().getName().getCreditName().getContent() : null);
        }
        if (record.getPerson().getOtherNames() != null) {
            if (record.getPerson().getOtherNames().getOtherNames() != null && !record.getPerson().getOtherNames().getOtherNames().isEmpty()) {
                List<String> names = new ArrayList<String>();
                for (org.orcid.jaxb.model.record_v2.OtherName on : record.getPerson().getOtherNames().getOtherNames()) {
                    names.add(on.getContent());
                }
                profileIndexDocument.setOtherNames(names);
            }
        }
        if (record.getPerson().getEmails() != null && record.getPerson().getEmails().getEmails() != null) {
            for (org.orcid.jaxb.model.record_v2.Email e : record.getPerson().getEmails().getEmails()) {
                profileIndexDocument.addEmailAddress(e.getEmail());
            }
        }
        // weird, the type is not indexed...!
        if (record.getPerson().getExternalIdentifiers() != null && record.getPerson().getExternalIdentifiers().getExternalIdentifiers() != null) {
            List<String> extIdOrcids = new ArrayList<String>();
            List<String> extIdRefs = new ArrayList<String>();
            List<String> extIdOrcidsAndRefs = new ArrayList<String>();
            for (PersonExternalIdentifier externalIdentifier : record.getPerson().getExternalIdentifiers().getExternalIdentifiers()) {
                String sourcePath = null;
                if (externalIdentifier.getSource() != null && externalIdentifier.getSource().retrieveSourcePath() != null) {
                    sourcePath = externalIdentifier.getSource().retrieveSourcePath();
                    extIdOrcids.add(sourcePath);
                }
                if (externalIdentifier.getValue() != null) {
                    // weird, the type is not indexed...!
                    extIdRefs.add(externalIdentifier.getValue());
                }
                if (NullUtils.noneNull(sourcePath, externalIdentifier.getValue())) {
                    extIdOrcidsAndRefs.add(sourcePath + "=" + externalIdentifier.getValue());
                }
            }
            if (!extIdOrcids.isEmpty()) {
                profileIndexDocument.setExternalIdSources(extIdOrcids);
            }
            if (!extIdRefs.isEmpty()) {
                profileIndexDocument.setExternalIdReferences(extIdRefs);
            }
            if (!extIdOrcidsAndRefs.isEmpty()) {
                profileIndexDocument.setExternalIdSourcesAndReferences(extIdOrcidsAndRefs);
            }
        }
        // weird, we only index keywords if activities exist...!
        if (record.getActivitiesSummary() != null) {
            if (record.getPerson().getKeywords() != null && record.getPerson().getKeywords().getKeywords() != null) {
                List<String> keywordValues = new ArrayList<String>();
                for (org.orcid.jaxb.model.record_v2.Keyword keyword : record.getPerson().getKeywords().getKeywords()) {
                    keywordValues.add(keyword.getContent());
                }
                profileIndexDocument.setKeywords(keywordValues);
            }
        }
        if (record.getActivitiesSummary() != null && record.getActivitiesSummary().getWorks() != null && record.getActivitiesSummary().getWorks().getWorkGroup() != null) {
            // work ids
            Map<String, List<String>> allExternalIdentifiers = new HashMap<String, List<String>>();
            Map<String, List<String>> partOf = new HashMap<String, List<String>>();
            Map<String, List<String>> self = new HashMap<String, List<String>>();
            Set<String> workTitles = new HashSet<String>();
            for (WorkGroup wg : record.getActivitiesSummary().getWorks().getWorkGroup()) {
                if (wg.getWorkSummary() != null) {
                    for (WorkSummary w : wg.getWorkSummary()) {
                        // have to use summaries here as group does not include part-of
                        if (w.getExternalIdentifiers() != null && w.getExternalIdentifiers().getExternalIdentifier() != null) {
                            for (ExternalID id : w.getExternalIdentifiers().getExternalIdentifier()) {
                                // old way
                                if (!allExternalIdentifiers.containsKey(id.getType())) {
                                    allExternalIdentifiers.put(id.getType(), new ArrayList<String>());
                                }
                                if (!allExternalIdentifiers.get(id.getType()).contains(id.getValue())) {
                                    allExternalIdentifiers.get(id.getType()).add(id.getValue());
                                }
                                // new way
                                if (Relationship.SELF.equals(id.getRelationship())) {
                                    if (!self.containsKey(id.getType() + SolrConstants.DYNAMIC_SELF)) {
                                        self.put(id.getType() + SolrConstants.DYNAMIC_SELF, new ArrayList<String>());
                                    }
                                    if (!self.get(id.getType() + SolrConstants.DYNAMIC_SELF).contains(id.getValue())) {
                                        self.get(id.getType() + SolrConstants.DYNAMIC_SELF).add(id.getValue());
                                    }
                                }
                                if (Relationship.PART_OF.equals(id.getRelationship())) {
                                    if (!partOf.containsKey(id.getType() + SolrConstants.DYNAMIC_PART_OF)) {
                                        partOf.put(id.getType() + SolrConstants.DYNAMIC_PART_OF, new ArrayList<String>());
                                    }
                                    if (!partOf.get(id.getType() + SolrConstants.DYNAMIC_PART_OF).contains(id.getValue())) {
                                        partOf.get(id.getType() + SolrConstants.DYNAMIC_PART_OF).add(id.getValue());
                                    }
                                }
                            }
                        }
                        if (w.getTitle() != null) {
                            if (w.getTitle().getTitle() != null && StringUtils.isNotEmpty(w.getTitle().getTitle().getContent())) {
                                workTitles.add(w.getTitle().getTitle().getContent());
                            }
                            if (w.getTitle().getSubtitle() != null && StringUtils.isNotEmpty(w.getTitle().getSubtitle().getContent())) {
                                workTitles.add(w.getTitle().getSubtitle().getContent());
                            }
                            if (w.getTitle().getTranslatedTitle() != null && StringUtils.isNotEmpty(w.getTitle().getTranslatedTitle().getContent())) {
                                workTitles.add(w.getTitle().getTranslatedTitle().getContent());
                            }
                        }
                    }
                }
            }
            profileIndexDocument.setSelfIds(self);
            profileIndexDocument.setPartOfIds(partOf);
            // now add them to the doc, the old way
            addExternalIdentifiersToIndexDocument(profileIndexDocument, allExternalIdentifiers);
            profileIndexDocument.setWorkTitles(new ArrayList<String>(workTitles));
        }
        Map<String, List<String>> organisationIds = new HashMap<String, List<String>>();
        organisationIds.put(SolrConstants.FUNDREF_ORGANISATION_ID, new ArrayList<String>());
        organisationIds.put(SolrConstants.RINGGOLD_ORGANISATION_ID, new ArrayList<String>());
        organisationIds.put(SolrConstants.GRID_ORGANISATION_ID, new ArrayList<String>());
        Map<String, List<String>> organisationNames = new HashMap<String, List<String>>();
        organisationNames.put(SolrConstants.AFFILIATION_ORGANISATION_NAME, new ArrayList<String>());
        organisationNames.put(SolrConstants.FUNDING_ORGANISATION_NAME, new ArrayList<String>());
        if (!fundings.isEmpty()) {
            Set<String> fundingTitle = new HashSet<String>();
            Set<String> fundingGrantNumbers = new HashSet<String>();
            for (Funding f : fundings) {
                if (f.getTitle() != null) {
                    if (f.getTitle().getTitle() != null && StringUtils.isNotEmpty(f.getTitle().getTitle().getContent())) {
                        fundingTitle.add(f.getTitle().getTitle().getContent());
                    }
                    if (f.getTitle().getTranslatedTitle() != null && StringUtils.isNotEmpty(f.getTitle().getTranslatedTitle().getContent())) {
                        fundingTitle.add(f.getTitle().getTranslatedTitle().getContent());
                    }
                }
                if (f.getExternalIdentifiers() != null && f.getExternalIdentifiers().getExternalIdentifier() != null) {
                    for (ExternalID id : f.getExternalIdentifiers().getExternalIdentifier()) {
                        if (id.getType().equals("grant_number")) {
                            fundingGrantNumbers.add(id.getValue());
                        }
                    }
                }
                if (f.getOrganization() != null) {
                    organisationNames.get(SolrConstants.FUNDING_ORGANISATION_NAME).add(f.getOrganization().getName());
                    if (f.getOrganization().getDisambiguatedOrganization() != null)
                        organisationIds.get(SolrConstants.FUNDREF_ORGANISATION_ID).add(f.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier());
                }
            }
            profileIndexDocument.setFundingTitles(new ArrayList<String>(fundingTitle));
            profileIndexDocument.setGrantNumbers(new ArrayList<String>(fundingGrantNumbers));
        }
        // now do affiliations
        if (record.getActivitiesSummary() != null && record.getActivitiesSummary().getEducations() != null && record.getActivitiesSummary().getEducations().getSummaries() != null) {
            for (EducationSummary e : record.getActivitiesSummary().getEducations().getSummaries()) {
                if (e.getOrganization() != null) {
                    organisationNames.get(SolrConstants.AFFILIATION_ORGANISATION_NAME).add(e.getOrganization().getName());
                    if (e.getOrganization().getDisambiguatedOrganization() != null) {
                        String sourceType = e.getOrganization().getDisambiguatedOrganization().getDisambiguationSource();
                        if (SolrConstants.RINGGOLD_ORG_TYPE.equals(sourceType)) {
                            organisationIds.get(SolrConstants.RINGGOLD_ORGANISATION_ID).add(e.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier());
                        } else if (SolrConstants.GRID_ORG_TYPE.equals(sourceType)) {
                            organisationIds.get(SolrConstants.GRID_ORGANISATION_ID).add(e.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier());
                        }
                    }
                }
            }
        }
        if (record.getActivitiesSummary() != null && record.getActivitiesSummary().getEmployments() != null && record.getActivitiesSummary().getEmployments().getSummaries() != null) {
            for (EmploymentSummary e : record.getActivitiesSummary().getEmployments().getSummaries()) {
                if (e.getOrganization() != null) {
                    organisationNames.get(SolrConstants.AFFILIATION_ORGANISATION_NAME).add(e.getOrganization().getName());
                    if (e.getOrganization().getDisambiguatedOrganization() != null) {
                        String sourceType = e.getOrganization().getDisambiguatedOrganization().getDisambiguationSource();
                        if (SolrConstants.RINGGOLD_ORG_TYPE.equals(sourceType)) {
                            organisationIds.get(SolrConstants.RINGGOLD_ORGANISATION_ID).add(e.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier());
                        } else if (SolrConstants.GRID_ORG_TYPE.equals(sourceType)) {
                            organisationIds.get(SolrConstants.GRID_ORGANISATION_ID).add(e.getOrganization().getDisambiguatedOrganization().getDisambiguatedOrganizationIdentifier());
                        }
                    }
                }
            }
        }
        profileIndexDocument.setOrganisationIds(organisationIds);
        profileIndexDocument.setOrganisationNames(organisationNames);
    }
    if (indexProfile) {
        try {
            StringWriter sw = new StringWriter();
            jaxbContext_2_0_api.createMarshaller().marshal(record, sw);
            profileIndexDocument.setPublicProfileMessage(sw.getBuffer().toString());
        } catch (JAXBException e) {
            LOG.error("problem marshalling xml", e);
        }
    }
    LOG.debug(profileIndexDocument.toString());
    return profileIndexDocument;
}
Also used : HashMap(java.util.HashMap) Funding(org.orcid.jaxb.model.record_v2.Funding) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) ArrayList(java.util.ArrayList) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) StringWriter(java.io.StringWriter) OrcidSolrDocument(org.orcid.utils.solr.entities.OrcidSolrDocument) ArrayList(java.util.ArrayList) List(java.util.List) HashSet(java.util.HashSet) JAXBException(javax.xml.bind.JAXBException) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)

Example 70 with PersonExternalIdentifier

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

the class MapperFacadeFactory method getExternalIdentifierMapperFacade.

public MapperFacade getExternalIdentifierMapperFacade() {
    MapperFactory mapperFactory = getNewMapperFactory();
    ClassMapBuilder<PersonExternalIdentifier, ExternalIdentifierEntity> externalIdentifierClassMap = mapperFactory.classMap(PersonExternalIdentifier.class, ExternalIdentifierEntity.class);
    addV2DateFields(externalIdentifierClassMap);
    externalIdentifierClassMap.field("putCode", "id");
    externalIdentifierClassMap.field("type", "externalIdCommonName");
    externalIdentifierClassMap.field("value", "externalIdReference");
    externalIdentifierClassMap.field("url.value", "externalIdUrl");
    externalIdentifierClassMap.fieldBToA("displayIndex", "displayIndex");
    externalIdentifierClassMap.byDefault();
    registerSourceConverters(mapperFactory, externalIdentifierClassMap);
    // TODO: add relationship to database schema for people.
    externalIdentifierClassMap.register();
    return mapperFactory.getMapperFacade();
}
Also used : ExternalIdentifierEntity(org.orcid.persistence.jpa.entities.ExternalIdentifierEntity) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)

Aggregations

PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)99 Test (org.junit.Test)91 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)47 Address (org.orcid.jaxb.model.record_v2.Address)42 Keyword (org.orcid.jaxb.model.record_v2.Keyword)42 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)41 OtherName (org.orcid.jaxb.model.record_v2.OtherName)40 Email (org.orcid.jaxb.model.record_v2.Email)39 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)33 Biography (org.orcid.jaxb.model.record_v2.Biography)32 Person (org.orcid.jaxb.model.record_v2.Person)32 Addresses (org.orcid.jaxb.model.record_v2.Addresses)31 Emails (org.orcid.jaxb.model.record_v2.Emails)31 Keywords (org.orcid.jaxb.model.record_v2.Keywords)31 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)31 Name (org.orcid.jaxb.model.record_v2.Name)29 Response (javax.ws.rs.core.Response)19 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)19 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)19 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)19