本文整理汇总了Java中net.fortuna.ical4j.model.component.VEvent类的典型用法代码示例。如果您正苦于以下问题:Java VEvent类的具体用法?Java VEvent怎么用?Java VEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
VEvent类属于net.fortuna.ical4j.model.component包,在下文中一共展示了VEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: icalResponse
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
private GetEventsResponse icalResponse(Page<EventEntity> eventPage) {
Calendar calendar = new Calendar();
calendar.getProperties().add(new ProdId("-//PutPut//iCal4j 1.0//EN"));
calendar.getProperties().add(Version.VERSION_2_0);
calendar.getProperties().add(CalScale.GREGORIAN);
eventPage
.getContent()
.stream()
.forEach(event -> {
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
net.fortuna.ical4j.model.TimeZone timezone = registry.getTimeZone(event.getTimezone());
VEvent vEvent = createVEvent(event, timezone);
vEvent.getProperties().add(new Uid(event.getId()));
vEvent.getProperties().add(new Description(event.getDescription()));
vEvent.getProperties().add(new Location(event.getLocation()));
vEvent.getProperties().add(timezone.getVTimeZone().getTimeZoneId());
calendar.getComponents().add(vEvent);
});
return GetEventsResponse.withCalendarOK(calendar.toString());
}
示例2: isHoliday
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
/**
* Checks if the given date is a holiday.
* @param cal date to check
* @return true, if date is a holiday, otherwise false
*/
@Override
public boolean isHoliday(Calendar cal) {
Objects.requireNonNull(cal, "parameter cal must not be null!");
// clear time in given date (cal)
cal.set(java.util.Calendar.HOUR_OF_DAY, 0);
cal.clear(java.util.Calendar.MINUTE);
cal.clear(java.util.Calendar.SECOND);
// create filter for search in calendar
Period period = new Period(new DateTime(cal.getTime()), new Dur(1, 0, 0, 0));
Filter filter = new Filter(new PeriodRule(period));
// get all events for the given date
Collection<VEvent> filteredEvents = filter.filter(calendar.getComponents(Component.VEVENT));
// here is a little workaround: if we have an event for the given date in the holiday calendar
// then the given date must be a holiday. however, ical4j returns an event even for the day
// after the holiday. so we check if the endDate of the event is our date. in that case, we ignore
// the event und return false.
if(filteredEvents.size() == 1) {
VEvent event = filteredEvents.iterator().next();
GregorianCalendar endDateCal = new GregorianCalendar();
endDateCal.setTime(event.getEndDate().getDate());
if(endDateCal.get(Calendar.MONTH) == cal.get(Calendar.MONTH)
&& endDateCal.get(Calendar.DATE) == cal.get(Calendar.DATE)) {
return false;
}
return true;
}
return filteredEvents.size() > 0;
}
示例3: parseAppointmenttoCalendar
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
/**
* Methods to parse Appointment to iCalendar according RFC 2445
*
* @param appointment to be converted to iCalendar
* @return iCalendar representation of the Appointment
*/
public Calendar parseAppointmenttoCalendar(Appointment appointment) {
String tzid = parseTimeZone(null, appointment.getOwner()).getID();
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
net.fortuna.ical4j.model.TimeZone timeZone = registry.getTimeZone(tzid);
if (timeZone == null) {
throw new NoSuchElementException("Unable to get time zone by id provided: " + tzid);
}
Calendar icsCalendar = new Calendar();
icsCalendar.getProperties().add(new ProdId("-//Events Calendar//Apache Openmeetings//EN"));
icsCalendar.getProperties().add(Version.VERSION_2_0);
icsCalendar.getProperties().add(CalScale.GREGORIAN);
icsCalendar.getComponents().add(timeZone.getVTimeZone());
DateTime start = new DateTime(appointment.getStart()), end = new DateTime(appointment.getEnd());
VEvent meeting = new VEvent(start, end, appointment.getTitle());
meeting = addVEventpropsfromAppointment(appointment, meeting);
icsCalendar.getComponents().add(meeting);
return icsCalendar;
}
示例4: parseAppointmentstoCalendar
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
/**
* Parses a List of Appointments into a VCALENDAR component.
*
* @param appointments List of Appointments for the Calendar
* @param ownerId Owner of the Appointments
* @return VCALENDAR representation of the Appointments
*/
public Calendar parseAppointmentstoCalendar(List<Appointment> appointments, Long ownerId) {
String tzid = parseTimeZone(null, userDao.get(ownerId)).getID();
TimeZoneRegistry registry = TimeZoneRegistryFactory.getInstance().createRegistry();
net.fortuna.ical4j.model.TimeZone timeZone = registry.getTimeZone(tzid);
if (timeZone == null) {
throw new NoSuchElementException("Unable to get time zone by id provided: " + tzid);
}
Calendar icsCalendar = new Calendar();
icsCalendar.getProperties().add(new ProdId(PROD_ID));
icsCalendar.getProperties().add(Version.VERSION_2_0);
icsCalendar.getProperties().add(CalScale.GREGORIAN);
icsCalendar.getComponents().add(timeZone.getVTimeZone());
for (Appointment appointment : appointments) {
DateTime start = new DateTime(appointment.getStart()), end = new DateTime(appointment.getEnd());
VEvent meeting = new VEvent(start, end, appointment.getTitle());
meeting = addVEventpropsfromAppointment(appointment, meeting);
icsCalendar.getComponents().add(meeting);
}
return icsCalendar;
}
示例5: getEventsInPeriod
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
public static List<Event> getEventsInPeriod(final Calendar cal, final Period period) {
final Filter filter = new Filter(new Rule[] {new PeriodRule(period)}, Filter.MATCH_ALL);
final List<Component> filtered = (List<Component>) filter.filter(cal.getComponents());
final List<Event> ret = new ArrayList<>();
for (final Component comp : filtered) {
if (!(comp instanceof VEvent)) {
continue;
}
final PeriodList recurrenceSet = comp.calculateRecurrenceSet(period);
for (final Object p : recurrenceSet) {
ret.add(new Event(
getValueIfExists(comp, Property.SUMMARY),
getValueIfExists(comp, Property.URL),
(Period) p));
}
}
Collections.sort(ret);
return ret;
}
示例6: testCreateContentThrowsExceptionForInvalidDates
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
@Test(expected=IllegalArgumentException.class)
public void testCreateContentThrowsExceptionForInvalidDates() throws Exception {
User user = testHelper.makeDummyUser();
CollectionItem rootCollection = contentDao.createRootItem(user);
NoteItem noteItem = new MockNoteItem();
noteItem.getAttributeValue("");
noteItem.setName("foo");
noteItem.setOwner(user);
Calendar c = new Calendar();
VEvent e = new VEvent();
e.getProperties().add(new DtStart("20131010T101010Z"));
e.getProperties().add(new DtEnd("20131010T091010Z"));
c.getComponents().add(e);
MockEventStamp mockEventStamp = new MockEventStamp();
mockEventStamp.setEventCalendar(c);
noteItem.addStamp(mockEventStamp);
service.createContent(rootCollection, noteItem);
}
示例7: cancelEvent
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
/**
* {@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;
}
示例8: testUpdateCollectionFailsForEventsWithInvalidDates
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
@Test(expected=IllegalArgumentException.class)
public void testUpdateCollectionFailsForEventsWithInvalidDates() throws Exception {
User user = testHelper.makeDummyUser();
CollectionItem rootCollection = contentDao.createRootItem(user);
NoteItem noteItem = new MockNoteItem();
noteItem.getAttributeValue("");
noteItem.setName("foo");
noteItem.setOwner(user);
Calendar c = new Calendar();
VEvent e = new VEvent();
e.getProperties().add(new DtStart("20131010T101010Z"));
e.getProperties().add(new DtEnd("20131010T091010Z"));
c.getComponents().add(e);
MockEventStamp mockEventStamp = new MockEventStamp();
mockEventStamp.setEventCalendar(c);
noteItem.addStamp(mockEventStamp);
service.updateCollection(rootCollection, Collections.singleton((Item)noteItem));
}
示例9: generateEvents
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public List<VEvent> generateEvents(User user, SignupCalendarHelper calendarHelper) {
List<VEvent> events = new ArrayList<VEvent>();
VEvent meetingEvent = meeting.getVevent();
if (meetingEvent == null) {
return events;
}
Set<SignupAttendee> attendees = new HashSet<SignupAttendee>();
for(SignupTimeslot timeslot: meeting.getSignupTimeSlots()) {
attendees.addAll(timeslot.getAttendees());
}
calendarHelper.addAttendeesToVEvent(meetingEvent, attendees);
events.add(meetingEvent);
return events;
}
示例10: areTimeZoneIdsValid
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
private static boolean areTimeZoneIdsValid(VEvent event){
for(String propertyName : PROPERTIES_WITH_TIMEZONES){
List<Property> props = event.getProperties(propertyName);
for(Property p : props){
if(p != null && p.getParameter(Parameter.TZID) != null){
String tzId = p.getParameter(Parameter.TZID).getValue();
if(tzId != null && timeZoneRegistry.getTimeZone(tzId) == null){
LOG.warn("Unknown TZID [" + tzId + "] for event " + event);
return false;
}
}
}
}
return true;
}
示例11: canGenerateEventsFromAttendeeCancellationOwnEmail
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
@Test
public void canGenerateEventsFromAttendeeCancellationOwnEmail() {
when(_mockedUser.getId()).thenReturn("userId");
when(_mockedCancelledTimeslot.getAttendee("userId")).thenReturn(_mockedAttendee);
when(_mockedItem.isInitiator()).thenReturn(true);
final List<SignupTrackingItem> items = Collections.singletonList(_mockedItem);
_email = new AttendeeCancellationOwnEmail(_mockedUser, items, _mockedMeeting, _mockedFacade);
final List<VEvent> events = _email.generateEvents(_mockedUser, _mockedCalendarHelper);
verify(_mockedCalendarHelper, times(1)).cancelVEvent(any(VEvent.class));
assertEquals(1, events.size());
assertTrue(_email.isCancellation());
}
示例12: updateNoteModification
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
/**
* Updates note modification.
* @param noteMod The note item modified.
* @param event The event.
*/
private void updateNoteModification(NoteItem noteMod,
VEvent event) {
EventExceptionStamp exceptionStamp =
StampUtils.getEventExceptionStamp(noteMod);
exceptionStamp.setExceptionEvent(event);
// copy VTIMEZONEs to front if present
ComponentList<VTimeZone> vtimezones = exceptionStamp.getMasterStamp()
.getEventCalendar().getComponents(Component.VTIMEZONE);
for(VTimeZone vtimezone : vtimezones) {
exceptionStamp.getEventCalendar().getComponents().add(0, vtimezone);
}
noteMod.setClientModifiedDate(new Date());
noteMod.setLastModifiedBy(noteMod.getModifies().getLastModifiedBy());
noteMod.setLastModification(ContentItem.Action.EDITED);
setCalendarAttributes(noteMod, event);
}
示例13: evaluate
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
/**
* Evaluates.
* @param comps The component list.
* @param filter The time range filter.
* @return the result.
*/
private boolean evaluate(ComponentList comps, TimeRangeFilter filter) {
Component comp = (Component) comps.get(0);
if(comp instanceof VEvent) {
return evaluateVEventTimeRange(comps, filter);
}
else if(comp instanceof VToDo) {
return evaulateVToDoTimeRange(comps, filter);
}
else if(comp instanceof VJournal) {
return evaluateVJournalTimeRange((VJournal) comp, filter);
}
else if(comp instanceof VAlarm) {
return evaluateVAlarmTimeRange(comps, filter);
}
else {
return false;
}
}
示例14: removeDisplayAlarm
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
/**
* 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();
}
}
}
示例15: syncExceptions
import net.fortuna.ical4j.model.component.VEvent; //导入依赖的package包/类
/**
* Sync exceptions.
* @param exceptions The exceptions.
* @param masterNote The master note.
*/
private void syncExceptions(Map<Date, VEvent> exceptions,
NoteItem masterNote) {
for (Entry<Date, VEvent> entry : exceptions.entrySet()) {
syncException(entry.getValue(), masterNote);
}
// remove old exceptions
for (NoteItem noteItem : masterNote.getModifications()) {
EventExceptionStamp eventException =
StampUtils.getEventExceptionStamp(noteItem);
if (eventException==null || !exceptions.containsKey(eventException.getRecurrenceId())) {
noteItem.setIsActive(false);
}
}
}