use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class OrcidSecurityManagerTestBase method createPersonExternalIdentifier.
protected PersonExternalIdentifier createPersonExternalIdentifier(Visibility v, String sourceId) {
PersonExternalIdentifier p = new PersonExternalIdentifier();
p.setValue("ext-id-" + System.currentTimeMillis());
p.setVisibility(v);
setSource(p, sourceId);
return p;
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class ExternalIdentifierManagerTest method testAddExternalIdentifierToUnclaimedRecordPreserveExternalIdentifierVisibility.
@Test
public void testAddExternalIdentifierToUnclaimedRecordPreserveExternalIdentifierVisibility() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
PersonExternalIdentifier extId = getExternalIdentifier();
extId = externalIdentifierManager.createExternalIdentifier(unclaimedOrcid, extId, true);
extId = externalIdentifierManager.getExternalIdentifier(unclaimedOrcid, extId.getPutCode());
assertNotNull(extId);
assertEquals(Visibility.PUBLIC, extId.getVisibility());
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class PersonValidatorTest method validateExternalIdentifier_invalidValueTest.
@Test(expected = OrcidValidationException.class)
public void validateExternalIdentifier_invalidValueTest() {
PersonExternalIdentifier extId = getPersonExternalIdentifier();
extId.setValue(null);
PersonValidator.validateExternalIdentifier(extId, getSourceEntity(), true, true, Visibility.PUBLIC, true);
fail();
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class PersonValidatorTest method getPersonExternalIdentifier.
private PersonExternalIdentifier getPersonExternalIdentifier() {
PersonExternalIdentifier extId = new PersonExternalIdentifier();
extId.setRelationship(Relationship.SELF);
extId.setType("doi");
extId.setUrl(new Url("http://test.orcid.org"));
extId.setValue("extId1");
extId.setVisibility(Visibility.PUBLIC);
return extId;
}
use of org.orcid.jaxb.model.v3.dev1.record.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class ExternalIdentifierManagerImpl method updateExternalIdentifier.
@Override
public PersonExternalIdentifier updateExternalIdentifier(String orcid, PersonExternalIdentifier externalIdentifier, boolean isApiRequest) {
SourceEntity sourceEntity = sourceManager.retrieveSourceEntity();
ExternalIdentifierEntity updatedExternalIdentifierEntity = externalIdentifierDao.getExternalIdentifierEntity(orcid, externalIdentifier.getPutCode());
// Save the original source
String existingSourceId = updatedExternalIdentifierEntity.getSourceId();
String existingClientSourceId = updatedExternalIdentifierEntity.getClientSourceId();
Visibility originalVisibility = Visibility.fromValue(updatedExternalIdentifierEntity.getVisibility().value());
// Validate external identifier
PersonValidator.validateExternalIdentifier(externalIdentifier, sourceEntity, false, isApiRequest, originalVisibility, requireRelationshipOnExternalIdentifier);
// Validate it is not duplicated
List<ExternalIdentifierEntity> existingExternalIdentifiers = externalIdentifierDao.getExternalIdentifiers(orcid, getLastModified(orcid));
for (ExternalIdentifierEntity existing : existingExternalIdentifiers) {
if (isDuplicated(existing, externalIdentifier, sourceEntity)) {
Map<String, String> params = new HashMap<String, String>();
params.put("type", "external-identifier");
params.put("value", externalIdentifier.getUrl().getValue());
throw new OrcidDuplicatedElementException(params);
}
}
orcidSecurityManager.checkSource(updatedExternalIdentifierEntity);
jpaJaxbExternalIdentifierAdapter.toExternalIdentifierEntity(externalIdentifier, updatedExternalIdentifierEntity);
updatedExternalIdentifierEntity.setLastModified(new Date());
// Set source
updatedExternalIdentifierEntity.setSourceId(existingSourceId);
updatedExternalIdentifierEntity.setClientSourceId(existingClientSourceId);
externalIdentifierDao.merge(updatedExternalIdentifierEntity);
return jpaJaxbExternalIdentifierAdapter.toExternalIdentifier(updatedExternalIdentifierEntity);
}
Aggregations