use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.
the class AddressManagerReadOnlyImpl method getPrimaryAddress.
@Override
@Cacheable(value = "primary-address", key = "#orcid.concat('-').concat(#lastModified)")
public Address getPrimaryAddress(String orcid, long lastModified) {
List<AddressEntity> addresses = addressDao.getAddresses(orcid, getLastModified(orcid));
Address address = null;
if (addresses != null) {
//Look for the address with the largest display index
for (AddressEntity entity : addresses) {
if (address == null || address.getDisplayIndex() < entity.getDisplayIndex()) {
address = adapter.toAddress(entity);
}
}
}
return address;
}
use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.
the class AddressManagerTest method displayIndexIsSetTo_1_FromUI.
@Test
public void displayIndexIsSetTo_1_FromUI() {
when(sourceManager.retrieveSourceEntity()).thenReturn(new SourceEntity(new ClientDetailsEntity(CLIENT_1_ID)));
Address address = getAddress(Iso3166Country.MX);
address = addressManager.createAddress(claimedOrcid, address, false);
address = addressManager.getAddress(claimedOrcid, address.getPutCode());
assertNotNull(address);
assertEquals(Long.valueOf(1), address.getDisplayIndex());
}
use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.
the class AddressManagerTest method getAddress.
private Address getAddress(Iso3166Country country) {
Address address = new Address();
address.setCountry(new Country(country));
address.setVisibility(Visibility.PUBLIC);
return address;
}
use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.
the class OrcidSecurityManagerTestBase method createAddress.
protected Address createAddress(Visibility v, String sourceId) {
Address a = new Address();
a.setVisibility(v);
Iso3166Country[] all = Iso3166Country.values();
Random r = new Random();
int index = r.nextInt(all.length);
if (index < 0 || index >= all.length) {
index = 0;
}
a.setCountry(new Country(all[index]));
setSource(a, sourceId);
return a;
}
use of org.orcid.jaxb.model.record_rc4.Address in project ORCID-Source by ORCID.
the class ValidateV2RC2SamplesTest method unmarshallFromPath.
private Object unmarshallFromPath(String path, Class<?> type, String schemaPath) throws SAXException, URISyntaxException {
try (Reader reader = new InputStreamReader(getClass().getResourceAsStream(path))) {
Object obj = unmarshall(reader, type, schemaPath);
Object result = null;
if (ResearcherUrls.class.equals(type)) {
result = (ResearcherUrls) obj;
} else if (ResearcherUrl.class.equals(type)) {
result = (ResearcherUrl) obj;
} else if (PersonalDetails.class.equals(type)) {
result = (PersonalDetails) obj;
} else if (PersonExternalIdentifier.class.equals(type)) {
result = (PersonExternalIdentifier) obj;
} else if (PersonExternalIdentifiers.class.equals(type)) {
result = (PersonExternalIdentifiers) obj;
} else if (Biography.class.equals(type)) {
result = (Biography) obj;
} else if (Name.class.equals(type)) {
result = (Name) obj;
} else if (CreditName.class.equals(type)) {
result = (CreditName) obj;
} else if (OtherName.class.equals(type)) {
result = (OtherName) obj;
} else if (OtherNames.class.equals(type)) {
result = (OtherNames) obj;
} else if (Keywords.class.equals(type)) {
result = (Keywords) obj;
} else if (Keyword.class.equals(type)) {
result = (Keyword) obj;
} else if (Addresses.class.equals(type)) {
result = (Addresses) obj;
} else if (Address.class.equals(type)) {
result = (Address) obj;
} else if (Emails.class.equals(type)) {
result = (Emails) obj;
} else if (Email.class.equals(type)) {
result = (Email) obj;
} else if (Person.class.equals(type)) {
result = (Person) obj;
} else if (Deprecated.class.equals(type)) {
result = (Deprecated) obj;
} else if (Preferences.class.equals(type)) {
result = (Preferences) obj;
} else if (History.class.equals(type)) {
result = (History) obj;
} else if (Record.class.equals(type)) {
result = (Record) obj;
} else if (ActivitiesSummary.class.equals(type)) {
result = (ActivitiesSummary) obj;
}
return result;
} catch (IOException e) {
throw new RuntimeException("Error reading notification from classpath", e);
}
}
Aggregations