NIHVIVO-2299 add getAllUserAccounts() to UserAccountsDao classes.
This commit is contained in:
parent
95d26b9ffb
commit
4e645d0784
4 changed files with 48 additions and 2 deletions
|
@ -13,6 +13,11 @@ import edu.cornell.mannlib.vitro.webapp.beans.UserAccount;
|
||||||
*/
|
*/
|
||||||
public interface UserAccountsDao {
|
public interface UserAccountsDao {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all of the UserAccounts in the model.
|
||||||
|
*/
|
||||||
|
Collection<UserAccount> getAllUserAccounts();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the UserAccount for this URI.
|
* Get the UserAccount for this URI.
|
||||||
*
|
*
|
||||||
|
|
|
@ -27,6 +27,11 @@ public class UserAccountsDaoFiltering extends BaseFiltering implements
|
||||||
this.filters = filters;
|
this.filters = filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<UserAccount> getAllUserAccounts() {
|
||||||
|
return innerDao.getAllUserAccounts();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserAccount getUserAccountByUri(String uri) {
|
public UserAccount getUserAccountByUri(String uri) {
|
||||||
return innerDao.getUserAccountByUri(uri);
|
return innerDao.getUserAccountByUri(uri);
|
||||||
|
|
|
@ -38,6 +38,36 @@ public class UserAccountsDaoJena extends JenaBaseDao implements UserAccountsDao
|
||||||
return getOntModelSelector().getUserAccountsModel();
|
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
|
@Override
|
||||||
public UserAccount getUserAccountByUri(String uri) {
|
public UserAccount getUserAccountByUri(String uri) {
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
|
|
|
@ -84,4 +84,10 @@ public class UserAccountsDaoStub implements UserAccountsDao {
|
||||||
"UserAccountsDao.getUserAccountByExternalAuthId() not implemented.");
|
"UserAccountsDao.getUserAccountByExternalAuthId() not implemented.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<UserAccount> getAllUserAccounts() {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"UserAccountsDao.getAllUserAccounts() not implemented.");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue