Search in sources :

Example 1 with HistoricDetailQuery

use of org.activiti.engine.history.HistoricDetailQuery in project midpoint by Evolveum.

the class ActivitiInterface method queryActivitiProcessInstance.

public void queryActivitiProcessInstance(QueryProcessCommand qpc, Task task, OperationResult result) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException {
    String pid = qpc.getPid();
    LOGGER.trace("Querying process instance id {}", pid);
    HistoryService hs = activitiEngine.getHistoryService();
    HistoricDetailQuery hdq = hs.createHistoricDetailQuery().variableUpdates().processInstanceId(pid).orderByTime().desc();
    Map<String, Object> variables = new HashMap<>();
    for (HistoricDetail hd : hdq.list()) {
        HistoricVariableUpdate hvu = (HistoricVariableUpdate) hd;
        String varname = hvu.getVariableName();
        Object value = hvu.getValue();
        LOGGER.trace(" - found historic variable update: {} <- {}", varname, value);
        if (!variables.containsKey(varname)) {
            variables.put(varname, value);
        }
    }
    HistoricDetailQuery hdq2 = hs.createHistoricDetailQuery().formProperties().processInstanceId(pid).orderByVariableRevision().desc();
    for (HistoricDetail hd : hdq2.list()) {
        HistoricFormProperty hfp = (HistoricFormProperty) hd;
        String varname = hfp.getPropertyId();
        Object value = hfp.getPropertyValue();
        LOGGER.trace(" - found historic form property: {} <- {}", varname, value);
        variables.put(varname, value);
    }
    QueryProcessResponse qpr = new QueryProcessResponse(pid, variables, processInterfaceFinder);
    ProcessInstance pi = activitiEngine.getProcessEngine().getRuntimeService().createProcessInstanceQuery().processInstanceId(pid).singleResult();
    qpr.setRunning(pi != null && !pi.isEnded());
    LOGGER.trace("Running process instance = {}, isRunning: {}", pi, qpr.isRunning());
    LOGGER.trace("Response to be sent to midPoint: {}", qpr);
    wfTaskController.onProcessEvent(qpr, task, result);
}
Also used : HistoricVariableUpdate(org.activiti.engine.history.HistoricVariableUpdate) HistoricDetail(org.activiti.engine.history.HistoricDetail) HistoricFormProperty(org.activiti.engine.history.HistoricFormProperty) HashMap(java.util.HashMap) HistoryService(org.activiti.engine.HistoryService) ProcessInstance(org.activiti.engine.runtime.ProcessInstance) HistoricDetailQuery(org.activiti.engine.history.HistoricDetailQuery)

Example 2 with HistoricDetailQuery

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

the class BaseHistoricDetailService method getQueryResponse.

protected DataResponse getQueryResponse(HistoricDetailQueryRequest queryRequest, Map<String, String> allRequestParams, UriInfo uriInfo) {
    HistoryService historyService = BPMNOSGIService.getHistoryService();
    HistoricDetailQuery query = historyService.createHistoricDetailQuery();
    // Populate query based on request
    if (queryRequest.getProcessInstanceId() != null) {
        query.processInstanceId(queryRequest.getProcessInstanceId());
    }
    if (queryRequest.getExecutionId() != null) {
        query.executionId(queryRequest.getExecutionId());
    }
    if (queryRequest.getActivityInstanceId() != null) {
        query.activityInstanceId(queryRequest.getActivityInstanceId());
    }
    if (queryRequest.getTaskId() != null) {
        query.taskId(queryRequest.getTaskId());
    }
    if (queryRequest.getSelectOnlyFormProperties() != null) {
        if (queryRequest.getSelectOnlyFormProperties()) {
            query.formProperties();
        }
    }
    if (queryRequest.getSelectOnlyVariableUpdates() != null) {
        if (queryRequest.getSelectOnlyVariableUpdates()) {
            query.variableUpdates();
        }
    }
    return new HistoricDetailPaginateList(new RestResponseFactory(), uriInfo).paginateList(allRequestParams, queryRequest, query, "processInstanceId", allowedSortProperties);
}
Also used : HistoricDetailPaginateList(org.wso2.carbon.bpmn.rest.model.history.HistoricDetailPaginateList) RestResponseFactory(org.wso2.carbon.bpmn.rest.common.RestResponseFactory) HistoryService(org.activiti.engine.HistoryService) HistoricDetailQuery(org.activiti.engine.history.HistoricDetailQuery)

Aggregations

HistoryService (org.activiti.engine.HistoryService)2 HistoricDetailQuery (org.activiti.engine.history.HistoricDetailQuery)2 HashMap (java.util.HashMap)1 HistoricDetail (org.activiti.engine.history.HistoricDetail)1 HistoricFormProperty (org.activiti.engine.history.HistoricFormProperty)1 HistoricVariableUpdate (org.activiti.engine.history.HistoricVariableUpdate)1 ProcessInstance (org.activiti.engine.runtime.ProcessInstance)1 RestResponseFactory (org.wso2.carbon.bpmn.rest.common.RestResponseFactory)1 HistoricDetailPaginateList (org.wso2.carbon.bpmn.rest.model.history.HistoricDetailPaginateList)1