Search in sources :

Example 31 with ProjectBroker

use of org.olat.course.nodes.projectbroker.datamodel.ProjectBroker in project openolat by klemens.

the class ProjectBrokerManagerTest method testExistsProject.

@Test
public void testExistsProject() throws Exception {
    // 1. test project does not exists
    assertFalse("Wrong return value true, project does not exist", projectBrokerManager.existsProject(39927492743L));
    // 2. test project exists
    ProjectBroker projectBrokerD = projectBrokerManager.createAndSaveProjectBroker();
    Long idProjectBrokerD = projectBrokerD.getKey();
    Project testProjectA = createProject("thema existsProject-Test", id1, idProjectBrokerD, resourceableId);
    dbInstance.closeSession();
    assertTrue("Wrong return value false, project exists", projectBrokerManager.existsProject(testProjectA.getKey()));
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) Test(org.junit.Test)

Example 32 with ProjectBroker

use of org.olat.course.nodes.projectbroker.datamodel.ProjectBroker in project openolat by klemens.

the class ProjectBrokerManagerTest method testIsProjectManager.

@Test
public void testIsProjectManager() throws Exception {
    ProjectBroker projectBrokerD = projectBrokerManager.createAndSaveProjectBroker();
    Long idProjectBrokerD = projectBrokerD.getKey();
    Project testProjectA = createProject("thema A", id1, idProjectBrokerD, resourceableId);
    List<Identity> projectManagerList = new ArrayList<Identity>();
    projectManagerList.add(id1);
    Project testProjectB = createProject("thema B", id2, idProjectBrokerD, resourceableId);
    // check project leader in ProjectA
    assertTrue("Must be project-leader of project A", projectGroupManager.isProjectManager(id1, testProjectA));
    assertFalse("Can not be project leader of project B", projectGroupManager.isProjectManager(id1, testProjectB));
    assertTrue("Must be project-leader of project A", projectGroupManager.isProjectManager(id2, testProjectB));
    CoreSpringFactory.getImpl(BusinessGroupService.class).removeOwners(id1, projectManagerList, testProjectA.getProjectGroup());
    // check no project leader anymore
    assertFalse("Can not be project leader of project A", projectGroupManager.isProjectManager(id1, testProjectA));
    assertFalse("Can not be project leader of project B", projectGroupManager.isProjectManager(id1, testProjectB));
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) BusinessGroupService(org.olat.group.BusinessGroupService) ArrayList(java.util.ArrayList) Identity(org.olat.core.id.Identity) Test(org.junit.Test)

Example 33 with ProjectBroker

use of org.olat.course.nodes.projectbroker.datamodel.ProjectBroker in project openolat by klemens.

the class ProjectBrokerCourseNode method createInstanceForCopy.

/**
 * @see org.olat.course.nodes.CourseNode#createInstanceForCopy()
 */
@Override
public CourseNode createInstanceForCopy(boolean isNewTitle, ICourse course, Identity author) {
    // create the instance for the copy
    CourseNode copyInstance = super.createInstanceForCopy(isNewTitle, course, author);
    // get all the different managers
    BusinessGroupService bgs = CoreSpringFactory.getImpl(BusinessGroupService.class);
    CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
    ProjectGroupManager projectGroupManager = CoreSpringFactory.getImpl(ProjectGroupManager.class);
    ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
    // get the pbID from the source pb
    Long oldProjectBrokerId = projectBrokerManager.getProjectBrokerId(cpm, this);
    // create a new projectBroker for the copyInstance
    ProjectBroker newBroker = projectBrokerManager.createAndSaveProjectBroker();
    Long projectBrokerId = newBroker.getKey();
    projectBrokerManager.saveProjectBrokerId(projectBrokerId, cpm, copyInstance);
    // configure the new Project like the old one
    // copy the old accountManagergroup to preserve the
    // "persons in charge"
    Long originalAccountGroupKey = projectGroupManager.getAccountManagerGroupKey(cpm, this);
    if (originalAccountGroupKey != null) {
        BusinessGroup originalAccountGroup = projectGroupManager.getAccountManagerGroupFor(cpm, this, course, getShortTitle(), getShortTitle(), null);
        BusinessGroup newAccountManagerGroup = bgs.copyBusinessGroup(author, originalAccountGroup, originalAccountGroup.getName(), originalAccountGroup.getDescription(), originalAccountGroup.getMinParticipants(), originalAccountGroup.getMaxParticipants(), false, false, true, false, false, true, false, false);
        projectGroupManager.saveAccountManagerGroupKey(newAccountManagerGroup.getKey(), cpm, copyInstance);
        bgs.addResourceTo(newAccountManagerGroup, course.getCourseEnvironment().getCourseGroupManager().getCourseEntry());
    }
    if (oldProjectBrokerId != null) {
        List<Project> projects = projectBrokerManager.getProjectListBy(oldProjectBrokerId);
        for (Project project : projects) {
            // create projectGroup
            BusinessGroup projectGroup = projectGroupManager.createProjectGroupFor(projectBrokerId, author, project.getTitle(), project.getDescription(), course.getResourceableId());
            Project newProject = projectBrokerManager.createAndSaveProjectFor(project.getTitle(), project.getDescription(), projectBrokerId, projectGroup);
            // copy all project configurations
            newProject.setMailNotificationEnabled(project.isMailNotificationEnabled());
            newProject.setMaxMembers(project.getMaxMembers());
            for (int i = 0; i < project.getCustomFieldSize(); i++) {
                newProject.setCustomFieldValue(i, project.getCustomFieldValue(i));
            }
            projectGroupManager.setDeselectionAllowed(newProject, project.getProjectGroup().isAllowToLeave());
            projectBrokerManager.updateProject(newProject);
            // attachment file
            OlatRootFolderImpl rootFolder = new OlatRootFolderImpl(projectBrokerManager.getAttamchmentRelativeRootPath(project, course.getCourseEnvironment(), this), null);
            VFSItem item = rootFolder.resolve(project.getAttachmentFileName());
            if (item instanceof VFSLeaf) {
                projectBrokerManager.saveAttachedFile(newProject, project.getAttachmentFileName(), (VFSLeaf) item, course.getCourseEnvironment(), copyInstance);
                newProject.setAttachedFileName(project.getAttachmentFileName());
                projectBrokerManager.updateProject(newProject);
            }
        }
    }
    return copyInstance;
}
Also used : VFSLeaf(org.olat.core.util.vfs.VFSLeaf) BusinessGroup(org.olat.group.BusinessGroup) VFSItem(org.olat.core.util.vfs.VFSItem) ProjectBrokerManager(org.olat.course.nodes.projectbroker.service.ProjectBrokerManager) ProjectGroupManager(org.olat.course.nodes.projectbroker.service.ProjectGroupManager) Project(org.olat.course.nodes.projectbroker.datamodel.Project) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) OlatRootFolderImpl(org.olat.core.commons.modules.bc.vfs.OlatRootFolderImpl) BusinessGroupService(org.olat.group.BusinessGroupService) CoursePropertyManager(org.olat.course.properties.CoursePropertyManager) PersistingCoursePropertyManager(org.olat.course.properties.PersistingCoursePropertyManager)

Example 34 with ProjectBroker

use of org.olat.course.nodes.projectbroker.datamodel.ProjectBroker in project openolat by klemens.

the class ProjectDetailsPanelController method openEditController.

private void openEditController(UserRequest ureq) {
    if (projectBrokerManager.existsProject(project.getKey())) {
        OLATResourceable projectOres = OresHelper.createOLATResourceableInstance(Project.class, project.getKey());
        this.lock = CoordinatorManager.getInstance().getCoordinator().getLocker().acquireLock(projectOres, ureq.getIdentity(), null);
        if (lock.isSuccess()) {
            editController = new ProjectEditDetailsFormController(ureq, this.getWindowControl(), project, courseEnv, courseNode, projectBrokerModuleConfiguration, newCreatedProject);
            editController.addControllerListener(this);
            editVC.put("editController", editController.getInitialComponent());
            detailsPanel.pushContent(editVC);
        } else {
            this.showInfo("info.project.already.edit", project.getTitle());
        }
    } else {
        this.showInfo("info.project.nolonger.exist", project.getTitle());
        // fire event to update project list
        ProjectBroker projectBroker = project.getProjectBroker();
        OLATResourceableDeletedEvent delEv = new OLATResourceableDeletedEvent(projectBroker);
        CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(delEv, projectBroker);
    }
}
Also used : ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) OLATResourceable(org.olat.core.id.OLATResourceable) OLATResourceableDeletedEvent(org.olat.core.util.resource.OLATResourceableDeletedEvent)

Example 35 with ProjectBroker

use of org.olat.course.nodes.projectbroker.datamodel.ProjectBroker 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)

Aggregations

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