Search in sources :

Example 1 with CycleBusinessCalendar

use of org.activiti.engine.impl.calendar.CycleBusinessCalendar in project Activiti by Activiti.

the class ProcessEngineConfigurationImpl method initBusinessCalendarManager.

public void initBusinessCalendarManager() {
    if (businessCalendarManager == null) {
        MapBusinessCalendarManager mapBusinessCalendarManager = new MapBusinessCalendarManager();
        mapBusinessCalendarManager.addBusinessCalendar(DurationBusinessCalendar.NAME, new DurationBusinessCalendar(this.clock));
        mapBusinessCalendarManager.addBusinessCalendar(DueDateBusinessCalendar.NAME, new DueDateBusinessCalendar(this.clock));
        mapBusinessCalendarManager.addBusinessCalendar(CycleBusinessCalendar.NAME, new CycleBusinessCalendar(this.clock));
        businessCalendarManager = mapBusinessCalendarManager;
    }
}
Also used : DurationBusinessCalendar(org.activiti.engine.impl.calendar.DurationBusinessCalendar) MapBusinessCalendarManager(org.activiti.engine.impl.calendar.MapBusinessCalendarManager) DueDateBusinessCalendar(org.activiti.engine.impl.calendar.DueDateBusinessCalendar) CycleBusinessCalendar(org.activiti.engine.impl.calendar.CycleBusinessCalendar)

Example 2 with CycleBusinessCalendar

use of org.activiti.engine.impl.calendar.CycleBusinessCalendar in project Activiti by Activiti.

the class CycleBusinessCalendarTest method testSimpleCron.

public void testSimpleCron() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    CycleBusinessCalendar businessCalendar = new CycleBusinessCalendar(testingClock);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy MM dd - HH:mm");
    Date now = simpleDateFormat.parse("2011 03 11 - 17:23");
    testingClock.setCurrentTime(now);
    Date duedate = businessCalendar.resolveDuedate("0 0 0 1 * ?");
    Date expectedDuedate = simpleDateFormat.parse("2011 04 1 - 00:00");
    assertThat(duedate).isEqualTo(expectedDuedate);
}
Also used : DefaultClockImpl(org.activiti.engine.impl.util.DefaultClockImpl) CycleBusinessCalendar(org.activiti.engine.impl.calendar.CycleBusinessCalendar) Clock(org.activiti.engine.runtime.Clock) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 3 with CycleBusinessCalendar

use of org.activiti.engine.impl.calendar.CycleBusinessCalendar in project Activiti by Activiti.

the class MapBusinessCalendarManagerTest method testMapConstructor.

public void testMapConstructor() {
    Map<String, BusinessCalendar> calendars = new HashMap<String, BusinessCalendar>(1);
    CycleBusinessCalendar calendar = new CycleBusinessCalendar(null);
    calendars.put("someKey", calendar);
    MapBusinessCalendarManager businessCalendarManager = new MapBusinessCalendarManager(calendars);
    assertThat(businessCalendarManager.getBusinessCalendar("someKey").equals(calendar)).isTrue();
}
Also used : MapBusinessCalendarManager(org.activiti.engine.impl.calendar.MapBusinessCalendarManager) HashMap(java.util.HashMap) CycleBusinessCalendar(org.activiti.engine.impl.calendar.CycleBusinessCalendar) BusinessCalendar(org.activiti.engine.impl.calendar.BusinessCalendar) CycleBusinessCalendar(org.activiti.engine.impl.calendar.CycleBusinessCalendar)

Example 4 with CycleBusinessCalendar

use of org.activiti.engine.impl.calendar.CycleBusinessCalendar in project Activiti by Activiti.

the class CycleBusinessCalendarTest method testSimpleDuration.

public void testSimpleDuration() throws Exception {
    Clock testingClock = new DefaultClockImpl();
    CycleBusinessCalendar businessCalendar = new CycleBusinessCalendar(testingClock);
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy MM dd - HH:mm");
    Date now = simpleDateFormat.parse("2010 06 11 - 17:23");
    testingClock.setCurrentTime(now);
    Date duedate = businessCalendar.resolveDuedate("R/P2DT5H70M");
    Date expectedDuedate = simpleDateFormat.parse("2010 06 13 - 23:33");
    assertThat(duedate).isEqualTo(expectedDuedate);
}
Also used : DefaultClockImpl(org.activiti.engine.impl.util.DefaultClockImpl) CycleBusinessCalendar(org.activiti.engine.impl.calendar.CycleBusinessCalendar) Clock(org.activiti.engine.runtime.Clock) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

CycleBusinessCalendar (org.activiti.engine.impl.calendar.CycleBusinessCalendar)4 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 MapBusinessCalendarManager (org.activiti.engine.impl.calendar.MapBusinessCalendarManager)2 DefaultClockImpl (org.activiti.engine.impl.util.DefaultClockImpl)2 Clock (org.activiti.engine.runtime.Clock)2 HashMap (java.util.HashMap)1 BusinessCalendar (org.activiti.engine.impl.calendar.BusinessCalendar)1 DueDateBusinessCalendar (org.activiti.engine.impl.calendar.DueDateBusinessCalendar)1 DurationBusinessCalendar (org.activiti.engine.impl.calendar.DurationBusinessCalendar)1