use of org.orcid.jaxb.model.v3.dev1.common.TransientError in project ORCID-Source by ORCID.
the class JSONWorkExternalIdentifiersConverterV3 method convertFrom.
@Override
public ExternalIDs convertFrom(String source, Type<ExternalIDs> destinationType) {
JSONWorkExternalIdentifiers workExternalIdentifiers = JsonUtils.readObjectFromJsonString(source, JSONWorkExternalIdentifiers.class);
ExternalIDs externalIDs = new ExternalIDs();
for (JSONWorkExternalIdentifier workExternalIdentifier : workExternalIdentifiers.getWorkExternalIdentifier()) {
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);
// note, uses API type name.
id.setNormalized(new TransientNonEmptyString(norm.normalise(id.getType(), workExternalIdentifier.getWorkExternalIdentifierId().content)));
if (StringUtils.isEmpty(id.getNormalized().getValue())) {
id.setNormalizedError(new TransientError(localeManager.resolveMessage("transientError.normalization_failed.code"), localeManager.resolveMessage("transientError.normalization_failed.message", id.getType(), 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)));
}
externalIDs.getExternalIdentifier().add(id);
}
return externalIDs;
}
Aggregations