use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class NotificationsTest method testGetBusinessGroupFolderNotifications.
@Test
public void testGetBusinessGroupFolderNotifications() throws IOException, URISyntaxException {
// create a business group with folder notifications
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("rest-not-5-" + UUID.randomUUID().toString());
BusinessGroup group = businessGroupService.createBusinessGroup(id, "Notifications 2", "REST folder notifications for group", null, null, false, false, null);
CollaborationTools tools = CollaborationToolsFactory.getInstance().getOrCreateCollaborationTools(group);
tools.setToolEnabled(CollaborationTools.TOOL_FOLDER, true);
String relPath = tools.getFolderRelPath();
dbInstance.commitAndCloseSession();
// publish
String businessPath = "[BusinessGroup:" + group.getKey() + "][toolfolder:0]";
SubscriptionContext folderSubContext = new SubscriptionContext("BusinessGroup", group.getKey(), "toolfolder");
PublisherData folderPdata = new PublisherData("FolderModule", relPath, businessPath);
notificationManager.subscribe(id, folderSubContext, folderPdata);
// add a file
OlatRootFolderImpl folder = tools.getSecuredFolder(group, folderSubContext, id, true);
String filename = addFile(folder);
// mark as published
notificationManager.markPublisherNews(folderSubContext, null, true);
dbInstance.commitAndCloseSession();
// get the notification
RestConnection conn = new RestConnection();
assertTrue(conn.login(id.getName(), "A6B7C8"));
UriBuilder request = UriBuilder.fromUri(getContextURI()).path("notifications");
HttpGet method = conn.createGet(request.build(), MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
List<SubscriptionInfoVO> infos = parseUserArray(response.getEntity().getContent());
Assert.assertNotNull(infos);
Assert.assertEquals(1, infos.size());
SubscriptionInfoVO infoVO = infos.get(0);
Assert.assertNotNull(infoVO.getItems());
Assert.assertEquals(1, infoVO.getItems().size());
SubscriptionListItemVO itemVO = infoVO.getItems().get(0);
Assert.assertNotNull(itemVO);
Assert.assertEquals(group.getKey(), itemVO.getGroupKey());
Assert.assertEquals("/" + filename, itemVO.getPath());
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class NotificationsTest method testGetBusinessGroupForumNotifications.
@Test
public void testGetBusinessGroupForumNotifications() throws IOException, URISyntaxException {
// create a business group with forum notifications
Identity id = JunitTestHelper.createAndPersistIdentityAsUser("rest-not-4-" + UUID.randomUUID().toString());
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);
Message message = createMessage(id, groupForum);
notificationManager.markPublisherNews(forumSubContext, null, true);
dbInstance.commitAndCloseSession();
// get the notification
RestConnection conn = new RestConnection();
assertTrue(conn.login(id.getName(), "A6B7C8"));
UriBuilder request = UriBuilder.fromUri(getContextURI()).path("notifications");
HttpGet method = conn.createGet(request.build(), MediaType.APPLICATION_JSON, true);
HttpResponse response = conn.execute(method);
assertEquals(200, response.getStatusLine().getStatusCode());
List<SubscriptionInfoVO> infos = parseUserArray(response.getEntity().getContent());
Assert.assertNotNull(infos);
Assert.assertEquals(1, infos.size());
SubscriptionInfoVO infoVO = infos.get(0);
Assert.assertNotNull(infoVO.getItems());
Assert.assertEquals(1, infoVO.getItems().size());
SubscriptionListItemVO itemVO = infoVO.getItems().get(0);
Assert.assertNotNull(itemVO);
Assert.assertEquals(group.getKey(), itemVO.getGroupKey());
Assert.assertEquals(message.getKey(), itemVO.getMessageKey());
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class GTACourseNode method archiveNodeData.
@Override
public boolean archiveNodeData(Locale locale, ICourse course, ArchiveOptions options, ZipOutputStream exportStream, String charset) {
final GTAManager gtaManager = CoreSpringFactory.getImpl(GTAManager.class);
final ModuleConfiguration config = getModuleConfiguration();
String prefix;
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
prefix = "grouptask_";
} else {
prefix = "ita_";
}
String dirName = prefix + StringHelper.transformDisplayNameToFileSystemName(getShortName()) + "_" + Formatter.formatDatetimeFilesystemSave(new Date(System.currentTimeMillis()));
TaskList taskList = gtaManager.getTaskList(course.getCourseEnvironment().getCourseGroupManager().getCourseEntry(), this);
// save assessment datas
List<Identity> users = null;
if (config.getBooleanSafe(GTASK_GRADING)) {
users = ScoreAccountingHelper.loadUsers(course.getCourseEnvironment(), options);
String courseTitle = course.getCourseTitle();
String fileName = ExportUtil.createFileNameWithTimeStamp(courseTitle, "xlsx");
List<AssessableCourseNode> nodes = Collections.<AssessableCourseNode>singletonList(this);
try (OutputStream out = new ShieldOutputStream(exportStream)) {
exportStream.putNextEntry(new ZipEntry(dirName + "/" + fileName));
ScoreAccountingHelper.createCourseResultsOverviewXMLTable(users, nodes, course, locale, out);
exportStream.closeEntry();
} catch (Exception e) {
log.error("", e);
}
}
// copy tasks
if (taskList != null) {
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
List<BusinessGroup> selectedGroups;
if (options != null && options.getGroup() != null) {
selectedGroups = Collections.singletonList(options.getGroup());
} else {
selectedGroups = gtaManager.getBusinessGroups(this);
}
for (BusinessGroup businessGroup : selectedGroups) {
archiveNodeData(course, businessGroup, taskList, dirName, exportStream);
}
} else {
if (users == null) {
users = ScoreAccountingHelper.loadUsers(course.getCourseEnvironment(), options);
}
Set<Identity> uniqueUsers = new HashSet<>(users);
for (Identity user : uniqueUsers) {
archiveNodeData(course, user, taskList, dirName, exportStream);
}
}
}
// copy solutions
if (config.getBooleanSafe(GTACourseNode.GTASK_SAMPLE_SOLUTION)) {
VFSContainer solutions = gtaManager.getSolutionsContainer(course.getCourseEnvironment(), this);
if (solutions.exists()) {
String solutionDirName = dirName + "/solutions";
for (VFSItem solution : solutions.getItems(new SystemItemFilter())) {
ZipUtil.addToZip(solution, solutionDirName, exportStream);
}
}
}
return true;
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class GTACourseNode method getCoachedGroupListController.
public GTACoachedGroupListController getCoachedGroupListController(UserRequest ureq, WindowControl wControl, BreadcrumbPanel stackPanel, UserCourseEnvironment coachCourseEnv, boolean admin, List<BusinessGroup> coachedGroups) {
List<BusinessGroup> groups;
CourseGroupManager gm = coachCourseEnv.getCourseEnvironment().getCourseGroupManager();
if (admin) {
groups = gm.getAllBusinessGroups();
} else {
groups = coachedGroups;
}
groups = CoreSpringFactory.getImpl(GTAManager.class).filterBusinessGroups(groups, this);
return new GTACoachedGroupListController(ureq, wControl, stackPanel, coachCourseEnv, this, groups);
}
use of org.olat.group.BusinessGroup in project OpenOLAT by OpenOLAT.
the class PFNotificationsHandler method checkPublisher.
private void checkPublisher(Publisher p) {
try {
if ("BusinessGroup".equals(p.getResName())) {
BusinessGroup bg = CoreSpringFactory.getImpl(BusinessGroupService.class).loadBusinessGroup(p.getResId());
if (bg == null) {
log.info("deactivating publisher with key; " + p.getKey(), null);
NotificationsManager.getInstance().deactivate(p);
}
} else if ("CourseModule".equals(p.getResName())) {
if (!NotificationsUpgradeHelper.checkCourse(p)) {
log.info("deactivating publisher with key; " + p.getKey(), null);
NotificationsManager.getInstance().deactivate(p);
}
}
} catch (Exception e) {
log.error("", e);
}
}
Aggregations