use of org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class AbstractSetExternalTaskRetriesCmd method collectProcessInstanceIds.
protected List<String> collectProcessInstanceIds() {
Set<String> collectedProcessInstanceIds = new HashSet<String>();
List<String> processInstanceIds = builder.getProcessInstanceIds();
if (processInstanceIds != null && !processInstanceIds.isEmpty()) {
collectedProcessInstanceIds.addAll(processInstanceIds);
}
ProcessInstanceQueryImpl processInstanceQuery = (ProcessInstanceQueryImpl) builder.getProcessInstanceQuery();
if (processInstanceQuery != null) {
collectedProcessInstanceIds.addAll(processInstanceQuery.listIds());
}
HistoricProcessInstanceQueryImpl historicProcessInstanceQuery = (HistoricProcessInstanceQueryImpl) builder.getHistoricProcessInstanceQuery();
if (historicProcessInstanceQuery != null) {
collectedProcessInstanceIds.addAll(historicProcessInstanceQuery.listIds());
}
return new ArrayList<String>(collectedProcessInstanceIds);
}
use of org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class DeleteHistoricProcessInstancesBatchCmd method collectHistoricProcessInstanceIds.
protected List<String> collectHistoricProcessInstanceIds() {
Set<String> collectedProcessInstanceIds = new HashSet<String>();
List<String> processInstanceIds = this.getHistoricProcessInstanceIds();
if (processInstanceIds != null) {
collectedProcessInstanceIds.addAll(processInstanceIds);
}
final HistoricProcessInstanceQueryImpl processInstanceQuery = (HistoricProcessInstanceQueryImpl) this.historicProcessInstanceQuery;
if (processInstanceQuery != null) {
for (HistoricProcessInstance hpi : processInstanceQuery.list()) {
collectedProcessInstanceIds.add(hpi.getId());
}
}
return new ArrayList<String>(collectedProcessInstanceIds);
}
use of org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class ExternalTaskRestServiceInteractionTest method testSetRetriesWithHistoricProcessInstanceQuery.
@Test
public void testSetRetriesWithHistoricProcessInstanceQuery() {
when(historyServiceMock.createHistoricProcessInstanceQuery()).thenReturn(new HistoricProcessInstanceQueryImpl());
HistoricProcessInstanceQueryDto query = new HistoricProcessInstanceQueryDto();
query.setProcessDefinitionId(EXAMPLE_PROCESS_DEFINITION_ID);
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("retries", "5");
parameters.put("historicProcessInstanceQuery", query);
given().contentType(POST_JSON_CONTENT_TYPE).body(parameters).then().expect().statusCode(Status.NO_CONTENT.getStatusCode()).when().put(RETRIES_EXTERNAL_TASK_SYNC_URL);
ArgumentCaptor<HistoricProcessInstanceQuery> queryCapture = ArgumentCaptor.forClass(HistoricProcessInstanceQuery.class);
verify(externalTaskService).updateRetries();
verifyNoMoreInteractions(externalTaskService);
verify(updateRetriesBuilder).externalTaskIds((List<String>) null);
verify(updateRetriesBuilder).processInstanceIds((List<String>) null);
verify(updateRetriesBuilder).externalTaskQuery(null);
verify(updateRetriesBuilder).processInstanceQuery(null);
verify(updateRetriesBuilder).historicProcessInstanceQuery(queryCapture.capture());
verify(updateRetriesBuilder).set(5);
verifyNoMoreInteractions(updateRetriesBuilder);
HistoricProcessInstanceQueryImpl actualQuery = (HistoricProcessInstanceQueryImpl) queryCapture.getValue();
assertThat(actualQuery).isNotNull();
assertThat(actualQuery.getProcessDefinitionId()).isEqualTo(EXAMPLE_PROCESS_DEFINITION_ID);
}
use of org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class AbstractRestartProcessInstanceCmd method collectProcessInstanceIds.
protected Collection<String> collectProcessInstanceIds() {
Set<String> collectedProcessInstanceIds = new HashSet<String>();
List<String> processInstanceIds = builder.getProcessInstanceIds();
if (processInstanceIds != null) {
collectedProcessInstanceIds.addAll(processInstanceIds);
}
final HistoricProcessInstanceQueryImpl historicProcessInstanceQuery = (HistoricProcessInstanceQueryImpl) builder.getHistoricProcessInstanceQuery();
if (historicProcessInstanceQuery != null) {
collectedProcessInstanceIds.addAll(historicProcessInstanceQuery.listIds());
}
EnsureUtil.ensureNotEmpty(BadUserRequestException.class, "processInstanceIds", collectedProcessInstanceIds);
return collectedProcessInstanceIds;
}
use of org.camunda.bpm.engine.impl.HistoricProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class DeleteHistoricProcessInstancesCmd method execute.
@Override
public Void execute(CommandContext commandContext) {
ensureNotEmpty(BadUserRequestException.class, "processInstanceIds", processInstanceIds);
ensureNotContainsNull(BadUserRequestException.class, "processInstanceId is null", "processInstanceIds", processInstanceIds);
// Check if process instance is still running
List<HistoricProcessInstance> instances = commandContext.runWithoutAuthorization(new Callable<List<HistoricProcessInstance>>() {
@Override
public List<HistoricProcessInstance> call() throws Exception {
return new HistoricProcessInstanceQueryImpl().processInstanceIds(new HashSet<String>(processInstanceIds)).list();
}
});
if (processInstanceIds.size() == 1) {
ensureNotEmpty(BadUserRequestException.class, "No historic process instance found with id: " + processInstanceIds.get(0), "historicProcessInstanceIds", instances);
} else {
ensureNotEmpty(BadUserRequestException.class, "No historic process instances found", "historicProcessInstanceIds", instances);
}
// check if all historicProcessInstances were found
List<String> existingIds = new ArrayList<String>();
for (HistoricProcessInstance historicProcessInstance : instances) {
existingIds.add(historicProcessInstance.getId());
for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) {
checker.checkDeleteHistoricProcessInstance(historicProcessInstance);
}
ensureNotNull(BadUserRequestException.class, "Process instance is still running, cannot delete historic process instance: " + historicProcessInstance, "instance.getEndTime()", historicProcessInstance.getEndTime());
}
ArrayList<String> nonExistingIds = new ArrayList<String>(processInstanceIds);
nonExistingIds.removeAll(existingIds);
ensureNumberOfElements(BadUserRequestException.class, "No historic process instances found with ids " + nonExistingIds, "nonExistingIds", nonExistingIds, 0);
commandContext.getHistoricProcessInstanceManager().deleteHistoricProcessInstanceByIds(processInstanceIds);
return null;
}
Aggregations