Search in sources :

Example 16 with HistoryService

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

the class ArchivedPage method createDetailComponent.

@Override
protected Component createDetailComponent(String id) {
    HistoryService historyService = ProcessEngines.getDefaultProcessEngine().getHistoryService();
    HistoricTaskInstance historicTaskInstance = historyService.createHistoricTaskInstanceQuery().taskId(id).singleResult();
    taskEventPanel.setTaskId(historicTaskInstance.getId());
    return new HistoricTaskDetailPanel(historicTaskInstance, this);
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoryService(org.activiti.engine.HistoryService)

Example 17 with HistoryService

use of org.activiti.engine.HistoryService in project midpoint by Evolveum.

the class ProcessInstanceManager method deleteProcessInstance.

private void deleteProcessInstance(String instanceId, OperationResult parentResult) {
    OperationResult result = parentResult.createSubresult(OPERATION_DELETE_PROCESS_INSTANCE);
    result.addParam("instanceId", instanceId);
    HistoryService hs = activitiEngine.getHistoryService();
    try {
        hs.deleteHistoricProcessInstance(instanceId);
    } catch (RuntimeException e) {
        result.recordFatalError("Process instance couldn't be deleted: " + e.getMessage(), e);
        throw e;
    } finally {
        result.computeStatusIfUnknown();
    }
}
Also used : HistoryService(org.activiti.engine.HistoryService) OperationResult(com.evolveum.midpoint.schema.result.OperationResult)

Example 18 with HistoryService

use of org.activiti.engine.HistoryService in project bamboobsc by billchen198318.

the class TestBPMN001 method queryHistory.

@Test
public void queryHistory() throws Exception {
    HistoryService historyService = (HistoryService) AppContext.getBean("historyService");
    List<HistoricTaskInstance> taskInstances = historyService.createHistoricTaskInstanceQuery().finished().list();
    for (HistoricTaskInstance taskInst : taskInstances) {
        System.out.println(taskInst.getId() + " , " + taskInst.getName() + " , " + taskInst.getFormKey() + " , " + taskInst.getAssignee());
    }
}
Also used : HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) HistoryService(org.activiti.engine.HistoryService) Test(org.junit.Test)

Example 19 with HistoryService

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

the class HistoricDetailService method getVariableFromRequest.

public RestVariable getVariableFromRequest(boolean includeBinary, String detailId) {
    Object value = null;
    HistoricVariableUpdate variableUpdate = null;
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    HistoricDetail detailObject = historyService.createHistoricDetailQuery().id(detailId).singleResult();
    if (detailObject instanceof HistoricVariableUpdate) {
        variableUpdate = (HistoricVariableUpdate) detailObject;
        value = variableUpdate.getValue();
    }
    if (value == null) {
        throw new ActivitiObjectNotFoundException("Historic detail '" + detailId + "' doesn't have a variable value.", VariableInstanceEntity.class);
    } else {
        return new RestResponseFactory().createRestVariable(variableUpdate.getVariableName(), value, null, detailId, RestResponseFactory.VARIABLE_HISTORY_DETAIL, includeBinary, uriInfo.getBaseUri().toString());
    }
}
Also used : HistoricVariableUpdate(org.activiti.engine.history.HistoricVariableUpdate) HistoricDetail(org.activiti.engine.history.HistoricDetail) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoryService(org.activiti.engine.HistoryService) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

Example 20 with HistoryService

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

the class HistoricTaskInstanceService method getVariableFromRequest.

protected RestVariable getVariableFromRequest(boolean includeBinary, String taskId, String variableName, String scope) {
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    RestVariable.RestVariableScope variableScope = RestVariable.getScopeFromString(scope);
    HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().taskId(taskId);
    if (variableScope != null) {
        if (variableScope == RestVariable.RestVariableScope.GLOBAL) {
            taskQuery.includeProcessVariables();
        } else {
            taskQuery.includeTaskLocalVariables();
        }
    } else {
        taskQuery.includeTaskLocalVariables().includeProcessVariables();
    }
    HistoricTaskInstance taskObject = taskQuery.singleResult();
    if (taskObject == null) {
        throw new ActivitiObjectNotFoundException("Historic task instance '" + taskId + "' couldn't be found.", HistoricTaskInstanceEntity.class);
    }
    Object value = null;
    if (variableScope != null) {
        if (variableScope == RestVariable.RestVariableScope.GLOBAL) {
            value = taskObject.getProcessVariables().get(variableName);
        } else {
            value = taskObject.getTaskLocalVariables().get(variableName);
        }
    } else {
        // look for local task restVariables first
        if (taskObject.getTaskLocalVariables().containsKey(variableName)) {
            value = taskObject.getTaskLocalVariables().get(variableName);
        } else {
            value = taskObject.getProcessVariables().get(variableName);
        }
    }
    if (value == null) {
        throw new ActivitiObjectNotFoundException("Historic task instance '" + taskId + "' variable value for " + variableName + " couldn't be found.", VariableInstanceEntity.class);
    } else {
        return new RestResponseFactory().createRestVariable(variableName, value, null, taskId, RestResponseFactory.VARIABLE_HISTORY_TASK, includeBinary, uriInfo.getBaseUri().toString());
    }
}
Also used : RestVariable(org.wso2.carbon.bpmn.rest.engine.variable.RestVariable) HistoricTaskInstance(org.activiti.engine.history.HistoricTaskInstance) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoryService(org.activiti.engine.HistoryService) HistoricTaskInstanceQuery(org.activiti.engine.history.HistoricTaskInstanceQuery) ActivitiObjectNotFoundException(org.activiti.engine.ActivitiObjectNotFoundException)

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