Search in sources :

Example 1 with ServiceSummary

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

the class MemberV3ApiServiceDelegatorImpl method viewServices.

@Override
public Response viewServices(String orcid) {
    List<ServiceSummary> servicesList = affiliationsManagerReadOnly.getServiceSummaryList(orcid);
    // Lets copy the list so we don't modify the cached collection
    List<ServiceSummary> filteredList = null;
    if (servicesList != null) {
        filteredList = new ArrayList<ServiceSummary>(servicesList);
    }
    servicesList = filteredList;
    orcidSecurityManager.checkAndFilter(orcid, servicesList, ScopePathType.AFFILIATIONS_READ_LIMITED);
    Services services = new Services(servicesList);
    ActivityUtils.setPathToAffiliations(services, orcid);
    sourceUtils.setSourceName(services);
    Api3_0_Dev1LastModifiedDatesHelper.calculateLastModified(services);
    return Response.ok(services).build();
}
Also used : Services(org.orcid.jaxb.model.v3.dev1.record.summary.Services) ServiceSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)

Example 2 with ServiceSummary

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

the class MemberV3ApiServiceDelegatorImpl method viewServiceSummary.

@Override
public Response viewServiceSummary(String orcid, Long putCode) {
    ServiceSummary es = affiliationsManagerReadOnly.getServiceSummary(orcid, putCode);
    orcidSecurityManager.checkAndFilter(orcid, es, ScopePathType.AFFILIATIONS_READ_LIMITED);
    ActivityUtils.setPathToActivity(es, orcid);
    sourceUtils.setSourceName(es);
    return Response.ok(es).build();
}
Also used : ServiceSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)

Example 3 with ServiceSummary

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

the class MemberV3ApiServiceDelegator_ServicesTest method testAddService.

@Test
public void testAddService() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary originalSummary = (ActivitiesSummary) response.getEntity();
    assertNotNull(originalSummary);
    Utils.verifyLastModified(originalSummary.getLastModifiedDate());
    assertNotNull(originalSummary.getServices());
    Utils.verifyLastModified(originalSummary.getServices().getLastModifiedDate());
    assertNotNull(originalSummary.getServices().getSummaries());
    assertNotNull(originalSummary.getServices().getSummaries().get(0));
    Utils.verifyLastModified(originalSummary.getServices().getSummaries().get(0).getLastModifiedDate());
    assertEquals(4, originalSummary.getServices().getSummaries().size());
    response = serviceDelegator.createService(ORCID, (Service) Utils.getAffiliation(AffiliationType.SERVICE));
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewActivities(ORCID);
    assertNotNull(response);
    ActivitiesSummary summaryWithNewElement = (ActivitiesSummary) response.getEntity();
    assertNotNull(summaryWithNewElement);
    Utils.verifyLastModified(summaryWithNewElement.getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getServices());
    Utils.verifyLastModified(summaryWithNewElement.getServices().getLastModifiedDate());
    assertNotNull(summaryWithNewElement.getServices().getSummaries());
    assertEquals(5, summaryWithNewElement.getServices().getSummaries().size());
    boolean haveNew = false;
    for (ServiceSummary serviceSummary : summaryWithNewElement.getServices().getSummaries()) {
        assertNotNull(serviceSummary.getPutCode());
        Utils.verifyLastModified(serviceSummary.getLastModifiedDate());
        if (serviceSummary.getPutCode().equals(putCode)) {
            assertEquals("My department name", serviceSummary.getDepartmentName());
            haveNew = true;
        } else {
            assertTrue(originalSummary.getServices().getSummaries().contains(serviceSummary));
        }
    }
    assertTrue(haveNew);
    // Remove new element
    serviceDelegator.deleteAffiliation(ORCID, putCode);
}
Also used : Response(javax.ws.rs.core.Response) Service(org.orcid.jaxb.model.v3.dev1.record.Service) List(java.util.List) ServiceSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary) ActivitiesSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with ServiceSummary

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

the class MemberV3ApiServiceDelegator_ServicesTest method testViewServiceSummaryReadPublic.

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

Example 5 with ServiceSummary

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

the class PublicV3ApiServiceDelegatorTest method testViewServices.

@Test
public void testViewServices() {
    Response response = serviceDelegator.viewServices(ORCID);
    assertNotNull(response);
    Services services = (Services) response.getEntity();
    assertNotNull(services);
    assertEquals("/0000-0000-0000-0003/services", services.getPath());
    assertNotNull(services.getLastModifiedDate());
    assertNotNull(services.getLastModifiedDate().getValue());
    assertEquals(1, services.getSummaries().size());
    ServiceSummary service = services.getSummaries().get(0);
    assertEquals(Long.valueOf(47), service.getPutCode());
    assertNotNull(service.getLastModifiedDate());
    assertNotNull(service.getLastModifiedDate().getValue());
    assertEquals("/0000-0000-0000-0003/service/47", service.getPath());
    assertEquals("PUBLIC Department", service.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), service.getVisibility().value());
    assertEquals("APP-5555555555555555", service.getSource().retrieveSourcePath());
}
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)

Aggregations

ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)49 Test (org.junit.Test)40 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)35 EducationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EducationSummary)35 EmploymentSummary (org.orcid.jaxb.model.v3.dev1.record.summary.EmploymentSummary)35 FundingSummary (org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary)35 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)35 MembershipSummary (org.orcid.jaxb.model.v3.dev1.record.summary.MembershipSummary)35 QualificationSummary (org.orcid.jaxb.model.v3.dev1.record.summary.QualificationSummary)35 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)35 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)34 PeerReviewSummary (org.orcid.jaxb.model.v3.dev1.record.summary.PeerReviewSummary)34 Address (org.orcid.jaxb.model.v3.dev1.record.Address)14 Email (org.orcid.jaxb.model.v3.dev1.record.Email)14 Keyword (org.orcid.jaxb.model.v3.dev1.record.Keyword)14 Name (org.orcid.jaxb.model.v3.dev1.record.Name)14 OtherName (org.orcid.jaxb.model.v3.dev1.record.OtherName)14 PersonExternalIdentifier (org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier)14 Record (org.orcid.jaxb.model.v3.dev1.record.Record)14 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)14