Search in sources :

Example 1 with Attendee

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;
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) VTimeZone(net.fortuna.ical4j.model.component.VTimeZone) GregorianCalendar(java.util.GregorianCalendar) Calendar(net.fortuna.ical4j.model.Calendar) TimeZoneRegistry(net.fortuna.ical4j.model.TimeZoneRegistry) GregorianCalendar(java.util.GregorianCalendar) Cn(net.fortuna.ical4j.model.parameter.Cn) ProdId(net.fortuna.ical4j.model.property.ProdId) Calendar(net.fortuna.ical4j.model.Calendar) DateTime(net.fortuna.ical4j.model.DateTime) Attendee(net.fortuna.ical4j.model.property.Attendee) Uid(net.fortuna.ical4j.model.property.Uid) VTimeZone(net.fortuna.ical4j.model.component.VTimeZone) TimeZone(net.fortuna.ical4j.model.TimeZone) DtStamp(net.fortuna.ical4j.model.property.DtStamp) PropertyList(net.fortuna.ical4j.model.PropertyList) DtStart(net.fortuna.ical4j.model.property.DtStart) Summary(net.fortuna.ical4j.model.property.Summary) DtEnd(net.fortuna.ical4j.model.property.DtEnd)

Example 2 with Attendee

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;
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) VTimeZone(net.fortuna.ical4j.model.component.VTimeZone) GregorianCalendar(java.util.GregorianCalendar) Calendar(net.fortuna.ical4j.model.Calendar) TimeZoneRegistry(net.fortuna.ical4j.model.TimeZoneRegistry) GregorianCalendar(java.util.GregorianCalendar) Cn(net.fortuna.ical4j.model.parameter.Cn) ProdId(net.fortuna.ical4j.model.property.ProdId) Calendar(net.fortuna.ical4j.model.Calendar) DateTime(net.fortuna.ical4j.model.DateTime) Attendee(net.fortuna.ical4j.model.property.Attendee) Uid(net.fortuna.ical4j.model.property.Uid) VTimeZone(net.fortuna.ical4j.model.component.VTimeZone) TimeZone(net.fortuna.ical4j.model.TimeZone) DtStamp(net.fortuna.ical4j.model.property.DtStamp) PropertyList(net.fortuna.ical4j.model.PropertyList) DtStart(net.fortuna.ical4j.model.property.DtStart) Summary(net.fortuna.ical4j.model.property.Summary) DtEnd(net.fortuna.ical4j.model.property.DtEnd)

Example 3 with Attendee

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;
}
Also used : Uid(net.fortuna.ical4j.model.property.Uid) Description(net.fortuna.ical4j.model.property.Description) Organizer(net.fortuna.ical4j.model.property.Organizer) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) Sequence(net.fortuna.ical4j.model.property.Sequence) Cn(net.fortuna.ical4j.model.parameter.Cn) UUID(java.util.UUID) URI(java.net.URI) Attendee(net.fortuna.ical4j.model.property.Attendee) Location(net.fortuna.ical4j.model.property.Location)

Example 4 with Attendee

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;
}
Also used : User(org.apache.openmeetings.db.entity.user.User) DateProperty(net.fortuna.ical4j.model.property.DateProperty) MeetingMember(org.apache.openmeetings.db.entity.calendar.MeetingMember) Parameter(net.fortuna.ical4j.model.Parameter) Property(net.fortuna.ical4j.model.Property) DateProperty(net.fortuna.ical4j.model.property.DateProperty) URI(java.net.URI) Attendee(net.fortuna.ical4j.model.property.Attendee) Date(java.util.Date)

Example 5 with Attendee

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();
}
Also used : VEvent(net.fortuna.ical4j.model.component.VEvent) Description(net.fortuna.ical4j.model.property.Description) Organizer(net.fortuna.ical4j.model.property.Organizer) TimeZoneRegistry(net.fortuna.ical4j.model.TimeZoneRegistry) Sequence(net.fortuna.ical4j.model.property.Sequence) Cn(net.fortuna.ical4j.model.parameter.Cn) DateTime(net.fortuna.ical4j.model.DateTime) Attendee(net.fortuna.ical4j.model.property.Attendee) Uid(net.fortuna.ical4j.model.property.Uid) TimeZone(net.fortuna.ical4j.model.TimeZone) NoSuchElementException(java.util.NoSuchElementException) Location(net.fortuna.ical4j.model.property.Location)

Aggregations

Attendee (net.fortuna.ical4j.model.property.Attendee)14 Cn (net.fortuna.ical4j.model.parameter.Cn)7 PropertyList (net.fortuna.ical4j.model.PropertyList)6 VEvent (net.fortuna.ical4j.model.component.VEvent)6 Uid (net.fortuna.ical4j.model.property.Uid)5 DateTime (net.fortuna.ical4j.model.DateTime)4 Property (net.fortuna.ical4j.model.Property)4 TimeZone (net.fortuna.ical4j.model.TimeZone)4 TimeZoneRegistry (net.fortuna.ical4j.model.TimeZoneRegistry)4 XProperty (net.fortuna.ical4j.model.property.XProperty)4 GregorianCalendar (java.util.GregorianCalendar)3 Parameter (net.fortuna.ical4j.model.Parameter)3 VTimeZone (net.fortuna.ical4j.model.component.VTimeZone)3 Description (net.fortuna.ical4j.model.property.Description)3 DtEnd (net.fortuna.ical4j.model.property.DtEnd)3 Organizer (net.fortuna.ical4j.model.property.Organizer)3 URI (java.net.URI)2 Iterator (java.util.Iterator)2 Calendar (net.fortuna.ical4j.model.Calendar)2 VAlarm (net.fortuna.ical4j.model.component.VAlarm)2