use of org.orcid.persistence.jpa.entities.AddressEntity in project ORCID-Source by ORCID.
the class JpaJaxbAddressAdapterTest method getAddressEntity.
private AddressEntity getAddressEntity() {
AddressEntity result = new AddressEntity();
result.setId(Long.valueOf(1));
result.setDateCreated(new Date());
result.setLastModified(new Date());
result.setIso2Country(Iso3166Country.US);
result.setUser(new ProfileEntity("0000-0000-0000-0000"));
result.setVisibility(Visibility.PUBLIC);
result.setClientSourceId("APP-000000001");
return result;
}
use of org.orcid.persistence.jpa.entities.AddressEntity in project ORCID-Source by ORCID.
the class AddressManagerImpl method deleteAddress.
@Override
@Transactional
public boolean deleteAddress(String orcid, Long putCode) {
AddressEntity entity = addressDao.getAddress(orcid, putCode);
orcidSecurityManager.checkSource(entity);
try {
addressDao.remove(entity);
} catch (Exception e) {
return false;
}
return true;
}
use of org.orcid.persistence.jpa.entities.AddressEntity 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.persistence.jpa.entities.AddressEntity in project ORCID-Source by ORCID.
the class ProfileEntityManagerImplTest method testClaimChangingVisibility.
@Test
@Transactional
public void testClaimChangingVisibility() {
Claim claim = new Claim();
claim.setActivitiesVisibilityDefault(org.orcid.pojo.ajaxForm.Visibility.valueOf(Visibility.PRIVATE));
claim.setPassword(Text.valueOf("passwordTest1"));
claim.setPasswordConfirm(Text.valueOf("passwordTest1"));
Checkbox checked = new Checkbox();
checked.setValue(true);
claim.setSendChangeNotifications(checked);
claim.setSendOrcidNews(checked);
claim.setTermsOfUse(checked);
assertTrue(profileEntityManager.claimProfileAndUpdatePreferences("0000-0000-0000-0001", "public_0000-0000-0000-0001@test.orcid.org", Locale.EN, claim));
ProfileEntity profile = profileEntityManager.findByOrcid("0000-0000-0000-0001");
assertNotNull(profile);
assertNotNull(profile.getBiographyEntity());
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, profile.getBiographyEntity().getVisibility());
assertNotNull(profile.getAddresses());
assertEquals(3, profile.getAddresses().size());
for (AddressEntity a : profile.getAddresses()) {
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, a.getVisibility());
}
assertNotNull(profile.getExternalIdentifiers());
assertEquals(3, profile.getExternalIdentifiers().size());
for (ExternalIdentifierEntity e : profile.getExternalIdentifiers()) {
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, e.getVisibility());
}
assertNotNull(profile.getKeywords());
assertEquals(3, profile.getKeywords().size());
for (ProfileKeywordEntity k : profile.getKeywords()) {
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, k.getVisibility());
}
assertNotNull(profile.getOtherNames());
assertEquals(3, profile.getOtherNames().size());
for (OtherNameEntity o : profile.getOtherNames()) {
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, o.getVisibility());
}
assertNotNull(profile.getResearcherUrls());
assertEquals(3, profile.getResearcherUrls().size());
for (ResearcherUrlEntity r : profile.getResearcherUrls()) {
assertEquals(org.orcid.jaxb.model.common_v2.Visibility.PRIVATE, r.getVisibility());
}
}
use of org.orcid.persistence.jpa.entities.AddressEntity in project ORCID-Source by ORCID.
the class MapperFacadeFactory method getAddressMapperFacade.
public MapperFacade getAddressMapperFacade() {
MapperFactory mapperFactory = getNewMapperFactory();
ClassMapBuilder<Address, AddressEntity> addressClassMap = mapperFactory.classMap(Address.class, AddressEntity.class);
addV2DateFields(addressClassMap);
registerSourceConverters(mapperFactory, addressClassMap);
addressClassMap.field("putCode", "id");
addressClassMap.field("country.value", "iso2Country");
addressClassMap.field("visibility", "visibility");
addressClassMap.fieldBToA("displayIndex", "displayIndex");
addressClassMap.byDefault();
addressClassMap.register();
return mapperFactory.getMapperFacade();
}
Aggregations