Search in sources :

Example 36 with Project

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

the class ProjectBrokerManagerTest method testUpdateProject.

@Test
public void testUpdateProject() throws Exception {
    ProjectBroker projectBroker = projectBrokerManager.createAndSaveProjectBroker();
    Long idProjectBroker = projectBroker.getKey();
    Project testProjectA = createProject("updateTest", id1, idProjectBroker, resourceableId);
    DBFactory.getInstance().closeSession();
    // testProjectA is now a detached-object
    // Update 1
    String updateTitle = "thema updateProject-Test update1";
    testProjectA.setTitle(updateTitle);
    String updateDescription = "description update1";
    testProjectA.setDescription(updateDescription);
    String updateState = "state update1";
    testProjectA.setState(updateState);
    projectBrokerManager.updateProject(testProjectA);
    dbInstance.closeSession();
    // testProjectA is now a detached-object again
    Project reloadedProject = (Project) dbInstance.loadObject(testProjectA, true);
    assertEquals("Wrong updated title 1", updateTitle, reloadedProject.getTitle());
    // Update 2
    String updateTitle2 = "thema updateProject-Test update2";
    testProjectA.setTitle(updateTitle2);
    int updateMaxMembers = 3;
    testProjectA.setMaxMembers(updateMaxMembers);
    String updateAttachmentFileName = "attachmentFile.txt";
    testProjectA.setAttachedFileName(updateAttachmentFileName);
    boolean updateMailNotification = Boolean.TRUE;
    testProjectA.setMailNotificationEnabled(updateMailNotification);
    String updateCustomField0 = "CustomField0";
    testProjectA.setCustomFieldValue(0, updateCustomField0);
    String updateCustomField1 = "CustomField1";
    testProjectA.setCustomFieldValue(1, updateCustomField1);
    projectBrokerManager.updateProject(testProjectA);
    dbInstance.closeSession();
    // Update 3
    Calendar cal = Calendar.getInstance();
    cal.clear();
    cal.set(2010, 11, 15, 15, 30, 45);
    Date startDate = cal.getTime();
    cal.clear();
    cal.set(2010, 11, 20, 15, 30, 45);
    Date endDate = cal.getTime();
    ProjectEvent projectEventEnroll = new ProjectEvent(Project.EventType.ENROLLMENT_EVENT, startDate, endDate);
    testProjectA.setProjectEvent(projectEventEnroll);
    ProjectEvent projectEventHandout = new ProjectEvent(Project.EventType.HANDOUT_EVENT, startDate, endDate);
    testProjectA.setProjectEvent(projectEventHandout);
    dbInstance.closeSession();
    reloadedProject = (Project) DBFactory.getInstance().loadObject(testProjectA, true);
    assertEquals("Wrong updated title 2", updateTitle2, reloadedProject.getTitle());
    assertEquals("Wrong description", updateDescription, reloadedProject.getDescription());
    assertEquals("Wrong state", updateState, reloadedProject.getState());
    assertEquals("Wrong maxMembers", updateMaxMembers, reloadedProject.getMaxMembers());
    assertEquals("Wrong AttachmentFileName", updateAttachmentFileName, reloadedProject.getAttachmentFileName());
    assertEquals("Wrong MailNotification", updateMailNotification, reloadedProject.isMailNotificationEnabled());
    assertEquals("Wrong CustomField 0", updateCustomField0, reloadedProject.getCustomFieldValue(0));
    assertEquals("Wrong CustomField 1", updateCustomField1, reloadedProject.getCustomFieldValue(1));
    assertEquals("Wrong customField Size", 2, reloadedProject.getCustomFieldSize());
    assertEquals("Wrong event Type (Handout)", Project.EventType.HANDOUT_EVENT, reloadedProject.getProjectEvent(Project.EventType.HANDOUT_EVENT).getEventType());
    assertEquals("Wrong event start-date (Handout)", startDate.getTime(), reloadedProject.getProjectEvent(Project.EventType.HANDOUT_EVENT).getStartDate().getTime());
    assertEquals("Wrong event end-date (Handout)", endDate.getTime(), reloadedProject.getProjectEvent(Project.EventType.HANDOUT_EVENT).getEndDate().getTime());
    assertEquals("Wrong event Type (Enroll)", Project.EventType.ENROLLMENT_EVENT, reloadedProject.getProjectEvent(Project.EventType.ENROLLMENT_EVENT).getEventType());
    assertEquals("Wrong event start-date (Enroll)", startDate.getTime(), reloadedProject.getProjectEvent(Project.EventType.ENROLLMENT_EVENT).getStartDate().getTime());
    assertEquals("Wrong event end-date (Enroll)", endDate.getTime(), reloadedProject.getProjectEvent(Project.EventType.ENROLLMENT_EVENT).getEndDate().getTime());
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) ProjectBroker(org.olat.course.nodes.projectbroker.datamodel.ProjectBroker) Calendar(java.util.Calendar) Date(java.util.Date) ProjectEvent(org.olat.course.nodes.projectbroker.datamodel.ProjectEvent) Test(org.junit.Test)

Example 37 with Project

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

the class ProjectGroupManagerImpl method acceptAllCandidates.

@Override
public void acceptAllCandidates(Long projectBrokerId, Identity actionIdentity, boolean autoSignOut, boolean isAcceptSelectionManually) {
    // loop over all project
    List<Project> projectList = projectBrokerManager.getProjectListBy(projectBrokerId);
    for (Iterator<Project> iterator = projectList.iterator(); iterator.hasNext(); ) {
        Project project = iterator.next();
        List<Identity> candidates = securityManager.getIdentitiesOfSecurityGroup(project.getCandidateGroup());
        if (!candidates.isEmpty()) {
            log.audit("ProjectBroker: Accept ALL candidates, project=" + project);
            acceptCandidates(candidates, project, actionIdentity, autoSignOut, isAcceptSelectionManually);
        }
    }
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) Identity(org.olat.core.id.Identity)

Example 38 with Project

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

the class ProjectGroupManagerImpl method hasProjectBrokerAnyCandidates.

@Override
public boolean hasProjectBrokerAnyCandidates(Long projectBrokerId) {
    List<Project> projectList = projectBrokerManager.getProjectListBy(projectBrokerId);
    for (Iterator<Project> iterator = projectList.iterator(); iterator.hasNext(); ) {
        Project project = iterator.next();
        List<Identity> candidates = securityManager.getIdentitiesOfSecurityGroup(project.getCandidateGroup());
        if (!candidates.isEmpty()) {
            return true;
        }
    }
    return false;
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) Identity(org.olat.core.id.Identity)

Example 39 with Project

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

the class ProjectBrokerManagerImpl method cancelProjectEnrollmentOf.

public boolean cancelProjectEnrollmentOf(final Identity identity, final Project project, final ProjectBrokerModuleConfiguration moduleConfig) {
    OLATResourceable projectOres = OresHelper.createOLATResourceableInstance(Project.class, project.getKey());
    Boolean result = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectOres, new SyncerCallback<Boolean>() {

        public Boolean execute() {
            if (existsProject(project.getKey())) {
                // For cluster-safe : reload project object here another node might have changed this in the meantime
                Project reloadedProject = (Project) dbInstance.loadObject(project, true);
                // User can only cancel enrollment, when state is 'NOT_ASSIGNED'
                if (canBeCancelEnrollmentBy(identity, project, moduleConfig)) {
                    businessGroupRelationDao.removeRole(identity, reloadedProject.getProjectGroup(), GroupRoles.participant.name());
                    securityManager.removeIdentityFromSecurityGroup(identity, reloadedProject.getCandidateGroup());
                    logAudit("ProjectBroker: Remove (as participant or waitinglist) identity=" + identity + " from project=" + project);
                    if (isLogDebugEnabled()) {
                        logDebug("ProjectBroker: Remove as participant reloadedProject=" + reloadedProject + "  ParticipantGroup=" + reloadedProject.getProjectGroup() + "  CandidateGroup=" + reloadedProject.getCandidateGroup());
                    }
                    if ((reloadedProject.getMaxMembers() != Project.MAX_MEMBERS_UNLIMITED) && (reloadedProject.getSelectedPlaces() < reloadedProject.getMaxMembers())) {
                        reloadedProject.setState(Project.STATE_NOT_ASSIGNED);
                        updateProjectAndInvalidateCache(reloadedProject);
                    }
                    return Boolean.TRUE;
                } else {
                    return Boolean.FALSE;
                }
            } else {
                // project no longer exist
                return Boolean.FALSE;
            }
        }
    });
    // end of doInSync
    return result.booleanValue();
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) OLATResourceable(org.olat.core.id.OLATResourceable)

Example 40 with Project

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

the class ProjectBrokerManagerImpl method deleteProject.

/**
 * Delete a project and delete project-groups related to this project.
 * This method is cluster-save.
 * @see org.olat.course.nodes.projectbroker.service.ProjectBrokerManager#deleteProject(org.olat.course.nodes.projectbroker.datamodel.Project)
 */
public void deleteProject(final Project project, final boolean deleteGroup, final CourseEnvironment courseEnv, final CourseNode cNode) {
    logDebug("start deleteProject project=" + project);
    final Long projectBrokerId = project.getProjectBroker().getKey();
    OLATResourceable projectBrokerOres = OresHelper.createOLATResourceableInstance(this.getClass(), projectBrokerId);
    CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectBrokerOres, new SyncerExecutor() {

        public void execute() {
            Project reloadedProject = (Project) dbInstance.loadObject(project, true);
            // delete first candidate-group, project-group will be deleted after deleting project
            SecurityGroup candidateGroup = reloadedProject.getCandidateGroup();
            if ((courseEnv != null) && (cNode != null)) {
                deleteAllAttachmentFilesOfProject(reloadedProject, courseEnv, cNode);
                deleteAllDropboxFilesOfProject(reloadedProject, courseEnv, cNode);
                deleteAllReturnboxFilesOfProject(reloadedProject, courseEnv, cNode);
            }
            dbInstance.deleteObject(reloadedProject);
            logInfo("deleteSecurityGroup(project.getCandidateGroup())=" + candidateGroup.getKey());
            securityManager.deleteSecurityGroup(candidateGroup);
            // invalide with removing from cache
            projectCache.remove(projectBrokerId.toString());
        }
    });
    if (deleteGroup) {
        logDebug("start deleteProjectGroupFor project=" + project);
        projectGroupManager.deleteProjectGroupFor(project);
    }
    logDebug("DONE deleteProjectGroupFor project=" + project);
}
Also used : Project(org.olat.course.nodes.projectbroker.datamodel.Project) OLATResourceable(org.olat.core.id.OLATResourceable) SyncerExecutor(org.olat.core.util.coordinate.SyncerExecutor) SecurityGroup(org.olat.basesecurity.SecurityGroup)

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