Java Code Examples for net.fortuna.ical4j.model.property.DtStart#getDate()

The following examples show how to use net.fortuna.ical4j.model.property.DtStart#getDate() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EventValidator.java    From cosmo with Apache License 2.0 6 votes vote down vote up
private static boolean isEventValid(VEvent event, ValidationConfig config) {
    if (config == null) {
        LOG.error("ValidationConfig cannot be null");
        return false;
    }
    DtStart startDate = event.getStartDate();
    DtEnd endDate = event.getEndDate(true);
    if (startDate == null || startDate.getDate() == null
            || endDate != null && startDate.getDate().after(endDate.getDate())) {

        return false;
    }

    for (PropertyValidator validator : values()) {
        if (!validator.isValid(event, config)) {
            return false;
        }
    }

    return areTimeZoneIdsValid(event);
}
 
Example 2
Source File: ICalConverter.java    From scipio-erp with Apache License 2.0 5 votes vote down vote up
protected static Timestamp fromDtStart(PropertyList<Property> propertyList) {
    DtStart iCalObj = (DtStart) propertyList.getProperty(DtStart.DTSTART);
    if (iCalObj == null) {
        return null;
    }
    Date date = iCalObj.getDate();
    return new Timestamp(date.getTime());
}
 
Example 3
Source File: HibBaseEventStamp.java    From cosmo with Apache License 2.0 5 votes vote down vote up
public Date getStartDate() {
    VEvent event = getEvent();
    if(event==null) {
        return null;
    }
    
    DtStart dtStart = event.getStartDate();
    if (dtStart == null) {
        return null;
    }
    return dtStart.getDate();
}
 
Example 4
Source File: MockBaseEventStamp.java    From cosmo with Apache License 2.0 5 votes vote down vote up
/**
 * Gets start date.
 * @return date.
 */
public Date getStartDate() {
    VEvent event = getEvent();
    if (event==null) {
        return null;
    }
    
    DtStart dtStart = event.getStartDate();
    if (dtStart == null) {
        return null;
    }
    return dtStart.getDate();
}
 
Example 5
Source File: RecurrenceExpander.java    From cosmo with Apache License 2.0 4 votes vote down vote up
/**
 * Gets start date.
 * @param comp The component.
 * @return The date.
 */
private Date getStartDate(Component comp) {
    DtStart prop = (DtStart) comp.getProperties().getProperty(
            Property.DTSTART);
    return (prop != null) ? prop.getDate() : null;
}
 
Example 6
Source File: ICalendarService.java    From axelor-open-suite with GNU Affero General Public License v3.0 4 votes vote down vote up
@Transactional
protected ICalendarEvent findOrCreateEvent(VEvent vEvent, ICalendar calendar) {

  String uid = vEvent.getUid().getValue();
  DtStart dtStart = vEvent.getStartDate();
  DtEnd dtEnd = vEvent.getEndDate();

  ICalendarEvent event = iEventRepo.findByUid(uid);
  if (event == null) {
    event = ICalendarEventFactory.getNewIcalEvent(calendar);
    event.setUid(uid);
    event.setCalendar(calendar);
  }

  ZoneId zoneId = OffsetDateTime.now().getOffset();
  if (dtStart.getDate() != null) {
    if (dtStart.getTimeZone() != null) {
      zoneId = dtStart.getTimeZone().toZoneId();
    }
    event.setStartDateTime(LocalDateTime.ofInstant(dtStart.getDate().toInstant(), zoneId));
  }

  if (dtEnd.getDate() != null) {
    if (dtEnd.getTimeZone() != null) {
      zoneId = dtEnd.getTimeZone().toZoneId();
    }
    event.setEndDateTime(LocalDateTime.ofInstant(dtEnd.getDate().toInstant(), zoneId));
  }

  event.setAllDay(!(dtStart.getDate() instanceof DateTime));

  event.setSubject(getValue(vEvent, Property.SUMMARY));
  event.setDescription(getValue(vEvent, Property.DESCRIPTION));
  event.setLocation(getValue(vEvent, Property.LOCATION));
  event.setGeo(getValue(vEvent, Property.GEO));
  event.setUrl(getValue(vEvent, Property.URL));
  event.setSubjectTeam(event.getSubject());
  if (Clazz.PRIVATE.getValue().equals(getValue(vEvent, Property.CLASS))) {
    event.setVisibilitySelect(ICalendarEventRepository.VISIBILITY_PRIVATE);
  } else {
    event.setVisibilitySelect(ICalendarEventRepository.VISIBILITY_PUBLIC);
  }
  if (Transp.TRANSPARENT.getValue().equals(getValue(vEvent, Property.TRANSP))) {
    event.setDisponibilitySelect(ICalendarEventRepository.DISPONIBILITY_AVAILABLE);
  } else {
    event.setDisponibilitySelect(ICalendarEventRepository.DISPONIBILITY_BUSY);
  }
  if (event.getVisibilitySelect() == ICalendarEventRepository.VISIBILITY_PRIVATE) {
    event.setSubjectTeam(I18n.get("Available"));
    if (event.getDisponibilitySelect() == ICalendarEventRepository.DISPONIBILITY_BUSY) {
      event.setSubjectTeam(I18n.get("Busy"));
    }
  }
  ICalendarUser organizer = findOrCreateUser(vEvent.getOrganizer(), event);
  if (organizer != null) {
    event.setOrganizer(organizer);
    iCalendarUserRepository.save(organizer);
  }

  for (Object item : vEvent.getProperties(Property.ATTENDEE)) {
    ICalendarUser attendee = findOrCreateUser((Property) item, event);
    if (attendee != null) {
      event.addAttendee(attendee);
      iCalendarUserRepository.save(attendee);
    }
  }
  iEventRepo.save(event);
  return event;
}
 
Example 7
Source File: InstanceList.java    From cosmo with Apache License 2.0 2 votes vote down vote up
/**
 * Gets start date.
 *
 * @param comp The component.
 * @return The date.
 */
private Date getStartDate(Component comp) {
    DtStart prop = (DtStart) comp.getProperties().getProperty(
            Property.DTSTART);
    return (prop != null) ? prop.getDate() : null;
}