Search in sources :

Example 1 with InvitedPosition

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

the class MemberV3ApiServiceDelegatorImpl method viewInvitedPosition.

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

Example 2 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testViewPublicInvitedPosition.

@Test
public void testViewPublicInvitedPosition() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
    assertNotNull(response);
    InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    Utils.verifyLastModified(invitedPosition.getLastModifiedDate());
    assertEquals(Long.valueOf(32L), invitedPosition.getPutCode());
    assertEquals("/0000-0000-0000-0003/invited-position/32", invitedPosition.getPath());
    assertEquals("PUBLIC Department", invitedPosition.getDepartmentName());
    assertEquals(Visibility.PUBLIC.value(), invitedPosition.getVisibility().value());
}
Also used : Response(javax.ws.rs.core.Response) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 3 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testViewInvitedPositions.

@Test
public void testViewInvitedPositions() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response r = serviceDelegator.viewInvitedPositions(ORCID);
    assertNotNull(r);
    InvitedPositions invitedPositions = (InvitedPositions) r.getEntity();
    assertNotNull(invitedPositions);
    assertEquals("/0000-0000-0000-0003/invited-positions", invitedPositions.getPath());
    Utils.verifyLastModified(invitedPositions.getLastModifiedDate());
    assertNotNull(invitedPositions.getSummaries());
    assertEquals(4, invitedPositions.getSummaries().size());
    boolean found1 = false, found2 = false, found3 = false, found4 = false;
    for (InvitedPositionSummary summary : invitedPositions.getSummaries()) {
        Utils.verifyLastModified(summary.getLastModifiedDate());
        if (Long.valueOf(32).equals(summary.getPutCode())) {
            assertEquals("PUBLIC Department", summary.getDepartmentName());
            found1 = true;
        } else if (Long.valueOf(33).equals(summary.getPutCode())) {
            assertEquals("LIMITED Department", summary.getDepartmentName());
            found2 = true;
        } else if (Long.valueOf(34).equals(summary.getPutCode())) {
            assertEquals("PRIVATE Department", summary.getDepartmentName());
            found3 = true;
        } else if (Long.valueOf(35).equals(summary.getPutCode())) {
            assertEquals("SELF LIMITED Department", summary.getDepartmentName());
            found4 = true;
        } else {
            fail("Invalid invitedPosition found: " + summary.getPutCode());
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
    assertTrue(found4);
}
Also used : Response(javax.ws.rs.core.Response) InvitedPositionSummary(org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary) InvitedPositions(org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositions) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 4 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPositionDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateInvitedPositionDuplicateExternalIDs() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    ExternalID e1 = new ExternalID();
    e1.setRelationship(Relationship.SELF);
    e1.setType("erm");
    e1.setUrl(new Url("https://orcid.org"));
    e1.setValue("err");
    ExternalID e2 = new ExternalID();
    e2.setRelationship(Relationship.SELF);
    e2.setType("err");
    e2.setUrl(new Url("http://bbc.co.uk"));
    e2.setValue("erm");
    ExternalIDs externalIDs = new ExternalIDs();
    externalIDs.getExternalIdentifier().add(e1);
    externalIDs.getExternalIdentifier().add(e2);
    InvitedPosition invitedPosition = (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION);
    invitedPosition.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createInvitedPosition(ORCID, invitedPosition);
    assertNotNull(response);
    assertEquals(HttpStatus.SC_CREATED, response.getStatus());
    Map<?, ?> map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode1 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    InvitedPosition another = (InvitedPosition) Utils.getAffiliation(AffiliationType.INVITED_POSITION);
    response = serviceDelegator.createInvitedPosition(ORCID, another);
    map = response.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    resultWithPutCode = (List<?>) map.get("Location");
    Long putCode2 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    response = serviceDelegator.viewInvitedPosition(ORCID, putCode2);
    another = (InvitedPosition) response.getEntity();
    another.setExternalIDs(externalIDs);
    try {
        serviceDelegator.updateInvitedPosition(ORCID, putCode2, another);
    } finally {
        serviceDelegator.deleteAffiliation(ORCID, putCode1);
        serviceDelegator.deleteAffiliation(ORCID, putCode2);
    }
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) List(java.util.List) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 5 with InvitedPosition

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

the class MemberV3ApiServiceDelegator_InvitedPositionsTest method testUpdateInvitedPositionChangingVisibilityTest.

@Test(expected = VisibilityMismatchException.class)
public void testUpdateInvitedPositionChangingVisibilityTest() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    Response response = serviceDelegator.viewInvitedPosition(ORCID, 32L);
    assertNotNull(response);
    InvitedPosition invitedPosition = (InvitedPosition) response.getEntity();
    assertNotNull(invitedPosition);
    assertEquals(Visibility.PUBLIC, invitedPosition.getVisibility());
    invitedPosition.setVisibility(Visibility.PRIVATE);
    response = serviceDelegator.updateInvitedPosition(ORCID, 32L, invitedPosition);
    fail();
}
Also used : Response(javax.ws.rs.core.Response) InvitedPosition(org.orcid.jaxb.model.v3.dev1.record.InvitedPosition) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

InvitedPosition (org.orcid.jaxb.model.v3.dev1.record.InvitedPosition)40 Test (org.junit.Test)28 DBUnitTest (org.orcid.test.DBUnitTest)17 Response (javax.ws.rs.core.Response)16 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 Service (org.orcid.jaxb.model.v3.dev1.record.Service)11 Employment (org.orcid.jaxb.model.v3.dev1.record.Employment)10 Qualification (org.orcid.jaxb.model.v3.dev1.record.Qualification)10 Affiliation (org.orcid.jaxb.model.v3.dev1.record.Affiliation)7 InvitedPositionSummary (org.orcid.jaxb.model.v3.dev1.record.summary.InvitedPositionSummary)6 List (java.util.List)4 Url (org.orcid.jaxb.model.v3.dev1.common.Url)4 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)4 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)4 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)4 Work (org.orcid.jaxb.model.v3.dev1.record.Work)4 ActivitiesSummary (org.orcid.jaxb.model.v3.dev1.record.summary.ActivitiesSummary)4 OrgAffiliationRelationEntity (org.orcid.persistence.jpa.entities.OrgAffiliationRelationEntity)4