Search in sources :

Example 61 with ExternalIDs

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

the class Utils method getFunding.

public static Funding getFunding() {
    Funding newFunding = new Funding();
    FundingTitle title = new FundingTitle();
    title.setTitle(new Title("Public Funding # 2"));
    newFunding.setTitle(title);
    newFunding.setType(FundingType.AWARD);
    ExternalID fExtId = new ExternalID();
    fExtId.setRelationship(Relationship.PART_OF);
    fExtId.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
    fExtId.setUrl(new Url("http://fundingExtId.com"));
    fExtId.setValue("new-funding-ext-id");
    ExternalIDs fExtIds = new ExternalIDs();
    fExtIds.getExternalIdentifier().add(fExtId);
    newFunding.setExternalIdentifiers(fExtIds);
    newFunding.setOrganization(getOrganization());
    return newFunding;
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) Funding(org.orcid.jaxb.model.v3.dev1.record.Funding) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Title(org.orcid.jaxb.model.v3.dev1.common.Title) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url)

Example 62 with ExternalIDs

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

the class Utils method getWork.

public static Work getWork(String title) {
    Work work = new Work();
    WorkTitle workTitle = new WorkTitle();
    workTitle.setTitle(new Title(title));
    work.setWorkTitle(workTitle);
    work.setWorkType(WorkType.BOOK);
    work.setVisibility(Visibility.PUBLIC);
    ExternalIDs extIds = new ExternalIDs();
    ExternalID extId = new ExternalID();
    extId.setRelationship(Relationship.PART_OF);
    extId.setType(WorkExternalIdentifierType.AGR.value());
    extId.setValue("ext-id-" + System.currentTimeMillis());
    extId.setUrl(new Url("http://thisIsANewUrl.com"));
    extIds.getExternalIdentifier().add(extId);
    work.setWorkExternalIdentifiers(extIds);
    return work;
}
Also used : ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) Work(org.orcid.jaxb.model.v3.dev1.record.Work) Title(org.orcid.jaxb.model.v3.dev1.common.Title) FundingTitle(org.orcid.jaxb.model.v3.dev1.record.FundingTitle) WorkTitle(org.orcid.jaxb.model.v3.dev1.record.WorkTitle) ResearcherUrl(org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url)

Example 63 with ExternalIDs

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

the class ActivityValidator method checkFundingExternalIdentifiersForDuplicates.

public void checkFundingExternalIdentifiersForDuplicates(ExternalIDs newExtIds, ExternalIDs existingExtIds, Source existingSource, SourceEntity sourceEntity) {
    if (existingExtIds != null && newExtIds != null) {
        for (ExternalID existingId : existingExtIds.getExternalIdentifier()) {
            for (ExternalID newId : newExtIds.getExternalIdentifier()) {
                if (areRelationshipsSameButNotBothPartOf(existingId.getRelationship(), newId.getRelationship()) && newId.equals(existingId) && sourceEntity.getSourceId().equals(getExistingSource(existingSource))) {
                    Map<String, String> params = new HashMap<String, String>();
                    params.put("clientName", sourceEntity.getSourceName());
                    throw new OrcidDuplicatedActivityException(params);
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) OrcidDuplicatedActivityException(org.orcid.core.exception.OrcidDuplicatedActivityException) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)

Example 64 with ExternalIDs

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

the class ExternalIDValidator method validateFunding.

public void validateFunding(ExternalIDs ids) {
    if (// urgh
    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 65 with ExternalIDs

use of org.orcid.jaxb.model.v3.dev1.record.ExternalIDs 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)

Aggregations

ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)75 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)72 Url (org.orcid.jaxb.model.v3.dev1.common.Url)49 Test (org.junit.Test)45 Title (org.orcid.jaxb.model.v3.dev1.common.Title)23 ResearcherUrl (org.orcid.jaxb.model.v3.dev1.record.ResearcherUrl)22 Response (javax.ws.rs.core.Response)20 DBUnitTest (org.orcid.test.DBUnitTest)20 WorkTitle (org.orcid.jaxb.model.v3.dev1.record.WorkTitle)19 List (java.util.List)15 Work (org.orcid.jaxb.model.v3.dev1.record.Work)14 TransientNonEmptyString (org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString)8 SourceEntity (org.orcid.persistence.jpa.entities.SourceEntity)8 WorkBulk (org.orcid.jaxb.model.v3.dev1.record.WorkBulk)7 BaseTest (org.orcid.core.BaseTest)6 JSONUrl (org.orcid.core.adapter.jsonidentifier.JSONUrl)6 DisambiguatedOrganization (org.orcid.jaxb.model.v3.dev1.common.DisambiguatedOrganization)6 Organization (org.orcid.jaxb.model.v3.dev1.common.Organization)6 OrganizationAddress (org.orcid.jaxb.model.v3.dev1.common.OrganizationAddress)6 FundingTitle (org.orcid.jaxb.model.v3.dev1.record.FundingTitle)6