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());
}
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);
}
}
}
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;
}
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();
}
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);
}
Aggregations