Search in sources :

Example 61 with Project

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());
    }
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) BusinessGroup(org.olat.group.BusinessGroup) Identity(org.olat.core.id.Identity) Link(org.olat.core.gui.components.link.Link)

Example 62 with Project

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);
                }
            }
        }
    });
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) OLATResourceable(org.olat.core.id.OLATResourceable) Iterator(java.util.Iterator) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) Identity(org.olat.core.id.Identity)

Example 63 with 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;
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ArrayList(java.util.ArrayList)

Example 64 with Project

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;
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) ProjectImpl(org.olat.course.nodes.projectbroker.datamodel.ProjectImpl)

Example 65 with Project

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);
        }
    });
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) OLATResourceable(org.olat.core.id.OLATResourceable) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor)

Aggregations

Project (org.olat.course.nodes.projectbroker.datamodel.Project)70 ProjectBroker (org.olat.course.nodes.projectbroker.datamodel.ProjectBroker)30 Identity (org.olat.core.id.Identity)22 OLATResourceable (org.olat.core.id.OLATResourceable)16 Test (org.junit.Test)14 ArrayList (java.util.ArrayList)12 CoursePropertyManager (org.olat.course.properties.CoursePropertyManager)12 ProjectEvent (org.olat.course.nodes.projectbroker.datamodel.ProjectEvent)10 ProjectBrokerManager (org.olat.course.nodes.projectbroker.service.ProjectBrokerManager)10 BusinessGroup (org.olat.group.BusinessGroup)10 BusinessGroupService (org.olat.group.BusinessGroupService)10 SyncerExecutor (org.olat.core.util.coordinate.SyncerExecutor)8 VFSLeaf (org.olat.core.util.vfs.VFSLeaf)8 ProjectGroupManager (org.olat.course.nodes.projectbroker.service.ProjectGroupManager)8 PersistingCoursePropertyManager (org.olat.course.properties.PersistingCoursePropertyManager)8 File (java.io.File)6 OlatRootFolderImpl (org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl)6 VFSItem (org.olat.core.util.vfs.VFSItem)6 XStream (com.thoughtworks.xstream.XStream)4 IOException (java.io.IOException)4