Search in sources :

Example 46 with Distinction

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

the class AffiliationsManagerTest method testAddDistinctionToUnclaimedRecordPreserveDistinctionVisibility.

@Test
public void testAddDistinctionToUnclaimedRecordPreserveDistinctionVisibility() {
    when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
    Distinction element = getDistinction();
    element = affiliationsManager.createDistinctionAffiliation(unclaimedOrcid, element, true);
    element = affiliationsManager.getDistinctionAffiliation(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) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) Test(org.junit.Test) BaseTest(org.orcid.core.BaseTest)

Example 47 with Distinction

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

the class AffiliationsManagerTest method getDistinction.

private Distinction getDistinction() {
    Distinction element = new Distinction();
    fillAffiliation(element);
    return element;
}
Also used : Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction)

Example 48 with Distinction

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

the class MemberV3ApiServiceDelegatorImpl method viewDistinction.

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

Example 49 with Distinction

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

the class MemberV3ApiServiceDelegatorImpl method updateDistinction.

@Override
public Response updateDistinction(String orcid, Long putCode, Distinction distinction) {
    orcidSecurityManager.checkClientAccessAndScopes(orcid, ScopePathType.AFFILIATIONS_UPDATE);
    if (!putCode.equals(distinction.getPutCode())) {
        Map<String, String> params = new HashMap<String, String>();
        params.put("urlPutCode", String.valueOf(putCode));
        params.put("bodyPutCode", String.valueOf(distinction.getPutCode()));
        throw new MismatchedPutCodeException(params);
    }
    clearSource(distinction);
    Distinction e = affiliationsManager.updateDistinctionAffiliation(orcid, distinction, true);
    sourceUtils.setSourceName(e);
    return Response.ok(e).build();
}
Also used : HashMap(java.util.HashMap) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) MismatchedPutCodeException(org.orcid.core.exception.MismatchedPutCodeException)

Example 50 with Distinction

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

the class MemberV3Dev1Test method testUpdateDistinctionWithProfileCreationTokenWhenClaimedAndNotSource.

@Test
public void testUpdateDistinctionWithProfileCreationTokenWhenClaimedAndNotSource() throws JSONException, InterruptedException, URISyntaxException {
    Distinction distinction = (Distinction) unmarshallFromPath("/record_3.0_dev1/samples/read_samples/distinction-3.0_dev1.xml", Distinction.class);
    distinction.setPutCode(null);
    distinction.setVisibility(Visibility.PUBLIC);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV3Dev1ApiClientImpl.createDistinctionXml(this.getUser1OrcidId(), distinction, 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() + "/distinction/\\d+"));
    ClientResponse getResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    Distinction gotDistinction = getResponse.getEntity(Distinction.class);
    assertEquals("department-name", gotDistinction.getDepartmentName());
    assertEquals("role-title", gotDistinction.getRoleTitle());
    gotDistinction.setDepartmentName("updated dept. name");
    gotDistinction.setRoleTitle("updated role title");
    String profileCreateToken = oauthHelper.getClientCredentialsAccessToken(this.getClient2ClientId(), this.getClient2ClientSecret(), ScopePathType.ORCID_PROFILE_CREATE);
    ClientResponse putResponse = memberV3Dev1ApiClientImpl.updateLocationXml(postResponse.getLocation(), profileCreateToken, gotDistinction);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV3Dev1ApiClientImpl.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    Distinction gotAfterUpdateDistinction = getAfterUpdateResponse.getEntity(Distinction.class);
    assertEquals("department-name", gotAfterUpdateDistinction.getDepartmentName());
    assertEquals("role-title", gotAfterUpdateDistinction.getRoleTitle());
    ClientResponse deleteResponse = memberV3Dev1ApiClientImpl.deleteDistinctionXml(this.getUser1OrcidId(), gotDistinction.getPutCode(), accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) Test(org.junit.Test)

Aggregations

Distinction (org.orcid.jaxb.model.v3.dev1.record.Distinction)41 Test (org.junit.Test)31 DBUnitTest (org.orcid.test.DBUnitTest)18 Response (javax.ws.rs.core.Response)17 Education (org.orcid.jaxb.model.v3.dev1.record.Education)11 Membership (org.orcid.jaxb.model.v3.dev1.record.Membership)11 Service (org.orcid.jaxb.model.v3.dev1.record.Service)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 DistinctionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.DistinctionSummary)7 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)6 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)5 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)5 ArrayList (java.util.ArrayList)4 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)4 Work (org.orcid.jaxb.model.v3.dev1.record.Work)4 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)4 ClientResponse (com.sun.jersey.api.client.ClientResponse)3