// 1. get all ReprositoryEntries with lastusage > x
String query = "select re from org.olat.repository.RepositoryEntry as re "
+ " where (re.lastUsage = null or re.lastUsage < :lastUsage)"
+ " and re.olatResource != null ";
DBQuery dbq = DBFactory.getInstance().createQuery(query);
dbq.setDate("lastUsage", lastUsageLimit.getTime());
List reprositoryEntries = dbq.list();
// 2. get all ReprositoryEntries in deletion-process (email send)
query = "select re from org.olat.repository.RepositoryEntry as re"
+ " , org.olat.commons.lifecycle.LifeCycleEntry as le"
+ " where re.key = le.persistentRef "
+ " and re.olatResource != null "
+ " and le.persistentTypeName ='" + RepositoryEntry.class.getName() + "'"
+ " and le.action ='" + SEND_DELETE_EMAIL_ACTION + "' ";
dbq = DBFactory.getInstance().createQuery(query);
List groupsInProcess = dbq.list();
// 3. Remove all ReprositoryEntries in deletion-process from all unused-ReprositoryEntries
reprositoryEntries.removeAll(groupsInProcess);
return filterRepositoryWithReferences(reprositoryEntries);
}