Search in sources :

Example 31 with ExternalID

use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.

the class OrcidSecurityManagerTestBase method createWorkSummary.

protected WorkSummary createWorkSummary(Visibility v, String sourceId, String extIdValue) {
    WorkSummary work = new WorkSummary();
    work.setVisibility(v);
    ExternalID extId = new ExternalID();
    extId.setValue(extIdValue);
    ExternalIDs extIds = new ExternalIDs();
    extIds.getExternalIdentifier().add(extId);
    work.setExternalIdentifiers(extIds);
    addSharedExtId(extIds);
    setSource(work, sourceId);
    return work;
}
Also used : WorkSummary(org.orcid.jaxb.model.record.summary_v2.WorkSummary) ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID)

Example 32 with ExternalID

use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.

the class ActivityValidatorTest method getExternalIDs.

public ExternalIDs getExternalIDs() {
    ExternalID id1 = getExternalID();
    ExternalIDs extIds = new ExternalIDs();
    extIds.getExternalIdentifier().add(id1);
    return extIds;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID)

Example 33 with ExternalID

use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.

the class ActivityValidatorTest method getExternalID.

public ExternalID getExternalID() {
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("doi");
    id1.setValue("value1");
    id1.setUrl(new Url("http://value1.com"));
    return id1;
}
Also used : ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Url(org.orcid.jaxb.model.common_v2.Url)

Example 34 with ExternalID

use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.

the class ActivitiesGroupGenerator_GroupingFundingsTest method generateFundings.

/**
     * funding-1 -> A, B, C 
     * funding-2 -> C, D, E
     * funding-3 -> X, Y, Z
     * funding-4 -> Y, B, 1
     * funding-5 -> M, N, O 
     * funding-6 -> O, P, Q
     * funding-7 -> 1, 2, B  
     * funding-8 -> No external identifiers
     * funding-9 -> No external identifiers  
     * */
private Map<String, FundingSummary> generateFundings() {
    Map<String, FundingSummary> result = new HashMap<String, FundingSummary>();
    for (int i = 1; i < 10; i++) {
        String name = "funding-" + i;
        FundingSummary funding = new FundingSummary();
        FundingTitle title = new FundingTitle();
        title.setTitle(new Title(name));
        funding.setTitle(title);
        ExternalIDs fei = new ExternalIDs();
        switch(i) {
            case 1:
                ExternalID f1 = new ExternalID();
                f1.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f1.setValue("A");
                ExternalID f2 = new ExternalID();
                f2.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f2.setValue("B");
                ExternalID f3 = new ExternalID();
                f3.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f3.setValue("C");
                fei.getExternalIdentifier().add(f1);
                fei.getExternalIdentifier().add(f2);
                fei.getExternalIdentifier().add(f3);
                break;
            case 2:
                ExternalID f4 = new ExternalID();
                f4.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f4.setValue("C");
                ExternalID f5 = new ExternalID();
                f5.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f5.setValue("D");
                ExternalID f6 = new ExternalID();
                f6.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f6.setValue("E");
                fei.getExternalIdentifier().add(f4);
                fei.getExternalIdentifier().add(f5);
                fei.getExternalIdentifier().add(f6);
                break;
            case 3:
                ExternalID f7 = new ExternalID();
                f7.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f7.setValue("X");
                ExternalID f8 = new ExternalID();
                f8.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f8.setValue("Y");
                ExternalID f9 = new ExternalID();
                f9.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f9.setValue("Z");
                fei.getExternalIdentifier().add(f7);
                fei.getExternalIdentifier().add(f8);
                fei.getExternalIdentifier().add(f9);
                break;
            case 4:
                ExternalID f10 = new ExternalID();
                f10.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f10.setValue("Y");
                ExternalID f11 = new ExternalID();
                f11.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f11.setValue("B");
                ExternalID f12 = new ExternalID();
                f12.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f12.setValue("1");
                fei.getExternalIdentifier().add(f10);
                fei.getExternalIdentifier().add(f11);
                fei.getExternalIdentifier().add(f12);
                break;
            case 5:
                ExternalID f13 = new ExternalID();
                f13.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f13.setValue("M");
                ExternalID f14 = new ExternalID();
                f14.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f14.setValue("N");
                ExternalID f15 = new ExternalID();
                f15.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f15.setValue("O");
                fei.getExternalIdentifier().add(f13);
                fei.getExternalIdentifier().add(f14);
                fei.getExternalIdentifier().add(f15);
                break;
            case 6:
                ExternalID f16 = new ExternalID();
                f16.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f16.setValue("O");
                ExternalID f17 = new ExternalID();
                f17.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f17.setValue("P");
                ExternalID f18 = new ExternalID();
                f18.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f18.setValue("Q");
                fei.getExternalIdentifier().add(f16);
                fei.getExternalIdentifier().add(f17);
                fei.getExternalIdentifier().add(f18);
                break;
            case 7:
                ExternalID f19 = new ExternalID();
                f19.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f19.setValue("1");
                ExternalID f20 = new ExternalID();
                f20.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f20.setValue("2");
                ExternalID f21 = new ExternalID();
                f21.setType(org.orcid.jaxb.model.message.FundingExternalIdentifierType.GRANT_NUMBER.value());
                f21.setValue("B");
                fei.getExternalIdentifier().add(f19);
                fei.getExternalIdentifier().add(f20);
                fei.getExternalIdentifier().add(f21);
                break;
        }
        funding.setExternalIdentifiers(fei);
        result.put(name, funding);
    }
    return result;
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) HashMap(java.util.HashMap) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) FundingSummary(org.orcid.jaxb.model.record.summary_v2.FundingSummary) Title(org.orcid.jaxb.model.common_v2.Title) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle) FundingTitle(org.orcid.jaxb.model.record_v2.FundingTitle)

Example 35 with ExternalID

use of org.orcid.jaxb.model.record_rc4.ExternalID in project ORCID-Source by ORCID.

the class WorksTest method createViewUpdateAndDeleteWork.

@Test
public void createViewUpdateAndDeleteWork() throws JSONException, InterruptedException, URISyntaxException {
    showMyOrcidPage();
    changeDefaultUserVisibility(webDriver, org.orcid.jaxb.model.common_v2.Visibility.PUBLIC);
    long time = System.currentTimeMillis();
    Work workToCreate = (Work) unmarshallFromPath("/record_2.0/samples/read_samples/work-2.0.xml", Work.class);
    workToCreate.setPutCode(null);
    workToCreate.setSource(null);
    workToCreate.getExternalIdentifiers().getExternalIdentifier().clear();
    ExternalID wExtId = new ExternalID();
    wExtId.setValue("Work Id " + time);
    wExtId.setType("agr");
    wExtId.setRelationship(Relationship.SELF);
    wExtId.setUrl(new Url("http://test.orcid.org/" + time));
    workToCreate.getExternalIdentifiers().getExternalIdentifier().add(wExtId);
    String accessToken = getAccessToken();
    ClientResponse postResponse = memberV2ApiClient.createWorkXml(this.getUser1OrcidId(), workToCreate, 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(".*/v2.0/" + this.getUser1OrcidId() + "/work/\\d+"));
    ClientResponse getResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getResponse.getStatus());
    Work gotWork = getResponse.getEntity(Work.class);
    assertEquals("common:title", gotWork.getWorkTitle().getTitle().getContent());
    assertEquals("work:citation", gotWork.getWorkCitation().getCitation());
    assertEquals(CitationType.FORMATTED_UNSPECIFIED, gotWork.getWorkCitation().getWorkCitationType());
    gotWork.getWorkTitle().getTitle().setContent("updated title");
    //Save the original visibility
    Visibility originalVisibility = gotWork.getVisibility();
    Visibility updatedVisibility = Visibility.PRIVATE.equals(originalVisibility) ? Visibility.LIMITED : Visibility.PRIVATE;
    //Verify you cant update the visibility
    gotWork.setVisibility(updatedVisibility);
    ClientResponse putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotWork);
    assertEquals(Response.Status.FORBIDDEN.getStatusCode(), putResponse.getStatus());
    OrcidError error = putResponse.getEntity(OrcidError.class);
    assertNotNull(error);
    assertEquals(Integer.valueOf(9035), error.getErrorCode());
    //Set the visibility again to the initial one
    gotWork.setVisibility(originalVisibility);
    putResponse = memberV2ApiClient.updateLocationXml(postResponse.getLocation(), accessToken, gotWork);
    assertEquals(Response.Status.OK.getStatusCode(), putResponse.getStatus());
    ClientResponse getAfterUpdateResponse = memberV2ApiClient.viewLocationXml(postResponse.getLocation(), accessToken);
    assertEquals(Response.Status.OK.getStatusCode(), getAfterUpdateResponse.getStatus());
    Work gotAfterUpdateWork = getAfterUpdateResponse.getEntity(Work.class);
    assertEquals("updated title", gotAfterUpdateWork.getWorkTitle().getTitle().getContent());
    assertEquals("work:citation", gotAfterUpdateWork.getWorkCitation().getCitation());
    assertEquals(CitationType.FORMATTED_UNSPECIFIED, gotAfterUpdateWork.getWorkCitation().getWorkCitationType());
    ClientResponse deleteResponse = memberV2ApiClient.deleteWorkXml(this.getUser1OrcidId(), gotWork.getPutCode(), accessToken);
    assertEquals(Response.Status.NO_CONTENT.getStatusCode(), deleteResponse.getStatus());
}
Also used : ClientResponse(com.sun.jersey.api.client.ClientResponse) OrcidError(org.orcid.jaxb.model.error_v2.OrcidError) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) Visibility(org.orcid.jaxb.model.common_v2.Visibility) Url(org.orcid.jaxb.model.common_v2.Url) Test(org.junit.Test)

Aggregations

ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)110 Test (org.junit.Test)97 Url (org.orcid.jaxb.model.common_v2.Url)55 ClientResponse (com.sun.jersey.api.client.ClientResponse)52 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)50 Work (org.orcid.jaxb.model.record_v2.Work)32 Title (org.orcid.jaxb.model.common_v2.Title)28 WorkTitle (org.orcid.jaxb.model.record_v2.WorkTitle)22 Funding (org.orcid.jaxb.model.record_v2.Funding)16 PeerReview (org.orcid.jaxb.model.record_v2.PeerReview)16 WorkSummary (org.orcid.jaxb.model.record.summary_v2.WorkSummary)14 ArrayList (java.util.ArrayList)13 ExternalID (org.orcid.jaxb.model.record_rc3.ExternalID)13 ExternalID (org.orcid.jaxb.model.record_rc4.ExternalID)13 FundingTitle (org.orcid.jaxb.model.record_v2.FundingTitle)11 OrcidError (org.orcid.jaxb.model.error_v2.OrcidError)9 WorkGroup (org.orcid.jaxb.model.record.summary_v2.WorkGroup)8 ExternalID (org.orcid.jaxb.model.record_rc2.ExternalID)8 List (java.util.List)7 Validator (javax.xml.validation.Validator)7