Class BwAlarm

All Implemented Interfaces:
Serializable, Comparable<BwAlarm>, AttendeesEntity, DescriptionEntity<BwString>, Differable<BwAlarm>, OwnedEntity, SummaryEntity, XpropsEntity, org.bedework.util.logging.Logged

An alarm in bedework representing an rfc2445 valarm object.

The same alarm entity may be referred to by some or all instances of a recurring event. The alarm entity contains the real time (UTC) at which it will next trigger. This is derived from the event which refers to it.

When an event is triggered we determine if that event is now expired or if it now has a new trigger time based on another instance for that event. We update the entity to reflect that.

Expired events are explicitly flagged as such. We don't use time as the indicator as system down time could lead to alarms never being triggered. This could lead to an alarm storm if there is a long down time.

Version:
1.0
Author:
Mike Douglass douglm . rpi.edu
See Also:
  • Field Details

    • alarmTypeAudio

      public static final int alarmTypeAudio
      audio
      See Also:
    • alarmTypeDisplay

      public static final int alarmTypeDisplay
      display
      See Also:
    • alarmTypeEmail

      public static final int alarmTypeEmail
      email
      See Also:
    • alarmTypeProcedure

      public static final int alarmTypeProcedure
      procedure
      See Also:
    • alarmTypeNone

      public static final int alarmTypeNone
      none
      See Also:
    • alarmTypeOther

      public static final int alarmTypeOther
      other - name in x-props
      See Also:
    • alarmTypes

      public static final String[] alarmTypes
      Names for type of alarm
    • alarmType

      protected int alarmType
    • trigger

      protected String trigger
    • triggerStart

      protected boolean triggerStart
    • triggerDateTime

      protected boolean triggerDateTime
    • duration

      protected String duration
    • repeat

      protected int repeat
    • repeatCount

      protected int repeatCount
    • expired

      protected boolean expired
    • attach

      protected String attach
    • attendees

      protected Set<BwAttendee> attendees
    • triggerDate

      protected Date triggerDate
      Calculated on a call to getTriggerDate()
  • Constructor Details

    • BwAlarm

      public BwAlarm()
      Constructor
  • Method Details

    • setAlarmType

      public void setAlarmType(int val)
      Set the alarmType for this event

      This corrresponds to the ACTION property but perhaps not close enough

      Parameters:
      val - alarmType
    • getAlarmType

      public int getAlarmType()
      Get the alarmType
      Returns:
      int alarmType
    • setTrigger

      public void setTrigger(String val)
      Set the trigger - rfc format
      Parameters:
      val - String trigger value
    • getTrigger

      public String getTrigger()
      Get the trigger in rfc format
      Returns:
      String trigger value
    • setTriggerStart

      public void setTriggerStart(boolean val)
      Set the triggerStart flag
      Parameters:
      val - boolean true if we trigger off start
    • getTriggerStart

      public boolean getTriggerStart()
      Get the triggerStart flag
      Returns:
      boolean true if we trigger off start
    • setTriggerDateTime

      public void setTriggerDateTime(boolean val)
      Set the triggerDateTime flag
      Parameters:
      val - boolean true if we trigger off DateTime
    • getTriggerDateTime

      public boolean getTriggerDateTime()
      Get the triggerDateTime flag
      Returns:
      boolean true if we trigger off DateTime
    • setDuration

      public void setDuration(String val)
      Set the duration - rfc format
      Parameters:
      val - String duration value
    • getDuration

      public String getDuration()
      Get the duration in rfc format
      Returns:
      String duration value
    • setRepeat

      public void setRepeat(int val)
      Set the repetition count for this alarm, 0 means no repeat, 1 means 2 alarms will be sent etc.
      Parameters:
      val - repetition count
    • getRepeat

      public int getRepeat()
      Get the repetition count
      Returns:
      int the repetition count
    • setRepeatCount

      public void setRepeatCount(int val)
      Set the current repetition count for this alarm.
      Parameters:
      val - repetition count
    • getRepeatCount

      public int getRepeatCount()
      Get the current repetition count
      Returns:
      int the repetition count
    • setExpired

      public void setExpired(boolean val)
      Set the expired flag
      Parameters:
      val - boolean true if the alarm has expired
    • getExpired

      public boolean getExpired()
      Get the expired flag
      Returns:
      boolean true if expired
    • setAttach

      public void setAttach(String val)
      Set the attachment
      Parameters:
      val - String attachment name
    • getAttach

      public String getAttach()
      Get the attachment
      Returns:
      String attachment name
    • getEntityType

      public int getEntityType()
      Returns:
      type of entity
    • setAttendees

      public void setAttendees(Set<BwAttendee> val)
      Description copied from interface: AttendeesEntity
      Set the attendees Set
      Specified by:
      setAttendees in interface AttendeesEntity
      Parameters:
      val - Set of attendees
    • getAttendees

      public Set<BwAttendee> getAttendees()
      Description copied from interface: AttendeesEntity
      Get the attendees
      Specified by:
      getAttendees in interface AttendeesEntity
      Returns:
      Set attendees list
    • getNumAttendees

      public int getNumAttendees()
      Specified by:
      getNumAttendees in interface AttendeesEntity
      Returns:
      int number of attendees.
    • addAttendee

      public void addAttendee(BwAttendee val)
      Specified by:
      addAttendee in interface AttendeesEntity
    • removeAttendee

      public boolean removeAttendee(BwAttendee val)
      Specified by:
      removeAttendee in interface AttendeesEntity
      Returns:
      boolean true if removed.
    • copyAttendees

      public Set<BwAttendee> copyAttendees()
      Description copied from interface: AttendeesEntity
      Return a copy of the Set
      Specified by:
      copyAttendees in interface AttendeesEntity
      Returns:
      Set of BwAttendee
    • cloneAttendees

      public Set<BwAttendee> cloneAttendees()
      Description copied from interface: AttendeesEntity
      Return a clone of the Set
      Specified by:
      cloneAttendees in interface AttendeesEntity
      Returns:
      Set of BwAttendee
    • setRecipients

      public void setRecipients(Set<String> val)
      Description copied from interface: AttendeesEntity
      Set the recipients Set
      Specified by:
      setRecipients in interface AttendeesEntity
      Parameters:
      val - Set of (String)recipients
    • getRecipients

      public Set<String> getRecipients()
      Description copied from interface: AttendeesEntity
      Get the recipients
      Specified by:
      getRecipients in interface AttendeesEntity
      Returns:
      Set recipients set
    • getNumRecipients

      public int getNumRecipients()
      Specified by:
      getNumRecipients in interface AttendeesEntity
      Returns:
      int number of recipients.
    • addRecipient

      public void addRecipient(String val)
      Specified by:
      addRecipient in interface AttendeesEntity
    • removeRecipient

      public boolean removeRecipient(String val)
      Specified by:
      removeRecipient in interface AttendeesEntity
      Returns:
      boolean true if removed.
    • setDescriptions

      public void setDescriptions(Set<BwString> val)
      Description copied from interface: DescriptionEntity
      Set the descriptions Set
      Specified by:
      setDescriptions in interface DescriptionEntity<BwString>
      Parameters:
      val - Set of (BwString)descriptions
    • getDescriptions

      public Set<BwString> getDescriptions()
      Description copied from interface: DescriptionEntity
      Get the descriptions
      Specified by:
      getDescriptions in interface DescriptionEntity<BwString>
      Returns:
      Set descriptions set
    • getNumDescriptions

      public int getNumDescriptions()
      Specified by:
      getNumDescriptions in interface DescriptionEntity<BwString>
      Returns:
      int number of descriptions.
    • addDescription

      public void addDescription(String lang, String val)
      Specified by:
      addDescription in interface DescriptionEntity<BwString>
    • addDescription

      public void addDescription(BwString val)
      Specified by:
      addDescription in interface DescriptionEntity<BwString>
    • removeDescription

      public boolean removeDescription(BwString val)
      Specified by:
      removeDescription in interface DescriptionEntity<BwString>
      Returns:
      boolean true if removed.
    • updateDescriptions

      public void updateDescriptions(String lang, String val)
      Description copied from interface: DescriptionEntity
      If description with given lang is present updates the value, otherwise adds it.
      Specified by:
      updateDescriptions in interface DescriptionEntity<BwString>
    • findDescription

      public BwString findDescription(String lang)
      Specified by:
      findDescription in interface DescriptionEntity<BwString>
      Returns:
      BwString with language code or default
    • setDescription

      public void setDescription(String val)
      Specified by:
      setDescription in interface DescriptionEntity<BwString>
      Parameters:
      val - String default
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface DescriptionEntity<BwString>
      Returns:
      String default
    • setSummaries

      public void setSummaries(Set<BwString> val)
      Description copied from interface: SummaryEntity
      Set the summaries Set
      Specified by:
      setSummaries in interface SummaryEntity
      Parameters:
      val - Set of (BwString)summaries
    • getSummaries

      public Set<BwString> getSummaries()
      Description copied from interface: SummaryEntity
      Get the summaries
      Specified by:
      getSummaries in interface SummaryEntity
      Returns:
      Set summaries set
    • getNumSummaries

      public int getNumSummaries()
      Specified by:
      getNumSummaries in interface SummaryEntity
      Returns:
      int number of summaries.
    • addSummary

      public void addSummary(BwString val)
      Specified by:
      addSummary in interface SummaryEntity
    • removeSummary

      public boolean removeSummary(BwString val)
      Specified by:
      removeSummary in interface SummaryEntity
      Returns:
      boolean true if removed.
    • updateSummaries

      public void updateSummaries(String lang, String val)
      Description copied from interface: SummaryEntity
      If summary with given lang is present updates the value, otherwise adds it.
      Specified by:
      updateSummaries in interface SummaryEntity
    • findSummary

      public BwString findSummary(String lang)
      Specified by:
      findSummary in interface SummaryEntity
      Returns:
      BwString with language code or default
    • setSummary

      public void setSummary(String val)
      Specified by:
      setSummary in interface SummaryEntity
      Parameters:
      val - String default
    • getSummary

      public String getSummary()
      Specified by:
      getSummary in interface SummaryEntity
      Returns:
      String default
    • setXproperties

      public void setXproperties(List<BwXproperty> val)
      Description copied from interface: XpropsEntity
      Set the x-props
      Specified by:
      setXproperties in interface XpropsEntity
      Parameters:
      val - list of x-props
    • getXproperties

      public List<BwXproperty> getXproperties()
      Specified by:
      getXproperties in interface XpropsEntity
      Returns:
      List
    • getNumXproperties

      public int getNumXproperties()
      Specified by:
      getNumXproperties in interface XpropsEntity
      Returns:
      int
    • getXproperties

      public List<BwXproperty> getXproperties(String val)
      Specified by:
      getXproperties in interface XpropsEntity
      Parameters:
      val - - name to match
      Returns:
      list of matching properties - never null
    • getXicalProperties

      public List<BwXproperty> getXicalProperties(String val)
      Find x-properties storing the value of the named ical property
      Specified by:
      getXicalProperties in interface XpropsEntity
      Parameters:
      val - - name to match
      Returns:
      list of matching properties - never null
    • removeXproperties

      public int removeXproperties(String val)
      Remove all instances of the named property.
      Specified by:
      removeXproperties in interface XpropsEntity
      Parameters:
      val - - name to match
      Returns:
      number of removed proeprties
    • addXproperty

      public void addXproperty(BwXproperty val)
      Specified by:
      addXproperty in interface XpropsEntity
      Parameters:
      val - an x-prop
    • removeXproperty

      public void removeXproperty(BwXproperty val)
      Specified by:
      removeXproperty in interface XpropsEntity
      Parameters:
      val - an x-prop
    • cloneXproperty

      public List<BwXproperty> cloneXproperty()
      Specified by:
      cloneXproperty in interface XpropsEntity
      Returns:
      List of x-properties
    • getNextTriggerDate

      public Date getNextTriggerDate(BwDateTime start, Date previousTrigger) throws CalFacadeException
      Get the next trigger Date value. This is the next time for the alarm.

      This is based on the previous time which will have been set when the alarm was last triggered.

      Returns null for no more triggers.

      Can be called repeatedly for the same result. To move to the next trigger time, update repeatCount.

      Parameters:
      start - for instance to base this on
      previousTrigger - null for first
      Returns:
      Date next trigger time as a date object
      Throws:
      CalFacadeException - on error
    • getTriggerDate

      public Date getTriggerDate(BwDateTime start) throws CalFacadeException
      Get the trigger Date value. This is the earliest time for the alarm.
      Returns:
      Date trigger time as a date object
      Throws:
      CalFacadeException - on error
    • audioAlarm

      public static BwAlarm audioAlarm(String owner, BwAlarm.TriggerVal trigger, String duration, int repeat, String attach)
      Make an audio alarm
      Parameters:
      owner - the href
      trigger - a TriggerVal
      duration - String dur value
      repeat - count
      attach - attachment
      Returns:
      BwEventAlarm
    • displayAlarm

      public static BwAlarm displayAlarm(String owner, BwAlarm.TriggerVal trigger, String duration, int repeat, String description)
      Make a display alarm
      Parameters:
      owner - the href
      trigger - a TriggerVal
      duration - String dur value
      repeat - count
      description - text
      Returns:
      BwEventAlarm
    • emailAlarm

      public static BwAlarm emailAlarm(String owner, BwAlarm.TriggerVal trigger, String duration, int repeat, String attach, String description, String summary, Set<BwAttendee> attendees)
      Make an email alarm
      Parameters:
      owner - the href
      trigger - a TriggerVal
      duration - String dur value
      repeat - count
      attach - to send
      description - text
      summary - text
      attendees - recipients
      Returns:
      BwEventAlarm
    • procedureAlarm

      public static BwAlarm procedureAlarm(String owner, BwAlarm.TriggerVal trigger, String duration, int repeat, String attach, String description)
      Make a procedure alarm
      Parameters:
      owner - the href
      trigger - a TriggerVal
      duration - String dur value
      repeat - count
      attach - to send
      description - text
      Returns:
      BwEventAlarm
    • noneAlarm

      public static BwAlarm noneAlarm(String owner, BwAlarm.TriggerVal trigger, String duration, int repeat, String description)
      Make a "ACTION:NONE" alarm
      Parameters:
      owner - the href
      trigger - a TriggerVal
      duration - String dur value
      repeat - count
      description - text
      Returns:
      BwEventAlarm
    • otherAlarm

      public static BwAlarm otherAlarm(String owner, String action, BwAlarm.TriggerVal trigger, String duration, int repeat, String description)
      Make an alarm for an unrecognizd action
      Parameters:
      owner - the href
      trigger - a TriggerVal
      duration - String dur value
      repeat - count
      description - text
      Returns:
      BwEventAlarm
    • toStringSegment

      protected void toStringSegment(org.bedework.util.misc.ToString ts)
      Description copied from class: BwOwnedDbentity
      Add our stuff to the ToString object
      Overrides:
      toStringSegment in class BwOwnedDbentity<BwAlarm>
      Parameters:
      ts - ToString for result
    • matches

      public boolean matches(BwAlarm that)
      Here we attempt to see if an incomplete object matches this one. We match in order:
      action, trigger, duration, repeat

      The absence of duration and repeat in the pattern is a problem if there is one in the event set that has no duration/repeat and one that does.

      Parameters:
      that - alarm to match
      Returns:
      true if it matches.
    • changed

      public boolean changed(BwAlarm that)
      An alarm is equal for same event, owner, action and trigger.

      However, we also need to know if a particular alarm has been changed.

      Parameters:
      that - alarm to check
      Returns:
      boolean true if this alarm is changed with respect to that
    • compareEqFields

      public int compareEqFields(BwAlarm that)
      Compare fields that define equality
      Parameters:
      that - alarm to compare
      Returns:
      int
    • differsFrom

      public boolean differsFrom(BwAlarm val)
      Description copied from interface: Differable
      Return true if the entity differs in any way.
      Specified by:
      differsFrom in interface Differable<BwAlarm>
      Returns:
      boolean
    • compareTo

      public int compareTo(BwAlarm that)
      Specified by:
      compareTo in interface Comparable<BwAlarm>
      Overrides:
      compareTo in class BwUnversionedDbentity<BwAlarm>
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class BwUnversionedDbentity<BwAlarm>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • clone

      public Object clone()
      Description copied from class: BwUnversionedDbentity
      Make visible
      Overrides:
      clone in class BwUnversionedDbentity<BwAlarm>
      Returns:
      Object of class T