event.setExecutionId(((Job) persistedObject).getExecutionId()); event.setProcessInstanceId(((Job) persistedObject).getProcessInstanceId()); event.setProcessDefinitionId(((Job) persistedObject).getProcessDefinitionId()); } else if (persistedObject instanceof DelegateExecution) { event.setExecutionId(((DelegateExecution) persistedObject).getId());
public void buttonClick(ClickEvent event) { if (isSuspendedProcessDefinition) { ExplorerApp.get().getViewManager().showSuspendedProcessDefinitionsPage(job.getProcessDefinitionId()); } else { ExplorerApp.get().getViewManager().showActiveProcessDefinitionsPage(job.getProcessDefinitionId()); } } });
protected boolean isHandledByActiviti5Engine() { boolean isActiviti5ProcessDefinition = Activiti5Util.isActiviti5ProcessDefinitionId(processEngineConfiguration, job.getProcessDefinitionId()); if (isActiviti5ProcessDefinition) { return processEngineConfiguration.getCommandExecutor().execute(new Command<Boolean>() { @Override public Boolean execute(CommandContext commandContext) { commandContext.getProcessEngineConfiguration().getActiviti5CompatibilityHandler().executeJobWithLockAndRetry(job); return true; } }); } return false; }
@Override public Void execute(CommandContext commandContext) { if (job.getProcessDefinitionId() != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, job.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); activiti5CompatibilityHandler.handleFailedJob(job, exception); return null; } CommandConfig commandConfig = processEngineConfiguration.getCommandExecutor().getDefaultConfig().transactionRequiresNew(); FailedJobCommandFactory failedJobCommandFactory = commandContext.getFailedJobCommandFactory(); Command<Object> cmd = failedJobCommandFactory.getCommand(job.getId(), exception); log.trace("Using FailedJobCommandFactory '" + failedJobCommandFactory.getClass() + "' and command of type '" + cmd.getClass() + "'"); processEngineConfiguration.getCommandExecutor().execute(commandConfig, cmd); // Dispatch an event, indicating job execution failed in a // try-catch block, to prevent the original exception to be swallowed if (commandContext.getEventDispatcher().isEnabled()) { try { commandContext.getEventDispatcher().dispatchEvent(ActivitiEventBuilder.createEntityExceptionEvent(ActivitiEventType.JOB_EXECUTION_FAILURE, job, exception)); } catch (Throwable ignore) { log.warn("Exception occurred while dispatching job failure event, ignoring.", ignore); } } return null; }
public Object execute(CommandContext commandContext) { if (jobId == null) { throw new ActivitiIllegalArgumentException("jobId and job is null"); } Job job = commandContext.getJobEntityManager().findById(jobId); if (job == null) { throw new JobNotFoundException(jobId); } if (log.isDebugEnabled()) { log.debug("Executing job {}", job.getId()); } if (job.getProcessDefinitionId() != null && Activiti5Util.isActiviti5ProcessDefinitionId(commandContext, job.getProcessDefinitionId())) { Activiti5CompatibilityHandler activiti5CompatibilityHandler = Activiti5Util.getActiviti5CompatibilityHandler(); activiti5CompatibilityHandler.executeJob(job); return null; } commandContext.addCloseListener(new FailedJobListener(commandContext.getProcessEngineConfiguration().getCommandExecutor(), job)); try { commandContext.getJobManager().execute(job); } catch (Throwable exception) { // Finally, Throw the exception to indicate the ExecuteJobCmd failed throw new ActivitiException("Job " + jobId + " failed", exception); } return null; }
public JobResponse createJobResponse(Job job, RestUrlBuilder urlBuilder) { JobResponse response = new JobResponse(); response.setId(job.getId()); response.setDueDate(job.getDuedate()); response.setExceptionMessage(job.getExceptionMessage()); response.setExecutionId(job.getExecutionId()); response.setProcessDefinitionId(job.getProcessDefinitionId()); response.setProcessInstanceId(job.getProcessInstanceId()); response.setRetries(job.getRetries()); response.setTenantId(job.getTenantId()); response.setUrl(urlBuilder.buildUrl(RestUrls.URL_JOB, job.getId())); if (job.getProcessDefinitionId() != null) { response.setProcessDefinitionUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION, job.getProcessDefinitionId())); } if (job.getProcessInstanceId() != null) { response.setProcessInstanceUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE, job.getProcessInstanceId())); } if (job.getExecutionId() != null) { response.setExecutionUrl(urlBuilder.buildUrl(RestUrls.URL_EXECUTION, job.getExecutionId())); } return response; }
protected void addLinkToProcessDefinition(final VerticalLayout verticalLayout, final String labelText, final boolean isSuspendedProcessDefinition) { HorizontalLayout layout = new HorizontalLayout(); verticalLayout.addComponent(layout); Label processDefinitionLabel = new Label(labelText); processDefinitionLabel.setSizeUndefined(); layout.addComponent(processDefinitionLabel); layout.addComponent(new Label(" ", Label.CONTENT_XHTML)); Button showProcessDefinitionLink = new Button(job.getProcessDefinitionId()); showProcessDefinitionLink.addStyleName(Reindeer.BUTTON_LINK); showProcessDefinitionLink.addListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { if (isSuspendedProcessDefinition) { ExplorerApp.get().getViewManager().showSuspendedProcessDefinitionsPage(job.getProcessDefinitionId()); } else { ExplorerApp.get().getViewManager().showActiveProcessDefinitionsPage(job.getProcessDefinitionId()); } } }); layout.addComponent(showProcessDefinitionLink); }
} else { if (job.getProcessDefinitionId() != null) {
event.setExecutionId(((Job) persistedObject).getExecutionId()); event.setProcessInstanceId(((Job) persistedObject).getProcessInstanceId()); event.setProcessDefinitionId(((Job) persistedObject).getProcessDefinitionId()); } else if (persistedObject instanceof DelegateExecution) { event.setExecutionId(((DelegateExecution) persistedObject).getId());