use of org.orcid.core.adapter.jsonidentifier.JSONWorkExternalIdentifier 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;
}
use of org.orcid.core.adapter.jsonidentifier.JSONWorkExternalIdentifier in project ORCID-Source by ORCID.
the class JSONWorkExternalIdentifiersConverterV1 method convertFrom.
public WorkExternalIdentifiers convertFrom(String source) {
JSONWorkExternalIdentifiers jsonWorkExternalIdentifiers = JsonUtils.readObjectFromJsonString(source, JSONWorkExternalIdentifiers.class);
WorkExternalIdentifiers workExternalIdentifiers = new WorkExternalIdentifiers();
for (JSONWorkExternalIdentifier jsonWorkExternalIdentifier : jsonWorkExternalIdentifiers.getWorkExternalIdentifier()) {
WorkExternalIdentifier workExternalIdentifier = new WorkExternalIdentifier();
try {
workExternalIdentifier.setWorkExternalIdentifierType(WorkExternalIdentifierType.fromValue(conv.convertFrom(jsonWorkExternalIdentifier.getWorkExternalIdentifierType(), null)));
} catch (Exception e) {
workExternalIdentifier.setWorkExternalIdentifierType(WorkExternalIdentifierType.OTHER_ID);
}
workExternalIdentifier.setWorkExternalIdentifierId(new org.orcid.jaxb.model.message.WorkExternalIdentifierId());
if (jsonWorkExternalIdentifier.getWorkExternalIdentifierId() != null) {
workExternalIdentifier.getWorkExternalIdentifierId().setContent(jsonWorkExternalIdentifier.getWorkExternalIdentifierId().content);
}
workExternalIdentifiers.getWorkExternalIdentifier().add(workExternalIdentifier);
}
return workExternalIdentifiers;
}
use of org.orcid.core.adapter.jsonidentifier.JSONWorkExternalIdentifier in project ORCID-Source by ORCID.
the class JSONWorkExternalIdentifiersConverterV2 method convertTo.
@Override
public String convertTo(ExternalIDs source, Type<String> destinationType) {
JSONWorkExternalIdentifiers jsonWorkExternalIdentifiers = new JSONWorkExternalIdentifiers();
for (ExternalID externalID : source.getExternalIdentifier()) {
JSONWorkExternalIdentifier jsonWorkExternalIdentifier = new JSONWorkExternalIdentifier();
if (externalID.getType() != null) {
jsonWorkExternalIdentifier.setWorkExternalIdentifierType(conv.convertTo(externalID.getType(), null));
}
if (externalID.getUrl() != null) {
jsonWorkExternalIdentifier.setUrl(new JSONUrl(externalID.getUrl().getValue()));
}
if (!PojoUtil.isEmpty(externalID.getValue())) {
jsonWorkExternalIdentifier.setWorkExternalIdentifierId(new WorkExternalIdentifierId(externalID.getValue()));
}
if (externalID.getRelationship() != null) {
jsonWorkExternalIdentifier.setRelationship(conv.convertTo(externalID.getRelationship().value(), null));
}
jsonWorkExternalIdentifiers.getWorkExternalIdentifier().add(jsonWorkExternalIdentifier);
}
return JsonUtils.convertToJsonString(jsonWorkExternalIdentifiers);
}
Aggregations