Search in sources :

Example 16 with HistoryService

use of org.camunda.bpm.engine.HistoryService in project camunda-bpm-platform by camunda.

the class RestartProcessInstancesCmd method resolveStartActivityInstance.

protected HistoricActivityInstance resolveStartActivityInstance(HistoricProcessInstance processInstance) {
    HistoryService historyService = Context.getProcessEngineConfiguration().getHistoryService();
    String processInstanceId = processInstance.getId();
    String startActivityId = processInstance.getStartActivityId();
    ensureNotNull("startActivityId", startActivityId);
    List<HistoricActivityInstance> historicActivityInstances = historyService.createHistoricActivityInstanceQuery().processInstanceId(processInstanceId).activityId(startActivityId).orderPartiallyByOccurrence().asc().list();
    ensureNotEmpty("historicActivityInstances", historicActivityInstances);
    HistoricActivityInstance startActivityInstance = historicActivityInstances.get(0);
    return startActivityInstance;
}
Also used : HistoryService(org.camunda.bpm.engine.HistoryService) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance)

Example 17 with HistoryService

use of org.camunda.bpm.engine.HistoryService in project camunda-bpm-platform by camunda.

the class RestartProcessInstancesCmd method collectInitialVariables.

protected VariableMap collectInitialVariables(CommandContext commandContext, HistoricProcessInstance processInstance) {
    HistoryService historyService = commandContext.getProcessEngineConfiguration().getHistoryService();
    HistoricActivityInstance startActivityInstance = resolveStartActivityInstance(processInstance);
    HistoricDetailQueryImpl query = (HistoricDetailQueryImpl) historyService.createHistoricDetailQuery().variableUpdates().executionId(processInstance.getId()).activityInstanceId(startActivityInstance.getId());
    List<HistoricDetail> historicDetails = query.sequenceCounter(1).list();
    VariableMap variables = new VariableMapImpl();
    for (HistoricDetail detail : historicDetails) {
        HistoricVariableUpdate variableUpdate = (HistoricVariableUpdate) detail;
        variables.putValueTyped(variableUpdate.getVariableName(), variableUpdate.getTypedValue());
    }
    return variables;
}
Also used : HistoricVariableUpdate(org.camunda.bpm.engine.history.HistoricVariableUpdate) HistoricDetail(org.camunda.bpm.engine.history.HistoricDetail) VariableMapImpl(org.camunda.bpm.engine.variable.impl.VariableMapImpl) VariableMap(org.camunda.bpm.engine.variable.VariableMap) HistoricDetailQueryImpl(org.camunda.bpm.engine.impl.HistoricDetailQueryImpl) HistoryService(org.camunda.bpm.engine.HistoryService) HistoricActivityInstance(org.camunda.bpm.engine.history.HistoricActivityInstance)

Example 18 with HistoryService

use of org.camunda.bpm.engine.HistoryService in project camunda-bpm-platform by camunda.

the class TestHelper method clearUserOperationLog.

public static void clearUserOperationLog(ProcessEngineConfigurationImpl processEngineConfiguration) {
    if (processEngineConfiguration.getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_FULL)) {
        HistoryService historyService = processEngineConfiguration.getHistoryService();
        List<UserOperationLogEntry> logs = historyService.createUserOperationLogQuery().list();
        for (UserOperationLogEntry log : logs) {
            historyService.deleteUserOperationLogEntry(log.getId());
        }
    }
}
Also used : UserOperationLogEntry(org.camunda.bpm.engine.history.UserOperationLogEntry) HistoryService(org.camunda.bpm.engine.HistoryService)

Example 19 with HistoryService

use of org.camunda.bpm.engine.HistoryService in project camunda-bpm-platform by camunda.

the class HistoricBatchQueryAuthorizationTest method removeAllRunningAndHistoricBatches.

private void removeAllRunningAndHistoricBatches() {
    HistoryService historyService = engineRule.getHistoryService();
    ManagementService managementService = engineRule.getManagementService();
    for (Batch batch : managementService.createBatchQuery().list()) {
        managementService.deleteBatch(batch.getId(), true);
    }
    // remove history of completed batches
    for (HistoricBatch historicBatch : historyService.createHistoricBatchQuery().list()) {
        historyService.deleteHistoricBatch(historicBatch.getId());
    }
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) ManagementService(org.camunda.bpm.engine.ManagementService) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) HistoryService(org.camunda.bpm.engine.HistoryService)

Example 20 with HistoryService

use of org.camunda.bpm.engine.HistoryService in project camunda-bpm-platform by camunda.

the class SetExternalTaskRetriesUserOperationLogTest method removeAllRunningAndHistoricBatches.

@After
public void removeAllRunningAndHistoricBatches() {
    HistoryService historyService = rule.getHistoryService();
    ManagementService managementService = rule.getManagementService();
    for (Batch batch : managementService.createBatchQuery().list()) {
        managementService.deleteBatch(batch.getId(), true);
    }
    // remove history of completed batches
    for (HistoricBatch historicBatch : historyService.createHistoricBatchQuery().list()) {
        historyService.deleteHistoricBatch(historicBatch.getId());
    }
}
Also used : HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) ManagementService(org.camunda.bpm.engine.ManagementService) HistoricBatch(org.camunda.bpm.engine.batch.history.HistoricBatch) Batch(org.camunda.bpm.engine.batch.Batch) HistoryService(org.camunda.bpm.engine.HistoryService) After(org.junit.After)

Aggregations

HistoryService (org.camunda.bpm.engine.HistoryService)23 InvalidRequestException (org.camunda.bpm.engine.rest.exception.InvalidRequestException)9 ManagementService (org.camunda.bpm.engine.ManagementService)5 Batch (org.camunda.bpm.engine.batch.Batch)4 ArrayList (java.util.ArrayList)3 HistoricBatch (org.camunda.bpm.engine.batch.history.HistoricBatch)3 HistoricActivityInstance (org.camunda.bpm.engine.history.HistoricActivityInstance)3 HistoricVariableInstance (org.camunda.bpm.engine.history.HistoricVariableInstance)3 VariableMap (org.camunda.bpm.engine.variable.VariableMap)3 List (java.util.List)2 FormService (org.camunda.bpm.engine.FormService)2 RepositoryService (org.camunda.bpm.engine.RepositoryService)2 TaskService (org.camunda.bpm.engine.TaskService)2 HistoricVariableUpdate (org.camunda.bpm.engine.history.HistoricVariableUpdate)2 VariableMapImpl (org.camunda.bpm.engine.variable.impl.VariableMapImpl)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1 Date (java.util.Date)1 ProcessApplicationService (org.camunda.bpm.ProcessApplicationService)1 ProcessApplicationInfo (org.camunda.bpm.application.ProcessApplicationInfo)1