コード例 #1
0
 @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();
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .changeProjectGroupName(
             getIdentity(),
             project.getProjectGroup(),
             newProjectGroupName,
             newProjectGroupDescription,
             courseResource);
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .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 (projectState.isSelected(0)) {
     if (!project.getState().equals(stateKeys[0])) {
       project.setState(stateKeys[0]);
       projectChanged = true;
     }
   } else {
     if (!project.getState().equals(stateKeys[1])) {
       project.setState(stateKeys[1]);
       projectChanged = true;
     }
   }
   if (project.getMaxMembers() != maxMembers.getIntValue()) {
     project.setMaxMembers(maxMembers.getIntValue());
     projectChanged = true;
   }
   if (attachmentFileName.getUploadFileName() != null
       && !attachmentFileName.getUploadFileName().equals("")) {
     project.setAttachedFileName(attachmentFileName.getUploadFileName());
     uploadFiles(attachmentFileName);
   }
   // store customfields
   int index = 0;
   for (Iterator iterator = customfieldElementList.iterator(); iterator.hasNext(); ) {
     Object 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.getSelectedKey();
       } else {
         value = "";
       }
     }
     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();
     if (!project.getProjectEvent(eventType).getStartDate().equals(startDate)
         || !project.getProjectEvent(eventType).getEndDate().equals(endDate)) {
       project.setProjectEvent(new ProjectEvent(eventType, startDate, endDate));
       projectChanged = true;
     }
   }
   if (projectChanged) {
     ProjectBrokerManagerFactory.getProjectBrokerManager().updateProject(project);
     ProjectBrokerManagerFactory.getProjectBrokerEmailer()
         .sendProjectChangedEmailToParticipants(ureq.getIdentity(), project, this.getTranslator());
     fireEvent(ureq, Event.DONE_EVENT);
   }
 }
コード例 #2
0
 @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();
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .changeProjectGroupName(
             getIdentity(),
             project.getProjectGroup(),
             newProjectGroupName,
             newProjectGroupDescription,
             courseResource);
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .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());
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .setProjectGroupMaxMembers(
             getIdentity(), project.getProjectGroup(), maxMembers.getIntValue());
     projectChanged = true;
   }
   if (attachmentFileName.getUploadFileName() != null
       && !attachmentFileName.getUploadFileName().equals("")) {
     // First call uploadFiles than setAttachedFileName because uploadFiles needs old attachment
     // name
     uploadFiles(attachmentFileName);
     project.setAttachedFileName(attachmentFileName.getUploadFileName());
     projectChanged = true;
   } else if (project.getAttachmentFileName() != null
       && !project.getAttachmentFileName().equals("")) {
     // Attachment file has been removed
     project.setAttachedFileName("");
     projectChanged = true;
   }
   // store customfields
   int index = 0;
   for (Iterator iterator = customfieldElementList.iterator(); iterator.hasNext(); ) {
     Object 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 (ProjectBrokerManagerFactory.getProjectBrokerManager().existsProject(project.getKey())) {
       ProjectBrokerManagerFactory.getProjectBrokerManager().updateProject(project);
       ProjectBrokerManagerFactory.getProjectBrokerEmailer()
           .sendProjectChangedEmailToParticipants(
               ureq.getIdentity(), project, this.getTranslator());
     } else {
       this.showInfo("info.project.nolonger.exist", project.getTitle());
     }
   }
   fireEvent(ureq, Event.DONE_EVENT);
 }