Search in sources :

Example 46 with Service

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

the class MapperFacadeFactory method getServiceMapperFacade.

public MapperFacade getServiceMapperFacade() {
    MapperFactory mapperFactory = new DefaultMapperFactory.Builder().build();
    ClassMapBuilder<Service, OrgAffiliationRelationEntity> classMap = mapperFactory.classMap(Service.class, OrgAffiliationRelationEntity.class);
    ClassMapBuilder<ServiceSummary, OrgAffiliationRelationEntity> summaryClassMap = mapperFactory.classMap(ServiceSummary.class, OrgAffiliationRelationEntity.class);
    return generateMapperFacadeForAffiliation(mapperFactory, classMap, summaryClassMap);
}
Also used : DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) DefaultMapperFactory(ma.glasnost.orika.impl.DefaultMapperFactory) MapperFactory(ma.glasnost.orika.MapperFactory) Service(org.orcid.jaxb.model.v3.dev1.record.Service) NormalizationService(org.orcid.core.utils.v3.identifiers.NormalizationService) OrgAffiliationRelationEntity(org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity) ServiceSummary(org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)

Example 47 with Service

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

the class AffiliationsManagerTest method testAddServiceToUnclaimedRecordPreserveServiceVisibility.

@Test
public void testAddServiceToUnclaimedRecordPreserveServiceVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Service element = getService();
    element = affiliationsManager.createServiceAffiliation(unclaimedOrcid, element, true);
    element = affiliationsManager.getServiceAffiliation(unclaimedOrcid, element.getPutCode());
    assertNotNull(element);
    assertEquals(Visibility.PUBLIC, element.getVisibility());
}
Also used : ClientDetailsEntity(org.orcid.persistence.jpa.entities.ClientDetailsEntity) SourceEntity(org.orcid.persistence.jpa.entities.SourceEntity) Service(org.orcid.jaxb.model.v3.dev1.record.Service) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 48 with Service

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

the class ActivityUtilsTest method setPathToServicesTest.

@Test
public void setPathToServicesTest() {
    Services x = getServices();
    ActivityUtils.setPathToAffiliations(x, ORCID);
    assertEquals("/" + ORCID + "/service/123", x.getSummaries().get(0).getPath());
}
Also used : Services(org.orcid.jaxb.model.v3.dev1.record.summary.Services) Test(org.junit.Test)

Example 49 with Service

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

the class MemberV3ApiServiceDelegatorImpl method viewService.

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

Example 50 with Service

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

the class MemberV3Dev1Test method testUpdateServiceWithProfileCreationTokenWhenClaimedAndNotSource.

@Test
public void testUpdateServiceWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
    Service service = (Service) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/service-3.0_dev1.xml", Service.class);
    service.setPutCode(null);
    service.setVisibility(Visibility.PUBLIC);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV3Dev1ApiClientImpl.createServiceXml(this.getUser1OrcidId(), service, accessToken);
    assertNotNull(postResponse);
    assertEquals(Response.Status.CREATED.getStatusCode(), postResponse.getStatus());
    String locationPath = postResponse.getLocation().getPath();
    assertTrue("Location header path should match pattern, but was " + locationPath, locationPath.matches(".*/v3.0_dev1/" + this.getUser1OrcidId() + "/service/\\d+"));
    ClientResponse getResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    Service gotService = getResponse.getEntity(Service.class);
    assertEquals("department-name", gotService.getDepartmentName());
    assertEquals("role-title", gotService.getRoleTitle());
    gotService.setDepartmentName("updated dept. name");
    gotService.setRoleTitle("updated role title");
    String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
    ClientResponse putResponse = memberV3Dev1ApiClientImpl.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotService);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    Service gotAfterUpdateService = getAfterUpdateResponse.getEntity(Service.class);
    assertEquals("department-name", gotAfterUpdateService.getDepartmentName());
    assertEquals("role-title", gotAfterUpdateService.getRoleTitle());
    ClientResponse deleteResponse = memberV3Dev1ApiClientImpl.deleteServiceXml(this.getUser1OrcidId(), gotService.getPutCode(), accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Service(org.orcid.jaxb.model.v3.dev1.record.Service) Test(org.junit.Test)

Aggregations

Service (org.orcid.jaxb.model.v3.dev1.record.Service)41 Test (org.junit.Test)31 DBUnitTest (org.orcid.test.DBUnitTest)18 Response (javax.ws.rs.core.Response)17 Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)11 Education (org.orcid.jaxb.model.v3.dev1.record.Education)11 Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)11 Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)10 InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)10 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)10 Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)8 ServiceSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ServiceSummary)7 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)6 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)4 Work (org.orcid.jaxb.model.v3.dev1.record.Work)4 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)4 Services (org.orcid.jaxb.model.v3.dev1.record.summary.Services)4