use of org.activiti.engine.HistoryService in project carbon-business-process by wso2.
the class BPMNInstanceService method deleteProcessInstance.
/**
* Delete process instance by passing instance ID
*
* @param instanceId
* @throws BPSFault
*/
public void deleteProcessInstance(String instanceId) throws BPSFault {
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
RuntimeService runtimeService = BPMNServerHolder.getInstance().getEngine().getRuntimeService();
List<ProcessInstance> processInstances = runtimeService.createProcessInstanceQuery().processInstanceTenantId(tenantId.toString()).processInstanceId(instanceId).list();
if (processInstances.isEmpty()) {
HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString()).processInstanceId(instanceId).list();
if (historicProcessInstances.isEmpty()) {
String msg = "No process instances with the ID: " + instanceId;
log.error(msg);
throw new BPSFault(msg);
}
historyService.deleteHistoricProcessInstance(instanceId);
return;
}
runtimeService.deleteProcessInstance(instanceId, "Deleted by user: " + tenantId);
}
use of org.activiti.engine.HistoryService in project carbon-business-process by wso2.
the class BPMNInstanceService method getPaginatedHistoryInstances.
/**
* Get paginated history instances
*
* @param start
* @param size
* @return list of BPMNInstances
*/
public BPMNInstance[] getPaginatedHistoryInstances(int start, int size) {
BPMNInstance bpmnInstance;
Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
List<BPMNInstance> bpmnInstances = new ArrayList<>();
HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString()).finished().includeProcessVariables();
historyInstanceCount = (int) query.count();
List<HistoricProcessInstance> historicProcessInstances = query.listPage(start, size);
for (HistoricProcessInstance instance : historicProcessInstances) {
bpmnInstance = new BPMNInstance();
bpmnInstance.setInstanceId(instance.getId());
bpmnInstance.setProcessId(instance.getProcessDefinitionId());
bpmnInstance.setStartTime(instance.getStartTime());
bpmnInstance.setEndTime(instance.getEndTime());
bpmnInstance.setVariables(formatVariables(instance.getProcessVariables()));
bpmnInstances.add(bpmnInstance);
}
return bpmnInstances.toArray(new BPMNInstance[bpmnInstances.size()]);
}
use of org.activiti.engine.HistoryService in project carbon-business-process by wso2.
the class HistoricTaskInstanceService method deleteTaskInstance.
@DELETE
@Path("/{taskId}")
public Response deleteTaskInstance(@PathParam("taskId") String taskId) {
HistoryService historyService = BPMNOSGIService.getHistoryService();
historyService.deleteHistoricTaskInstance(taskId);
return Response.ok().status(Response.Status.NO_CONTENT).build();
}
use of org.activiti.engine.HistoryService in project carbon-business-process by wso2.
the class HistoricTaskInstanceService method getTaskIdentityLinks.
@GET
@Path("/{taskId}/identitylinks")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getTaskIdentityLinks(@PathParam("taskId") String taskId) {
HistoryService historyService = BPMNOSGIService.getHistoryService();
List<HistoricIdentityLink> identityLinks = historyService.getHistoricIdentityLinksForTask(taskId);
List<HistoricIdentityLinkResponse> historicIdentityLinkResponseList = new ArrayList<>();
if (identityLinks != null) {
historicIdentityLinkResponseList = new RestResponseFactory().createHistoricIdentityLinkResponseList(identityLinks, uriInfo.getBaseUri().toString());
}
HistoricIdentityLinkResponseCollection historicIdentityLinkResponseCollection = new HistoricIdentityLinkResponseCollection();
historicIdentityLinkResponseCollection.setHistoricIdentityLinkResponses(historicIdentityLinkResponseList);
return Response.ok().entity(historicIdentityLinkResponseCollection).build();
}
use of org.activiti.engine.HistoryService in project carbon-business-process by wso2.
the class HistoricVariableInstanceService method getVariableFromRequest.
protected RestVariable getVariableFromRequest(boolean includeBinary, String varInstanceId) {
HistoryService historyService = BPMNOSGIService.getHistoryService();
HistoricVariableInstance varObject = historyService.createHistoricVariableInstanceQuery().id(varInstanceId).singleResult();
if (varObject == null) {
throw new ActivitiObjectNotFoundException("Historic variable instance '" + varInstanceId + "' couldn't be found.", VariableInstanceEntity.class);
} else {
return new RestResponseFactory().createRestVariable(varObject.getVariableName(), varObject.getValue(), null, varInstanceId, RestResponseFactory.VARIABLE_HISTORY_VARINSTANCE, includeBinary, uriInfo.getBaseUri().toString());
}
}
Aggregations