use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
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;
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
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);
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
the class ProjectBrokerManagerImpl method getOrLoadProjectBoker.
// /////////////////
// Private Methods
// /////////////////
private ProjectBroker getOrLoadProjectBoker(final Long projectBrokerId) {
// 1. check if alreday a projectBroker is in the cache
ProjectBroker projectBroker = projectCache.get(projectBrokerId.toString());
if (projectBroker == null) {
logDebug("find no projectBroker in the cache => create a new one projectBrokerId=" + projectBrokerId);
StringBuilder sb = new StringBuilder();
sb.append("select distinct project from ").append(ProjectImpl.class.getName()).append(" as project ").append(" left join fetch project.projectGroup pGroup").append(" left join fetch pGroup.baseGroup bGroup").append(" where project.projectBroker.key=:projectBrokerKey");
List<Project> projectList = dbInstance.getCurrentEntityManager().createQuery(sb.toString(), Project.class).setParameter("projectBrokerKey", projectBrokerId).getResultList();
projectBroker = getProjectBroker(projectBrokerId);
projectBroker.setProjects(projectList);
projectCache.put(projectBrokerId.toString(), projectBroker);
}
return projectBroker;
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
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