Search in sources :

Example 6 with ProjectBroker

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

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 7 with ProjectBroker

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

the class ProjectBrokerManagerImpl method createAndSaveProjectBroker.

public ProjectBroker createAndSaveProjectBroker() {
    ProjectBroker projectBroker = new ProjectBrokerImpl();
    dbInstance.saveObject(projectBroker);
    return projectBroker;
}
Also used : ProjectBrokerImpl(org.olat.course.nodes.projectbroker.datamodel.ProjectBrokerImpl) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker)

Example 8 with ProjectBroker

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

the class ProjectBrokerManagerImpl method deleteProjectBroker.

public void deleteProjectBroker(Long projectBrokerId, CourseEnvironment courseEnvironment, CourseNode courseNode) {
    logDebug("Start deleting projectBrokerId=" + projectBrokerId);
    ProjectBroker projectBroker = getOrLoadProjectBoker(projectBrokerId);
    // delete all projects of a project-broker
    List<Project> deleteProjectList = new ArrayList<Project>();
    deleteProjectList.addAll(projectBroker.getProjects());
    for (Iterator<Project> iterator = deleteProjectList.iterator(); iterator.hasNext(); ) {
        Project project = iterator.next();
        deleteProject(project, true, courseEnvironment, courseNode);
        logAudit("ProjectBroker: Deleted project=" + project);
    }
    logDebug("All projects are deleted for ProjectBroker=" + projectBroker);
    projectGroupManager.deleteAccountManagerGroup(courseEnvironment.getCoursePropertyManager(), courseNode);
    ProjectBroker reloadedProjectBroker = (ProjectBroker) dbInstance.loadObject(projectBroker, true);
    dbInstance.deleteObject(reloadedProjectBroker);
    // invalide with removing from cache
    projectCache.remove(projectBrokerId.toString());
    logAudit("ProjectBroker: Deleted ProjectBroker=" + projectBroker);
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) ArrayList(java.util.ArrayList)

Example 9 with ProjectBroker

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

the class ProjectBrokerManagerImpl method createAndSaveProjectFor.

public Project createAndSaveProjectFor(String title, String description, final Long projectBrokerId, BusinessGroup projectGroup) {
    OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
    final Project project = new ProjectImpl(title, description, projectGroup, getProjectBroker(projectBrokerId));
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {

        public void execute() {
            dbInstance.saveObject(project);
            ProjectBroker projectBroker = getOrLoadProjectBoker(projectBrokerId);
            if (!projectBroker.getProjects().contains(project)) {
                projectBroker.getProjects().add(project);
            }
            projectCache.update(projectBrokerId.toString(), projectBroker);
        }
    });
    return 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) ProjectImpl(org.olat.course.nodes.projectbroker.datamodel.ProjectImpl) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor)

Example 10 with ProjectBroker

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

the class ProjectBrokerManagerImpl method getProjectListBy.

/**
 * @param projectbroker_id
 * @return List of projects for certain project-broker
 */
public List<Project> getProjectListBy(final Long projectBrokerId) {
    final boolean debug = isLogDebugEnabled();
    long rstart = 0;
    if (debug) {
        logDebug("getProjectListBy for projectBroker=" + projectBrokerId);
        rstart = System.currentTimeMillis();
    }
    OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
    List<Project> projectList = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerCallback<List<Project>>() {

        public List<Project> execute() {
            ProjectBroker projectBroker = getOrLoadProjectBoker(projectBrokerId);
            return projectBroker.getProjects();
        }
    });
    if (debug) {
        long rstop = System.currentTimeMillis();
        logDebug("time to fetch project with projectbroker_id " + projectBrokerId + " :" + (rstop - rstart), null);
    }
    return projectList;
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) OLATResourceable(org.olat.core.id.OLATResourceable) ArrayList(java.util.ArrayList) List(java.util.List)

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