@Test public void selectUsernameIfAbsentTest() { final Map<String, List<Object>> attributes = Collections.singletonMap( CUSTOMARY_FIRST_NAME_ATTRIBUTE, Collections.singletonList(FIRST_NAME)); final IPersonAttributes person = new NamedPersonImpl(USERNAME, attributes); final IPersonAttributes rslt = portalRootPersonAttributeDao.selectUsernameIfAbsent(person); Assert.assertEquals( USERNAME, rslt.getAttributeValue(usernameAttributeProvider.getUsernameAttribute())); }
protected IPersonAttributes selectUsernameIfAbsent(IPersonAttributes person) { IPersonAttributes rslt = person; final String usernameAttribute = usernameAttributeProvider.getUsernameAttribute(); if (!rslt.getAttributes().containsKey(usernameAttribute) && person.getName() != null) { logger.debug("Adding attribute username='{}' for person: ", person.getName(), person); final Map<String, List<Object>> attributes = person.getAttributes(); final Map<String, List<Object>> mutableMap = new LinkedHashMap<>(attributes); mutableMap.put(usernameAttribute, Collections.singletonList(person.getName())); rslt = new NamedPersonImpl(person.getName(), mutableMap); } return rslt; }
PortalRootPersonAttributeDao extends AbstractFlatteningPersonAttributeDao { protected IPersonAttributes selectUsernameIfAbsent(IPersonAttributes person) { IPersonAttributes rslt = person; final String usernameAttribute = usernameAttributeProvider.getUsernameAttribute(); if (!rslt.getAttributes().containsKey(usernameAttribute) && person.getName() != null) { logger.debug("Adding attribute username='{}' for person: ", person.getName(), person); final Map<String, List<Object>> attributes = person.getAttributes(); final Map<String, List<Object>> mutableMap = new LinkedHashMap<>(attributes); mutableMap.put(usernameAttribute, Collections.singletonList(person.getName())); rslt = new NamedPersonImpl(person.getName(), mutableMap); } return rslt; } }
PortalRootPersonAttributeDao extends AbstractFlatteningPersonAttributeDao { protected IPersonAttributes selectUsernameIfAbsent(IPersonAttributes person) { IPersonAttributes rslt = person; final String usernameAttribute = usernameAttributeProvider.getUsernameAttribute(); if (!rslt.getAttributes().containsKey(usernameAttribute) && person.getName() != null) { logger.debug("Adding attribute username='{}' for person: ", person.getName(), person); final Map<String, List<Object>> attributes = person.getAttributes(); final Map<String, List<Object>> mutableMap = new LinkedHashMap<>(attributes); mutableMap.put(usernameAttribute, Collections.singletonList(person.getName())); rslt = new NamedPersonImpl(person.getName(), mutableMap); } return rslt; }  }
PortalRootPersonAttributeDao extends AbstractFlatteningPersonAttributeDao { protected IPersonAttributes selectUsernameIfAbsent(IPersonAttributes person) { IPersonAttributes rslt = person; final String usernameAttribute = usernameAttributeProvider.getUsernameAttribute(); if (!rslt.getAttributes().containsKey(usernameAttribute) && person.getName() != null) { logger.debug("Adding attribute username='{}' for person: ", person.getName(), person); final Map<String, List<Object>> attributes = person.getAttributes(); final Map<String, List<Object>> mutableMap = new LinkedHashMap<>(attributes); mutableMap.put(usernameAttribute, Collections.singletonList(person.getName())); rslt = new NamedPersonImpl(person.getName(), mutableMap); } return rslt; }  IPersonAttributeDao getDelegatePersonAttributeDao(); @Required void setDelegatePersonAttributeDao(IPersonAttributeDao delegatePersonAttributeDao); @Autowired void setUsernameAttributeProvider(IUsernameAttributeProvider usernameAttributeProvider); Map<String, Map<String, List<Object>>> getAttributeOverridesMap(); void setAttributeOverridesMap(Map<String, Map<String, List<Object>>> overridesMap); void setUserAttributeOverride(String uid, Map<String, Object> attributes); void removeUserAttributeOverride(String uid); @Override IPersonAttributes getPerson(String uid); @Override Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(
            Map<String, List<Object>> query); @Override Set<String> getPossibleUserAttributeNames(); @Override Set<String> getAvailableQueryAttributes(); }
PortalRootPersonAttributeDao extends AbstractFlatteningPersonAttributeDao { protected IPersonAttributes selectUsernameIfAbsent(IPersonAttributes person) { IPersonAttributes rslt = person; final String usernameAttribute = usernameAttributeProvider.getUsernameAttribute(); if (!rslt.getAttributes().containsKey(usernameAttribute) && person.getName() != null) { logger.debug("Adding attribute username='{}' for person: ", person.getName(), person); final Map<String, List<Object>> attributes = person.getAttributes(); final Map<String, List<Object>> mutableMap = new LinkedHashMap<>(attributes); mutableMap.put(usernameAttribute, Collections.singletonList(person.getName())); rslt = new NamedPersonImpl(person.getName(), mutableMap); } return rslt; }  IPersonAttributeDao getDelegatePersonAttributeDao(); @Required void setDelegatePersonAttributeDao(IPersonAttributeDao delegatePersonAttributeDao); @Autowired void setUsernameAttributeProvider(IUsernameAttributeProvider usernameAttributeProvider); Map<String, Map<String, List<Object>>> getAttributeOverridesMap(); void setAttributeOverridesMap(Map<String, Map<String, List<Object>>> overridesMap); void setUserAttributeOverride(String uid, Map<String, Object> attributes); void removeUserAttributeOverride(String uid); @Override IPersonAttributes getPerson(String uid); @Override Set<IPersonAttributes> getPeopleWithMultivaluedAttributes(
            Map<String, List<Object>> query); @Override Set<String> getPossibleUserAttributeNames(); @Override Set<String> getAvailableQueryAttributes();  }