Search in sources :

Example 71 with PersonExternalIdentifier

use of org.orcid.jaxb.model.record_v2.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 72 with PersonExternalIdentifier

use of org.orcid.jaxb.model.record_v2.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)

Example 73 with PersonExternalIdentifier

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

the class PersonDetailsManagerReadOnlyImpl method getPersonDetails.

@Override
public Person getPersonDetails(String orcid) {
    Person person = new Person();
    person.setName(recordNameManager.getRecordName(orcid));
    person.setBiography(biographyManager.getBiography(orcid));
    Addresses addresses = addressManager.getAddresses(orcid);
    if (addresses.getAddress() != null) {
        Addresses filteredAddresses = new Addresses();
        filteredAddresses.setAddress(new ArrayList<Address>(addresses.getAddress()));
        person.setAddresses(filteredAddresses);
    }
    PersonExternalIdentifiers extIds = externalIdentifierManager.getExternalIdentifiers(orcid);
    if (extIds.getExternalIdentifiers() != null) {
        PersonExternalIdentifiers filteredExtIds = new PersonExternalIdentifiers();
        filteredExtIds.setExternalIdentifiers(new ArrayList<PersonExternalIdentifier>(extIds.getExternalIdentifiers()));
        person.setExternalIdentifiers(filteredExtIds);
    }
    Keywords keywords = profileKeywordManager.getKeywords(orcid);
    if (keywords.getKeywords() != null) {
        Keywords filteredKeywords = new Keywords();
        filteredKeywords.setKeywords(new ArrayList<Keyword>(keywords.getKeywords()));
        person.setKeywords(filteredKeywords);
    }
    OtherNames otherNames = otherNameManager.getOtherNames(orcid);
    if (otherNames.getOtherNames() != null) {
        OtherNames filteredOtherNames = new OtherNames();
        filteredOtherNames.setOtherNames(new ArrayList<OtherName>(otherNames.getOtherNames()));
        person.setOtherNames(filteredOtherNames);
    }
    ResearcherUrls rUrls = researcherUrlManager.getResearcherUrls(orcid);
    if (rUrls.getResearcherUrls() != null) {
        ResearcherUrls filteredRUrls = new ResearcherUrls();
        filteredRUrls.setResearcherUrls(new ArrayList<ResearcherUrl>(rUrls.getResearcherUrls()));
        person.setResearcherUrls(filteredRUrls);
    }
    Emails emails = emailManager.getEmails(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.record_v2.Keywords) Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) OtherNames(org.orcid.jaxb.model.record_v2.OtherNames) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Addresses(org.orcid.jaxb.model.record_v2.Addresses) PersonExternalIdentifiers(org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers) ResearcherUrls(org.orcid.jaxb.model.record_v2.ResearcherUrls) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Emails(org.orcid.jaxb.model.record_v2.Emails) Person(org.orcid.jaxb.model.record_v2.Person)

Example 74 with PersonExternalIdentifier

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

the class ValidateV2_1SamplesTest method testUnmarshallRecord.

@Test
public void testUnmarshallRecord() throws SAXException, URISyntaxException {
    Record record = (Record) unmarshallFromPath("/record_2.1/samples/read_samples/record-2.1.xml", Record.class, "/record_2.1/record-2.1.xsd");
    assertNotNull(record);
    // Check activities
    assertNotNull(record.getActivitiesSummary());
    ActivitiesSummary activities = record.getActivitiesSummary();
    assertNotNull(activities.getLastModifiedDate());
    assertNotNull(activities.getEducations());
    Educations educations = activities.getEducations();
    assertNotNull(educations.getLastModifiedDate());
    assertEquals(1, educations.getSummaries().size());
    EducationSummary education = educations.getSummaries().get(0);
    assertEquals(Long.valueOf(0), education.getPutCode());
    assertEquals(Visibility.PRIVATE, education.getVisibility());
    assertEquals("education:department-name", education.getDepartmentName());
    assertEquals("education:role-title", education.getRoleTitle());
    assertNotNull(education.getEndDate());
    assertEquals("02", education.getEndDate().getDay().getValue());
    assertEquals("02", education.getEndDate().getMonth().getValue());
    assertEquals("1848", education.getEndDate().getYear().getValue());
    assertNotNull(education.getStartDate());
    assertEquals("02", education.getStartDate().getDay().getValue());
    assertEquals("02", education.getStartDate().getMonth().getValue());
    assertEquals("1848", education.getStartDate().getYear().getValue());
    assertNotNull(education.getOrganization());
    assertEquals("common:name", education.getOrganization().getName());
    assertEquals("common:city", education.getOrganization().getAddress().getCity());
    assertEquals("common:region", education.getOrganization().getAddress().getRegion());
    assertEquals(Iso3166Country.AF, education.getOrganization().getAddress().getCountry());
    validateSourceInHttps(education.getSource());
    assertNotNull(activities.getEmployments());
    Employments employments = activities.getEmployments();
    assertNotNull(employments.getLastModifiedDate());
    assertEquals(1, employments.getSummaries().size());
    EmploymentSummary employment = employments.getSummaries().get(0);
    assertEquals(Long.valueOf(0), employment.getPutCode());
    assertEquals(Visibility.PRIVATE, employment.getVisibility());
    assertEquals("employment:department-name", employment.getDepartmentName());
    assertEquals("employment:role-title", employment.getRoleTitle());
    assertNotNull(employment.getEndDate());
    assertEquals("02", employment.getEndDate().getDay().getValue());
    assertEquals("02", employment.getEndDate().getMonth().getValue());
    assertEquals("1848", employment.getEndDate().getYear().getValue());
    assertNotNull(employment.getStartDate());
    assertEquals("02", employment.getStartDate().getDay().getValue());
    assertEquals("02", employment.getStartDate().getMonth().getValue());
    assertEquals("1848", employment.getStartDate().getYear().getValue());
    assertNotNull(employment.getOrganization());
    assertEquals("common:name", employment.getOrganization().getName());
    assertEquals("common:city", employment.getOrganization().getAddress().getCity());
    assertEquals("common:region", employment.getOrganization().getAddress().getRegion());
    assertEquals(Iso3166Country.AF, employment.getOrganization().getAddress().getCountry());
    validateSourceInHttps(employment.getSource());
    assertNotNull(activities.getFundings());
    Fundings fundings = activities.getFundings();
    assertNotNull(fundings.getLastModifiedDate());
    assertEquals(1, fundings.getFundingGroup().size());
    assertNotNull(fundings.getFundingGroup().get(0).getLastModifiedDate());
    assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
    assertEquals(1, fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals("grant_number", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
    FundingSummary funding = fundings.getFundingGroup().get(0).getFundingSummary().get(0);
    assertEquals(Long.valueOf(0), funding.getPutCode());
    assertEquals(Visibility.PRIVATE, funding.getVisibility());
    assertNotNull(funding.getTitle());
    assertEquals("common:title", funding.getTitle().getTitle().getContent());
    assertEquals("common:translated-title", funding.getTitle().getTranslatedTitle().getContent());
    assertEquals("en", funding.getTitle().getTranslatedTitle().getLanguageCode());
    assertNotNull(funding.getExternalIdentifiers());
    assertEquals(1, funding.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(Relationship.SELF, funding.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("grant_number", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("http://tempuri.org", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
    assertEquals("external-id-value", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertNotNull(funding.getEndDate());
    assertEquals("02", funding.getEndDate().getDay().getValue());
    assertEquals("02", funding.getEndDate().getMonth().getValue());
    assertEquals("1848", funding.getEndDate().getYear().getValue());
    assertNotNull(funding.getStartDate());
    assertEquals("02", funding.getStartDate().getDay().getValue());
    assertEquals("02", funding.getStartDate().getMonth().getValue());
    assertEquals("1848", funding.getStartDate().getYear().getValue());
    validateSourceInHttps(funding.getSource());
    assertNotNull(funding.getOrganization());
    assertEquals("common:name", funding.getOrganization().getName());
    assertEquals("common:city", funding.getOrganization().getAddress().getCity());
    assertEquals("common:region", funding.getOrganization().getAddress().getRegion());
    assertEquals(Iso3166Country.AF, funding.getOrganization().getAddress().getCountry());
    assertNotNull(activities.getPeerReviews());
    assertNotNull(activities.getPeerReviews().getLastModifiedDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getUrl());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getDay());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getMonth());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getYear());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCreatedDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCreatedDate().getValue());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getDisplayIndex());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getUrl());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getGroupId());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getLastModifiedDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getCity());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getCountry());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getRegion());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getName());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getSource());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getSource().retrieveSourcePath());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
    validateSourceInHttps(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getSource());
    assertNotNull(activities.getWorks());
    Works works = activities.getWorks();
    assertNotNull(works.getLastModifiedDate());
    assertEquals(1, works.getWorkGroup().size());
    assertNotNull(works.getWorkGroup().get(0).getIdentifiers());
    assertEquals(1, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals(Relationship.PART_OF, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("agr", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("http://orcid.org", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
    assertEquals("external-id-value", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(1, works.getWorkGroup().get(0).getWorkSummary().size());
    WorkSummary work = works.getWorkGroup().get(0).getWorkSummary().get(0);
    assertEquals(Long.valueOf(0), work.getPutCode());
    assertEquals(Visibility.PRIVATE, work.getVisibility());
    assertNotNull(work.getTitle());
    assertEquals("common:title", work.getTitle().getTitle().getContent());
    assertEquals("common:translated-title", work.getTitle().getTranslatedTitle().getContent());
    assertEquals("en", work.getTitle().getTranslatedTitle().getLanguageCode());
    assertNotNull(work.getExternalIdentifiers());
    assertEquals(1, work.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(Relationship.SELF, work.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("agr", work.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("http://tempuri.org", work.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
    assertEquals("external-id-value", work.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(WorkType.ARTISTIC_PERFORMANCE, work.getType());
    assertNotNull(work.getPublicationDate());
    assertEquals("02", work.getPublicationDate().getDay().getValue());
    assertEquals("02", work.getPublicationDate().getMonth().getValue());
    assertEquals("1848", work.getPublicationDate().getYear().getValue());
    validateSourceInHttps(work.getSource());
    // Check biography
    Person person = record.getPerson();
    assertNotNull(person);
    assertNotNull(person.getLastModifiedDate().getValue());
    assertNotNull(person.getAddresses());
    assertNotNull(person.getAddresses().getLastModifiedDate());
    assertEquals(1, person.getAddresses().getAddress().size());
    Address address = person.getAddresses().getAddress().get(0);
    assertEquals(Long.valueOf(1), address.getPutCode());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Long.valueOf(0), address.getDisplayIndex());
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(person.getBiography());
    assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
    assertEquals("biography", person.getBiography().getContent());
    assertNotNull(person.getEmails());
    assertTrue(StringUtils.isNotBlank(person.getEmails().getPath()));
    assertNotNull(person.getEmails().getLastModifiedDate());
    assertNotNull(person.getEmails().getEmails());
    assertEquals(1, person.getEmails().getEmails().size());
    Email email = person.getEmails().getEmails().get(0);
    assertNotNull(email.getCreatedDate().getValue());
    assertEquals("user1@email.com", email.getEmail());
    assertNotNull(email.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(0), email.getPutCode());
    assertNotNull(email.getSource());
    validateSourceInHttps(email.getSource());
    assertEquals(Visibility.PUBLIC, email.getVisibility());
    assertNotNull(person.getExternalIdentifiers());
    assertTrue(StringUtils.isNotBlank(person.getExternalIdentifiers().getPath()));
    assertNotNull(person.getExternalIdentifiers().getLastModifiedDate().getValue());
    assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
    assertNotNull(extId.getCreatedDate().getValue());
    assertNotNull(extId.getLastModifiedDate());
    assertEquals(Long.valueOf(0), extId.getDisplayIndex());
    assertEquals(Long.valueOf(1), extId.getPutCode());
    assertEquals(Relationship.PART_OF, extId.getRelationship());
    assertNotNull(extId.getSource());
    assertEquals("type-1", extId.getType());
    assertEquals("http://url.com/1", extId.getUrl().getValue());
    assertEquals("value-1", extId.getValue());
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
    validateSourceInHttps(extId.getSource());
    assertNotNull(person.getKeywords());
    assertTrue(StringUtils.isNotBlank(person.getKeywords().getPath()));
    assertNotNull(person.getKeywords().getLastModifiedDate().getValue());
    assertNotNull(person.getKeywords().getKeywords());
    assertEquals(1, person.getKeywords().getKeywords().size());
    Keyword keyword = person.getKeywords().getKeywords().get(0);
    assertEquals("keyword1", keyword.getContent());
    assertNotNull(keyword.getCreatedDate().getValue());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(0), keyword.getDisplayIndex());
    assertEquals(Long.valueOf(1), keyword.getPutCode());
    assertNotNull(keyword.getSource());
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
    validateSourceInHttps(keyword.getSource());
    assertNotNull(person.getOtherNames());
    assertTrue(StringUtils.isNotBlank(person.getOtherNames().getPath()));
    assertNotNull(person.getOtherNames().getLastModifiedDate().getValue());
    assertNotNull(person.getOtherNames().getOtherNames());
    assertEquals(1, person.getOtherNames().getOtherNames().size());
    OtherName otherName = person.getOtherNames().getOtherNames().get(0);
    assertEquals("other-name-1", otherName.getContent());
    assertNotNull(otherName.getCreatedDate().getValue());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(0), otherName.getDisplayIndex());
    assertEquals(Long.valueOf(1), otherName.getPutCode());
    assertNotNull(otherName.getSource());
    assertEquals(Visibility.PUBLIC, otherName.getVisibility());
    validateSourceInHttps(otherName.getSource());
    assertNotNull(person.getResearcherUrls());
    assertTrue(StringUtils.isNotBlank(person.getResearcherUrls().getPath()));
    assertNotNull(person.getResearcherUrls().getLastModifiedDate().getValue());
    assertNotNull(person.getResearcherUrls().getResearcherUrls().size());
    ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
    assertNotNull(rUrl.getCreatedDate().getValue());
    assertEquals(Long.valueOf(0), rUrl.getDisplayIndex());
    assertNotNull(rUrl.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(1248), rUrl.getPutCode());
    assertNotNull(rUrl.getSource());
    assertEquals("http://url.com/", rUrl.getUrl().getValue());
    assertEquals("url-name-1", rUrl.getUrlName());
    assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
    validateSourceInHttps(rUrl.getSource());
    assertNotNull(person.getName());
    Name name = person.getName();
    assertTrue(StringUtils.isNotBlank(name.getPath()));
    assertEquals("credit-name", name.getCreditName().getContent());
    assertEquals("family-name", name.getFamilyName().getContent());
    assertEquals("give-names", name.getGivenNames().getContent());
    assertNotNull(name.getLastModifiedDate().getValue());
    assertEquals(Visibility.PUBLIC, name.getVisibility());
}
Also used : Email(org.orcid.jaxb.model.record_v2.Email) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) CreditName(org.orcid.jaxb.model.record_v2.CreditName) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Name(org.orcid.jaxb.model.record_v2.Name) Employments(org.orcid.jaxb.model.record.summary_v2.Employments) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_v2.EducationSummary) Educations(org.orcid.jaxb.model.record.summary_v2.Educations) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_v2.EmploymentSummary) Record(org.orcid.jaxb.model.record_v2.Record) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) Works(org.orcid.jaxb.model.record.summary_v2.Works) Person(org.orcid.jaxb.model.record_v2.Person) Test(org.junit.Test)

Example 75 with PersonExternalIdentifier

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

the class ValidateV2RC2SamplesTest method testUnmarshallRecord.

@Test
public void testUnmarshallRecord() throws SAXException, URISyntaxException {
    Record record = (Record) unmarshallFromPath("/record_2.0_rc2/samples/record-2.0_rc2.xml", Record.class, "/record_2.0_rc2/record-2.0_rc2.xsd");
    assertNotNull(record);
    // Check activities
    assertNotNull(record.getActivitiesSummary());
    ActivitiesSummary activities = record.getActivitiesSummary();
    assertNotNull(activities.getLastModifiedDate());
    assertNotNull(activities.getEducations());
    Educations educations = activities.getEducations();
    assertNotNull(educations.getLastModifiedDate());
    assertEquals(1, educations.getSummaries().size());
    EducationSummary education = educations.getSummaries().get(0);
    assertEquals(Long.valueOf(0), education.getPutCode());
    assertEquals(Visibility.PRIVATE, education.getVisibility());
    assertEquals("education:department-name", education.getDepartmentName());
    assertEquals("education:role-title", education.getRoleTitle());
    assertNotNull(education.getEndDate());
    assertEquals("02", education.getEndDate().getDay().getValue());
    assertEquals("02", education.getEndDate().getMonth().getValue());
    assertEquals("1848", education.getEndDate().getYear().getValue());
    assertNotNull(education.getStartDate());
    assertEquals("02", education.getStartDate().getDay().getValue());
    assertEquals("02", education.getStartDate().getMonth().getValue());
    assertEquals("1848", education.getStartDate().getYear().getValue());
    assertNotNull(education.getOrganization());
    assertEquals("common:name", education.getOrganization().getName());
    assertEquals("common:city", education.getOrganization().getAddress().getCity());
    assertEquals("common:region", education.getOrganization().getAddress().getRegion());
    assertEquals(Iso3166Country.AF, education.getOrganization().getAddress().getCountry());
    assertNotNull(activities.getEmployments());
    Employments employments = activities.getEmployments();
    assertNotNull(employments.getLastModifiedDate());
    assertEquals(1, employments.getSummaries().size());
    EmploymentSummary employment = employments.getSummaries().get(0);
    assertEquals(Long.valueOf(0), employment.getPutCode());
    assertEquals(Visibility.PRIVATE, employment.getVisibility());
    assertEquals("employment:department-name", employment.getDepartmentName());
    assertEquals("employment:role-title", employment.getRoleTitle());
    assertNotNull(employment.getEndDate());
    assertEquals("02", employment.getEndDate().getDay().getValue());
    assertEquals("02", employment.getEndDate().getMonth().getValue());
    assertEquals("1848", employment.getEndDate().getYear().getValue());
    assertNotNull(employment.getStartDate());
    assertEquals("02", employment.getStartDate().getDay().getValue());
    assertEquals("02", employment.getStartDate().getMonth().getValue());
    assertEquals("1848", employment.getStartDate().getYear().getValue());
    assertNotNull(employment.getOrganization());
    assertEquals("common:name", employment.getOrganization().getName());
    assertEquals("common:city", employment.getOrganization().getAddress().getCity());
    assertEquals("common:region", employment.getOrganization().getAddress().getRegion());
    assertEquals(Iso3166Country.AF, employment.getOrganization().getAddress().getCountry());
    assertNotNull(activities.getFundings());
    Fundings fundings = activities.getFundings();
    assertNotNull(fundings.getLastModifiedDate());
    assertEquals(1, fundings.getFundingGroup().size());
    assertNotNull(fundings.getFundingGroup().get(0).getLastModifiedDate());
    assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
    assertEquals(1, fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals("grant_number", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", fundings.getFundingGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(1, fundings.getFundingGroup().get(0).getFundingSummary().size());
    FundingSummary funding = fundings.getFundingGroup().get(0).getFundingSummary().get(0);
    assertEquals(Long.valueOf(0), funding.getPutCode());
    assertEquals(Visibility.PRIVATE, funding.getVisibility());
    assertNotNull(funding.getTitle());
    assertEquals("common:title", funding.getTitle().getTitle().getContent());
    assertEquals("common:translated-title", funding.getTitle().getTranslatedTitle().getContent());
    assertEquals("en", funding.getTitle().getTranslatedTitle().getLanguageCode());
    assertNotNull(funding.getExternalIdentifiers());
    assertEquals(1, funding.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(Relationship.SELF, funding.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("grant_number", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("http://tempuri.org", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
    assertEquals("external-id-value", funding.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertNotNull(funding.getEndDate());
    assertEquals("02", funding.getEndDate().getDay().getValue());
    assertEquals("02", funding.getEndDate().getMonth().getValue());
    assertEquals("1848", funding.getEndDate().getYear().getValue());
    assertNotNull(funding.getStartDate());
    assertEquals("02", funding.getStartDate().getDay().getValue());
    assertEquals("02", funding.getStartDate().getMonth().getValue());
    assertEquals("1848", funding.getStartDate().getYear().getValue());
    assertNotNull(activities.getPeerReviews());
    assertNotNull(activities.getPeerReviews().getLastModifiedDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getUrl());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getDay());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getMonth());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCompletionDate().getYear());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCreatedDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getCreatedDate().getValue());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getDisplayIndex());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier());
    assertEquals(1, activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().size());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getUrl());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getGroupId());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getLastModifiedDate());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getCity());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getCountry());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getAddress().getRegion());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getOrganization().getName());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getPutCode());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getSource());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getSource().retrieveSourcePath());
    assertNotNull(activities.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getVisibility());
    assertNotNull(activities.getWorks());
    Works works = activities.getWorks();
    assertNotNull(works.getLastModifiedDate());
    assertEquals(1, works.getWorkGroup().size());
    assertNotNull(works.getWorkGroup().get(0).getIdentifiers());
    assertEquals(1, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().size());
    assertEquals(Relationship.PART_OF, works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("agr", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("http://orcid.org", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
    assertEquals("external-id-value", works.getWorkGroup().get(0).getIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(1, works.getWorkGroup().get(0).getWorkSummary().size());
    WorkSummary work = works.getWorkGroup().get(0).getWorkSummary().get(0);
    assertEquals(Long.valueOf(0), work.getPutCode());
    assertEquals(Visibility.PRIVATE, work.getVisibility());
    assertNotNull(work.getTitle());
    assertEquals("common:title", work.getTitle().getTitle().getContent());
    assertEquals("common:translated-title", work.getTitle().getTranslatedTitle().getContent());
    assertEquals("en", work.getTitle().getTranslatedTitle().getLanguageCode());
    assertNotNull(work.getExternalIdentifiers());
    assertEquals(1, work.getExternalIdentifiers().getExternalIdentifier().size());
    assertEquals(Relationship.SELF, work.getExternalIdentifiers().getExternalIdentifier().get(0).getRelationship());
    assertEquals("agr", work.getExternalIdentifiers().getExternalIdentifier().get(0).getType());
    assertEquals("http://tempuri.org", work.getExternalIdentifiers().getExternalIdentifier().get(0).getUrl().getValue());
    assertEquals("external-id-value", work.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
    assertEquals(WorkType.ARTISTIC_PERFORMANCE, work.getType());
    assertNotNull(work.getPublicationDate());
    assertEquals("02", work.getPublicationDate().getDay().getValue());
    assertEquals("02", work.getPublicationDate().getMonth().getValue());
    assertEquals("1848", work.getPublicationDate().getYear().getValue());
    // Check biography
    Person person = record.getPerson();
    assertNotNull(person);
    assertNotNull(person.getLastModifiedDate().getValue());
    assertNotNull(person.getAddresses());
    assertNotNull(person.getAddresses().getLastModifiedDate());
    assertEquals(1, person.getAddresses().getAddress().size());
    Address address = person.getAddresses().getAddress().get(0);
    assertEquals(Long.valueOf(1), address.getPutCode());
    assertEquals(Visibility.PUBLIC, address.getVisibility());
    assertEquals(Iso3166Country.US, address.getCountry().getValue());
    assertEquals(Long.valueOf(0), address.getDisplayIndex());
    assertNotNull(address.getLastModifiedDate());
    assertNotNull(person.getBiography());
    assertEquals(Visibility.PUBLIC, person.getBiography().getVisibility());
    assertEquals("biography", person.getBiography().getContent());
    assertNotNull(person.getEmails());
    assertTrue(StringUtils.isNotBlank(person.getEmails().getPath()));
    assertNotNull(person.getEmails().getLastModifiedDate());
    assertNotNull(person.getEmails().getEmails());
    assertEquals(1, person.getEmails().getEmails().size());
    Email email = person.getEmails().getEmails().get(0);
    assertNotNull(email.getCreatedDate().getValue());
    assertEquals("user1@email.com", email.getEmail());
    assertNotNull(email.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(0), email.getPutCode());
    assertNotNull(email.getSource());
    assertEquals(Visibility.PUBLIC, email.getVisibility());
    assertNotNull(person.getExternalIdentifiers());
    assertTrue(StringUtils.isNotBlank(person.getExternalIdentifiers().getPath()));
    assertNotNull(person.getExternalIdentifiers().getLastModifiedDate().getValue());
    assertNotNull(person.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(1, person.getExternalIdentifiers().getExternalIdentifiers().size());
    PersonExternalIdentifier extId = person.getExternalIdentifiers().getExternalIdentifiers().get(0);
    assertNotNull(extId.getCreatedDate().getValue());
    assertNotNull(extId.getLastModifiedDate());
    assertEquals(Long.valueOf(0), extId.getDisplayIndex());
    assertEquals(Long.valueOf(1), extId.getPutCode());
    assertEquals(Relationship.PART_OF, extId.getRelationship());
    assertNotNull(extId.getSource());
    assertEquals("type-1", extId.getType());
    assertEquals("http://url.com/1", extId.getUrl().getValue());
    assertEquals("value-1", extId.getValue());
    assertEquals(Visibility.PUBLIC, extId.getVisibility());
    assertNotNull(person.getKeywords());
    assertTrue(StringUtils.isNotBlank(person.getKeywords().getPath()));
    assertNotNull(person.getKeywords().getLastModifiedDate().getValue());
    assertNotNull(person.getKeywords().getKeywords());
    assertEquals(1, person.getKeywords().getKeywords().size());
    Keyword keyword = person.getKeywords().getKeywords().get(0);
    assertEquals("keyword1", keyword.getContent());
    assertNotNull(keyword.getCreatedDate().getValue());
    assertNotNull(keyword.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(0), keyword.getDisplayIndex());
    assertEquals(Long.valueOf(1), keyword.getPutCode());
    assertNotNull(keyword.getSource());
    assertEquals(Visibility.PUBLIC, keyword.getVisibility());
    assertNotNull(person.getOtherNames());
    assertTrue(StringUtils.isNotBlank(person.getOtherNames().getPath()));
    assertNotNull(person.getOtherNames().getLastModifiedDate().getValue());
    assertNotNull(person.getOtherNames().getOtherNames());
    assertEquals(1, person.getOtherNames().getOtherNames().size());
    OtherName otherName = person.getOtherNames().getOtherNames().get(0);
    assertEquals("other-name-1", otherName.getContent());
    assertNotNull(otherName.getCreatedDate().getValue());
    assertNotNull(otherName.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(0), otherName.getDisplayIndex());
    assertEquals(Long.valueOf(1), otherName.getPutCode());
    assertNotNull(otherName.getSource());
    assertEquals(Visibility.PUBLIC, otherName.getVisibility());
    assertNotNull(person.getResearcherUrls());
    assertTrue(StringUtils.isNotBlank(person.getResearcherUrls().getPath()));
    assertNotNull(person.getResearcherUrls().getLastModifiedDate().getValue());
    assertNotNull(person.getResearcherUrls().getResearcherUrls().size());
    ResearcherUrl rUrl = person.getResearcherUrls().getResearcherUrls().get(0);
    assertNotNull(rUrl.getCreatedDate().getValue());
    assertEquals(Long.valueOf(0), rUrl.getDisplayIndex());
    assertNotNull(rUrl.getLastModifiedDate().getValue());
    assertEquals(Long.valueOf(1248), rUrl.getPutCode());
    assertNotNull(rUrl.getSource());
    assertEquals("http://url.com/", rUrl.getUrl().getValue());
    assertEquals("url-name-1", rUrl.getUrlName());
    assertEquals(Visibility.PUBLIC, rUrl.getVisibility());
    assertNotNull(person.getName());
    Name name = person.getName();
    assertTrue(StringUtils.isNotBlank(name.getPath()));
    assertEquals("credit-name", name.getCreditName().getContent());
    assertEquals("family-name", name.getFamilyName().getContent());
    assertEquals("give-names", name.getGivenNames().getContent());
    assertNotNull(name.getLastModifiedDate().getValue());
    assertEquals(Visibility.PUBLIC, name.getVisibility());
}
Also used : Email(org.orcid.jaxb.model.record_rc2.Email) Address(org.orcid.jaxb.model.record_rc2.Address) Keyword(org.orcid.jaxb.model.record_rc2.Keyword) Fundings(org.orcid.jaxb.model.record.summary_rc2.Fundings) OtherName(org.orcid.jaxb.model.record_rc2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_rc2.PersonExternalIdentifier) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc2.ActivitiesSummary) OtherName(org.orcid.jaxb.model.record_rc2.OtherName) CreditName(org.orcid.jaxb.model.record_rc2.CreditName) Name(org.orcid.jaxb.model.record_rc2.Name) Employments(org.orcid.jaxb.model.record.summary_rc2.Employments) WorkSummary(org.orcid.jaxb.model.record.summary_rc2.WorkSummary) EducationSummary(org.orcid.jaxb.model.record.summary_rc2.EducationSummary) Educations(org.orcid.jaxb.model.record.summary_rc2.Educations) FundingSummary(org.orcid.jaxb.model.record.summary_rc2.FundingSummary) EmploymentSummary(org.orcid.jaxb.model.record.summary_rc2.EmploymentSummary) Record(org.orcid.jaxb.model.record_rc2.Record) ResearcherUrl(org.orcid.jaxb.model.record_rc2.ResearcherUrl) Works(org.orcid.jaxb.model.record.summary_rc2.Works) Person(org.orcid.jaxb.model.record_rc2.Person) Test(org.junit.Test)

Aggregations

PersonExternalIdentifier (org.orcid.jaxb.model.record_v2.PersonExternalIdentifier)99 Test (org.junit.Test)91 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)50 OtherName (org.orcid.jaxb.model.record_v2.OtherName)44 Address (org.orcid.jaxb.model.record_v2.Address)43 Keyword (org.orcid.jaxb.model.record_v2.Keyword)42 PersonExternalIdentifiers (org.orcid.jaxb.model.record_v2.PersonExternalIdentifiers)42 Email (org.orcid.jaxb.model.record_v2.Email)39 OtherNames (org.orcid.jaxb.model.record_v2.OtherNames)34 Biography (org.orcid.jaxb.model.record_v2.Biography)33 Addresses (org.orcid.jaxb.model.record_v2.Addresses)32 Emails (org.orcid.jaxb.model.record_v2.Emails)32 Keywords (org.orcid.jaxb.model.record_v2.Keywords)32 Person (org.orcid.jaxb.model.record_v2.Person)32 ResearcherUrls (org.orcid.jaxb.model.record_v2.ResearcherUrls)32 Name (org.orcid.jaxb.model.record_v2.Name)30 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