Search in sources :

Example 36 with Record

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

the class PublicV3ApiServiceDelegatorTest method testValidateRecordUsingToken.

@Test
public void testValidateRecordUsingToken() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewRecord(ORCID);
    assertNotNull(response);
    Record record = (Record) response.getEntity();
    validateRecord(record);
}
Also used : Response(javax.ws.rs.core.Response) Record(org.orcid.jaxb.model.v3.dev1.record.Record) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 37 with Record

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

the class PublicAPISecurityManagerV3Test method checkIsPublicRecordTest.

@Test
public void checkIsPublicRecordTest() {
    Record r = getRecordElement();
    publicAPISecurityManagerV3.filter(r);
    // Verify activities - nothing filtered
    ActivitiesSummary as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEducations());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getEmployments());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertGroupContainsOnlyPublicElements(as.getFundings());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertGroupContainsOnlyPublicElements(as.getPeerReviews());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertGroupContainsOnlyPublicElements(as.getWorks());
    assertEquals(3, as.getDistinctions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getDistinctions());
    assertEquals(3, as.getInvitedPositions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
    assertEquals(3, as.getMemberships().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getMemberships());
    assertEquals(3, as.getQualifications().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getQualifications());
    assertEquals(3, as.getServices().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getServices());
    // Verify bio sections - nothing filtered
    Person p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertAllArePublic(p.getAddresses().getAddress());
    assertEquals(3, p.getEmails().getEmails().size());
    assertAllArePublic(p.getEmails().getEmails());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertAllArePublic(p.getExternalIdentifiers().getExternalIdentifiers());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertAllArePublic(p.getKeywords().getKeywords());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertAllArePublic(p.getOtherNames().getOtherNames());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertAllArePublic(p.getResearcherUrls().getResearcherUrls());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
    // Filter biography, name, educations and funding
    r = getRecordElement();
    r.getPerson().getBiography().setVisibility(Visibility.LIMITED);
    r.getPerson().getName().setVisibility(Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getEducations().getSummaries(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getFundings(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(r);
    // Verify activities - educations and funding filtered
    as = r.getActivitiesSummary();
    assertNotNull(as.getEducations());
    assertTrue(as.getEducations().getSummaries().isEmpty());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertTrue(as.getFundings().getFundingGroup().isEmpty());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertEquals(3, as.getDistinctions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getDistinctions());
    assertEquals(3, as.getInvitedPositions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
    assertEquals(3, as.getMemberships().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getMemberships());
    assertEquals(3, as.getQualifications().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getQualifications());
    assertEquals(3, as.getServices().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getServices());
    // Verify bio sections - bio and name filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertEquals(3, p.getEmails().getEmails().size());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNull(p.getBiography());
    assertNull(p.getName());
    // Filter emails, external identifiers, peer reviews and works
    r = getRecordElement();
    setVisibility(r.getPerson().getEmails().getEmails(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getPerson().getExternalIdentifiers().getExternalIdentifiers(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getPeerReviews(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getActivitiesSummary().getWorks(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(r);
    // Verify activities - peer reviews and works filtered
    as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertTrue(as.getPeerReviews().getPeerReviewGroup().isEmpty());
    assertTrue(as.getWorks().getWorkGroup().isEmpty());
    assertEquals(3, as.getDistinctions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getDistinctions());
    assertEquals(3, as.getInvitedPositions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
    assertEquals(3, as.getMemberships().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getMemberships());
    assertEquals(3, as.getQualifications().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getQualifications());
    assertEquals(3, as.getServices().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getServices());
    // Verify bio sections - emails, external identifiers filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertNotNull(p.getEmails());
    assertTrue(p.getEmails().getEmails().isEmpty());
    assertNotNull(p.getExternalIdentifiers());
    assertTrue(p.getExternalIdentifiers().getExternalIdentifiers().isEmpty());
    assertEquals(3, p.getKeywords().getKeywords().size());
    assertEquals(3, p.getOtherNames().getOtherNames().size());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
    // Filter keywords and other names
    r = getRecordElement();
    setVisibility(r.getPerson().getOtherNames().getOtherNames(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    setVisibility(r.getPerson().getKeywords().getKeywords(), Visibility.LIMITED, Visibility.PRIVATE, Visibility.LIMITED);
    publicAPISecurityManagerV3.filter(r);
    // Verify activities - nothing filtered
    as = r.getActivitiesSummary();
    assertEquals(3, as.getEducations().getSummaries().size());
    assertEquals(3, as.getEmployments().getSummaries().size());
    assertEquals(3, as.getFundings().getFundingGroup().size());
    assertEquals(3, as.getPeerReviews().getPeerReviewGroup().size());
    assertEquals(3, as.getWorks().getWorkGroup().size());
    assertEquals(3, as.getDistinctions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getDistinctions());
    assertEquals(3, as.getInvitedPositions().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getInvitedPositions());
    assertEquals(3, as.getMemberships().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getMemberships());
    assertEquals(3, as.getQualifications().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getQualifications());
    assertEquals(3, as.getServices().getSummaries().size());
    assertContainerContainsOnlyPublicElements(as.getServices());
    // Verify bio sections - keywords and other names filtered
    p = r.getPerson();
    assertEquals(3, p.getAddresses().getAddress().size());
    assertEquals(3, p.getEmails().getEmails().size());
    assertEquals(3, p.getExternalIdentifiers().getExternalIdentifiers().size());
    assertNotNull(p.getKeywords());
    assertTrue(p.getKeywords().getKeywords().isEmpty());
    assertNotNull(p.getOtherNames());
    assertTrue(p.getOtherNames().getOtherNames().isEmpty());
    assertEquals(3, p.getResearcherUrls().getResearcherUrls().size());
    assertNotNull(p.getBiography());
    assertNotNull(p.getName());
}
Also used : Record(org.orcid.jaxb.model.v3.dev1.record.Record) Person(org.orcid.jaxb.model.v3.dev1.record.Person) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) Test(org.junit.Test)

Example 38 with Record

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

the class PublicV3ApiServiceDelegatorImpl method viewRecord.

@Override
public Response viewRecord(String orcid) {
    Record record = recordManagerReadOnly.getPublicRecord(orcid);
    publicAPISecurityManagerV3.filter(record);
    if (record.getPerson() != null) {
        sourceUtilsReadOnly.setSourceName(record.getPerson());
    }
    if (record.getActivitiesSummary() != null) {
        ActivityUtils.cleanEmptyFields(record.getActivitiesSummary());
        sourceUtilsReadOnly.setSourceName(record.getActivitiesSummary());
    }
    ElementUtils.setPathToRecord(record, orcid);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(record);
    return Response.ok(record).build();
}
Also used : Record(org.orcid.jaxb.model.v3.dev1.record.Record) GroupIdRecord(org.orcid.jaxb.model.v3.dev1.groupid.GroupIdRecord)

Example 39 with Record

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

the class RecordManagerReadOnlyImpl method getRecord.

@Override
public Record getRecord(String orcid) {
    Record record = new Record();
    record.setOrcidType(getOrcidType(orcid));
    record.setHistory(getHistory(orcid));
    record.setOrcidIdentifier(getOrcidIdentifier(orcid));
    record.setPreferences(getPreferences(orcid));
    record.setActivitiesSummary(activitiesSummaryManager.getActivitiesSummary(orcid));
    record.setPerson(personDetailsManager.getPersonDetails(orcid));
    return record;
}
Also used : Record(org.orcid.jaxb.model.v3.dev1.record.Record)

Example 40 with Record

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

the class ContributorUtilsTest method getFundingWithOrcidContributor.

private Funding getFundingWithOrcidContributor() {
    Funding funding = new Funding();
    FundingTitle fundingTitle = new FundingTitle();
    fundingTitle.setTitle(new Title("work with contributor who has ORCID record"));
    funding.setTitle(fundingTitle);
    funding.setContributors(getFundingContributorWithOrcid());
    return funding;
}
Also used : Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) Title(org.orcid.jaxb.model.v3.dev1.common.Title) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle)

Aggregations

Test (org.junit.Test)34 Record (org.orcid.jaxb.model.v3.dev1.record.Record)33 Email (org.orcid.jaxb.model.v3.dev1.record.Email)18 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)18 Person (org.orcid.jaxb.model.v3.dev1.record.Person)17 Address (org.orcid.jaxb.model.v3.dev1.record.Address)16 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)16 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)16 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)16 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)15 Emails (org.orcid.jaxb.model.v3.dev1.record.Emails)15 Name (org.orcid.jaxb.model.v3.dev1.record.Name)15 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)15 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)15 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)15 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)15 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)15 OtherNames (org.orcid.jaxb.model.v3.dev1.record.OtherNames)14 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)14 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)14