net.fortuna.ical4j.model.Property Java Examples
The following examples show how to use
net.fortuna.ical4j.model.Property.
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: 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 #2
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 #3
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
public void setDisplayAlarmRepeat(Integer count) { VAlarm alarm = getDisplayAlarm(); if(alarm==null) { return; } Repeat repeat = (Repeat) alarm.getProperties().getProperty(Property.REPEAT); if (count == null) { if (repeat != null) { alarm.getProperties().remove(repeat); } return; } if (repeat == null) { repeat = new Repeat(); alarm.getProperties().add(repeat); } repeat.setCount(count.intValue()); }
Example #4
Source File: ExternalCalendaringServiceImpl.java From sakai with Educational Community License v2.0 | 6 votes |
/** * {@inheritDoc} */ public VEvent cancelEvent(VEvent vevent) { if(!isIcsEnabled()) { log.debug("ExternalCalendaringService is disabled. Enable via calendar.ics.generation.enabled=true in sakai.properties"); return null; } // You can only have one status so make sure we remove any previous ones. vevent.getProperties().removeAll(vevent.getProperties(Property.STATUS)); vevent.getProperties().add(Status.VEVENT_CANCELLED); // Must define a sequence for cancellations. If one was not defined when the event was created use 1 if (vevent.getProperties().getProperty(Property.SEQUENCE) == null) { vevent.getProperties().add(new Sequence("1")); } if(log.isDebugEnabled()){ log.debug("VEvent cancelled:" + vevent); } return vevent; }
Example #5
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
public void setDisplayAlarmTriggerDate(DateTime triggerDate) { VAlarm alarm = getDisplayAlarm(); if(alarm==null) { return; } Trigger oldTrigger = (Trigger) alarm.getProperties().getProperty( Property.TRIGGER); if (oldTrigger != null) { alarm.getProperties().remove(oldTrigger); } Trigger newTrigger = new Trigger(); newTrigger.getParameters().add(Value.DATE_TIME); newTrigger.setDateTime(triggerDate); alarm.getProperties().add(newTrigger); }
Example #6
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
public void setDisplayAlarmTrigger(Trigger newTrigger) { VAlarm alarm = getDisplayAlarm(); if(alarm==null) { return; } Trigger oldTrigger = (Trigger) alarm.getProperties().getProperty( Property.TRIGGER); if (oldTrigger != null) { alarm.getProperties().remove(oldTrigger); } if(newTrigger!=null) { alarm.getProperties().add(newTrigger); } }
Example #7
Source File: Utils.java From XPagesExtensionLibrary with Apache License 2.0 | 6 votes |
/** * Reads an iCalendar property value and then unescapes it. * * @param property * RFC Java * \n \r\n * \, , * \; ; * \\ \ * @return */ public static String getUnescapedString(Property property) { String value = null; if ( property != null ) { value = property.getValue(); } if ( value != null ) { // Replace all occurences of "\\n" with "\r\n". value = value.replaceAll("(?<!\\\\)\\\\n", "\r\n"); // $NON-NLS-1$ $NON-NLS-2$ value = value.replaceAll("(?<!\\\\)\\\\N", "\r\n"); // $NON-NLS-1$ $NON-NLS-2$ // Unescape all commas. value = value.replaceAll("\\\\,", ","); // Unescape all semicolons value = value.replaceAll("\\\\;", ";"); // Unescape all backslashes. value = value.replaceAll("\\\\\\\\", "\\\\"); } return value; }
Example #8
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 #9
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 #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: 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 #12
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 #13
Source File: MockBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
/** * Sets recurrence id. * @param date The date. */ public void setRecurrenceId(Date date) { RecurrenceId recurrenceId = (RecurrenceId) getEvent().getProperties(). getProperty(Property.RECURRENCE_ID); if (date == null) { if (recurrenceId != null) { getEvent().getProperties().remove(recurrenceId); } return; } if (recurrenceId == null) { recurrenceId = new RecurrenceId(); getEvent().getProperties().add(recurrenceId); } recurrenceId.setDate(date); setDatePropertyValue(recurrenceId, date); }
Example #14
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 #15
Source File: EventValidator.java From cosmo with Apache License 2.0 | 6 votes |
@Override protected boolean isValid(VEvent event, ValidationConfig config) { List<? extends Property> rrules = event.getProperties(prop); if (rrules == null) { return true; } for (Property p : rrules) { RRule rrule = (RRule) p; if (!isRRuleValid(rrule, config)) { return false; } } return true; }
Example #16
Source File: MockBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
/** * Sets diplay alarm repeat. * @param count */ public void setDisplayAlarmRepeat(Integer count) { VAlarm alarm = getDisplayAlarm(); if (alarm == null) { return; } Repeat repeat = (Repeat) alarm.getProperties().getProperty(Property.REPEAT); if (count == null) { if (repeat != null) { alarm.getProperties().remove(repeat); } return; } if (repeat == null) { repeat = new Repeat(); alarm.getProperties().add(repeat); } repeat.setCount(count.intValue()); }
Example #17
Source File: MockBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
/** * Gets display alarm description. * @return The alarm description. */ public String getDisplayAlarmDescription() { VAlarm alarm = getDisplayAlarm(); if (alarm == null) { return null; } Description description = (Description) alarm.getProperties() .getProperty(Property.DESCRIPTION); if (description == null) { return null; } return description.getValue(); }
Example #18
Source File: CalendarFilterEvaluater.java From cosmo with Apache License 2.0 | 6 votes |
/** * Evaluates. * @param property The property. * @param filter The text match filter. * @return The result. */ private boolean evaluate(Property property, TextMatchFilter filter) { boolean matched = false; if(filter.isCaseless()) { matched = property.getValue().toLowerCase(CosmoConstants.LANGUAGE_LOCALE).contains(filter.getValue().toLowerCase(CosmoConstants.LANGUAGE_LOCALE)); } else { matched = property.getValue().contains(filter.getValue()); } if(filter.isNegateCondition()) { return !matched; } else { return matched; } }
Example #19
Source File: MockBaseEventStamp.java From cosmo with Apache License 2.0 | 6 votes |
/** * Removes display alarm. */ public void removeDisplayAlarm() { VEvent event = getEvent(); if (event == null) { return; } for(@SuppressWarnings("rawtypes") Iterator it = event.getAlarms().iterator();it.hasNext();) { VAlarm alarm = (VAlarm) it.next(); if (alarm.getProperties().getProperty(Property.ACTION).equals( Action.DISPLAY)) { it.remove(); } } }
Example #20
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 #21
Source File: HCalendarParser.java From cosmo with Apache License 2.0 | 5 votes |
/** * Builds event. * @param element The element. * @param handler The content handler. * @throws ParserException - if something is wrong this exception is thrown. */ private void buildEvent(Element element, ContentHandler handler) throws ParserException { if (LOG.isDebugEnabled()) { LOG.debug("Building event"); } handler.startComponent(Component.VEVENT); buildProperty(findElement(XPATH_DTSTART, element), Property.DTSTART, handler); buildProperty(findElement(XPATH_DTEND, element), Property.DTEND, handler); buildProperty(findElement(XPATH_DURATION, element), Property.DURATION, handler); buildProperty(findElement(XPATH_SUMMARY, element), Property.SUMMARY, handler); buildProperty(findElement(XPATH_UID, element), Property.UID, handler); buildProperty(findElement(XPATH_DTSTAMP, element), Property.DTSTAMP, handler); for (Element category : findElements(XPATH_CATEGORY, element)) { buildProperty(category, Property.CATEGORIES, handler); } buildProperty(findElement(XPATH_LOCATION, element), Property.LOCATION, handler); buildProperty(findElement(XPATH_URL, element), Property.URL, handler); buildProperty(findElement(XPATH_DESCRIPTION, element), Property.DESCRIPTION, handler); buildProperty(findElement(XPATH_LAST_MODIFIED, element), Property.LAST_MODIFIED, handler); buildProperty(findElement(XPATH_STATUS, element), Property.STATUS, handler); buildProperty(findElement(XPATH_CLASS, element), Property.CLASS, handler); for (Element attendee : findElements(XPATH_ATTENDEE, element)) { buildProperty(attendee, Property.ATTENDEE, handler); } buildProperty(findElement(XPATH_CONTACT, element), Property.CONTACT, handler); buildProperty(findElement(XPATH_ORGANIZER, element), Property.ORGANIZER, handler); handler.endComponent(Component.VEVENT); }
Example #22
Source File: HCalendarParser.java From cosmo with Apache License 2.0 | 5 votes |
/** * Verify if the name is the date property. * @param name The name. * @return The result. */ private static boolean isDateProperty(String name) { return name.equals(Property.DTSTART) || name.equals(Property.DTEND) || name.equals(Property.LAST_MODIFIED) || name.equals(Property.DTSTAMP); }
Example #23
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 #24
Source File: OutputFilter.java From cosmo with Apache License 2.0 | 5 votes |
/** * @param comp The component. */ private void componentToUTC(Component comp) { // Do to each top-level property for (Property prop : (List<Property>) comp.getProperties()) { if (prop instanceof DateProperty) { DateProperty dprop = (DateProperty) prop; Date date = dprop.getDate(); if (date instanceof DateTime && (((DateTime) date).getTimeZone() != null)) { dprop.setUtc(true); } } } // Do to each embedded component ComponentList<? extends CalendarComponent> subcomps = null; if (comp instanceof VEvent) { subcomps = ((VEvent) comp).getAlarms() ; } else if (comp instanceof VToDo) { subcomps = ((VToDo)comp).getAlarms(); } if (subcomps != null) { for (CalendarComponent subcomp : subcomps) { componentToUTC(subcomp); } } }
Example #25
Source File: HibEventExceptionStamp.java From cosmo with Apache License 2.0 | 5 votes |
protected void setMissing(Property prop, boolean missing) { Parameter parameter = prop.getParameters().getParameter(PARAM_OSAF_MISSING); if (missing) { if (parameter == null) { prop.getParameters().add( new XParameter(PARAM_OSAF_MISSING, VALUE_TRUE)); } } else { if (parameter != null) { prop.getParameters().remove(parameter); } } }
Example #26
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 #27
Source File: HCalendarParser.java From cosmo with Apache License 2.0 | 5 votes |
/** * Verify if the name is the text property. * @param name The name. * @return The result. */ private static boolean isTextProperty(String name) { return name.equals(Property.SUMMARY) || name.equals(Property.LOCATION) || name.equals(Property.CATEGORIES) || name.equals(Property.DESCRIPTION) || name.equals(Property.ATTENDEE) || name.equals(Property.CONTACT) || name.equals(Property.ORGANIZER); }
Example #28
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 5 votes |
public void setStatus(String text) { // ical4j Status value is immutable, so if there's any change // at all, we have to remove the old status and add a new // one. Status status = (Status) getEvent().getProperties().getProperty(Property.STATUS); if (status != null) { getEvent().getProperties().remove(status); } if (text == null) { return; } getEvent().getProperties().add(new Status(text)); }
Example #29
Source File: HibBaseEventStamp.java From cosmo with Apache License 2.0 | 5 votes |
public String getLocation() { Property p = getEvent().getProperties(). getProperty(Property.LOCATION); if (p == null) { return null; } return p.getValue(); }
Example #30
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); }