diff --git a/src/main/java/org/olat/modules/qpool/manager/PoolDAO.java b/src/main/java/org/olat/modules/qpool/manager/PoolDAO.java index e373e31b992e7a409703c87a588cdefc57b55b50..76f2a109008bf1b8a5570d5fb800636d8573ec4f 100644 --- a/src/main/java/org/olat/modules/qpool/manager/PoolDAO.java +++ b/src/main/java/org/olat/modules/qpool/manager/PoolDAO.java @@ -92,7 +92,7 @@ public class PoolDAO { public int removeFromPool(List<QuestionItemShort> items, Pool pool) { if(items == null || items.isEmpty()) return 0; - List<Long> keys = new ArrayList<Long>(); + List<Long> keys = new ArrayList<>(); for(QuestionItemShort item:items) { keys.add(item.getKey()); } diff --git a/src/main/java/org/olat/modules/qpool/manager/QuestionPoolServiceImpl.java b/src/main/java/org/olat/modules/qpool/manager/QuestionPoolServiceImpl.java index 60fc918b4a656c54d72296aa21890451bcd84ba9..7e0ca593a859f33733c909e74179390787fd2cdc 100644 --- a/src/main/java/org/olat/modules/qpool/manager/QuestionPoolServiceImpl.java +++ b/src/main/java/org/olat/modules/qpool/manager/QuestionPoolServiceImpl.java @@ -363,7 +363,7 @@ public class QuestionPoolServiceImpl implements QPoolService { private List<Long> toKeys(List<? extends QuestionItemShort> items) { if(items == null || items.isEmpty()) return Collections.emptyList(); - List<Long> keys = new ArrayList<Long>(items.size()); + List<Long> keys = new ArrayList<>(items.size()); for(QuestionItemShort item:items) { keys.add(item.getKey()); } @@ -502,7 +502,7 @@ public class QuestionPoolServiceImpl implements QPoolService { return;//nothing to do } - List<SecurityGroup> secGroups = new ArrayList<SecurityGroup>(pools.size()); + List<SecurityGroup> secGroups = new ArrayList<>(pools.size()); for(Pool pool:pools) { SecurityGroup secGroup = ((PoolImpl)pool).getOwnerGroup(); secGroups.add(secGroup); @@ -607,7 +607,7 @@ public class QuestionPoolServiceImpl implements QPoolService { if(searchParams.isFulltextSearch()) { try { String queryString = searchParams.getSearchString(); - List<String> condQueries = new ArrayList<String>(); + List<String> condQueries = new ArrayList<>(); if(searchParams.getCondQueries() != null) { condQueries.addAll(searchParams.getCondQueries()); } @@ -616,17 +616,17 @@ public class QuestionPoolServiceImpl implements QPoolService { searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS); if(results.isEmpty()) { - return new DefaultResultInfos<QuestionItemView>(); + return new DefaultResultInfos<>(); } List<QuestionItemView> items = itemQueriesDao.getItemsOfPool(searchParams, results, firstResult, maxResults, orderBy); - return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items); + return new DefaultResultInfos<>(firstResult + items.size(), results.size(), items); } catch (Exception e) { log.error("", e); } - return new DefaultResultInfos<QuestionItemView>(); + return new DefaultResultInfos<>(); } else { List<QuestionItemView> items = itemQueriesDao.getItemsOfPool(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy); - return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items); + return new DefaultResultInfos<>(firstResult + items.size(), -1, items); } } @@ -635,7 +635,7 @@ public class QuestionPoolServiceImpl implements QPoolService { if(searchParams.isFulltextSearch()) { try { String queryString = searchParams.getSearchString(); - List<String> condQueries = new ArrayList<String>(); + List<String> condQueries = new ArrayList<>(); if(searchParams.getCondQueries() != null) { condQueries.addAll(searchParams.getCondQueries()); } @@ -644,17 +644,17 @@ public class QuestionPoolServiceImpl implements QPoolService { searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS); if(results.isEmpty()) { - return new DefaultResultInfos<QuestionItemView>(); + return new DefaultResultInfos<>(); } List<QuestionItemView> items = itemQueriesDao.getItemsByAuthor(searchParams, results, firstResult, maxResults, orderBy); - return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items); + return new DefaultResultInfos<>(firstResult + items.size(), results.size(), items); } catch (Exception e) { log.error("", e); } - return new DefaultResultInfos<QuestionItemView>(); + return new DefaultResultInfos<>(); } else { List<QuestionItemView> items = itemQueriesDao.getItemsByAuthor(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy); - return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items); + return new DefaultResultInfos<>(firstResult + items.size(), -1, items); } } @@ -675,7 +675,7 @@ public class QuestionPoolServiceImpl implements QPoolService { List<Long> favoritKeys = questionItemDao.getFavoritKeys(searchParams.getIdentity()); String queryString = searchParams.getSearchString(); - List<String> condQueries = new ArrayList<String>(); + List<String> condQueries = new ArrayList<>(); if(searchParams.getCondQueries() != null) { condQueries.addAll(searchParams.getCondQueries()); } @@ -684,17 +684,17 @@ public class QuestionPoolServiceImpl implements QPoolService { searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS); if(results.isEmpty()) { - return new DefaultResultInfos<QuestionItemView>(); + return new DefaultResultInfos<>(); } List<QuestionItemView> items = itemQueriesDao.getFavoritItems(searchParams, results, firstResult, maxResults, orderBy); - return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items); + return new DefaultResultInfos<>(firstResult + items.size(), results.size(), items); } catch (Exception e) { log.error("", e); } - return new DefaultResultInfos<QuestionItemView>(); + return new DefaultResultInfos<>(); } else { List<QuestionItemView> items = itemQueriesDao.getFavoritItems(searchParams, searchParams.getItemKeys(), firstResult, maxResults, orderBy); - return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items); + return new DefaultResultInfos<>(firstResult + items.size(), -1, items); } } @@ -719,7 +719,7 @@ public class QuestionPoolServiceImpl implements QPoolService { return;//nothing to do } - List<OLATResource> resources = new ArrayList<OLATResource>(groups.size()); + List<OLATResource> resources = new ArrayList<>(groups.size()); for(BusinessGroup group:groups) { resources.add(group.getResource()); } @@ -752,7 +752,7 @@ public class QuestionPoolServiceImpl implements QPoolService { if(searchParams != null && searchParams.isFulltextSearch()) { try { String queryString = searchParams.getSearchString(); - List<String> condQueries = new ArrayList<String>(); + List<String> condQueries = new ArrayList<>(); if(searchParams.getCondQueries() != null) { condQueries.addAll(searchParams.getCondQueries()); } @@ -760,11 +760,11 @@ public class QuestionPoolServiceImpl implements QPoolService { List<Long> results = searchClient.doSearch(queryString, condQueries, searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS); if(results.isEmpty()) { - return new DefaultResultInfos<QuestionItemView>(); + return new DefaultResultInfos<>(); } List<QuestionItemView> items = itemQueriesDao.getSharedItemByResource(searchParams.getIdentity(), resource, results, searchParams.getFormat(), firstResult, maxResults); - return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items); + return new DefaultResultInfos<>(firstResult + items.size(), results.size(), items); } catch (Exception e) { log.error("", e); } @@ -772,7 +772,7 @@ public class QuestionPoolServiceImpl implements QPoolService { } else { List<QuestionItemView> items = itemQueriesDao.getSharedItemByResource(searchParams.getIdentity(), resource, null, searchParams.getFormat(), firstResult, maxResults, orderBy); - return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items); + return new DefaultResultInfos<>(firstResult + items.size(), -1, items); } } @@ -836,7 +836,7 @@ public class QuestionPoolServiceImpl implements QPoolService { try { List<Long> content = collectionDao.getItemKeysOfCollection(collection); String queryString = searchParams.getSearchString(); - List<String> condQueries = new ArrayList<String>(); + List<String> condQueries = new ArrayList<>(); if(searchParams.getCondQueries() != null) { condQueries.addAll(searchParams.getCondQueries()); } @@ -845,19 +845,19 @@ public class QuestionPoolServiceImpl implements QPoolService { searchParams.getIdentity(), searchParams.getRoles(), 0, MAX_NUMBER_DOCS); if(results.isEmpty()) { - return new DefaultResultInfos<QuestionItemView>(); + return new DefaultResultInfos<>(); } List<QuestionItemView> items = itemQueriesDao.getItemsOfCollection(searchParams.getIdentity(), collection, results, searchParams.getFormat(), firstResult, maxResults, orderBy); - return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), results.size(), items); + return new DefaultResultInfos<>(firstResult + items.size(), results.size(), items); } catch (Exception e) { log.error("", e); } - return new DefaultResultInfos<QuestionItemView>(); + return new DefaultResultInfos<>(); } else { List<QuestionItemView> items = itemQueriesDao.getItemsOfCollection(searchParams.getIdentity(), collection, searchParams.getItemKeys(), searchParams.getFormat(), firstResult, maxResults, orderBy); - return new DefaultResultInfos<QuestionItemView>(firstResult + items.size(), -1, items); + return new DefaultResultInfos<>(firstResult + items.size(), -1, items); } } @@ -884,7 +884,7 @@ public class QuestionPoolServiceImpl implements QPoolService { @Override public ResultInfos<Pool> getPools(int firstResult, int maxResults, SortKey... orderBy) { List<Pool> pools = poolDao.getPools(firstResult, maxResults); - return new DefaultResultInfos<Pool>(firstResult + pools.size(), -1, pools); + return new DefaultResultInfos<>(firstResult + pools.size(), -1, pools); } @Override @@ -943,6 +943,7 @@ public class QuestionPoolServiceImpl implements QPoolService { } } + @Override public Taxonomy getQPoolTaxonomy() { TaxonomyRef ref = getQPoolTaxonomyRef() ; return ref == null ? null: taxonomyDao.loadByKey(ref.getKey()); diff --git a/src/main/java/org/olat/modules/qpool/ui/PoolsController.java b/src/main/java/org/olat/modules/qpool/ui/PoolsController.java index 0cc3ffd84b2c6d677da1fb43c6baa1af7ec535f7..db15672ff10161042265d23527ad187303e01d8f 100644 --- a/src/main/java/org/olat/modules/qpool/ui/PoolsController.java +++ b/src/main/java/org/olat/modules/qpool/ui/PoolsController.java @@ -25,7 +25,6 @@ import java.util.List; import java.util.Set; import org.olat.core.CoreSpringFactory; -import org.olat.core.commons.persistence.ResultInfos; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.form.flexible.FormItem; import org.olat.core.gui.components.form.flexible.FormItemContainer; @@ -103,8 +102,8 @@ public class PoolsController extends FormBasicController { columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(true, Cols.publicPool.i18nKey(), Cols.publicPool.ordinal(), true, "publicPool", FlexiColumnModel.ALIGNMENT_LEFT, new BooleanCellRenderer( - new CSSIconFlexiCellRenderer("o_public"), - new CSSIconFlexiCellRenderer("o_private")) + new CSSIconFlexiCellRenderer("o_icon_pool_public"), + new CSSIconFlexiCellRenderer("o_icon_pool_private")) )); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel(Cols.name.i18nKey(), Cols.name.ordinal(), true, "name")); columnsModel.addFlexiColumnModel(new DefaultFlexiColumnModel("select", translate("select"), "select-pool")); @@ -113,7 +112,7 @@ public class PoolsController extends FormBasicController { poolTable = uifactory.addTableElement(getWindowControl(), "pools", model, getTranslator(), formLayout); poolTable.setMultiSelect(true); poolTable.setRendererType(FlexiTableRendererType.classic); - reloadModel(); + reloadModel(ureq); FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator()); buttonsCont.setRootForm(mainForm); @@ -122,9 +121,9 @@ public class PoolsController extends FormBasicController { uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl()); } - private void reloadModel() { - ResultInfos<Pool> pools = qpoolService.getPools(0, -1); - model.setObjects(pools.getObjects()); + private void reloadModel(UserRequest ureq) { + List<Pool> pools = qpoolService.getPools(getIdentity(), ureq.getUserSession().getRoles()); + model.setObjects(pools); poolTable.reset(); } @@ -141,7 +140,7 @@ public class PoolsController extends FormBasicController { } else if(source == selectButton) { Set<Integer> selectIndexes = poolTable.getMultiSelectedIndex(); if(!selectIndexes.isEmpty()) { - List<Pool> rows = new ArrayList<Pool>(selectIndexes.size()); + List<Pool> rows = new ArrayList<>(selectIndexes.size()); for(Integer index:selectIndexes) { Pool row = model.getObject(index.intValue()); rows.add(row); @@ -225,7 +224,7 @@ public class PoolsController extends FormBasicController { @Override public void setObjects(List<Pool> objects) { - rows = new ArrayList<Pool>(objects); + rows = new ArrayList<>(objects); } @Override