1 package org.splat.simer;
3 import org.splat.exception.InvalidParameterException;
4 import org.splat.wapp.PopupMenu;
7 * Description creation/modification action.
9 public class EditStudyDescriptionAction extends DisplayStudyStepAction {
14 private static final long serialVersionUID = 6467920934724352021L;
19 private String _descriptionValue;
22 * Description popup menu.
24 private transient PopupMenu _descriptionPopup = null;
29 private Long _studyId;
32 * Loads description (if already loaded - reloads).
35 public String doDisplayDescription() {
37 _descriptionValue = getStudyService().getDescription(getOpenStudy().getIndex());
38 _descriptionPopup = getApplicationSettings().getPopupMenu("description");
39 } catch(InvalidParameterException exception) {
40 _descriptionValue = null;
41 LOG.debug("Error while trying to add description: " + exception.getMessage());
47 * Checks if user can set description.
48 * @return true if user can set description
50 public boolean userCanModufyDescription() {
51 return "true".equals(getWriteAccess())
52 && _openStudy.getStudyRights().canEditDescription();
56 * Sets study description.
59 public String doSetDescription() {
61 if (userCanModufyDescription() && _descriptionValue != null && _descriptionValue.length()>0) {
62 getStudyService().setDescription(_studyId, _descriptionValue);
64 } catch(InvalidParameterException exception) {
65 LOG.debug("Error while trying to add description: " + exception.getMessage());
67 doDisplayDescription();
72 * Removes study description.
75 public String doRemoveDescription() {
77 if(userCanModufyDescription()) {
78 getStudyService().removeDescription(_studyId);
80 } catch(InvalidParameterException exception) {
81 LOG.debug("Error while trying to add description: " + exception.getMessage());
83 doDisplayDescription();
88 * Get the descriptionValue.
89 * @return the descriptionValue
91 public String getDescriptionValue() {
92 return _descriptionValue;
96 * Set the descriptionValue.
97 * @param descriptionValue the descriptionValue to set
99 public void setDescriptionValue(final String descriptionValue) {
100 _descriptionValue = descriptionValue;
104 * Get the descriptionPopup. Should have this exact name since it is used in menupopup.jsp.
105 * @return the descriptionPopup
107 public PopupMenu getPopup() {
108 return _descriptionPopup;
113 * @return the studyId
115 public Long getStudyId() {
121 * @param studyId the studyId to set
123 public void setStudyId(final Long studyId) {