Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
New Developer
Posts: 17
Registered: ‎08-06-2009
My Device: Not Specified

Working with recurring events and exceptions

I am developing a BlackBerry JAVA application that needs to retrieve, add, update and delete events in BlackBerry Calendar. I use EventList, BlackBerryEvent classes to do this. I can successfully make required actions with non-recurring events and with recurring events without exceptions (exception is a changed occurence of recurring event). But:
1) I did not find any solution to create recurring event with exceptions;
2) How to determine that event is an exception? How to find for which recurrent event this exception was created?

 

It looks like java has no means to do this...

 

Any Help will be appreciated.

 

Thanks,
Dmitry.

Developer
Posts: 132
Registered: ‎05-07-2009
My Device: Curve
My Carrier: Vodafone

Re: Working with recurring events and exceptions

Did you try "RepeatRule" class?... there you can give except dates.

 

Please reply.

Sameer Joshi
Blackberry developer.
New Developer
Posts: 17
Registered: ‎08-06-2009
My Device: Not Specified

Re: Working with recurring events and exceptions

Thanks for reply, but “Except dates” in "RepeatRule" class can be used for retrieving date of exception, but it does not guarantee that event is exception and exception is related to particular recurring event. I found that Event class has private field “_relatedLUID”. For exception this field is set to UID of recurring event. But there is no way to retrieve its value in JAVA Micro Edition.
Developer
Posts: 132
Registered: ‎05-07-2009
My Device: Curve
My Carrier: Vodafone

Re: Working with recurring events and exceptions

buddy, can u please explain in simple terms what are u expecting?... i did not get you.... what is exception event? i know what are excpetion dates.....
Sameer Joshi
Blackberry developer.
New Developer
Posts: 8
Registered: ‎07-27-2009
My Device: Not Specified

Re: Working with recurring events and exceptions

[ Edited ]

I guess exceptions are hard to predict in advance it is much easier to see conflicts once the event exists. Bedework offers the option of setting exceptions during event creation, but the UI is hardly intuitive. Which i think is the real reason  how do you easily manage 50 events  in the add event dialog without making it a UI nightmare.

 

Social Media Optimization Company in Chennai

Message Edited by GemariahPryce on 08-06-2009 05:19 AM
New Developer
Posts: 17
Registered: ‎08-06-2009
My Device: Not Specified

Re: Working with recurring events and exceptions

Sameer, let me give you an example.
1) You have BlackBerry Calendar without any events.
2) Create event with subject “Subj”, start 2009-08-06 10:00, end 2009-08-06 11:00, recurrence “Daily”, every 2 days, end date 2009-08-16;
3) In Calendar go to date 2009-08-08, you will see the second occurrence of recurring event;
4) Highlight this occurrence, press menu “Open”, in dialog select “Open this occurrence”;
5) Change subject to “Exc”, start and end dates to 2009-08-09, save event. You will see that this occurrence is an exception now (on date 2008-08-09) – Blackberry will display this event with crossed arrows;
6) Using code below retrieve list of events from Calendar:
EventList bbEventList =(EventList)PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
Enumeration enumeration =bbEventList.items();
while (enumeration.hasMoreElements())
{

}
7) Enumeration will have 2 events: recurring event with subject “Subj” and non-recurring event with subject “Exc” (private field _relatedLUID is set to UID of event “Subj”). In this case I cannot find any solution to determine that event “Exc” is an exception of event “Subj”. Function getExceptDates()of RepeatRule for event “Subj” returns date 2009-08-08 10:00, exception date is 2009-08-09 10:00. So this date cannot be used in this case.
Developer
Posts: 132
Registered: ‎05-07-2009
My Device: Curve
My Carrier: Vodafone

Re: Working with recurring events and exceptions

OK got it...... now what i had done in this case is..... you get an enum of Except Dates in getExceptDates() function..... it will have your "Exc" date, now you match this date with your all dates in the event, and it they match return false and break the loop. I no a bit lengthy process but this is how i did it.

 

getExceptDate() will return you the date with "Exc" as description... and the normal event list enum returns you all the dates even though they are except dates, so we need to match the date with except date and if except date enum has it return false and dont include it.... 

Sameer Joshi
Blackberry developer.
New Developer
Posts: 17
Registered: ‎08-06-2009
My Device: Not Specified

Re: Working with recurring events and exceptions

Sameer, thanks for reply, but it looks like your solution will not fly because of 2 reasons:
1. See test case in my previous post. In my test case recurring event “Subj” returned except date “2009-08-08 10:00”, but date of “Exc” is “2009-08-09 10:00”.
2. Comparison of dates is not reliable approach. For example date of “Exc” is “2009-08-09 10:00”. What if user has non recurring event “Event3” with the same date “2009-08-09 10:00”?
Also do you know how to programmatically create recurring events with exceptions in BlackBerry Calendar?
Developer
Posts: 132
Registered: ‎05-07-2009
My Device: Curve
My Carrier: Vodafone

Re: Working with recurring events and exceptions

No buddy, the repeat rule is for particular event , so for all recurring events there will be different RepeatRule, so event3 is different subj is different,

 

1) for event Subj there will be 1 RepeatRule--- so that repeatRule.getExceptDates() enum will give u except dates of "Subj" event only. and further you have the enum of recurring dates of "Subj" event using RepeatRule.dates(blah blah parameters).... now  make cascaded while or foor loops to match the normal dates and except dates for event "subj".... when 2 occurences match thats except date. exclude that date and continue with the loop untill the Except date enum exhausts.

 

2) Yes you can create recurring events programmatically, Use RepeatRule only, 

For e,.g

 Weekely recurring event

setInt( RepeatRule.FREQUENCY, RepeatRule.WEEKLY );
setInt( RepeatRule.INTERVAL, 3 );
setInt( RepeatRule.DAY_IN_WEEK, RepeatRule.FRIDAY );

 After that set this repeatrule to the desired event.

Sameer Joshi
Blackberry developer.
New Developer
Posts: 17
Registered: ‎08-06-2009
My Device: Not Specified

Re: Working with recurring events and exceptions

It looks like we have misunderstanding.
1) Let’s go to sample again:

    a) In BlackBerry we have recurring event “Subj”. “Subj” has exception “Exc”. Just to be clear... Under term "exception" I mean changed occurrence of recurring event.
    b) Function dates(…) for event “Subj” returns dates “2009-08-06”, “2009-08-10”, “2009-08-12”, “2009-08-14”, “2009-08-16”;
    c) Function getExceptDates() for event “Subj” returns date “2009-08-08”
    d) Event “Exc” that retrieved from EventList class has date “2009-08-09”
    e) We cannot match “Exc” and “Subj”, because date “2009-08-09” does not match to dates from item b) and c)

2) I know how to programmatically create recurring events. The question is how to programmatically create exception (“Exc”) for particular recurring event (“Subj”).