net.fortuna.ical4j.model.PropertyList Java Examples
The following examples show how to use
net.fortuna.ical4j.model.PropertyList.
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: EventReloaderJob.java From openhab1-addons with Eclipse Public License 2.0 | 6 votes |
/** * Returns a list of categories or an empty list if none found. * * @param vEvent * @return */ private List<String> readCategory(VEvent vEvent) { PropertyList<Property> propertyCategoryList = vEvent.getProperties(Property.CATEGORIES); ArrayList<String> splittedCategoriesToReturn = new ArrayList<String>(); if (propertyCategoryList != null) { for (int categoriesLineNum = 0; categoriesLineNum < propertyCategoryList.size(); categoriesLineNum++) { Property propertyCategory = propertyCategoryList.get(categoriesLineNum); String categories = propertyCategory.getValue(); if (categories != null) { String[] categoriesSplit = StringUtils.split(categories, ","); for (String category : categoriesSplit) { if (!splittedCategoriesToReturn.contains(category)) { splittedCategoriesToReturn.add(category); } } } } } return splittedCategoriesToReturn; }
Example #2
Source File: OutputFilter.java From cosmo with Apache License 2.0 | 6 votes |
private void filterProperties(PropertyList<Property> properties, StringBuilder buffer) { if (isAllProperties()) { buffer.append(properties.toString()); return; } if (! hasPropertyFilters()) { return; } for (Property property : properties) { PropertyMatch pm = testPropertyValue(property.getName()); if (pm.isMatch()) { if (pm.isValueExcluded()) { chompPropertyValue(property, buffer); } else { buffer.append(property.toString()); } } } }
Example #3
Source File: ICalRecurConverter.java From scipio-erp with Apache License 2.0 | 6 votes |
public static void convert(TemporalExpression expr, PropertyList<Property> eventProps) { ICalRecurConverter converter = new ICalRecurConverter(); expr.accept(converter); DtStart dateStart = (DtStart) eventProps.getProperty(Property.DTSTART); if (converter.dateStart != null) { if (dateStart != null) { eventProps.remove(dateStart); } dateStart = converter.dateStart; eventProps.add(dateStart); } if (dateStart != null && converter.exRuleList.size() > 0) { // iCalendar quirk - if exclusions exist, then the start date must be excluded also ExDate exdate = new ExDate(); exdate.getDates().add(dateStart.getDate()); converter.exDateList.add(exdate); } eventProps.addAll(converter.incDateList); eventProps.addAll(converter.incRuleList); eventProps.addAll(converter.exDateList); eventProps.addAll(converter.exRuleList); }
Example #4
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 6 votes |
protected static ResponseProperties storeWorkEffort(Component component, Map<String, Object> context) throws GenericEntityException { PropertyList<Property> propertyList = component.getProperties(); String workEffortId = fromXProperty(propertyList, workEffortIdXPropName); Delegator delegator = (Delegator) context.get("delegator"); GenericValue workEffort = EntityQuery.use(delegator).from("WorkEffort").where("workEffortId", workEffortId).queryOne(); if (workEffort == null) { return ICalWorker.createNotFoundResponse(null); } if (!hasPermission(workEffortId, "UPDATE", context)) { return null; } Map<String, Object> serviceMap = new HashMap<>(); serviceMap.put("workEffortId", workEffortId); setWorkEffortServiceMap(component, serviceMap); invokeService("updateWorkEffort", serviceMap, context); return storePartyAssignments(workEffortId, component, context); }
Example #5
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 6 votes |
protected static void setWorkEffortServiceMap(Component component, Map<String, Object> serviceMap) { PropertyList<Property> propertyList = component.getProperties(); setMapElement(serviceMap, "scopeEnumId", fromClazz(propertyList)); setMapElement(serviceMap, "description", fromDescription(propertyList)); setMapElement(serviceMap, "locationDesc", fromLocation(propertyList)); setMapElement(serviceMap, "priority", fromPriority(propertyList)); setMapElement(serviceMap, "currentStatusId", fromStatus(propertyList)); setMapElement(serviceMap, "workEffortName", fromSummary(propertyList)); setMapElement(serviceMap, "universalId", fromUid(propertyList)); // Set some fields to null so calendar clients can revert changes serviceMap.put("estimatedStartDate", null); serviceMap.put("estimatedCompletionDate", null); serviceMap.put("estimatedMilliSeconds", null); serviceMap.put("lastModifiedDate", null); serviceMap.put("actualCompletionDate", null); serviceMap.put("percentComplete", null); setMapElement(serviceMap, "estimatedStartDate", fromDtStart(propertyList)); setMapElement(serviceMap, "estimatedMilliSeconds", fromDuration(propertyList)); setMapElement(serviceMap, "lastModifiedDate", fromLastModified(propertyList)); if ("VTODO".equals(component.getName())) { setMapElement(serviceMap, "actualCompletionDate", fromCompleted(propertyList)); setMapElement(serviceMap, "percentComplete", fromPercentComplete(propertyList)); } else { setMapElement(serviceMap, "estimatedCompletionDate", fromDtEnd(propertyList)); } }
Example #6
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 6 votes |
protected static void loadWorkEffort(PropertyList<Property> componentProps, GenericValue workEffort) { replaceProperty(componentProps, new DtStamp()); // iCalendar object created date/time replaceProperty(componentProps, toClazz(workEffort.getString("scopeEnumId"))); replaceProperty(componentProps, toCreated(workEffort.getTimestamp("createdDate"))); replaceProperty(componentProps, toDescription(workEffort.getString("description"))); replaceProperty(componentProps, toDtStart(workEffort.getTimestamp("estimatedStartDate"))); replaceProperty(componentProps, toLastModified(workEffort.getTimestamp("lastModifiedDate"))); replaceProperty(componentProps, toPriority(workEffort.getLong("priority"))); replaceProperty(componentProps, toLocation(workEffort.getString("locationDesc"))); replaceProperty(componentProps, toStatus(workEffort.getString("currentStatusId"))); replaceProperty(componentProps, toSummary(workEffort.getString("workEffortName"))); Property uid = componentProps.getProperty(Uid.UID); if (uid == null) { // Don't overwrite UIDs created by calendar clients replaceProperty(componentProps, toUid(workEffort.getString("workEffortId"))); } replaceProperty(componentProps, toXProperty(workEffortIdXPropName, workEffort.getString("workEffortId"))); }
Example #7
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
public void setRecurrenceDates(DateList dates) { if (dates == null) { return; } PropertyList<RDate> rdateList = getEvent().getProperties().getProperties(Property.RDATE); for (RDate rdate : rdateList) { rdateList.remove(rdate); } if (dates.isEmpty()) { return; } RDate rDate = new RDate(dates); setDateListPropertyValue(rDate); rdateList.add(rDate); }
Example #8
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
public void setExceptionDates(DateList dates) { if (dates == null) { return; } PropertyList<Property> properties = getEvent().getProperties(); for (Property exdate : properties.getProperties(Property.EXDATE)) { properties.remove(exdate); } if (dates.isEmpty()) { return; } ExDate exDate = new ExDate(dates); setDateListPropertyValue(exDate); properties.add(exDate); }
Example #9
Source File: StandardCalendarQueryProcessorTest.java From cosmo with Apache License 2.0 | 6 votes |
/** * verify periods. * @param vfb VFreeBusy. * @param fbtype FbType. * @param periods The periods. */ private void verifyPeriods(VFreeBusy vfb, FbType fbtype, String periods) { PropertyList<FreeBusy> props = vfb.getProperties(Property.FREEBUSY); FreeBusy fb = null; for(FreeBusy next : props) { FbType type = (FbType) next.getParameter(Parameter.FBTYPE); if(type==null && fbtype==null) { fb = next; } else if(type != null && type.equals(fbtype)) { fb = next; } } if (fb == null) { Assert.fail("periods " + periods + " not in " + vfb.toString()); } Assert.assertEquals(periods, fb.getPeriods().toString()); }
Example #10
Source File: MockBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
/** * Sets recurrence dates. * @param dates The date list. */ public void setRecurrenceDates(DateList dates) { if (dates == null) { return; } PropertyList<Property> pl = getEvent().getProperties(); for (Property rdate : pl.getProperties(Property.RDATE)) { pl.remove(rdate); } if (dates.isEmpty()) { return; } RDate rDate = new RDate(dates); setDateListPropertyValue(rDate); pl.add(rDate); }
Example #11
Source File: MockBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
/** * Sets exception dates. * @param dates The date list. */ public void setExceptionDates(DateList dates) { if (dates == null) { return; } PropertyList<Property> properties = getEvent().getProperties(); for (Property exdate : properties.getProperties(Property.EXDATE)) { properties.remove(exdate); } if (dates.isEmpty()) { return; } ExDate exDate = new ExDate(dates); setDateListPropertyValue(exDate); properties.add(exDate); }
Example #12
Source File: ICal3ClientFilter.java From cosmo with Apache License 2.0 | 5 votes |
private void fixDateTimeProperties(Component component) { PropertyList<Property> props = component.getProperties(); for(Property prop : props) { if(prop instanceof DateProperty || prop instanceof DateListProperty) { Value v = (Value) prop.getParameter(Parameter.VALUE); if(Value.DATE_TIME.equals(v)) { prop.getParameters().remove(v); } } } }
Example #13
Source File: ICal3ClientFilter.java From cosmo with Apache License 2.0 | 5 votes |
private void fixExDates(Component comp) throws Exception { PropertyList<ExDate> exDates = comp.getProperties(Property.EXDATE); List<Property> toAdd = new ArrayList<>(); List<Property> toRemove = new ArrayList<>(); for(ExDate exDate : exDates) { // ical likes a single exdate if(exDate.getDates().size()==1) { continue; } // remove exdate with multiple dates toRemove.add(exDate); // create single dates instead for(Date date : exDate.getDates()) { ExDate singleEx = (ExDate) exDate.copy(); singleEx.getDates().clear(); singleEx.getDates().add(date); toAdd.add(singleEx); } } // remove exdates with multiple dates comp.getProperties().removeAll(toRemove); // Add all single exdates comp.getProperties().addAll(toAdd); }
Example #14
Source File: MockBaseEventStamp.java From cosmo with Apache License 2.0 | 5 votes |
/** * Sets recurrence rules. * @param recurs List with recurrence rules. */ public void setRecurrenceRules(List<Recur> recurs) { if (recurs == null) { return; } PropertyList<Property> pl = getEvent().getProperties(); for (Property rrule : pl.getProperties(Property.RRULE)) { pl.remove(rrule); } for (Recur recur : recurs) { pl.add(new RRule(recur)); } }
Example #15
Source File: MockBaseEventStamp.java From cosmo with Apache License 2.0 | 5 votes |
/** * Sets exception rules. * @param recurs The list. */ public void setExceptionRules(List<Recur> recurs) { if (recurs == null) { return; } PropertyList<Property> pl = getEvent().getProperties(); for (Property exrule : pl.getProperties(Property.EXRULE)) { pl.remove(exrule); } for (Recur recur : recurs) { pl.add(new ExRule(recur)); } }
Example #16
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 5 votes |
public void setExceptionRules(List<Recur> recurs) { if (recurs == null) { return; } PropertyList<Property> properties = getEvent().getProperties(); for (Property exrule : properties.getProperties(Property.EXRULE)) { properties.remove(exrule); } for (Recur recur : recurs) { properties.add(new ExRule(recur)); } }
Example #17
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 5 votes |
public List<Recur> getExceptionRules() { List<Recur> toReturn = new ArrayList<Recur>(); PropertyList<ExRule> exRuleProperties = getEvent().getProperties().getProperties(Property.EXRULE); for (ExRule exrule : exRuleProperties) { toReturn.add(exrule.getRecur()); } return toReturn; }
Example #18
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 5 votes |
public void setRecurrenceRules(List<Recur> recurs) { if (recurs == null) { return; } PropertyList<Property> properties = getEvent().getProperties(); for (Property rrule : properties.getProperties(Property.RRULE)) { properties.remove(rrule); } for (Recur recur : recurs) { properties.add(new RRule(recur)); } }
Example #19
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 5 votes |
public List<Recur> getRecurrenceRules() { List<Recur> toReturn = new ArrayList<>(); VEvent event = getEvent(); if(event != null) { PropertyList<RRule> rruleProperties = event.getProperties().getProperties(Property.RRULE); for (RRule rrule : rruleProperties) { toReturn.add(rrule.getRecur()); } } return toReturn; }
Example #20
Source File: JsonAlarmAdapter.java From XPagesExtensionLibrary with Apache License 2.0 | 5 votes |
public Object getJsonProperty(String property) { if ( JSON_ACTION.equals(property)) { return _alarm.getAction().getValue(); } else if ( JSON_TRIGGER.equals(property)) { return new JsonTriggerAdapter(_alarm.getTrigger()); } else if ( JSON_DESCRIPTION.equals(property)) { return Utils.getUnescapedString(_alarm.getDescription()); } else if ( JSON_SUMMARY.equals(property) ) { return Utils.getUnescapedString(_alarm.getSummary()); } else if ( JSON_REPEAT.equals(property) ) { return _alarm.getRepeat().getValue(); } else if ( JSON_DURATION.equals(property) ) { return _alarm.getDuration().getValue(); } else if ( JSON_ATTACH.equals(property)) { // attach may need a adapter return _alarm.getAttachment().getValue(); } else if ( JSON_ATTENDEES.equals(property) ) { List<JsonAttendeeAdapter> attendees = new ArrayList<JsonAttendeeAdapter>(); PropertyList list = _alarm.getProperties(ATTENDEE); if ( list != null ) { Iterator iterator = list.iterator(); while (iterator.hasNext() ) { attendees.add(new JsonAttendeeAdapter((Property)iterator.next())); } } return attendees; } return null; }
Example #21
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 #22
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 5 votes |
protected static String fromClazz(PropertyList<Property> propertyList) { Clazz iCalObj = (Clazz) propertyList.getProperty(Clazz.CLASS); if (iCalObj == null) { return null; } return "WES_".concat(iCalObj.getValue()); }
Example #23
Source File: CalendarFilterEvaluater.java From cosmo with Apache License 2.0 | 5 votes |
/** * Evaluates VFreeBusy time range. * @param freeBusy freebusy. * @param filter The filter. * @return The result. */ private boolean evaulateVFreeBusyTimeRange(VFreeBusy freeBusy, TimeRangeFilter filter) { DtStart start = freeBusy.getStartDate(); DtEnd end = freeBusy.getEndDate(); if (start != null && end != null) { InstanceList instances = new InstanceList(); if (filter.getTimezone() != null) { instances.setTimezone(new TimeZone(filter.getTimezone())); } instances.addComponent(freeBusy, filter.getPeriod().getStart(), filter.getPeriod().getEnd()); return instances.size() > 0; } PropertyList<FreeBusy> props = freeBusy.getProperties(Property.FREEBUSY); if(props.size()==0) { return false; } for (FreeBusy fb : props) { PeriodList periods = fb.getPeriods(); Iterator<Period> periodIt = periods.iterator(); while(periodIt.hasNext()) { Period period = periodIt.next(); if(filter.getPeriod().getStart().before(period.getEnd()) && filter.getPeriod().getEnd().after(period.getStart())) { return true; } } } return false; }
Example #24
Source File: CalendarFilterEvaluater.java From cosmo with Apache License 2.0 | 5 votes |
/** * Evaluates. * @param props The property list. * @param filter The time range filter. * @return The result. */ private boolean evaluate(PropertyList<Property> props, TimeRangeFilter filter) { // Evaluate timerange filter against a set of properties. // If any property matches, then evaluation succeeds. // This is basically a big OR for(Property prop : props) { if(evaluate(prop, filter)==true) { return true; } } return false; }
Example #25
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 5 votes |
protected static Double fromPriority(PropertyList<Property> propertyList) { Priority iCalObj = (Priority) propertyList.getProperty(Priority.PRIORITY); if (iCalObj == null) { return null; } return (double) iCalObj.getLevel(); }
Example #26
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 #27
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 5 votes |
protected static Timestamp fromCompleted(PropertyList<Property> propertyList) { Completed iCalObj = (Completed) propertyList.getProperty(Completed.COMPLETED); if (iCalObj == null) { return null; } Date date = iCalObj.getDate(); return new Timestamp(date.getTime()); }
Example #28
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 5 votes |
protected static String fromDescription(PropertyList<Property> propertyList) { Description iCalObj = (Description) propertyList.getProperty(Description.DESCRIPTION); if (iCalObj == null) { return null; } return iCalObj.getValue(); }
Example #29
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 5 votes |
protected static Timestamp fromDtEnd(PropertyList<Property> propertyList) { DtEnd iCalObj = (DtEnd) propertyList.getProperty(DtEnd.DTEND); if (iCalObj == null) { return null; } Date date = iCalObj.getDate(); return new Timestamp(date.getTime()); }
Example #30
Source File: ICalConverter.java From scipio-erp with Apache License 2.0 | 5 votes |
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()); }