Search in sources :

Example 26 with HistoryService

use of org.activiti.engine.HistoryService in project carbon-business-process by wso2.

the class BPMNInstanceService method deleteAllCompletedInstances.

/**
 * Delete all completed instances
 */
public void deleteAllCompletedInstances() {
    Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
    HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
    HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString()).finished();
    for (HistoricProcessInstance instance : query.list()) {
        historyService.deleteHistoricProcessInstance(instance.getId());
    }
}
Also used : HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoryService(org.activiti.engine.HistoryService)

Example 27 with HistoryService

use of org.activiti.engine.HistoryService in project carbon-business-process by wso2.

the class BPMNInstanceService method deleteHistoryInstance.

/**
 * Delete history instance by instance ID
 * @param instanceId
 */
public void deleteHistoryInstance(String instanceId) {
    HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
    historyService.deleteHistoricProcessInstance(instanceId);
}
Also used : HistoryService(org.activiti.engine.HistoryService)

Example 28 with HistoryService

use of org.activiti.engine.HistoryService in project carbon-business-process by wso2.

the class BPMNInstanceService method getHistoryInstanceCount.

/**
 * Get total history instance count
 *
 * @return count int
 * @throws BPSFault
 */
public int getHistoryInstanceCount() throws BPSFault {
    if (historyInstanceCount == -1) {
        Integer tenantId = CarbonContext.getThreadLocalCarbonContext().getTenantId();
        HistoryService historyService = BPMNServerHolder.getInstance().getEngine().getHistoryService();
        HistoricProcessInstanceQuery query = historyService.createHistoricProcessInstanceQuery().processInstanceTenantId(tenantId.toString()).finished();
        historyInstanceCount = (int) query.count();
    }
    return historyInstanceCount;
}
Also used : HistoricProcessInstanceQuery(org.activiti.engine.history.HistoricProcessInstanceQuery) HistoryService(org.activiti.engine.HistoryService)

Example 29 with HistoryService

use of org.activiti.engine.HistoryService in project carbon-business-process by wso2.

the class ProcessTerminationListener method notify.

@Override
public void notify(DelegateExecution delegateExecution) throws Exception {
    // Process instance details have to be fetched from history service as some information such as process start time is not available from
    // runtime service or delegate execution.
    HistoryService historyService = delegateExecution.getEngineServices().getHistoryService();
    List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().processInstanceId(delegateExecution.getProcessInstanceId()).list();
    if (historicProcessInstances.size() == 1) {
        HistoricProcessInstance instance = historicProcessInstances.get(0);
        BPMNAnalyticsHolder.getInstance().getBpmnDataPublisher().publishProcessEvent(instance);
        // publishing analytics data of service tasks in the process
        if (BPMNAnalyticsHolder.getInstance().getAsyncDataPublishingEnabled()) {
            BPMNAnalyticsHolder.getInstance().getBpmnDataPublisher().publishServiceTaskEvent(historyService.createHistoricActivityInstanceQuery().processInstanceId(delegateExecution.getProcessInstanceId()));
        }
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoryService(org.activiti.engine.HistoryService)

Example 30 with HistoryService

use of org.activiti.engine.HistoryService in project Activiti by Activiti.

the class MyTransactionalOperationTransactionDependentTaskListener method notify.

@Override
public void notify(String processInstanceId, String executionId, Task task, Map<String, Object> executionVariables, Map<String, Object> customPropertiesMap) {
    super.notify(processInstanceId, executionId, task, executionVariables, customPropertiesMap);
    if (Context.getCommandContext().getProcessEngineConfiguration().getHistoryLevel().isAtLeast(HistoryLevel.ACTIVITY)) {
        HistoryService historyService = Context.getCommandContext().getProcessEngineConfiguration().getHistoryService();
        // delete first historic instance
        List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
        historyService.deleteHistoricProcessInstance(historicProcessInstances.get(0).getId());
    }
}
Also used : HistoricProcessInstance(org.activiti.engine.history.HistoricProcessInstance) HistoryService(org.activiti.engine.HistoryService)

Aggregations

HistoryService (org.activiti.engine.HistoryService)31 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)11 HistoricProcessInstance (org.activiti.engine.history.HistoricProcessInstance)10 ActivitiObjectNotFoundException (org.activiti.engine.ActivitiObjectNotFoundException)6 HistoricProcessInstanceQuery (org.activiti.engine.history.HistoricProcessInstanceQuery)6 HistoricTaskInstance (org.activiti.engine.history.HistoricTaskInstance)5 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)5 ArrayList (java.util.ArrayList)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 RuntimeService (org.activiti.engine.RuntimeService)4 HashMap (java.util.HashMap)3 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)3 Consumes (javax.ws.rs.Consumes)2 GET (javax.ws.rs.GET)2 POST (javax.ws.rs.POST)2 RepositoryService (org.activiti.engine.RepositoryService)2 HistoricActivityInstanceQuery (org.activiti.engine.history.HistoricActivityInstanceQuery)2 HistoricDetail (org.activiti.engine.history.HistoricDetail)2 HistoricDetailQuery (org.activiti.engine.history.HistoricDetailQuery)2