Search in sources :

Example 46 with ExternalIDs

use of org.orcid.jaxb.model.record_rc3.ExternalIDs in project ORCID-Source by ORCID.

the class ExternalIDValidatorTest method testValidExtIdsWorksFine_flagOff.

@Test
public void testValidExtIdsWorksFine_flagOff() {
    ExternalIDs extIds = new ExternalIDs();
    ExternalID id1 = new ExternalID();
    id1.setRelationship(null);
    id1.setType("doi");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    ExternalID id2 = new ExternalID();
    id2.setRelationship(null);
    id2.setType("doi");
    id2.setValue("value1");
    id2.setUrl(new Url("http://value1.com"));
    ExternalID id3 = new ExternalID();
    id3.setRelationship(null);
    id3.setType("doi");
    id3.setValue("value1");
    id3.setUrl(new Url("http://value1.com"));
    extIds.getExternalIdentifier().add(id1);
    extIds.getExternalIdentifier().add(id2);
    extIds.getExternalIdentifier().add(id3);
    validator.validateWorkOrPeerReview(extIds);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 47 with ExternalIDs

use of org.orcid.jaxb.model.record_rc3.ExternalIDs in project ORCID-Source by ORCID.

the class MemberV2ApiServiceDelegator_WorksTest method testCreateWorksWithBulkAllOK.

@Test
public void testCreateWorksWithBulkAllOK() {
    Long time = System.currentTimeMillis();
    SecurityContextTestUtils.setUpSecurityContext(ORCID, ScopePathType.READ_LIMITED, ScopePathType.ACTIVITIES_UPDATE);
    WorkBulk bulk = new WorkBulk();
    for (int i = 0; i < 5; i++) {
        Work work = new Work();
        WorkTitle title = new WorkTitle();
        title.setTitle(new Title("Bulk work " + i + " " + time));
        work.setWorkTitle(title);
        ExternalIDs extIds = new ExternalIDs();
        ExternalID extId = new ExternalID();
        extId.setRelationship(Relationship.SELF);
        extId.setType("doi");
        extId.setUrl(new Url("http://doi/" + i + "/" + time));
        extId.setValue("doi-" + i + "-" + time);
        extIds.getExternalIdentifier().add(extId);
        work.setWorkExternalIdentifiers(extIds);
        work.setWorkType(WorkType.BOOK);
        bulk.getBulk().add(work);
    }
    Response response = serviceDelegator.createWorks(ORCID, bulk);
    assertNotNull(response);
    assertEquals(Response.Status.OK.getStatusCode(), response.getStatus());
    bulk = (WorkBulk) response.getEntity();
    assertNotNull(bulk);
    assertEquals(5, bulk.getBulk().size());
    for (int i = 0; i < 5; i++) {
        assertTrue(Work.class.isAssignableFrom(bulk.getBulk().get(i).getClass()));
        Work w = (Work) bulk.getBulk().get(i);
        Utils.verifyLastModified(w.getLastModifiedDate());
        assertNotNull(w.getPutCode());
        assertTrue(0L < w.getPutCode());
        assertEquals("Bulk work " + i + " " + time, w.getWorkTitle().getTitle().getContent());
        assertNotNull(w.getExternalIdentifiers().getExternalIdentifier());
        assertEquals("doi-" + i + "-" + time, w.getExternalIdentifiers().getExternalIdentifier().get(0).getValue());
        Response r = serviceDelegator.viewWork(ORCID, w.getPutCode());
        assertNotNull(r);
        assertEquals(Response.Status.OK.getStatusCode(), r.getStatus());
        assertEquals("Bulk work " + i + " " + time, ((Work) r.getEntity()).getWorkTitle().getTitle().getContent());
        // Delete the work
        r = serviceDelegator.deleteWork(ORCID, w.getPutCode());
        assertNotNull(r);
        assertEquals(Response.Status.NO_CONTENT.getStatusCode(), r.getStatus());
    }
}
Also used : Response(javax.ws.rs.core.Response) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) WorkBulk(org.orcid.jaxb.model.record_v2.WorkBulk) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) Title(org.orcid.jaxb.model.common_v2.Title) Url(org.orcid.jaxb.model.common_v2.Url) ResearcherUrl(org.orcid.jaxb.model.record_v2.ResearcherUrl) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 48 with ExternalIDs

use of org.orcid.jaxb.model.record_rc3.ExternalIDs in project ORCID-Source by ORCID.

the class SourceInActivitiesTest method getFundingWithPutCode.

private ProfileFundingEntity getFundingWithPutCode(String userOrcid) {
    Funding funding = new Funding();
    funding.setOrganization(getOrganization());
    FundingTitle title = new FundingTitle();
    title.setTitle(new Title("Title " + System.currentTimeMillis()));
    funding.setTitle(title);
    funding.setType(org.orcid.jaxb.model.record_v2.FundingType.AWARD);
    ExternalID extId = new ExternalID();
    extId.setValue("111");
    extId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
    extId.setUrl(new Url("http://test.com"));
    ExternalIDs extIdentifiers = new ExternalIDs();
    extIdentifiers.getExternalIdentifier().add(extId);
    funding.setExternalIdentifiers(extIdentifiers);
    funding.setPutCode(Long.valueOf(111));
    funding = profileFundingManager.createFunding(userOrcid, funding, true);
    return profileFundingManager.getProfileFundingEntity(funding.getPutCode());
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) Funding(org.orcid.jaxb.model.record_v2.Funding) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Title(org.orcid.jaxb.model.common_v2.Title) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) Url(org.orcid.jaxb.model.common_v2.Url)

Example 49 with ExternalIDs

use of org.orcid.jaxb.model.record_rc3.ExternalIDs in project ORCID-Source by ORCID.

the class WorkExternalIdentifiersConversionsTest method testConvertFromExternalIDs.

@Test
public void testConvertFromExternalIDs() {
    WorkExternalIDsConverter conv = new WorkExternalIDsConverter();
    ExternalID id = new ExternalID();
    id.setRelationship(Relationship.SELF);
    id.setType("doi");
    id.setUrl(new Url("http://what.com"));
    id.setValue("value");
    ExternalID id2 = new ExternalID();
    id2.setRelationship(Relationship.PART_OF);
    id2.setType("source-work-id");
    id2.setUrl(new Url("http://whatnow.com"));
    id2.setValue("value2");
    ExternalIDs ids = new ExternalIDs();
    ids.getExternalIdentifier().add(id);
    ids.getExternalIdentifier().add(id2);
    String externalIdentifiersAsString = conv.convertTo(ids, null);
    assertEquals(expectedIDs, externalIdentifiersAsString);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) WorkExternalIDsConverter(org.orcid.core.adapter.impl.jsonidentifiers.WorkExternalIDsConverter) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Example 50 with ExternalIDs

use of org.orcid.jaxb.model.record_rc3.ExternalIDs in project ORCID-Source by ORCID.

the class FundingExternalIdentifiersConversionsTest method coreObjectToRecordTest.

@Test
public void coreObjectToRecordTest() {
    FundingExternalIdentifiers fei = getFundingExternalIdentifiers();
    ExternalIDs messageObject = fei.toRecordPojo();
    assertNotNull(messageObject);
    assertEquals(3, messageObject.getExternalIdentifier().size());
    boolean found1 = false, found2 = false, found3 = false;
    for (ExternalID f : messageObject.getExternalIdentifier()) {
        if (f.getValue().equals("f1")) {
            found1 = true;
            assertEquals("www.f1.com", f.getUrl().getValue());
            assertEquals(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value(), f.getType());
        } else if (f.getValue().equals("f2")) {
            found2 = true;
            assertEquals("www.f2.com", f.getUrl().getValue());
            assertEquals(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value(), f.getType());
        } else if (f.getValue().equals("f3")) {
            found3 = true;
            assertEquals("www.f3.com", f.getUrl().getValue());
            assertEquals(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value(), f.getType());
        } else {
            fail();
        }
    }
    assertTrue(found1);
    assertTrue(found2);
    assertTrue(found3);
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) FundingExternalIdentifiers(org.orcid.core.adapter.impl.jsonidentifiers.FundingExternalIdentifiers) Test(org.junit.Test)

Aggregations

ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)60 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)50 Url (org.orcid.jaxb.model.common_v2.Url)37 Test (org.junit.Test)32 Title (org.orcid.jaxb.model.common_v2.Title)24 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)20 Work (org.orcid.jaxb.model.record_v2.Work)15 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)11 MarshallingTest (org.orcid.jaxb.model.notification.custom.MarshallingTest)8 Funding (org.orcid.jaxb.model.record_v2.Funding)8 ResearcherUrl (org.orcid.jaxb.model.record_v2.ResearcherUrl)7 Organization (org.orcid.jaxb.model.common_v2.Organization)6 OrganizationAddress (org.orcid.jaxb.model.common_v2.OrganizationAddress)6 Response (javax.ws.rs.core.Response)5 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)5 FuzzyDate (org.orcid.jaxb.model.common_v2.FuzzyDate)4 TranslatedTitle (org.orcid.jaxb.model.common_v2.TranslatedTitle)4 ActivitiesSummary (org.orcid.jaxb.model.record.summary_v2.ActivitiesSummary)4 BaseTest (org.orcid.core.BaseTest)3 Day (org.orcid.jaxb.model.common_v2.Day)3