use of org.olat.collaboration.CollaborationTools in project OpenOLAT by OpenOLAT.
the class GroupFoldersTest method setUp.
/**
* Set up a course with learn group and group area
* EXACTLY THE SAME AS GroupMgmTest
* @see org.olat.test.OlatJerseyTestCase#setUp()
*/
@Before
@Override
public void setUp() throws Exception {
super.setUp();
conn = new RestConnection();
// create a course with learn group
owner1 = JunitTestHelper.createAndPersistIdentityAsUser("rest-one");
owner2 = JunitTestHelper.createAndPersistIdentityAsUser("rest-two");
part1 = JunitTestHelper.createAndPersistIdentityAsUser("rest-four");
part2 = JunitTestHelper.createAndPersistIdentityAsUser("rest-five");
// create course and persist as OLATResourceImpl
OLATResourceable resourceable = OresHelper.createOLATResourceableInstance("junitcourse", System.currentTimeMillis());
course = OLATResourceManager.getInstance().findOrPersistResourceable(resourceable);
RepositoryService rs = CoreSpringFactory.getImpl(RepositoryService.class);
RepositoryEntry re = rs.create("administrator", "-", "rest-re", null, course);
repositoryService.update(re);
DBFactory.getInstance().commit();
// create learn group
// 1) context one: learning groups
RepositoryEntry c1 = JunitTestHelper.createAndPersistRepositoryEntry();
// create groups without waiting list
g1 = businessGroupService.createBusinessGroup(null, "rest-g1", null, 0, 10, false, false, c1);
g2 = businessGroupService.createBusinessGroup(null, "rest-g2", null, 0, 10, false, false, c1);
DBFactory.getInstance().commitAndCloseSession();
// permission to see owners and participants
businessGroupService.updateDisplayMembers(g1, false, false, false, false, false, false, false);
businessGroupService.updateDisplayMembers(g2, true, true, false, false, false, false, false);
// members g1
businessGroupRelationDao.addRole(owner1, g1, GroupRoles.coach.name());
businessGroupRelationDao.addRole(owner2, g1, GroupRoles.coach.name());
businessGroupRelationDao.addRole(part1, g1, GroupRoles.participant.name());
businessGroupRelationDao.addRole(part2, g1, GroupRoles.participant.name());
// members g2
businessGroupRelationDao.addRole(owner1, g2, GroupRoles.coach.name());
businessGroupRelationDao.addRole(part1, g2, GroupRoles.participant.name());
// 3) collaboration tools
CollaborationTools collabTools1 = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(g1);
collabTools1.setToolEnabled(CollaborationTools.TOOL_FOLDER, true);
CollaborationTools collabTools2 = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(g2);
collabTools2.setToolEnabled(CollaborationTools.TOOL_FOLDER, true);
// simulate user clicks
DBFactory.getInstance().commitAndCloseSession();
}
use of org.olat.collaboration.CollaborationTools in project OpenOLAT by OpenOLAT.
the class NotificationsTest method testGetPublisher.
@Test
public void testGetPublisher() throws IOException, URISyntaxException {
// create a business group with forum notifications
Identity id = JunitTestHelper.createAndPersistIdentityAsRndUser("rest-not-9");
BusinessGroup group = businessGroupService.createBusinessGroup(id, "Notifications 1", "REST forum notifications for group", null, null, false, false, null);
CollaborationTools tools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(group);
tools.setToolEnabled(CollaborationTools.TOOL_FORUM, true);
Forum groupForum = tools.getForum();
dbInstance.commitAndCloseSession();
// publish
String businessPath = "[BusinessGroup:" + group.getKey() + "][toolforum:0]";
SubscriptionContext forumSubContext = new SubscriptionContext("BusinessGroup", group.getKey(), "toolforum");
PublisherData forumPdata = new PublisherData(OresHelper.calculateTypeName(Forum.class), groupForum.getKey().toString(), businessPath);
notificationManager.subscribe(id, forumSubContext, forumPdata);
dbInstance.commitAndCloseSession();
// GET publisher
RestConnection conn = new RestConnection();
assertTrue(conn.login("administrator", "openolat"));
UriBuilder request = UriBuilder.fromUri(getContextURI()).path("notifications/publisher/BusinessGroup/" + group.getKey() + "/toolforum");
HttpGet method = conn.createGet(request.build(), MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
PublisherVO publisher = conn.parse(response, PublisherVO.class);
Assert.assertNotNull(publisher);
Assert.assertEquals("BusinessGroup", publisher.getResName());
Assert.assertEquals(group.getKey(), publisher.getResId());
Assert.assertEquals("toolforum", publisher.getSubidentifier());
Assert.assertEquals("Forum", publisher.getType());
Assert.assertEquals(groupForum.getKey().toString(), publisher.getData());
}
use of org.olat.collaboration.CollaborationTools in project OpenOLAT by OpenOLAT.
the class OLATUpgrade_11_4_0 method processInfoMessage.
/**
* @param business group
* @return true if upgrade went well
*/
private boolean processInfoMessage(BusinessGroup businessGroup) {
// iterate all groups and translate their singular info message to the new standard
try {
String businessPath = "[BusinessGroup:" + businessGroup.getKey() + "][toolmsg:0]";
int messageCount = infoMessageManager.countInfoMessageByResource(businessGroup.getResource(), InfoMessageFrontendManager.businessGroupResSubPath, businessPath, null, null);
// only upgrade if business group has not any info messages of the new kind yet
if (1 > messageCount) {
CollaborationTools collabTools = toolsF.getOrCreateCollaborationTools(businessGroup);
Property property = collabTools.lookupNewsDBEntry();
if (property != null) {
// collabTools.lookupNews();
String oldNews = property.getTextValue();
Identity author;
List<Identity> members = groupService.getMembers(businessGroup, GroupRoles.owner.name(), GroupRoles.coach.name());
if (members == null || (members != null && members.isEmpty())) {
author = deletionManager.getAdminUserIdentity();
} else {
author = members.get(0);
}
InfoMessageImpl infoMessage = (InfoMessageImpl) infoMessageManager.createInfoMessage(businessGroup.getResource(), InfoMessageFrontendManager.businessGroupResSubPath, businessPath, author);
Translator trans = Util.createPackageTranslator(CollaborationTools.class, I18nModule.getDefaultLocale());
String title = trans.translate("news.content");
infoMessage.setTitle(title);
infoMessage.setMessage(oldNews);
infoMessage.setCreationDate(property.getCreationDate());
infoMessageManager.saveInfoMessage(infoMessage);
} else {
log.warn("The group " + businessGroup.getName() + " does not have an info message");
}
}
return true;
} catch (Exception e) {
log.warn("Update InfoMessage for " + businessGroup.getName() + " failed", e);
return false;
}
}
use of org.olat.collaboration.CollaborationTools in project OpenOLAT by OpenOLAT.
the class BusinessGroupServiceTest method testDeleteGroup.
/**
* test if removing a BuddyGroup really deletes everything it should.
*
* @throws Exception
*/
@Test
public void testDeleteGroup() throws Exception {
List<BusinessGroup> sqlRes = businessGroupService.findBusinessGroupsOwnedBy(id2);
assertTrue("1 BuddyGroup owned by id2", sqlRes.size() == 1);
BusinessGroup found = sqlRes.get(0);
CollaborationTools myCTSMngr = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(found);
String[] availableTools = CollaborationToolsFactory.getInstance().getAvailableTools().clone();
for (int i = 0; i < availableTools.length; i++) {
myCTSMngr.setToolEnabled(availableTools[i], true);
}
businessGroupService.deleteBusinessGroup(found);
sqlRes = businessGroupService.findBusinessGroupsOwnedBy(id2);
assertTrue("0 BuddyGroup owned by id2", sqlRes.size() == 0);
}
use of org.olat.collaboration.CollaborationTools in project OpenOLAT by OpenOLAT.
the class BusinessGroupMainRunController method doPortfolio.
private Activateable2 doPortfolio(UserRequest ureq) {
addLoggingResourceable(LoggingResourceable.wrap(ORES_TOOLPORTFOLIO, OlatResourceableType.portfolio));
ContextEntry ce = BusinessControlFactory.getInstance().createContextEntry(ORES_TOOLPORTFOLIO);
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(ce, getWindowControl());
ThreadLocalUserActivityLogger.addLoggingResourceInfo(LoggingResourceable.wrapPortfolioOres(ce.getOLATResourceable()));
addToHistory(ureq, bwControl);
CollaborationTools collabTools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(businessGroup);
collabToolCtr = collabTools.createPortfolioController(ureq, bwControl, toolbarPanel, businessGroup);
listenTo(collabToolCtr);
toolbarPanel.popUpToRootController(ureq);
toolbarPanel.pushController("Portfolio", collabToolCtr);
List<ContextEntry> entries = BusinessControlFactory.getInstance().createCEListFromResourceType("Toc");
((Activateable2) collabToolCtr).activate(ureq, entries, null);
return (Activateable2) collabToolCtr;
}
Aggregations