use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
the class ProjectEditDetailsFormController method formOK.
@Override
protected void formOK(UserRequest ureq) {
boolean projectChanged = false;
if (!project.getTitle().equals(projectTitle.getValue())) {
// title has been changed => change project-group name too
String newProjectGroupName = translate("project.member.groupname", projectTitle.getValue());
String newProjectGroupDescription = translate("project.member.groupdescription", projectTitle.getValue());
OLATResource courseResource = courseEnv.getCourseGroupManager().getCourseResource();
projectGroupManager.changeProjectGroupName(getIdentity(), project.getProjectGroup(), newProjectGroupName, newProjectGroupDescription, courseResource);
projectGroupManager.sendGroupChangeEvent(project, courseEnv.getCourseResourceableId(), ureq.getIdentity());
projectChanged = true;
}
if (!project.getTitle().equals(projectTitle.getValue())) {
project.setTitle(projectTitle.getValue());
projectChanged = true;
}
if (!project.getDescription().equals(projectDescription.getValue())) {
project.setDescription(projectDescription.getValue());
projectChanged = true;
}
if (project.getMaxMembers() != maxMembers.getIntValue()) {
project.setMaxMembers(maxMembers.getIntValue());
projectGroupManager.setProjectGroupMaxMembers(getIdentity(), project.getProjectGroup(), maxMembers.getIntValue());
projectChanged = true;
}
if (StringHelper.containsNonWhitespace(attachmentFileName.getUploadFileName())) {
// First call uploadFiles than setAttachedFileName because uploadFiles needs old attachment name
uploadFiles(attachmentFileName);
project.setAttachedFileName(attachmentFileName.getUploadFileName());
projectChanged = true;
} else if (StringHelper.containsNonWhitespace(project.getAttachmentFileName()) && attachmentFileName.getInitialFile() == null) {
// Attachment file has been removed
project.setAttachedFileName("");
projectChanged = true;
}
// store customfields
int index = 0;
for (Iterator<FormItem> iterator = customfieldElementList.iterator(); iterator.hasNext(); ) {
FormItem element = iterator.next();
String value = "";
if (element instanceof TextElement) {
TextElement textElement = (TextElement) element;
value = textElement.getValue();
} else if (element instanceof SingleSelection) {
SingleSelection selectionElement = (SingleSelection) element;
if (!selectionElement.getSelectedKey().equals(DROPDOWN_NO_SELECETION)) {
value = selectionElement.getValue(selectionElement.getSelected());
} else {
value = "";
}
}
getLogger().debug("customfield index=" + index + " value=" + value + " project.getCustomFieldValue(index)=" + project.getCustomFieldValue(index));
if (!project.getCustomFieldValue(index).equals(value)) {
project.setCustomFieldValue(index, value);
projectChanged = true;
}
index++;
}
// store events
for (Project.EventType eventType : eventStartElementList.keySet()) {
Date startDate = eventStartElementList.get(eventType).getDate();
Date endDate = eventEndElementList.get(eventType).getDate();
// First handle startdate
if (hasBeenChanged(project.getProjectEvent(eventType).getStartDate(), startDate) || hasBeenChanged(project.getProjectEvent(eventType).getEndDate(), endDate)) {
project.setProjectEvent(new ProjectEvent(eventType, startDate, endDate));
projectChanged = true;
}
}
if (mailNotification.isSelected(0) != project.isMailNotificationEnabled()) {
project.setMailNotificationEnabled(mailNotification.isSelected(0));
projectChanged = true;
}
if (projectChanged) {
if (projectBrokerManager.existsProject(project.getKey())) {
projectBrokerManager.updateProject(project);
projectBrokerMailer.sendProjectChangedEmailToParticipants(ureq.getIdentity(), project, this.getTranslator());
} else {
showInfo("info.project.nolonger.exist", project.getTitle());
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.course.nodes.projectbroker.datamodel.Project 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;
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
the class ProjectBrokerManagerImpl method enrollProjectParticipant.
@Override
public boolean enrollProjectParticipant(final Identity identity, final Project project, final ProjectBrokerModuleConfiguration moduleConfig, final int nbrSelectedProjects, final boolean isParticipantInAnyProject) {
final boolean debug = isLogDebugEnabled();
OLATResourceable projectOres = OresHelper.createOLATResourceableInstance(Project.class, project.getKey());
logDebug("enrollProjectParticipant: start identity=" + identity + " project=" + project);
Boolean result = CoordinatorManager.getInstance().getCoordinator().getSyncer().doInSync(projectOres, new SyncerCallback<Boolean>() {
@Override
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);
if (debug) {
logDebug("enrollProjectParticipant: project.getMaxMembers()=" + reloadedProject.getMaxMembers());
logDebug("enrollProjectParticipant: project.getSelectedPlaces()=" + reloadedProject.getSelectedPlaces());
}
if (canBeProjectSelectedBy(identity, reloadedProject, moduleConfig, nbrSelectedProjects, isParticipantInAnyProject)) {
if (moduleConfig.isAcceptSelectionManually()) {
securityManager.addIdentityToSecurityGroup(identity, reloadedProject.getCandidateGroup());
logAudit("ProjectBroker: Add as candidate identity=" + identity + " to project=" + reloadedProject);
if (debug) {
logDebug("ProjectBroker: Add as candidate reloadedProject=" + reloadedProject + " CandidateGroup=" + reloadedProject.getCandidateGroup());
}
} else {
businessGroupRelationDao.addRole(identity, reloadedProject.getProjectGroup(), GroupRoles.participant.name());
logAudit("ProjectBroker: Add as participant identity=" + identity + " to project=" + reloadedProject);
if (debug) {
logDebug("ProjectBroker: Add as participant reloadedProject=" + reloadedProject + " ParticipantGroup=" + reloadedProject.getProjectGroup());
}
if ((reloadedProject.getMaxMembers() != Project.MAX_MEMBERS_UNLIMITED) && (reloadedProject.getSelectedPlaces() >= reloadedProject.getMaxMembers())) {
reloadedProject.setState(Project.STATE_ASSIGNED);
updateProjectAndInvalidateCache(reloadedProject);
}
}
return Boolean.TRUE;
} else {
if (debug) {
logDebug("ProjectBroker: project-group was full for identity=" + identity + " , project=" + reloadedProject);
}
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 getProjectsOf.
@Override
public List<Project> getProjectsOf(Identity identity, Long projectBrokerId) {
List<Project> myProjects = new ArrayList<Project>();
List<Project> allProjects = getProjectListBy(projectBrokerId);
// TODO: for better performance should be done with sql query instead of a loop
for (Iterator<Project> iterator = allProjects.iterator(); iterator.hasNext(); ) {
Project project = iterator.next();
if (businessGroupService.hasRoles(identity, project.getProjectGroup(), GroupRoles.participant.name())) {
myProjects.add(project);
}
}
return myProjects;
}
use of org.olat.course.nodes.projectbroker.datamodel.Project in project OpenOLAT by OpenOLAT.
the class ProjectBrokerManagerImpl method updateProjectAndInvalidateCache.
private void updateProjectAndInvalidateCache(final Project project) {
// avoid hibernate exception : object with same identifier already exist in session.
// reload object from db, because project is a detached object but could be already in hibernate session
Project reloadedProject = (Project) dbInstance.loadObject(project, true);
// set all value on reloadedProject with values from updated project
reloadedProject.setTitle(project.getTitle());
reloadedProject.setState(project.getState());
for (Project.EventType eventType : Project.EventType.values()) {
reloadedProject.setProjectEvent(project.getProjectEvent(eventType));
}
reloadedProject.setMaxMembers(project.getMaxMembers());
reloadedProject.setMailNotificationEnabled(project.isMailNotificationEnabled());
reloadedProject.setDescription(project.getDescription());
for (int index = 0; index < project.getCustomFieldSize(); index++) {
reloadedProject.setCustomFieldValue(index, project.getCustomFieldValue(index));
}
reloadedProject.setAttachedFileName(project.getAttachmentFileName());
dbInstance.updateObject(reloadedProject);
// invalide with removing from cache
projectCache.remove(project.getProjectBroker().getKey().toString());
}
Aggregations