Search in sources :

Example 96 with ExternalID

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

the class NormalizationServiceTest method checkDOIAndCaseNormalized.

@Test
public void checkDOIAndCaseNormalized() {
    ExternalID normed = new ExternalID();
    normed.setRelationship(Relationship.SELF);
    normed.setType("doi");
    normed.setValue("10.1/upper");
    // everything should normalize to this.
    normed.setNormalized(new TransientNonEmptyString("10.1/upper"));
    ExternalID id1 = new ExternalID();
    id1.setRelationship(Relationship.SELF);
    id1.setType("doi");
    id1.setValue("https://dx.doi.org/10.1/UPPER");
    id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
    assertEquals(id1, normed);
    id1.setValue("http://doi.org/10.1/UPPER");
    id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
    assertEquals(id1, normed);
    id1.setValue("10.1/UPPER");
    id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
    assertEquals(id1, normed);
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) TransientNonEmptyString(org.orcid.jaxb.model.v3.dev1.common.TransientNonEmptyString) Test(org.junit.Test)

Example 97 with ExternalID

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

the class JSONFundingExternalIdentifiersConverterV3 method convertFrom.

@Override
public ExternalIDs convertFrom(String source, Type<ExternalIDs> destinationType) {
    JSONFundingExternalIdentifiers fundingExternalIdentifiers = JsonUtils.readObjectFromJsonString(source, JSONFundingExternalIdentifiers.class);
    ExternalIDs externalIDs = new ExternalIDs();
    for (JSONExternalIdentifier externalIdentifier : fundingExternalIdentifiers.getFundingExternalIdentifier()) {
        ExternalID id = new ExternalID();
        if (externalIdentifier.getType() == null) {
            id.setType(FundingExternalIdentifierType.GRANT_NUMBER.value());
        } else {
            id.setType(externalIdentifier.getType().toLowerCase());
        }
        if (externalIdentifier.getUrl() != null && !PojoUtil.isEmpty(externalIdentifier.getUrl().getValue())) {
            Url url = new Url(externalIdentifier.getUrl().getValue());
            id.setUrl(url);
        }
        if (!PojoUtil.isEmpty(externalIdentifier.getValue())) {
            id.setValue(externalIdentifier.getValue());
        }
        if (externalIdentifier.getRelationship() != null) {
            id.setRelationship(Relationship.fromValue(conv.convertFrom(externalIdentifier.getRelationship(), null)));
        }
        externalIDs.getExternalIdentifier().add(id);
    }
    return externalIDs;
}
Also used : JSONExternalIdentifier(org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifier) ExternalIDs(org.orcid.jaxb.model.v3.dev1.record.ExternalIDs) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) JSONFundingExternalIdentifiers(org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers) JSONUrl(org.orcid.core.adapter.jsonidentifier.JSONUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url)

Example 98 with ExternalID

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

the class JSONFundingExternalIdentifiersConverterV3 method convertTo.

@Override
public String convertTo(ExternalIDs source, Type<String> destinationType) {
    JSONFundingExternalIdentifiers jsonFundingExternalIdentifiers = new JSONFundingExternalIdentifiers();
    for (ExternalID externalID : source.getExternalIdentifier()) {
        JSONExternalIdentifier jsonExternalIdentifier = new JSONExternalIdentifier();
        if (externalID.getType() != null) {
            jsonExternalIdentifier.setType(conv.convertTo(externalID.getType(), null));
        }
        if (externalID.getUrl() != null) {
            jsonExternalIdentifier.setUrl(new JSONUrl(externalID.getUrl().getValue()));
        }
        if (!PojoUtil.isEmpty(externalID.getValue())) {
            jsonExternalIdentifier.setValue(externalID.getValue());
        }
        if (externalID.getRelationship() != null) {
            jsonExternalIdentifier.setRelationship(conv.convertTo(externalID.getRelationship().value(), null));
        }
        jsonFundingExternalIdentifiers.getFundingExternalIdentifier().add(jsonExternalIdentifier);
    }
    return JsonUtils.convertToJsonString(jsonFundingExternalIdentifiers);
}
Also used : JSONExternalIdentifier(org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifier) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) JSONFundingExternalIdentifiers(org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers) JSONUrl(org.orcid.core.adapter.jsonidentifier.JSONUrl)

Example 99 with ExternalID

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

the class JSONPeerReviewWorkExternalIdentifierConverterV3 method convertFrom.

@Override
public ExternalID convertFrom(String source, Type<ExternalID> destinationType) {
    JSONWorkExternalIdentifier workExternalIdentifier = JsonUtils.readObjectFromJsonString(source, JSONWorkExternalIdentifier.class);
    ExternalID id = new ExternalID();
    if (workExternalIdentifier.getWorkExternalIdentifierType() == null) {
        id.setType(WorkExternalIdentifierType.OTHER_ID.value());
    } else {
        id.setType(conv.convertFrom(workExternalIdentifier.getWorkExternalIdentifierType(), null));
    }
    if (workExternalIdentifier.getWorkExternalIdentifierId() != null) {
        id.setValue(workExternalIdentifier.getWorkExternalIdentifierId().content);
    }
    if (workExternalIdentifier.getUrl() != null) {
        id.setUrl(new Url(workExternalIdentifier.getUrl().getValue()));
    }
    if (workExternalIdentifier.getRelationship() != null) {
        id.setRelationship(Relationship.fromValue(conv.convertFrom(workExternalIdentifier.getRelationship(), null)));
    }
    return id;
}
Also used : ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) JSONWorkExternalIdentifier(org.orcid.core.adapter.jsonidentifier.JSONWorkExternalIdentifier) JSONUrl(org.orcid.core.adapter.jsonidentifier.JSONUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url)

Example 100 with ExternalID

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

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