use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.
the class RepositoryManagerQueryTest method testOneShootQueryWithRoles.
@Test
public void testOneShootQueryWithRoles() {
List<String> types = Collections.singletonList(TEST_RES_NAME);
// roles: author + institution manager
Roles role2 = new Roles(false, false, false, true, false, true, false);
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(null, null, null, types, admin, role2, "Volks");
List<RepositoryEntry> resultOneShootInstitut = rm.genericANDQueryWithRolesRestriction(params, 0, -1, true);
assertNotNull(resultOneShootInstitut);
assertFalse(resultOneShootInstitut.isEmpty());
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.
the class RepositoryManagerQueryTest method testOneShootQueryPaging.
@Test
public void testOneShootQueryPaging() {
List<String> types = Collections.singletonList(TEST_RES_NAME);
// roles: institution manager search: authorname
Roles role4 = new Roles(false, false, false, false, false, true, false);
// test paging
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(null, "kan", null, types, null, role4, "Volks");
List<RepositoryEntry> resultOneShootInstitut6 = rm.genericANDQueryWithRolesRestriction(params, 0, 50, true);
rm.countGenericANDQueryWithRolesRestriction(params);
assertNotNull(resultOneShootInstitut6);
assertEquals(50, resultOneShootInstitut6.size());
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.
the class RepositoryManagerQueryTest method testOneShootWithInstitution.
@Test
public void testOneShootWithInstitution() {
List<String> types = Collections.singletonList(TEST_RES_NAME);
// roles: institution manager
Roles role3 = new Roles(false, false, false, true, false, true, false);
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(null, null, null, types, null, role3, "Volks");
List<RepositoryEntry> resultOneShootInstitut3 = rm.genericANDQueryWithRolesRestriction(params, 0, -1, true);
assertNotNull(resultOneShootInstitut3);
assertFalse(resultOneShootInstitut3.isEmpty());
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project OpenOLAT by OpenOLAT.
the class UserCalendarWebService method getCalendars.
private void getCalendars(CalendarVisitor calVisitor, UserRequest ureq) {
Roles roles = ureq.getUserSession().getRoles();
Identity retrievedUser = ureq.getIdentity();
CalendarModule calendarModule = CoreSpringFactory.getImpl(CalendarModule.class);
if (calendarModule.isEnabled()) {
if (calendarModule.isEnablePersonalCalendar()) {
KalendarRenderWrapper personalWrapper = getPersonalCalendar(ureq.getIdentity());
calVisitor.visit(personalWrapper);
}
if (calendarModule.isEnableCourseToolCalendar() || calendarModule.isEnableCourseElementCalendar()) {
RepositoryManager rm = RepositoryManager.getInstance();
ACService acManager = CoreSpringFactory.getImpl(ACService.class);
SearchRepositoryEntryParameters repoParams = new SearchRepositoryEntryParameters(retrievedUser, roles, "CourseModule");
repoParams.setOnlyExplicitMember(true);
repoParams.setIdentity(retrievedUser);
IdentityEnvironment ienv = new IdentityEnvironment();
ienv.setIdentity(retrievedUser);
ienv.setRoles(roles);
List<RepositoryEntry> entries = rm.genericANDQueryWithRolesRestriction(repoParams, 0, -1, true);
for (RepositoryEntry entry : entries) {
AccessResult result = acManager.isAccessible(entry, retrievedUser, false);
if (result.isAccessible()) {
try {
final ICourse course = CourseFactory.loadCourse(entry);
CourseConfig config = course.getCourseEnvironment().getCourseConfig();
UserCourseEnvironment userCourseEnv = new UserCourseEnvironmentImpl(ienv, course.getCourseEnvironment());
if (config.isCalendarEnabled()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
} else {
CalCourseNodeVisitor visitor = new CalCourseNodeVisitor();
new CourseTreeVisitor(course, ienv).visit(visitor, new VisibleTreeFilter());
if (visitor.isFound()) {
KalendarRenderWrapper wrapper = CourseCalendars.getCourseCalendarWrapper(ureq, userCourseEnv, null);
calVisitor.visit(wrapper);
}
}
} catch (Exception e) {
log.error("", e);
}
}
}
}
if (calendarModule.isEnableGroupCalendar()) {
CollaborationManager collaborationManager = CoreSpringFactory.getImpl(CollaborationManager.class);
// start found forums in groups
BusinessGroupService bgm = CoreSpringFactory.getImpl(BusinessGroupService.class);
SearchBusinessGroupParams params = new SearchBusinessGroupParams(retrievedUser, true, true);
params.addTools(CollaborationTools.TOOL_CALENDAR);
List<BusinessGroup> groups = bgm.findBusinessGroups(params, null, 0, -1);
for (BusinessGroup group : groups) {
KalendarRenderWrapper wrapper = collaborationManager.getCalendar(group, ureq, false);
calVisitor.visit(wrapper);
}
}
}
}
use of org.olat.repository.model.SearchRepositoryEntryParameters in project openolat by klemens.
the class CatalogNodeManagerController method loadResources.
private void loadResources(UserRequest ureq) {
SearchRepositoryEntryParameters params = new SearchRepositoryEntryParameters(getIdentity(), ureq.getUserSession().getRoles());
params.setParentEntry(catalogEntry);
List<RepositoryEntry> repoEntries = repositoryManager.genericANDQueryWithRolesRestriction(params, 0, -1, false);
List<Long> resourceKeys = new ArrayList<>();
for (RepositoryEntry entry : repoEntries) {
resourceKeys.add(entry.getOlatResource().getKey());
}
List<OLATResourceAccess> resourcesWithOffer = acService.getAccessMethodForResources(resourceKeys, null, true, new Date());
List<CatalogEntryRow> items = new ArrayList<>();
List<CatalogEntryRow> closedItems = new ArrayList<>();
for (RepositoryEntry entry : repoEntries) {
CatalogEntryRow row = new CatalogEntryRow(entry);
List<PriceMethod> types = new ArrayList<PriceMethod>();
if (entry.isMembersOnly()) {
// members only always show lock icon
types.add(new PriceMethod("", "o_ac_membersonly_icon", 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(getLocale());
types.add(new PriceMethod(price, type, displayName));
}
}
}
}
if (!types.isEmpty()) {
row.setAccessTypes(types);
}
if (entry.getRepositoryEntryStatus().isClosed()) {
closedItems.add(row);
} else {
items.add(row);
}
}
entriesModel.setObjects(items);
entriesEl.reset();
entriesEl.setVisible(entriesModel.getRowCount() > 0);
closedEntriesModel.setObjects(closedItems);
closedEntriesEl.reset();
closedEntriesEl.setVisible(closedEntriesModel.getRowCount() > 0);
}
Aggregations