Search in sources :

Example 21 with Services

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

the class ValidateV3_dev1SamplesTest method testMarshallServices.

@Test
public void testMarshallServices() throws JAXBException, SAXException, URISyntaxException {
    Services object = (Services) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/services-3.0_dev1.xml", Services.class);
    marshall(object, "/record_3.0_dev1/activities-3.0_dev1.xsd");
}
Also used : Services(org.orcid.jaxb.model.v3.dev1.record.summary.Services) Test(org.junit.Test)

Example 22 with Services

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

the class PublicV3ApiServiceDelegatorImpl method viewServices.

@Override
public Response viewServices(String orcid) {
    List<ServiceSummary> services = affiliationsManagerReadOnly.getServiceSummaryList(orcid);
    Services publicServices = new Services();
    for (ServiceSummary summary : services) {
        if (Visibility.PUBLIC.equals(summary.getVisibility())) {
            ActivityUtils.setPathToActivity(summary, orcid);
            sourceUtilsReadOnly.setSourceName(summary);
            publicServices.getSummaries().add(summary);
        }
    }
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(publicServices);
    ActivityUtils.setPathToAffiliations(publicServices, orcid);
    return Response.ok(publicServices).build();
}
Also used : Services(org.orcid.jaxb.model.v3.dev1.record.summary.Services) ServiceSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)

Example 23 with Services

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

the class MemberV3ApiServiceDelegator_ServicesTest method testViewServicesReadPublic.

@Test
public void testViewServicesReadPublic() {
    SecurityContextTestUtils.setUpSecurityContextForClientOnly("APP-5555555555555555", ScopePathType.READ_PUBLIC);
    Response r = serviceDelegator.viewServices(ORCID);
    Services element = (Services) r.getEntity();
    assertNotNull(element);
    assertEquals("/0000-0000-0000-0003/services", element.getPath());
    Utils.assertIsPublicOrSource(element, "APP-5555555555555555");
}
Also used : Response(javax.ws.rs.core.Response) Services(org.orcid.jaxb.model.v3.dev1.record.summary.Services) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 24 with Services

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

the class MemberV3ApiServiceDelegator_ServicesTest method testViewServices.

@Test
public void testViewServices() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewServices(ORCID);
    assertNotNull(r);
    Services services = (Services) r.getEntity();
    assertNotNull(services);
    assertEquals("/0000-0000-0000-0003/services", services.getPath());
    Utils.verifyLastModified(services.getLastModifiedDate());
    assertNotNull(services.getSummaries());
    assertEquals(4, services.getSummaries().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (ServiceSummary summary : services.getSummaries()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        if (Long.valueOf(47).equals(summary.getPutCode())) {
            assertEquals("PUBLIC Department", summary.getDepartmentName());
            found1 = true;
        } else if (Long.valueOf(48).equals(summary.getPutCode())) {
            assertEquals("LIMITED Department", summary.getDepartmentName());
            found2 = true;
        } else if (Long.valueOf(49).equals(summary.getPutCode())) {
            assertEquals("PRIVATE Department", summary.getDepartmentName());
            found3 = true;
        } else if (Long.valueOf(50).equals(summary.getPutCode())) {
            assertEquals("SELF LIMITED Department", summary.getDepartmentName());
            found4 = true;
        } else {
            fail("Invalid service found: " + summary.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) Services(org.orcid.jaxb.model.v3.dev1.record.summary.Services) ServiceSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 25 with Services

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

the class OrcidSecurityManagerImpl method checkAndFilter.

@Override
public void checkAndFilter(String orcid, ActivitiesSummary activities) {
    if (activities == null) {
        return;
    }
    // Check the token
    isMyToken(orcid);
    // Distinctions
    if (activities.getDistinctions() != null) {
        checkAndFilter(orcid, activities.getDistinctions().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Educations
    if (activities.getEducations() != null) {
        checkAndFilter(orcid, activities.getEducations().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Employments
    if (activities.getEmployments() != null) {
        checkAndFilter(orcid, activities.getEmployments().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Invited positions
    if (activities.getInvitedPositions() != null) {
        checkAndFilter(orcid, activities.getInvitedPositions().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Memberships
    if (activities.getMemberships() != null) {
        checkAndFilter(orcid, activities.getMemberships().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Qualifications
    if (activities.getQualifications() != null) {
        checkAndFilter(orcid, activities.getQualifications().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Services
    if (activities.getServices() != null) {
        checkAndFilter(orcid, activities.getServices().getSummaries(), READ_AFFILIATIONS_REQUIRED_SCOPE, true);
    }
    // Funding
    if (activities.getFundings() != null) {
        Iterator<FundingGroup> groupIt = activities.getFundings().getFundingGroup().iterator();
        while (groupIt.hasNext()) {
            FundingGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getFundingSummary(), READ_FUNDING_REQUIRED_SCOPE, true);
            // Clean external identifiers
            if (group.getFundingSummary().isEmpty()) {
                groupIt.remove();
            } else {
                filterExternalIdentifiers(group);
            }
        }
    }
    // PeerReviews
    if (activities.getPeerReviews() != null) {
        Iterator<PeerReviewGroup> groupIt = activities.getPeerReviews().getPeerReviewGroup().iterator();
        while (groupIt.hasNext()) {
            PeerReviewGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getPeerReviewSummary(), READ_PEER_REVIEWS_REQUIRED_SCOPE, true);
            if (group.getPeerReviewSummary().isEmpty()) {
                groupIt.remove();
            }
        }
    }
    // Works
    if (activities.getWorks() != null) {
        Iterator<WorkGroup> groupIt = activities.getWorks().getWorkGroup().iterator();
        while (groupIt.hasNext()) {
            WorkGroup group = groupIt.next();
            // Filter the list of elements
            checkAndFilter(orcid, group.getWorkSummary(), READ_WORKS_REQUIRED_SCOPE, true);
            // Clean external identifiers
            if (group.getWorkSummary().isEmpty()) {
                groupIt.remove();
            } else {
                filterExternalIdentifiers(group);
            }
        }
    }
}
Also used : PeerReviewGroup(org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewGroup) WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) FundingGroup(org.orcid.jaxb.model.v3.dev1.record.summary.FundingGroup)

Aggregations

Test (org.junit.Test)43 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)40 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)34 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)34 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)34 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)34 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)34 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)34 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)34 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)34 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)34 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)33 Services (org.orcid.jaxb.model.v3.dev1.record.summary.Services)16 Address (org.orcid.jaxb.model.v3.dev1.record.Address)15 Email (org.orcid.jaxb.model.v3.dev1.record.Email)15 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)15 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)15 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)15 Biography (org.orcid.jaxb.model.v3.dev1.record.Biography)14 Name (org.orcid.jaxb.model.v3.dev1.record.Name)14