JBoss Community

Custom BusinessCalendar

reply from Marco Baroetto in jBPM - View the full discussion

I think the jBPM Develpers Guide is not correct in 2.1.2 Business Calendar:

 

 For example: 
public class CustomBusinessCalendar implements BusinessCalendar {
  
  public Date add(Date date, String duration) {
    if ("my next birthday".equals(duration)) {
      GregorianCalendar gregorianCalendar = new GregorianCalendar();
      gregorianCalendar.set(Calendar.MONTH, Calendar.JULY);
      gregorianCalendar.set(Calendar.DAY_OF_MONTH, 21);
      return gregorianCalendar.getTime();
    }
    return null;
  }
}     





To configure the jBPM engine to use this custom business calendar, just add      the following line to your jbpm.cfg.xml: 



<process-engine-context>
    <object  class="org.jbpm.test.custombusinesscalendarimpl.CustomBusinessCalendar"

/>
</process-engine-context>   



 

 Take a look at the       

org.jbpm.test.custombusinesscalendarimpl.CustomBusinessCalendarImplTest for more information. 

 

 

1) org.jbpm.test.custombusinesscalendarimpl.CustomBusinessCalendarImplTest doesn't exist

 

2) To add your EL expression in timers (at least for task's duedate) you have to:

 

- Write my.own.MyNextBirthday extends Date (or Calendar,GregorianCalendar...) and is equals to the date you want.

- Add to your cfg the following:

 

 <object name="myNextBirthday" class="my.own.MyNextBirthday" />

 

3) Write your jpdl as follows:

 

<task name="TaskTransaction2_step1"  duedate="#{myNextBirthday} +3 days" candidate-groups="user">

Reply to this message by going to Community

Start a new discussion in jBPM at Community