net.fortuna.ical4j.model.property.Summary Java Examples
The following examples show how to use
net.fortuna.ical4j.model.property.Summary.
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: FreeBusyUtil.java From cosmo with Apache License 2.0 | 6 votes |
private static VEvent getFreeBusyEvent(VEvent vEvent, String freeBusyText) { try { VEvent freeBusyEvent = new VEvent(); freeBusyEvent.getProperties().add(new Summary(freeBusyText)); for (String propertyName : FREE_BUSY_ALLOWED_PROPERTIES) { Property property = vEvent.getProperty(propertyName); if (property != null) { freeBusyEvent.getProperties().add(property); } } return freeBusyEvent; } catch (Exception e) { throw new RuntimeException(e); } }
Example #2
Source File: Util.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
public static Calendar createCalendar(CalDavEvent calDavEvent, DateTimeZone timeZone) { TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); TimeZone timezone = registry.getTimeZone(timeZone.getID()); Calendar calendar = new Calendar(); calendar.getProperties().add(Version.VERSION_2_0); calendar.getProperties().add(new ProdId("openHAB")); VEvent vEvent = new VEvent(); vEvent.getProperties().add(new Summary(calDavEvent.getName())); vEvent.getProperties().add(new Description(calDavEvent.getContent())); final DtStart dtStart = new DtStart(new net.fortuna.ical4j.model.DateTime(calDavEvent.getStart().toDate())); dtStart.setTimeZone(timezone); vEvent.getProperties().add(dtStart); final DtEnd dtEnd = new DtEnd(new net.fortuna.ical4j.model.DateTime(calDavEvent.getEnd().toDate())); dtEnd.setTimeZone(timezone); vEvent.getProperties().add(dtEnd); vEvent.getProperties().add(new Uid(calDavEvent.getId())); vEvent.getProperties().add(Clazz.PUBLIC); vEvent.getProperties() .add(new LastModified(new net.fortuna.ical4j.model.DateTime(calDavEvent.getLastChanged().toDate()))); calendar.getComponents().add(vEvent); return calendar; }
Example #3
Source File: ICalUtils.java From camel-quarkus with Apache License 2.0 | 5 votes |
protected static Calendar createTestCalendar(ZonedDateTime start, ZonedDateTime end, String summary, String attendee) { // Create a TimeZone TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry(); String tzId = start.getZone().getId(); TimeZone timezone = registry.getTimeZone(tzId.equals("Z") ? "UTC" : tzId); VTimeZone tz = timezone.getVTimeZone(); // Create the event PropertyList propertyList = new PropertyList(); DateTime ts = new DateTime(true); ts.setTime(0); propertyList.add(new DtStamp(ts)); propertyList.add(new DtStart(toDateTime(start, registry))); propertyList.add(new DtEnd(toDateTime(end, registry))); propertyList.add(new Summary(summary)); 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:" + attendee)); dev1.getParameters().add(Role.REQ_PARTICIPANT); dev1.getParameters().add(new Cn(attendee)); meeting.getProperties().add(dev1); // 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; }
Example #4
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 5 votes |
protected static String fromSummary(PropertyList<Property> propertyList) { Summary iCalObj = (Summary) propertyList.getProperty(Summary.SUMMARY); if (iCalObj == null) { return null; } return iCalObj.getValue(); }
Example #5
Source File: ICalFormatTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
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:[email protected]")); dev1.getParameters().add(Role.REQ_PARTICIPANT); dev1.getParameters().add(new Cn("Developer 1")); meeting.getProperties().add(dev1); Attendee dev2 = new Attendee(URI.create("mailto:[email protected]")); 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; }
Example #6
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 4 votes |
protected static Summary toSummary(String javaObj) { if (javaObj == null) { return null; } return new Summary(javaObj); }
Example #7
Source File: IcsFileImporter.java From ganttproject with GNU General Public License v3.0 | 4 votes |
/** * Reads calendar events from file * @return a list of events if file was parsed successfully or null otherwise */ private static List<CalendarEvent> readEvents(File f) { try { CompatibilityHints.setHintEnabled(CompatibilityHints.KEY_RELAXED_PARSING, true); CalendarBuilder builder = new CalendarBuilder(); List<CalendarEvent> gpEvents = Lists.newArrayList(); Calendar c = builder.build(new UnfoldingReader(new FileReader(f))); for (Component comp : (List<Component>)c.getComponents()) { if (comp instanceof VEvent) { VEvent event = (VEvent) comp; if (event.getStartDate() == null) { GPLogger.log("No start date found, ignoring. Event="+event); continue; } Date eventStartDate = event.getStartDate().getDate(); if (event.getEndDate() == null) { GPLogger.log("No end date found, using start date instead. Event="+event); } Date eventEndDate = event.getEndDate() == null ? eventStartDate : event.getEndDate().getDate(); TimeDuration oneDay = GPTimeUnitStack.createLength(GPTimeUnitStack.DAY, 1); if (eventEndDate != null) { java.util.Date startDate = GPTimeUnitStack.DAY.adjustLeft(eventStartDate); java.util.Date endDate = GPTimeUnitStack.DAY.adjustLeft(eventEndDate); RRule recurrenceRule = (RRule) event.getProperty(Property.RRULE); boolean recursYearly = false; if (recurrenceRule != null) { recursYearly = Recur.YEARLY.equals(recurrenceRule.getRecur().getFrequency()) && 1 == recurrenceRule.getRecur().getInterval(); } while (startDate.compareTo(endDate) <= 0) { Summary summary = event.getSummary(); gpEvents.add(CalendarEvent.newEvent( startDate, recursYearly, CalendarEvent.Type.HOLIDAY, summary == null ? "" : summary.getValue(), null)); startDate = GPCalendarCalc.PLAIN.shiftDate(startDate, oneDay); } } } } return gpEvents; } catch (IOException | ParserException e) { GPLogger.log(e); return null; } }