use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.
the class ProcessDefinitionRestServiceImpl method getStatistics.
@Override
public List<StatisticsResultDto> getStatistics(Boolean includeFailedJobs, Boolean includeRootIncidents, Boolean includeIncidents, String includeIncidentsForType) {
if (includeIncidents != null && includeIncidentsForType != null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeIncidents or includeIncidentsForType can be set.");
}
if (includeIncidents != null && includeRootIncidents != null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeIncidents or includeRootIncidents can be set.");
}
if (includeRootIncidents != null && includeIncidentsForType != null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Only one of the query parameter includeRootIncidents or includeIncidentsForType can be set.");
}
ManagementService mgmtService = getProcessEngine().getManagementService();
ProcessDefinitionStatisticsQuery query = mgmtService.createProcessDefinitionStatisticsQuery();
if (includeFailedJobs != null && includeFailedJobs) {
query.includeFailedJobs();
}
if (includeIncidents != null && includeIncidents) {
query.includeIncidents();
} else if (includeIncidentsForType != null) {
query.includeIncidentsForType(includeIncidentsForType);
} else if (includeRootIncidents != null && includeRootIncidents) {
query.includeRootIncidents();
}
List<ProcessDefinitionStatistics> queryResults = query.list();
List<StatisticsResultDto> results = new ArrayList<StatisticsResultDto>();
for (ProcessDefinitionStatistics queryResult : queryResults) {
StatisticsResultDto dto = ProcessDefinitionStatisticsResultDto.fromProcessDefinitionStatistics(queryResult);
results.add(dto);
}
return results;
}
use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.
the class ProcessInstanceRestServiceImpl method setRetriesByProcessHistoricQueryBased.
@Override
public BatchDto setRetriesByProcessHistoricQueryBased(SetJobRetriesByProcessDto setJobRetriesDto) {
List<String> processInstanceIds = new ArrayList<String>();
HistoricProcessInstanceQueryDto queryDto = setJobRetriesDto.getHistoricProcessInstanceQuery();
if (queryDto != null) {
HistoricProcessInstanceQuery query = queryDto.toQuery(getProcessEngine());
List<HistoricProcessInstance> historicProcessInstances = query.list();
for (HistoricProcessInstance historicProcessInstance : historicProcessInstances) {
processInstanceIds.add(historicProcessInstance.getId());
}
}
if (setJobRetriesDto.getProcessInstances() != null) {
processInstanceIds.addAll(setJobRetriesDto.getProcessInstances());
}
try {
ManagementService managementService = getProcessEngine().getManagementService();
Batch batch = managementService.setJobRetriesAsync(processInstanceIds, (ProcessInstanceQuery) null, setJobRetriesDto.getRetries());
return BatchDto.fromBatch(batch);
} catch (BadUserRequestException e) {
throw new InvalidRequestException(Status.BAD_REQUEST, e.getMessage());
}
}
use of org.camunda.bpm.engine.ManagementService 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());
}
}
use of org.camunda.bpm.engine.ManagementService 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());
}
}
use of org.camunda.bpm.engine.ManagementService in project camunda-bpm-platform by camunda.
the class BatchHelper method removeAllRunningAndHistoricBatches.
/**
* Remove all batches and historic batches. Usually called in {@link org.junit.After} method.
*/
public void removeAllRunningAndHistoricBatches() {
HistoryService historyService = getHistoryService();
ManagementService managementService = 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());
}
}
Aggregations