use of com.emc.storageos.db.client.constraint.impl.AlternateIdConstraintImpl in project coprhd-controller by CoprHD.
the class NotificationManager method getMailAddressOfUser.
/**
* get user's mail address from UserPreference CF
*
* @param userName
* @return
*/
private String getMailAddressOfUser(String userName) {
DataObjectType doType = TypeMap.getDoType(UserPreferences.class);
AlternateIdConstraint constraint = new AlternateIdConstraintImpl(doType.getColumnField(UserPreferences.USER_ID), userName);
NamedElementQueryResultList queryResults = new NamedElementQueryResultList();
_dbClient.queryByConstraint(constraint, queryResults);
List<URI> userPrefsIds = Lists.newArrayList();
for (NamedElementQueryResultList.NamedElement namedElement : queryResults) {
userPrefsIds.add(namedElement.getId());
}
final List<UserPreferences> userPrefs = Lists.newArrayList();
Iterator<UserPreferences> iter = _dbClient.queryIterativeObjects(UserPreferences.class, userPrefsIds);
while (iter.hasNext()) {
userPrefs.add(iter.next());
}
if (userPrefs.size() > 1) {
throw new IllegalStateException("There should only be 1 user preferences object for a user");
} else if (userPrefs.isEmpty()) {
// if there isn't a user prefs object in the DB yet then we haven't saved one for this user yet.
return null;
}
return userPrefs.get(0).getEmail();
}
use of com.emc.storageos.db.client.constraint.impl.AlternateIdConstraintImpl in project coprhd-controller by CoprHD.
the class ModelClientImpl method findByAlternateId.
@Override
public <T extends DataObject> List<NamedElement> findByAlternateId(Class<T> clazz, String columnField, String value) throws DatabaseException {
LOG.debug("findByAlternateId({}, {}, {})", new Object[] { clazz, columnField, value });
DataObjectType doType = TypeMap.getDoType(clazz);
AlternateIdConstraint constraint = new AlternateIdConstraintImpl(doType.getColumnField(columnField), value);
return queryNamedElementsByConstraint(constraint);
}
Aggregations