Search in sources :

Example 1 with JSONFundingExternalIdentifiers

use of org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers in project ORCID-Source by ORCID.

the class JSONFundingExternalIdentifiersConverterV1 method convertFrom.

public FundingExternalIdentifiers convertFrom(String source) {
    JSONFundingExternalIdentifiers jsonFundingExternalIdentifiers = JsonUtils.readObjectFromJsonString(source, JSONFundingExternalIdentifiers.class);
    FundingExternalIdentifiers fundingExternalIdentifiers = new FundingExternalIdentifiers();
    for (JSONExternalIdentifier jsonFundingExternalIdentifier : jsonFundingExternalIdentifiers.getFundingExternalIdentifier()) {
        FundingExternalIdentifier fundingExternalIdentifier = new FundingExternalIdentifier();
        try {
            if (jsonFundingExternalIdentifier.getType() != null) {
                fundingExternalIdentifier.setType(FundingExternalIdentifierType.fromValue(jsonFundingExternalIdentifier.getType().toLowerCase()));
            } else {
                fundingExternalIdentifier.setType(FundingExternalIdentifierType.GRANT_NUMBER);
            }
        } catch (IllegalArgumentException e) {
            fundingExternalIdentifier.setType(FundingExternalIdentifierType.GRANT_NUMBER);
        }
        if (jsonFundingExternalIdentifier.getUrl() != null) {
            org.orcid.jaxb.model.message.Url messageUrl = new org.orcid.jaxb.model.message.Url();
            messageUrl.setValue(jsonFundingExternalIdentifier.getUrl().getValue());
            fundingExternalIdentifier.setUrl(messageUrl);
        }
        fundingExternalIdentifier.setValue(jsonFundingExternalIdentifier.getValue());
        fundingExternalIdentifiers.getFundingExternalIdentifier().add(fundingExternalIdentifier);
    }
    return fundingExternalIdentifiers;
}
Also used : JSONExternalIdentifier(org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifier) JSONFundingExternalIdentifiers(org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers) JSONFundingExternalIdentifiers(org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers) FundingExternalIdentifiers(org.orcid.jaxb.model.message.FundingExternalIdentifiers) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier) JSONUrl(org.orcid.core.adapter.jsonidentifier.JSONUrl)

Example 2 with JSONFundingExternalIdentifiers

use of org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers in project ORCID-Source by ORCID.

the class JSONFundingExternalIdentifiersConverterV2 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.record_v2.ExternalID) JSONFundingExternalIdentifiers(org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers) JSONUrl(org.orcid.core.adapter.jsonidentifier.JSONUrl)

Example 3 with JSONFundingExternalIdentifiers

use of org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers in project ORCID-Source by ORCID.

the class JSONFundingExternalIdentifiersConverterV1 method convertTo.

public String convertTo(FundingExternalIdentifiers messagePojo) {
    JSONFundingExternalIdentifiers fundingExternalIdentifiers = new JSONFundingExternalIdentifiers();
    if (messagePojo != null) {
        for (FundingExternalIdentifier fundingExternalIdentifier : messagePojo.getFundingExternalIdentifier()) {
            JSONExternalIdentifier jsonExternalIdentifier = new JSONExternalIdentifier();
            if (fundingExternalIdentifier.getType() != null) {
                jsonExternalIdentifier.setType(fundingExternalIdentifier.getType().value());
            }
            if (fundingExternalIdentifier.getUrl() != null) {
                jsonExternalIdentifier.setUrl(new JSONUrl(fundingExternalIdentifier.getUrl().getValue()));
            }
            if (!PojoUtil.isEmpty(fundingExternalIdentifier.getValue())) {
                jsonExternalIdentifier.setValue(fundingExternalIdentifier.getValue());
            }
            jsonExternalIdentifier.setRelationship(Relationship.SELF.value());
            fundingExternalIdentifiers.getFundingExternalIdentifier().add(jsonExternalIdentifier);
        }
    }
    return JsonUtils.convertToJsonString(fundingExternalIdentifiers);
}
Also used : JSONExternalIdentifier(org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifier) JSONFundingExternalIdentifiers(org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers) JSONUrl(org.orcid.core.adapter.jsonidentifier.JSONUrl) FundingExternalIdentifier(org.orcid.jaxb.model.message.FundingExternalIdentifier)

Example 4 with JSONFundingExternalIdentifiers

use of org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers in project ORCID-Source by ORCID.

the class JSONFundingExternalIdentifiersConverterV2 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.record_v2.ExternalIDs) ExternalID(org.orcid.jaxb.model.record_v2.ExternalID) JSONFundingExternalIdentifiers(org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers) JSONUrl(org.orcid.core.adapter.jsonidentifier.JSONUrl) Url(org.orcid.jaxb.model.common_v2.Url)

Example 5 with JSONFundingExternalIdentifiers

use of org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers 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)

Aggregations

JSONExternalIdentifier (org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifier)6 JSONFundingExternalIdentifiers (org.orcid.core.adapter.jsonidentifier.JSONFundingExternalIdentifiers)6 JSONUrl (org.orcid.core.adapter.jsonidentifier.JSONUrl)6 FundingExternalIdentifier (org.orcid.jaxb.model.message.FundingExternalIdentifier)2 ExternalID (org.orcid.jaxb.model.record_v2.ExternalID)2 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)2 Url (org.orcid.jaxb.model.common_v2.Url)1 FundingExternalIdentifiers (org.orcid.jaxb.model.message.FundingExternalIdentifiers)1 ExternalIDs (org.orcid.jaxb.model.record_v2.ExternalIDs)1 Url (org.orcid.jaxb.model.v3.dev1.common.Url)1 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)1