Search in sources :

Example 1 with JSONExternalIdentifiers

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

the class JSONExternalIdentifiersConverterV3 method convertTo.

@Override
public String convertTo(ExternalIDs source, Type<String> destinationType) {
    JSONExternalIdentifiers jsonExternalIdentifiers = new JSONExternalIdentifiers();
    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));
        }
        jsonExternalIdentifiers.getExternalIdentifier().add(jsonExternalIdentifier);
    }
    return JsonUtils.convertToJsonString(jsonExternalIdentifiers);
}
Also used : JSONExternalIdentifier(org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifier) ExternalID(org.orcid.jaxb.model.v3.dev1.record.ExternalID) JSONUrl(org.orcid.core.adapter.jsonidentifier.JSONUrl) JSONExternalIdentifiers(org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifiers)

Example 2 with JSONExternalIdentifiers

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

the class JSONExternalIdentifiersConverterV3 method convertFrom.

@Override
public ExternalIDs convertFrom(String source, Type<ExternalIDs> destinationType) {
    JSONExternalIdentifiers externalIdentifiers = JsonUtils.readObjectFromJsonString(source, JSONExternalIdentifiers.class);
    ExternalIDs externalIDs = new ExternalIDs();
    for (JSONExternalIdentifier externalIdentifier : externalIdentifiers.getExternalIdentifier()) {
        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) JSONUrl(org.orcid.core.adapter.jsonidentifier.JSONUrl) Url(org.orcid.jaxb.model.v3.dev1.common.Url) JSONExternalIdentifiers(org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifiers)

Aggregations

JSONExternalIdentifier (org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifier)2 JSONExternalIdentifiers (org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifiers)2 JSONUrl (org.orcid.core.adapter.jsonidentifier.JSONUrl)2 ExternalID (org.orcid.jaxb.model.v3.dev1.record.ExternalID)2 Url (org.orcid.jaxb.model.v3.dev1.common.Url)1 ExternalIDs (org.orcid.jaxb.model.v3.dev1.record.ExternalIDs)1