Search in sources :

Example 11 with Work

use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.

the class WorksTest method getWork.

private Work getWork(String title, boolean randomExtId, String extIdValue) {
    Long time = System.currentTimeMillis();
    Work work = new Work();
    WorkTitle workTitle = new WorkTitle();
    Title wTitle = new Title(title);
    workTitle.setTranslatedTitle(new TranslatedTitle(title, "en"));
    workTitle.setTitle(wTitle);
    work.setWorkTitle(workTitle);
    work.setWorkType(WorkType.BOOK);
    ExternalID extId = new ExternalID();
    extId.setRelationship(Relationship.SELF);
    if (randomExtId) {
        extId.setValue("work-ext-id-" + (Math.random() * 1000) + "-" + time);
    } else {
        extId.setValue("work-ext-id-" + extIdValue);
    }
    extId.setType("doi");
    ExternalIDs extIds = new ExternalIDs();
    extIds.getExternalIdentifier().add(extId);
    work.setWorkExternalIdentifiers(extIds);
    return work;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_rc3.ExternalIDs) TranslatedTitle(org.orcid.jaxb.model.common_rc3.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_rc3.WorkTitle) ExternalID(org.orcid.jaxb.model.record_rc3.ExternalID) Work(org.orcid.jaxb.model.record_rc3.Work) WorkTitle(org.orcid.jaxb.model.record_rc3.WorkTitle) Title(org.orcid.jaxb.model.common_rc3.Title) TranslatedTitle(org.orcid.jaxb.model.common_rc3.TranslatedTitle)

Example 12 with Work

use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.

the class MemberV2ApiServiceImplV2_0_rc1 method compareWorkAndCreditNameVisibility.

private void compareWorkAndCreditNameVisibility(Work work) {
    Visibility workVisibility = work.getVisibility();
    if (work.getWorkContributors() != null && work.getWorkContributors().getContributor() != null) {
        for (Contributor contributor : work.getWorkContributors().getContributor()) {
            if (contributor.getCreditName() != null && contributor.getCreditName().getVisibility() != null && contributor.getCreditName().getVisibility().isMoreRestrictiveThan(workVisibility)) {
                String title = (work.getWorkTitle() == null || work.getWorkTitle().getTitle() == null) ? null : work.getWorkTitle().getTitle().getContent();
                LOGGER.error("Client posting work '{}' with visibility ({}) less restrictive than its contributor credit name '{}' ({})", new Object[] { title, workVisibility, contributor.getCreditName().getContent(), contributor.getCreditName().getVisibility() });
            }
        }
    }
}
Also used : FundingContributor(org.orcid.jaxb.model.record_rc1.FundingContributor) Contributor(org.orcid.jaxb.model.common_rc1.Contributor) Visibility(org.orcid.jaxb.model.common_rc1.Visibility)

Example 13 with Work

use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.

the class WorkToCiteprocTranslatorTest method makeWork.

private Work makeWork(String bibtex) {
    Work work = new Work();
    Citation citation = new Citation();
    citation.setWorkCitationType(CitationType.BIBTEX);
    citation.setCitation(bibtex);
    work.setWorkCitation(citation);
    return work;
}
Also used : Work(org.orcid.jaxb.model.record_v2.Work) Citation(org.orcid.jaxb.model.record_v2.Citation)

Example 14 with Work

use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_GeneralTest method testOrcidProfileCreate_CAN_CRUDOnUnclaimedAccounts.

@Test
public void testOrcidProfileCreate_CAN_CRUDOnUnclaimedAccounts() {
    String orcid = "0000-0000-0000-0001";
    SecurityContextTestUtils.setUpSecurityContextForClientOnly();
    // Test address
    Response response = serviceDelegator.createAddress(orcid, Utils.getAddress());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    Long putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewAddress(orcid, putCode);
    assertNotNull(response);
    Address address = (Address) response.getEntity();
    assertNotNull(address);
    address.getCountry().setValue(Iso3166Country.ZW);
    response = serviceDelegator.updateAddress(orcid, putCode, address);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteAddress(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test education
    response = serviceDelegator.createEducation(orcid, Utils.getEducation());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewEducation(orcid, putCode);
    assertNotNull(response);
    Education education = (Education) response.getEntity();
    assertNotNull(education);
    education.setDepartmentName("Updated department name");
    response = serviceDelegator.updateEducation(orcid, putCode, education);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteAffiliation(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test employment
    response = serviceDelegator.createEmployment(orcid, Utils.getEmployment());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewEmployment(orcid, putCode);
    assertNotNull(response);
    Employment employment = (Employment) response.getEntity();
    assertNotNull(employment);
    employment.setDepartmentName("Updated department name");
    response = serviceDelegator.updateEmployment(orcid, putCode, employment);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteAffiliation(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test external identifiers
    response = serviceDelegator.createExternalIdentifier(orcid, Utils.getPersonExternalIdentifier());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewExternalIdentifier(orcid, putCode);
    assertNotNull(response);
    PersonExternalIdentifier externalIdentifier = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(externalIdentifier);
    response = serviceDelegator.updateExternalIdentifier(orcid, putCode, externalIdentifier);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteExternalIdentifier(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test funding
    response = serviceDelegator.createFunding(orcid, Utils.getFunding());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewFunding(orcid, putCode);
    assertNotNull(response);
    Funding funding = (Funding) response.getEntity();
    assertNotNull(funding);
    response = serviceDelegator.updateFunding(orcid, putCode, funding);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteFunding(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test keyword
    response = serviceDelegator.createKeyword(orcid, Utils.getKeyword());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewKeyword(orcid, putCode);
    assertNotNull(response);
    Keyword keyword = (Keyword) response.getEntity();
    assertNotNull(keyword);
    response = serviceDelegator.updateKeyword(orcid, putCode, keyword);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteKeyword(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test other names
    response = serviceDelegator.createOtherName(orcid, Utils.getOtherName());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewOtherName(orcid, putCode);
    assertNotNull(response);
    OtherName otherName = (OtherName) response.getEntity();
    assertNotNull(otherName);
    response = serviceDelegator.updateOtherName(orcid, putCode, otherName);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteOtherName(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test peer review
    response = serviceDelegator.createPeerReview(orcid, Utils.getPeerReview());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewPeerReview(orcid, putCode);
    assertNotNull(response);
    PeerReview peerReview = (PeerReview) response.getEntity();
    assertNotNull(peerReview);
    response = serviceDelegator.updatePeerReview(orcid, putCode, peerReview);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deletePeerReview(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test researcher url
    response = serviceDelegator.createResearcherUrl(orcid, Utils.getResearcherUrl());
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewResearcherUrl(orcid, putCode);
    assertNotNull(response);
    ResearcherUrl rUrl = (ResearcherUrl) response.getEntity();
    assertNotNull(rUrl);
    response = serviceDelegator.updateResearcherUrl(orcid, putCode, rUrl);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteResearcherUrl(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
    // Test work
    response = serviceDelegator.createWork(orcid, Utils.getWork("work # 1 " + System.currentTimeMillis()));
    assertNotNull(response);
    assertEquals(Response.Status.CREATED.getStatusCode(), response.getStatus());
    putCode = Utils.getPutCode(response);
    response = serviceDelegator.viewWork(orcid, putCode);
    assertNotNull(response);
    Work work = (Work) response.getEntity();
    assertNotNull(work);
    response = serviceDelegator.updateWork(orcid, putCode, work);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    response = serviceDelegator.deleteWork(orcid, putCode);
    assertNotNull(response);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus());
}
Also used : Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Funding(org.orcid.jaxb.model.record_v2.Funding) OtherName(org.orcid.jaxb.model.record_v2.OtherName) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) Response(javax.ws.rs.core.Response) Education(org.orcid.jaxb.model.record_v2.Education) Employment(org.orcid.jaxb.model.record_v2.Employment) Work(org.orcid.jaxb.model.record_v2.Work) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 15 with Work

use of org.orcid.jaxb.model.record_rc1.Work in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_GeneralTest method testOrcidProfileCreate_CANT_UpdateOnClaimedAccounts.

@Test
public void testOrcidProfileCreate_CANT_UpdateOnClaimedAccounts() {
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    Response response = serviceDelegator.viewAddress(ORCID, 9L);
    assertNotNull(response);
    Address a = (Address) response.getEntity();
    assertNotNull(a);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateAddress(ORCID, a.getPutCode(), a);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewEducation(ORCID, 20L);
    assertNotNull(response);
    Education edu = (Education) response.getEntity();
    assertNotNull(edu);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateEducation(ORCID, edu.getPutCode(), edu);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewEmployment(ORCID, 17L);
    assertNotNull(response);
    Employment emp = (Employment) response.getEntity();
    assertNotNull(emp);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateEmployment(ORCID, emp.getPutCode(), emp);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewExternalIdentifier(ORCID, 13L);
    assertNotNull(response);
    PersonExternalIdentifier extId = (PersonExternalIdentifier) response.getEntity();
    assertNotNull(extId);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateExternalIdentifier(ORCID, extId.getPutCode(), extId);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewFunding(ORCID, 10L);
    assertNotNull(response);
    Funding f = (Funding) response.getEntity();
    assertNotNull(f);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateFunding(ORCID, f.getPutCode(), f);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewKeyword(ORCID, 9L);
    assertNotNull(response);
    Keyword k = (Keyword) response.getEntity();
    assertNotNull(k);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateKeyword(ORCID, k.getPutCode(), k);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewOtherName(ORCID, 13L);
    assertNotNull(response);
    OtherName o = (OtherName) response.getEntity();
    assertNotNull(o);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateOtherName(ORCID, o.getPutCode(), o);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewPeerReview(ORCID, 9L);
    assertNotNull(response);
    PeerReview p = (PeerReview) response.getEntity();
    assertNotNull(p);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updatePeerReview(ORCID, p.getPutCode(), p);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewResearcherUrl(ORCID, 13L);
    assertNotNull(response);
    ResearcherUrl r = (ResearcherUrl) response.getEntity();
    assertNotNull(r);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateResearcherUrl(ORCID, r.getPutCode(), r);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED);
    response = serviceDelegator.viewWork(ORCID, 11L);
    assertNotNull(response);
    Work w = (Work) response.getEntity();
    assertNotNull(w);
    try {
        SecurityContextTestUtils.setUpSecurityContextForClientOnly();
        serviceDelegator.updateWork(ORCID, w.getPutCode(), w);
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Non client credential scope found in client request", e.getMessage());
    }
}
Also used : Response(javax.ws.rs.core.Response) Address(org.orcid.jaxb.model.record_v2.Address) Keyword(org.orcid.jaxb.model.record_v2.Keyword) Education(org.orcid.jaxb.model.record_v2.Education) Employment(org.orcid.jaxb.model.record_v2.Employment) Funding(org.orcid.jaxb.model.record_v2.Funding) OtherName(org.orcid.jaxb.model.record_v2.OtherName) Work(org.orcid.jaxb.model.record_v2.Work) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) PersonExternalIdentifier(org.orcid.jaxb.model.record_v2.PersonExternalIdentifier) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)152 Work (org.orcid.jaxb.model.record_v2.Work)151 ClientResponse (com.sun.jersey.api.client.ClientResponse)56 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)35 WorkBulk (org.orcid.jaxb.model.record_v2.WorkBulk)26 DBUnitTest (org.orcid.test.DBUnitTest)25 Response (javax.ws.rs.core.Response)24 Title (org.orcid.jaxb.model.common_v2.Title)24 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)23 Url (org.orcid.jaxb.model.common_v2.Url)22 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)22 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)17 ArrayList (java.util.ArrayList)16 BaseTest (org.orcid.core.BaseTest)16 BulkElement (org.orcid.jaxb.model.record.bulk.BulkElement)16 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)15 Work (org.orcid.jaxb.model.record_rc1.Work)12 WorkExternalIdentifier (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifier)12 WorkExternalIdentifierId (org.orcid.jaxb.model.record_rc1.WorkExternalIdentifierId)12 Work (org.orcid.jaxb.model.record_rc3.Work)11