Java Code Examples for org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity#setEndTime()
The following examples show how to use
org.activiti.engine.impl.persistence.entity.HistoricProcessInstanceEntity#setEndTime() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ReOpenProcessCmd.java From lemon with Apache License 2.0 | 5 votes |
public Void execute(CommandContext commandContext) { HistoricProcessInstanceEntity historicProcessInstanceEntity = commandContext .getHistoricProcessInstanceEntityManager() .findHistoricProcessInstance(historicProcessInstanceId); if (historicProcessInstanceEntity.getEndTime() == null) { logger.info("historicProcessInstanceId is running"); return null; } historicProcessInstanceEntity.setEndActivityId(null); historicProcessInstanceEntity.setEndTime(null); String processDefinitionId = historicProcessInstanceEntity .getProcessDefinitionId(); String initiator = historicProcessInstanceEntity.getStartUserId(); String businessKey = historicProcessInstanceEntity.getBusinessKey(); ProcessDefinitionEntity processDefinition = new GetDeploymentProcessDefinitionCmd( processDefinitionId).execute(commandContext); // ExecutionEntity processInstance = processDefinition // .createProcessInstance(businessKey); ExecutionEntity processInstance = this.createProcessInstance( historicProcessInstanceEntity.getId(), businessKey, initiator, processDefinition); try { Authentication.setAuthenticatedUserId(initiator); // start processInstance.start(); } finally { Authentication.setAuthenticatedUserId(null); } return null; }
Example 2
Source File: JobServiceGetJobsTest.java From herd with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Test public void testGetJobsGivenOneCompletedJobAndPassingStartAndEndTimeAssertReturnCompletedJob() throws Exception { String namespace = "namespace"; String jobName = "jobName"; DateTime startTime = new DateTime(new Date(0123)); DateTime endTime = new DateTime(new Date(3456)); JobStatusEnum jobStatus = JobStatusEnum.COMPLETED; Set<String> authorizedNamespaces = new HashSet<>(Arrays.asList(namespace)); when(namespaceSecurityHelper.getAuthorizedNamespaces(any())).thenReturn(authorizedNamespaces); NamespaceEntity namespaceEntity = new NamespaceEntity(); namespaceEntity.setCode(namespace); when(namespaceDao.getNamespaceByCd(any())).thenReturn(namespaceEntity); List<JobDefinitionEntity> jobDefinitionEntities = new ArrayList<>(); JobDefinitionEntity jobDefinitionEntity1 = new JobDefinitionEntity(); jobDefinitionEntity1.setActivitiId(namespace + "." + jobName + ":1" + ":1"); jobDefinitionEntities.add(jobDefinitionEntity1); when(jobDefinitionDao.getJobDefinitionsByFilter(any(Collection.class), any())).thenReturn(jobDefinitionEntities); ProcessDefinition processDefinition = mock(ProcessDefinition.class); when(processDefinition.getId()).thenReturn("a.b:1:1"); when(processDefinition.getKey()).thenReturn("a.b"); when(activitiService.getProcessDefinitionsByIds(any())).thenReturn(asList(processDefinition)); when(activitiService.getHistoricProcessInstancesCountByStatusAndProcessDefinitionKeys(any(), any(), any(), any())).thenReturn(1l); List<HistoricProcessInstance> historicProcessInstances = new ArrayList<>(); HistoricProcessInstanceEntity historicProcessInstanceEntity1 = new HistoricProcessInstanceEntity(); historicProcessInstanceEntity1.setId("historicProcessInstanceEntity1.id"); historicProcessInstanceEntity1.setProcessDefinitionId("a.b:1:1"); historicProcessInstanceEntity1.setStartTime(new Date(1234)); historicProcessInstanceEntity1.setEndTime(new Date(2345)); historicProcessInstances.add(historicProcessInstanceEntity1); when(activitiService.getHistoricProcessInstancesByStatusAndProcessDefinitionKeys(any(), any(), any(), any())).thenReturn(historicProcessInstances); JobSummaries getJobsResult = jobServiceImpl.getJobs(namespace, jobName, jobStatus, startTime, endTime); List<JobSummary> jobSummaries = getJobsResult.getJobSummaries(); assertEquals(1, jobSummaries.size()); JobSummary jobSummary = jobSummaries.get(0); assertEquals(historicProcessInstanceEntity1.getId(), jobSummary.getId()); assertEquals("a", jobSummary.getNamespace()); assertEquals("b", jobSummary.getJobName()); assertEquals(JobStatusEnum.COMPLETED, jobSummary.getStatus()); assertEquals(historicProcessInstanceEntity1.getStartTime().getTime(), jobSummary.getStartTime().toGregorianCalendar().getTimeInMillis()); assertEquals(historicProcessInstanceEntity1.getEndTime().getTime(), jobSummary.getEndTime().toGregorianCalendar().getTimeInMillis()); assertEquals(0, jobSummary.getTotalExceptions()); verify(activitiService) .getHistoricProcessInstancesCountByStatusAndProcessDefinitionKeys(eq(JobStatusEnum.COMPLETED), any(), eq(startTime), eq(endTime)); verify(activitiService).getHistoricProcessInstancesByStatusAndProcessDefinitionKeys(eq(JobStatusEnum.COMPLETED), any(), eq(startTime), eq(endTime)); }