use of org.olat.course.nodes.projectbroker.datamodel.ProjectBroker in project OpenOLAT by OpenOLAT.
the class ProjectBrokerManagerTest method testPerformanceGetProjectList.
@Test
public void testPerformanceGetProjectList() throws Exception {
int FIRST_ITERATION = 10;
int SECOND_ITERATION = 90;
int THIRD_ITERATION = 400;
// create ProjectBroker C
ProjectBroker projectBrokerC = projectBrokerManager.createAndSaveProjectBroker();
Long idProjectBrokerC = projectBrokerC.getKey();
dbInstance.closeSession();
for (int i = 0; i < FIRST_ITERATION; i++) {
createProject("thema C1_" + i, id1, idProjectBrokerC, resourceableId);
}
dbInstance.closeSession();
long startTime = System.currentTimeMillis();
List<Project> projectListC = projectBrokerManager.getProjectListBy(idProjectBrokerC);
long endTime = System.currentTimeMillis();
assertEquals("Wrong projectList.size for project-broker C after first iteration", FIRST_ITERATION, projectListC.size());
long duration = endTime - startTime;
log.info("getProjectListBy takes " + duration + "ms with " + FIRST_ITERATION + " projects");
for (int i = 0; i < SECOND_ITERATION; i++) {
createProject("thema C1_" + i, id1, idProjectBrokerC, resourceableId);
}
dbInstance.closeSession();
startTime = System.currentTimeMillis();
projectListC = projectBrokerManager.getProjectListBy(idProjectBrokerC);
endTime = System.currentTimeMillis();
int numberOfProjects = FIRST_ITERATION + SECOND_ITERATION;
assertEquals("Wrong projectList.size for project-broker C", numberOfProjects, projectListC.size());
duration = endTime - startTime;
log.info("getProjectListBy takes " + duration + "ms with " + numberOfProjects + " projects");
for (int i = 0; i < THIRD_ITERATION; i++) {
createProject("thema C1_" + i, id1, idProjectBrokerC, resourceableId);
}
dbInstance.closeSession();
startTime = System.currentTimeMillis();
projectListC = projectBrokerManager.getProjectListBy(idProjectBrokerC);
endTime = System.currentTimeMillis();
numberOfProjects = FIRST_ITERATION + SECOND_ITERATION + THIRD_ITERATION;
assertEquals("Wrong projectList.size for project-broker C", numberOfProjects, projectListC.size());
duration = endTime - startTime;
log.info("getProjectListBy takes " + duration + "ms with " + numberOfProjects + " projects");
}
use of org.olat.course.nodes.projectbroker.datamodel.ProjectBroker in project OpenOLAT by OpenOLAT.
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 OpenOLAT.
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 OpenOLAT.
the class ProjectBrokerCourseNode method postImport.
@Override
public void postImport(File importDirectory, ICourse course, CourseEnvironmentMapper envMapper, Processing processType) {
// initialize managers
if (processType == Processing.editor && importDirectory != null) {
ProjectBrokerManager projectBrokerManager = CoreSpringFactory.getImpl(ProjectBrokerManager.class);
CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager();
// create a new projectBroker
ProjectBroker projectBroker = projectBrokerManager.createAndSaveProjectBroker();
projectBrokerManager.saveProjectBrokerId(projectBroker.getKey(), cpm, this);
// get the node folder inside of the importDirectory
File folderNodeData = new File(importDirectory, getIdent());
// for the broker prefs
File projectBrokerFile = new File(folderNodeData, "projectbroker.xml");
if (projectBrokerFile.exists()) {
XStream xstream = XStreamHelper.createXStreamInstance();
ProjectGroupManager projectGroupManager = CoreSpringFactory.getImpl(ProjectGroupManager.class);
ProjectBrokerConfig brokerConfig = (ProjectBrokerConfig) XStreamHelper.readObject(xstream, projectBrokerFile);
if (brokerConfig != null && brokerConfig.getAccountGroupKey() != null) {
Long accountGroupKey = envMapper.toGroupKeyFromOriginalKey(brokerConfig.getAccountGroupKey());
if (accountGroupKey != null) {
projectGroupManager.saveAccountManagerGroupKey(accountGroupKey, cpm, this);
}
}
}
// loop through the project directories
if (folderNodeData.exists()) {
for (File projectDir : folderNodeData.listFiles(DirectoryFilter.DIRECTORY_FILTER)) {
for (File projectFile : projectDir.listFiles(new FileNameSuffixFilter("xml"))) {
importProject(projectDir, projectFile, projectBroker, course, envMapper);
}
}
}
}
super.postImport(importDirectory, course, envMapper, processType);
}
use of org.olat.course.nodes.projectbroker.datamodel.ProjectBroker in project OpenOLAT by OpenOLAT.
the class ProjectBrokerGroupDeleteManager method deleteGroupDataFor.
@Override
public boolean deleteGroupDataFor(BusinessGroup group) {
log.debug("deleteAllProjectGroupEntiresFor started.. group=" + group);
List<Project> projectList = projectBrokerManager.getProjectsWith(group);
for (Project project : projectList) {
// no course-env, no course-node
projectBrokerManager.deleteProject(project, false, null, null);
ProjectBroker projectBroker = project.getProjectBroker();
OLATResourceableDeletedEvent delEv = new OLATResourceableDeletedEvent(projectBroker);
CoordinatorManager.getInstance().getCoordinator().getEventBus().fireEventToListenersOf(delEv, projectBroker);
log.debug("deleteProjectWith: group=" + group + " , project=" + project);
}
return true;
}
Aggregations