use of org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifier 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;
}
use of org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifier 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;
}
use of org.orcid.core.adapter.jsonidentifier.JSONExternalIdentifier 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);
}
Aggregations