001: package com.sun.portal.wireless.taglibs.cal.socs;
002:
003: import com.sun.portal.wireless.taglibs.base.Util;
004: import com.sun.portal.log.common.PortalLogger;
005: import com.sun.comclient.calendar.*;
006:
007: import java.util.logging.Logger;
008: import java.util.logging.Level;
009:
010: /** This is the ReminderBean but needs impl of all the concrete classes of Reminder
011: * as of now it is like EmailReminder
012: */
013:
014: public class ReminderBean {
015:
016: private VAlarm alarm = null;
017: private int durationMin = 0;
018: private int durationHour = 0;
019: private int durationDay = 0;
020: private boolean isAbsTriggerSet = false;
021:
022: // Create a logger for this class
023: private static Logger debugLogger = PortalLogger
024: .getLogger(ReminderBean.class);
025:
026: public ReminderBean(VAlarm aAlarm) {
027: this .alarm = aAlarm;
028: }
029:
030: /**
031: @return the alarm object given as paramter to Constructor
032: */
033: public VAlarm getAlarm() {
034: return alarm;
035: }
036:
037: /**
038: This creates the duration objcet and sets to the alarm and sign
039: Uses the durationMin, durationHour , durationDay
040: */
041:
042: protected void setDuration() {
043: if (!isAbsTriggerSet) {
044: try {
045: Duration dur = new Duration(durationDay, durationHour,
046: durationMin, 0);
047: if (dur != null) {
048: dur.setSign(-1); //done because alarm is before evt or task
049: alarm.setTrigger(dur);
050: }
051: } catch (Exception ex) {
052: debugLogger.log(Level.INFO, "PSMA_CSPWTCS0004", ex);
053: }
054: }
055:
056: }
057:
058: /**
059: sets the durationMin in this Bean only
060: @param string :the value of min as string
061: */
062:
063: public void setDurationMin(String minutes) {
064: try {
065: if ((minutes != null) || (!minutes.equals(""))) {
066: durationMin = Integer.parseInt(minutes);
067: debugLogger.log(Level.FINER, "PSMA_CSPWTCS0005",
068: minutes);
069: }
070: } catch (Exception ex) {
071: debugLogger.log(Level.INFO, "PSMA_CSPWTCS0006", ex);
072: }
073: setDuration();
074: }
075:
076: /**
077: sets the durationHour in this Bean only
078: @param string :the value of hour as string
079: */
080: public void setDurationHour(String hour) {
081: try {
082: if ((hour != null) || (!hour.equals(""))) {
083: durationHour = Integer.parseInt(hour);
084: }
085: } catch (Exception ex) {
086: debugLogger.log(Level.INFO, "PSMA_CSPWTCS0006", ex);
087: }
088: setDuration();
089: }
090:
091: /**
092: sets the durationDay in this Bean only
093: @param string :the value of Day as string
094: */
095: public void setDurationDay(String day) {
096: try {
097: if ((day != null) || (!day.equals(""))) {
098: durationDay = Integer.parseInt(day);
099: }
100: } catch (Exception ex) {
101: debugLogger.log(Level.INFO, "PSMA_CSPWTCS0006", ex);
102: }
103: setDuration();
104: }
105:
106: /**
107: * Sets the Absolute Alarm Time
108: * @param DateTime the time at which alarm is required
109: */
110: public void setAbsAlarmTime(DateTime alarmTime) {
111: try {
112: alarm.setAbsTrigger(alarmTime.toISO8601());
113: isAbsTriggerSet = true;
114: } catch (Exception ex) {
115: debugLogger.log(Level.INFO, "PSMA_CSPWTCS0007", ex);
116: }
117: }
118:
119: /**
120: * Gets the Trigger
121: @return the Trigger as String , could be DateTime/Duration in String
122: */
123: public String getTrigger() {
124: VAlarm alarm = getAlarm();
125: if (alarm.getTrigger() != null) {
126: return (alarm.getTrigger()).toString();
127: }
128: return "";
129: }
130:
131: public String toString() {
132: return getTrigger();
133: }
134:
135: }
|