use of org.olat.modules.ModuleConfiguration in project openolat by klemens.
the class GTAManagerImpl method getParticipatingBusinessGroups.
@Override
public List<BusinessGroup> getParticipatingBusinessGroups(IdentityRef identity, GTACourseNode cNode) {
ModuleConfiguration config = cNode.getModuleConfiguration();
List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
return getBusinessGroups(identity, groupKeys, areaKeys, GroupRoles.participant);
}
use of org.olat.modules.ModuleConfiguration in project openolat by klemens.
the class GTAManagerImpl method getTaskDefinitions.
@Override
public List<TaskDefinition> getTaskDefinitions(CourseEnvironment courseEnv, GTACourseNode cNode) {
Path taskDefinitionsPath = Paths.get(FolderConfig.getCanonicalRoot(), courseEnv.getCourseBaseContainer().getRelPath(), "gtasks", cNode.getIdent(), TASKS_DEFINITIONS);
List<TaskDefinition> taskDefinitions = new ArrayList<>();
if (Files.exists(taskDefinitionsPath)) {
TaskDefinitionList taskDefinitionsList = (TaskDefinitionList) taskDefinitionsXstream.fromXML(taskDefinitionsPath.toFile());
if (taskDefinitionsList != null && taskDefinitionsList.getTasks() != null) {
taskDefinitions.addAll(taskDefinitionsList.getTasks());
}
} else {
syncWithTaskList(courseEnv, cNode, new TaskListSynched() {
@Override
public void sync() {
ModuleConfiguration config = cNode.getModuleConfiguration();
TaskDefinitionList tasks = (TaskDefinitionList) config.get(GTACourseNode.GTASK_TASKS);
if (tasks != null) {
taskDefinitions.addAll(tasks.getTasks());
}
storeTaskDefinitions(taskDefinitions, courseEnv, cNode);
}
});
}
return taskDefinitions;
}
use of org.olat.modules.ModuleConfiguration in project openolat by klemens.
the class GTAManagerImpl method getDuplicatedMemberships.
@Override
public List<IdentityRef> getDuplicatedMemberships(GTACourseNode cNode) {
List<IdentityRef> duplicates;
ModuleConfiguration config = cNode.getModuleConfiguration();
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
List<Long> consolidatedGroupKeys = new ArrayList<>();
if (groupKeys != null && groupKeys.size() > 0) {
consolidatedGroupKeys.addAll(groupKeys);
}
consolidatedGroupKeys.addAll(areaManager.findBusinessGroupKeysOfAreaKeys(areaKeys));
List<BusinessGroupRef> businessGroups = BusinessGroupRefImpl.toRefs(consolidatedGroupKeys);
duplicates = businessGroupRelationDao.getDuplicateMemberships(businessGroups);
} else {
duplicates = Collections.emptyList();
}
return duplicates;
}
use of org.olat.modules.ModuleConfiguration in project openolat by klemens.
the class GTAManagerImpl method getBusinessGroups.
@Override
public List<BusinessGroup> getBusinessGroups(GTACourseNode cNode) {
List<BusinessGroup> groups;
ModuleConfiguration config = cNode.getModuleConfiguration();
if (GTAType.group.name().equals(config.getStringValue(GTACourseNode.GTASK_TYPE))) {
List<Long> groupKeys = config.getList(GTACourseNode.GTASK_GROUPS, Long.class);
List<Long> areaKeys = config.getList(GTACourseNode.GTASK_AREAS, Long.class);
List<Long> consolidatedGroupKeys = new ArrayList<>();
if (groupKeys != null && groupKeys.size() > 0) {
consolidatedGroupKeys.addAll(groupKeys);
}
consolidatedGroupKeys.addAll(areaManager.findBusinessGroupKeysOfAreaKeys(areaKeys));
groups = businessGroupService.loadBusinessGroups(consolidatedGroupKeys);
} else {
groups = Collections.emptyList();
}
return groups;
}
use of org.olat.modules.ModuleConfiguration in project openolat by klemens.
the class ENWebService method getGroups.
/**
* Retrieves the groups where the enrollment happens
* @response.representation.200.qname {http://www.example.com}groupVO
* @response.representation.200.mediaType application/xml, application/json
* @response.representation.200.doc The groups
* @response.representation.200.example {@link org.olat.restapi.support.vo.Examples#SAMPLE_GROUPVO}
* @response.representation.401.doc The roles of the authenticated user are not sufficient
* @response.representation.404.doc The course or course node not found
* @param nodeId The node's id
* @param httpRequest The HTTP request
* @return An array of groups
*/
@GET
@Path("{nodeId}/groups")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Response getGroups(@PathParam("courseId") Long courseId, @PathParam("nodeId") String nodeId, @Context HttpServletRequest httpRequest) {
if (!isAuthor(httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
ICourse course = CoursesWebService.loadCourse(courseId);
if (course == null) {
return Response.serverError().status(Status.NOT_FOUND).build();
} else if (!isAuthorEditor(course, httpRequest)) {
return Response.serverError().status(Status.UNAUTHORIZED).build();
}
BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
CourseNode node = getParentNode(course, nodeId);
ModuleConfiguration config = node.getModuleConfiguration();
String groupNames = (String) config.get(ENCourseNode.CONFIG_GROUPNAME);
@SuppressWarnings("unchecked") List<Long> groupKeys = (List<Long>) config.get(ENCourseNode.CONFIG_GROUP_IDS);
if (groupKeys == null && StringHelper.containsNonWhitespace(groupNames)) {
groupKeys = bgs.toGroupKeys(groupNames, course.getCourseEnvironment().getCourseGroupManager().getCourseEntry());
}
if (groupKeys == null || groupKeys.isEmpty()) {
return Response.ok(new GroupVO[0]).build();
}
List<GroupVO> voes = new ArrayList<GroupVO>();
List<BusinessGroup> groups = bgs.loadBusinessGroups(groupKeys);
for (BusinessGroup group : groups) {
voes.add(get(group));
}
GroupVO[] voArr = new GroupVO[voes.size()];
voes.toArray(voArr);
return Response.ok(voArr).build();
}
Aggregations