cancel
Showing results for 
Search instead for 
Did you mean: 

Need to Implement Custom Business Calendar

ms1
Champ in-the-making
Champ in-the-making
Hello All,

I need to implement a business calendar which only counts business days for all timers, due dates, etc. For simplicity, we just want to skip Saturdays and Sundays. So, if a task is created on Friday with a 3 day due date, the due date would be the following Wednesday.

I see from other posts in the forum that I can implement my own BusinessCalendar, but I am wondering if anyone has some tips on the best way to do this. Has anyone implemented this or can offer advice on the best way to do this?

Thanks
11 REPLIES 11

vasile_dirla
Star Contributor
Star Contributor

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi,

may be you are looking for:
https://github.com/Activiti/Activiti/pull/646

If you need only one BusinessCalendar, you can configure it easily in process engine configuration.

Regards
Martin

ms1
Champ in-the-making
Champ in-the-making
Hi Vasile,
Yes, this is what I want to do. Does this work for v5.17 community edition?

@Martin - From what I could tell, this could work for me too. I am not sure where to start with this though. I understand that I can write and use my own business calendar implementation, but the problem for me is that the underlying code does quite a bit of work and the date calculation is buried in the Helper class … I don't want to mess with those implementations if I don't have to.
Let me ask this, if you had to do this, how would you implement it?

Thanks,
Mark

vasile_dirla
Star Contributor
Star Contributor
Hi Mark,
Hmm no, this is working only in the Enterprise version. (sorry, I haven't noticed you are using community edition)

If i'll have to do this task I'll take the sources from Martin and adjust them in case it doesn't fit exactly my needs.

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Mark,

Just implement org.activiti.engine.impl.calendar.BusinessCalendar.
Regards
Martin

ms1
Champ in-the-making
Champ in-the-making
Thanks Martin and Vasile,

Here is what I did to implement this … maybe this will help someone else.

I ended up deriving from the Activiti Calendar implementations (CycleBusinessCalendar, DueDateBusinessCalendar and DurationBusinessCalendar), overriding the resolveDueDate method to call the parent method(to avoid replicating any Activiti logic) and modifying the date to only take MON-FRI into account.
This works great and I believe will allow us to easily upgrade when we want.

Thanks again,
Mark

balajimurkute24
Champ in-the-making
Champ in-the-making
Can you please share the more details on this .I am not able to call CycleBusinessCalendar, DueDateBusinessCalendar and DurationBusinessCalendar classes resolveDueDate  in my own code.Its bydefault taking the activit classes  and its method.
Thanks in advance.

Thanks,
Balaji Murkute

vasile_dirla
Star Contributor
Star Contributor
Hi Mark,
Yes, I think it's a good approach.

balajimurkute24
Champ in-the-making
Champ in-the-making
Hi mark,

      As per your comment 7 you have overrided the resolveDueDate method of DueDateBusinessCalendar class but how exactly you are able to call this resolved date from activiti.I am new to activiti .Can you please put more details about this or configuration structure/or sample Example.Thanks in advance .

Thanks,
Balaji M.