use of org.olat.course.nodes.projectbroker.datamodel.Project in project openolat by klemens.
the class ProjectListController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest, org.olat.core.gui.components.Component, org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Component source, Event event) {
if (source == createNewProjectButton) {
String projectTitle = translate("new.project.title");
int i = 1;
while (projectBrokerManager.existProjectName(projectBrokerId, projectTitle)) {
projectTitle = translate("new.project.title") + i++;
}
String projectGroupName = translate("project.member.groupname", projectTitle);
String projectGroupDescription = translate("project.member.groupdescription", projectTitle);
BusinessGroup projectGroup = projectGroupManager.createProjectGroupFor(projectBrokerId, ureq.getIdentity(), projectGroupName, projectGroupDescription, courseId);
Project project = projectBrokerManager.createAndSaveProjectFor(projectTitle, projectTitle, projectBrokerId, projectGroup);
projectGroupManager.sendGroupChangeEvent(project, courseId, ureq.getIdentity());
getLogger().debug("Created a new project=" + project);
projectController = new ProjectController(ureq, this.getWindowControl(), userCourseEnv, courseNode, project, true, moduleConfig);
listenTo(projectController);
mainPanel.pushContent(projectController.getInitialComponent());
} else if (event.getCommand().equals(OPEN_IDENTITY_CMD)) {
Link link = (Link) source;
if (calloutCtrl != null) {
calloutCtrl.deactivate();
removeAsListenerAndDispose(calloutCtrl);
calloutCtrl = null;
}
openUserInPopup(ureq, (Identity) link.getUserObject());
}
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project openolat by klemens.
the class ProjectBrokerManagerImpl method signOutFormAllCandidateList.
public void signOutFormAllCandidateList(final List<Identity> chosenIdentities, final Long projectBrokerId) {
OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {
public void execute() {
ProjectBroker projectBroker = getOrLoadProjectBoker(projectBrokerId);
for (Iterator<Project> iterator = projectBroker.getProjects().iterator(); iterator.hasNext(); ) {
Project project = iterator.next();
// loop over all identities
for (Iterator<Identity> iterator2 = chosenIdentities.iterator(); iterator2.hasNext(); ) {
Identity identity = iterator2.next();
securityManager.removeIdentityFromSecurityGroup(identity, project.getCandidateGroup());
logAudit("ProjectBroker: AutoSignOut: identity=" + identity + " from project=" + project);
}
}
}
});
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project openolat by klemens.
the class ProjectBrokerManagerImpl method getProjectsOf.
@Override
public List<Project> getProjectsOf(Identity identity, Long projectBrokerId) {
List<Project> myProjects = new ArrayList<Project>();
List<Project> allProjects = getProjectListBy(projectBrokerId);
// TODO: for better performance should be done with sql query instead of a loop
for (Iterator<Project> iterator = allProjects.iterator(); iterator.hasNext(); ) {
Project project = iterator.next();
if (businessGroupService.hasRoles(identity, project.getProjectGroup(), GroupRoles.participant.name())) {
myProjects.add(project);
}
}
return myProjects;
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project openolat by klemens.
the class ProjectBrokerManagerImpl method getOrLoadProjectBoker.
// /////////////////
// Private Methods
// /////////////////
private ProjectBroker getOrLoadProjectBoker(final Long projectBrokerId) {
// 1. check if alreday a projectBroker is in the cache
ProjectBroker projectBroker = projectCache.get(projectBrokerId.toString());
if (projectBroker == null) {
logDebug("find no projectBroker in the cache => create a new one projectBrokerId=" + projectBrokerId);
StringBuilder sb = new StringBuilder();
sb.append("select distinct project from ").append(ProjectImpl.class.getName()).append(" as project ").append(" left join fetch project.projectGroup pGroup").append(" left join fetch pGroup.baseGroup bGroup").append(" where project.projectBroker.key=:projectBrokerKey");
List<Project> projectList = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Project.class).setParameter("projectBrokerKey", projectBrokerId).getResultList();
projectBroker = getProjectBroker(projectBrokerId);
projectBroker.setProjects(projectList);
projectCache.put(projectBrokerId.toString(), projectBroker);
}
return projectBroker;
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project openolat by klemens.
the class ProjectBrokerManagerImpl method setProjectState.
@Override
public void setProjectState(final Project project, final String state) {
final Long projectBrokerId = project.getProjectBroker().getKey();
OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {
@Override
public void execute() {
// For cluster-safe : reload project object here another node might have changed this in the meantime
Project reloadedProject = (Project) dbInstance.loadObject(project, true);
reloadedProject.setState(state);
updateProjectAndInvalidateCache(reloadedProject);
}
});
}
Aggregations