@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()); id.setNormalized(new TransientNonEmptyString(norm.normalise(id.getType(), externalIdentifier.getValue()))); if (StringUtils.isEmpty(id.getNormalized().getValue())){ id.setNormalizedError(new TransientError(localeManager.resolveMessage("transientError.normalization_failed.code"),localeManager.resolveMessage("transientError.normalization_failed.message", id.getType(), externalIdentifier.getValue()))); } } if (externalIdentifier.getRelationship() != null) { id.setRelationship(Relationship.fromValue(conv.convertFrom(externalIdentifier.getRelationship(), null))); } externalIDs.getExternalIdentifier().add(id); } return externalIDs; }
public ExternalID clone() { ExternalID id = new ExternalID(); id.type = this.getType(); id.value = this.getValue(); if (this.getNormalized() != null) id.setNormalized(this.getNormalized()); if (this.getNormalizedError() != null) id.setNormalizedError(this.getNormalizedError()); if (this.getUrl() != null) id.url = new Url(this.getUrl().getValue()); if (this.getRelationship() != null) id.relationship = this.getRelationship(); if (this.getNormalizedUrl() != null) id.setNormalizedUrl(this.getNormalizedUrl()); if (this.getNormalizedUrlError() != null) id.setNormalizedUrlError(this.getNormalizedUrlError()); return id; }
id.setNormalizedError(new TransientError(localeManager.resolveMessage("transientError.normalization_failed.code"),localeManager.resolveMessage("transientError.normalization_failed.message",id.getType(),workExternalIdentifier.getWorkExternalIdentifierId().content )));