use of net.fortuna.ical4j.model.DateTime in project openmeetings by apache.
the class IcalUtils method parseAppointmenttoCalendar.
/**
* Methods to parse Appointment to iCalendar according RFC 2445
*
* @param appointment to be converted to iCalendar
* @return iCalendar representation of the Appointment
*/
public Calendar parseAppointmenttoCalendar(Appointment appointment) {
String tzid = parseTimeZone(null, appointment.getOwner()).getID();
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
net.fortuna.ical4j.model.TimeZone timeZone = registry.getTimeZone(tzid);
if (timeZone == null) {
throw new NoSuchElementException("Unable to get time zone by id provided: " + tzid);
}
Calendar icsCalendar = new Calendar();
icsCalendar.getProperties().add(new ProdId("-//Events Calendar//Apache Openmeetings//EN"));
icsCalendar.getProperties().add(Version.VERSION_2_0);
icsCalendar.getProperties().add(CalScale.GREGORIAN);
icsCalendar.getComponents().add(timeZone.getVTimeZone());
DateTime start = new DateTime(appointment.getStart()), end = new DateTime(appointment.getEnd());
VEvent meeting = new VEvent(start, end, appointment.getTitle());
meeting = addVEventpropsfromAppointment(appointment, meeting);
icsCalendar.getComponents().add(meeting);
return icsCalendar;
}
use of net.fortuna.ical4j.model.DateTime in project openmeetings by apache.
the class IcalHandler method addNewMeeting.
/**
* @param startDate
* use standard TimeZone!!
* @param endDate
* use standard time zone!!
* @param name
* meeting name
* @param attendees
* List of attendees (use getAttendeeData to retrieve valid records)
* @param description
* containing the meeting description
* @param organizer
* organizer
* @param uid
* (maybe null)
* @param javaTzId ID of owner's java time zone
* @return UID of Meeting
*/
// ---------------------------------------------------------------------------------------
public String addNewMeeting(Date startDate, Date endDate, String name, List<Map<String, String>> attendees, String description, Map<String, String> organizer, String uid, String javaTzId) {
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
TimeZone timeZone = registry.getTimeZone(javaTzId);
if (timeZone == null) {
throw new NoSuchElementException("Unable to get time zone by id provided: " + javaTzId);
}
DateTime start = new DateTime(startDate);
start.setTimeZone(timeZone);
DateTime end = new DateTime(endDate);
end.setTimeZone(timeZone);
VEvent meeting = new VEvent(start, end, name);
meeting.getProperties().add(new Description(description));
meeting.getProperties().add(new Sequence(0));
meeting.getProperties().add(new Location(""));
meeting.getProperties().add(Transp.OPAQUE);
// generate unique identifier (if not submitted)
Uid ui;
if (Strings.isEmpty(uid)) {
ui = new Uid(UUID.randomUUID().toString());
log.debug("Generating Meeting UID : " + ui.getValue());
} else {
ui = new Uid(uid);
log.debug("Using Meeting UID : " + ui.getValue());
}
meeting.getProperties().add(ui);
for (Map<String, String> att : attendees) {
Attendee uno = new Attendee(URI.create(att.get("uri")));
String chair = att.get("chair");
uno.getParameters().add("0".equals(chair) ? Role.REQ_PARTICIPANT : Role.CHAIR);
uno.getParameters().add(new Cn(att.get("cn")));
meeting.getProperties().add(uno);
}
Organizer orger = new Organizer(URI.create(organizer.get("uri")));
orger.getParameters().add(new Cn(organizer.get("cn")));
meeting.getProperties().add(orger);
icsCalendar.getComponents().add(timeZone.getVTimeZone());
icsCalendar.getComponents().add(meeting);
return ui.getValue();
}
use of net.fortuna.ical4j.model.DateTime in project bw-calendar-engine by Bedework.
the class BwEvent method updateStag.
/**
* Set the stag for this event.
* @param val
*/
@NoProxy
public void updateStag(final Timestamp val) {
DateTime dt = new DateTime(val);
// dt.setUtc(true);
setStag(new LastModified(dt).getValue() + "-" + hex4FromNanos(val.getNanos()));
}
use of net.fortuna.ical4j.model.DateTime in project bw-calendar-engine by Bedework.
the class BwEvent method setDtstamps.
/**
* Set the dtstamp, lastmod and created if created is not set already.
* @param val
*/
@NoProxy
public void setDtstamps(final Timestamp val) {
DateTime dt = new DateTime(val);
setDtstamp(new DtStamp(dt).getValue());
setLastmod(new LastModified(dt).getValue());
setCtoken(getLastmod() + "-" + hex4FromNanos(val.getNanos()));
if (getCreated() == null) {
setCreated(new Created(dt).getValue());
}
}
use of net.fortuna.ical4j.model.DateTime in project bw-calendar-engine by Bedework.
the class BwDateTime method addDuration.
private BwDateTime addDuration(final Dur val) throws CalFacadeException {
DtEnd dtEnd;
java.util.Date endDt = val.getTime(makeDate());
DtStart dtStart = makeDtStart(Timezones.getTzRegistry());
if (getDateType()) {
dtEnd = new DtEnd(new Date(endDt));
addIcalParameter(dtEnd, Value.DATE);
} else {
DateTime d = new DateTime(endDt);
Parameter tzid = getIcalParameter(dtStart, "TZID");
if (tzid != null) {
DateTime sd = (DateTime) dtStart.getDate();
d.setTimeZone(sd.getTimeZone());
}
// dtEnd = new DtEnd(d, dtStart.isUtc());
dtEnd = new DtEnd(d);
if (tzid != null) {
addIcalParameter(dtEnd, tzid);
} else if (dtStart.isUtc()) {
dtEnd.setUtc(true);
}
}
return makeBwDateTime(dtEnd);
}
Aggregations