0001: /**********************************************************************************
0002: * $URL: https://source.sakaiproject.org/svn/announcement/tags/sakai_2-4-1/announcement-tool/tool/src/java/org/sakaiproject/announcement/tool/AnnouncementActionState.java $
0003: * $Id: AnnouncementActionState.java 22359 2007-03-09 19:12:21Z josrodri@iupui.edu $
0004: ***********************************************************************************
0005: *
0006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
0007: *
0008: * Licensed under the Educational Community License, Version 1.0 (the "License");
0009: * you may not use this file except in compliance with the License.
0010: * You may obtain a copy of the License at
0011: *
0012: * http://www.opensource.org/licenses/ecl1.php
0013: *
0014: * Unless required by applicable law or agreed to in writing, software
0015: * distributed under the License is distributed on an "AS IS" BASIS,
0016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0017: * See the License for the specific language governing permissions and
0018: * limitations under the License.
0019: *
0020: **********************************************************************************/package org.sakaiproject.announcement.tool;
0021:
0022: import java.util.Collection;
0023: import java.util.HashMap;
0024: import java.util.Iterator;
0025: import java.util.List;
0026: import java.util.Map;
0027: import java.util.Observable;
0028: import java.util.Properties;
0029: import java.util.Set;
0030: import java.util.Vector;
0031:
0032: import org.sakaiproject.announcement.api.AnnouncementMessageEdit;
0033: import org.sakaiproject.cheftool.ControllerState;
0034: import org.sakaiproject.entity.cover.EntityManager;
0035: import org.sakaiproject.site.api.Site;
0036: import org.sakaiproject.time.api.Time;
0037: import org.sakaiproject.tool.api.SessionBindingEvent;
0038: import org.sakaiproject.tool.api.SessionBindingListener;
0039: import org.sakaiproject.tool.api.Tool;
0040: import org.sakaiproject.tool.cover.ToolManager;
0041: import org.sakaiproject.util.ParameterParser;
0042: import org.sakaiproject.util.ResourceLoader;
0043: import org.sakaiproject.util.StringUtil;
0044:
0045: /**
0046: * <p>
0047: * AnnouncementActionState is the state object for the AnnouncementAction tool. This object listens for changes on the announcement, and requests a UI delivery when changes occur.
0048: * </p>
0049: */
0050: public class AnnouncementActionState extends ControllerState implements
0051: SessionBindingListener {
0052: /** Resource bundle using current language locale */
0053: private static ResourceLoader rb = new ResourceLoader(
0054: "announcement");
0055:
0056: public static int DEFAULT_DISPLAY_NUMBER_OPTION = 100;
0057:
0058: /**
0059: * Holds the display options for the Announcements tool
0060: */
0061: static public class DisplayOptions {
0062: private static final String varNameEnforceNumberOfCharsPerAnnouncementLimit = "limitNumberOfCharsPerAnnouncement";
0063:
0064: private static final String varNameEnforceNumberOfAnnouncementsLimit = "limitNumberOfAnnouncements";
0065:
0066: private static final String varNameEnforceNumberOfDaysInPastLimit = "limitNumberOfDaysInPast";
0067:
0068: private static final String varNameShowAnnouncementBody = "showAnnouncementBody";
0069:
0070: private static final String varNameShowAllColumns = "showAllColumns";
0071:
0072: private static final String varNameNumberOfDaysInPast = "days";
0073:
0074: private static final String varNameNumberOfAnnouncements = "items";
0075:
0076: private static final String varNameNumberCharsPerAnnouncement = "length";
0077:
0078: private static final String varNameShowOnlyOptionsButton = "showOnlyOptionsButton";
0079:
0080: private static final String VarNameDisplaySelection = "displaySelection";
0081:
0082: private static final String ANNOUNCEMENT_TOOL_ID = "sakai.announcements";
0083:
0084: boolean showAllColumns = true;
0085:
0086: boolean showAnnouncementBody = false;
0087:
0088: int numberOfDaysInThePast = 365;
0089:
0090: boolean enforceNumberOfDaysInThePastLimit;
0091:
0092: int numberOfAnnouncements = DEFAULT_DISPLAY_NUMBER_OPTION;
0093:
0094: boolean enforceNumberOfAnnouncementsLimit;
0095:
0096: int numberOfCharsPerAnnouncement = Integer.MAX_VALUE;
0097:
0098: boolean enforceNumberOfCharsPerAnnouncement;
0099:
0100: boolean showOnlyOptionsButton = false;
0101:
0102: /**
0103: * Default constructor
0104: */
0105: public DisplayOptions() {
0106: }
0107:
0108: /**
0109: * Gets the number of announcements that we will show (if the limit is enabled).
0110: */
0111: public int getNumberOfAnnouncements() {
0112: return numberOfAnnouncements;
0113: }
0114:
0115: /**
0116: * Gets the number of characters that we will show in an announcement (if the limit is enabled).
0117: */
0118: public int getNumberOfCharsPerAnnouncement() {
0119: return numberOfCharsPerAnnouncement;
0120: }
0121:
0122: /**
0123: * Gets the number of days in the past for which we will show announcments (if the limit is enabled).
0124: */
0125: public int getNumberOfDaysInThePast() {
0126: return numberOfDaysInThePast;
0127: }
0128:
0129: /**
0130: * Gets whether or not we should show the announcement body.
0131: */
0132: public boolean isShowAnnouncementBody() {
0133: return showAnnouncementBody;
0134: }
0135:
0136: /**
0137: * Gets whether or not we should show all the columns associated with the announcement.
0138: */
0139: public boolean isShowAllColumns() {
0140: return showAllColumns;
0141: }
0142:
0143: /**
0144: * Sets the limit on the number of announcements to show (if the limit is enabled).
0145: */
0146: public void setNumberOfAnnouncements(int i) {
0147: // Force the setting to be greater than or equal to zero since
0148: // a negative value doesn't make sense.
0149: numberOfAnnouncements = Math.max(i, 0);
0150: }
0151:
0152: /**
0153: * Sets the number of characters to show per announcement (if the limit is enabled).
0154: */
0155: public void setNumberOfCharsPerAnnouncement(int i) {
0156: // Force the setting to be greater than or equal to zero since
0157: // a negative value doesn't make sense.
0158: numberOfCharsPerAnnouncement = Math.max(i, 0);
0159: }
0160:
0161: /**
0162: * Sets the number of days in the past for which we will show announcments (if the limit is enabled).
0163: */
0164: public void setNumberOfDaysInThePast(int i) {
0165: // Force the setting to be greater than or equal to zero since
0166: // a negative value doesn't make sense.
0167: numberOfDaysInThePast = Math.max(i, 0);
0168: }
0169:
0170: /**
0171: * Sets whether or not we should show the announcement body.
0172: */
0173: public void setShowAnnouncementBody(boolean b) {
0174: showAnnouncementBody = b;
0175: }
0176:
0177: /**
0178: * Sets whether or not we should show all the columns associated with the announcement.
0179: */
0180: public void setShowAllColumns(boolean b) {
0181: showAllColumns = b;
0182: }
0183:
0184: /**
0185: * Returns true if we should limit the number of announcments shown.
0186: */
0187: public boolean isEnforceNumberOfAnnouncementsLimit() {
0188: return enforceNumberOfAnnouncementsLimit;
0189: }
0190:
0191: /**
0192: * Returns true if we should limit the number of characters per announcement.
0193: */
0194: public boolean isEnforceNumberOfCharsPerAnnouncement() {
0195: return enforceNumberOfCharsPerAnnouncement;
0196: }
0197:
0198: /**
0199: * Returns true if we should limit the announcements displayed based on the number of days in the past on which the occurred.
0200: */
0201: public boolean isEnforceNumberOfDaysInThePastLimit() {
0202: return enforceNumberOfDaysInThePastLimit;
0203: }
0204:
0205: /**
0206: * Sets whether or not we should limit the number of announcements displayed.
0207: */
0208: public void setEnforceNumberOfAnnouncementsLimit(boolean b) {
0209: enforceNumberOfAnnouncementsLimit = b;
0210: }
0211:
0212: /**
0213: * Sets whether or not we should limit the number of chars per announcement.
0214: */
0215: public void setEnforceNumberOfCharsPerAnnouncement(boolean b) {
0216: enforceNumberOfCharsPerAnnouncement = b;
0217: }
0218:
0219: /**
0220: * Sets whether or not we shoud limit the announcements displayed based on the number of days in the past on which they occurred.
0221: */
0222: public void setEnforceNumberOfDaysInThePastLimit(boolean b) {
0223: enforceNumberOfDaysInThePastLimit = b;
0224: }
0225:
0226: /**
0227: * Utility routine used to get an integer named value from a map or supply a default value if none is found.
0228: */
0229: private int getIntegerParameter(Map params, String paramName,
0230: int defaultValue) {
0231: String intValString = (String) params.get(paramName);
0232:
0233: if (StringUtil.trimToNull(intValString) != null) {
0234: return Integer.parseInt(intValString);
0235: } else {
0236: return defaultValue;
0237: }
0238: }
0239:
0240: /**
0241: * Utility routine used to get an boolean named value from a map or supply a default value if none is found.
0242: */
0243: boolean getBooleanParameter(Map params, String paramName,
0244: boolean defaultValue) {
0245: String booleanValString = (String) params.get(paramName);
0246:
0247: if (StringUtil.trimToNull(booleanValString) != null) {
0248: return Boolean.valueOf(booleanValString).booleanValue();
0249: } else {
0250: return defaultValue;
0251: }
0252: }
0253:
0254: /**
0255: * Loads properties from a map into our object.
0256: */
0257: public void loadProperties(Map params) {
0258: setShowAllColumns(getBooleanParameter(params,
0259: varNameShowAllColumns, showAllColumns));
0260: setShowAnnouncementBody(getBooleanParameter(params,
0261: varNameShowAnnouncementBody, showAnnouncementBody));
0262: setShowOnlyOptionsButton(getBooleanParameter(params,
0263: varNameShowOnlyOptionsButton, showOnlyOptionsButton));
0264:
0265: if (params.get(varNameNumberOfDaysInPast) != null) {
0266: setNumberOfDaysInThePast(getIntegerParameter(params,
0267: varNameNumberOfDaysInPast,
0268: numberOfDaysInThePast));
0269: setEnforceNumberOfDaysInThePastLimit(true);
0270: } else {
0271: setEnforceNumberOfDaysInThePastLimit(false);
0272: }
0273:
0274: if (params.get(varNameNumberOfAnnouncements) != null) {
0275: setNumberOfAnnouncements(getIntegerParameter(params,
0276: varNameNumberOfAnnouncements,
0277: numberOfAnnouncements));
0278: setEnforceNumberOfAnnouncementsLimit(true);
0279: } else {
0280: setEnforceNumberOfAnnouncementsLimit(false);
0281: }
0282:
0283: if (params.get(varNameNumberCharsPerAnnouncement) != null) {
0284: setNumberOfCharsPerAnnouncement(getIntegerParameter(
0285: params, varNameNumberCharsPerAnnouncement,
0286: numberOfCharsPerAnnouncement));
0287: setEnforceNumberOfCharsPerAnnouncement(true);
0288: } else {
0289: setEnforceNumberOfCharsPerAnnouncement(false);
0290: }
0291: }
0292:
0293: /**
0294: * Loads properties from a ParameterParser object (usually gotten from a user's page submission).
0295: */
0296: public void loadProperties(ParameterParser parameters) {
0297: Tool tool = ToolManager.getCurrentTool();
0298: if (tool.getId().equals(ANNOUNCEMENT_TOOL_ID)) {
0299: String VarNameDisplaySelection = parameters
0300: .getString("VarNameDisplaySelection");
0301: if (VarNameDisplaySelection.equals("sortable")) {
0302: setShowAllColumns(true);
0303: setShowAnnouncementBody(false);
0304:
0305: setNumberOfCharsPerAnnouncement(numberOfCharsPerAnnouncement);
0306: setEnforceNumberOfCharsPerAnnouncement(false);
0307: } else if (VarNameDisplaySelection
0308: .equals("sortableWithBody")) {
0309: setShowAllColumns(true);
0310: setShowAnnouncementBody(true);
0311:
0312: setNumberOfCharsPerAnnouncement(numberOfCharsPerAnnouncement);
0313: setEnforceNumberOfCharsPerAnnouncement(false);
0314: } else if (VarNameDisplaySelection.equals("list")) {
0315: setShowAllColumns(false);
0316: setShowAnnouncementBody(true);
0317:
0318: String varNameNumberChars = parameters
0319: .getString("changeChars");
0320: if (varNameNumberChars.equals(rb
0321: .getString("custom.shofir"))) {
0322: setNumberOfCharsPerAnnouncement(50);
0323: setEnforceNumberOfCharsPerAnnouncement(true);
0324: } else if (varNameNumberChars.equals(rb
0325: .getString("custom.shofirtwo"))) {
0326: setNumberOfCharsPerAnnouncement(100);
0327: setEnforceNumberOfCharsPerAnnouncement(true);
0328: } else if (varNameNumberChars.equals(rb
0329: .getString("custom.shoall"))) {
0330: setNumberOfCharsPerAnnouncement(numberOfCharsPerAnnouncement);
0331: setEnforceNumberOfCharsPerAnnouncement(false);
0332: }
0333: }
0334: } else {
0335: setShowAllColumns(parameters
0336: .getBoolean(varNameShowAllColumns));
0337: setShowAnnouncementBody(parameters
0338: .getBoolean(varNameShowAnnouncementBody));
0339:
0340: String varNameNumberChars = parameters
0341: .getString("changeChars");
0342: if (varNameNumberChars.equals(rb
0343: .getString("custom.shofir"))) {
0344: setNumberOfCharsPerAnnouncement(50);
0345: setEnforceNumberOfCharsPerAnnouncement(true);
0346: } else if (varNameNumberChars.equals(rb
0347: .getString("custom.shofirtwo"))) {
0348: setNumberOfCharsPerAnnouncement(100);
0349: setEnforceNumberOfCharsPerAnnouncement(true);
0350: } else if (varNameNumberChars.equals(rb
0351: .getString("custom.shoall"))) {
0352: setNumberOfCharsPerAnnouncement(numberOfCharsPerAnnouncement);
0353: setEnforceNumberOfCharsPerAnnouncement(false);
0354: }
0355: }
0356: // if this parameter has been defined, use its value to replace the current setting
0357: // otherwise, leave alone the current setting
0358: if (parameters.get(varNameShowOnlyOptionsButton) != null) {
0359: setShowOnlyOptionsButton(parameters
0360: .getBoolean(varNameShowOnlyOptionsButton));
0361: }
0362:
0363: setNumberOfDaysInThePast(parameters
0364: .getInt(varNameNumberOfDaysInPast));
0365: setEnforceNumberOfDaysInThePastLimit(StringUtil
0366: .trimToNull(parameters
0367: .get(varNameNumberOfDaysInPast)) != null);
0368:
0369: setNumberOfAnnouncements(parameters.getInt(
0370: varNameNumberOfAnnouncements,
0371: DEFAULT_DISPLAY_NUMBER_OPTION));
0372: setEnforceNumberOfAnnouncementsLimit(StringUtil
0373: .trimToNull(parameters
0374: .get(varNameNumberOfAnnouncements)) != null);
0375:
0376: // setNumberOfCharsPerAnnouncement(parameters.getInt(varNameNumberCharsPerAnnouncement, numberOfCharsPerAnnouncement));
0377: // setEnforceNumberOfCharsPerAnnouncement(StringUtil.trimToNull(parameters.get(varNameNumberCharsPerAnnouncement)) != null);
0378: }
0379:
0380: /**
0381: * Saves the properties in this object to a ResourcePropertiesEdit object.
0382: */
0383: public void saveProperties(Properties resEdit) {
0384: resEdit.setProperty(varNameShowAllColumns, Boolean
0385: .toString(showAllColumns));
0386: resEdit.setProperty(varNameShowAnnouncementBody, Boolean
0387: .toString(showAnnouncementBody));
0388: resEdit.setProperty(varNameShowOnlyOptionsButton, Boolean
0389: .toString(showOnlyOptionsButton));
0390:
0391: if (isEnforceNumberOfDaysInThePastLimit()) {
0392: resEdit.setProperty(varNameNumberOfDaysInPast, Integer
0393: .toString(numberOfDaysInThePast));
0394: } else {
0395: // Since the absence of a property means that there are no limits, remove the
0396: // property from the resEdit object, in case it is already present.
0397: resEdit.remove(varNameNumberOfDaysInPast);
0398: }
0399:
0400: if (this .isEnforceNumberOfAnnouncementsLimit()) {
0401: resEdit.setProperty(varNameNumberOfAnnouncements,
0402: Integer.toString(numberOfAnnouncements));
0403: } else {
0404: // Since the absence of a property means that there are no limits, remove the
0405: // property from the resEdit object, in case it is already present.
0406: resEdit.remove(varNameNumberOfAnnouncements);
0407: }
0408:
0409: if (this .isEnforceNumberOfCharsPerAnnouncement()) {
0410: resEdit.setProperty(varNameNumberCharsPerAnnouncement,
0411: Integer.toString(numberOfCharsPerAnnouncement));
0412: } else {
0413: // Since the absence of a property means that there are no limits, remove the
0414: // property from the resEdit object, in case it is already present.
0415: resEdit.remove(varNameNumberCharsPerAnnouncement);
0416: }
0417: }
0418:
0419: /**
0420: * Gets a variable name for use in Velocity scripts to name input fields, etc.
0421: */
0422: public static String getVarNameEnforceNumberOfAnnouncementsLimit() {
0423: return varNameEnforceNumberOfAnnouncementsLimit;
0424: }
0425:
0426: /**
0427: * Gets a variable name for use in Velocity scripts to name input fields, etc.
0428: */
0429: public static String getVarNameEnforceNumberOfDaysInPastLimit() {
0430: return varNameEnforceNumberOfDaysInPastLimit;
0431: }
0432:
0433: /**
0434: * Gets a variable name for use in Velocity scripts to name input fields, etc.
0435: */
0436: public static String getVarNameNumberCharsPerAnnouncement() {
0437: return varNameNumberCharsPerAnnouncement;
0438: }
0439:
0440: /**
0441: * Gets a variable name for use in Velocity scripts to name input fields, etc.
0442: */
0443: public static String getVarNameNumberOfAnnouncements() {
0444: return varNameNumberOfAnnouncements;
0445: }
0446:
0447: /**
0448: * Gets a variable name for use in Velocity scripts to name input fields, etc.
0449: */
0450: public static String getVarNameEnforceNumberOfCharsPerAnnouncementLimit() {
0451: return varNameEnforceNumberOfCharsPerAnnouncementLimit;
0452: }
0453:
0454: /**
0455: * Gets a variable name for use in Velocity scripts to name input fields, etc.
0456: */
0457: public static String getVarNameNumberOfDaysInPast() {
0458: return varNameNumberOfDaysInPast;
0459: }
0460:
0461: /**
0462: * Gets a variable name for use in Velocity scripts to name input fields, etc.
0463: */
0464: public static String getVarNameShowAllColumns() {
0465: return varNameShowAllColumns;
0466: }
0467:
0468: /**
0469: * Gets a variable name for use in Velocity scripts to name input fields, etc.
0470: */
0471: public static String getVarNameShowAnnouncementBody() {
0472: return varNameShowAnnouncementBody;
0473: }
0474:
0475: public boolean isShowOnlyOptionsButton() {
0476: return showOnlyOptionsButton;
0477: }
0478:
0479: public void setShowOnlyOptionsButton(boolean b) {
0480: showOnlyOptionsButton = b;
0481: }
0482:
0483: }
0484:
0485: /** Creates new AnnouncementActionState */
0486: public AnnouncementActionState() {
0487: init();
0488: } // constructor
0489:
0490: /**
0491: * Release any resources and restore the object to initial conditions to be reused.
0492: */
0493: public void recycle() {
0494: super .recycle();
0495:
0496: } // recycle
0497:
0498: /**
0499: * Init to startup values
0500: */
0501: protected void init() {
0502: super .init();
0503:
0504: } // init
0505:
0506: private Site m_editSite;
0507:
0508: // the announcement channel id
0509: private String m_channelId = null;
0510:
0511: // the announecement message id
0512: // private String m_messageId = null;
0513: // the announecement message reference
0514: private String m_messageReference = null;
0515:
0516: // parameter for announcement status: true - new created; false - already existing
0517: private boolean m_isNewAnn = true;
0518:
0519: // the template index: the main list screen - true; other screen - false
0520: private boolean m_isListVM = true;
0521:
0522: // the list of messages to be deleted
0523: private Vector m_delete_messages = new Vector();
0524:
0525: // collection ID
0526: // private String m_collectionId = null;
0527: // vm status
0528: private String m_status = null;
0529:
0530: // temporary attachment list - never set to null!
0531: private List m_attachments = EntityManager.newReferenceList();
0532:
0533: // temporary selected attachment list
0534: private Vector m_selectedAttachments = new Vector();
0535:
0536: // temporary added attachments
0537: private Vector m_moreAttachments = new Vector();
0538:
0539: // temporary attachments only for attachment editing
0540: private Vector m_tempAttachments = new Vector();
0541:
0542: // temporary moreAttachments only for attachment editing
0543: private Vector m_tempMoreAttachments = new Vector();
0544:
0545: // temporary storage for new announcement subject
0546: private String m_tempSubject;
0547:
0548: // temporary storage for new announcement body
0549: private String m_tempBody;
0550:
0551: // temporary storage for new announcement release date
0552: private Time m_releaseDate = null;
0553:
0554: // temporary storage for new announcement retract date
0555: private Time m_retractDate = null;
0556:
0557: // temporary storage for announcement hidden
0558: private Boolean m_hidden = null;
0559:
0560: // temporary storage for announce to selection
0561: private String m_tempAnnounceTo;
0562:
0563: // temporary storage for announce to groups selection
0564: private Collection m_tempAnnounceToGroups;
0565:
0566: // temporary storage for local file inputStream, contentType and display name
0567: private HashMap m_fileProperties = new HashMap();
0568:
0569: // temporary storage for attachment properties: title, description, and copyright
0570: private HashMap m_attachProperties = new HashMap();
0571:
0572: // storage for home collection Id
0573: private String m_homeCollectionId;
0574:
0575: // storage for home Collection Display ame
0576: private String m_homeCollectionDisplayName;
0577:
0578: // ********* for sorting *********
0579: // the current sorted by property name
0580: private String m_currentSortedBy = "date";
0581:
0582: // the current sort sequence: ture - acscending/false - descending
0583: private boolean m_currentSortAsc = false;
0584:
0585: // ********* for sorting *********
0586:
0587: private DisplayOptions m_displayOptions;
0588:
0589: /**
0590: * Get
0591: */
0592: public String getTempSubject() {
0593: return m_tempSubject;
0594:
0595: } // getTempSubject()
0596:
0597: /**
0598: * Get
0599: */
0600: public String getTempBody() {
0601: return m_tempBody;
0602:
0603: } // getTempBody()
0604:
0605: /**
0606: * Get
0607: */
0608: public String getTempAnnounceTo() {
0609: return m_tempAnnounceTo;
0610:
0611: } // getTempAnnounceTo()
0612:
0613: /**
0614: * set
0615: */
0616: public void setTempAnnounceTo(String tempAnnounceTo) {
0617: // if there's a change
0618: if (tempAnnounceTo == null
0619: || !tempAnnounceTo.equals(m_tempAnnounceTo)) {
0620: // remember the new
0621: m_tempAnnounceTo = tempAnnounceTo;
0622: }
0623:
0624: } // setTempAnnounceTo()
0625:
0626: /**
0627: * Get
0628: */
0629: public Collection getTempAnnounceToGroups() {
0630: return m_tempAnnounceToGroups;
0631:
0632: } // getTempAnnounceToGroups()
0633:
0634: /**
0635: * set
0636: */
0637: public void setTempAnnounceToGroups(Collection tempAnnounceToGroups) {
0638: m_tempAnnounceToGroups = tempAnnounceToGroups;
0639:
0640: } // setTempAnnounceTo()
0641:
0642: /**
0643: * Get
0644: */
0645: public void setTempSubject(String tempSubject) {
0646: // if there's a change
0647: if (tempSubject != m_tempSubject) {
0648: // remember the new
0649: m_tempSubject = tempSubject;
0650: }
0651:
0652: } // setTempSubject()
0653:
0654: /**
0655: * Get
0656: */
0657: public void setTempBody(String tempBody) {
0658: if (tempBody != m_tempBody) {
0659: // remember the new
0660: m_tempBody = tempBody;
0661: }
0662:
0663: } // setTempBody()
0664:
0665: public void setTempReleaseDate(Time tempDate) {
0666: if (tempDate != m_releaseDate) {
0667: //remember the new
0668: m_releaseDate = tempDate;
0669: }
0670: } // setTempReleaseDate()
0671:
0672: public Time getTempReleaseDate() {
0673: return m_releaseDate;
0674: } // getTempReleaseDate()
0675:
0676: public void setTempRetractDate(Time tempDate) {
0677: if (tempDate != m_retractDate) {
0678: // remember the new
0679: m_retractDate = tempDate;
0680: }
0681: } // setTempRetractDate()
0682:
0683: public Time getTempRetractDate() {
0684: return m_retractDate;
0685: } // getTempRetractDate()
0686:
0687: public Boolean getTempHidden() {
0688: return m_hidden;
0689: }
0690:
0691: public void setTempHidden(Boolean hidden) {
0692: if (hidden != m_hidden) {
0693: m_hidden = hidden;
0694: }
0695: }
0696:
0697: /**
0698: * Get the channel id of current state
0699: *
0700: * @return The current channel id
0701: */
0702: public String getChannelId() {
0703: return m_channelId;
0704:
0705: } // getChannelId
0706:
0707: /**
0708: * Set the chat channel id to listen to.
0709: *
0710: * @param channel
0711: * The chat channel id to listen to.
0712: */
0713: public void setChannelId(String channelId) {
0714: // if there's a change
0715: if (channelId != m_channelId) {
0716: // remember the new
0717: m_channelId = channelId;
0718: }
0719:
0720: } // setChannelId
0721:
0722: // /**
0723: // * Get the collectionId of current state
0724: // * @return The current collectionId
0725: // */
0726: // public String getCollectionId()
0727: // {
0728: // return m_collectionId;
0729: //
0730: // } // getCollectionId
0731: //
0732: //
0733: // /**
0734: // * Set the chat collectionId to listen to.
0735: // * @param collectionId The collectionId.
0736: // */
0737: // public void setCollectionId(String collectionId)
0738: // {
0739: // // if there's a change
0740: // if (collectionId != m_collectionId)
0741: // {
0742: // // remember the new
0743: // m_collectionId = collectionId;
0744: // }
0745: //
0746: // } // setCollectionId
0747:
0748: /**
0749: * Get the the file properties for uploading
0750: *
0751: * @return The current collectionId
0752: */
0753: public Vector getFileProperties(String key) {
0754:
0755: Set m_filePropertiesSet = m_fileProperties.entrySet();
0756: Iterator i = m_filePropertiesSet.iterator();
0757:
0758: while (i.hasNext()) {
0759: Map.Entry me = (Map.Entry) i.next();
0760: if ((me.getKey()).equals(key))
0761: return (Vector) me.getValue();
0762: }
0763: return null;
0764:
0765: } // getFileProperties
0766:
0767: /**
0768: * Set the fileProperties
0769: *
0770: * @param key
0771: * The key for map class, which is the absolute local path of file
0772: * @param properties
0773: * The Vector which stores the inputStream, contentType, fileName of the file in order
0774: */
0775:
0776: public void setFileProperties(String key, Vector properties) {
0777: m_fileProperties.put(key, properties);
0778:
0779: } // setFileProperties
0780:
0781: /**
0782: * Get the attachment properties
0783: *
0784: * @return The property based on the given key
0785: */
0786: public Vector getAttachProperties(String key) {
0787:
0788: Set m_attachPropertiesSet = m_attachProperties.entrySet();
0789: Iterator i = m_attachPropertiesSet.iterator();
0790:
0791: while (i.hasNext()) {
0792: Map.Entry me = (Map.Entry) i.next();
0793: if ((me.getKey()).equals(key))
0794: return (Vector) me.getValue();
0795: }
0796: return null;
0797:
0798: } // getAttachProperties
0799:
0800: /**
0801: * Set the attachProperties
0802: *
0803: * @param key
0804: * The key for map class, which is the absolute local path of file
0805: * @param properties
0806: * The Vector which stores the attachment properties: title, description, and copyright in order
0807: */
0808: public void setAttachProperties(String key, Vector properties) {
0809: m_attachProperties.put(key, properties);
0810:
0811: } // setAttachProperties
0812:
0813: public void setFF(String key) {
0814: key.length();
0815: }
0816:
0817: /**
0818: * Get the status of preview: true - view new created; false - view revised existed
0819: *
0820: * @return The current status
0821: */
0822: public boolean getIsNewAnnouncement() {
0823: return m_isNewAnn;
0824:
0825: } // gsetIsNewAnnouncement
0826:
0827: /**
0828: * Set the status of preview: true - view new created; false - view revised existed
0829: *
0830: * @param preview_status
0831: * The status of preview: true - view new created; false - view revised existed
0832: */
0833: public void setIsNewAnnouncement(boolean isNewAnn) {
0834: // if there's a change
0835: if (isNewAnn != m_isNewAnn) {
0836: // remember the new
0837: m_isNewAnn = isNewAnn;
0838: }
0839:
0840: } // setIsNewAnnouncement
0841:
0842: /**
0843: * Get the current vm: true - in main list view; false - in other view
0844: *
0845: * @return The boolean to show whether in main list view
0846: */
0847: public boolean getIsListVM() {
0848: return m_isListVM;
0849:
0850: } // getIsListVM
0851:
0852: /**
0853: * Set the current vm: true - in main list view; false - in other view
0854: *
0855: * @param m_isListVM:
0856: * true - in main list view; false - in other view
0857: */
0858: public void setIsListVM(boolean isListVM) {
0859: m_isListVM = isListVM;
0860: } // setIsListVM
0861:
0862: /**
0863: * Get
0864: */
0865: public Vector getDelete_messages() {
0866: return m_delete_messages;
0867:
0868: } // getDelete_messages
0869:
0870: /**
0871: * Set
0872: */
0873: public void setDeleteMessages(Vector delete_messages) {
0874: // if there's a change
0875: if (delete_messages != null) {
0876: m_delete_messages = (Vector) delete_messages.clone();
0877: } else {
0878: m_delete_messages = null;
0879: }
0880: // remember the new
0881:
0882: } // setDelete_messages
0883:
0884: private AnnouncementMessageEdit m_edit;
0885:
0886: /**
0887: * Get edit The edit object
0888: */
0889: public void setEdit(AnnouncementMessageEdit edit) {
0890: m_edit = edit;
0891: }
0892:
0893: /**
0894: * Get edit object
0895: *
0896: * @return m_edit The edit object
0897: */
0898: public AnnouncementMessageEdit getEdit() {
0899: return m_edit;
0900: }
0901:
0902: /**
0903: * Get
0904: */
0905: public List getAttachments() {
0906: return m_attachments;
0907:
0908: } // getAttachment
0909:
0910: /**
0911: * Set
0912: */
0913: public void setAttachments(List attachments) {
0914: if (attachments != null) {
0915: m_attachments = EntityManager.newReferenceList(attachments);
0916: } else {
0917: m_attachments.clear();
0918: }
0919: // remember the new
0920:
0921: } // setAttachments
0922:
0923: /**
0924: * Get
0925: */
0926: public Vector getSelectedAttachments() {
0927: return m_selectedAttachments;
0928:
0929: } // getSelectedAttachment
0930:
0931: /**
0932: * Set
0933: */
0934: public void setSelectedAttachments(Vector selectedAttachments) {
0935: // if there's a change
0936: if (selectedAttachments != null) {
0937: m_selectedAttachments = (Vector) selectedAttachments
0938: .clone();
0939: } else {
0940: m_selectedAttachments = null;
0941: }
0942:
0943: // remember the new
0944: } // setSelectedAttachments
0945:
0946: /**
0947: * Get
0948: */
0949: public Vector getMoreAttachments() {
0950: return m_moreAttachments;
0951:
0952: } // getMoreAttachment
0953:
0954: /**
0955: * Set
0956: */
0957: public void setMoreAttachments(Vector moreAttachments) {
0958: // if there's a change
0959: if (moreAttachments != null) {
0960: m_moreAttachments = (Vector) moreAttachments.clone();
0961: } else {
0962: m_moreAttachments = null;
0963: }
0964:
0965: // remember the new
0966:
0967: } // setMoreAttachments
0968:
0969: /**
0970: * Get
0971: */
0972: public Vector getTempAttachments() {
0973: return m_tempAttachments;
0974:
0975: } // getTempAttachments
0976:
0977: /**
0978: * Set
0979: */
0980: public void setTempAttachments(Vector tempAttachments) {
0981: // if there's a change
0982: if (tempAttachments != null) {
0983: m_tempAttachments = (Vector) tempAttachments.clone();
0984: } else {
0985: m_tempAttachments = null;
0986: }
0987:
0988: // remember the new
0989:
0990: } // setTempAttachments
0991:
0992: /**
0993: * Get
0994: */
0995: public Vector getTempMoreAttachments() {
0996: return m_tempMoreAttachments;
0997:
0998: } // getTempMoreAttachments()
0999:
1000: /**
1001: * Set
1002: */
1003: public void setTempMoreAttachments(Vector tempMoreAttachments) {
1004: // if there's a change
1005: if (tempMoreAttachments != null) {
1006: m_tempMoreAttachments = (Vector) tempMoreAttachments
1007: .clone();
1008: } else {
1009: m_tempMoreAttachments = null;
1010: }
1011:
1012: // remember the new
1013:
1014: } // setTempMoreAttachments()
1015:
1016: /**********************************************************************************************************************************************************************************************************************************************************
1017: * Observer implementation
1018: *********************************************************************************************************************************************************************************************************************************************************/
1019:
1020: /**
1021: * This method is called whenever the observed object is changed. An application calls an <tt>Observable</tt> object's <code>notifyObservers</code> method to have all the object's observers notified of the change. default implementation is to
1022: * cause the courier service to deliver to the interface controlled by my controller. Extensions can override.
1023: *
1024: * @param o
1025: * the observable object.
1026: * @param arg
1027: * an argument passed to the <code>notifyObservers</code> method.
1028: */
1029: public void update(Observable o, Object arg) {
1030: // // deliver to the control panel of the portlet
1031: // CourierService.deliver(getSetId(), getId()/* %%%, ChatListAction.CONTROL_PANEL */);
1032:
1033: }
1034:
1035: /**
1036: * Get the status to be
1037: *
1038: * @return The status to be
1039: */
1040: public String getStatus() {
1041: return m_status;
1042:
1043: }
1044:
1045: /**
1046: * Set the status to be
1047: *
1048: * @param status
1049: * The status to be
1050: */
1051: public void setStatus(String status) {
1052: // if there's a change
1053: if (status != m_status) {
1054: // remember the new
1055: m_status = status;
1056: }
1057:
1058: }
1059:
1060: // ********* for sorting *********
1061: /**
1062: * set the current sorted by property name
1063: *
1064: * @param name
1065: * The sorted by property name
1066: */
1067: protected void setCurrentSortedBy(String name) {
1068: m_currentSortedBy = name;
1069:
1070: } // setCurrentSortedBy
1071:
1072: /**
1073: * get the current sorted by property name
1074: *
1075: * @return "true" if the property is sorted ascendingly; "false" if the property is sorted descendingly
1076: */
1077: protected String getCurrentSortedBy() {
1078: return m_currentSortedBy;
1079:
1080: } // getSortCurrentSortedBy
1081:
1082: /**
1083: * set the current sort property
1084: *
1085: * @param asc
1086: * "true" if the property is sorted ascendingly; "false" if the property is sorted descendingly
1087: */
1088: protected void setCurrentSortAsc(boolean asc) {
1089: m_currentSortAsc = asc;
1090:
1091: } // setCurrentSortAsc
1092:
1093: /**
1094: * get the current sort property
1095: *
1096: * @return "true" if the property is sorted ascendingly; "false" if the property is sorted descendingly
1097: */
1098: protected boolean getCurrentSortAsc() {
1099: return m_currentSortAsc;
1100:
1101: } // getCurrentSortAsc
1102:
1103: // ********* for sorting *********
1104:
1105: /**
1106: * Returns the currently selected message reference.
1107: */
1108: public String getMessageReference() {
1109: return m_messageReference;
1110: }
1111:
1112: /**
1113: * Sets the currently selected message reference.
1114: */
1115: public void setMessageReference(String string) {
1116: m_messageReference = string;
1117: }
1118:
1119: public Site getEditSite() {
1120: return m_editSite;
1121: }
1122:
1123: public void setEditSite(Site site) {
1124: m_editSite = site;
1125:
1126: }
1127:
1128: public DisplayOptions getDisplayOptions() {
1129: return m_displayOptions;
1130: }
1131:
1132: public void setDisplayOptions(DisplayOptions options) {
1133: m_displayOptions = options;
1134: }
1135:
1136: /**********************************************************************************************************************************************************************************************************************************************************
1137: * SessionBindingListener implementation
1138: *********************************************************************************************************************************************************************************************************************************************************/
1139:
1140: public void valueBound(SessionBindingEvent event) {
1141: }
1142:
1143: public void valueUnbound(SessionBindingEvent event) {
1144: // pass it on to my edits
1145: if ((m_editSite != null)
1146: && (m_editSite instanceof SessionBindingListener)) {
1147: ((SessionBindingListener) m_editSite).valueUnbound(event);
1148: }
1149:
1150: if ((m_edit != null)
1151: && (m_edit instanceof SessionBindingListener)) {
1152: ((SessionBindingListener) m_edit).valueUnbound(event);
1153: }
1154: }
1155: }
|