diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/UserAccountsDao.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/UserAccountsDao.java index 203556434..927538a31 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/UserAccountsDao.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/UserAccountsDao.java @@ -13,6 +13,11 @@ import edu.cornell.mannlib.vitro.webapp.beans.UserAccount; */ public interface UserAccountsDao { + /** + * Get all of the UserAccounts in the model. + */ + Collection getAllUserAccounts(); + /** * Get the UserAccount for this URI. * diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/UserAccountsDaoFiltering.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/UserAccountsDaoFiltering.java index 6348a2ad0..2a08eb9f8 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/UserAccountsDaoFiltering.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/filtering/UserAccountsDaoFiltering.java @@ -27,6 +27,11 @@ public class UserAccountsDaoFiltering extends BaseFiltering implements this.filters = filters; } + @Override + public Collection getAllUserAccounts() { + return innerDao.getAllUserAccounts(); + } + @Override public UserAccount getUserAccountByUri(String uri) { return innerDao.getUserAccountByUri(uri); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/UserAccountsDaoJena.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/UserAccountsDaoJena.java index 7cf587a04..82613c2da 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/UserAccountsDaoJena.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/dao/jena/UserAccountsDaoJena.java @@ -38,6 +38,36 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao return getOntModelSelector().getUserAccountsModel(); } + @Override + public Collection getAllUserAccounts() { + List userUris = new ArrayList(); + + 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 userAccounts = new ArrayList(); + 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) { @@ -108,9 +138,9 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao if (externalAuthId == null) { return null; } - + String userUri = null; - + getOntModel().enterCriticalSection(Lock.READ); try { StmtIterator stmts = getOntModel().listStatements(null, diff --git a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/UserAccountsDaoStub.java b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/UserAccountsDaoStub.java index 811de33c3..42aa6a104 100644 --- a/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/UserAccountsDaoStub.java +++ b/webapp/test/stubs/edu/cornell/mannlib/vitro/webapp/dao/UserAccountsDaoStub.java @@ -84,4 +84,10 @@ public class UserAccountsDaoStub implements UserAccountsDao { "UserAccountsDao.getUserAccountByExternalAuthId() not implemented."); } + @Override + public Collection getAllUserAccounts() { + throw new RuntimeException( + "UserAccountsDao.getAllUserAccounts() not implemented."); + } + }