use of org.olat.group.model.BusinessGroupRow in project openolat by klemens.
the class BusinessGroupDAOTest method findBusinessGroupsByDescription.
@Test
public void findBusinessGroupsByDescription() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-4");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "fingbg-1", marker.toUpperCase() + "-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "fingbg-2", "desc-" + marker, 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "fingbg-3", "desc-other-one", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
// check find business group
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setDescription(marker);
List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(2, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
Assert.assertFalse(groups.contains(group3));
// check find business group
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setDescription(marker);
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
Assert.assertNotNull(groupViews);
Assert.assertEquals(2, groupViews.size());
Assert.assertTrue(contains(groupViews, group1));
Assert.assertTrue(contains(groupViews, group2));
Assert.assertFalse(contains(groupViews, group3));
}
use of org.olat.group.model.BusinessGroupRow in project openolat by klemens.
the class BusinessGroupDAOTest method findPublicGroupsLimitedDate.
@Test
public void findPublicGroupsLimitedDate() {
// create a group with an access control limited by a valid date
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-11");
BusinessGroup groupVisible = businessGroupDao.createAndPersist(null, "access-grp-2", "access-grp-2-desc", 0, 5, true, false, true, false, false);
// create and save an offer
Offer offer = acService.createOffer(groupVisible.getResource(), "TestBGWorkflow");
Calendar cal = Calendar.getInstance();
cal.add(Calendar.HOUR_OF_DAY, -1);
offer.setValidFrom(cal.getTime());
cal.add(Calendar.HOUR_OF_DAY, 2);
offer.setValidTo(cal.getTime());
assertNotNull(offer);
offer = acService.save(offer);
acMethodManager.enableMethod(TokenAccessMethod.class, true);
List<AccessMethod> methods = acMethodManager.getAvailableMethodsByType(TokenAccessMethod.class);
AccessMethod method = methods.get(0);
OfferAccess access = acMethodManager.createOfferAccess(offer, method);
acMethodManager.save(access);
// create a group with an access control limited by dates in the past
BusinessGroup oldGroup = businessGroupDao.createAndPersist(null, "access-grp-3", "access-grp-3-desc", 0, 5, true, false, true, false, false);
// create and save an offer
Offer oldOffer = acService.createOffer(oldGroup.getResource(), "TestBGWorkflow");
cal.add(Calendar.HOUR_OF_DAY, -5);
oldOffer.setValidFrom(cal.getTime());
cal.add(Calendar.HOUR_OF_DAY, -5);
oldOffer.setValidTo(cal.getTime());
assertNotNull(oldOffer);
oldOffer = acService.save(oldOffer);
OfferAccess oldAccess = acMethodManager.createOfferAccess(oldOffer, method);
acMethodManager.save(oldAccess);
dbInstance.commitAndCloseSession();
// retrieve the offer
BusinessGroupQueryParams paramsAll = new BusinessGroupQueryParams();
paramsAll.setPublicGroups(Boolean.TRUE);
List<BusinessGroupRow> accessGroups = businessGroupDao.searchBusinessGroupsWithMemberships(paramsAll, id);
Assert.assertNotNull(accessGroups);
Assert.assertTrue(accessGroups.size() >= 1);
Assert.assertTrue(contains(accessGroups, groupVisible));
Assert.assertFalse(contains(accessGroups, oldGroup));
}
use of org.olat.group.model.BusinessGroupRow in project openolat by klemens.
the class AbstractBusinessGroupListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (createButton == source) {
doCreate(ureq, getWindowControl(), null);
} else if (deleteButton == source) {
confirmDelete(ureq, getSelectedItems());
} else if (duplicateButton == source) {
doCopy(ureq, getSelectedItems());
} else if (configButton == source) {
doConfiguration(ureq, getSelectedItems());
} else if (emailButton == source) {
doEmails(ureq, getSelectedItems());
} else if (usersButton == source) {
doUserManagement(ureq, getSelectedItems());
} else if (mergeButton == source) {
doMerge(ureq, getSelectedItems());
} else if (selectButton == source) {
doSelect(ureq, getSelectedItems());
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
String cmd = link.getCmd();
if ("mark".equals(cmd)) {
BusinessGroupRow row = (BusinessGroupRow) link.getUserObject();
boolean marked = toogleMark(row);
link.setIconLeftCSS(marked ? "o_icon o_icon_bookmark o_icon-lg" : "o_icon o_icon_bookmark_add o_icon-lg");
link.getComponent().setDirty(true);
} else if ("allresources".equals(cmd)) {
BusinessGroupShort bg = (BusinessGroupShort) link.getUserObject();
NewControllerFactory.getInstance().launch("[BusinessGroup:" + bg.getKey() + "][toolresources:0]", ureq, getWindowControl());
} else if ("resource".equals(cmd)) {
RepositoryEntryShort re = (RepositoryEntryShort) link.getUserObject();
NewControllerFactory.getInstance().launch("[RepositoryEntry:" + re.getKey() + "]", ureq, getWindowControl());
} else if (link.getUserObject() instanceof BusinessGroupRef) {
BusinessGroupRef item = (BusinessGroupRef) link.getUserObject();
Long businessGroupKey = item.getKey();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
if (businessGroup == null) {
groupTableModel.removeBusinessGroup(businessGroupKey);
tableEl.reset();
} else if (TABLE_ACTION_ACCESS.equals(cmd)) {
doAccess(ureq, businessGroup);
} else if (TABLE_ACTION_LEAVE.equals(cmd)) {
doConfirmLeaving(ureq, businessGroup);
}
}
} else if (source == tableEl) {
String cmd = event.getCommand();
if (event instanceof SelectionEvent) {
SelectionEvent se = (SelectionEvent) event;
if (se.getIndex() >= 0 && se.getIndex() < groupTableModel.getRowCount()) {
BusinessGroupRef item = groupTableModel.getObject(se.getIndex());
Long businessGroupKey = item.getKey();
BusinessGroup businessGroup = businessGroupService.loadBusinessGroup(businessGroupKey);
// prevent rs after a group is deleted by someone else
if (businessGroup == null) {
groupTableModel.removeBusinessGroup(businessGroupKey);
tableEl.reset();
} else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
doLaunch(ureq, businessGroup);
} else if (TABLE_ACTION_DELETE.equals(cmd)) {
confirmDelete(ureq, Collections.singletonList(item));
} else if (TABLE_ACTION_LAUNCH.equals(cmd)) {
doLaunch(ureq, businessGroup);
} else if (TABLE_ACTION_EDIT.equals(cmd)) {
doEdit(ureq, businessGroup);
} else if (TABLE_ACTION_LEAVE.equals(cmd)) {
doConfirmLeaving(ureq, businessGroup);
} else if (TABLE_ACTION_ACCESS.equals(cmd)) {
doAccess(ureq, businessGroup);
} else if (TABLE_ACTION_SELECT.equals(cmd)) {
doSelect(ureq, businessGroup);
}
}
} else if (event instanceof FlexiTableSearchEvent) {
doSearch((FlexiTableSearchEvent) event);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.group.model.BusinessGroupRow in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findBusinessGroupsWithResources.
@Test
public void findBusinessGroupsWithResources() {
// create a group attach to a resource
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-10");
Identity owner = JunitTestHelper.createAndPersistIdentityAsRndUser("marker-");
RepositoryEntry re = JunitTestHelper.createAndPersistRepositoryEntry();
BusinessGroup group1 = businessGroupDao.createAndPersist(owner, "rsrc-grp-1", "rsrc-grp-1-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(owner, "rsrc-grp-2", "rsrc-grp-2-desc", 0, 5, true, false, true, false, false);
businessGroupRelationDao.addRelationToResource(group1, re);
dbInstance.commitAndCloseSession();
// check the same with the views
// check the search function with resources
BusinessGroupQueryParams queryWithParams = new BusinessGroupQueryParams();
queryWithParams.setResources(Boolean.TRUE);
List<BusinessGroupRow> groupViewWith = businessGroupDao.searchBusinessGroupsWithMemberships(queryWithParams, id);
Assert.assertNotNull(groupViewWith);
Assert.assertFalse(groupViewWith.isEmpty());
Assert.assertTrue(contains(groupViewWith, group1));
// check the search function without resources
BusinessGroupQueryParams queryWithoutParams = new BusinessGroupQueryParams();
queryWithoutParams.setResources(Boolean.FALSE);
List<BusinessGroupRow> groupViewWithout = businessGroupDao.searchBusinessGroupsWithMemberships(queryWithoutParams, id);
Assert.assertNotNull(groupViewWithout);
Assert.assertFalse(groupViewWithout.isEmpty());
Assert.assertTrue(contains(groupViewWithout, group2));
}
use of org.olat.group.model.BusinessGroupRow in project OpenOLAT by OpenOLAT.
the class BusinessGroupDAOTest method findBusinessGroupsByDescriptionFuzzy.
@Test
public void findBusinessGroupsByDescriptionFuzzy() {
String marker = UUID.randomUUID().toString();
Identity identity = JunitTestHelper.createAndPersistIdentityAsRndUser("bg-search-5");
BusinessGroup group1 = businessGroupDao.createAndPersist(null, "fingbg-1", marker + "-desc", 0, 5, true, false, true, false, false);
BusinessGroup group2 = businessGroupDao.createAndPersist(null, "fingbg-2", "desc-" + marker.toUpperCase(), 0, 5, true, false, true, false, false);
BusinessGroup group3 = businessGroupDao.createAndPersist(null, "fingbg-3", "desc-" + marker + "-desc", 0, 5, true, false, true, false, false);
dbInstance.commitAndCloseSession();
SearchBusinessGroupParams params = new SearchBusinessGroupParams();
params.setDescription("*" + marker + "*");
List<BusinessGroup> groups = businessGroupDao.findBusinessGroups(params, null, 0, -1);
Assert.assertNotNull(groups);
Assert.assertEquals(3, groups.size());
Assert.assertTrue(groups.contains(group1));
Assert.assertTrue(groups.contains(group2));
Assert.assertTrue(groups.contains(group3));
// check same search with the views
BusinessGroupQueryParams searchParams = new BusinessGroupQueryParams();
searchParams.setDescription("*" + marker + "*");
List<BusinessGroupRow> groupViews = businessGroupDao.searchBusinessGroupsWithMemberships(searchParams, identity);
Assert.assertNotNull(groupViews);
Assert.assertEquals(3, groupViews.size());
Assert.assertTrue(contains(groupViews, group1));
Assert.assertTrue(contains(groupViews, group2));
Assert.assertTrue(contains(groupViews, group3));
}
Aggregations