NIHVIVO-2299 add getAllUserAccounts() to UserAccountsDao classes.

This commit is contained in:
j2blake 2011-06-08 16:05:18 +00:00
parent 95d26b9ffb
commit 4e645d0784
4 changed files with 48 additions and 2 deletions

View file

@ -13,6 +13,11 @@ import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
*/
public interface UserAccountsDao {
/**
* Get all of the UserAccounts in the model.
*/
Collection<UserAccount> getAllUserAccounts();
/**
* Get the UserAccount for this URI.
*

View file

@ -27,6 +27,11 @@ public class UserAccountsDaoFiltering extends BaseFiltering implements
this.filters = filters;
}
@Override
public Collection<UserAccount> getAllUserAccounts() {
return innerDao.getAllUserAccounts();
}
@Override
public UserAccount getUserAccountByUri(String uri) {
return innerDao.getUserAccountByUri(uri);

View file

@ -38,6 +38,36 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao
return getOntModelSelector().getUserAccountsModel();
}
@Override
public Collection<UserAccount> getAllUserAccounts() {
List<String> userUris = new ArrayList<String>();
getOntModel().enterCriticalSection(Lock.READ);
try {
StmtIterator stmts = getOntModel().listStatements((Resource) null,
RDF.type, USERACCOUNT);
while (stmts.hasNext()) {
Resource subject = stmts.next().getSubject();
if (subject != null) {
userUris.add(subject.getURI());
}
}
stmts.close();
} finally {
getOntModel().leaveCriticalSection();
}
List<UserAccount> userAccounts = new ArrayList<UserAccount>();
for (String userUri : userUris) {
UserAccount ua = getUserAccountByUri(userUri);
if (ua != null) {
userAccounts.add(ua);
}
}
return userAccounts;
}
@Override
public UserAccount getUserAccountByUri(String uri) {
if (uri == null) {

View file

@ -84,4 +84,10 @@ public class UserAccountsDaoStub implements UserAccountsDao {
"UserAccountsDao.getUserAccountByExternalAuthId() not implemented.");
}
@Override
public Collection<UserAccount> getAllUserAccounts() {
throw new RuntimeException(
"UserAccountsDao.getAllUserAccounts() not implemented.");
}
}