Search in sources :

Example 56 with ExternalIDs

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

the class MemberV3ApiServiceDelegator_DistinctionsTest method testUpdateDistinctionDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateDistinctionDuplicateExternalIDs() {
    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);
    Distinction distinction = (Distinction) Utils.getAffiliation(AffiliationType.DISTINCTION);
    distinction.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createDistinction(ORCID, distinction);
    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)));
    Distinction another = (Distinction) Utils.getAffiliation(AffiliationType.DISTINCTION);
    response = serviceDelegator.createDistinction(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.viewDistinction(ORCID, putCode2);
    another = (Distinction) response.getEntity();
    another.setExternalIDs(externalIDs);
    try {
        serviceDelegator.updateDistinction(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) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) List(java.util.List) Distinction(org.orcid.jaxb.model.v3.dev1.record.Distinction) 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 57 with ExternalIDs

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testUpdateMembershipDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testUpdateMembershipDuplicateExternalIDs() {
    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);
    Membership membership = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
    membership.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createMembership(ORCID, membership);
    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)));
    Membership another = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
    response = serviceDelegator.createMembership(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.viewMembership(ORCID, putCode2);
    another = (Membership) response.getEntity();
    another.setExternalIDs(externalIDs);
    try {
        serviceDelegator.updateMembership(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) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) 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 58 with ExternalIDs

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

the class MemberV3ApiServiceDelegator_MembershipsTest method testAddMembershipsDuplicateExternalIDs.

@Test(expected = OrcidDuplicatedActivityException.class)
public void testAddMembershipsDuplicateExternalIDs() {
    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);
    Membership membership = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
    membership.setExternalIDs(externalIDs);
    Response response = serviceDelegator.createMembership(ORCID, membership);
    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 putCode = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    try {
        Membership duplicate = (Membership) Utils.getAffiliation(AffiliationType.MEMBERSHIP);
        duplicate.setExternalIDs(externalIDs);
        serviceDelegator.createMembership(ORCID, duplicate);
    } finally {
        serviceDelegator.deleteAffiliation(ORCID, putCode);
    }
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Membership(org.orcid.jaxb.model.v3.dev1.record.Membership) 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 59 with ExternalIDs

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

the class MemberV3ApiServiceDelegator_PeerReviewsTest method testAddPeerReviewWithSameExtIdValueButDifferentExtIdType.

@Test
public void testAddPeerReviewWithSameExtIdValueButDifferentExtIdType() {
    SecurityContextTestUtils.setUpSecurityContext("4444-4444-4444-4444", ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    PeerReview peerReview1 = new PeerReview();
    ExternalIDs weis1 = new ExternalIDs();
    ExternalID wei1 = new ExternalID();
    wei1.setRelationship(null);
    wei1.setValue("same_but_different_type");
    wei1.setType(WorkExternalIdentifierType.DOI.value());
    weis1.getExternalIdentifier().add(wei1);
    peerReview1.setExternalIdentifiers(weis1);
    peerReview1.setGroupId("issn:0000003");
    peerReview1.setOrganization(Utils.getOrganization());
    peerReview1.setRole(Role.CHAIR);
    peerReview1.setSubjectContainerName(new Title("subject-container-name"));
    peerReview1.setSubjectExternalIdentifier(wei1);
    WorkTitle workTitle1 = new WorkTitle();
    workTitle1.setTitle(new Title("work-title"));
    peerReview1.setSubjectName(workTitle1);
    peerReview1.setSubjectType(WorkType.DATA_SET);
    peerReview1.setType(PeerReviewType.EVALUATION);
    Response response1 = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview1);
    assertNotNull(response1);
    assertEquals(Response.Status.CREATED.getStatusCode(), response1.getStatus());
    Map<?, ?> map = response1.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    List<?> resultWithPutCode = (List<?>) map.get("Location");
    Long putCode1 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    PeerReview peerReview2 = new PeerReview();
    ExternalIDs weis2 = new ExternalIDs();
    ExternalID wei2 = new ExternalID();
    wei2.setRelationship(null);
    // Same value
    wei2.setValue("same_but_different_type");
    // But different
    wei2.setType(WorkExternalIdentifierType.ARXIV.value());
    // type
    weis2.getExternalIdentifier().add(wei2);
    peerReview2.setExternalIdentifiers(weis2);
    peerReview2.setGroupId("issn:0000003");
    peerReview2.setOrganization(Utils.getOrganization());
    peerReview2.setRole(Role.CHAIR);
    peerReview2.setSubjectContainerName(new Title("subject-container-name"));
    peerReview2.setSubjectExternalIdentifier(wei2);
    WorkTitle workTitle2 = new WorkTitle();
    workTitle2.setTitle(new Title("work-title"));
    peerReview2.setSubjectName(workTitle2);
    peerReview2.setSubjectType(WorkType.DATA_SET);
    peerReview2.setType(PeerReviewType.EVALUATION);
    Response response2 = serviceDelegator.createPeerReview("4444-4444-4444-4444", peerReview2);
    assertNotNull(response2);
    assertEquals(Response.Status.CREATED.getStatusCode(), response2.getStatus());
    map = response2.getMetadata();
    assertNotNull(map);
    assertTrue(map.containsKey("Location"));
    resultWithPutCode = (List<?>) map.get("Location");
    Long putCode2 = Long.valueOf(String.valueOf(resultWithPutCode.get(0)));
    // Delete new peer reviews so they don't affect other tests
    serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode1);
    serviceDelegator.deletePeerReview("4444-4444-4444-4444", putCode2);
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Title(org.orcid.jaxb.model.v3.dev1.common.Title) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) List(java.util.List) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 60 with ExternalIDs

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

the class Utils method getPeerReview.

public static PeerReview getPeerReview() {
    PeerReview peerReview = new PeerReview();
    ExternalIDs weis = new ExternalIDs();
    ExternalID wei1 = new ExternalID();
    wei1.setRelationship(Relationship.PART_OF);
    wei1.setUrl(new Url("http://myUrl.com"));
    wei1.setValue("work-external-identifier-id");
    wei1.setType(WorkExternalIdentifierType.DOI.value());
    weis.getExternalIdentifier().add(wei1);
    peerReview.setExternalIdentifiers(weis);
    peerReview.setGroupId("issn:0000003");
    peerReview.setOrganization(getOrganization());
    peerReview.setRole(Role.CHAIR);
    peerReview.setSubjectContainerName(new Title("subject-container-name"));
    peerReview.setSubjectExternalIdentifier(wei1);
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title("work-title"));
    peerReview.setSubjectName(workTitle);
    peerReview.setSubjectType(WorkType.DATA_SET);
    peerReview.setType(PeerReviewType.EVALUATION);
    return peerReview;
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Title(org.orcid.jaxb.model.v3.dev1.common.Title) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) PeerReview(org.orcid.jaxb.model.v3.dev1.record.PeerReview) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url)

Aggregations

ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)75 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)72 Url (org.orcid.jaxb.model.v3.dev1.common.Url)49 Test (org.junit.Test)45 Title (org.orcid.jaxb.model.v3.dev1.common.Title)23 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)22 Response (javax.ws.rs.core.Response)20 DBUnitTest (org.orcid.test.DBUnitTest)20 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)19 List (java.util.List)15 Work (org.orcid.jaxb.model.v3.dev1.record.Work)14 TransientNonEmptyString (org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)8 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)8 WorkBulk (org.orcid.jaxb.model.v3.dev1.record.WorkBulk)7 BaseTest (org.orcid.core.BaseTest)6 JSONUrl (org.orcid.core.adapter.jsonidentifier.JSONUrl)6 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)6 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)6 OrganizationAddress (org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress)6 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)6