use of org.olat.repository.RepositoryEntryMyView in project OpenOLAT by OpenOLAT.
the class DefaultRepositoryEntryDataSource method getRows.
@Override
public final ResultInfos<RepositoryEntryRow> getRows(String query, List<FlexiTableFilter> filters, List<String> condQueries, int firstResult, int maxResults, SortKey... orderBy) {
if (filters != null && filters.size() > 0 && filters.get(0) != null) {
String filter = filters.get(0).getFilter();
if (StringHelper.containsNonWhitespace(filter)) {
searchParams.setFilters(Collections.singletonList(Filter.valueOf(filter)));
} else {
searchParams.setFilters(null);
}
} else {
searchParams.setFilters(null);
}
if (orderBy != null && orderBy.length > 0 && orderBy[0] != null) {
OrderBy o = OrderBy.valueOf(orderBy[0].getKey());
searchParams.setOrderBy(o);
searchParams.setOrderByAsc(orderBy[0].isAsc());
}
if (StringHelper.containsNonWhitespace(query)) {
searchParams.setIdRefsAndTitle(query);
} else {
searchParams.setIdRefsAndTitle(null);
}
List<RepositoryEntryMyView> views = repositoryService.searchMyView(searchParams, firstResult, maxResults);
List<RepositoryEntryRow> rows = processViewModel(views);
ResultInfos<RepositoryEntryRow> results = new DefaultResultInfos<RepositoryEntryRow>(firstResult + rows.size(), -1, rows);
if (firstResult == 0 && views.size() < maxResults) {
count = new Integer(views.size());
}
return results;
}
use of org.olat.repository.RepositoryEntryMyView in project OpenOLAT by OpenOLAT.
the class RepositoryEntryMyCourseQueriesTest method searchViews.
@Test
public void searchViews() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("mycourses-view-1-");
dbInstance.commit();
Roles roles = securityManager.getRoles(id);
SearchMyRepositoryEntryViewParams params = new SearchMyRepositoryEntryViewParams(id, roles);
params.setMarked(Boolean.TRUE);
List<RepositoryEntryMyView> views = repositoryEntryMyCourseViewQueries.searchViews(params, 0, 10);
Assert.assertNotNull(views);
}
use of org.olat.repository.RepositoryEntryMyView in project OpenOLAT by OpenOLAT.
the class RepositoryEntryMyCourseQueriesTest method searchViews_orderBy.
@Test
public void searchViews_orderBy() {
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("mycourses-view-2-");
dbInstance.commit();
Roles roles = securityManager.getRoles(id);
SearchMyRepositoryEntryViewParams params = new SearchMyRepositoryEntryViewParams(id, roles);
params.setMarked(Boolean.TRUE);
for (OrderBy orderBy : OrderBy.values()) {
params.setOrderBy(orderBy);
params.setOrderByAsc(true);
List<RepositoryEntryMyView> viewAsc = repositoryEntryMyCourseViewQueries.searchViews(params, 0, 10);
Assert.assertNotNull(viewAsc);
params.setOrderByAsc(false);
List<RepositoryEntryMyView> viewDesc = repositoryEntryMyCourseViewQueries.searchViews(params, 0, 10);
Assert.assertNotNull(viewDesc);
}
}
use of org.olat.repository.RepositoryEntryMyView in project openolat by klemens.
the class DefaultRepositoryEntryDataSource method processViewModel.
private List<RepositoryEntryRow> processViewModel(List<RepositoryEntryMyView> repoEntries) {
List<Long> repoKeys = new ArrayList<>(repoEntries.size());
List<OLATResource> resourcesWithAC = new ArrayList<>(repoEntries.size());
for (RepositoryEntryMyView entry : repoEntries) {
repoKeys.add(entry.getKey());
if (entry.isValidOfferAvailable()) {
resourcesWithAC.add(entry.getOlatResource());
}
}
List<OLATResourceAccess> resourcesWithOffer = acService.filterResourceWithAC(resourcesWithAC);
repositoryService.filterMembership(searchParams.getIdentity(), repoKeys);
List<RepositoryEntryRow> items = new ArrayList<RepositoryEntryRow>();
for (RepositoryEntryMyView entry : repoEntries) {
RepositoryEntryRow row = new RepositoryEntryRow(entry);
VFSLeaf image = repositoryManager.getImage(entry);
if (image != null) {
row.setThumbnailRelPath(uifactory.getMapperThumbnailUrl() + "/" + image.getName());
}
List<PriceMethod> types = new ArrayList<PriceMethod>();
if (entry.isMembersOnly()) {
// members only always show lock icon
types.add(new PriceMethod("", "o_ac_membersonly_icon", uifactory.getTranslator().translate("cif.access.membersonly.short")));
} else {
// collect access control method icons
OLATResource resource = entry.getOlatResource();
for (OLATResourceAccess resourceAccess : resourcesWithOffer) {
if (resource.getKey().equals(resourceAccess.getResource().getKey())) {
for (PriceMethodBundle bundle : resourceAccess.getMethods()) {
String type = (bundle.getMethod().getMethodCssClass() + "_icon").intern();
String price = bundle.getPrice() == null || bundle.getPrice().isEmpty() ? "" : PriceFormat.fullFormat(bundle.getPrice());
AccessMethodHandler amh = acModule.getAccessMethodHandler(bundle.getMethod().getType());
String displayName = amh.getMethodName(uifactory.getTranslator().getLocale());
types.add(new PriceMethod(price, type, displayName));
}
}
}
}
row.setMember(repoKeys.contains(entry.getKey()));
if (!types.isEmpty()) {
row.setAccessTypes(types);
}
uifactory.forgeMarkLink(row);
uifactory.forgeSelectLink(row);
uifactory.forgeStartLink(row);
uifactory.forgeDetails(row);
uifactory.forgeRatings(row);
uifactory.forgeComments(row);
items.add(row);
}
return items;
}
Aggregations