use of org.orcid.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class NormalizationServiceTest method checkDOIAndCaseNormalized.
@Test
public void checkDOIAndCaseNormalized() {
ExternalID normed = new ExternalID();
normed.setRelationship(Relationship.SELF);
normed.setType("doi");
normed.setValue("10.1/upper");
// everything should normalize to this.
normed.setNormalized(new TransientNonEmptyString("10.1/upper"));
ExternalID id1 = new ExternalID();
id1.setRelationship(Relationship.SELF);
id1.setType("doi");
id1.setValue("https://dx.doi.org/10.1/UPPER");
id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
assertEquals(id1, normed);
id1.setValue("http://doi.org/10.1/UPPER");
id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
assertEquals(id1, normed);
id1.setValue("10.1/UPPER");
id1.setNormalized(new TransientNonEmptyString(norm.normalise(id1.getType(), id1.getValue())));
assertEquals(id1, normed);
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID 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.jaxb.model.v3.dev1.record.ExternalID 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);
}
use of org.orcid.jaxb.model.v3.dev1.record.ExternalID 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.jaxb.model.v3.dev1.record.ExternalID in project ORCID-Source by ORCID.
the class OrcidSecurityManagerTestBase method createWorkSummary.
protected WorkSummary createWorkSummary(Visibility v, String sourceId, String extIdValue) {
WorkSummary work = new WorkSummary();
work.setVisibility(v);
ExternalID extId = new ExternalID();
extId.setValue(extIdValue);
ExternalIDs extIds = new ExternalIDs();
extIds.getExternalIdentifier().add(extId);
work.setExternalIdentifiers(extIds);
addSharedExtId(extIds);
setSource(work, sourceId);
return work;
}
Aggregations