Search in sources :

Example 6 with HistoricDecisionInstance

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

the class HistoricDecisionInstanceManager method findHistoricDecisionInstancesByQueryCriteria.

public List<HistoricDecisionInstance> findHistoricDecisionInstancesByQueryCriteria(HistoricDecisionInstanceQueryImpl query, Page page) {
    if (isHistoryEnabled()) {
        configureQuery(query);
        @SuppressWarnings("unchecked") List<HistoricDecisionInstance> decisionInstances = getDbEntityManager().selectList("selectHistoricDecisionInstancesByQueryCriteria", query, page);
        Map<String, HistoricDecisionInstanceEntity> decisionInstancesById = new HashMap<String, HistoricDecisionInstanceEntity>();
        for (HistoricDecisionInstance decisionInstance : decisionInstances) {
            decisionInstancesById.put(decisionInstance.getId(), (HistoricDecisionInstanceEntity) decisionInstance);
        }
        if (!decisionInstances.isEmpty() && query.isIncludeInput()) {
            appendHistoricDecisionInputInstances(decisionInstancesById, query);
        }
        if (!decisionInstances.isEmpty() && query.isIncludeOutputs()) {
            appendHistoricDecisionOutputInstances(decisionInstancesById, query);
        }
        return decisionInstances;
    } else {
        return Collections.emptyList();
    }
}
Also used : HashMap(java.util.HashMap) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance)

Example 7 with HistoricDecisionInstance

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

the class HistoricDecisionInstanceAuthorizationTest method testDeleteHistoricDecisionInstanceByInstanceIdWithDeleteHistoryPermissionOnDecisionDefinition.

public void testDeleteHistoricDecisionInstanceByInstanceIdWithDeleteHistoryPermissionOnDecisionDefinition() {
    // given
    createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, DELETE_HISTORY, READ_HISTORY);
    startProcessInstanceAndEvaluateDecision();
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
    verifyQueryResults(query, 1);
    HistoricDecisionInstance historicDecisionInstance = query.includeInputs().includeOutputs().singleResult();
    // when
    historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
    // then
    verifyQueryResults(query, 0);
}
Also used : HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)

Example 8 with HistoricDecisionInstance

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

the class HistoricDecisionInstanceAuthorizationTest method testDeleteHistoricDecisionInstanceByInstanceIdWithoutAuthorization.

public void testDeleteHistoricDecisionInstanceByInstanceIdWithoutAuthorization() {
    // given
    createGrantAuthorization(DECISION_DEFINITION, DECISION_DEFINITION_KEY, userId, READ_HISTORY);
    startProcessInstanceAndEvaluateDecision();
    HistoricDecisionInstanceQuery query = historyService.createHistoricDecisionInstanceQuery();
    HistoricDecisionInstance historicDecisionInstance = query.includeInputs().includeOutputs().singleResult();
    try {
        // when
        historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
        fail("expect authorization exception");
    } catch (AuthorizationException e) {
        // then
        assertThat(e.getMessage(), is("The user with id 'test' does not have 'DELETE_HISTORY' permission on resource 'testDecision' of type 'DecisionDefinition'."));
    }
}
Also used : AuthorizationException(org.camunda.bpm.engine.AuthorizationException) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) HistoricDecisionInstanceQuery(org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)

Example 9 with HistoricDecisionInstance

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

the class HistoryCleanupAuthorizationTest method clearDatabase.

protected void clearDatabase() {
    // reset configuration changes
    String defaultStartTime = processEngineConfiguration.getHistoryCleanupBatchWindowStartTime();
    String defaultEndTime = processEngineConfiguration.getHistoryCleanupBatchWindowEndTime();
    int defaultBatchSize = processEngineConfiguration.getHistoryCleanupBatchSize();
    processEngineConfiguration.setHistoryCleanupBatchWindowStartTime(defaultStartTime);
    processEngineConfiguration.setHistoryCleanupBatchWindowEndTime(defaultEndTime);
    processEngineConfiguration.setHistoryCleanupBatchSize(defaultBatchSize);
    processEngineConfiguration.getCommandExecutorTxRequired().execute(new Command<Void>() {

        public Void execute(CommandContext commandContext) {
            List<Job> jobs = managementService.createJobQuery().list();
            if (jobs.size() > 0) {
                assertEquals(1, jobs.size());
                String jobId = jobs.get(0).getId();
                commandContext.getJobManager().deleteJob((JobEntity) jobs.get(0));
                commandContext.getHistoricJobLogManager().deleteHistoricJobLogByJobId(jobId);
            }
            List<HistoricIncident> historicIncidents = historyService.createHistoricIncidentQuery().list();
            for (HistoricIncident historicIncident : historicIncidents) {
                commandContext.getDbEntityManager().delete((HistoricIncidentEntity) historicIncident);
            }
            commandContext.getMeterLogManager().deleteAll();
            return null;
        }
    });
    List<HistoricProcessInstance> historicProcessInstances = historyService.createHistoricProcessInstanceQuery().list();
    for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
        historyService.deleteHistoricProcessInstance(historicProcessInstance.getId());
    }
    List<HistoricDecisionInstance> historicDecisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
    for (HistoricDecisionInstance historicDecisionInstance : historicDecisionInstances) {
        historyService.deleteHistoricDecisionInstanceByInstanceId(historicDecisionInstance.getId());
    }
    List<HistoricCaseInstance> historicCaseInstances = historyService.createHistoricCaseInstanceQuery().list();
    for (HistoricCaseInstance historicCaseInstance : historicCaseInstances) {
        historyService.deleteHistoricCaseInstance(historicCaseInstance.getId());
    }
}
Also used : CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) HistoricProcessInstance(org.camunda.bpm.engine.history.HistoricProcessInstance) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance) JobEntity(org.camunda.bpm.engine.impl.persistence.entity.JobEntity) HistoricIncident(org.camunda.bpm.engine.history.HistoricIncident) HistoricIncidentEntity(org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity) HistoricCaseInstance(org.camunda.bpm.engine.history.HistoricCaseInstance) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with HistoricDecisionInstance

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

the class BulkHistoryDeleteDecisionInstancesAuthorizationTest method prepareHistoricDecisions.

private List<String> prepareHistoricDecisions() {
    for (int i = 0; i < 5; i++) {
        decisionService.evaluateDecisionByKey(DECISION).variables(createVariables()).evaluate();
    }
    final List<HistoricDecisionInstance> decisionInstances = historyService.createHistoricDecisionInstanceQuery().list();
    final List<String> decisionInstanceIds = new ArrayList<String>();
    for (HistoricDecisionInstance decisionInstance : decisionInstances) {
        decisionInstanceIds.add(decisionInstance.getId());
    }
    return decisionInstanceIds;
}
Also used : ArrayList(java.util.ArrayList) HistoricDecisionInstance(org.camunda.bpm.engine.history.HistoricDecisionInstance)

Aggregations

HistoricDecisionInstance (org.camunda.bpm.engine.history.HistoricDecisionInstance)51 Deployment (org.camunda.bpm.engine.test.Deployment)23 HistoricDecisionOutputInstance (org.camunda.bpm.engine.history.HistoricDecisionOutputInstance)9 Test (org.junit.Test)9 HistoricDecisionInputInstance (org.camunda.bpm.engine.history.HistoricDecisionInputInstance)8 ArrayList (java.util.ArrayList)7 HistoricDecisionInstanceQuery (org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery)7 VariableMap (org.camunda.bpm.engine.variable.VariableMap)6 List (java.util.List)4 HistoricProcessInstance (org.camunda.bpm.engine.history.HistoricProcessInstance)4 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)4 JobEntity (org.camunda.bpm.engine.impl.persistence.entity.JobEntity)4 CaseDefinition (org.camunda.bpm.engine.repository.CaseDefinition)4 CaseInstance (org.camunda.bpm.engine.runtime.CaseInstance)4 HashMap (java.util.HashMap)3 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)3 HistoricCaseInstance (org.camunda.bpm.engine.history.HistoricCaseInstance)3 HistoricIncident (org.camunda.bpm.engine.history.HistoricIncident)3 HistoricIncidentEntity (org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity)3 ProcessInstance (org.camunda.bpm.engine.runtime.ProcessInstance)3