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