Search in sources :

Example 21 with ExternalIDs

use of org.orcid.jaxb.model.record_rc3.ExternalIDs 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_v2.ExternalIDs) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) TranslatedTitle(org.orcid.jaxb.model.common_v2.TranslatedTitle)

Example 22 with ExternalIDs

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

the class ValidateV2RC3Identifiers method testActivities.

@Test
public void testActivities() {
    ActivitiesSummary as = unmarshallFromPath("/record_2.0_rc3/samples/activities-2.0_rc3.xml", ActivitiesSummary.class);
    ExternalIDs fundingIDs = as.getFundings().getFundingGroup().get(0).getFundingSummary().get(0).getExternalIdentifiers();
    ExternalIDs fundingIDs2 = as.getFundings().getFundingGroup().get(0).getIdentifiers();
    assertEquals("grant_number", fundingIDs.getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", fundingIDs.getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://tempuri.org"), fundingIDs.getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, fundingIDs.getExternalIdentifier().get(0).getRelationship());
    assertEquals(fundingIDs.getExternalIdentifier().get(0).getType(), fundingIDs2.getExternalIdentifier().get(0).getType());
    assertEquals(fundingIDs.getExternalIdentifier().get(0).getValue(), fundingIDs2.getExternalIdentifier().get(0).getValue());
    ExternalIDs peerIDs = as.getPeerReviews().getPeerReviewGroup().get(0).getPeerReviewSummary().get(0).getExternalIdentifiers();
    ExternalIDs peerIDs2 = as.getPeerReviews().getPeerReviewGroup().get(0).getIdentifiers();
    assertEquals("something", peerIDs.getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", peerIDs.getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://orcid.org"), peerIDs.getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, peerIDs.getExternalIdentifier().get(0).getRelationship());
    assertEquals(peerIDs.getExternalIdentifier().get(0).getType(), peerIDs2.getExternalIdentifier().get(0).getType());
    assertEquals(peerIDs.getExternalIdentifier().get(0).getValue(), peerIDs2.getExternalIdentifier().get(0).getValue());
    ExternalIDs workIDs = as.getWorks().getWorkGroup().get(0).getWorkSummary().get(0).getExternalIdentifiers();
    ExternalIDs workIDs2 = as.getWorks().getWorkGroup().get(0).getIdentifiers();
    assertEquals("agr", workIDs.getExternalIdentifier().get(0).getType());
    assertEquals("external-id-value", workIDs.getExternalIdentifier().get(0).getValue());
    assertEquals(new Url("http://orcid.org"), workIDs.getExternalIdentifier().get(0).getUrl());
    assertEquals(Relationship.SELF, workIDs.getExternalIdentifier().get(0).getRelationship());
    assertEquals(workIDs.getExternalIdentifier().get(0).getType(), workIDs2.getExternalIdentifier().get(0).getType());
    assertEquals(workIDs.getExternalIdentifier().get(0).getValue(), workIDs2.getExternalIdentifier().get(0).getValue());
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_rc3.ExternalIDs) Url(org.orcid.jaxb.model.common_rc3.Url) ActivitiesSummary(org.orcid.jaxb.model.record.summary_rc3.ActivitiesSummary) MarshallingTest(org.orcid.jaxb.model.notification.custom.MarshallingTest) Test(org.junit.Test)

Example 23 with ExternalIDs

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

the class WorkToCiteprocTranslatorTest method testBibtexWorkTranslationHyperAuthorLiteralAndMissingDOI.

@Test
public void testBibtexWorkTranslationHyperAuthorLiteralAndMissingDOI() {
    Work w = makeWork(bibtexHyperLiteral);
    ExternalIDs wei = new ExternalIDs();
    ExternalID eid = new ExternalID();
    eid.setType(WorkExternalIdentifierType.DOI.name());
    //WorkExternalIdentifierId id = new WorkExternalIdentifierId();
    eid.setValue("10.1234/1234");
    wei.getExternalIdentifier().add(eid);
    w.setWorkExternalIdentifiers(wei);
    WorkToCiteprocTranslator t = new WorkToCiteprocTranslator();
    CSLItemData d = t.toCiteproc(w, null, true);
    Assert.assertEquals(d.getAuthor().length, 1);
    Assert.assertEquals(d.getAuthor()[0].getLiteral(), "Altshuler, D.M. and Durbin, R.M. and Abecasis, G.R. and Bentley, D.R. and Chakravarti, A. and Clark, A.G. and Donnelly, P. and Eichler, E.E. and Flicek, P. and Gabriel, S.B. and Gibbs, R.A. and Gre...");
    Assert.assertEquals(d.getDOI(), "10.1234/1234");
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) CSLItemData(de.undercouch.citeproc.csl.CSLItemData) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) Work(org.orcid.jaxb.model.record_v2.Work) Test(org.junit.Test)

Example 24 with ExternalIDs

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

the class MemberV2ApiServiceDelegator_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.record_v2.ExternalIDs) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) WorkTitle(org.orcid.jaxb.model.record_v2.WorkTitle) Title(org.orcid.jaxb.model.common_v2.Title) List(java.util.List) PeerReview(org.orcid.jaxb.model.record_v2.PeerReview) DBUnitTest(org.orcid.test.DBUnitTest) Test(org.junit.Test)

Example 25 with ExternalIDs

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

the class OrcidSecurityManagerImpl method filterExternalIdentifiers.

/**
     * Filter the group external identifiers to match the external identifiers
     * that belongs to the activities it have after filtering
     * 
     * @param group
     *            The group we want to filter the external identifiers
     */
private void filterExternalIdentifiers(Group group) {
    // Iterate over every external identifier and check if it is still
    // present in the list of filtered elements
    ExternalIDs extIds = group.getIdentifiers();
    Iterator<ExternalID> extIdsIt = extIds.getExternalIdentifier().iterator();
    while (extIdsIt.hasNext()) {
        ExternalID extId = extIdsIt.next();
        boolean found = false;
        for (GroupableActivity summary : group.getActivities()) {
            if (summary.getExternalIdentifiers() != null) {
                if (summary.getExternalIdentifiers().getExternalIdentifier().contains(extId)) {
                    found = true;
                    break;
                }
            }
        }
        // If the ext id is not found, remove it from the list of ext ids
        if (!found) {
            extIdsIt.remove();
        }
    }
}
Also used : ExternalIDs(org.orcid.jaxb.model.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) GroupableActivity(org.orcid.jaxb.model.record_v2.GroupableActivity)

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