use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class ProcessDefinitionInfoComponent method initSuspensionStateInformation.
protected void initSuspensionStateInformation() {
List<Job> jobs = managementService.createJobQuery().processDefinitionId(processDefinition.getId()).orderByJobDuedate().asc().list();
List<JobEntity> suspensionStateJobs = new ArrayList<JobEntity>();
// TODO: this is a hack (ie the cast to JobEntity)... we must clean this in the engine!
for (Job job : jobs) {
JobEntity jobEntity = (JobEntity) job;
if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE) || jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) {
suspensionStateJobs.add(jobEntity);
}
}
if (!suspensionStateJobs.isEmpty()) {
// Header
Label suspensionStateTitle = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_SUSPENSION_STATE));
suspensionStateTitle.addStyleName(ExplorerLayout.STYLE_H3);
addComponent(suspensionStateTitle);
addEmptySpace(this);
// Actual suspend/activation jobs
for (JobEntity jobEntity : suspensionStateJobs) {
if (jobEntity.getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)) {
Label suspendLabel = new Label(i18nManager.getMessage(Messages.PROCESS_SCHEDULED_SUSPEND, Constants.DEFAULT_TIME_FORMATTER.format(jobEntity.getDuedate())), Label.CONTENT_XHTML);
addComponent(suspendLabel);
} else if (jobEntity.getJobHandlerType().equals(TimerActivateProcessDefinitionHandler.TYPE)) {
Label suspendLabel = new Label(i18nManager.getMessage(Messages.PROCESS_SCHEDULED_ACTIVATE, Constants.DEFAULT_TIME_FORMATTER.format(jobEntity.getDuedate())), Label.CONTENT_XHTML);
addComponent(suspendLabel);
}
}
}
addEmptySpace(this);
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class ActiveProcessDefinitionDetailPanel method initActions.
protected void initActions(final AbstractPage parentPage) {
ActiveProcessDefinitionPage processDefinitionPage = (ActiveProcessDefinitionPage) parentPage;
Button suspendButton = new Button(i18nManager.getMessage(Messages.PROCESS_SUSPEND));
suspendButton.addListener(new ClickListener() {
private static final long serialVersionUID = 1L;
public void buttonClick(ClickEvent event) {
ChangeProcessSuspensionStatePopupWindow popupWindow = new ChangeProcessSuspensionStatePopupWindow(processDefinition.getId(), parentPage, true);
ExplorerApp.get().getViewManager().showPopupWindow(popupWindow);
}
});
// Check if button must be disabled
boolean suspendJobPending = false;
List<Job> jobs = ProcessEngines.getDefaultProcessEngine().getManagementService().createJobQuery().processDefinitionId(processDefinition.getId()).list();
for (Job job : jobs) {
// TODO: this is a hack. Needs to be cleaner in engine!
if (((JobEntity) job).getJobHandlerType().equals(TimerSuspendProcessDefinitionHandler.TYPE)) {
suspendJobPending = true;
break;
}
}
suspendButton.setEnabled(!suspendJobPending);
// Clear toolbar and add 'start' button
processDefinitionPage.getToolBar().removeAllButtons();
processDefinitionPage.getToolBar().addButton(suspendButton);
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class ProcessInstanceSuspensionTest method testJobNotExecutedAfterProcessInstanceSuspend.
@Deployment
public void testJobNotExecutedAfterProcessInstanceSuspend() {
Date now = new Date();
processEngineConfiguration.getClock().setCurrentTime(now);
// Suspending the process instance should also stop the execution of jobs for that process instance
ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processDefinition.getId());
assertEquals(1, managementService.createJobQuery().count());
runtimeService.suspendProcessInstanceById(processInstance.getId());
assertEquals(1, managementService.createJobQuery().count());
// The jobs should not be executed now
// Timer is set to fire on 5 minutes
processEngineConfiguration.getClock().setCurrentTime(new Date(now.getTime() + (60 * 60 * 1000)));
Job job = managementService.createJobQuery().executable().singleResult();
assertNull(job);
assertEquals(1, managementService.createJobQuery().count());
// Activation of the process instance should now allow for job execution
runtimeService.activateProcessInstanceById(processInstance.getId());
waitForJobExecutorToProcessAllJobs(1000L, 100L);
assertEquals(0, managementService.createJobQuery().count());
assertEquals(0, runtimeService.createProcessInstanceQuery().count());
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class JobExceptionStacktraceResource method getJobStacktrace.
@RequestMapping(value = "/management/jobs/{jobId}/exception-stacktrace", method = RequestMethod.GET)
public String getJobStacktrace(@PathVariable String jobId, HttpServletResponse response) {
Job job = getJobFromResponse(jobId);
String stackTrace = managementService.getJobExceptionStacktrace(job.getId());
if (stackTrace == null) {
throw new ActivitiObjectNotFoundException("Job with id '" + job.getId() + "' doesn't have an exception stacktrace.", String.class);
}
response.setContentType("text/plain");
return stackTrace;
}
use of org.activiti.engine.runtime.Job in project Activiti by Activiti.
the class TimerEventsAndNewVersionDeploymentsTest method testTimerRestoreOnDeploymentDelete1.
public void testTimerRestoreOnDeploymentDelete1() {
String deploymentId1 = deployTimerProcess();
// Process has same key
String deploymentId2 = deployProcessWithoutTimers();
String deploymentId3 = deployTimerProcess();
String deploymentId4 = deployProcessWithoutTimers();
assertTimerJobs(0);
repositoryService.deleteDeployment(deploymentId4, true);
assertTimerJobs(1);
Job job = managementService.createJobQuery().singleResult();
assertEquals(repositoryService.createProcessDefinitionQuery().deploymentId(deploymentId3).singleResult().getId(), job.getProcessDefinitionId());
cleanup(deploymentId1, deploymentId2, deploymentId3);
}
Aggregations