use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class Api2_0_rc3_LastModifiedDatesHelper method calculateLastModified.
public static void calculateLastModified(PersonExternalIdentifiers extIds) {
if (extIds != null && extIds.getExternalIdentifiers() != null && !extIds.getExternalIdentifiers().isEmpty()) {
LastModifiedDate latest = null;
for (PersonExternalIdentifier extId : extIds.getExternalIdentifiers()) {
if (extId.getLastModifiedDate() != null && extId.getLastModifiedDate().after(latest)) {
latest = extId.getLastModifiedDate();
}
}
extIds.setLastModifiedDate(latest);
}
}
use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class JpaJaxbExternalIdentifierAdapterTest method fromExternalIdentifierEntityToExternalIdentifier.
@Test
public void fromExternalIdentifierEntityToExternalIdentifier() {
ExternalIdentifierEntity entity = getExternalIdentifierEntity();
PersonExternalIdentifier extId = jpaJaxbExternalIdentifierAdapter.toExternalIdentifier(entity);
assertNotNull(extId);
assertNotNull(extId.getCreatedDate());
assertNotNull(extId.getCreatedDate().getValue());
assertNotNull(extId.getLastModifiedDate());
assertNotNull(extId.getLastModifiedDate().getValue());
assertEquals("common-name", extId.getType());
assertEquals("id-reference", extId.getValue());
assertNotNull(extId.getUrl());
assertEquals("http://myurl.com", extId.getUrl().getValue());
assertEquals(Long.valueOf(123), extId.getPutCode());
assertNotNull(extId.getSource());
assertEquals("APP-0000000000000000", extId.getSource().retrieveSourcePath());
assertEquals(Visibility.LIMITED.value(), extId.getVisibility().value());
assertNotNull(extId.getCreatedDate());
assertNotNull(extId.getLastModifiedDate());
}
use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class ExternalIdentifierForm method toPersonExternalIdentifier.
public PersonExternalIdentifier toPersonExternalIdentifier() {
PersonExternalIdentifier result = new PersonExternalIdentifier();
if (putCode != null) {
result.setPutCode(Long.valueOf(putCode));
}
result.setDisplayIndex(displayIndex);
if (visibility != null && visibility.getVisibility() != null) {
result.setVisibility(org.orcid.jaxb.model.common_v2.Visibility.fromValue(visibility.getVisibility().value()));
}
if (url != null) {
result.setUrl(new Url(url));
}
result.setType(commonName);
result.setValue(reference);
return result;
}
use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class ExternalIdentifierManagerTest method testAddEqualsExternalIdentifiersFromSameSource.
@Test(expected = OrcidDuplicatedElementException.class)
public void testAddEqualsExternalIdentifiersFromSameSource() {
PersonExternalIdentifier extId = getExternalIdentifier();
extId.setType(extId.getType() + System.currentTimeMillis());
// Create from client # 1
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
PersonExternalIdentifier extId1 = externalIdentifierManager.createExternalIdentifier(claimedOrcid, extId, true);
assertNotNull(extId1);
assertNotNull(extId1.getPutCode());
// Remove the put code and the source
extId1.setPutCode(null);
extId1.setSource(null);
externalIdentifierManager.createExternalIdentifier(claimedOrcid, extId, true);
fail();
}
use of org.orcid.jaxb.model.record_rc4.PersonExternalIdentifier in project ORCID-Source by ORCID.
the class ExternalIdentifierManagerTest method getAllTest.
@Test
public void getAllTest() {
String orcid = "0000-0000-0000-0003";
PersonExternalIdentifiers elements = externalIdentifierManager.getExternalIdentifiers(orcid, System.currentTimeMillis());
assertNotNull(elements);
assertNotNull(elements.getExternalIdentifiers());
assertEquals(5, elements.getExternalIdentifiers().size());
boolean found1 = false, found2 = false, found3 = false, found4 = false, found5 = false;
for (PersonExternalIdentifier element : elements.getExternalIdentifiers()) {
if (13 == element.getPutCode()) {
found1 = true;
} else if (14 == element.getPutCode()) {
found2 = true;
} else if (15 == element.getPutCode()) {
found3 = true;
} else if (16 == element.getPutCode()) {
found4 = true;
} else if (17 == element.getPutCode()) {
found5 = true;
} else {
fail("Invalid put code found: " + element.getPutCode());
}
}
assertTrue(found1);
assertTrue(found2);
assertTrue(found3);
assertTrue(found4);
assertTrue(found5);
}
Aggregations