001: /*
002: * CalEvent.java
003: *
004: * Created on April 15, 2005, 3:42 PM
005: */
006:
007: package com.sun.portal.app.sharedevents.faces;
008:
009: import com.sun.comclient.calendar.DateTime;
010: import com.sun.comclient.calendar.VEvent;
011: import com.sun.portal.app.sharedevents.util.AppUtils;
012: import com.sun.portal.app.sharedevents.util.CalUserHelper;
013: import com.sun.portal.app.sharedevents.util.SharedConstants;
014: import java.util.TimeZone;
015:
016: /**
017: * @author SaiSatish Vedam
018: */
019: public class CalEvent {
020:
021: private VEvent event = null; // Event object that is encapsulated by this object
022: private String start = null; // Start Date Time of event
023: private String title = null; // Title of event
024: private boolean filtered = false; // Flag indicating filtered row.
025: private boolean selected = false; // Used only when maintaining state.
026: private boolean isRecurring = false;
027:
028: private String uidRid = null;
029:
030: /** Default constructor. */
031: public CalEvent(String start, String title) {
032:
033: this .start = start;
034: this .title = title;
035:
036: }
037:
038: public CalEvent(VEvent event) {
039:
040: this .event = event;
041: }
042:
043: /** Get start Date and duration of the event. */
044: public String getStart() {
045:
046: String start = null;
047:
048: if (event != null) {
049: DateTime stDt = null;
050: DateTime endDt = null;
051: try {
052: stDt = event.getStartTime();
053: endDt = event.getEndTime();
054: } catch (Exception e1) {
055: stDt = null;
056: endDt = null;
057: }
058: String df = CalUserHelper.getUserDateFormat();
059: String tzStr = CalUserHelper.getUserTimeZone();
060: TimeZone tz = TimeZone.getTimeZone(tzStr);
061:
062: start = AppUtils.getDisplayableDateTime(stDt, endDt, df,
063: "/", "24", tz);
064:
065: }
066:
067: return start;
068: }
069:
070: public void setStart(String value) {
071:
072: start = value;
073:
074: }
075:
076: public String getTitle() {
077:
078: String title = null;
079: if (event != null) {
080: try {
081: title = event.getSummary();
082: } catch (Exception e1) {
083: title = null;
084: }
085: }
086: if (title == null) {
087: title = "<Untitled Event>";
088: }
089:
090: return title;
091: }
092:
093: public void setTitle(String value) {
094:
095: if (value != null) {
096: if (event != null) {
097: try {
098: event.setSummary(value);
099: } catch (Exception e1) {
100:
101: }
102: }
103: }
104: //title = value;
105:
106: }
107:
108: /** Get flag indicating row is filtered -- see Filter util. */
109: public boolean getFiltered() {
110: return filtered;
111: }
112:
113: /** Set flag indicating row is filtered -- see Filter util. */
114: public void setFiltered(boolean value) {
115:
116: filtered = value;
117:
118: }
119:
120: /** Get selected property -- see Select util. */
121: public boolean getSelected() {
122: return selected;
123: }
124:
125: /** Set selected property -- see Select util. */
126: public void setSelected(boolean value) {
127: selected = value;
128: }
129:
130: /**
131: * Returns the Event UID and RID (if the event is recurring) concatenated with SharedConstants.UID_RID_SEPERATOR
132: * @return
133: */
134: public String getEventID() {
135: String uid = null;
136: String rid = null;
137: if (event != null) {
138: try {
139: uid = event.getID();
140: if (event.isRecurring()) {
141:
142: rid = event.getRecurrenceID().toISOString();
143: }
144: } catch (Exception e1) {
145:
146: }
147: }
148:
149: if (uid != null) {
150: if (rid != null && rid.length() > 0) {
151: uidRid = uid + SharedConstants.UID_RID_SEPERATOR + rid;
152:
153: } else {
154: uidRid = uid;
155: }
156: }
157:
158: return uidRid;
159:
160: }
161:
162: /*
163: * Returns the Event UID
164: */
165: public String getEventUID() {
166: String uid = null;
167:
168: if (event != null) {
169: try {
170: uid = event.getID();
171:
172: } catch (Exception e1) {
173:
174: }
175: }
176:
177: return uid;
178: }
179:
180: /*
181: * Returns the Event RID
182: */
183: public String getEventRID() {
184: String rid = null;
185:
186: if (event != null) {
187: try {
188: if (event.isRecurring()) {
189: rid = event.getRecurrenceID().toISOString();
190: }
191:
192: } catch (Exception e1) {
193:
194: }
195:
196: }
197:
198: return rid;
199: }
200:
201: public void setEventID(String value) {
202: uidRid = value;
203: }
204:
205: }
|