Search in sources :

Example 91 with ExternalID

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

the class ExternalIDValidator method validateNotificationItems.

public void validateNotificationItems(Items items) {
    if (items == null)
        return;
    List<String> errors = Lists.newArrayList();
    for (Item i : items.getItems()) {
        if (i.getExternalIdentifier() != null && i.getExternalIdentifier().getType() != null) {
            ExternalID extId = i.getExternalIdentifier();
            if (extId.getType() == null || !identifierTypeManager.fetchIdentifierTypesByAPITypeName(null).containsKey(extId.getType())) {
                errors.add(i.getExternalIdentifier().getType());
            }
            if (PojoUtil.isEmpty(extId.getValue())) {
                errors.add("value");
            }
            if (requireRelationshipOnExternalIdentifier) {
                if (extId.getRelationship() == null) {
                    errors.add("relationship");
                }
            }
        }
    }
    checkAndThrow(errors);
}
Also used : Item(org.orcid.jaxb.model.v3.dev1.notification.permission.Item) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID)

Example 92 with ExternalID

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

the class ExternalIDValidator method validateWorkOrPeerReview.

public void validateWorkOrPeerReview(ExternalIDs ids) {
    if (// yeuch
    ids == null)
        return;
    List<String> errors = Lists.newArrayList();
    for (ExternalID id : ids.getExternalIdentifier()) {
        if (id.getType() == null || !identifierTypeManager.fetchIdentifierTypesByAPITypeName(null).containsKey(id.getType())) {
            errors.add(id.getType());
        }
        if (PojoUtil.isEmpty(id.getValue())) {
            errors.add("value");
        }
        if (requireRelationshipOnExternalIdentifier) {
            if (id.getRelationship() == null) {
                errors.add("relationship");
            }
        }
    }
    checkAndThrow(errors);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID)

Example 93 with ExternalID

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

the class WorkManagerReadOnlyImpl method groupWorks.

/**
 * Generate a grouped list of works with the given list of works
 *
 * @param works
 *            The list of works to group
 * @param justPublic
 *            Specify if we want to group only the public elements in the
 *            given list
 * @return Works element with the WorkSummary elements grouped
 */
@Override
public Works groupWorks(List<WorkSummary> works, boolean justPublic) {
    ActivitiesGroupGenerator groupGenerator = new ActivitiesGroupGenerator();
    Works result = new Works();
    // Group all works
    for (WorkSummary work : works) {
        if (justPublic && !work.getVisibility().equals(org.orcid.jaxb.model.v3.dev1.common.Visibility.PUBLIC)) {
        // If it is just public and the work is not public, just ignore
        // it
        } else {
            groupGenerator.group(work);
        }
    }
    List<ActivitiesGroup> groups = groupGenerator.getGroups();
    for (ActivitiesGroup group : groups) {
        Set<GroupAble> externalIdentifiers = group.getGroupKeys();
        Set<GroupableActivity> activities = group.getActivities();
        WorkGroup workGroup = new WorkGroup();
        // Fill the work groups with the external identifiers
        if (externalIdentifiers == null || externalIdentifiers.isEmpty()) {
            // Initialize the ids as an empty list
            workGroup.getIdentifiers().getExternalIdentifier();
        } else {
            for (GroupAble extId : externalIdentifiers) {
                ExternalID workExtId = (ExternalID) extId;
                workGroup.getIdentifiers().getExternalIdentifier().add(workExtId.clone());
            }
        }
        // Fill the work group with the list of activities
        for (GroupableActivity activity : activities) {
            WorkSummary workSummary = (WorkSummary) activity;
            workGroup.getWorkSummary().add(workSummary);
        }
        // Sort the works
        workGroup.getWorkSummary().sort(WorkComparators.ALL);
        result.getWorkGroup().add(workGroup);
    }
    // Sort the groups!
    result.getWorkGroup().sort(WorkComparators.GROUP);
    return result;
}
Also used : WorkGroup(org.orcid.jaxb.model.v3.dev1.record.summary.WorkGroup) WorkSummary(org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) GroupableActivity(org.orcid.jaxb.model.v3.dev1.record.GroupableActivity) ActivitiesGroupGenerator(org.orcid.core.utils.v3.activities.ActivitiesGroupGenerator) Works(org.orcid.jaxb.model.v3.dev1.record.summary.Works) ActivitiesGroup(org.orcid.core.utils.v3.activities.ActivitiesGroup) GroupAble(org.orcid.jaxb.model.v3.dev1.record.GroupAble)

Example 94 with ExternalID

use of org.orcid.jaxb.model.v3.dev1.record.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.v3.dev1.record.ExternalIDs) HashMap(java.util.HashMap) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) FundingSummary(org.orcid.jaxb.model.v3.dev1.record.summary.FundingSummary) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) Title(org.orcid.jaxb.model.v3.dev1.common.Title) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle)

Example 95 with ExternalID

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

the class NormalizationServiceTest method checkBibcodeAndCaseNormalized.

@Test
public void checkBibcodeAndCaseNormalized() {
    ExternalID normed = new ExternalID();
    normed.setRelationship(Relationship.SELF);
    normed.setType("bibcode");
    normed.setValue(" 123456789.A23456789 ");
    // everything should normalize to this.
    normed.setNormalized(new TransientNonEmptyString("123456789.A23456789"));
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("bibcode");
    id1.setValue(" 123456789.A23456789 ");
    id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
    assertEquals(normed, id1);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Test(org.junit.Test)

Aggregations

ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)120 Test (org.junit.Test)73 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)66 Url (org.orcid.jaxb.model.v3.dev1.common.Url)64 Title (org.orcid.jaxb.model.v3.dev1.common.Title)25 Work (org.orcid.jaxb.model.v3.dev1.record.Work)23 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)22 Response (javax.ws.rs.core.Response)20 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)20 DBUnitTest (org.orcid.test.DBUnitTest)20 List (java.util.List)16 TransientNonEmptyString (org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)14 WorkSummary (org.orcid.jaxb.model.v3.dev1.record.summary.WorkSummary)13 ClientResponse (com.sun.jersey.api.client.ClientResponse)12 BaseTest (org.orcid.core.BaseTest)9 OrcidError (org.orcid.jaxb.model.v3.dev1.error.OrcidError)9 ArrayList (java.util.ArrayList)8 Funding (org.orcid.jaxb.model.v3.dev1.record.Funding)8 PeerReview (org.orcid.jaxb.model.v3.dev1.record.PeerReview)8 JSONUrl (org.orcid.core.adapter.jsonidentifier.JSONUrl)7