@Override public VAlarm createComponent() { return new VAlarm(); }
@Override public void applyTo(VAlarm element) { Action action = element.getAction(); if (action == null || !"DISPLAY".equals(action.getValue()) || element.getDescription() != null && element.getDescription().getValue() != null) { return; } Description description = new Description("display"); element.getProperties().add(description); }
/** * Returns the optional description property. * @return the DESCRIPTION property or null if not specified */ public final Description getDescription() { return getProperty(Property.DESCRIPTION); }
PropertyValidator.getInstance().assertOne(Property.ACTION, getProperties()); PropertyValidator.getInstance().assertOne(Property.TRIGGER, getProperties()); PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties()); PropertyValidator.getInstance().assertOneOrLess(Property.REPEAT, getProperties()); PropertyValidator.getInstance().assertNone(Property.DURATION, getProperties()); PropertyValidator.getInstance().assertNone(Property.REPEAT, getProperties()); PropertyValidator.getInstance().assertOne(Property.DURATION, getProperties()); PropertyValidator.getInstance().assertOne(Property.REPEAT, getProperties()); final Validator actionValidator = actionValidators.get(getAction()); if (actionValidator != null) { actionValidator.validate(this); validateProperties();
public void creatDisplayAlarm() { VAlarm alarm = new VAlarm(); alarm.getProperties().add(Action.DISPLAY); getEvent().getAlarms().add(alarm); setDisplayAlarmDescription("Event Reminder"); } }
/** * Constructs a new VALARM instance that will trigger at the specified time. * @param trigger the time the alarm will trigger */ public VAlarm(final DateTime trigger) { this(); getProperties().add(new Trigger(trigger)); }
VAlarm alarm = new VAlarm(); alarm.getProperties().add(new Trigger(new DateTime(System.currentTimeMillis()))); alarm = (VAlarm) alarm.copy(); alarm.getProperties().add(Action.DISPLAY); alarm.getProperties().add(new Description("Testing display")); suite.addTest(new VAlarmTest("testValidation", alarm)); alarm = new VAlarm(java.time.Duration.ofHours(2)); alarm.getProperties().add(Action.DISPLAY); alarm.getProperties().add(new Description("Testing display")); Duration duration = new Duration(java.time.Duration.ofMinutes(2)); alarm.getProperties().add(duration); suite.addTest(new VAlarmTest("testValidationException", alarm)); alarm = (VAlarm) alarm.copy(); alarm.getProperties().add(new Repeat(2)); suite.addTest(new VAlarmTest("testValidation", alarm)); alarm = (VAlarm) alarm.copy(); alarm.getProperties().remove(duration); suite.addTest(new VAlarmTest("testValidationException", alarm)); alarm = new VAlarm(java.time.Duration.ofDays(-2)); alarm.getProperties().add(Action.EMAIL); alarm.getProperties().add(new Attendee("mailto:john_doe@example.com")); alarm.getProperties().add(new Summary("*** REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING ***")); alarm.getProperties().add(new Description("A draft agenda needs to be sent out to the attendees " + "to the weekly managers meeting (MGR-LIST). Attached is a "
public void validate(final VEvent target) throws ValidationException { Arrays.asList(DTSTAMP, DTSTART, ORGANIZER, SEQUENCE, SUMMARY, UID).forEach(property -> PropertyValidator.getInstance().assertOne(property, target.getProperties())); Arrays.asList(CATEGORIES, CLASS, CREATED, DESCRIPTION, DTEND, DURATION, GEO, LAST_MODIFIED, LOCATION, PRIORITY, RESOURCES, STATUS, TRANSP, URL).forEach(property -> PropertyValidator.getInstance().assertOneOrLess(property, target.getProperties())); Arrays.asList(RECURRENCE_ID, REQUEST_STATUS).forEach(property -> PropertyValidator.getInstance().assertNone(property, target.getProperties())); for (final VAlarm alarm : target.getAlarms()) { alarm.validate(Method.ADD); } } }
final Dur dur = alarm.getTrigger().getDuration(); if (alarm.getAction() == null || dur == null) { return false; if (Action.AUDIO.equals(alarm.getAction())) { event.setReminderActionType(ReminderActionType.MESSAGE_SOUND); } else {
/** * Find and return the first DISPLAY VALARM in a comoponent * @param component VEVENT or VTODO * @return first DISPLAY VALARM, null if there is none */ public static VAlarm getDisplayAlarm(Component component) { ComponentList<VAlarm> alarms = null; if(component instanceof VEvent) { alarms = ((VEvent) component).getAlarms(); } else if(component instanceof VToDo) { alarms = ((VToDo) component).getAlarms(); } if(alarms==null || alarms.size()==0) { return null; } for(Iterator<VAlarm> it = alarms.iterator();it.hasNext();) { VAlarm alarm = it.next(); if(Action.DISPLAY.equals(alarm.getAction())) { return alarm; } } return null; } }
Trigger trigger = alarm.getTrigger(); if(trigger==null) { continue;
Trigger trigger = alarm.getTrigger(); if(trigger==null) { return dates; Duration dur = alarm.getDuration(); if(dur==null) { return dates; Repeat repeat = alarm.getRepeat(); if(repeat==null) { return dates;
PropertyValidator.getInstance().assertOne(Property.ACTION, getProperties()); PropertyValidator.getInstance().assertOne(Property.TRIGGER, getProperties()); PropertyValidator.getInstance().assertOneOrLess(Property.DURATION, getProperties()); PropertyValidator.getInstance().assertOneOrLess(Property.REPEAT, getProperties()); PropertyValidator.getInstance().assertNone(Property.DURATION, getProperties()); PropertyValidator.getInstance().assertNone(Property.REPEAT, getProperties()); PropertyValidator.getInstance().assertOne(Property.DURATION, getProperties()); PropertyValidator.getInstance().assertOne(Property.REPEAT, getProperties()); final Validator actionValidator = (Validator) actionValidators.get(getAction()); if (actionValidator != null) { actionValidator.validate(); validateProperties();
public void creatDisplayAlarm() { VAlarm alarm = new VAlarm(); alarm.getProperties().add(Action.DISPLAY); getEvent().getAlarms().add(alarm); setDisplayAlarmDescription("Event Reminder"); } }
/** * {@inheritDoc} */ public void validate(VAlarm target) throws ValidationException { /* * ; the following are all REQUIRED, ; but MUST NOT occur more than once action / description / trigger / */ PropertyValidator.getInstance().assertOne(DESCRIPTION, target.getProperties()); } }
public void validate(final VEvent target) throws ValidationException { Arrays.asList(DTSTAMP, DTSTART, ORGANIZER, SEQUENCE, SUMMARY, UID).forEach(property -> PropertyValidator.getInstance().assertOne(property, target.getProperties())); Arrays.asList(CATEGORIES, CLASS, CREATED, DESCRIPTION, DTEND, DURATION, GEO, LAST_MODIFIED, LOCATION, PRIORITY, RESOURCES, STATUS, TRANSP, URL).forEach(property -> PropertyValidator.getInstance().assertOneOrLess(property, target.getProperties())); Arrays.asList(RECURRENCE_ID, REQUEST_STATUS).forEach(property -> PropertyValidator.getInstance().assertNone(property, target.getProperties())); for (final VAlarm alarm : target.getAlarms()) { alarm.validate(Method.ADD); } } }
VAlarm a = (VAlarm) alarm; if (a.getAction() != Action.AUDIO && a.getAction() != Action.DISPLAY) continue; // Ignore email and procedure alarms Trigger t = a.getTrigger(); final long startMs = e.getStartDate().getDate().getTime(); long alarmStartMs = startMs;
/** * Find and return the first DISPLAY VALARM in a comoponent * @param component VEVENT or VTODO * @return first DISPLAY VALARM, null if there is none */ public static VAlarm getDisplayAlarm(Component component) { ComponentList<VAlarm> alarms = null; if(component instanceof VEvent) { alarms = ((VEvent) component).getAlarms(); } else if(component instanceof VToDo) { alarms = ((VToDo) component).getAlarms(); } if(alarms==null || alarms.size()==0) { return null; } for(Iterator<VAlarm> it = alarms.iterator();it.hasNext();) { VAlarm alarm = it.next(); if(Action.DISPLAY.equals(alarm.getAction())) { return alarm; } } return null; } }
Trigger trigger = alarm.getTrigger(); if(trigger==null) { continue;
Trigger trigger = alarm.getTrigger(); if(trigger==null) { return dates; Duration dur = alarm.getDuration(); if(dur==null) { return dates; Repeat repeat = alarm.getRepeat(); if(repeat==null) { return dates;