use of net.fortuna.ical4j.model.PropertyList in project openhab1-addons by openhab.
the class EventReloaderJob method readCategory.
/**
* Returns a list of categories or an empty list if none found.
*
* @param vEvent
* @return
*/
private List<String> readCategory(VEvent vEvent) {
PropertyList 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;
}
use of net.fortuna.ical4j.model.PropertyList in project OpenOLAT by OpenOLAT.
the class ICalFileCalendarManager method createKalendarEventRecurringOccurence.
@Override
public KalendarEvent createKalendarEventRecurringOccurence(KalendarRecurEvent recurEvent) {
KalendarEvent rootEvent = recurEvent.getCalendar().getEvent(recurEvent.getID(), null);
VEvent vEvent = getVEvent(recurEvent);
PropertyList vEventProperties = vEvent.getProperties();
for (Iterator<?> objIt = vEventProperties.iterator(); objIt.hasNext(); ) {
Object property = objIt.next();
if (property instanceof RRule || property instanceof ExDate) {
objIt.remove();
}
}
try {
Kalendar calendar = recurEvent.getCalendar();
Date startDate = recurEvent.getOccurenceDate();
String startString = CalendarUtils.formatRecurrenceDate(startDate, rootEvent.isAllDayEvent());
RecurrenceId recurId;
if (rootEvent.isAllDayEvent()) {
recurId = new RecurrenceId(tz);
recurId.setDate(CalendarUtils.createDate(startDate));
} else {
recurId = new RecurrenceId(startString, tz);
}
vEventProperties.add(recurId);
KalendarEvent kEvent = getKalendarEvent(vEvent);
kEvent.setKalendar(calendar);
return kEvent;
} catch (ParseException e) {
log.error("", e);
return null;
}
}
use of net.fortuna.ical4j.model.PropertyList in project OpenOLAT by OpenOLAT.
the class ICalServlet method updateUrlProperties.
private void updateUrlProperties(Calendar calendar) {
for (Iterator<?> eventIter = calendar.getComponents().iterator(); eventIter.hasNext(); ) {
Object comp = eventIter.next();
if (comp instanceof VEvent) {
VEvent event = (VEvent) comp;
PropertyList ooLinkProperties = event.getProperties(CalendarManager.ICAL_X_OLAT_LINK);
if (ooLinkProperties.isEmpty()) {
continue;
}
Url currentUrl = event.getUrl();
if (currentUrl != null) {
continue;
}
for (Iterator<?> iter = ooLinkProperties.iterator(); iter.hasNext(); ) {
XProperty linkProperty = (XProperty) iter.next();
if (linkProperty != null) {
String encodedLink = linkProperty.getValue();
StringTokenizer st = new StringTokenizer(encodedLink, "ยง", false);
if (st.countTokens() >= 4) {
// provider
st.nextToken();
// id
st.nextToken();
// displayname
st.nextToken();
String uri = st.nextToken();
try {
Url urlProperty = new Url();
urlProperty.setValue(uri);
event.getProperties().add(urlProperty);
break;
} catch (URISyntaxException e) {
log.error("Invalid URL:" + uri);
}
}
}
}
}
}
}
use of net.fortuna.ical4j.model.PropertyList in project ofbiz-framework by apache.
the class ICalConverter method setWorkEffortServiceMap.
protected static void setWorkEffortServiceMap(Component component, Map<String, Object> serviceMap) {
PropertyList 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));
}
}
use of net.fortuna.ical4j.model.PropertyList in project ofbiz-framework by apache.
the class ICalConverter method getAlarms.
protected static void getAlarms(GenericValue workEffort, ComponentList alarms) throws GenericEntityException {
Description description = null;
if (workEffort.get("description") != null) {
description = new Description(workEffort.getString("description"));
} else {
description = new Description(workEffort.getString("workEffortName"));
}
Summary summary = new Summary(UtilProperties.getMessage("WorkEffortUiLabels", "WorkEffortEventReminder", Locale.getDefault()));
Delegator delegator = workEffort.getDelegator();
String workEffortId = workEffort.getString("workEffortId");
List<GenericValue> reminderList = EntityQuery.use(delegator).from("WorkEffortEventReminder").where("workEffortId", workEffort.get("workEffortId")).queryList();
for (GenericValue reminder : reminderList) {
String reminderId = workEffortId + "-" + reminder.getString("sequenceId");
VAlarm alarm = null;
PropertyList alarmProps = null;
boolean newAlarm = true;
Iterator<VAlarm> i = UtilGenerics.cast(alarms.iterator());
while (i.hasNext()) {
alarm = i.next();
Property xProperty = alarm.getProperty(reminderXPropName);
if (xProperty != null && reminderId.equals(xProperty.getValue())) {
newAlarm = false;
alarmProps = alarm.getProperties();
// TODO: Write update code. For now, just re-create
alarmProps.clear();
break;
}
}
if (newAlarm) {
alarm = createAlarm(reminder);
alarms.add(alarm);
alarmProps = alarm.getProperties();
alarmProps.add(new XProperty(reminderXPropName, reminderId));
}
GenericValue contactMech = reminder.getRelatedOne("ContactMech", false);
if (contactMech != null && "EMAIL_ADDRESS".equals(contactMech.get("contactMechTypeId"))) {
try {
alarmProps.add(new Attendee(contactMech.getString("infoString")));
alarmProps.add(Action.EMAIL);
alarmProps.add(summary);
alarmProps.add(description);
} catch (URISyntaxException e) {
alarmProps.add(Action.DISPLAY);
alarmProps.add(new Description("Error encountered while creating iCalendar: " + e));
}
} else {
alarmProps.add(Action.DISPLAY);
alarmProps.add(description);
}
if (Debug.verboseOn()) {
try {
alarm.validate(true);
Debug.logVerbose("iCalendar alarm passes validation", module);
} catch (ValidationException e) {
if (Debug.verboseOn())
Debug.logVerbose("iCalendar alarm fails validation: " + e, module);
}
}
}
}
Aggregations