use of org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class AbstractModificationCmd method collectProcessInstanceIds.
protected Collection<String> collectProcessInstanceIds(CommandContext commandContext) {
Set<String> collectedProcessInstanceIds = new HashSet<String>();
List<String> processInstanceIds = builder.getProcessInstanceIds();
if (processInstanceIds != null) {
collectedProcessInstanceIds.addAll(processInstanceIds);
}
final ProcessInstanceQueryImpl processInstanceQuery = (ProcessInstanceQueryImpl) builder.getProcessInstanceQuery();
if (processInstanceQuery != null) {
collectedProcessInstanceIds.addAll(processInstanceQuery.listIds());
}
return collectedProcessInstanceIds;
}
use of org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl 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.ProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class AbstractMigrationCmd method collectProcessInstanceIds.
protected Collection<String> collectProcessInstanceIds(CommandContext commandContext) {
Set<String> collectedProcessInstanceIds = new HashSet<String>();
List<String> processInstanceIds = executionBuilder.getProcessInstanceIds();
if (processInstanceIds != null) {
collectedProcessInstanceIds.addAll(processInstanceIds);
}
final ProcessInstanceQueryImpl processInstanceQuery = (ProcessInstanceQueryImpl) executionBuilder.getProcessInstanceQuery();
if (processInstanceQuery != null) {
collectedProcessInstanceIds.addAll(processInstanceQuery.listIds());
}
return collectedProcessInstanceIds;
}
use of org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class ProcessDefinitionManager method deleteProcessDefinition.
/**
* Deletes the given process definition from the database and cache.
* If cascadeToHistory and cascadeToInstances is set to true it deletes
* the history and the process instances.
*
* *Note*: If more than one process definition, from one deployment, is deleted in
* a single transaction and the cascadeToHistory and cascadeToInstances flag was set to true it
* can cause a dirty deployment cache. The process instances of ALL process definitions must be deleted,
* before every process definition can be deleted! In such cases the cascadeToInstances flag
* have to set to false!
*
* On deletion of all process instances, the task listeners will be deleted as well.
* Deletion of tasks and listeners needs the redeployment of deployments.
* It can cause to problems if is done sequential with the deletion of process definition
* in a single transaction.
*
* *For example*:
* Deployment contains two process definition. First process definition
* and instances will be removed, also cleared from the cache.
* Second process definition will be removed and his instances.
* Deletion of instances will cause redeployment this deploys again
* first into the cache. Only the second will be removed from cache and
* first remains in the cache after the deletion process.
*
* @param processDefinition the process definition which should be deleted
* @param processDefinitionId the id of the process definition
* @param cascadeToHistory if true the history will deleted as well
* @param cascadeToInstances if true the process instances are deleted as well
* @param skipCustomListeners if true skips the custom listeners on deletion of instances
*/
public void deleteProcessDefinition(ProcessDefinition processDefinition, String processDefinitionId, boolean cascadeToHistory, boolean cascadeToInstances, boolean skipCustomListeners) {
if (cascadeToHistory) {
cascadeDeleteHistoryForProcessDefinition(processDefinitionId);
if (cascadeToInstances) {
cascadeDeleteProcessInstancesForProcessDefinition(processDefinitionId, skipCustomListeners);
}
} else {
ProcessInstanceQueryImpl procInstQuery = new ProcessInstanceQueryImpl().processDefinitionId(processDefinitionId);
long processInstanceCount = getProcessInstanceManager().findProcessInstanceCountByQueryCriteria(procInstQuery);
if (processInstanceCount != 0) {
throw LOG.deleteProcessDefinitionWithProcessInstancesException(processDefinitionId, processInstanceCount);
}
}
// remove related authorization parameters in IdentityLink table
getIdentityLinkManager().deleteIdentityLinksByProcDef(processDefinitionId);
// remove timer start events:
deleteTimerStartEventsForProcessDefinition(processDefinition);
// delete process definition from database
getDbEntityManager().delete(ProcessDefinitionEntity.class, "deleteProcessDefinitionsById", processDefinitionId);
// remove process definition from cache:
Context.getProcessEngineConfiguration().getDeploymentCache().removeProcessDefinition(processDefinitionId);
deleteSubscriptionsForProcessDefinition(processDefinitionId);
// delete job definitions
getJobDefinitionManager().deleteJobDefinitionsByProcessDefinitionId(processDefinition.getId());
}
use of org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl in project camunda-bpm-platform by camunda.
the class DeleteProcessInstancesJobHandler method createJobs.
@Override
public boolean createJobs(BatchEntity batch) {
DeleteProcessInstanceBatchConfiguration configuration = readConfiguration(batch.getConfigurationBytes());
List<String> ids = configuration.getIds();
final CommandContext commandContext = Context.getCommandContext();
int batchJobsPerSeed = batch.getBatchJobsPerSeed();
int invocationsPerBatchJob = batch.getInvocationsPerBatchJob();
int numberOfItemsToProcess = Math.min(invocationsPerBatchJob * batchJobsPerSeed, ids.size());
// view of process instances to process
final List<String> processIds = ids.subList(0, numberOfItemsToProcess);
List<String> deploymentIds = commandContext.runWithoutAuthorization(new Callable<List<String>>() {
@Override
public List<String> call() throws Exception {
return commandContext.getDeploymentManager().findDeploymentIdsByProcessInstances(processIds);
}
});
for (final String deploymentId : deploymentIds) {
List<String> processIdsPerDeployment = commandContext.runWithoutAuthorization(new Callable<List<String>>() {
@Override
public List<String> call() throws Exception {
final ProcessInstanceQueryImpl processInstanceQueryToBeProcess = new ProcessInstanceQueryImpl();
processInstanceQueryToBeProcess.processInstanceIds(new HashSet<String>(processIds)).deploymentId(deploymentId);
return commandContext.getExecutionManager().findProcessInstancesIdsByQueryCriteria(processInstanceQueryToBeProcess);
}
});
processIds.removeAll(processIdsPerDeployment);
createJobEntities(batch, configuration, deploymentId, processIdsPerDeployment, invocationsPerBatchJob);
}
// when there are non existing process instance ids
if (!processIds.isEmpty()) {
createJobEntities(batch, configuration, null, processIds, invocationsPerBatchJob);
}
return ids.isEmpty();
}
Aggregations