Search in sources :

Example 6 with Works

use of org.orcid.jaxb.model.record.summary_rc4.Works in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method viewWorksTest.

@Test
public void viewWorksTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewWorks(ORCID);
    assertNotNull(r);
    Works works = (Works) r.getEntity();
    assertNotNull(works);
    assertEquals("/0000-0000-0000-0003/works", works.getPath());
    Utils.verifyLastModified(works.getLastModifiedDate());
    assertNotNull(works.getWorkGroup());
    assertNotNull(works.getPath());
    assertEquals(4, works.getWorkGroup().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (WorkGroup workGroup : works.getWorkGroup()) {
        Utils.verifyLastModified(workGroup.getLastModifiedDate());
        assertNotNull(workGroup.getIdentifiers());
        assertNotNull(workGroup.getIdentifiers().getExternalIdentifier());
        assertEquals(1, workGroup.getIdentifiers().getExternalIdentifier().size());
        assertNotNull(workGroup.getWorkSummary());
        assertEquals(1, workGroup.getWorkSummary().size());
        WorkSummary summary = workGroup.getWorkSummary().get(0);
        Utils.verifyLastModified(summary.getLastModifiedDate());
        assertNotNull(summary.getTitle());
        assertNotNull(summary.getTitle().getTitle());
        switch(workGroup.getIdentifiers().getExternalIdentifier().get(0).getValue()) {
            case "1":
                assertEquals("PUBLIC", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(11), summary.getPutCode());
                found1 = true;
                break;
            case "2":
                assertEquals("LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(12), summary.getPutCode());
                found2 = true;
                break;
            case "3":
                assertEquals("PRIVATE", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(13), summary.getPutCode());
                found3 = true;
                break;
            case "4":
                assertEquals("SELF LIMITED", summary.getTitle().getTitle().getContent());
                assertEquals(Long.valueOf(14), summary.getPutCode());
                found4 = true;
                break;
            default:
                fail("Invalid external id found: " + workGroup.getIdentifiers().getExternalIdentifier().get(0).getValue());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) WorkGroup(org.orcid.jaxb.model.record.summary_v2.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) Works(org.orcid.jaxb.model.record.summary_v2.Works) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 7 with Works

use of org.orcid.jaxb.model.record.summary_rc4.Works in project ORCID-Source by ORCID.

the class ActivitiesSummaryManagerReadOnlyImpl method getActivitiesSummary.

public ActivitiesSummary getActivitiesSummary(String orcid, boolean justPublic) {
    long lastModifiedTime = getLastModified(orcid);
    ActivitiesSummary activities = new ActivitiesSummary();
    // Set educations
    List<EducationSummary> educationsList = affiliationsManager.getEducationSummaryList(orcid, lastModifiedTime);
    Educations educations = new Educations();
    for (EducationSummary summary : educationsList) {
        if (justPublic) {
            if (Visibility.PUBLIC.equals(summary.getVisibility())) {
                educations.getSummaries().add(summary);
            }
        } else {
            educations.getSummaries().add(summary);
        }
    }
    activities.setEducations(educations);
    // Set employments
    List<EmploymentSummary> employmentList = affiliationsManager.getEmploymentSummaryList(orcid, lastModifiedTime);
    Employments employments = new Employments();
    for (EmploymentSummary summary : employmentList) {
        if (justPublic) {
            if (Visibility.PUBLIC.equals(summary.getVisibility())) {
                employments.getSummaries().add(summary);
            }
        } else {
            employments.getSummaries().add(summary);
        }
    }
    activities.setEmployments(employments);
    // Set fundings
    List<FundingSummary> fundingSummaries = fundingManager.getFundingSummaryList(orcid, lastModifiedTime);
    Fundings fundings = fundingManager.groupFundings(fundingSummaries, justPublic);
    activities.setFundings(fundings);
    // Set peer reviews
    List<PeerReviewSummary> peerReviewSummaries = peerReviewManager.getPeerReviewSummaryList(orcid, lastModifiedTime);
    PeerReviews peerReviews = peerReviewManager.groupPeerReviews(peerReviewSummaries, justPublic);
    activities.setPeerReviews(peerReviews);
    // Set works
    List<WorkSummary> workSummaries = workManager.getWorksSummaryList(orcid, lastModifiedTime);
    Works works = workManager.groupWorks(workSummaries, justPublic);
    activities.setWorks(works);
    return activities;
}
Also used : Fundings(org.orcid.jaxb.model.record.summary_v2.Fundings) PeerReviews(org.orcid.jaxb.model.record.summary_v2.PeerReviews) ActivitiesSummary(org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary) 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) PeerReviewSummary(org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary) 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) Works(org.orcid.jaxb.model.record.summary_v2.Works)

Example 8 with Works

use of org.orcid.jaxb.model.record.summary_rc4.Works 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 9 with Works

use of org.orcid.jaxb.model.record.summary_rc4.Works in project ORCID-Source by ORCID.

the class WorksTest method testWorksWithPartOfRelationshipDontGetGrouped.

@Test
public void testWorksWithPartOfRelationshipDontGetGrouped() throws JSONException, InterruptedException, URISyntaxException {
    long time = System.currentTimeMillis();
    String accessTokenForClient1 = getAccessToken();
    String accessTokenForClient2 = getAccessToken(getUser1OrcidId(), getUser1Password(), getScopes(ScopePathType.ACTIVITIES_UPDATE, ScopePathType.ACTIVITIES_READ_LIMITED), getClient2ClientId(), getClient2ClientSecret(), getClient2RedirectUri());
    Work work1 = (Work) unmarshallFromPath("/record_2.0_rc4/samples/work-2.0_rc4.xml", Work.class);
    work1.setPutCode(null);
    work1.setVisibility(Visibility.PUBLIC);
    work1.getExternalIdentifiers().getExternalIdentifier().clear();
    org.orcid.jaxb.model.record_rc4.WorkTitle title1 = new org.orcid.jaxb.model.record_rc4.WorkTitle();
    title1.setTitle(new Title("Work # 1" + time));
    work1.setWorkTitle(title1);
    ExternalID wExtId1 = new ExternalID();
    wExtId1.setValue("Work Id " + time);
    wExtId1.setType(WorkExternalIdentifierType.AGR.value());
    wExtId1.setRelationship(Relationship.SELF);
    wExtId1.setUrl(new Url("http://orcid.org/work#1"));
    work1.getExternalIdentifiers().getExternalIdentifier().clear();
    work1.getExternalIdentifiers().getExternalIdentifier().add(wExtId1);
    Work work2 = (Work) unmarshallFromPath("/record_2.0_rc4/samples/work-2.0_rc4.xml", Work.class);
    work2.setPutCode(null);
    work2.setVisibility(Visibility.PUBLIC);
    org.orcid.jaxb.model.record_rc4.WorkTitle title2 = new org.orcid.jaxb.model.record_rc4.WorkTitle();
    title2.setTitle(new Title("Work # 2" + time));
    work2.setWorkTitle(title2);
    work2.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID wExtId2 = new ExternalID();
    wExtId2.setValue("Work Id " + time);
    wExtId2.setType(WorkExternalIdentifierType.AGR.value());
    wExtId2.setRelationship(Relationship.PART_OF);
    wExtId2.setUrl(new Url("http://orcid.org/work#2"));
    work2.getExternalIdentifiers().getExternalIdentifier().clear();
    work2.getExternalIdentifiers().getExternalIdentifier().add(wExtId2);
    Work work3 = (Work) unmarshallFromPath("/record_2.0_rc4/samples/work-2.0_rc4.xml", Work.class);
    work3.setPutCode(null);
    work3.setVisibility(Visibility.PUBLIC);
    org.orcid.jaxb.model.record_rc4.WorkTitle title3 = new org.orcid.jaxb.model.record_rc4.WorkTitle();
    title3.setTitle(new Title("Work # 3" + time));
    work3.setWorkTitle(title3);
    work3.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID wExtId3 = new ExternalID();
    wExtId3.setValue("Work Id " + time);
    wExtId3.setType(WorkExternalIdentifierType.AGR.value());
    wExtId3.setRelationship(Relationship.SELF);
    wExtId3.setUrl(new Url("http://orcid.org/work#3"));
    work3.getExternalIdentifiers().getExternalIdentifier().clear();
    work3.getExternalIdentifiers().getExternalIdentifier().add(wExtId3);
    //Add the three works
    ClientResponse postResponse = memberV2ApiClient.createWorkXml(this.getUser1OrcidId(), work1, accessTokenForClient1);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    Long putCode1 = getPutCodeFromResponse(postResponse);
    postResponse = memberV2ApiClient.createWorkXml(this.getUser1OrcidId(), work2, accessTokenForClient1);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    Long putCode2 = getPutCodeFromResponse(postResponse);
    postResponse = memberV2ApiClient.createWorkXml(this.getUser1OrcidId(), work3, accessTokenForClient2);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    Long putCode3 = getPutCodeFromResponse(postResponse);
    ClientResponse activitiesResponse = memberV2ApiClient.viewActivities(this.getUser1OrcidId(), accessTokenForClient1);
    assertEquals(Response.Status.OK.getStatusCode(), activitiesResponse.getStatus());
    ActivitiesSummary activities = activitiesResponse.getEntity(ActivitiesSummary.class);
    assertNotNull(activities);
    assertFalse(activities.getWorks().getWorkGroup().isEmpty());
    WorkGroup work1Group = null;
    WorkGroup work2Group = null;
    WorkGroup work3Group = null;
    boolean work1found = false;
    boolean work2found = false;
    boolean work3found = false;
    for (WorkGroup group : activities.getWorks().getWorkGroup()) {
        if (group.getIdentifiers().getExternalIdentifier() == null || group.getIdentifiers().getExternalIdentifier().isEmpty()) {
            for (WorkSummary summary : group.getWorkSummary()) {
                String title = summary.getTitle().getTitle().getContent();
                if (("Work # 2" + time).equals(title)) {
                    work2found = true;
                    work2Group = group;
                }
            }
        } else {
            for (ExternalID id : group.getIdentifiers().getExternalIdentifier()) {
                //If it is the ID is the one we are looking for
                if (id.getValue().equals("Work Id " + time)) {
                    for (WorkSummary summary : group.getWorkSummary()) {
                        String title = summary.getTitle().getTitle().getContent();
                        if (("Work # 1" + time).equals(title)) {
                            work1found = true;
                            work1Group = group;
                        } else if (("Work # 3" + time).equals(title)) {
                            work3found = true;
                            work3Group = group;
                        }
                    }
                }
            }
        }
    }
    assertTrue(work1found);
    assertTrue(work2found);
    assertTrue(work3found);
    //Check that work # 1 and Work # 3 are in the same work
    assertEquals(work1Group, work3Group);
    //Check that work # 2 is not in the same group than group # 1
    assertThat(work2Group, not(work1Group));
    //Remove all created works
    ClientResponse deleteResponse = memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode1, accessTokenForClient1);
    assertNotNull(deleteResponse);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
    deleteResponse = memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode2, accessTokenForClient1);
    assertNotNull(deleteResponse);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
    deleteResponse = memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), putCode3, accessTokenForClient2);
    assertNotNull(deleteResponse);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) ExternalID(org.orcid.jaxb.model.record_rc4.ExternalID) TranslatedTitle(org.orcid.jaxb.model.common_rc4.TranslatedTitle) Title(org.orcid.jaxb.model.common_rc4.Title) WorkTitle(org.orcid.jaxb.model.record_rc4.WorkTitle) Url(org.orcid.jaxb.model.common_rc4.Url) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc4.ActivitiesSummary) WorkGroup(org.orcid.jaxb.model.record.summary_rc4.WorkGroup) WorkSummary(org.orcid.jaxb.model.record.summary_rc4.WorkSummary) WorkTitle(org.orcid.jaxb.model.record_rc4.WorkTitle) Work(org.orcid.jaxb.model.record_rc4.Work) WorkTitle(org.orcid.jaxb.model.record_rc4.WorkTitle) Test(org.junit.Test)

Example 10 with Works

use of org.orcid.jaxb.model.record.summary_rc4.Works 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

Test (org.junit.Test)35 Works (org.orcid.jaxb.model.record.summary_v2.Works)26 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)22 ClientResponse (com.sun.jersey.api.client.ClientResponse)12 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)12 BaseTest (org.orcid.core.BaseTest)10 EducationSummary (org.orcid.jaxb.model.record.summary_v2.EducationSummary)8 Educations (org.orcid.jaxb.model.record.summary_v2.Educations)8 EmploymentSummary (org.orcid.jaxb.model.record.summary_v2.EmploymentSummary)8 Employments (org.orcid.jaxb.model.record.summary_v2.Employments)8 FundingSummary (org.orcid.jaxb.model.record.summary_v2.FundingSummary)8 Fundings (org.orcid.jaxb.model.record.summary_v2.Fundings)8 InputStream (java.io.InputStream)4 JAXBContext (javax.xml.bind.JAXBContext)4 Unmarshaller (javax.xml.bind.Unmarshaller)4 V2Convertible (org.orcid.core.version.V2Convertible)4 PeerReviewSummary (org.orcid.jaxb.model.record.summary_v2.PeerReviewSummary)4 PeerReviews (org.orcid.jaxb.model.record.summary_v2.PeerReviews)4 Address (org.orcid.jaxb.model.record_v2.Address)4 Email (org.orcid.jaxb.model.record_v2.Email)4