Search in sources :

Example 51 with CollaborationTools

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();
}
Also used : OLATResourceable(org.olat.core.id.OLATResourceable) CollaborationTools(org.olat.collaboration.CollaborationTools) RepositoryEntry(org.olat.repository.RepositoryEntry) RepositoryService(org.olat.repository.RepositoryService) Before(org.junit.Before)

Example 52 with CollaborationTools

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());
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) HttpGet(org.apache.http.client.methods.HttpGet) CollaborationTools(org.olat.collaboration.CollaborationTools) HttpResponse(org.apache.http.HttpResponse) SubscriptionContext(org.olat.core.commons.services.notifications.SubscriptionContext) PublisherVO(org.olat.core.commons.services.notifications.restapi.vo.PublisherVO) Identity(org.olat.core.id.Identity) UriBuilder(javax.ws.rs.core.UriBuilder) PublisherData(org.olat.core.commons.services.notifications.PublisherData) Forum(org.olat.modules.fo.Forum) Test(org.junit.Test)

Example 53 with CollaborationTools

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;
    }
}
Also used : Translator(org.olat.core.gui.translator.Translator) CollaborationTools(org.olat.collaboration.CollaborationTools) InfoMessageImpl(org.olat.commons.info.model.InfoMessageImpl) Identity(org.olat.core.id.Identity) Property(org.olat.properties.Property)

Example 54 with CollaborationTools

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);
}
Also used : BusinessGroup(org.olat.group.BusinessGroup) CollaborationTools(org.olat.collaboration.CollaborationTools) Test(org.junit.Test)

Example 55 with CollaborationTools

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;
}
Also used : Activateable2(org.olat.core.gui.control.generic.dtabs.Activateable2) CollaborationTools(org.olat.collaboration.CollaborationTools) WindowControl(org.olat.core.gui.control.WindowControl) ContextEntry(org.olat.core.id.context.ContextEntry)

Aggregations

CollaborationTools (org.olat.collaboration.CollaborationTools)98 BusinessGroup (org.olat.group.BusinessGroup)58 Identity (org.olat.core.id.Identity)30 Test (org.junit.Test)28 HttpResponse (org.apache.http.HttpResponse)22 BusinessGroupService (org.olat.group.BusinessGroupService)22 Path (javax.ws.rs.Path)18 WindowControl (org.olat.core.gui.control.WindowControl)18 URI (java.net.URI)16 HttpGet (org.apache.http.client.methods.HttpGet)16 ContextEntry (org.olat.core.id.context.ContextEntry)16 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)14 SubscriptionContext (org.olat.core.commons.services.notifications.SubscriptionContext)14 Forum (org.olat.modules.fo.Forum)12 Activateable2 (org.olat.core.gui.control.generic.dtabs.Activateable2)10 RepositoryEntry (org.olat.repository.RepositoryEntry)10 IOException (java.io.IOException)8 VFSContainer (org.olat.core.util.vfs.VFSContainer)8 InputStream (java.io.InputStream)7 ArrayList (java.util.ArrayList)6