use of net.fortuna.ical4j.model.property.Attendee in project camel by apache.
the class ICalDataFormatTest method createTestCalendar.
/**
* Creates test calendar instance.
*
* @return ICal calendar object.
*/
protected Calendar createTestCalendar() throws ParseException {
// Create a TimeZone
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
TimeZone timezone = registry.getTimeZone("America/New_York");
VTimeZone tz = timezone.getVTimeZone();
// Start Date is on: April 1, 2013, 9:00 am
java.util.Calendar startDate = new GregorianCalendar();
startDate.setTimeZone(timezone);
startDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
startDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
startDate.set(java.util.Calendar.YEAR, 2013);
startDate.set(java.util.Calendar.HOUR_OF_DAY, 17);
startDate.set(java.util.Calendar.MINUTE, 0);
startDate.set(java.util.Calendar.SECOND, 0);
// End Date is on: April 1, 2013, 13:00
java.util.Calendar endDate = new GregorianCalendar();
endDate.setTimeZone(timezone);
endDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
endDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
endDate.set(java.util.Calendar.YEAR, 2013);
endDate.set(java.util.Calendar.HOUR_OF_DAY, 21);
endDate.set(java.util.Calendar.MINUTE, 0);
endDate.set(java.util.Calendar.SECOND, 0);
// Create the event
PropertyList propertyList = new PropertyList();
propertyList.add(new DtStamp("20130324T180000Z"));
propertyList.add(new DtStart(new DateTime(startDate.getTime())));
propertyList.add(new DtEnd(new DateTime(endDate.getTime())));
propertyList.add(new Summary("Progress Meeting"));
VEvent meeting = new VEvent(propertyList);
// add timezone info..
meeting.getProperties().add(tz.getTimeZoneId());
// generate unique identifier..
meeting.getProperties().add(new Uid("00000000"));
// add attendees..
Attendee dev1 = new Attendee(URI.create("mailto:dev1@mycompany.com"));
dev1.getParameters().add(Role.REQ_PARTICIPANT);
dev1.getParameters().add(new Cn("Developer 1"));
meeting.getProperties().add(dev1);
Attendee dev2 = new Attendee(URI.create("mailto:dev2@mycompany.com"));
dev2.getParameters().add(Role.OPT_PARTICIPANT);
dev2.getParameters().add(new Cn("Developer 2"));
meeting.getProperties().add(dev2);
// Create a calendar
net.fortuna.ical4j.model.Calendar icsCalendar = new net.fortuna.ical4j.model.Calendar();
icsCalendar.getProperties().add(Version.VERSION_2_0);
icsCalendar.getProperties().add(new ProdId("-//Events Calendar//iCal4j 1.0//EN"));
icsCalendar.getProperties().add(CalScale.GREGORIAN);
// Add the event and print
icsCalendar.getComponents().add(meeting);
return icsCalendar;
}
use of net.fortuna.ical4j.model.property.Attendee in project wildfly-camel by wildfly-extras.
the class ICalFormatTest method createTestCalendar.
private Calendar createTestCalendar() throws ParseException {
// Create a TimeZone
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
TimeZone timezone = registry.getTimeZone("America/New_York");
VTimeZone tz = timezone.getVTimeZone();
// Start Date is on: April 1, 2013, 9:00 am
java.util.Calendar startDate = new GregorianCalendar();
startDate.setTimeZone(timezone);
startDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
startDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
startDate.set(java.util.Calendar.YEAR, 2013);
startDate.set(java.util.Calendar.HOUR_OF_DAY, 17);
startDate.set(java.util.Calendar.MINUTE, 0);
startDate.set(java.util.Calendar.SECOND, 0);
// End Date is on: April 1, 2013, 13:00
java.util.Calendar endDate = new GregorianCalendar();
endDate.setTimeZone(timezone);
endDate.set(java.util.Calendar.MONTH, java.util.Calendar.APRIL);
endDate.set(java.util.Calendar.DAY_OF_MONTH, 1);
endDate.set(java.util.Calendar.YEAR, 2013);
endDate.set(java.util.Calendar.HOUR_OF_DAY, 21);
endDate.set(java.util.Calendar.MINUTE, 0);
endDate.set(java.util.Calendar.SECOND, 0);
// Create the event
PropertyList propertyList = new PropertyList();
propertyList.add(new DtStamp("20130324T180000Z"));
propertyList.add(new DtStart(new DateTime(startDate.getTime())));
propertyList.add(new DtEnd(new DateTime(endDate.getTime())));
propertyList.add(new Summary("Progress Meeting"));
VEvent meeting = new VEvent(propertyList);
// add timezone info..
meeting.getProperties().add(tz.getTimeZoneId());
// generate unique identifier..
meeting.getProperties().add(new Uid("00000000"));
// add attendees..
Attendee dev1 = new Attendee(URI.create("mailto:dev1@mycompany.com"));
dev1.getParameters().add(Role.REQ_PARTICIPANT);
dev1.getParameters().add(new Cn("Developer 1"));
meeting.getProperties().add(dev1);
Attendee dev2 = new Attendee(URI.create("mailto:dev2@mycompany.com"));
dev2.getParameters().add(Role.OPT_PARTICIPANT);
dev2.getParameters().add(new Cn("Developer 2"));
meeting.getProperties().add(dev2);
// Create a calendar
net.fortuna.ical4j.model.Calendar icsCalendar = new net.fortuna.ical4j.model.Calendar();
icsCalendar.getProperties().add(Version.VERSION_2_0);
icsCalendar.getProperties().add(new ProdId("-//Events Calendar//iCal4j 1.0//EN"));
icsCalendar.getProperties().add(CalScale.GREGORIAN);
// Add the event and print
icsCalendar.getComponents().add(meeting);
return icsCalendar;
}
use of net.fortuna.ical4j.model.property.Attendee in project openmeetings by apache.
the class IcalUtils method addVEventpropsfromAppointment.
/**
* Adds the Appointment Properties to the given VEvent
*
* @param appointment Appointment whose properties are taken
* @param meeting VEvent of the Appointment
* @return Updated VEvent
*/
private static VEvent addVEventpropsfromAppointment(Appointment appointment, VEvent meeting) {
if (appointment.getLocation() != null) {
meeting.getProperties().add(new Location(appointment.getLocation()));
}
meeting.getProperties().add(new Description(appointment.getDescription()));
meeting.getProperties().add(new Sequence(0));
meeting.getProperties().add(Transp.OPAQUE);
String uid = appointment.getIcalId();
Uid ui;
if (uid == null || uid.length() < 1) {
UUID uuid = UUID.randomUUID();
appointment.setIcalId(uuid.toString());
ui = new Uid(uuid.toString());
} else {
ui = new Uid(uid);
}
meeting.getProperties().add(ui);
if (appointment.getMeetingMembers() != null) {
for (MeetingMember meetingMember : appointment.getMeetingMembers()) {
Attendee attendee = new Attendee(URI.create("mailto:" + meetingMember.getUser().getAddress().getEmail()));
attendee.getParameters().add(Role.REQ_PARTICIPANT);
attendee.getParameters().add(new Cn(meetingMember.getUser().getLogin()));
meeting.getProperties().add(attendee);
}
}
URI orgUri = URI.create("mailto:" + appointment.getOwner().getAddress().getEmail());
Attendee orgAtt = new Attendee(orgUri);
orgAtt.getParameters().add(Role.CHAIR);
Cn orgCn = new Cn(appointment.getOwner().getLogin());
orgAtt.getParameters().add(orgCn);
meeting.getProperties().add(orgAtt);
Organizer organizer = new Organizer(orgUri);
organizer.getParameters().add(orgCn);
meeting.getProperties().add(organizer);
return meeting;
}
use of net.fortuna.ical4j.model.property.Attendee in project openmeetings by apache.
the class IcalUtils method addVEventPropertiestoAppointment.
/**
* Add properties from the Given VEvent Component to the Appointment
*
* @param a Appointment to which the properties are to be added
* @param event VEvent to parse properties from.
* @return Updated Appointment
*/
private Appointment addVEventPropertiestoAppointment(Appointment a, CalendarComponent event) {
DateProperty dtstart = (DateProperty) event.getProperty(Property.DTSTART), dtend = (DateProperty) event.getProperty(Property.DTEND), dtstamp = (DateProperty) event.getProperty(Property.DTSTAMP), lastmod = (DateProperty) event.getProperty(Property.LAST_MODIFIED);
Property uid = event.getProperty(Property.UID), description = event.getProperty(Property.DESCRIPTION), summary = event.getProperty(Property.SUMMARY), location = event.getProperty(Property.LOCATION), organizer = event.getProperty(Property.ORGANIZER), recur = event.getProperty(Property.RRULE);
PropertyList<Attendee> attendees = event.getProperties(Property.ATTENDEE);
if (uid != null) {
a.setIcalId(uid.getValue());
}
Date d = dtstart.getDate();
a.setStart(d);
if (dtend == null) {
a.setEnd(addTimetoDate(d, java.util.Calendar.HOUR_OF_DAY, 1));
} else {
a.setEnd(dtend.getDate());
}
a.setInserted(dtstamp.getDate());
if (lastmod != null) {
a.setUpdated(lastmod.getDate());
}
if (description != null) {
a.setDescription(description.getValue());
}
if (summary != null) {
a.setTitle(summary.getValue());
}
if (location != null) {
a.setLocation(location.getValue());
}
if (recur != null) {
Parameter freq = recur.getParameter("FREQ");
if (freq != null) {
if (freq.getValue().equals(Recur.DAILY)) {
a.setIsDaily(true);
} else if (freq.getValue().equals(Recur.WEEKLY)) {
a.setIsWeekly(true);
} else if (freq.getValue().equals(Recur.MONTHLY)) {
a.setIsMonthly(true);
} else if (freq.getValue().equals(Recur.YEARLY)) {
a.setIsYearly(true);
}
}
}
List<MeetingMember> attList = a.getMeetingMembers() == null ? new ArrayList<>() : a.getMeetingMembers();
// Note this value can be repeated in attendees as well.
if (organizer != null) {
URI uri = URI.create(organizer.getValue());
// If the value of the organizer is an email
if ("mailto".equals(uri.getScheme())) {
String email = uri.getSchemeSpecificPart();
// Contact or exist and owner
User org = userDao.getByEmail(email);
if (org == null) {
org = userDao.getContact(email, a.getOwner());
attList.add(createMeetingMember(a, org));
} else if (!org.getId().equals(a.getOwner().getId())) {
attList.add(createMeetingMember(a, org));
}
}
}
if (attendees != null && !attendees.isEmpty()) {
for (Property attendee : attendees) {
URI uri = URI.create(attendee.getValue());
if ("mailto".equals(uri.getScheme())) {
String email = uri.getSchemeSpecificPart();
User u = userDao.getByEmail(email);
if (u == null) {
u = userDao.getContact(email, a.getOwner());
}
attList.add(createMeetingMember(a, u));
}
}
}
a.setMeetingMembers(attList.isEmpty() ? null : attList);
return a;
}
use of net.fortuna.ical4j.model.property.Attendee 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();
}
Aggregations