use of org.jbpm.process.core.timer.BusinessCalendarImpl in project jbpm by kiegroup.
the class HumanTaskReassignmentTest method configureBusinessCalendar.
private void configureBusinessCalendar(boolean businessHour) {
Properties configuration = new Properties();
if (businessHour) {
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -1);
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
configuration.setProperty(BusinessCalendarImpl.START_HOUR, "0");
configuration.setProperty(BusinessCalendarImpl.END_HOUR, "24");
configuration.setProperty(BusinessCalendarImpl.HOURS_PER_DAY, "24");
configuration.setProperty(BusinessCalendarImpl.DAYS_PER_WEEK, "7");
configuration.setProperty(BusinessCalendarImpl.WEEKEND_DAYS, Integer.toString(dayOfWeek));
} else {
Date today = new Date();
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 1);
Date tomorrow = c.getTime();
String dateFormat = "yyyy-MM-dd";
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
configuration.setProperty(BusinessCalendarImpl.HOLIDAYS, sdf.format(today) + "," + sdf.format(tomorrow));
configuration.setProperty(BusinessCalendarImpl.HOLIDAY_DATE_FORMAT, dateFormat);
}
BusinessCalendar businessCalendar = new BusinessCalendarImpl(configuration);
ksession.getEnvironment().set("jbpm.business.calendar", businessCalendar);
}
use of org.jbpm.process.core.timer.BusinessCalendarImpl in project jbpm by kiegroup.
the class BusinessCalendarTest method configureBusinessCalendar.
private void configureBusinessCalendar(boolean businessHour) {
Properties configuration = new Properties();
if (businessHour) {
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, -1);
int dayOfWeek = c.get(Calendar.DAY_OF_WEEK);
configuration.setProperty(BusinessCalendarImpl.START_HOUR, "0");
configuration.setProperty(BusinessCalendarImpl.END_HOUR, "24");
configuration.setProperty(BusinessCalendarImpl.HOURS_PER_DAY, "24");
configuration.setProperty(BusinessCalendarImpl.DAYS_PER_WEEK, "7");
configuration.setProperty(BusinessCalendarImpl.WEEKEND_DAYS, Integer.toString(dayOfWeek));
} else {
Date today = new Date();
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 1);
Date tomorrow = c.getTime();
String dateFormat = "yyyy-MM-dd";
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
configuration.setProperty(BusinessCalendarImpl.HOLIDAYS, sdf.format(today) + "," + sdf.format(tomorrow));
configuration.setProperty(BusinessCalendarImpl.HOLIDAY_DATE_FORMAT, dateFormat);
}
BusinessCalendar businessCalendar = new BusinessCalendarImpl(configuration);
ksession.getEnvironment().set("jbpm.business.calendar", businessCalendar);
}
use of org.jbpm.process.core.timer.BusinessCalendarImpl in project jbpm by kiegroup.
the class BoundaryEventOnTaskWithCalendarTest method testProcessWithTimeCycleISO.
@Test(timeout = 10000)
public void testProcessWithTimeCycleISO() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("deadline1", 1);
addProcessEventListener(countDownListener);
createRuntimeManager("org/jbpm/test/functional/event/BoundaryEventWithCycleCalendar.bpmn2");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
ksession.getEnvironment().set("jbpm.business.calendar", new BusinessCalendarImpl() {
@Override
public long calculateBusinessTimeAsDuration(String timeExpression) {
timeExpression = adoptISOFormat(timeExpression);
return TimeUtils.parseTimeString(timeExpression);
}
@Override
public Date calculateBusinessTimeAsDate(String timeExpression) {
timeExpression = adoptISOFormat(timeExpression);
return new Date(TimeUtils.parseTimeString(getCurrentTime() + timeExpression));
}
});
HashMap<String, Object> params = new HashMap<String, Object>();
params.put("date", "R3/PT2S");
ProcessInstance processInstance = ksession.startProcess("boundaryTimer", params);
assertNodeTriggered(processInstance.getId(), "Start", "form1");
countDownListener.waitTillCompleted();
ProcessInstance pi = ksession.getProcessInstance(processInstance.getId());
assertNull(pi);
assertNodeTriggered(processInstance.getId(), "Koniec1");
assertProcessInstanceCompleted(processInstance.getId());
}
use of org.jbpm.process.core.timer.BusinessCalendarImpl in project jbpm by kiegroup.
the class BoundaryEventOnTaskWithCalendarTest method testProcess.
@Test(timeout = 10000)
public void testProcess() throws Exception {
NodeLeftCountDownProcessEventListener countDownListener = new NodeLeftCountDownProcessEventListener("deadline1", 1);
addProcessEventListener(countDownListener);
createRuntimeManager("org/jbpm/test/functional/event/BoundaryEventWithCalendar.bpmn2");
RuntimeEngine runtimeEngine = getRuntimeEngine();
KieSession ksession = runtimeEngine.getKieSession();
ksession.getEnvironment().set("jbpm.business.calendar", new BusinessCalendarImpl());
HashMap<String, Object> params = new HashMap<String, Object>();
OffsetDateTime plusTwoSeconds = OffsetDateTime.now().plusSeconds(2);
params.put("date", plusTwoSeconds.toString());
ProcessInstance processInstance = ksession.startProcess("boundaryTimer", params);
assertNodeTriggered(processInstance.getId(), "Start", "form1");
countDownListener.waitTillCompleted();
ProcessInstance pi = ksession.getProcessInstance(processInstance.getId());
assertNull(pi);
assertNodeTriggered(processInstance.getId(), "Koniec1");
assertProcessInstanceCompleted(processInstance.getId());
}
Aggregations