diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/authorization/UserOperationLogCategoryPermissions.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/authorization/UserOperationLogCategoryPermissions.java new file mode 100644 index 0000000000000000000000000000000000000000..47661fb09f0ae0496ecb8433cdc5d6bfb50367e9 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/authorization/UserOperationLogCategoryPermissions.java @@ -0,0 +1,78 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.authorization; + +/** + * The set of built-in {@link Permission Permissions} for {@link Resources#OPERATION_LOG_CATEGORY User operation log based on categories} in Camunda Platform. + * + * @author Tobias Metzke + * + */ +public enum UserOperationLogCategoryPermissions implements Permission { + + /** The none permission means 'no action', 'doing nothing'. + * It does not mean that no permissions are granted. */ + NONE("NONE", 0), + + /** + * Indicates that all interactions are permitted. + * If ALL is revoked it means that the user is not permitted + * to do everything, which means that at least one permission + * is revoked. This does not implicate that all individual + * permissions are revoked. + * + * Example: If the UPDATE permission is revoked then the ALL + * permission is revoked as well, because the user is not authorized + * to execute all actions anymore. + */ + ALL("ALL", Integer.MAX_VALUE), + + /** Indicates that READ interactions on defined categories are permitted. */ + READ("READ", 2), + + /** Indicates that UPDATE interactions on defined categories are permitted. */ + UPDATE("UPDATE", 4), + + /** Indicates that DELETE interactions on defined categories are permitted. */ + DELETE("DELETE", 16); + + private static final Resource[] RESOURCES = new Resource[] { Resources.OPERATION_LOG_CATEGORY }; + + private String name; + private int id; + + private UserOperationLogCategoryPermissions(String name, int id) { + this.name = name; + this.id = id; + } + + @Override + public String getName() { + return name; + } + + @Override + public int getValue() { + return id; + } + + @Override + public Resource[] getTypes() { + return RESOURCES; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/Batch.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/Batch.java new file mode 100644 index 0000000000000000000000000000000000000000..fa06a69461dc13616a555d9d06aac11ab61d3068 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/Batch.java @@ -0,0 +1,138 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.batch; + +import org.camunda.bpm.engine.ManagementService; + +import java.util.Date; + +/** + *

A batch represents a number of jobs which + * execute a number of commands asynchronously. + *

+ *

Batches have three types of jobs: + *

+ *

+ *

All three job types have independent job definitions. They can be controlled individually + * (e.g. suspension) and are independently represented in the historic job log. + */ +public interface Batch { + + String TYPE_PROCESS_INSTANCE_MIGRATION = "instance-migration"; + String TYPE_PROCESS_INSTANCE_MODIFICATION = "instance-modification"; + String TYPE_PROCESS_INSTANCE_RESTART = "instance-restart"; + String TYPE_PROCESS_INSTANCE_DELETION = "instance-deletion"; + String TYPE_PROCESS_INSTANCE_UPDATE_SUSPENSION_STATE = "instance-update-suspension-state"; + String TYPE_HISTORIC_PROCESS_INSTANCE_DELETION = "historic-instance-deletion"; + String TYPE_HISTORIC_DECISION_INSTANCE_DELETION = "historic-decision-instance-deletion"; + String TYPE_SET_JOB_RETRIES = "set-job-retries"; + String TYPE_SET_EXTERNAL_TASK_RETRIES = "set-external-task-retries"; + String TYPE_PROCESS_SET_REMOVAL_TIME = "process-set-removal-time"; + String TYPE_DECISION_SET_REMOVAL_TIME = "decision-set-removal-time"; + String TYPE_BATCH_SET_REMOVAL_TIME = "batch-set-removal-time"; + String TYPE_SET_VARIABLES = "set-variables"; + String TYPE_CORRELATE_MESSAGE = "correlate-message"; + + /** + * @return the id of the batch + */ + String getId(); + + /** + * @return the type of the batch + */ + String getType(); + + /** + * @return the number of batch execution jobs required to complete the batch + */ + int getTotalJobs(); + + /** + * @return the number of batch execution jobs already created by the seed job + */ + int getJobsCreated(); + + /** + * @return number of batch jobs created per batch seed job invocation + */ + int getBatchJobsPerSeed(); + + /** + * @return the number of invocations executed per batch job + */ + int getInvocationsPerBatchJob(); + + /** + * @return the id of the batch seed job definition + */ + String getSeedJobDefinitionId(); + + /** + * @return the id of the batch monitor job definition + */ + String getMonitorJobDefinitionId(); + + /** + * @return the id of the batch job definition + */ + String getBatchJobDefinitionId(); + + /** + * @return the batch's tenant id or null + */ + String getTenantId(); + + /** + * @return the batch creator's user id + */ + String getCreateUserId(); + + /** + *

+ * Indicates whether this batch is suspended. If a batch is suspended, + * the batch jobs will not be acquired by the job executor. + *

+ *

+ *

+ * Note: It is still possible to manually suspend and activate + * jobs and job definitions using the {@link ManagementService}, which will + * not change the suspension state of the batch. + *

+ * + * @return true if this batch is currently suspended, false otherwise + * @see ManagementService#suspendBatchById(String) + * @see ManagementService#activateBatchById(String) + */ + boolean isSuspended(); + + /** + * @return the date the batch was started + */ + Date getStartTime(); + + /** + * @return the date the batch execution started + */ + Date getExecutionStartTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/BatchQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/BatchQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..5df84b70bac1774a4dafa410c5b0a3182ba4db9a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/BatchQuery.java @@ -0,0 +1,56 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.batch; + +import org.camunda.bpm.engine.query.Query; + +/** + * Query for {@link Batch} instances. + */ +public interface BatchQuery extends Query { + + /** Only select batch instances for the given batch id. */ + BatchQuery batchId(String batchId); + + /** + * Only select batches of the given type. + */ + BatchQuery type(String type); + + /** Only selects batches with one of the given tenant ids. */ + BatchQuery tenantIdIn(String... tenantIds); + + /** Only selects batches which have no tenant id. */ + BatchQuery withoutTenantId(); + + /** Only selects batches which are active **/ + BatchQuery active(); + + /** Only selects batches which are suspended **/ + BatchQuery suspended(); + + /** + * Returns batches sorted by id; must be followed by an invocation of {@link #asc()} or {@link #desc()}. + */ + BatchQuery orderById(); + + /** + * Returns batches sorted by tenant id; must be followed by an invocation of {@link #asc()} or {@link #desc()}. + */ + BatchQuery orderByTenantId(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/BatchStatistics.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/BatchStatistics.java new file mode 100644 index 0000000000000000000000000000000000000000..38829c5f231211db58f84252a7944f0c759b83f3 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/BatchStatistics.java @@ -0,0 +1,86 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.batch; + +/** + *

+ * Additional statistics for a single batch. + *

+ * + *

+ * Contains the number of remaining jobs, completed and failed batch + * execution jobs. The following relation between these exists: + * + * + * batch total jobs = remaining jobs + completed jobs + * + *

+ */ +public interface BatchStatistics extends Batch { + /** + *

+ * The number of remaining batch execution jobs. + * This does include failed batch execution jobs and + * batch execution jobs which still have to be created by the seed job. + *

+ * + *

+ * See + * {@link #getTotalJobs()} for the number of all batch execution jobs, + * {@link #getCompletedJobs()} for the number of completed batch execution jobs and + * {@link #getFailedJobs()} for the number of failed batch execution jobs. + *

+ * + * @return the number of remaining batch execution jobs + */ + int getRemainingJobs(); + + /** + *

+ * The number of completed batch execution jobs. + * This does include aborted/deleted batch execution jobs. + *

+ * + *

+ * See + * {@link #getTotalJobs()} for the number of all batch execution jobs, + * {@link #getRemainingJobs()} ()} for the number of remaining batch execution jobs and + * {@link #getFailedJobs()} for the number of failed batch execution jobs. + *

+ * + * @return the number of completed batch execution jobs + */ + int getCompletedJobs(); + + /** + *

+ * The number of failed batch execution jobs. + * This does not include aborted or deleted batch execution jobs. + *

+ * + *

+ * See + * {@link #getTotalJobs()} for the number of all batch execution jobs, + * {@link #getRemainingJobs()} ()} for the number of remaining batch execution jobs and + * {@link #getCompletedJobs()} ()} for the number of completed batch execution jobs. + *

+ * + * @return the number of failed batch execution jobs + */ + int getFailedJobs(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/BatchStatisticsQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/BatchStatisticsQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..5fe5b294a11c43159e595b2563147c4b99923c41 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/BatchStatisticsQuery.java @@ -0,0 +1,77 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.batch; + +import org.camunda.bpm.engine.query.Query; + +import java.util.Date; + +public interface BatchStatisticsQuery extends Query { + + /** + * Only select batch statistics for the given batch id. + */ + BatchStatisticsQuery batchId(String batchId); + + /** + * Only select batch statistics of the given type. + */ + BatchStatisticsQuery type(String type); + + /** Only selects batch statistics with one of the given tenant ids. */ + BatchStatisticsQuery tenantIdIn(String... tenantIds); + + /** Only selects batch statistics which have no tenant id. */ + BatchStatisticsQuery withoutTenantId(); + + /** Only selects batches which are active **/ + BatchStatisticsQuery active(); + + /** Only selects batches which are suspended **/ + BatchStatisticsQuery suspended(); + + /** Only selects batches that are started by the given user id **/ + BatchStatisticsQuery createdBy(String userId); + + /** Only select historic activity instances that were started before the given date. */ + BatchStatisticsQuery startedBefore(Date date); + + /** Only select historic activity instances that were started after the given date. */ + BatchStatisticsQuery startedAfter(Date date); + + /** Only selects batches with failed jobs **/ + BatchStatisticsQuery withFailures(); + + /** Only selects batches without failed jobs **/ + BatchStatisticsQuery withoutFailures(); + + /** + * Returns batch statistics sorted by batch id; must be followed by an invocation of {@link #asc()} or {@link #desc()}. + */ + BatchStatisticsQuery orderById(); + + /** + * Returns batch statistics sorted by tenant id; must be followed by an invocation of {@link #asc()} or {@link #desc()}. + */ + BatchStatisticsQuery orderByTenantId(); + + /** + * Returns batch statistics sorted by start time; must be followed by an invocation of {@link #asc()} or {@link #desc()}. + */ + BatchStatisticsQuery orderByStartTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/history/HistoricBatch.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/history/HistoricBatch.java new file mode 100644 index 0000000000000000000000000000000000000000..bbce2208450bd6b79747bc067e00c28cfa5851d7 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/history/HistoricBatch.java @@ -0,0 +1,94 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.batch.history; + +import java.util.Date; + +/** + * Historic representation of a {@link org.camunda.bpm.engine.batch.Batch}. + */ +public interface HistoricBatch { + + /** + * @return the id of the batch + */ + String getId(); + + /** + * @return the type of the batch + */ + String getType(); + + /** + * @return the number of batch execution jobs required to complete the batch + */ + int getTotalJobs(); + + /** + * @return number of batch jobs created per batch seed job invocation + */ + int getBatchJobsPerSeed(); + + /** + * @return the number of invocations executed per batch job + */ + int getInvocationsPerBatchJob(); + + /** + * @return the id of the batch seed job definition + */ + String getSeedJobDefinitionId(); + + /** + * @return the id of the batch monitor job definition + */ + String getMonitorJobDefinitionId(); + + /** + * @return the id of the batch job definition + */ + String getBatchJobDefinitionId(); + + /** + * @return the batch's tenant id or null + */ + String getTenantId(); + + /** + * @return the batch creator's user id + */ + String getCreateUserId(); + + /** + * @return the date the batch was started + */ + Date getStartTime(); + + /** + * @return the date the batch was completed + */ + Date getEndTime(); + + /** The time the historic batch will be removed. */ + Date getRemovalTime(); + + /** + * @return the date the batch execution started + */ + Date getExecutionStartTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/history/HistoricBatchQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/history/HistoricBatchQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..bd8a1fd158d1b88f4514f4bb60a17b2f8b80040b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/batch/history/HistoricBatchQuery.java @@ -0,0 +1,68 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.batch.history; + +import org.camunda.bpm.engine.query.Query; + +/** + * Query for {@link HistoricBatch} instances. + */ +public interface HistoricBatchQuery extends Query { + + /** + * Only select historic batch instances for the given batch id. + */ + HistoricBatchQuery batchId(String batchId); + + /** + * Only select historic batches of the given type. + */ + HistoricBatchQuery type(String type); + + /** + * Only select historic batches which are completed or not. + */ + HistoricBatchQuery completed(boolean completed); + + /** Only selects historic batches with one of the given tenant ids. */ + HistoricBatchQuery tenantIdIn(String... tenantIds); + + /** Only selects historic batches which have no tenant id. */ + HistoricBatchQuery withoutTenantId(); + + /** + * Returns historic batches sorted by id; must be followed by an invocation of {@link #asc()} or {@link #desc()}. + */ + HistoricBatchQuery orderById(); + + /** + * Returns historic batches sorted by start time; must be followed by an invocation of {@link #asc()} or {@link #desc()}. + */ + HistoricBatchQuery orderByStartTime(); + + /** + * Returns historic batches sorted by end time; must be followed by an invocation of {@link #asc()} or {@link #desc()}. + */ + HistoricBatchQuery orderByEndTime(); + + /** + * Returns historic batches sorted by tenant id; must be followed by an invocation of {@link #asc()} or {@link #desc()}. + */ + HistoricBatchQuery orderByTenantId(); + + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/context/DelegateExecutionContext.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/context/DelegateExecutionContext.java new file mode 100644 index 0000000000000000000000000000000000000000..39727b75879483d996c76d6c778707d8dad16fbd --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/context/DelegateExecutionContext.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.context; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.impl.context.BpmnExecutionContext; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; + +/** + * Represents a delegation execution context which should return the current + * delegation execution. + * + * @author Christopher Zell + */ +public class DelegateExecutionContext { + + /** + * Returns the current delegation execution or null if the + * execution is not available. + * + * @return the current delegation execution or null if not available + */ + public static DelegateExecution getCurrentDelegationExecution() { + BpmnExecutionContext bpmnExecutionContext = Context.getBpmnExecutionContext(); + ExecutionEntity executionEntity = null; + if (bpmnExecutionContext != null) { + executionEntity = bpmnExecutionContext.getExecution(); + } + return executionEntity; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/context/ProcessEngineContext.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/context/ProcessEngineContext.java new file mode 100644 index 0000000000000000000000000000000000000000..065f4cd21eaab9cee2590e78e48df9316642de05 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/context/ProcessEngineContext.java @@ -0,0 +1,116 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.context; + +import org.camunda.bpm.engine.impl.context.ProcessEngineContextImpl; + +import java.util.concurrent.Callable; + +/** + *

When a Process Engine API call is performed, the engine + * will create a Process Engine Context. The context caches database + * entities, so that multiple operations on the same entity do not + * result in multiple database queries. This also means that the changes + * to these entities are accumulated and are flushed to the database + * as soon as the Process Engine API call returns (however, the current + * transaction might be committed at a later time).

+ * + *

If a Process Engine API call is nested into another call, the + * default behaviour is to reuse the existing Process Engine Context. + * This means that the nested call will have access to the same cached + * entities and the changes made to them.

+ * + *

When the nested call is to be executed in a new transaction, a new Process + * Engine Context needs to be created for its execution. In this case, the + * nested call will use a new cache for the database entities, independent of + * the previous (outer) call cache. This means that, the changes in the cache of + * one call are invisible to the other call and vice versa. When the nested call + * returns, the changes are flushed to the database independently of the Process + * Engine Context of the outer call.

+ * + *

The ProcessEngineContext is a utility class to declare to + * the Process Engine that a new Process Engine Context needs to be created + * in order for the database operations in a nested Process Engine API call + * to be separated in a new transaction.

+ * + * Example on declaring a new Process Engine Context: + * + *
+ *  try {
+ *    ProcessEngineContext.requiresNew();
+ *    runtimeService.startProcessInstanceByKey("EXAMPLE_INSTANCE");
+ *  } finally {
+ *    ProcessEngineContext.clear();
+ *  }
+ * 
+ */ +public class ProcessEngineContext { + + /** + * Declares to the Process Engine that a new, separate context, + * bound to the current thread, needs to be created for all subsequent + * Process Engine database operations. The method should always be used + * in a try-finally block to ensure that {@link #clear()} is called + * under any circumstances. + * + * Please see the {@link ProcessEngineContext} class documentation for + * a more detailed description on the purpose of this method. + */ + public static void requiresNew() { + ProcessEngineContextImpl.set(true); + } + + /** + * Declares to the Process Engine that the new Context created + * by the {@link #requiresNew()} method can be closed. Please + * see the {@link ProcessEngineContext} class documentation for + * a more detailed description on the purpose of this method. + */ + public static void clear() { + ProcessEngineContextImpl.clear(); + } + + /** + *

Takes a callable and executes all engine API invocations + * within that callable in a new Process Engine Context. Please + * see the {@link ProcessEngineContext} class documentation for + * a more detailed description on the purpose of this method.

+ * + * An alternative to calling: + * + * + * try { + * requiresNew(); + * callable.call(); + * } finally { + * clear(); + * } + * + * + * @param callable the callable to execute + * @return what is defined by the callable passed to the method + * @throws Exception + */ + public static T withNewProcessEngineContext(Callable callable) throws Exception { + try { + requiresNew(); + return callable.call(); + } finally { + clear(); + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/BaseDelegateExecution.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/BaseDelegateExecution.java new file mode 100644 index 0000000000000000000000000000000000000000..f16f118eb54702f9dd662af2d392e92c5c2a947b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/BaseDelegateExecution.java @@ -0,0 +1,38 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +/** + * + * @author Daniel Meyer + * @author Roman Smirnov + * @author Sebastian Menski + * + */ +public interface BaseDelegateExecution extends VariableScope { + + /** Unique id of this path of execution that can be used as a handle to provide external signals back into the engine after wait states. */ + String getId(); + + /** The {@link ExecutionListener#EVENTNAME_START event name} in case this execution is passed in for an {@link ExecutionListener} */ + String getEventName(); + + /** The business key for the root execution (e.g. process instance). + */ + String getBusinessKey(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/BpmnError.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/BpmnError.java new file mode 100644 index 0000000000000000000000000000000000000000..86cceda0bde9c49b0481107e13a9b88bc410cc8b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/BpmnError.java @@ -0,0 +1,98 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.bpmn.parser.Error; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotEmpty; + + +/** + * Special exception that can be used to throw a BPMN Error from + * {@link JavaDelegate}s and expressions. + * + * This should only be used for business faults, which shall be handled by a + * Boundary Error Event or Error Event Sub-Process modeled in the process + * definition. Technical errors should be represented by other exception types. + * + * This class represents an actual instance of a BPMN Error, whereas + * {@link Error} represents an Error definition. + * + * @author Falko Menge + */ +public class BpmnError extends ProcessEngineException { + + private static final long serialVersionUID = 1L; + + private String errorCode; + private String errorMessage; + + public BpmnError(String errorCode) { + super(exceptionMessage(errorCode, null)); + setErrorCode(errorCode); + } + + public BpmnError(String errorCode, String message) { + super(exceptionMessage(errorCode, message)); + setErrorCode(errorCode); + setMessage(message); + } + + public BpmnError(String errorCode, String message, Throwable cause) { + super(exceptionMessage(errorCode, message), cause); + setErrorCode(errorCode); + setMessage(message); + } + + public BpmnError(String errorCode, Throwable cause) { + super(exceptionMessage(errorCode, null), cause); + setErrorCode(errorCode); + } + + private static String exceptionMessage(String errorCode, String message) { + if (message == null) { + return ""; + } else { + return message + " (errorCode='" + errorCode + "')"; + } + } + + protected void setErrorCode(String errorCode) { + ensureNotEmpty("Error Code", errorCode); + this.errorCode = errorCode; + } + + public String getErrorCode() { + return errorCode; + } + + @Override + public String toString() { + return super.toString() + " (errorCode='" + errorCode + "')"; + } + + protected void setMessage(String errorMessage) { + ensureNotEmpty("Error Message", errorMessage); + this.errorMessage = errorMessage; + } + + @Override + public String getMessage() { + return errorMessage; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/BpmnModelExecutionContext.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/BpmnModelExecutionContext.java new file mode 100644 index 0000000000000000000000000000000000000000..9d0db04066454b1b1c482513448b64a48c3e55ba --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/BpmnModelExecutionContext.java @@ -0,0 +1,53 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +import org.camunda.bpm.model.bpmn.BpmnModelInstance; +import org.camunda.bpm.model.bpmn.instance.FlowElement; +import org.camunda.bpm.model.bpmn.instance.FlowNode; +import org.camunda.bpm.model.bpmn.instance.SequenceFlow; + +/** + * Implemented by classes which provide access to the {@link BpmnModelInstance} + * and the currently executed {@link FlowElement}. + * + * @author Daniel Meyer + * @author Sebastian Menski + * + */ +public interface BpmnModelExecutionContext { + + /** + * Returns the {@link BpmnModelInstance} for the currently executed Bpmn Model + * + * @return the current {@link BpmnModelInstance} + */ + BpmnModelInstance getBpmnModelInstance(); + + /** + *

Returns the currently executed Element in the BPMN Model. This method returns a {@link FlowElement} which may be casted + * to the concrete type of the Bpmn Model Element currently executed.

+ * + *

If called from a Service {@link ExecutionListener}, the method will return the corresponding {@link FlowNode} + * for {@link ExecutionListener#EVENTNAME_START} and {@link ExecutionListener#EVENTNAME_END} and the corresponding + * {@link SequenceFlow} for {@link ExecutionListener#EVENTNAME_TAKE}.

+ * + * @return the {@link FlowElement} corresponding to the current Bpmn Model Element + */ + FlowElement getBpmnModelElementInstance(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/CaseExecutionListener.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/CaseExecutionListener.java new file mode 100644 index 0000000000000000000000000000000000000000..3cad506c09b8bb20740c529ef198486c7c072ae6 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/CaseExecutionListener.java @@ -0,0 +1,84 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +import org.camunda.bpm.engine.runtime.CaseExecution; +import org.camunda.bpm.engine.runtime.CaseInstance; +import org.camunda.bpm.model.cmmn.instance.Stage; +import org.camunda.bpm.model.cmmn.instance.Task; + +/** + * Listener interface implemented by user code which wants to be notified + * when a state transition happens on a {@link CaseExecution}. + * + *

The following state transition are supported on a {@link CaseInstance}: + *

    + *
  • {@link #CREATE}
  • + *
  • {@link #COMPLETE}
  • + *
  • {@link #TERMINATE}
  • + *
  • {@link #SUSPEND}
  • + *
  • {@link #RE_ACTIVATE}
  • + *
  • {@link #CLOSE}
  • + *
+ *

+ * + *

And on a {@link CaseExecution} which is not a {@link CaseInstance} and which + * is associated with a {@link Task} or a {@link Stage} the following state transition + * are supported: + *

    + *
  • {@link #CREATE}
  • + *
  • {@link #ENABLE}
  • + *
  • {@link #DISABLE}
  • + *
  • {@link #RE_ENABLE}
  • + *
  • {@link #START}
  • + *
  • {@link #MANUAL_START}
  • + *
  • {@link #COMPLETE}
  • + *
  • {@link #TERMINATE}
  • + *
  • {@link #EXIT}
  • + *
  • {@link #SUSPEND}
  • + *
  • {@link #RESUME}
  • + *
  • {@link #PARENT_SUSPEND}
  • + *
  • {@link #PARENT_RESUME}
  • + *
+ *

+ * + * @author Roman Smirnov + * + */ +public interface CaseExecutionListener extends DelegateListener { + + String CREATE = "create"; + String ENABLE = "enable"; + String DISABLE = "disable"; + String RE_ENABLE = "reenable"; + String START = "start"; + String MANUAL_START = "manualStart"; + String COMPLETE = "complete"; + String RE_ACTIVATE = "reactivate"; + String TERMINATE = "terminate"; + String EXIT = "exit"; + String PARENT_TERMINATE = "parentTerminate"; + String SUSPEND = "suspend"; + String RESUME = "resume"; + String PARENT_SUSPEND = "parentSuspend"; + String PARENT_RESUME = "parentResume"; + String CLOSE = "close"; + String OCCUR = "occur"; + + void notify(DelegateCaseExecution caseExecution) throws Exception; + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/CaseVariableListener.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/CaseVariableListener.java new file mode 100644 index 0000000000000000000000000000000000000000..6ae490a01dde173bb322e927b22775f5270dc2a6 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/CaseVariableListener.java @@ -0,0 +1,39 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +/** + *

A variable listener can be defined on a scope in a case model. + * Depending on its configuration, it is invoked when a variable is create/updated/deleted + * on a case execution that corresponds to that scope or to any of its descendant scopes.

+ * + *

+ * Beware: If you set a variable inside a {@link VariableListener} implementation, + * this will result in new variable listener invocations. Make sure that your implementation + * allows to exit such a cascade as otherwise there will be an infinite loop. + *

+ * + * @author Thorben Lindhauer + */ +public interface CaseVariableListener extends VariableListener { + + String CREATE = VariableListener.CREATE; + String UPDATE = VariableListener.UPDATE; + String DELETE = VariableListener.DELETE; + + void notify(DelegateCaseVariableInstance variableInstance) throws Exception; +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/CmmnModelExecutionContext.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/CmmnModelExecutionContext.java new file mode 100644 index 0000000000000000000000000000000000000000..4a352ed0e3482b42b4c919bac1d14749f73a6128 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/CmmnModelExecutionContext.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +import org.camunda.bpm.model.cmmn.CmmnModelInstance; +import org.camunda.bpm.model.cmmn.instance.CmmnElement; + +/** + * Implemented by classes which provide access to the {@link CmmnModelInstance} + * and the currently executed {@link CmmnElement}. + * + * @author Roman Smirnov + * + */ +public interface CmmnModelExecutionContext { + + /** + * Returns the {@link CmmnModelInstance} for the currently executed Cmmn Model + * + * @return the current {@link CmmnModelInstance} + */ + CmmnModelInstance getCmmnModelInstance(); + + /** + *

Returns the currently executed Element in the Cmmn Model. This method returns a {@link CmmnElement} which may be casted + * to the concrete type of the Cmmn Model Element currently executed.

+ * + * @return the {@link CmmnElement} corresponding to the current Cmmn Model Element + */ + CmmnElement getCmmnModelElementInstance(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateCaseExecution.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateCaseExecution.java new file mode 100644 index 0000000000000000000000000000000000000000..571f913a15cab1a48634bb62d2271a32092f1735 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateCaseExecution.java @@ -0,0 +1,61 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +/** + * @author Roman Smirnov + * + */ +public interface DelegateCaseExecution extends BaseDelegateExecution, ProcessEngineServicesAware, CmmnModelExecutionContext { + + String getId(); + + String getCaseInstanceId(); + + String getEventName(); + + String getCaseBusinessKey(); + + String getCaseDefinitionId(); + + String getParentId(); + + String getActivityId(); + + String getActivityName(); + + String getTenantId(); + + boolean isAvailable(); + + boolean isEnabled(); + + boolean isDisabled(); + + boolean isActive(); + + boolean isSuspended(); + + boolean isTerminated(); + + boolean isCompleted(); + + boolean isFailed(); + + boolean isClosed(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateCaseVariableInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateCaseVariableInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..07c1a3a1d2460201131c897545a33d364e9d182f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateCaseVariableInstance.java @@ -0,0 +1,33 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + + +/** + * @author Thorben Lindhauer + * + */ +public interface DelegateCaseVariableInstance extends DelegateVariableInstance { + + /** The event name, which caused the listener to be notified. + * Valid values are the constants defined in {@link CaseVariableListener}.*/ + String getEventName(); + + /** The case execution in which context the variable was created/updated/deleted. */ + DelegateCaseExecution getSourceExecution(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateExecution.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateExecution.java new file mode 100644 index 0000000000000000000000000000000000000000..72bd4d7b7a852879a5f16fb9a670a78c04ea3048 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateExecution.java @@ -0,0 +1,144 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.runtime.Incident; + +/** + * Execution used in {@link JavaDelegate}s and {@link ExecutionListener}s. + * + * @author Tom Baeyens + */ +public interface DelegateExecution extends BaseDelegateExecution, BpmnModelExecutionContext, ProcessEngineServicesAware { + + /** Reference to the overall process instance */ + String getProcessInstanceId(); + + /** + * The business key for the process instance this execution is associated + * with. + */ + String getProcessBusinessKey(); + + /** + * Configure a business key on the process instance this execution is associated + * with. + * + * @param businessKey the new business key + */ + void setProcessBusinessKey(String businessKey); + + /** + * The process definition key for the process instance this execution is + * associated with. + */ + String getProcessDefinitionId(); + + /** + * Gets the id of the parent of this execution. If null, the execution + * represents a process-instance. + */ + String getParentId(); + + /** + * Gets the id of the current activity. + */ + String getCurrentActivityId(); + + /** + * Gets the name of the current activity. + */ + String getCurrentActivityName(); + + /** + * return the Id of the activity instance currently executed by this execution + */ + String getActivityInstanceId(); + + /** + * return the Id of the parent activity instance currently executed by this + * execution + */ + String getParentActivityInstanceId(); + + /** return the Id of the current transition */ + String getCurrentTransitionId(); + + /** + * Return the process instance execution for this execution. In case this + * execution is the process instance execution the method returns itself. + */ + DelegateExecution getProcessInstance(); + + /** + * In case this delegate execution is the process instance execution + * and this process instance was started by a call activity, this method + * returns the execution which executed the call activity in the super process instance. + * + * @return the super execution or null. + */ + DelegateExecution getSuperExecution(); + + /** + * Returns whether this execution has been canceled. + */ + boolean isCanceled(); + + /** + * Return the id of the tenant this execution belongs to. Can be null + * if the execution belongs to no single tenant. + */ + String getTenantId(); + + /** + * Method to store variable in a specific scope identified by activity ID. + * + * @param variableName - name of the variable + * @param value - value of the variable + * @param activityId - activity ID which is associated with destination execution, + * if not existing - exception will be thrown + * @throws ProcessEngineException if scope with specified activity ID is not found + */ + void setVariable (String variableName, Object value, String activityId); + + /** + * Create an incident associated with this execution + * + * @param incidentType the type of incident + * @param configuration + * @return a new incident + */ + Incident createIncident(String incidentType, String configuration); + + /** + * Create an incident associated with this execution + * + * @param incidentType the type of incident + * @param configuration + * @param message + * @return a new incident + */ + Incident createIncident(String incidentType, String configuration, String message); + + /** + * Resolve and remove an incident with given id + * + * @param incidentId + */ + void resolveIncident(String incidentId); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateListener.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateListener.java new file mode 100644 index 0000000000000000000000000000000000000000..9c0f1ca8a9c9b67296faceaccf182fc73fccd1ce --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateListener.java @@ -0,0 +1,29 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +/** + * @author Daniel Meyer + * @author Roman Smirnov + * @author Sebastian Menski + * + */ +public interface DelegateListener { + + void notify(T instance) throws Exception; + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateTask.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateTask.java new file mode 100644 index 0000000000000000000000000000000000000000..aea0b564c413e087d8616d3c95c9ed41ff7e3cc4 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateTask.java @@ -0,0 +1,212 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +import java.util.Collection; +import java.util.Date; +import java.util.Set; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.task.IdentityLink; +import org.camunda.bpm.engine.task.IdentityLinkType; +import org.camunda.bpm.model.bpmn.instance.UserTask; + +/** + * @author Joram Barrez + * @author Daniel Meyer + * @author Sebastian Menski + */ +public interface DelegateTask extends VariableScope, BpmnModelExecutionContext, ProcessEngineServicesAware { + + /** DB id of the task. */ + String getId(); + + /** Name or title of the task. */ + String getName(); + + /** Change the name of the task. */ + void setName(String name); + + /** Free text description of the task. */ + String getDescription(); + + /** Change the description of the task */ + void setDescription(String description); + + /** indication of how important/urgent this task is with a number between + * 0 and 100 where higher values mean a higher priority and lower values mean + * lower priority: [0..19] lowest, [20..39] low, [40..59] normal, [60..79] high + * [80..100] highest */ + int getPriority(); + + /** indication of how important/urgent this task is with a number between + * 0 and 100 where higher values mean a higher priority and lower values mean + * lower priority: [0..19] lowest, [20..39] low, [40..59] normal, [60..79] high + * [80..100] highest */ + void setPriority(int priority); + + /** Reference to the process instance or null if it is not related to a process instance. */ + String getProcessInstanceId(); + + /** Reference to the path of execution or null if it is not related to a process instance. */ + String getExecutionId(); + + /** Reference to the process definition or null if it is not related to a process. */ + String getProcessDefinitionId(); + + /** Reference to the case instance or null if it is not related to a case instance. */ + String getCaseInstanceId(); + + /** Reference to the case execution or null if it is not related to a case instance. */ + String getCaseExecutionId(); + + /** Reference to the case definition or null if it is not related to a case. */ + String getCaseDefinitionId(); + + /** The date/time when this task was created */ + Date getCreateTime(); + + /** + * The date/time when this task was last updated. + * All operations that fire {@link TaskListener#EVENTNAME_UPDATE} count as an update to the task. + * Returns null if the task was never updated before (i.e. it was only created). + * */ + Date getLastUpdated(); + + /** The id of the activity in the process defining this task or null if this is not related to a process */ + String getTaskDefinitionKey(); + + /** Returns the execution currently at the task. */ + DelegateExecution getExecution(); + + /** Returns the case execution currently at the task. */ + DelegateCaseExecution getCaseExecution(); + + /** Returns the event name which triggered the task listener to fire for this task. */ + String getEventName(); + + /** Adds the given user as a candidate user to this task. */ + void addCandidateUser(String userId); + + /** Adds multiple users as candidate user to this task. */ + void addCandidateUsers(Collection candidateUsers); + + /** Adds the given group as candidate group to this task */ + void addCandidateGroup(String groupId); + + /** Adds multiple groups as candidate group to this task. */ + void addCandidateGroups(Collection candidateGroups); + + /** The {@link User.getId() userId} of the person responsible for this task. */ + String getOwner(); + + /** The {@link User.getId() userId} of the person responsible for this task.*/ + void setOwner(String owner); + + /** The {@link User.getId() userId} of the person to which this task is delegated. */ + String getAssignee(); + + /** The {@link User.getId() userId} of the person to which this task is delegated. */ + void setAssignee(String assignee); + + /** Due date of the task. */ + Date getDueDate(); + + /** Change due date of the task. */ + void setDueDate(Date dueDate); + + /** Get delete reason of the task. */ + String getDeleteReason(); + + /** + * Involves a user with a task. The type of identity link is defined by the given identityLinkType. + * @param userId id of the user involve, cannot be null. + * @param identityLinkType type of identityLink, cannot be null (@see {@link IdentityLinkType}). + * @throws ProcessEngineException when the task or user doesn't exist. + */ + void addUserIdentityLink(String userId, String identityLinkType); + + /** + * Involves a group with group task. The type of identityLink is defined by the given identityLink. + * @param groupId id of the group to involve, cannot be null. + * @param identityLinkType type of identity, cannot be null (@see {@link IdentityLinkType}). + * @throws ProcessEngineException when the task or group doesn't exist. + */ + void addGroupIdentityLink(String groupId, String identityLinkType); + + /** + * Convenience shorthand for {@link #deleteUserIdentityLink(String, String)}; with type {@link IdentityLinkType#CANDIDATE} + * @param userId id of the user to use as candidate, cannot be null. + * @throws ProcessEngineException when the task or user doesn't exist. + */ + void deleteCandidateUser(String userId); + + /** + * Convenience shorthand for {@link #deleteGroupIdentityLink(String, String, String)}; with type {@link IdentityLinkType#CANDIDATE} + * @param groupId id of the group to use as candidate, cannot be null. + * @throws ProcessEngineException when the task or group doesn't exist. + */ + void deleteCandidateGroup(String groupId); + + /** + * Removes the association between a user and a task for the given identityLinkType. + * @param userId id of the user involve, cannot be null. + * @param identityLinkType type of identityLink, cannot be null (@see {@link IdentityLinkType}). + * @throws ProcessEngineException when the task or user doesn't exist. + */ + void deleteUserIdentityLink(String userId, String identityLinkType); + + /** + * Removes the association between a group and a task for the given identityLinkType. + * @param groupId id of the group to involve, cannot be null. + * @param identityLinkType type of identity, cannot be null (@see {@link IdentityLinkType}). + * @throws ProcessEngineException when the task or group doesn't exist. + */ + void deleteGroupIdentityLink(String groupId, String identityLinkType); + + /** + * Retrieves the candidate users and groups associated with the task. + * @return set of {@link IdentityLink}s of type {@link IdentityLinkType#CANDIDATE}. + */ + Set getCandidates(); + + /** + * Provides access to the current {@link UserTask} Element from the Bpmn Model. + * @return the current {@link UserTask} Element from the Bpmn Model. + */ + @Override + public UserTask getBpmnModelElementInstance(); + + /** + * Return the id of the tenant this task belongs to. Can be null + * if the task belongs to no single tenant. + */ + String getTenantId(); + + /** Follow-up date of the task. */ + Date getFollowUpDate(); + + /** Change follow-up date of the task. */ + void setFollowUpDate(Date followUpDate); + + /** + * set status to complete. + * + * @throws IllegalStateException if performed on completion or deletion + */ + void complete(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateVariableInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateVariableInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..0d8a6d4e5851dec11d2c99fefe664fd6f70a06e8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateVariableInstance.java @@ -0,0 +1,30 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +import org.camunda.bpm.engine.runtime.VariableInstance; + +/** + * @author Thorben Lindhauer + * + */ +public interface DelegateVariableInstance extends VariableInstance, ProcessEngineServicesAware { + + String getEventName(); + + T getSourceExecution(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateVariableMapping.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateVariableMapping.java new file mode 100644 index 0000000000000000000000000000000000000000..67d1f42fdc17da863475563ebe93bafe07050249 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/DelegateVariableMapping.java @@ -0,0 +1,47 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +import org.camunda.bpm.engine.variable.VariableMap; + +/** + * Represents a delegated mapping of input and output variables. + * + * @author Christopher Zell + */ +public interface DelegateVariableMapping { + + /** + * Maps the input variables into the given variables map. + * The variables map will be used by the sub process. + * + * @param superExecution the execution object of the super (outer) process + * @param subVariables the variables map of the sub (inner) process + */ + void mapInputVariables(DelegateExecution superExecution, VariableMap subVariables); + + /** + * Maps the output variables into the outer process. This means the variables of + * the sub process, which can be accessed via the subInstance, will be + * set as variables into the super process, for example via ${superExecution.setVariables}. + * + * @param superExecution the execution object of the super (outer) process, which gets the output variables + * @param subInstance the instance of the sub process, which contains the variables + */ + void mapOutputVariables(DelegateExecution superExecution, VariableScope subInstance); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/ExecutionListener.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/ExecutionListener.java new file mode 100644 index 0000000000000000000000000000000000000000..cde7c8118efb0384b2cbf48cac0a8e217da4845c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/ExecutionListener.java @@ -0,0 +1,35 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + + + + +/** Callback interface to be notified of execution events like starting a process instance, + * ending an activity instance or taking a transition. + * + * @author Tom Baeyens + * @author Joram Barrez + */ +public interface ExecutionListener extends DelegateListener { + + String EVENTNAME_START = "start"; + String EVENTNAME_END = "end"; + String EVENTNAME_TAKE = "take"; + + void notify(DelegateExecution execution) throws Exception; +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/Expression.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/Expression.java new file mode 100644 index 0000000000000000000000000000000000000000..f67d0d75238a9ca4b698dff396c66227ce918b59 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/Expression.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +/** + * @author Frederik Heremans + */ +public interface Expression { + + // public API for field injection + + Object getValue(VariableScope variableScope); + + void setValue(Object value, VariableScope variableScope); + + String getExpressionText(); + + boolean isLiteralText(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/JavaDelegate.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/JavaDelegate.java new file mode 100644 index 0000000000000000000000000000000000000000..3009743113c18a856ab4a380c2e2cfb2e94529c0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/JavaDelegate.java @@ -0,0 +1,38 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + + +/** + * Convience class that should be used when a Java delegation in a BPMN 2.0 + * process is required (for example, to call custom business logic). + * + * This class can be used for both service tasks and event listeners. + * + * This class does not allow to influence the control flow. It follows the + * default BPMN 2.0 behavior of taking every outgoing sequence flow (which has a + * condition that evaluates to true if there is a condition defined) If you are + * in need of influencing the flow in your process, use the + * class 'org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior' instead. + * + * @author Joram Barrez + */ +public interface JavaDelegate { + + void execute(DelegateExecution execution) throws Exception; + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/ProcessEngineServicesAware.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/ProcessEngineServicesAware.java new file mode 100644 index 0000000000000000000000000000000000000000..c5d1bc76e82aba8a153761a1fbff014a03273d4b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/ProcessEngineServicesAware.java @@ -0,0 +1,47 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +import org.camunda.bpm.engine.ProcessEngine; +import org.camunda.bpm.engine.ProcessEngineServices; + +/** + *

Interface providing access to the {@link ProcessEngineServices} from Java + * delegation code.

+ * + * @author Daniel Meyer + * + */ +public interface ProcessEngineServicesAware { + + /** + * Returns the {@link ProcessEngineServices} providing access to the + * public API of the process engine. + * + * @return the {@link ProcessEngineServices}. + */ + ProcessEngineServices getProcessEngineServices(); + + /** + * Returns the {@link ProcessEngine} providing access to the + * public API of the process engine. + * + * @return the {@link ProcessEngine}. + */ + ProcessEngine getProcessEngine(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/TaskListener.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/TaskListener.java new file mode 100644 index 0000000000000000000000000000000000000000..00e79a5c5d07efbbab5a3400430f09ea32f863e0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/TaskListener.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +/** + * Listener interface implemented by user code which wants to be notified when a property of a task changes. + * + *

The following Task Events are supported: + *

    + *
  • {@link #EVENTNAME_CREATE}
  • + *
  • {@link #EVENTNAME_ASSIGNMENT}
  • + *
  • {@link #EVENTNAME_COMPLETE}
  • + *
  • {@link #EVENTNAME_UPDATE}
  • + *
  • {@link #EVENTNAME_DELETE}
  • + *
  • {@link #EVENTNAME_TIMEOUT}
  • + *
+ *

+ * + * @author Tom Baeyens + */ +public interface TaskListener { + + String EVENTNAME_CREATE = "create"; + String EVENTNAME_ASSIGNMENT = "assignment"; + String EVENTNAME_COMPLETE = "complete"; + String EVENTNAME_UPDATE = "update"; + String EVENTNAME_DELETE = "delete"; + String EVENTNAME_TIMEOUT = "timeout"; + + void notify(DelegateTask delegateTask); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/VariableListener.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/VariableListener.java new file mode 100644 index 0000000000000000000000000000000000000000..9305eb2d2864923b57c34199159cc0a9b29191eb --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/VariableListener.java @@ -0,0 +1,29 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +/** + * @author Thorben Lindhauer + */ +public interface VariableListener> { + + String CREATE = "create"; + String UPDATE = "update"; + String DELETE = "delete"; + + void notify(T variableInstance) throws Exception; +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/VariableScope.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/VariableScope.java new file mode 100644 index 0000000000000000000000000000000000000000..ead4514441bc07cf555d7d804fe8d623751341fb --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/VariableScope.java @@ -0,0 +1,113 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.delegate; + +import java.util.Collection; +import java.util.Map; +import java.util.Set; + +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.value.TypedValue; + +/** + * @author Tom Baeyens + */ +public interface VariableScope { + + String getVariableScopeKey(); + + Map getVariables(); + + VariableMap getVariablesTyped(); + + VariableMap getVariablesTyped(boolean deserializeValues); + + Map getVariablesLocal(); + + VariableMap getVariablesLocalTyped(); + + VariableMap getVariablesLocalTyped(boolean deserializeValues); + + Object getVariable(String variableName); + + Object getVariableLocal(String variableName); + + T getVariableTyped(String variableName); + + T getVariableTyped(String variableName, boolean deserializeValue); + + T getVariableLocalTyped(String variableName); + + T getVariableLocalTyped(String variableName, boolean deserializeValue); + + Set getVariableNames(); + + Set getVariableNamesLocal(); + + void setVariable(String variableName, Object value); + + void setVariableLocal(String variableName, Object value); + + void setVariables(Map variables); + + void setVariablesLocal(Map variables); + + boolean hasVariables(); + + boolean hasVariablesLocal(); + + boolean hasVariable(String variableName); + + boolean hasVariableLocal(String variableName); + + /** + * Removes the variable and creates a new + * {@link HistoricVariableUpdateEntity}. + */ + void removeVariable(String variableName); + + /** + * Removes the local variable and creates a new + * {@link HistoricVariableUpdateEntity}. + */ + void removeVariableLocal(String variableName); + + /** + * Removes the variables and creates a new + * {@link HistoricVariableUpdateEntity} for each of them. + */ + void removeVariables(Collection variableNames); + + /** + * Removes the local variables and creates a new + * {@link HistoricVariableUpdateEntity} for each of them. + */ + void removeVariablesLocal(Collection variableNames); + + /** + * Removes the (local) variables and creates a new + * {@link HistoricVariableUpdateEntity} for each of them. + */ + void removeVariables(); + + /** + * Removes the (local) variables and creates a new + * {@link HistoricVariableUpdateEntity} for each of them. + */ + void removeVariablesLocal(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/package.html b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/package.html new file mode 100644 index 0000000000000000000000000000000000000000..28ce0c949e417a9f13b88399a16bd7ae433c3052 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/delegate/package.html @@ -0,0 +1,6 @@ + + + Interfaces used to include Java code in a process as the behavior of an activity + or as a listener to process events with {@link org.camunda.bpm.engine.delegate.JavaDelegate}s. + + \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/dmn/DecisionEvaluationBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/dmn/DecisionEvaluationBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..d7444d8a438c6c509a3367c24d7aafa46e9dfd2c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/dmn/DecisionEvaluationBuilder.java @@ -0,0 +1,76 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.dmn; + +import java.util.Map; + +import org.camunda.bpm.dmn.engine.DmnDecisionTableResult; +import org.camunda.bpm.engine.AuthorizationException; +import org.camunda.bpm.engine.authorization.Permissions; +import org.camunda.bpm.engine.authorization.Resources; +import org.camunda.bpm.engine.exception.NotFoundException; +import org.camunda.bpm.engine.exception.NotValidException; + +/** + * Fluent builder to evaluate a decision. + * + * @author Kristin Polenz + * + */ +public interface DecisionEvaluationBuilder { + + /** + * Specify the id of the tenant the decision definition belongs to. Can only be + * used when the definition is referenced by key and not by id. + */ + DecisionEvaluationBuilder decisionDefinitionTenantId(String tenantId); + + /** + * Specify that the decision definition belongs to no tenant. Can only be + * used when the definition is referenced by key and not by id. + */ + DecisionEvaluationBuilder decisionDefinitionWithoutTenantId(); + + /** + * Set the version of the decision definition. If null then + * the latest version is taken. + */ + DecisionEvaluationBuilder version(Integer version); + + /** + * Set the input values of the decision. + */ + DecisionEvaluationBuilder variables(Map variables); + + /** + * Evaluates the decision. + * + * @return the result of the evaluation. + * + * @throws NotFoundException + * when no decision definition is deployed with the given id / key. + * + * @throws NotValidException + * when the given decision definition id / key is null. + * + * @throws AuthorizationException + * if the user has no {@link Permissions#CREATE_INSTANCE} permission + * on {@link Resources#DECISION_DEFINITION}. + */ + DmnDecisionTableResult evaluate(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/dmn/DecisionsEvaluationBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/dmn/DecisionsEvaluationBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..d1b31c9e6ebf7d52fd11758bb331e208b0d5d215 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/dmn/DecisionsEvaluationBuilder.java @@ -0,0 +1,73 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.dmn; + +import java.util.Map; + +import org.camunda.bpm.dmn.engine.DmnDecisionResult; +import org.camunda.bpm.engine.AuthorizationException; +import org.camunda.bpm.engine.authorization.Permissions; +import org.camunda.bpm.engine.authorization.Resources; +import org.camunda.bpm.engine.exception.NotFoundException; +import org.camunda.bpm.engine.exception.NotValidException; + +/** + * Fluent builder to evaluate a decision. + */ +public interface DecisionsEvaluationBuilder { + + /** + * Specify the id of the tenant the decision definition belongs to. Can only be + * used when the definition is referenced by key and not by id. + */ + DecisionsEvaluationBuilder decisionDefinitionTenantId(String tenantId); + + /** + * Specify that the decision definition belongs to no tenant. Can only be + * used when the definition is referenced by key and not by id. + */ + DecisionsEvaluationBuilder decisionDefinitionWithoutTenantId(); + + /** + * Set the version of the decision definition. If null then + * the latest version is taken. + */ + DecisionsEvaluationBuilder version(Integer version); + + /** + * Set the input values of the decision. + */ + DecisionsEvaluationBuilder variables(Map variables); + + /** + * Evaluates the decision. + * + * @return the result of the evaluation. + * + * @throws NotFoundException + * when no decision definition is deployed with the given id / key. + * + * @throws NotValidException + * when the given decision definition id / key is null. + * + * @throws AuthorizationException + * if the user has no {@link Permissions#CREATE_INSTANCE} permission + * on {@link Resources#DECISION_DEFINITION}. + */ + DmnDecisionResult evaluate(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/DeploymentResourceNotFoundException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/DeploymentResourceNotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..b6a6f84c753d83b9a085db88c7791d967013c779 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/DeploymentResourceNotFoundException.java @@ -0,0 +1,45 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception; + +import org.camunda.bpm.engine.ProcessEngineException; + +/** + * @author Roman Smirnov + * + */ +public class DeploymentResourceNotFoundException extends ProcessEngineException { + + private static final long serialVersionUID = 1L; + + public DeploymentResourceNotFoundException() { + super(); + } + + public DeploymentResourceNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public DeploymentResourceNotFoundException(String message) { + super(message); + } + + public DeploymentResourceNotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NotAllowedException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NotAllowedException.java new file mode 100644 index 0000000000000000000000000000000000000000..411636741c713a5a3aaa351456d032c230d4f9a8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NotAllowedException.java @@ -0,0 +1,47 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception; + +import org.camunda.bpm.engine.BadUserRequestException; + +/** + *

This exception is thrown, if an operation is not allowed to be executed.

+ * + * @author Roman Smirnov + * + */ +public class NotAllowedException extends BadUserRequestException { + + private static final long serialVersionUID = 1L; + + public NotAllowedException() { + super(); + } + + public NotAllowedException(String message, Throwable cause) { + super(message, cause); + } + + public NotAllowedException(String message) { + super(message); + } + + public NotAllowedException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NotFoundException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..52887dd07257bc3968600390f742596266be57ca --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NotFoundException.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception; + +import org.camunda.bpm.engine.BadUserRequestException; + +/** + *

This exception is thrown, if an entity (case execution, case definition) is not found.

+ * + * @author Roman Smirnov + * + */ +public class NotFoundException extends BadUserRequestException { + + private static final long serialVersionUID = 1L; + + public NotFoundException() { + } + + public NotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public NotFoundException(String message) { + super(message); + } + + public NotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NotValidException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NotValidException.java new file mode 100644 index 0000000000000000000000000000000000000000..7b45469b66eec5b4fa2e8c57a9d4410f35e2bfa8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NotValidException.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception; + +import org.camunda.bpm.engine.BadUserRequestException; + +/** + *

This exception is thrown, if a given value is not valid.

+ * + * @author Roman Smirnov + * + */ +public class NotValidException extends BadUserRequestException { + + private static final long serialVersionUID = 1L; + + public NotValidException() { + } + + public NotValidException(String message, Throwable cause) { + super(message, cause); + } + + public NotValidException(String message) { + super(message); + } + + public NotValidException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NullValueException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NullValueException.java new file mode 100644 index 0000000000000000000000000000000000000000..af8a6fbbf18986a34e4a9e4e3776665826d665eb --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/NullValueException.java @@ -0,0 +1,44 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception; + +import org.camunda.bpm.engine.ProcessEngineException; + +/** + * @author Roman Smirnov + * + */ +public class NullValueException extends ProcessEngineException { + + private static final long serialVersionUID = 1L; + + public NullValueException() { + } + + public NullValueException(String message, Throwable cause) { + super(message, cause); + } + + public NullValueException(String message) { + super(message); + } + + public NullValueException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseDefinitionNotFoundException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseDefinitionNotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..dab68954fa7a34a0fb1f69d4db0cbe4e2a54eb5d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseDefinitionNotFoundException.java @@ -0,0 +1,45 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception.cmmn; + + +/** + *

This is exception is thrown when a specific case definition is not found.

+ * + * @author Roman Smirnov + * + */ +public class CaseDefinitionNotFoundException extends CaseException { + + private static final long serialVersionUID = 1L; + + public CaseDefinitionNotFoundException() { + } + + public CaseDefinitionNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public CaseDefinitionNotFoundException(String message) { + super(message); + } + + public CaseDefinitionNotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseException.java new file mode 100644 index 0000000000000000000000000000000000000000..7e329dfa6f951abb7fd038626e118c6918a7240b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseException.java @@ -0,0 +1,48 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception.cmmn; + +import org.camunda.bpm.engine.ProcessEngineException; + +/** + *

This is exception is thrown when something happens in the execution + * of a case instance.

+ * + * @author Roman Smirnov + * + */ +public class CaseException extends ProcessEngineException { + + private static final long serialVersionUID = 1L; + + public CaseException() { + super(); + } + + public CaseException(String message, Throwable cause) { + super(message, cause); + } + + public CaseException(String message) { + super(message); + } + + public CaseException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseExecutionNotFoundException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseExecutionNotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..a8929ae0761fab6f673efd5ef1e8d3897af9cb35 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseExecutionNotFoundException.java @@ -0,0 +1,45 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception.cmmn; + + +/** + *

This is exception is thrown when a specific case execution is not found.

+ * + * @author Roman Smirnov + * + */ +public class CaseExecutionNotFoundException extends CaseException { + + private static final long serialVersionUID = 1L; + + public CaseExecutionNotFoundException() { + } + + public CaseExecutionNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public CaseExecutionNotFoundException(String message) { + super(message); + } + + public CaseExecutionNotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseIllegalStateTransitionException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseIllegalStateTransitionException.java new file mode 100644 index 0000000000000000000000000000000000000000..727923e97292ba9e48f623f5704e9a35287cd3ae --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CaseIllegalStateTransitionException.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception.cmmn; + + +/** + *

This is exception is thrown when a state transition on a case execution + * is not possible. For example: an 'enabled' case execution cannot be completed.

+ * + * @author Roman Smirnov + * + */ +public class CaseIllegalStateTransitionException extends CaseException { + + private static final long serialVersionUID = 1L; + + public CaseIllegalStateTransitionException() { + } + + public CaseIllegalStateTransitionException(String message, Throwable cause) { + super(message, cause); + } + + public CaseIllegalStateTransitionException(String message) { + super(message); + } + + public CaseIllegalStateTransitionException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CmmnModelInstanceNotFoundException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CmmnModelInstanceNotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..50a3f4d19e2a1b43db5c7b9354f66706bc72b9ed --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/cmmn/CmmnModelInstanceNotFoundException.java @@ -0,0 +1,48 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception.cmmn; + +import org.camunda.bpm.model.cmmn.CmmnModelInstance; + + +/** + *

This is exception is thrown when a {@link CmmnModelInstance} is not found.

+ * + * @author Roman Smirnov + * + */ +public class CmmnModelInstanceNotFoundException extends CaseException { + + private static final long serialVersionUID = 1L; + + public CmmnModelInstanceNotFoundException() { + super(); + } + + public CmmnModelInstanceNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public CmmnModelInstanceNotFoundException(String message) { + super(message); + } + + public CmmnModelInstanceNotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/dmn/DecisionDefinitionNotFoundException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/dmn/DecisionDefinitionNotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..f92138a3dca4d4698c56f5e50da3134071345766 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/dmn/DecisionDefinitionNotFoundException.java @@ -0,0 +1,42 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception.dmn; + + +/** + *

This exception is thrown when a specific decision definition is not found.

+ */ +public class DecisionDefinitionNotFoundException extends DecisionException { + + private static final long serialVersionUID = 1L; + + public DecisionDefinitionNotFoundException() { + } + + public DecisionDefinitionNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public DecisionDefinitionNotFoundException(String message) { + super(message); + } + + public DecisionDefinitionNotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/dmn/DecisionException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/dmn/DecisionException.java new file mode 100644 index 0000000000000000000000000000000000000000..0db8ba7ab671979d2572ac9eb0881fc40e6daa31 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/dmn/DecisionException.java @@ -0,0 +1,44 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception.dmn; + +import org.camunda.bpm.engine.ProcessEngineException; + +/** + *

This exception is thrown when something happens related to a decision.

+ */ +public class DecisionException extends ProcessEngineException { + + private static final long serialVersionUID = 1L; + + public DecisionException() { + super(); + } + + public DecisionException(String message, Throwable cause) { + super(message, cause); + } + + public DecisionException(String message) { + super(message); + } + + public DecisionException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/dmn/DmnModelInstanceNotFoundException.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/dmn/DmnModelInstanceNotFoundException.java new file mode 100644 index 0000000000000000000000000000000000000000..e4781eebace34c57a67d97b5f189c5e68d0bd977 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/exception/dmn/DmnModelInstanceNotFoundException.java @@ -0,0 +1,45 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.exception.dmn; + +import org.camunda.bpm.model.dmn.DmnModelInstance; + + +/** + *

This exception is thrown when a {@link DmnModelInstance} is not found.

+ */ +public class DmnModelInstanceNotFoundException extends DecisionException { + + private static final long serialVersionUID = 1L; + + public DmnModelInstanceNotFoundException() { + super(); + } + + public DmnModelInstanceNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public DmnModelInstanceNotFoundException(String message) { + super(message); + } + + public DmnModelInstanceNotFoundException(Throwable cause) { + super(cause); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTask.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTask.java new file mode 100644 index 0000000000000000000000000000000000000000..b505c94bf5c39c24f895cde84a3f3ffabbbabbb1 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTask.java @@ -0,0 +1,145 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.externaltask; + +import java.util.Date; +import java.util.Map; + +import org.camunda.bpm.engine.ExternalTaskService; + +/** + * Represents an instance of an external task that is created when + * a service-task like activity (i.e. service task, send task, ...) with + * attribute camunda:type="external" is executed. + * + * @author Thorben Lindhauer + */ +public interface ExternalTask { + + /** + * @return the id of the task + */ + String getId(); + + /** + * @return the name of the topic the task belongs to + */ + String getTopicName(); + + /** + * @return the id of the worker that has locked the task + */ + String getWorkerId(); + + /** + * @return the absolute time at which the lock expires + */ + Date getLockExpirationTime(); + + /** + * @return the absolute time at which the task was created + * @return + */ + Date getCreateTime(); + + /** + * @return the id of the process instance the task exists in + */ + String getProcessInstanceId(); + + /** + * @return the id of the execution that the task is assigned to + */ + String getExecutionId(); + + /** + * @return the id of the activity for which the task is created + */ + String getActivityId(); + + /** + * @return the id of the activity instance in which context the task exists + */ + String getActivityInstanceId(); + + /** + * @return the id of the process definition the tasks activity belongs to + */ + String getProcessDefinitionId(); + + /** + * @return the key of the process definition the tasks activity belongs to + */ + String getProcessDefinitionKey(); + + /** + * @return the version tag of the process definition the tasks activity belongs to + */ + String getProcessDefinitionVersionTag(); + + /** + * @return the number of retries left. The number of retries is provided by + * a task client, therefore the initial value is null. + */ + Integer getRetries(); + + /** + * @return short error message submitted with the latest reported failure executing this task; + * null if no failure was reported previously or if no error message + * was submitted + * + * @see ExternalTaskService#handleFailure(String, String,String, String, int, long) + * + * To get the full error details, + * use {@link ExternalTaskService#getExternalTaskErrorDetails(String)} + */ + String getErrorMessage(); + + /** + * @return true if the external task is suspended; a suspended external task + * cannot be completed, thereby preventing process continuation + */ + boolean isSuspended(); + + /** + * @return the id of the tenant the task belongs to. Can be null + * if the task belongs to no single tenant. + */ + String getTenantId(); + + /** + * Returns the priority of the external task. + * + * @return the priority of the external task + */ + long getPriority(); + + /** + * Returns a map containing all custom extension properties of the external task. + * + * @return the properties, never null + */ + Map getExtensionProperties(); + + /** + * Returns the business key of the process instance the external task belongs to + * + * @return the business key + */ + String getBusinessKey(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTaskQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTaskQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..87b0ec920f9c28b0974ef351a6f8788be7742b7f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTaskQuery.java @@ -0,0 +1,273 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.externaltask; + +import org.camunda.bpm.engine.query.Query; + +import java.io.Serializable; +import java.util.Date; +import java.util.Set; + +/** + * @author Thorben Lindhauer + * @author Christopher Zell + */ +public interface ExternalTaskQuery extends Query { + + /** + * Only select the external task with the given id + */ + ExternalTaskQuery externalTaskId(String externalTaskId); + + /** + * Only select external tasks with any of the given ids + */ + ExternalTaskQuery externalTaskIdIn(Set externalTaskIds); + + /** + * Only select external tasks that was most recently locked by the given worker + */ + ExternalTaskQuery workerId(String workerId); + + /** + * Only select external tasks that have a lock expiring before the given date + */ + ExternalTaskQuery lockExpirationBefore(Date lockExpirationDate); + + /** + * Only select external tasks that have a lock expiring after the given date + */ + ExternalTaskQuery lockExpirationAfter(Date lockExpirationDate); + + /** + * Only select external tasks of the given topic + */ + ExternalTaskQuery topicName(String topicName); + + /** + * Only select external tasks that are currently locked, i.e. that have a lock expiration + * time that is in the future + */ + ExternalTaskQuery locked(); + + /** + * Only select external tasks that are not currently locked, i.e. that have no + * lock expiration time or one that is overdue + */ + ExternalTaskQuery notLocked(); + + /** + * Only select external tasks created in the context of the given execution + */ + ExternalTaskQuery executionId(String executionId); + + /** + * Only select external tasks created in the context of the given process instance + */ + ExternalTaskQuery processInstanceId(String processInstanceId); + + /** + * Only select external tasks created in the context of the given process instances + */ + ExternalTaskQuery processInstanceIdIn(String... processInstanceIdIn); + + /** + * Only select tasks which are part of a process instance which has the given + * process definition key. + */ + ExternalTaskQuery processDefinitionKey(String processDefinitionKey); + + /** + * Only select tasks which are part of a process instance which has one of the + * given process definition keys. + */ + ExternalTaskQuery processDefinitionKeyIn(String... processDefinitionKeys); + + /** + * Only select external tasks that belong to an instance of the given process definition + */ + ExternalTaskQuery processDefinitionId(String processDefinitionId); + + /** + * Only select tasks which are part of a process instance which has the given + * process definition name. + */ + ExternalTaskQuery processDefinitionName(String processDefinitionName); + + /** + * Only select tasks which are part of a process instance which process definition + * name is like the given parameter. + * The syntax is that of SQL: for example usage: nameLike(%processDefinitionName%) + */ + ExternalTaskQuery processDefinitionNameLike(String processDefinitionName); + + /** + * Only select external tasks that belong to an instance of the given activity + */ + ExternalTaskQuery activityId(String activityId); + + /** + * Only select external tasks that belong to an instances of the given activities. + */ + ExternalTaskQuery activityIdIn(String... activityIdIn); + + /** + * Only select external tasks with a priority that is higher than or equal to the given priority. + * + * @since 7.5 + * @param priority the priority which is used for the query + * @return the builded external task query + */ + ExternalTaskQuery priorityHigherThanOrEquals(long priority); + + /** + * Only select external tasks with a priority that is lower than or equal to the given priority. + * + * @since 7.5 + * @param priority the priority which is used for the query + * @return the builded external task query + */ + ExternalTaskQuery priorityLowerThanOrEquals(long priority); + + /** + * Only select tasks which have are part of a process that have a variable + * with the given name set to the given value. + */ + ExternalTaskQuery processVariableValueEquals(String variableName, Object variableValue); + + /** + * Only select tasks which have a variable with the given name, but + * with a different value than the passed value. + * Byte-arrays and {@link Serializable} objects (which are not primitive type wrappers) + * are not supported. + */ + ExternalTaskQuery processVariableValueNotEquals(String variableName, Object variableValue); + + /** + * Only select tasks which are part of a process that have a variable + * with the given name and matching the given value. + * The syntax is that of SQL: for example usage: valueLike(%value%) + */ + ExternalTaskQuery processVariableValueLike(String variableName, String variableValue); + + /** + * Only select tasks which are part of a process that have a variable + * with the given name and not matching the given value. + * The syntax is that of SQL: for example usage: valueNotLike(%value%) + */ + ExternalTaskQuery processVariableValueNotLike(String variableName, String variableValue); + + /** + * Only select tasks which are part of a process that have a variable + * with the given name and a value greater than the given one. + */ + ExternalTaskQuery processVariableValueGreaterThan(String variableName, Object variableValue); + + /** + * Only select tasks which are part of a process that have a variable + * with the given name and a value greater than or equal to the given one. + */ + ExternalTaskQuery processVariableValueGreaterThanOrEquals(String variableName, Object variableValue); + + /** + * Only select tasks which are part of a process that have a variable + * with the given name and a value less than the given one. + */ + ExternalTaskQuery processVariableValueLessThan(String variableName, Object variableValue); + + /** + * Only select tasks which are part of a process that have a variable + * with the given name and a value greater than or equal to the given one. + */ + ExternalTaskQuery processVariableValueLessThanOrEquals(String variableName, Object variableValue); + + /** + * All queries for task-, process- and case-variables will match the variable names in a case-insensitive way. + */ + ExternalTaskQuery matchVariableNamesIgnoreCase(); + + /** + * All queries for task-, process- and case-variables will match the variable values in a case-insensitive way. + */ + ExternalTaskQuery matchVariableValuesIgnoreCase(); + + /** + * Only select external tasks that are currently suspended + */ + ExternalTaskQuery suspended(); + + /** + * Only select external tasks that are currently not suspended + */ + ExternalTaskQuery active(); + + /** + * Only select external tasks that have retries > 0 + */ + ExternalTaskQuery withRetriesLeft(); + + /** + * Only select external tasks that have retries = 0 + */ + ExternalTaskQuery noRetriesLeft(); + + /** Only select external tasks that belong to one of the given tenant ids. */ + ExternalTaskQuery tenantIdIn(String... tenantIds); + + /** + * Order by external task id (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + ExternalTaskQuery orderById(); + + /** + * Order by lock expiration time (needs to be followed by {@link #asc()} or {@link #desc()}). + * Ordering of tasks with no lock expiration time is database-dependent. + */ + ExternalTaskQuery orderByLockExpirationTime(); + + /** + * Order by process instance id (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + ExternalTaskQuery orderByProcessInstanceId(); + + /** + * Order by process definition id (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + ExternalTaskQuery orderByProcessDefinitionId(); + + /** + * Order by process definition key (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + ExternalTaskQuery orderByProcessDefinitionKey(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of external tasks without tenant id is database-specific. + */ + ExternalTaskQuery orderByTenantId(); + + /** + * Order by priority (needs to be followed by {@link #asc()} or {@link #desc()}). + * @since 7.5 + */ + ExternalTaskQuery orderByPriority(); + + /** + * Order by create time (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + ExternalTaskQuery orderByCreateTime(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTaskQueryBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTaskQueryBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..26a0e0a6d76c5c3b38ecea738364701f238e2000 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTaskQueryBuilder.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.externaltask; + +import java.util.List; + +/** + * @author Thorben Lindhauer + * + */ +public interface ExternalTaskQueryBuilder { + + /** + * Specifies that tasks of a topic should be fetched and locked for + * a certain amount of time + * + * @param topicName the name of the topic + * @param lockDuration the duration in milliseconds for which tasks should be locked; + * begins at the time of fetching + * @return + */ + public ExternalTaskQueryTopicBuilder topic(String topicName, long lockDuration); + + /** + * Performs the fetching. Locks candidate tasks of the given topics + * for the specified duration. + * + * @return fetched external tasks that match the topic and that can be + * successfully locked + */ + List execute(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTaskQueryTopicBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTaskQueryTopicBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..4026e3dd7155b89385079c2fd84597377ddd6af5 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/ExternalTaskQueryTopicBuilder.java @@ -0,0 +1,150 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.externaltask; + +import java.util.List; +import java.util.Map; + +/** + * @author Thorben Lindhauer + * + */ +public interface ExternalTaskQueryTopicBuilder extends ExternalTaskQueryBuilder { + + /** + * Define variables to fetch with all tasks for the current topic. Calling + * this method multiple times overrides the previously specified variables. + * + * @param variables the variable names to fetch, if null all variables will be fetched + * @return this builder + */ + public ExternalTaskQueryTopicBuilder variables(String... variables); + + /** + * Define variables to fetch with all tasks for the current topic. Calling + * this method multiple times overrides the previously specified variables. + * + * @param variables the variable names to fetch, if null all variables will be fetched + * @return this builder + */ + public ExternalTaskQueryTopicBuilder variables(List variables); + + /** + * Define a HashMap of variables and their values to filter correlated tasks. + * Calling this method multiple times overrides the previously specified variables. + * + * @param variables a HashMap of the variable names (keys) and the values to filter by + * @return this builder + */ + public ExternalTaskQueryTopicBuilder processInstanceVariableEquals(Map variables); + + /** + * Define a single variable and its name to filter tasks in a topic. Multiple calls to + * this method add to the existing "variable filters". + * + * @param name the name of the variable you want to fetch and query by + * @param value the value of the variable which you want to filter + * @return this builder + */ + public ExternalTaskQueryTopicBuilder processInstanceVariableEquals(String name, Object value); + + /** + * Define business key value to filter external tasks by (Process Instance) Business Key. + * + * @param businessKey the value of the Business Key to filter by + * @return this builder + */ + public ExternalTaskQueryTopicBuilder businessKey(String businessKey); + + /** + * Define process definition id to filter external tasks by. + * + * @param processDefinitionId the definition id to filter by + * @return this builder + */ + public ExternalTaskQueryTopicBuilder processDefinitionId(String processDefinitionId); + + /** + * Define process definition ids to filter external tasksb by. + * + * @param processDefinitionIds the definition ids to filter by + * @return this builder + */ + public ExternalTaskQueryTopicBuilder processDefinitionIdIn(String... processDefinitionIds); + + /** + * Define process definition key to filter external tasks by. + * + * @param processDefinitionKey the definition key to filter by + * @return this builder + */ + public ExternalTaskQueryTopicBuilder processDefinitionKey(String processDefinitionKey); + + /** + * Define process definition keys to filter external tasks by. + * + * @param processDefinitionKey the definition keys to filter by + * @return this builder + */ + public ExternalTaskQueryTopicBuilder processDefinitionKeyIn(String... processDefinitionKeys); + + + /** + * Define a process definition version tag to filter external tasks by. + * + * @param versionTag the version tag to filter by + * @return this builder + */ + public ExternalTaskQueryTopicBuilder processDefinitionVersionTag(String versionTag); + + /** + * Filter external tasks only with null tenant id. + * + * @return this builder + */ + public ExternalTaskQueryTopicBuilder withoutTenantId(); + + /** + * Define tenant ids to filter external tasks by. + * + * @param tenantIds the tenant ids to filter by + * @return this builder + */ + public ExternalTaskQueryTopicBuilder tenantIdIn(String... tenantIds); + + /** + * Enable deserialization of variable values that are custom objects. By default, the query + * will not attempt to deserialize the value of these variables. + * + * @return this builder + */ + public ExternalTaskQueryTopicBuilder enableCustomObjectDeserialization(); + + /** + * Define whether only local variables will be fetched with all tasks for the current topic. + * + * @return this builder + */ + public ExternalTaskQueryTopicBuilder localVariables(); + + /** + * Configure the query to include custom extension properties, if available, for all fetched tasks. + * + * @return this builder + */ + public ExternalTaskQueryTopicBuilder includeExtensionProperties(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/FetchAndLockBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/FetchAndLockBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..8299593f7bc4cf2036090ec2810cf6451d921a4d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/FetchAndLockBuilder.java @@ -0,0 +1,76 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.externaltask; + +/** + * Fetch And Lock Builder used to enable a Fluent API that exposes all parameters for fetch and Lock operation. + */ +public interface FetchAndLockBuilder { + + /** + * Configures the workerId that will be used during the Fetch and Lock operation. + * + * @param workerId the given workerId + * @return the builder + */ + FetchAndLockBuilder workerId(String workerId); + + /** + * Configures the max tasks fetching that will be used during the Fetch and Lock operation. + * + * @param maxTasks the given number of max tasks + * @return the builder + */ + FetchAndLockBuilder maxTasks(int maxTasks); + + /** + * Configures fetching to consider (or not) priority during the Fetch and Lock operation. + * + * @param usePriority the given usePriority flag. If true, tasks will be fetched in descending order. + * @return the builder + */ + FetchAndLockBuilder usePriority(boolean usePriority); + + /** + * Configures the fetching during the Fetch and Lock Operation to include ordering by create time of the external tasks. + * This method can be combined by calling asc() or desc() afterwards to define an ascending or descending order respectively. + * + * @return the builder + */ + FetchAndLockBuilder orderByCreateTime(); + + /** + * Configures the order to be ascending. + * + * @return the builder + */ + FetchAndLockBuilder asc(); + + /** + * Configures the order to be descending. + * + * @return the builder + */ + FetchAndLockBuilder desc(); + + /** + * Returns the {@link ExternalTaskQueryTopicBuilder} to handle all the configuration that applies per topic. + * + * @return the builder + */ + ExternalTaskQueryTopicBuilder subscribe(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/LockedExternalTask.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/LockedExternalTask.java new file mode 100644 index 0000000000000000000000000000000000000000..82365c2256e742f40d0ce705176bcbcfc2c1a437 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/LockedExternalTask.java @@ -0,0 +1,157 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.externaltask; + +import java.util.Date; +import java.util.Map; + +import org.camunda.bpm.engine.ExternalTaskService; +import org.camunda.bpm.engine.variable.VariableMap; + +/** + * Represents an external task that was fetched and locked. + * + * @author Thorben Lindhauer + */ +public interface LockedExternalTask { + + /** + * @return the id of the task + */ + String getId(); + + /** + * @return the name of the topic the task belongs to + */ + String getTopicName(); + + /** + * @return the id of the worker that has locked the task + */ + String getWorkerId(); + + /** + * @return the absolute time at which the lock expires + */ + Date getLockExpirationTime(); + + /** + * @return the absolute time at which the task was created + */ + Date getCreateTime(); + + /** + * @return the id of the process instance the task exists in + */ + String getProcessInstanceId(); + + /** + * @return the id of the execution that the task is assigned to + */ + String getExecutionId(); + + /** + * @return the id of the activity for which the task is created + */ + String getActivityId(); + + /** + * @return the id of the activity instance in which context the task exists + */ + String getActivityInstanceId(); + + /** + * @return the id of the process definition the tasks activity belongs to + */ + String getProcessDefinitionId(); + + /** + * @return the key of the process definition the tasks activity belongs to + */ + String getProcessDefinitionKey(); + + /** + * @return the version tag of the process definition the tasks activity belongs to + */ + String getProcessDefinitionVersionTag(); + + /** + * @return the number of retries left. The number of retries is provided by + * a task client, therefore the initial value is null. + */ + Integer getRetries(); + + /** + * @return the full error message submitted with the latest reported failure executing this task; + * null if no failure was reported previously or if no error message + * was submitted + * + * @see ExternalTaskService#handleFailure(String, String, String, int, long) + */ + String getErrorMessage(); + + /** + * @return error details submitted with the latest reported failure executing this task; + * null if no failure was reported previously or if no error details + * was submitted + * + * @see ExternalTaskService#handleFailure(String, String, String, String, int, long) + */ + String getErrorDetails(); + + /** + * @return a map of variables that contains an entry for every variable + * that was specified at fetching time, if such a variable exists in the tasks + * ancestor execution hierarchy. + */ + VariableMap getVariables(); + + /** + * @return the id of the tenant the task belongs to. Can be null + * if the task belongs to no single tenant. + */ + String getTenantId(); + + /** + * Returns the priority of the locked external task. + * The default priority is 0. + * @return the priority of the external task + */ + long getPriority(); + + /** + * Returns the business key of the process instance the external task belongs to + * + * @return the business key + */ + String getBusinessKey(); + + /** + * Returns a map of custom extension properties if the fetch instructions + * indicate to include extension properties. + * + * If extension properties are included, the returned map contains any + * extension property that is defined in the model definition of the external + * task. If extension properties not included or no properties are defined for + * the external task, the map will be empty. + * + * @return a map with all defined custom extension properties, never + * null + */ + Map getExtensionProperties(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/UpdateExternalTaskRetriesBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/UpdateExternalTaskRetriesBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..b29d5b4afa2e542a6f078e0bf4c199ec15d214d0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/UpdateExternalTaskRetriesBuilder.java @@ -0,0 +1,73 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.externaltask; + +import org.camunda.bpm.engine.AuthorizationException; +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.authorization.BatchPermissions; +import org.camunda.bpm.engine.authorization.Permissions; +import org.camunda.bpm.engine.authorization.Resources; +import org.camunda.bpm.engine.batch.Batch; + +public interface UpdateExternalTaskRetriesBuilder extends UpdateExternalTaskRetriesSelectBuilder { + + /** + * Sets the retries for external tasks. + * + * If the new value is 0, a new incident with a null message is created. + * If the old value is 0 and the new value is greater than 0, an existing incident + * is resolved. + * + * @param retries + * + * @throws org.camunda.bpm.engine.BadUserRequestException + * If no external tasks are found + * If a external task id is set to null + * + * @throws AuthorizationException thrown if the current user does not possess any of the following permissions: + *
    + *
  • {@link Permissions#UPDATE} on {@link Resources#PROCESS_INSTANCE}
  • + *
  • {@link Permissions#UPDATE_INSTANCE} on {@link Resources#PROCESS_DEFINITION}
  • + *
+ * @throws BadUserRequestException + * When the affected instances count exceeds the maximum results limit. A maximum results + * limit can be specified with the process engine configuration property + * queryMaxResultsLimit (default {@link Integer#MAX_VALUE}). + * Please use the batch operation {@link #setAsync} instead. + */ + void set(int retries); + + /** + * Sets the retries for external tasks asynchronously as batch. The returned batch + * can be used to track the progress. + * + * If the new value is 0, a new incident with a null message is created. + * If the old value is 0 and the new value is greater than 0, an existing incident + * is resolved. + * + * @param retries + * + * @throws org.camunda.bpm.engine.BadUserRequestException + * If no external tasks are found or if a external task id is set to null + * + * @throws AuthorizationException + * if the user has no {@link Permissions#CREATE} or + * {@link BatchPermissions#CREATE_BATCH_SET_EXTERNAL_TASK_RETRIES} permission on {@link Resources#BATCH}. + */ + Batch setAsync(int retries); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/UpdateExternalTaskRetriesSelectBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/UpdateExternalTaskRetriesSelectBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..2c1547b3b355d4ffa30823fcb67b78cea41ada27 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/externaltask/UpdateExternalTaskRetriesSelectBuilder.java @@ -0,0 +1,61 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.externaltask; + +import java.util.List; + +import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; + +public interface UpdateExternalTaskRetriesSelectBuilder { + + /** + * Selects a list of external tasks with the given list of ids. + */ + UpdateExternalTaskRetriesBuilder externalTaskIds(List externalTaskIds); + + /** + * Selects a list of external tasks with the given list of ids. + */ + UpdateExternalTaskRetriesBuilder externalTaskIds(String... externalTaskIds); + + /** + * Selects a list of external tasks with the given list of process instances ids. + */ + UpdateExternalTaskRetriesBuilder processInstanceIds(List processInstanceIds); + + /** + * Selects a list of external tasks with the given list of process instances ids. + */ + UpdateExternalTaskRetriesBuilder processInstanceIds(String... processInstanceIds); + + /** + * Selects a list of external tasks with the given external task query. + */ + UpdateExternalTaskRetriesBuilder externalTaskQuery(ExternalTaskQuery externalTaskQuery); + + /** + * Selects a list of external tasks with the given process instance query. + */ + UpdateExternalTaskRetriesBuilder processInstanceQuery(ProcessInstanceQuery processInstanceQuery); + + /** + * Selects a list of external tasks with the given historic process instance query. + */ + UpdateExternalTaskRetriesBuilder historicProcessInstanceQuery(HistoricProcessInstanceQuery historicProcessInstanceQuery); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/filter/Filter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/filter/Filter.java new file mode 100644 index 0000000000000000000000000000000000000000..9f2122bf74e17c908f11b3683651daed4197df1f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/filter/Filter.java @@ -0,0 +1,90 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.filter; + +import java.util.Map; +import org.camunda.bpm.engine.query.Query; + +/** + * @author Sebastian Menski + */ +public interface Filter { + + /** + * @return the id of the filer + */ + String getId(); + + /** + * @return the resource type fo the filter + */ + String getResourceType(); + + /** + * @return the name of the filter + */ + String getName(); + + /** + * @param name the name of the filter + * @return this filter + */ + Filter setName(String name); + + /** + * @return the owner of the filter + */ + String getOwner(); + + /** + * @param owner the owner of the filter + * @return this filter + */ + Filter setOwner(String owner); + + /** + * @return the saved query as query object + */ + > T getQuery(); + + /** + * @param query the saved query as query object + * @return this filter + */ + > Filter setQuery(T query); + + /** + * Extends the query with the additional query. The query of the filter is therefore modified + * and if the filter is saved the query is updated. + * + * @param extendingQuery the query to extend the filter with + * @return a copy of this filter with the extended query + */ + > Filter extend(T extendingQuery); + + /** + * @return the properties as map + */ + Map getProperties(); + + /** + * @param properties the properties to set as map + * @return this filter + */ + Filter setProperties(Map properties); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/filter/FilterQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/filter/FilterQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..2d56549f029de12149cd7d81bc97b3dd570724fd --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/filter/FilterQuery.java @@ -0,0 +1,71 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.filter; + + +import org.camunda.bpm.engine.query.Query; + +/** + * @author Sebastian Menski + */ +public interface FilterQuery extends Query { + + /** + * @param filterId set the filter id to query + * @return this query + */ + FilterQuery filterId(String filterId); + + /** + * @param resourceType set the filter resource type to query + * @return this query + */ + FilterQuery filterResourceType(String resourceType); + + /** + * @param name set the filter name to query + * @return this query + */ + FilterQuery filterName(String name); + + /** + * @param nameLike set the filter name like to query + * @return this query + */ + FilterQuery filterNameLike(String nameLike); + + /** + * @param owner set the filter owner to query + * @return this query + */ + FilterQuery filterOwner(String owner); + + // ordering //////////////////////////////////////////////////////////// + + /** Order by filter id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + FilterQuery orderByFilterId(); + + /** Order by filter id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + FilterQuery orderByFilterResourceType(); + + /** Order by filter id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + FilterQuery orderByFilterName(); + + /** Order by filter id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + FilterQuery orderByFilterOwner(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/CamundaFormRef.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/CamundaFormRef.java new file mode 100644 index 0000000000000000000000000000000000000000..04136be2c9430e4c833376b47742c75aed5856e9 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/CamundaFormRef.java @@ -0,0 +1,42 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.form; + +/** + * A {@link CamundaFormRef} represents a reference to a deployed Camunda Form. + */ +public interface CamundaFormRef { + + /** + * The key of a {@link CamundaFormRef} corresponds to the {@code id} attribute + * in the Camunda Forms JSON. + */ + String getKey(); + + /** + * The binding of {@link CamundaFormRef} specifies which version of the form + * to reference. Possible values are: {@code latest}, {@code deployment} and + * {@code version} (specific version value can be retrieved with {@link #getVersion()}). + */ + String getBinding(); + + /** + * If the {@link #getBinding() binding} of a {@link CamundaFormRef} is set to + * {@code version}, the specific version is returned. + */ + Integer getVersion(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormData.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormData.java new file mode 100644 index 0000000000000000000000000000000000000000..501d9f1380e23c464248d29622202f6d779a19bc --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormData.java @@ -0,0 +1,63 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.form; + +import java.util.List; + + +/** Contains all metadata for displaying a form and serves as + * base interface for {@link StartFormData} and {@link TaskFormData} + * + * @author Tom Baeyens + * @author Michael Siebers + * @author Daniel Meyer + * + */ +public interface FormData { + + /** User-defined reference to a form. In the Camunda Tasklist application, + * it is assumed that the form key specifies a resource in the deployment + * which is the template for the form. But users are free to + * use this property differently. + * + * A form can be referenced either through a form key or through a {@link CamundaFormRef}. + * + */ + String getFormKey(); + + /** + * User-defined reference to a form. A {@link CamundaFormRef} can specify any + * Camunda Form deployed to the engine with any deployment. It is also possible + * to specify a specific version of a deployed form. + * + * A form can be referenced either through a form key or through a {@link CamundaFormRef}. + * + */ + CamundaFormRef getCamundaFormRef(); + + /** The deployment id of the process definition to which this form is related + * */ + String getDeploymentId(); + + /** Properties containing the dynamic information that needs to be displayed in the form. */ + @Deprecated + List getFormProperties(); + + /** returns the form fields which make up this form. */ + List getFormFields(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormField.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormField.java new file mode 100644 index 0000000000000000000000000000000000000000..b129de1bff5d28f7fb052f0a1ca340bfa523aee0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormField.java @@ -0,0 +1,82 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.form; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.variable.value.TypedValue; + +/** + *

Represents an individual field in a form.

+ * + * @author Michael Siebers + * @author Daniel Meyer + * + */ +public interface FormField { + + /** + * @return the Id of a form property. Must be unique for a given form. + * The id is used for mapping the form field to a process variable. + */ + public String getId(); + + /** + * @return the human-readable display name of a form property. + */ + public String getLabel(); + + /** + * @return the type of this form field. + */ + public FormType getType(); + + /** + * @return the name of the type of this form field + */ + public String getTypeName(); + + /** + * @return the default value for this form field. + */ + @Deprecated + public Object getDefaultValue(); + + /** + * @return the value for this form field + */ + public TypedValue getValue(); + + /** + * @return a list of {@link FormFieldValidationConstraint ValidationConstraints}. + */ + public List getValidationConstraints(); + + /** + * @return a {@link Map} of additional properties. This map may be used for adding additional configuration + * to a form field. An example may be layout hints such as the size of the rendered form field or information + * about an icon to prepend or append to the rendered form field. + */ + public Map getProperties(); + + /** + * @return true if field is defined as businessKey, false otherwise + */ + boolean isBusinessKey(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormFieldValidationConstraint.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormFieldValidationConstraint.java new file mode 100644 index 0000000000000000000000000000000000000000..bd2a3327695d8c86ec2675d49fd5c3d90bebe81c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormFieldValidationConstraint.java @@ -0,0 +1,32 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.form; + +/** + * + * @author Daniel Meyer + * + */ +public interface FormFieldValidationConstraint { + + /** @return the name of the validation constraint */ + public String getName(); + + /** @return the configuration of the validation constraint. */ + public Object getConfiguration(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..e40494e49d4c05aef2b90dba9404a47eb0ac5ad8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormProperty.java @@ -0,0 +1,52 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.form; + +import org.camunda.bpm.engine.FormService; + + +/** + * Represents a single property on a form. + * + * @author Tom Baeyens + */ +@Deprecated +public interface FormProperty { + + /** The key used to submit the property in {@link FormService#submitStartFormData(String, java.util.Map)} + * or {@link FormService#submitTaskFormData(String, java.util.Map)} */ + String getId(); + + /** The display label */ + String getName(); + + /** Type of the property. */ + FormType getType(); + + /** Optional value that should be used to display in this property */ + String getValue(); + + /** Is this property read to be displayed in the form and made accessible with the methods + * {@link FormService#getStartFormData(String)} and {@link FormService#getTaskFormData(String)}. */ + boolean isReadable(); + + /** Is this property expected when a user submits the form? */ + boolean isWritable(); + + /** Is this property a required input field */ + boolean isRequired(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormType.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormType.java new file mode 100644 index 0000000000000000000000000000000000000000..94eebba3d7cb043708f80e257897fad099ee420c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/FormType.java @@ -0,0 +1,36 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.form; + + +/** + * Used to indicate the type on a {@link FormProperty}. + * @author Tom Baeyens + */ +public interface FormType { + + /** Name for the form type. */ + String getName(); + + /** Retrieve type specific extra information like + * the list of values for enum types or the format + * for date types. Look in the userguide for + * which extra information keys each type provides + * and what return type they give. */ + Object getInformation(String key); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/StartFormData.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/StartFormData.java new file mode 100644 index 0000000000000000000000000000000000000000..4a2db60b05190c44f33667998dbeb03238212b43 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/StartFormData.java @@ -0,0 +1,31 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.form; + +import org.camunda.bpm.engine.repository.ProcessDefinition; + + +/** Specific {@link FormData} for starting a new process instance. + * + * @author Tom Baeyens + */ +public interface StartFormData extends FormData { + + /** The process definition for which this form is starting a new process instance */ + ProcessDefinition getProcessDefinition(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/TaskFormData.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/TaskFormData.java new file mode 100644 index 0000000000000000000000000000000000000000..d4fe5415cc2de42443ca9517e31a83aa86efd1a7 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/TaskFormData.java @@ -0,0 +1,30 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.form; + +import org.camunda.bpm.engine.task.Task; + + +/** Specific {@link FormData} for completing a task. + * + * @author Tom Baeyens + */ +public interface TaskFormData extends FormData { + + /** The task for which this form is used to complete it. */ + Task getTask(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/package.html b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/package.html new file mode 100644 index 0000000000000000000000000000000000000000..9d5c3e663faebd60bc0d375cf6f7cc655ac49ce7 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/form/package.html @@ -0,0 +1,5 @@ + + + Classes related to the {@link org.camunda.bpm.engine.FormService}. + + \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricBatchReport.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricBatchReport.java new file mode 100644 index 0000000000000000000000000000000000000000..22eeaaf71dfc759235f5fd337fe61292c03f84b7 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricBatchReport.java @@ -0,0 +1,32 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.Query; + +/** + * Defines a report query for cleanable batches. + * + */ +public interface CleanableHistoricBatchReport extends Query { + + /** + * Order by finished batch operations amount (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + CleanableHistoricBatchReport orderByFinishedBatchOperation(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricBatchReportResult.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricBatchReportResult.java new file mode 100644 index 0000000000000000000000000000000000000000..c7ae3a2c2d2c295c5ce7ba3f93a482cf1182b615 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricBatchReportResult.java @@ -0,0 +1,44 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +/** + * This interface defines the result of Cleanable historic batch report. + * + */ +public interface CleanableHistoricBatchReportResult { + + /** + * Returns the batch type. + */ + String getBatchType(); + + /** + * Returns the history time to live for the selected batch type. + */ + Integer getHistoryTimeToLive(); + + /** + * Returns the amount of finished historic batches. + */ + long getFinishedBatchesCount(); + + /** + * Returns the amount of cleanable historic batches. + */ + long getCleanableBatchesCount(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricCaseInstanceReport.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricCaseInstanceReport.java new file mode 100644 index 0000000000000000000000000000000000000000..cb7062e67dafebb9560bcec4dc833a80e1f33659 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricCaseInstanceReport.java @@ -0,0 +1,64 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.query.Query; + +/** + * Defines a report query for cleanable case instances. + * + */ +public interface CleanableHistoricCaseInstanceReport extends Query { + + /** + * Only takes historic case instances into account for the given case definition ids. + * + * @throws NotValidException if one of the given ids is null + */ + CleanableHistoricCaseInstanceReport caseDefinitionIdIn(String... caseDefinitionIds); + + /** + * Only takes historic case instances into account for the given case definition keys. + * + * @throws NotValidException if one of the given keys is null + */ + CleanableHistoricCaseInstanceReport caseDefinitionKeyIn(String... caseDefinitionKeys); + + /** + * Only select historic case instances with one of the given tenant ids. + * + * @throws NotValidException if one of the given ids is null + */ + CleanableHistoricCaseInstanceReport tenantIdIn(String... tenantIds); + + /** + * Only selects historic case instances which have no tenant id. + */ + CleanableHistoricCaseInstanceReport withoutTenantId(); + + /** + * Only selects historic case instances which have more than zero finished instances. + */ + CleanableHistoricCaseInstanceReport compact(); + + /** + * Order by finished case instances amount (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + CleanableHistoricCaseInstanceReport orderByFinished(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricCaseInstanceReportResult.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricCaseInstanceReportResult.java new file mode 100644 index 0000000000000000000000000000000000000000..b3b7a30299c42bbc9e3b8e9dc14ec6a1b1b6a87a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricCaseInstanceReportResult.java @@ -0,0 +1,65 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +/** + * This interface defines the result of Historic finished case instance report. + * + */ +public interface CleanableHistoricCaseInstanceReportResult { + + /** + * Returns the case definition id for the selected definition. + */ + String getCaseDefinitionId(); + + /** + * Returns the case definition key for the selected definition. + */ + String getCaseDefinitionKey(); + + /** + * Returns the case definition name for the selected definition. + */ + String getCaseDefinitionName(); + + /** + * Returns the case definition version for the selected definition. + */ + int getCaseDefinitionVersion(); + + /** + * Returns the history time to live for the selected definition. + */ + Integer getHistoryTimeToLive(); + + /** + * Returns the amount of finished historic case instances. + */ + long getFinishedCaseInstanceCount(); + + /** + * Returns the amount of cleanable historic case instances. + */ + long getCleanableCaseInstanceCount(); + + /** + * + * Returns the tenant id of the current case instances. + */ + String getTenantId(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricDecisionInstanceReport.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricDecisionInstanceReport.java new file mode 100644 index 0000000000000000000000000000000000000000..fadb7de32df9e6336a5aa1cb8f33e0d3b8b17a25 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricDecisionInstanceReport.java @@ -0,0 +1,64 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.query.Query; + +/** + * Defines a report query for finished decision instances. + * + */ +public interface CleanableHistoricDecisionInstanceReport extends Query{ + + /** + * Only takes historic decision instances into account for the given decision definition ids. + * + * @throws NotValidException if one of the given ids is null + */ + CleanableHistoricDecisionInstanceReport decisionDefinitionIdIn(String... decisionDefinitionIds); + + /** + * Only takes historic decision instances into account for the given decision definition keys. + * + * @throws NotValidException if one of the given keys is null + */ + CleanableHistoricDecisionInstanceReport decisionDefinitionKeyIn(String... decisionDefinitionKeys); + + /** + * Only select historic decision instances with one of the given tenant ids. + * + * @throws NotValidException if one of the given ids is null + */ + CleanableHistoricDecisionInstanceReport tenantIdIn(String... tenantIds); + + /** + * Only selects historic decision instances which have no tenant id. + */ + CleanableHistoricDecisionInstanceReport withoutTenantId(); + + /** + * Only selects historic decision instances which have more than zero finished instances. + */ + CleanableHistoricDecisionInstanceReport compact(); + + /** + * Order by finished decision instances amount (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + CleanableHistoricDecisionInstanceReport orderByFinished(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricDecisionInstanceReportResult.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricDecisionInstanceReportResult.java new file mode 100644 index 0000000000000000000000000000000000000000..75778bc492a54ee098dac399062ec9b7c50147fa --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricDecisionInstanceReportResult.java @@ -0,0 +1,65 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +/** + * This interface defines the result of Cleanable historic decision instance report. + * + */ +public interface CleanableHistoricDecisionInstanceReportResult { + + /** + * Returns the decision definition id for the selected definition. + */ + String getDecisionDefinitionId(); + + /** + * Returns the decision definition key for the selected definition. + */ + String getDecisionDefinitionKey(); + + /** + * Returns the decision definition name for the selected definition. + */ + String getDecisionDefinitionName(); + + /** + * Returns the decision definition version for the selected definition. + */ + int getDecisionDefinitionVersion(); + + /** + * Returns the history time to live for the selected definition. + */ + Integer getHistoryTimeToLive(); + + /** + * Returns the amount of finished historic decision instances. + */ + long getFinishedDecisionInstanceCount(); + + /** + * Returns the amount of cleanable historic decision instances. + */ + long getCleanableDecisionInstanceCount(); + + /** + * + * Returns the tenant id of the current decision instances. + */ + String getTenantId(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricProcessInstanceReport.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricProcessInstanceReport.java new file mode 100644 index 0000000000000000000000000000000000000000..eeaef07efb08df0ffed148666495d9fbd9869600 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricProcessInstanceReport.java @@ -0,0 +1,64 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.query.Query; + +/** + * Defines a report query for cleanable process instances. + * + */ +public interface CleanableHistoricProcessInstanceReport extends Query { + + /** + * Only takes historic process instances into account for the given process definition ids. + * + * @throws NotValidException if one of the given ids is null + */ + CleanableHistoricProcessInstanceReport processDefinitionIdIn(String... processDefinitionIds); + + /** + * Only takes historic process instances into account for the given process definition keys. + * + * @throws NotValidException if one of the given keys is null + */ + CleanableHistoricProcessInstanceReport processDefinitionKeyIn(String... processDefinitionKeys); + + /** + * Only select historic process instances with one of the given tenant ids. + * + * @throws NotValidException if one of the given ids is null + */ + CleanableHistoricProcessInstanceReport tenantIdIn(String... tenantIds); + + /** + * Only selects historic process instances which have no tenant id. + */ + CleanableHistoricProcessInstanceReport withoutTenantId(); + + /** + * Only selects historic process instances which have more than zero finished instances. + */ + CleanableHistoricProcessInstanceReport compact(); + + /** + * Order by finished process instances amount (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + CleanableHistoricProcessInstanceReport orderByFinished(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricProcessInstanceReportResult.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricProcessInstanceReportResult.java new file mode 100644 index 0000000000000000000000000000000000000000..5764c6d12b2d7cacc15f739713d62a2b70456f4c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/CleanableHistoricProcessInstanceReportResult.java @@ -0,0 +1,65 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +/** + * This interface defines the result of Cleanable historic process instance report. + * + */ +public interface CleanableHistoricProcessInstanceReportResult { + + /** + * Returns the process definition id for the selected definition. + */ + String getProcessDefinitionId(); + + /** + * Returns the process definition key for the selected definition. + */ + String getProcessDefinitionKey(); + + /** + * Returns the process definition name for the selected definition. + */ + String getProcessDefinitionName(); + + /** + * Returns the process definition version for the selected definition. + */ + int getProcessDefinitionVersion(); + + /** + * Returns the history time to live for the selected definition. + */ + Integer getHistoryTimeToLive(); + + /** + * Returns the amount of finished historic process instances. + */ + long getFinishedProcessInstanceCount(); + + /** + * Returns the amount of cleanable historic process instances. + */ + long getCleanableProcessInstanceCount(); + + /** + * + * Returns the tenant id of the current process instances. + */ + String getTenantId(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/DurationReportResult.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/DurationReportResult.java new file mode 100644 index 0000000000000000000000000000000000000000..b3d46c5a234c35cf37ca9a528a9c334bda7116df --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/DurationReportResult.java @@ -0,0 +1,47 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +/** + *

Represents a report result about duration of completed instances for a given period.

+ * + *

The result must be interpreted in conjunction with the executed report.

+ * + * @author Roman Smirnov + * + */ +public interface DurationReportResult extends ReportResult { + + /** + *

Returns the smallest duration of all completed instances, + * which have been started in the given period.

+ */ + long getMinimum(); + + /** + *

Returns the greatest duration of all completed instances, + * which have been started in the given period.

+ */ + long getMaximum(); + + /** + *

Returns the average duration of all completed instances, + * which have been started in the given period.

+ */ + long getAverage(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/ExternalTaskState.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/ExternalTaskState.java new file mode 100644 index 0000000000000000000000000000000000000000..0af4abc1de720684cf9c32240c73d55ff69dbdb8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/ExternalTaskState.java @@ -0,0 +1,71 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + + +public interface ExternalTaskState { + + ExternalTaskState CREATED = new ExternalTaskStateImpl(0, "created"); + ExternalTaskState FAILED = new ExternalTaskStateImpl(1, "failed"); + ExternalTaskState SUCCESSFUL = new ExternalTaskStateImpl(2, "successful"); + ExternalTaskState DELETED = new ExternalTaskStateImpl(3, "deleted"); + + int getStateCode(); + + ///////////////////////////////////////////////////// default implementation + + static class ExternalTaskStateImpl implements ExternalTaskState { + + public final int stateCode; + protected final String name; + + public ExternalTaskStateImpl(int stateCode, String string) { + this.stateCode = stateCode; + this.name = string; + } + + public int getStateCode() { + return stateCode; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + stateCode; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + ExternalTaskStateImpl other = (ExternalTaskStateImpl) obj; + return stateCode == other.stateCode; + } + + @Override + public String toString() { + return name; + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..4d70f100a605cbd0566db8b94b881d5f0d111402 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityInstance.java @@ -0,0 +1,101 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +/** + * Represents one execution of an activity and it's stored permanent for statistics, audit and other business intelligence purposes. + * + * @author Christian Stettler + */ +public interface HistoricActivityInstance { + + /** The unique identifier of this historic activity instance. */ + String getId(); + + /** return the id of the parent activity instance */ + String getParentActivityInstanceId(); + + /** The unique identifier of the activity in the process */ + String getActivityId(); + + /** The display name for the activity */ + String getActivityName(); + + /** + * The activity type of the activity. + * Typically the activity type correspond to the XML tag used in the BPMN 2.0 process definition file. + * + * All activity types are available in {@link org.camunda.bpm.engine.ActivityTypes} + * + * @see org.camunda.bpm.engine.ActivityTypes + */ + String getActivityType(); + + /** Process definition key reference */ + String getProcessDefinitionKey(); + + /** Process definition reference */ + String getProcessDefinitionId(); + + /** Root process instance reference */ + String getRootProcessInstanceId(); + + /** Process instance reference */ + String getProcessInstanceId(); + + /** Execution reference */ + String getExecutionId(); + + /** The corresponding task in case of task activity */ + String getTaskId(); + + /** The called process instance in case of call activity */ + String getCalledProcessInstanceId(); + + /** The called case instance in case of (case) call activity */ + String getCalledCaseInstanceId(); + + /** Assignee in case of user task activity */ + String getAssignee(); + + /** Time when the activity instance started */ + Date getStartTime(); + + /** Time when the activity instance ended */ + Date getEndTime(); + + /** Difference between {@link #getEndTime()} and {@link #getStartTime()}. */ + Long getDurationInMillis(); + + /** Did this activity instance complete a BPMN 2.0 scope */ + boolean isCompleteScope(); + + /** Was this activity instance canceled */ + boolean isCanceled(); + + /** + * The id of the tenant this historic activity instance belongs to. Can be null + * if the historic activity instance belongs to no single tenant. + */ + String getTenantId(); + + /** The time the historic activity instance will be removed. */ + Date getRemovalTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..dc9919469b38218107f62d5f763b5a07db4f9aad --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityInstanceQuery.java @@ -0,0 +1,153 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.query.Query; +import org.camunda.bpm.engine.runtime.ProcessInstance; + + +/** + * Programmatic querying for {@link HistoricActivityInstance}s. + * + * @author Tom Baeyens + */ +public interface HistoricActivityInstanceQuery extends Query{ + + /** Only select historic activity instances with the given id (primary key within history tables). */ + HistoricActivityInstanceQuery activityInstanceId(String activityInstanceId); + + /** Only select historic activity instances with the given process instance. + * {@link ProcessInstance ) ids and {@link HistoricProcessInstance} ids match. */ + HistoricActivityInstanceQuery processInstanceId(String processInstanceId); + + /** Only select historic activity instances for the given process definition */ + HistoricActivityInstanceQuery processDefinitionId(String processDefinitionId); + + /** Only select historic activity instances for the given execution */ + HistoricActivityInstanceQuery executionId(String executionId); + + /** Only select historic activity instances for the given activity (id from BPMN 2.0 XML) */ + HistoricActivityInstanceQuery activityId(String activityId); + + /** Only select historic activity instances for activities with the given name */ + HistoricActivityInstanceQuery activityName(String activityName); + + /** + * Only select historic activity instances for activities which activityName is like the given value. + * + * @param activityNameLike The string can include the wildcard character '%' to express + * like-strategy: starts with (string%), ends with (%string) or contains (%string%). + */ + HistoricActivityInstanceQuery activityNameLike(String activityNameLike); + + /** Only select historic activity instances for activities with the given activity type */ + HistoricActivityInstanceQuery activityType(String activityType); + + /** Only select historic activity instances for userTask activities assigned to the given user */ + HistoricActivityInstanceQuery taskAssignee(String userId); + + /** Only select historic activity instances that are finished. */ + HistoricActivityInstanceQuery finished(); + + /** Only select historic activity instances that are not finished yet. */ + HistoricActivityInstanceQuery unfinished(); + + /** Only select historic activity instances that complete a BPMN scope */ + HistoricActivityInstanceQuery completeScope(); + + /** Only select historic activity instances that got canceled */ + HistoricActivityInstanceQuery canceled(); + + /** Only select historic activity instances that were started before the given date. */ + HistoricActivityInstanceQuery startedBefore(Date date); + + /** Only select historic activity instances that were started after the given date. */ + HistoricActivityInstanceQuery startedAfter(Date date); + + /** Only select historic activity instances that were started before the given date. */ + HistoricActivityInstanceQuery finishedBefore(Date date); + + /** Only select historic activity instances that were started after the given date. */ + HistoricActivityInstanceQuery finishedAfter(Date date); + + // ordering ///////////////////////////////////////////////////////////////// + /** Order by id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricActivityInstanceQuery orderByHistoricActivityInstanceId(); + + /** Order by processInstanceId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricActivityInstanceQuery orderByProcessInstanceId(); + + /** Order by executionId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricActivityInstanceQuery orderByExecutionId(); + + /** Order by activityId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricActivityInstanceQuery orderByActivityId(); + + /** Order by activityName (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricActivityInstanceQuery orderByActivityName(); + + /** Order by activityType (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricActivityInstanceQuery orderByActivityType(); + + /** Order by start (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricActivityInstanceQuery orderByHistoricActivityInstanceStartTime(); + + /** Order by end (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricActivityInstanceQuery orderByHistoricActivityInstanceEndTime(); + + /** Order by duration (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricActivityInstanceQuery orderByHistoricActivityInstanceDuration(); + + /** Order by processDefinitionId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricActivityInstanceQuery orderByProcessDefinitionId(); + + /** + *

Sort the {@link HistoricActivityInstance activity instances} in the order in which + * they occurred (ie. started) and needs to be followed by {@link #asc()} or {@link #desc()}.

+ * + *

The set of all {@link HistoricActivityInstance activity instances} is a partially + * ordered set. At a BPMN level this means that instances of concurrent activities (example: + * activities on different parallel branched after a parallel gateway) cannot be compared to each other. + * Instances of activities which are part of happens-before relation at the BPMN level will be ordered + * in respect to that relation.

+ * + *

Technically this means that {@link HistoricActivityInstance activity instances} + * with different {@link HistoricActivityInstance#getExecutionId() execution ids} are + * incomparable. Only {@link HistoricActivityInstance activity instances} with + * the same {@link HistoricActivityInstance#getExecutionId() execution id} can be totally + * ordered by using {@link #executionId(String)} and {@link #orderPartiallyByOccurrence()} + * which will return a result set ordered by its occurrence.

+ * + * @since 7.3 + */ + HistoricActivityInstanceQuery orderPartiallyByOccurrence(); + + /** Only select historic activity instances with one of the given tenant ids. */ + HistoricActivityInstanceQuery tenantIdIn(String... tenantIds); + + /** Only selects historic activity instances that have no tenant id. */ + HistoricActivityInstanceQuery withoutTenantId(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of historic activity instances without tenant id is database-specific. + */ + HistoricActivityInstanceQuery orderByTenantId(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityStatistics.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityStatistics.java new file mode 100644 index 0000000000000000000000000000000000000000..ab05cb86843475dbb4601e1d6a46873a41deba9d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityStatistics.java @@ -0,0 +1,60 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +/** + * + * @author Roman Smirnov + * + */ +public interface HistoricActivityStatistics { + + /** + * The activity id. + */ + String getId(); + + /** + * The number of all running instances of the activity. + */ + long getInstances(); + + /** + * The number of all finished instances of the activity. + */ + long getFinished(); + + /** + * The number of all canceled instances of the activity. + */ + long getCanceled(); + + /** + * The number of all instances, which complete a scope (ie. in bpmn manner: an activity + * which consumed a token and did not produced a new one), of the activity. + */ + long getCompleteScope(); + + /** The number of open incidents of the activity. */ + long getOpenIncidents(); + + /** The number of resolved incidents of the activity. */ + long getResolvedIncidents(); + + /** The number of deleted incidents of the activity. */ + long getDeletedIncidents(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityStatisticsQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityStatisticsQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..d0ea4b725b1c8d422e33b54d7fee62bc366a8b33 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricActivityStatisticsQuery.java @@ -0,0 +1,68 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; +import org.camunda.bpm.engine.query.Query; + +/** + * + * @author Roman Smirnov + * + */ +public interface HistoricActivityStatisticsQuery extends Query { + + /** + * Include an aggregation of finished instances in the result. + */ + HistoricActivityStatisticsQuery includeFinished(); + + /** + * Include an aggregation of canceled instances in the result. + */ + HistoricActivityStatisticsQuery includeCanceled(); + + /** + * Include an aggregation of instances, which complete a scope (ie. in bpmn manner: an activity + * which consumed a token and did not produced a new one), in the result. + */ + HistoricActivityStatisticsQuery includeCompleteScope(); + + /** Include an aggregation of the incidents in the result. */ + HistoricActivityStatisticsQuery includeIncidents(); + + /** Only select historic activities of process instances that were started before the given date. */ + HistoricActivityStatisticsQuery startedBefore(Date date); + + /** Only select historic activities of process instances that were started after the given date. */ + HistoricActivityStatisticsQuery startedAfter(Date date); + + /** Only select historic activities of process instances that were finished before the given date. */ + HistoricActivityStatisticsQuery finishedBefore(Date date); + + /** Only select historic activities of process instances that were finished after the given date. */ + HistoricActivityStatisticsQuery finishedAfter(Date date); + + /** Only select historic activities of process instances with the given IDs */ + HistoricActivityStatisticsQuery processInstanceIdIn(String... processInstanceIds); + + /** + * Order by activity id (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricActivityStatisticsQuery orderByActivityId(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..877f6a10b955970ae11c73cd8ded1a5276c9e8a6 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityInstance.java @@ -0,0 +1,97 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +/** + * Represents one execution of a case activity which is stored permanent for statistics, audit and other business intelligence purposes. + * + * @author Sebastian Menski + */ +public interface HistoricCaseActivityInstance { + + /** The id of the case activity instance (== as the id of the runtime activity). */ + String getId(); + + /** The id of the parent case activity instance. */ + String getParentCaseActivityInstanceId(); + + /** The unique identifier of the case activity in the case. */ + String getCaseActivityId(); + + /** The display name for the case activity. */ + String getCaseActivityName(); + + /** The display type for the case activity. */ + String getCaseActivityType(); + + /** The case definition reference. */ + String getCaseDefinitionId(); + + /** The case instance reference. */ + String getCaseInstanceId(); + + /** The case execution reference. */ + String getCaseExecutionId(); + + /** The corresponding task in case of a human task activity. */ + String getTaskId(); + + /** The corresponding process in case of a process task activity. */ + String getCalledProcessInstanceId(); + + /** The corresponding case in case of a case task activity. */ + String getCalledCaseInstanceId(); + + /** + * The id of the tenant this historic case activity instance belongs to. Can be null + * if the historic case activity instance belongs to no single tenant. + */ + String getTenantId(); + + /** The time when the case activity was created. */ + Date getCreateTime(); + + /** The time when the case activity ended */ + Date getEndTime(); + + /** Difference between {@link #getEndTime()} and {@link #getCreateTime()}. */ + Long getDurationInMillis(); + + /** Check if the case activity is required. */ + boolean isRequired(); + + /** Check if the case activity is available. */ + boolean isAvailable(); + + /** Check if the case activity is enabled. */ + boolean isEnabled(); + + /** Check if the case activity is disabled. */ + boolean isDisabled(); + + /** Check if the case activity is active. */ + boolean isActive(); + + /** Check if the case activity is completed. */ + boolean isCompleted(); + + /** Check if the case activity is terminated. */ + boolean isTerminated(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..d18b349261c1a1bc6627f837772e8b80801ed277 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityInstanceQuery.java @@ -0,0 +1,140 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.query.Query; + + +/** + * Programmatic querying for {@link HistoricCaseActivityInstance}s. + * + * @author Sebastian Menski + */ +public interface HistoricCaseActivityInstanceQuery extends Query{ + + /** Only select historic case activity instances with the given id (primary key within history tables). */ + HistoricCaseActivityInstanceQuery caseActivityInstanceId(String caseActivityInstanceId); + + /** Only select historic case activity instances with one of the given case activity instance ids. */ + HistoricCaseActivityInstanceQuery caseActivityInstanceIdIn(String... caseActivityInstanceIds); + + /** Only select historic case activity instances for the given case execution */ + HistoricCaseActivityInstanceQuery caseExecutionId(String caseExecutionId); + + /** Only select historic case activity instances with the given case instance. */ + HistoricCaseActivityInstanceQuery caseInstanceId(String caseInstanceId); + + /** Only select historic case activity instances for the given case definition */ + HistoricCaseActivityInstanceQuery caseDefinitionId(String caseDefinitionId); + + /** Only select historic case activity instances for the given case activity (id from CMMN 1.0 XML) */ + HistoricCaseActivityInstanceQuery caseActivityId(String caseActivityId); + + /** Only select historic case activity instances with one of the given case activity ids. */ + HistoricCaseActivityInstanceQuery caseActivityIdIn(String... caseActivityIds); + + /** Only select historic case activity instances for activities with the given name */ + HistoricCaseActivityInstanceQuery caseActivityName(String caseActivityName); + + /** Only select historic case activity instances for activities with the given type */ + HistoricCaseActivityInstanceQuery caseActivityType(String caseActivityType); + + /** Only select historic case activity instances that were created before the given date. */ + HistoricCaseActivityInstanceQuery createdBefore(Date date); + + /** Only select historic case activity instances that were created after the given date. */ + HistoricCaseActivityInstanceQuery createdAfter(Date date); + + /** Only select historic case activity instances that were ended (ie. completed or terminated) before the given date. */ + HistoricCaseActivityInstanceQuery endedBefore(Date date); + + /** Only select historic case activity instances that were ended (ie. completed or terminated) after the given date. */ + HistoricCaseActivityInstanceQuery endedAfter(Date date); + + /** Only select historic case activity instances which are required. */ + HistoricCaseActivityInstanceQuery required(); + + /** Only select historic case activity instances which are already ended (ie. completed or terminated). */ + HistoricCaseActivityInstanceQuery ended(); + + /** Only select historic case activity instances which are not ended (ie. completed or terminated). */ + HistoricCaseActivityInstanceQuery notEnded(); + + /** Only select historic case activity instances which are available */ + HistoricCaseActivityInstanceQuery available(); + + /** Only select historic case activity instances which are enabled */ + HistoricCaseActivityInstanceQuery enabled(); + + /** Only select historic case activity instances which are disabled */ + HistoricCaseActivityInstanceQuery disabled(); + + /** Only select historic case activity instances which are active */ + HistoricCaseActivityInstanceQuery active(); + + /** Only select historic case activity instances which are completed */ + HistoricCaseActivityInstanceQuery completed(); + + /** Only select historic case activity instances which are terminated */ + HistoricCaseActivityInstanceQuery terminated(); + + /** Only select historic case activity instances with one of the given tenant ids. */ + HistoricCaseActivityInstanceQuery tenantIdIn(String... tenantIds); + + /** Only selects historic case activity instances that have no tenant id. */ + HistoricCaseActivityInstanceQuery withoutTenantId(); + + // ordering ///////////////////////////////////////////////////////////////// + /** Order by id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseActivityInstanceQuery orderByHistoricCaseActivityInstanceId(); + + /** Order by caseInstanceId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseActivityInstanceQuery orderByCaseInstanceId(); + + /** Order by caseExecutionId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseActivityInstanceQuery orderByCaseExecutionId(); + + /** Order by caseActivityId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseActivityInstanceQuery orderByCaseActivityId(); + + /** Order by caseActivityName (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseActivityInstanceQuery orderByCaseActivityName(); + + /** Order by caseActivityType (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseActivityInstanceQuery orderByCaseActivityType(); + + /** Order by create time (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseActivityInstanceQuery orderByHistoricCaseActivityInstanceCreateTime(); + + /** Order by end time (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseActivityInstanceQuery orderByHistoricCaseActivityInstanceEndTime(); + + /** Order by duration (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseActivityInstanceQuery orderByHistoricCaseActivityInstanceDuration(); + + /** Order by caseDefinitionId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseActivityInstanceQuery orderByCaseDefinitionId(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of historic case activity instances without tenant id is database-specific. + */ + HistoricCaseActivityInstanceQuery orderByTenantId(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityStatistics.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityStatistics.java new file mode 100644 index 0000000000000000000000000000000000000000..de32a409d5583bae91470f4e9854b3fcdc0d0621 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityStatistics.java @@ -0,0 +1,60 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +/** + * @author Roman Smirnov + * + */ +public interface HistoricCaseActivityStatistics { + + /** + * The case activity id. + */ + String getId(); + + /** + * The number of available case activity instances. + */ + long getAvailable(); + + /** + * The number of enabled case activity instances. + */ + long getEnabled(); + + /** + * The number of disabled case activity instances. + */ + long getDisabled(); + + /** + * The number of active case activity instances. + */ + long getActive(); + + /** + * The number of completed case activity instances. + */ + long getCompleted(); + + /** + * The number of terminated case activity instances. + */ + long getTerminated(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityStatisticsQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityStatisticsQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..0e3d4a74011dc972313d52a98798bf9dd8abee06 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseActivityStatisticsQuery.java @@ -0,0 +1,27 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.Query; + +/** + * @author Roman Smirnov + * + */ +public interface HistoricCaseActivityStatisticsQuery extends Query { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..20720932e5e3e756fa8e3baf2f48bfe3aaed9e17 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseInstance.java @@ -0,0 +1,83 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.IdentityService; +import org.camunda.bpm.engine.runtime.CaseInstance; + +/** + * A single execution of a case definition that is stored permanently. + * + * @author Sebastian Menski + */ +public interface HistoricCaseInstance { + + /** The case instance id (== as the id of the runtime {@link CaseInstance}). */ + String getId(); + + /** The user provided unique reference to this process instance. */ + String getBusinessKey(); + + /** The case definition reference. */ + String getCaseDefinitionId(); + + /** The case definition key */ + String getCaseDefinitionKey(); + + /** The case definition name */ + String getCaseDefinitionName(); + + /** The time the case was created. */ + Date getCreateTime(); + + /** The time the case was closed. */ + Date getCloseTime(); + + /** The difference between {@link #getCloseTime()} and {@link #getCreateTime()}. */ + Long getDurationInMillis(); + + /** The authenticated user that created this case instance. + * @see IdentityService#setAuthenticatedUserId(String) */ + String getCreateUserId(); + + /** The case instance id of a potential super case instance or null if no super case instance exists. */ + String getSuperCaseInstanceId(); + + /** The process instance id of a potential super process instance or null if no super process instance exists. */ + String getSuperProcessInstanceId(); + + /** + * The id of the tenant this historic case instance belongs to. Can be null + * if the historic case instance belongs to no single tenant. + */ + String getTenantId(); + + /** Check if the case is active. */ + boolean isActive(); + + /** Check if the case is completed. */ + boolean isCompleted(); + + /** Check if the case is terminated. */ + boolean isTerminated(); + + /** Check if the case is closed. */ + boolean isClosed(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..a8a3b884c3a70f94c317029a186092656dbcf786 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricCaseInstanceQuery.java @@ -0,0 +1,254 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; +import java.util.List; +import java.util.Set; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.query.Query; + +/** + * Allows programmatic querying of {@link HistoricCaseInstance}s. + * + * @author Tom Baeyens + * @author Joram Barrez + * @author Falko Menge + */ +public interface HistoricCaseInstanceQuery extends Query { + + /** Only select historic case instances with the given case instance id. */ + HistoricCaseInstanceQuery caseInstanceId(String caseInstanceId); + + /** Only select historic case instances whose id is in the given set of ids. */ + HistoricCaseInstanceQuery caseInstanceIds(Set caseInstanceIds); + + /** Only select historic case instances for the given case definition */ + HistoricCaseInstanceQuery caseDefinitionId(String caseDefinitionId); + + /** Only select historic case instances that are defined by a case definition with the given key. */ + HistoricCaseInstanceQuery caseDefinitionKey(String caseDefinitionKey); + + /** Only select historic case instances that don't have a case definition of which the key is present in the given list */ + HistoricCaseInstanceQuery caseDefinitionKeyNotIn(List caseDefinitionKeys); + + /** Only select historic case instances that are defined by a case definition with the given name. */ + HistoricCaseInstanceQuery caseDefinitionName(String caseDefinitionName); + + /** + * Only select historic case instances that are defined by case definition which name + * is like the given value. + * + * @param nameLike The string can include the wildcard character '%' to express + * like-strategy: starts with (string%), ends with (%string) or contains (%string%). + */ + HistoricCaseInstanceQuery caseDefinitionNameLike(String nameLike); + + /** Only select historic case instances with the given business key */ + HistoricCaseInstanceQuery caseInstanceBusinessKey(String caseInstanceBusinessKey); + + /** + * Only select historic case instances which had a business key like the given value. + * + * @param caseInstanceBusinessKeyLike The string can include the wildcard character '%' to express + * like-strategy: starts with (string%), ends with (%string) or contains (%string%). + */ + HistoricCaseInstanceQuery caseInstanceBusinessKeyLike(String caseInstanceBusinessKeyLike); + + /** + *

Only selects historic case instances with historic case activity instances + * in at least one of the given case activity ids.

+ */ + HistoricCaseInstanceQuery caseActivityIdIn(String... caseActivityIds); + + /** Only select historic case instances that were created before the given date. */ + HistoricCaseInstanceQuery createdBefore(Date date); + + /** Only select historic case instances that were created after the given date. */ + HistoricCaseInstanceQuery createdAfter(Date date); + + /** Only select historic case instances that were closed before the given date. */ + HistoricCaseInstanceQuery closedBefore(Date date); + + /** Only select historic case instances that were closed after the given date. */ + HistoricCaseInstanceQuery closedAfter(Date date); + + /** Only select historic case instance that are created by the given user. */ + HistoricCaseInstanceQuery createdBy(String userId); + + /** Only select historic case instances started by the given case instance. */ + HistoricCaseInstanceQuery superCaseInstanceId(String superCaseInstanceId); + + /** Only select historic case instances having a sub case instance + * with the given case instance id. + * + * Note that there will always be maximum only one + * such case instance that can be the result of this query. + */ + HistoricCaseInstanceQuery subCaseInstanceId(String subCaseInstanceId); + + /** Only select historic case instances started by the given process instance. */ + HistoricCaseInstanceQuery superProcessInstanceId(String superProcessInstanceId); + + /** Only select historic case instances having a sub process instance + * with the given process instance id. + * + * Note that there will always be maximum only one + * such case instance that can be the result of this query. + */ + HistoricCaseInstanceQuery subProcessInstanceId(String subProcessInstanceId); + + /** Only select historic case instances with one of the given tenant ids. */ + HistoricCaseInstanceQuery tenantIdIn(String... tenantIds); + + /** Only selects historic case instances which have no tenant id. */ + HistoricCaseInstanceQuery withoutTenantId(); + + /** Only select historic case instances which are active */ + HistoricCaseInstanceQuery active(); + + /** Only select historic case instances which are completed */ + HistoricCaseInstanceQuery completed(); + + /** Only select historic case instances which are terminated */ + HistoricCaseInstanceQuery terminated(); + + /** Only select historic case instances which are closed */ + HistoricCaseInstanceQuery closed(); + + /** Only select historic case instance that are not yet closed. */ + HistoricCaseInstanceQuery notClosed(); + + /** + * The query will match the names of variables in a case-insensitive way. + */ + HistoricCaseInstanceQuery matchVariableNamesIgnoreCase(); + + /** + * The query will match the values of variables in a case-insensitive way. + */ + HistoricCaseInstanceQuery matchVariableValuesIgnoreCase(); + + /** + * Only select case instances which have a global variable with the given value. + * + * @param name the name of the variable + * @param value the value of the variable + * @throws NotValidException if the name is null + */ + HistoricCaseInstanceQuery variableValueEquals(String name, Object value); + + /** + * Only select case instances which have a global variable with the given name + * but a different value. + * + * @param name the name of the variable + * @param value the value of the variable + * @throws NotValidException if the name is null + */ + HistoricCaseInstanceQuery variableValueNotEquals(String name, Object value); + + /** + * Only select case instances which had a global variable with the given name + * and a value greater than the given value when they where closed. + * + * @param name the name of the variable + * @param value the value of the variable + * @throws NotValidException if the name or value is null + */ + HistoricCaseInstanceQuery variableValueGreaterThan(String name, Object value); + + /** + * Only select case instances which have a global variable with the given name + * and a value greater or equal than the given value. + * + * @param name the name of the variable + * @param value the value of the variable + * @throws NotValidException if the name or value is null + */ + HistoricCaseInstanceQuery variableValueGreaterThanOrEqual(String name, Object value); + + /** + * Only select case instances which have a global variable with the given name + * and a value less than the given value. + * + * @param name the name of the variable + * @param value the value of the variable + * @throws NotValidException if the name or value is null + */ + HistoricCaseInstanceQuery variableValueLessThan(String name, Object value); + + /** + * Only select case instances which have a global variable with the given name + * and a value less or equal than the given value. + * + * @param name the name of the variable + * @param value the value of the variable + * @throws NotValidException if the name or value is null + */ + HistoricCaseInstanceQuery variableValueLessThanOrEqual(String name, Object value); + + /** + * Only select case instances which have a global variable with the given name + * and a value like given value. + * + * @param name the name of the variable + * @param value the value of the variable, it can include the wildcard character '%' + * to express like-strategy: starts with (string%), ends with (%string), + * contains (%string%) + * @throws NotValidException if the name or value is null + */ + HistoricCaseInstanceQuery variableValueLike(String name, String value); + + /** + * Only select case instances which have a global variable + * with the given name and not matching the given value. + * The syntax is that of SQL: for example usage: valueNotLike(%value%) + * @param name the name of the variable + * @param value the value of the variable, it can include the wildcard character '%' + * to express like-strategy: starts with (string%), ends with (%string), + * contains (%string%) + * @throws NotValidException if the name or value is null or a null-value or a boolean-value is used + */ + HistoricCaseInstanceQuery variableValueNotLike(String name, String value); + + /** Order by the case instance id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseInstanceQuery orderByCaseInstanceId(); + + /** Order by the case definition id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseInstanceQuery orderByCaseDefinitionId(); + + /** Order by the business key (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseInstanceQuery orderByCaseInstanceBusinessKey(); + + /** Order by the create time (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseInstanceQuery orderByCaseInstanceCreateTime(); + + /** Order by the close time (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseInstanceQuery orderByCaseInstanceCloseTime(); + + /** Order by the duration of the case instance (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricCaseInstanceQuery orderByCaseInstanceDuration(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of historic case instances without tenant id is database-specific. + */ + HistoricCaseInstanceQuery orderByTenantId(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInputInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInputInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..11a8b5c09c9aea0c15758c81c7f913d9427d20e9 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInputInstance.java @@ -0,0 +1,80 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.variable.value.TypedValue; + +/** + * Represents one input variable of a decision evaluation. + * + * @author Philipp Ossler + */ +public interface HistoricDecisionInputInstance { + + /** The unique identifier of this historic decision input instance. */ + String getId(); + + /** The unique identifier of the historic decision instance. */ + String getDecisionInstanceId(); + + /** The unique identifier of the clause that the value is assigned for. + * Can be null if the decision is not implemented as decision table. */ + String getClauseId(); + + /** The name of the clause that the value is assigned for. + * Can be null if the decision is not implemented as decision table. */ + String getClauseName(); + + /** + * Returns the type name of the variable + */ + String getTypeName(); + + /** + * Returns the value of this variable instance. + */ + Object getValue(); + + /** + * Returns the {@link TypedValue} for this value. + */ + TypedValue getTypedValue(); + + /** + * If the variable value could not be loaded, this returns the error message. + * + * @return an error message indicating why the variable value could not be loaded. + */ + String getErrorMessage(); + + /** + * Returns time when the variable was created. + */ + Date getCreateTime(); + + /** + * Returns the root process instance id of the process instance + * on which the associated business rule task has been called. + */ + String getRootProcessInstanceId(); + + /** The time the historic decision instance will be removed. */ + Date getRemovalTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..eb58f2a82ed9a1957a76f5d7b52816cef7c86c09 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstance.java @@ -0,0 +1,131 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.ProcessEngineException; + +/** + * Represents one evaluation of a decision. + * + * @author Philipp Ossler + * @author Ingo Richtsmeier + * + */ +public interface HistoricDecisionInstance { + + /** The unique identifier of this historic decision instance. */ + String getId(); + + /** The decision definition reference. */ + String getDecisionDefinitionId(); + + /** The unique identifier of the decision definition */ + String getDecisionDefinitionKey(); + + /** The name of the decision definition */ + String getDecisionDefinitionName(); + + /** Time when the decision was evaluated. */ + Date getEvaluationTime(); + + /** Time when the historic decision instance is to be removed. */ + Date getRemovalTime(); + + /** The corresponding key of the process definition in case the decision was evaluated inside a process. */ + String getProcessDefinitionKey(); + + /** The corresponding id of the process definition in case the decision was evaluated inside a process. */ + String getProcessDefinitionId(); + + /** The corresponding process instance in case the decision was evaluated inside a process. */ + String getProcessInstanceId(); + + /** The corresponding key of the case definition in case the decision was evaluated inside a case. */ + String getCaseDefinitionKey(); + + /** The corresponding id of the case definition in case the decision was evaluated inside a case. */ + String getCaseDefinitionId(); + + /** The corresponding case instance in case the decision was evaluated inside a case. */ + String getCaseInstanceId(); + + /** The corresponding activity in case the decision was evaluated inside a process or a case. */ + String getActivityId(); + + /** The corresponding activity instance in case the decision was evaluated inside a process or a case. */ + String getActivityInstanceId(); + + /** + * The user ID in case the decision was evaluated by an authenticated user using the decision service + * outside of an execution context. + */ + String getUserId(); + + /** + * The input values of the evaluated decision. The fetching of the input values must be enabled on the query. + * + * @throws ProcessEngineException if the input values are not fetched. + * + * @see HistoricDecisionInstanceQuery#includeInputs() + */ + List getInputs(); + + /** + * The output values of the evaluated decision. The fetching of the output values must be enabled on the query. + * + * @throws ProcessEngineException if the output values are not fetched. + * + * @see HistoricDecisionInstanceQuery#includeOutputs() + */ + List getOutputs(); + + /** The result of the collect operation if the hit policy 'collect' was used for the decision. */ + Double getCollectResultValue(); + + /** + * The unique identifier of the historic decision instance of the evaluated root decision. + * Can be null if this instance is the root decision instance of the evaluation. + */ + String getRootDecisionInstanceId(); + + /** + * The unique identifier of the root historic process instance of the evaluated root decision + * in case the decision was evaluated inside a process, otherwise null. + */ + String getRootProcessInstanceId(); + + /** + * The id of the related decision requirements definition. Can be + * null if the decision has no relations to other decisions. + */ + String getDecisionRequirementsDefinitionId(); + + /** + * The key of the related decision requirements definition. Can be + * null if the decision has no relations to other decisions. + */ + String getDecisionRequirementsDefinitionKey(); + + /** + * The id of the tenant this historic decision instance belongs to. Can be null + * if the historic decision instance belongs to no single tenant. + */ + String getTenantId(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..633a6bab62f98fd7e0a0fcf565e6f0c48078c583 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstanceQuery.java @@ -0,0 +1,151 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.query.Query; + +/** + * Allows programmatic querying of {@link HistoricDecisionInstance}s. + * + * @author Philipp Ossler + */ +public interface HistoricDecisionInstanceQuery extends Query { + + /** Only select historic decision instances with the given decision instance id. */ + HistoricDecisionInstanceQuery decisionInstanceId(String decisionInstanceId); + + /** Only select historic decision instances whose id is in the given list of ids. */ + HistoricDecisionInstanceQuery decisionInstanceIdIn(String... decisionInstanceIdIn); + + /** Only select historic decision instances for the given decision definition */ + HistoricDecisionInstanceQuery decisionDefinitionId(String decisionDefinitionId); + + /** Only select historic decision instances for the given decision definitions */ + HistoricDecisionInstanceQuery decisionDefinitionIdIn(String... decisionDefinitionIdIn); + + /** Only select historic decision instances with the given key of the decision definition. */ + HistoricDecisionInstanceQuery decisionDefinitionKey(String decisionDefinitionKey); + + /** Only select historic decision instances with the given keys of the decision definition. */ + HistoricDecisionInstanceQuery decisionDefinitionKeyIn(String... decisionDefinitionKeyIn); + + /** Only select historic decision instances with the given name of the decision definition. */ + HistoricDecisionInstanceQuery decisionDefinitionName(String decisionDefinitionName); + + /** + * Only select historic decision instances with the given name of the decision definition using LIKE construct. + */ + HistoricDecisionInstanceQuery decisionDefinitionNameLike(String decisionDefinitionNameLike); + + /** Only select historic decision instances that are evaluated inside a process + * with the given process definition key. */ + HistoricDecisionInstanceQuery processDefinitionKey(String processDefinitionKey); + + /** Only select historic decision instances that are evaluated inside a process + * with the given process definition id. */ + HistoricDecisionInstanceQuery processDefinitionId(String processDefinitionId); + + /** Only select historic decision instances that are evaluated inside a process + * with the given process instance id. */ + HistoricDecisionInstanceQuery processInstanceId(String processInstanceId); + + /** Only select historic decision instances that are evaluated inside a case + * with the given case definition key. */ + HistoricDecisionInstanceQuery caseDefinitionKey(String caseDefinitionKey); + + /** Only select historic decision instances that are evaluated inside a case + * with the given case definition id. */ + HistoricDecisionInstanceQuery caseDefinitionId(String caseDefinitionId); + + /** Only select historic decision instances that are evaluated inside a case + * with the given case instance id. */ + HistoricDecisionInstanceQuery caseInstanceId(String caseInstanceId); + + /** Only select historic decision instances that are evaluated inside a process or a case + * which have one of the activity ids. */ + HistoricDecisionInstanceQuery activityIdIn(String... activityIds); + + /** Only select historic decision instances that are evaluated inside a process or a case + * which have one of the activity instance ids. */ + HistoricDecisionInstanceQuery activityInstanceIdIn(String... activityInstanceIds); + + /** Only select historic decision instances that were evaluated before the given date. */ + HistoricDecisionInstanceQuery evaluatedBefore(Date date); + + /** Only select historic decision instances that were evaluated after the given date. */ + HistoricDecisionInstanceQuery evaluatedAfter(Date date); + + /** Only select historic decision instances that were evaluated by the user with the given user ID. + *

The user ID is saved for decisions which are evaluated by a authenticated user without a process or + * case instance */ + HistoricDecisionInstanceQuery userId(String userId); + + /** Enable fetching {@link HistoricDecisionInputInstance} of evaluated decision. */ + HistoricDecisionInstanceQuery includeInputs(); + + /** Enable fetching {@link HistoricDecisionOutputInstance} of evaluated decision. */ + HistoricDecisionInstanceQuery includeOutputs(); + + /** Disable fetching of byte array input and output values. By default, the query will fetch the value of a byte array. + * By calling this method you can prevent the values of (potentially large) blob data chunks to be fetched. */ + HistoricDecisionInstanceQuery disableBinaryFetching(); + + /** Disable deserialization of input and output values that are custom objects. By default, the query + * will attempt to deserialize the value of these variables. By calling this method you can + * prevent such attempts in environments where their classes are not available. + * Independent of this setting, variable serialized values are accessible. */ + HistoricDecisionInstanceQuery disableCustomObjectDeserialization(); + + /** + * Only select historic decision instances with a given root historic decision + * instance id. This also includes the historic decision instance with the + * given id. + */ + HistoricDecisionInstanceQuery rootDecisionInstanceId(String decisionInstanceId); + + /** Only select historic decision instances that are the root decision instance of an evaluation. */ + HistoricDecisionInstanceQuery rootDecisionInstancesOnly(); + + /** Only select historic decision instances that belongs to a decision requirements definition with the given id. */ + HistoricDecisionInstanceQuery decisionRequirementsDefinitionId(String decisionRequirementsDefinitionId); + + /** Only select historic decision instances that belongs to a decision requirements definition with the given key. */ + HistoricDecisionInstanceQuery decisionRequirementsDefinitionKey(String decisionRequirementsDefinitionKey); + + /** Only select historic decision instances with one of the given tenant ids. */ + HistoricDecisionInstanceQuery tenantIdIn(String... tenantIds); + + /** Only selects historic decision instances that have no tenant id. */ + HistoricDecisionInstanceQuery withoutTenantId(); + + /** Order by decision instance id + * (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricDecisionInstanceQuery orderByDecisionInstanceId(); + + /** Order by the time when the decisions was evaluated + * (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricDecisionInstanceQuery orderByEvaluationTime(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of historic decision instances without tenant id is database-specific. + */ + HistoricDecisionInstanceQuery orderByTenantId(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstanceStatistics.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstanceStatistics.java new file mode 100644 index 0000000000000000000000000000000000000000..69893c06bdd71660b947b844673cf523b049d6f6 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstanceStatistics.java @@ -0,0 +1,33 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +/** + * @author Askar Akhmerov + */ +public interface HistoricDecisionInstanceStatistics { + + /** + * @return count of decision definition evaluations + */ + int getEvaluations(); + + /** + * @return key of decision definition + */ + String getDecisionDefinitionKey(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstanceStatisticsQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstanceStatisticsQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..381368ed4bf3554230f137fd52a8c2529be03678 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionInstanceStatisticsQuery.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.Query; + + +/** + * @author Askar Akhmerov + */ +public interface HistoricDecisionInstanceStatisticsQuery extends Query { + + /** + * Restrict query results to be based only on specified decision instance id + * + * @param decisionInstanceId - decision instance based on which constraint will be applied + * @return - query object to execute + */ + HistoricDecisionInstanceStatisticsQuery decisionInstanceId(String decisionInstanceId); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionOutputInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionOutputInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..0ff3e4bbc6fda2f35ba9efa1b008af79bb6df704 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDecisionOutputInstance.java @@ -0,0 +1,91 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.variable.value.TypedValue; + +/** + * Represents one output variable of a decision evaluation. + * + * @author Philipp Ossler + */ +public interface HistoricDecisionOutputInstance { + + /** The unique identifier of this historic decision output instance. */ + String getId(); + + /** The unique identifier of the historic decision instance. */ + String getDecisionInstanceId(); + + /** The unique identifier of the clause that the value is assigned for. + * Can be null if the decision is not implemented as decision table. */ + String getClauseId(); + + /** The name of the clause that the value is assigned for. + * Can be null if the decision is not implemented as decision table. */ + String getClauseName(); + + /** The unique identifier of the rule that is matched. + * Can be null if the decision is not implemented as decision table. */ + String getRuleId(); + + /** The order of the rule that is matched. + * Can be null if the decision is not implemented as decision table. */ + Integer getRuleOrder(); + + /** The name of the output variable. */ + String getVariableName(); + + /** + * Returns the type name of the variable + */ + String getTypeName(); + + /** + * Returns the value of this variable instance. + */ + Object getValue(); + + /** + * Returns the {@link TypedValue} for this value. + */ + TypedValue getTypedValue(); + + /** + * If the variable value could not be loaded, this returns the error message. + * + * @return an error message indicating why the variable value could not be loaded. + */ + String getErrorMessage(); + + /** + * Returns time when the variable was created. + */ + Date getCreateTime(); + + /** + * Returns the root process instance id of the process instance + * on which the associated business rule task has been called. + */ + String getRootProcessInstanceId(); + + /** The time the historic decision instance will be removed. */ + Date getRemovalTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDetail.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDetail.java new file mode 100644 index 0000000000000000000000000000000000000000..d431a5d89bb11d6250f9ac76fd121710b736b18a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDetail.java @@ -0,0 +1,84 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + + + +/** Base class for all kinds of information that is related to + * either a {@link HistoricProcessInstance} or a {@link HistoricActivityInstance}. + * + * @author Tom Baeyens + */ +public interface HistoricDetail { + + /** The unique DB id for this historic detail */ + String getId(); + + /** The process definition key reference. */ + String getProcessDefinitionKey(); + + /** The process definition reference. */ + String getProcessDefinitionId(); + + /** The root process instance reference */ + String getRootProcessInstanceId(); + + /** The process instance reference. */ + String getProcessInstanceId(); + + /** The activity reference in case this detail is related to an activity instance. */ + String getActivityInstanceId(); + + /** The identifier for the path of execution. */ + String getExecutionId(); + + /** The case definition key reference. */ + String getCaseDefinitionKey(); + + /** The case definition reference. */ + String getCaseDefinitionId(); + + /** The case instance reference. */ + String getCaseInstanceId(); + + /** The case execution reference. */ + String getCaseExecutionId(); + + /** The identifier for the task. */ + String getTaskId(); + + /** The time when this detail occurred */ + Date getTime(); + + /** + * The id of the tenant this historic detail belongs to. Can be null + * if the historic detail belongs to no single tenant. + */ + String getTenantId(); + + /** + * The id of operation. Helps to link records in different historic tables. + * References operationId of user operation log entry. + */ + String getUserOperationId(); + + /** The time the historic detail will be removed. */ + Date getRemovalTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDetailQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDetailQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..c20eacb39c4d807c0696caf3a17a7bb65d371ab0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricDetailQuery.java @@ -0,0 +1,210 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; +import org.camunda.bpm.engine.query.Query; +import org.camunda.bpm.engine.runtime.CaseExecution; +import org.camunda.bpm.engine.runtime.CaseInstance; +import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.runtime.VariableInstance; + +/** + * Programmatic querying for {@link HistoricDetail}s. + * + * @author Tom Baeyens + */ +public interface HistoricDetailQuery extends Query { + + /** + * Only select the historic detail with the given id. + * + * @param id the historic detail to select + * @return the query builder + */ + HistoricDetailQuery detailId(String id); + + /** Only select historic variable updates with the given process instance. + * {@link ProcessInstance} ids and {@link HistoricProcessInstance} ids match. */ + HistoricDetailQuery processInstanceId(String processInstanceId); + + /** Only select historic variable updates with the given case instance. + * {@link CaseInstance} ids and {@link HistoricCaseInstance} ids match. */ + HistoricDetailQuery caseInstanceId(String caseInstanceId); + + /** Only select historic variable updates with the given execution. + * Note that {@link Execution} ids are not stored in the history as first class citizen, + * only process instances are.*/ + HistoricDetailQuery executionId(String executionId); + + /** Only select historic variable updates with the given case execution. + * Note that {@link CaseExecution} ids are not stored in the history as first class citizen, + * only case instances are.*/ + HistoricDetailQuery caseExecutionId(String caseExecutionId); + + /** Only select historic variable updates associated to the given {@link HistoricActivityInstance activity instance}. + * @deprecated since 5.2, use {@link #activityInstanceId(String)} instead */ + HistoricDetailQuery activityId(String activityId); + + /** Only select historic variable updates associated to the given {@link HistoricActivityInstance activity instance}. */ + HistoricDetailQuery activityInstanceId(String activityInstanceId); + + /** Only select historic variable updates associated to the given {@link HistoricTaskInstance historic task instance}. */ + HistoricDetailQuery taskId(String taskId); + + /** Only select historic variable updates associated to the given {@link HistoricVariableInstance historic variable instance}. */ + HistoricDetailQuery variableInstanceId(String variableInstanceId); + + /** Only select historic process variables which match one of the given variable types. */ + HistoricDetailQuery variableTypeIn(String... variableTypes); + + /** Only select historic process variables that have a name matching the criteria. + * The syntax is that of SQL: for example usage: variableNameLike(%camunda%). + * The query will match the names of variables in a case-insensitive way. + */ + HistoricDetailQuery variableNameLike(String variableNameLike); + + /** Only select {@link HistoricFormProperty}s. */ + @Deprecated + HistoricDetailQuery formProperties(); + + /** Only select {@link HistoricFormField}s. */ + HistoricDetailQuery formFields(); + + /** Only select {@link HistoricVariableUpdate}s. */ + HistoricDetailQuery variableUpdates(); + + /** + * Disable fetching of byte array and file values. By default, the query will fetch such values. + * By calling this method you can prevent the values of (potentially large) blob data chunks to be fetched. + * The variables themselves are nonetheless included in the query result. + * + * @return the query builder + */ + HistoricDetailQuery disableBinaryFetching(); + + /** + * Disable deserialization of variable values that are custom objects. By default, the query + * will attempt to deserialize the value of these variables. By calling this method you can + * prevent such attempts in environments where their classes are not available. + * Independent of this setting, variable serialized values are accessible. + */ + HistoricDetailQuery disableCustomObjectDeserialization(); + + /** Exclude all task-related {@link HistoricDetail}s, so only items which have no + * task-id set will be selected. When used together with {@link #taskId(String)}, this + * call is ignored task details are NOT excluded. + */ + HistoricDetailQuery excludeTaskDetails(); + + /** Only select historic details with one of the given tenant ids. */ + HistoricDetailQuery tenantIdIn(String... tenantIds); + + /** Only selects historic details that have no tenant id. */ + HistoricDetailQuery withoutTenantId(); + + /** Only select historic details with the given process instance ids. */ + HistoricDetailQuery processInstanceIdIn(String... processInstanceIds); + + /** + * Select historic details related with given userOperationId. + */ + HistoricDetailQuery userOperationId(String userOperationId); + + /** Only select historic details that have occurred before the given date (inclusive). */ + HistoricDetailQuery occurredBefore(Date date); + + /** Only select historic details that have occurred after the given date (inclusive). */ + HistoricDetailQuery occurredAfter(Date date); + + /** Only select historic details that were set during the process start. */ + HistoricDetailQuery initial(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of historic details without tenant id is database-specific. + */ + HistoricDetailQuery orderByTenantId(); + + HistoricDetailQuery orderByProcessInstanceId(); + + HistoricDetailQuery orderByVariableName(); + + HistoricDetailQuery orderByFormPropertyId(); + + HistoricDetailQuery orderByVariableType(); + + HistoricDetailQuery orderByVariableRevision(); + + HistoricDetailQuery orderByTime(); + + /** + *

Sort the {@link HistoricDetail historic detail events} in the order in which + * they occurred and needs to be followed by {@link #asc()} or {@link #desc()}.

+ * + *

The set of all {@link HistoricVariableUpdate historic variable update events} is + * a partially ordered set. Due to this fact {@link HistoricVariableUpdate + * historic variable update events} for two different {@link VariableInstance variable + * instances} are incomparable. So that it is not possible to sort + * the {@link HistoricDetail historic variable update events} for two {@link VariableInstance + * variable instances} in the order they occurred. Just for one {@link VariableInstance variable + * instance} the set of {@link HistoricVariableUpdate historic variable update events} can be + * totally ordered by using {@link #variableInstanceId(String)} and {@link + * #orderPartiallyByOccurrence()} which will return a result set ordered by its occurrence.

+ * + *

For example:
+ * An execution variable myVariable will be updated multiple times:

+ * + * + * runtimeService.setVariable("anExecutionId", "myVariable", 1000);
+ * execution.setVariable("myVariable", 5000);
+ * runtimeService.setVariable("anExecutionId", "myVariable", 2500);
+ * runtimeService.removeVariable("anExecutionId", "myVariable"); + *
+ * + *

As a result there exists four {@link HistoricVariableUpdate historic variable update events}.

+ * + *

By using {@link #variableInstanceId(String)} and {@link #orderPartiallyByOccurrence()} it + * is possible to sort the events in the order in which they occurred. The following query

+ * + * + * historyService.createHistoricDetailQuery()
+ *   .variableInstanceId("myVariableInstId")
+ *   .orderPartiallyByOccurrence()
+ *   .asc()
+ *   .list() + *
+ * + *

will return the following totally ordered result set

+ * + * + * [
+ *   HistoricVariableUpdate[id: "myVariableInstId", variableName: "myVariable", value: 1000],
+ *   HistoricVariableUpdate[id: "myVariableInstId", variableName: "myVariable", value: 5000],
+ *   HistoricVariableUpdate[id: "myVariableInstId", variableName: "myVariable", value: 2500]
+ *   HistoricVariableUpdate[id: "myVariableInstId", variableName: "myVariable", value: null]
+ * ] + *
+ * + *

Note:
+ * Please note that a {@link HistoricFormField historic form field event} can occur only once.

+ * + * @since 7.3 + */ + HistoricDetailQuery orderPartiallyByOccurrence(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricExternalTaskLog.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricExternalTaskLog.java new file mode 100644 index 0000000000000000000000000000000000000000..053876d93a4ec65a4ebd9a01c0b0069737bec9b2 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricExternalTaskLog.java @@ -0,0 +1,149 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.HistoryService; +import org.camunda.bpm.engine.externaltask.ExternalTask; + +import java.util.Date; + +/** + *

The {@link HistoricExternalTaskLog} is used to have a log containing + * information about {@link ExternalTask task} execution. The log provides + * details about the last lifecycle state of a {@link ExternalTask task}:

+ * + * An instance of {@link HistoricExternalTaskLog} represents the latest historic + * state in the lifecycle of a {@link ExternalTask task}. + * + * @since 7.7 + */ +public interface HistoricExternalTaskLog { + + /** + * Returns the unique identifier for this historic external task log. + */ + String getId(); + + /** + * Returns the time when this log occurred. + */ + Date getTimestamp(); + + /** + * Returns the id of the associated external task. + */ + String getExternalTaskId(); + + /** + * Returns the retries of the associated external task before the associated external task has + * been executed and when this log occurred. + */ + Integer getRetries(); + + /** + * Returns the priority of the associated external task when this log entry was created. + */ + long getPriority(); + + /** + * Returns the topic name of the associated external task. + */ + String getTopicName(); + + /** + * Returns the id of the worker that fetched the external task most recently. + */ + String getWorkerId(); + + /** + * Returns the message of the error that occurred by executing the associated external task. + * + * To get the full error details, + * use {@link HistoryService#getHistoricExternalTaskLogErrorDetails(String)} + */ + String getErrorMessage(); + + /** + * Returns the id of the activity which the external task associated with. + */ + String getActivityId(); + + /** + * Returns the id of the activity instance on which the associated external task was created. + */ + String getActivityInstanceId(); + + /** + * Returns the specific execution id on which the associated external task was created. + */ + String getExecutionId(); + + /** + * Returns the specific root process instance id of the process instance + * on which the associated external task was created. + */ + String getRootProcessInstanceId(); + + /** + * Returns the specific process instance id on which the associated external task was created. + */ + String getProcessInstanceId(); + + /** + * Returns the specific process definition id on which the associated external task was created. + */ + String getProcessDefinitionId(); + + /** + * Returns the specific process definition key on which the associated external task was created. + */ + String getProcessDefinitionKey(); + + /** + * Returns the id of the tenant this external task log entry belongs to. Can be null + * if the external task log entry belongs to no single tenant. + */ + String getTenantId(); + + /** + * Returns true when this log represents + * the creation of the associated external task. + */ + boolean isCreationLog(); + + /** + * Returns true when this log represents + * the failed execution of the associated external task. + */ + boolean isFailureLog(); + + /** + * Returns true when this log represents + * the successful execution of the associated external task. + */ + boolean isSuccessLog(); + + /** + * Returns true when this log represents + * the deletion of the associated external task. + */ + boolean isDeletionLog(); + + /** The time the historic external task log will be removed. */ + Date getRemovalTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricExternalTaskLogQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricExternalTaskLogQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..0803852bf219369c9658fb02c1afaffe63345fa5 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricExternalTaskLogQuery.java @@ -0,0 +1,130 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.Query; + +public interface HistoricExternalTaskLogQuery extends Query { + + /** Only select historic external task log entries with the id. */ + HistoricExternalTaskLogQuery logId(String historicExternalTaskLogId); + + /** Only select historic external task log entries with the given external task id. */ + HistoricExternalTaskLogQuery externalTaskId(String taskId); + + /** Only select historic external task log entries with the given topic name. */ + HistoricExternalTaskLogQuery topicName(String topicName); + + /** Only select historic external task log entries with the given worker id. */ + HistoricExternalTaskLogQuery workerId(String workerId); + + /** Only select historic external task log entries with the given error message. */ + HistoricExternalTaskLogQuery errorMessage(String errorMessage); + + /** Only select historic external task log entries which are associated with one of the given activity ids. **/ + HistoricExternalTaskLogQuery activityIdIn(String... activityIds); + + /** Only select historic external task log entries which are associated with one of the given activity instance ids. **/ + HistoricExternalTaskLogQuery activityInstanceIdIn(String... activityInstanceIds); + + /** Only select historic external task log entries which are associated with one of the given execution ids. **/ + HistoricExternalTaskLogQuery executionIdIn(String... executionIds); + + /** Only select historic external task log entries with the process instance id. */ + HistoricExternalTaskLogQuery processInstanceId(String processInstanceId); + + /** Only select historic external task log entries with the process definition id. */ + HistoricExternalTaskLogQuery processDefinitionId(String processDefinitionId); + + /** Only select historic external task log entries with the process instance key. */ + HistoricExternalTaskLogQuery processDefinitionKey(String processDefinitionKey); + + /** Only select historic external task log entries that belong to one of the given tenant ids. */ + HistoricExternalTaskLogQuery tenantIdIn(String... tenantIds); + + /** Only selects historic external task log entries that have no tenant id. */ + HistoricExternalTaskLogQuery withoutTenantId(); + + /** + * Only select log entries where the external task had a priority higher than or + * equal to the given priority. + */ + HistoricExternalTaskLogQuery priorityHigherThanOrEquals(long priority); + + /** + * Only select log entries where the external task had a priority lower than or + * equal to the given priority. + */ + HistoricExternalTaskLogQuery priorityLowerThanOrEquals(long priority); + + /** Only select created historic external task log entries. */ + HistoricExternalTaskLogQuery creationLog(); + + /** Only select failed historic external task log entries. */ + HistoricExternalTaskLogQuery failureLog(); + + /** Only select successful historic external task log entries. */ + HistoricExternalTaskLogQuery successLog(); + + /** Only select deleted historic external task log entries. */ + HistoricExternalTaskLogQuery deletionLog(); + + + /** Order by timestamp (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByTimestamp(); + + /** Order by external task id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByExternalTaskId(); + + /** Order by external task retries (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByRetries(); + + /** + * Order by external task priority (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricExternalTaskLogQuery orderByPriority(); + + /** Order by topic name (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByTopicName(); + + /** Order by worker id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByWorkerId(); + + /** Order by activity id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByActivityId(); + + /** Order by activity instance id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByActivityInstanceId(); + + /** Order by execution id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByExecutionId(); + + /** Order by process instance id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByProcessInstanceId(); + + /** Order by process definition id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByProcessDefinitionId(); + + /** Order by process definition key (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricExternalTaskLogQuery orderByProcessDefinitionKey(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of external task log entries without tenant id is database-specific. + */ + HistoricExternalTaskLogQuery orderByTenantId(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricFormField.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricFormField.java new file mode 100644 index 0000000000000000000000000000000000000000..489bb498b50ba7464bf07e9f8b9a9d8d219ef75b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricFormField.java @@ -0,0 +1,33 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +/** + *

Historic form fields

+ * + * @author Daniel Meyer + * + */ +public interface HistoricFormField extends HistoricDetail { + + /** the id or key of the property */ + String getFieldId(); + + /** the submitted value */ + Object getFieldValue(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricFormProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricFormProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..2e27471c4d78a169c2988371895ffff3f9db0847 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricFormProperty.java @@ -0,0 +1,35 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + + +/** A single field that was submitted in either a start form or a task form. + * This is the audit information that can be used to trace who supplied which + * input for which tasks at what time. + * + * @author Tom Baeyens + */ +@Deprecated +public interface HistoricFormProperty extends HistoricDetail { + + /** the id or key of the property */ + String getPropertyId(); + + /** the submitted value */ + String getPropertyValue(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIdentityLinkLog.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIdentityLinkLog.java new file mode 100644 index 0000000000000000000000000000000000000000..475b1b79f0ffd4224d945822dd63c4414005037a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIdentityLinkLog.java @@ -0,0 +1,107 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.identity.GroupQuery; +import org.camunda.bpm.engine.identity.UserQuery; + +import java.util.Date; + + +/** + * An historic identity link stores the association of a task with a certain identity. + * + * For example, historic identity link is logged on the following conditions: + * - a user can be an assignee/Candidate/Owner (= identity link type) for a task + * - a group can be a candidate-group (= identity link type) for a task + * - a user can be an candidate in the scope of process definition + * - a group can be a candidate-group in the scope of process definition + * + * For every log, an operation type (add/delete) is added to the database + * based on the identity link operation + */ +public interface HistoricIdentityLinkLog { + + /** + * Returns the id of historic identity link (Candidate or Assignee or Owner). + */ + String getId(); + /** + * Returns the type of link (Candidate or Assignee or Owner). + * See {@link IdentityLinkType} for the native supported types by the process engine. + * + * */ + String getType(); + + /** + * If the identity link involves a user, then this will be a non-null id of a user. + * That userId can be used to query for user information through the {@link UserQuery} API. + */ + String getUserId(); + + /** + * If the identity link involves a group, then this will be a non-null id of a group. + * That groupId can be used to query for user information through the {@link GroupQuery} API. + */ + String getGroupId(); + + /** + * The id of the task associated with this identity link. + */ + String getTaskId(); + + /** + * Returns the userId of the user who assigns a task to the user + * + */ + String getAssignerId(); + + /** + * Returns the type of identity link history (add or delete identity link) + */ + String getOperationType(); + + /** + * Returns the time of identity link event (Creation/Deletion) + */ + Date getTime(); + + /** + * Returns the id of the related process definition + */ + String getProcessDefinitionId(); + + /** + * Returns the key of the related process definition + */ + String getProcessDefinitionKey(); + + /** + * Returns the id of the related tenant + */ + String getTenantId(); + + /** + * Returns the root process instance id of + * the related process instance + */ + String getRootProcessInstanceId(); + + /** The time the historic identity link log will be removed. */ + Date getRemovalTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIdentityLinkLogQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIdentityLinkLogQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..ef91143c8c22919a2b62e3e120bb1ebcd3eebbcd --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIdentityLinkLogQuery.java @@ -0,0 +1,136 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.query.Query; + +/** + * @author Deivarayan Azhagappan + */ +public interface HistoricIdentityLinkLogQuery extends Query { + + /** + * Only select historic identity links which have the date before the give date. + **/ + HistoricIdentityLinkLogQuery dateBefore(Date dateBefore); + + /** + * Only select historic identity links which have the date after the give date. + **/ + HistoricIdentityLinkLogQuery dateAfter(Date dateAfter); + + /** + * Only select historic identity links which have the given identity link type. + **/ + HistoricIdentityLinkLogQuery type(String type); + + /** + * Only select historic identity links which have the given user id. + **/ + HistoricIdentityLinkLogQuery userId(String userId); + + /** + * Only select historic identity links which have the given group id. + **/ + HistoricIdentityLinkLogQuery groupId(String groupId); + + /** + * Only select historic identity links which have the given task id. + **/ + HistoricIdentityLinkLogQuery taskId(String taskId); + + /** + * Only select historic identity links which have the given process definition id. + **/ + HistoricIdentityLinkLogQuery processDefinitionId(String processDefinitionId); + + /** + * Only select historic identity links which have the given process definition key. + **/ + HistoricIdentityLinkLogQuery processDefinitionKey(String processDefinitionKey); + + /** + * Only select historic identity links which have the given operation type (add/delete). + **/ + HistoricIdentityLinkLogQuery operationType(String operationType); + + /** + * Only select historic identity links which have the given assigner id. + **/ + HistoricIdentityLinkLogQuery assignerId(String assignerId); + + /** + * Only select historic identity links which have the given tenant id. + **/ + HistoricIdentityLinkLogQuery tenantIdIn(String... tenantId); + + /** Only selects historic job log entries that have no tenant id. */ + HistoricIdentityLinkLogQuery withoutTenantId(); + + /** + * Order by time (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricIdentityLinkLogQuery orderByTime(); + + /** + * Order by type (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricIdentityLinkLogQuery orderByType(); + + /** + * Order by userId (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricIdentityLinkLogQuery orderByUserId(); + + /** + * Order by groupId (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricIdentityLinkLogQuery orderByGroupId(); + + /** + * Order by taskId (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricIdentityLinkLogQuery orderByTaskId(); + + /** + * Order by processDefinitionId (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricIdentityLinkLogQuery orderByProcessDefinitionId(); + + /** + * Order by processDefinitionKey (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricIdentityLinkLogQuery orderByProcessDefinitionKey(); + + /** + * Order by operationType (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricIdentityLinkLogQuery orderByOperationType(); + + /** + * Order by assignerId (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricIdentityLinkLogQuery orderByAssignerId(); + + /** + * Order by tenantId (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricIdentityLinkLogQuery orderByTenantId(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIncident.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIncident.java new file mode 100644 index 0000000000000000000000000000000000000000..a3519084f9634b9d1834bdf83a686253754dd1e6 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIncident.java @@ -0,0 +1,163 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.runtime.Incident; + +/** + * Represents a historic {@link Incident incident} that is stored permanently. + * + * @author Roman Smirnov + * + */ +public interface HistoricIncident { + + /** + * Returns the unique identifier for this incident. + */ + String getId(); + + /** + * Time when the incident happened. + */ + Date getCreateTime(); + + /** + * Time when the incident has been resolved or deleted. + */ + Date getEndTime(); + + /** + * Returns the type of this incident to identify the + * kind of incident. + * + *

+ * + * For example: failedJobs will be returned + * in the case of an incident, which identify failed job + * during the execution of a process instance. + */ + String getIncidentType(); + + /** + * Returns the incident message. + */ + String getIncidentMessage(); + + /** + * Returns the specific execution on which this + * incident has happened. + */ + String getExecutionId(); + + /** + * Returns the id of the activity of the process instance + * on which this incident has happened. + */ + String getActivityId(); + + /** + * Returns the specific root process instance id of the process instance + * on which this incident has happened. + */ + String getRootProcessInstanceId(); + + /** + * Returns the specific process instance on which this + * incident has happened. + */ + String getProcessInstanceId(); + + /** + * Returns the id of the process definition of this + * process instance on which the incident has happened. + */ + String getProcessDefinitionId(); + + /** + * Returns the key of the process definition of this + * process instance on which the incident has happened. + */ + String getProcessDefinitionKey(); + + /** + * Returns the id of the incident on which this incident + * has been triggered. + */ + String getCauseIncidentId(); + + /** + * Returns the id of the root incident on which + * this transitive incident has been triggered. + */ + String getRootCauseIncidentId(); + + /** + * Returns the payload of this incident. + */ + String getConfiguration(); + + /** + * Returns the history payload of this incident. + */ + String getHistoryConfiguration(); + + /** + * Returns true, iff the corresponding incident + * has not been deleted or resolved. + */ + boolean isOpen(); + + /** + * Returns true, iff the corresponding incident + * has been deleted. + */ + boolean isDeleted(); + + /** + * Returns true, iff the corresponding incident + * has been resolved. + */ + boolean isResolved(); + + /** + * Returns the id of the tenant this incident belongs to. Can be null + * if the incident belongs to no single tenant. + */ + String getTenantId(); + + /** + * Returns the id of the job definition the incident belongs to. Can be null + * if the incident belongs to no job definition. + */ + String getJobDefinitionId(); + + /** The time the historic incident will be removed. */ + Date getRemovalTime(); + + /** + * Returns the id of the activity on which the last exception occurred. + */ + String getFailedActivityId(); + + /** + * Returns the annotation of this incident + */ + String getAnnotation(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIncidentQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIncidentQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..2dab52750429f65280c8d0fa1a6137303d9d198e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricIncidentQuery.java @@ -0,0 +1,160 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.Query; + +import java.util.Date; + +/** + * @author Roman Smirnov + * + */ +public interface HistoricIncidentQuery extends Query { + + /** Only select historic incidents which have the given id. **/ + HistoricIncidentQuery incidentId(String incidentId); + + /** Only select historic incidents which have the given incident type. **/ + HistoricIncidentQuery incidentType(String incidentType); + + /** Only select historic incidents which have the given incident message. **/ + HistoricIncidentQuery incidentMessage(String incidentMessage); + + /** + * Only select historic incidents which incident message is like the given value + * + * @param incidentMessageLike The string can include the wildcard character '%' to express + * like-strategy: starts with (string%), ends with (%string) or contains (%string%). + */ + HistoricIncidentQuery incidentMessageLike(String incidentMessageLike); + + /** Only select historic incidents which have the given process definition id. **/ + HistoricIncidentQuery processDefinitionId(String processDefinitionId); + + /** Only select historic incidents which have the given processDefinitionKey. **/ + HistoricIncidentQuery processDefinitionKey(String processDefinitionKey); + + /** Only select historic incidents which have one of the given process definition keys. **/ + HistoricIncidentQuery processDefinitionKeyIn(String... processDefinitionKeys); + + /** Only select historic incidents which have the given process instance id. **/ + HistoricIncidentQuery processInstanceId(String processInstanceId); + + /** Only select historic incidents with the given id. **/ + HistoricIncidentQuery executionId(String executionId); + + /** Only select historic incidents which have a createTime date before the given date **/ + HistoricIncidentQuery createTimeBefore(Date createTimeBefore); + + /** Only select historic incidents which have a createTime date after the given date **/ + HistoricIncidentQuery createTimeAfter(Date createTimeAfter); + + /** Only select historic incidents which have an endTimeBefore date before the given date **/ + HistoricIncidentQuery endTimeBefore(Date endTimeBefore); + + /** Only select historic incidents which have an endTimeAfter date after the given date **/ + HistoricIncidentQuery endTimeAfter(Date endTimeAfter); + + /** Only select historic incidents which contain an activity with the given id. **/ + HistoricIncidentQuery activityId(String activityId); + + /** Only select historic incidents which were created due to a failure at an activity with the given id. **/ + HistoricIncidentQuery failedActivityId(String activityId); + + /** Only select historic incidents which contain the id of the cause incident. **/ + HistoricIncidentQuery causeIncidentId(String causeIncidentId); + + /** Only select historic incidents which contain the id of the root cause incident. **/ + HistoricIncidentQuery rootCauseIncidentId(String rootCauseIncidentId); + + /** Only select historic incidents that belong to one of the given tenant ids. */ + HistoricIncidentQuery tenantIdIn(String... tenantIds); + + /** Only selects historic incidents that have no tenant id. */ + HistoricIncidentQuery withoutTenantId(); + + /** Only select incidents which contain the configuration. **/ + HistoricIncidentQuery configuration(String configuration); + + /** Only select incidents which contain the historyConfiguration. **/ + HistoricIncidentQuery historyConfiguration(String historyConfiguration); + + /** Only select incidents that belong to one of the given job definition ids. */ + HistoricIncidentQuery jobDefinitionIdIn(String... jobDefinitionIds); + + /** Only select historic incidents which are open. **/ + HistoricIncidentQuery open(); + + /** Only select historic incidents which are resolved. **/ + HistoricIncidentQuery resolved(); + + /** Only select historic incidents which are deleted. **/ + HistoricIncidentQuery deleted(); + + /** Order by id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByIncidentId(); + + /** Order by message (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByIncidentMessage(); + + /** Order by create time (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByCreateTime(); + + /** Order by end time (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByEndTime(); + + /** Order by incidentType (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByIncidentType(); + + /** Order by executionId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByExecutionId(); + + /** Order by activityId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByActivityId(); + + /** Order by processInstanceId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByProcessInstanceId(); + + /** Order by processDefinitionId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByProcessDefinitionId(); + + /** Order by processDefinitionKey (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByProcessDefinitionKey(); + + /** Order by causeIncidentId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByCauseIncidentId(); + + /** Order by rootCauseIncidentId (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByRootCauseIncidentId(); + + /** Order by configuration (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByConfiguration(); + + /** Order by historyConfiguration (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByHistoryConfiguration(); + + /** Order by incidentState (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricIncidentQuery orderByIncidentState(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of incidents without tenant id is database-specific. + */ + HistoricIncidentQuery orderByTenantId(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricJobLog.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricJobLog.java new file mode 100644 index 0000000000000000000000000000000000000000..0619ed6cb96380049a04f4e0bf2c46ca66d7b39c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricJobLog.java @@ -0,0 +1,185 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.HistoryService; +import org.camunda.bpm.engine.runtime.Job; + +/** + *

The {@link HistoricJobLog} is used to have a log containing + * information about {@link Job job} execution. The log provides + * details about the complete lifecycle of a {@link Job job}:

+ *
    + *
  • job created
  • + *
  • job execution failed
  • + *
  • job execution successful
  • + *
  • job was deleted
  • + *
+ * + * An instance of {@link HistoricJobLog} represents a state in + * the lifecycle of a {@link Job job}. + * + * @author Roman Smirnov + * + * @since 7.3 + */ +public interface HistoricJobLog { + + /** + * Returns the unique identifier for this historic job log. + */ + String getId(); + + /** + * Returns the time when this log occurred. + */ + Date getTimestamp(); + + /** + * Returns the id of the associated job. + */ + String getJobId(); + + /** + * Returns the due date of the associated job when this log occurred. + */ + Date getJobDueDate(); + + /** + * Returns the retries of the associated job before the associated job has + * been executed and when this log occurred. + */ + int getJobRetries(); + + /** + * Returns the priority of the associated job when this log entry was created. + * + * @since 7.4 + */ + long getJobPriority(); + + /** + * Returns the message of the exception that occurred by executing the associated job. + * + * To get the full exception stacktrace, + * use {@link HistoryService#getHistoricJobLogExceptionStacktrace(String)} + */ + String getJobExceptionMessage(); + + /** + * Returns the id of the job definition on which the associated job was created. + */ + String getJobDefinitionId(); + + /** + * Returns the job definition type of the associated job. + */ + String getJobDefinitionType(); + + /** + * Returns the job definition configuration type of the associated job. + */ + String getJobDefinitionConfiguration(); + + /** + * Returns the id of the activity on which the associated job was created. + */ + String getActivityId(); + + /** + * Returns the id of the activity on which the last exception occurred. + */ + String getFailedActivityId(); + + /** + * Returns the specific execution id on which the associated job was created. + */ + String getExecutionId(); + + /** + * Returns the specific root process instance id of the process instance + * on which the associated job was created. + */ + String getRootProcessInstanceId(); + + /** + * Returns the specific process instance id on which the associated job was created. + */ + String getProcessInstanceId(); + + /** + * Returns the specific process definition id on which the associated job was created. + */ + String getProcessDefinitionId(); + + /** + * Returns the specific process definition key on which the associated job was created. + */ + String getProcessDefinitionKey(); + + /** + * Returns the specific deployment id on which the associated job was created. + */ + String getDeploymentId(); + + /** + * Returns the id of the tenant this job log entry belongs to. Can be null + * if the job log entry belongs to no single tenant. + */ + String getTenantId(); + + /** + * Returns the name of the host where the Process Engine that added this job log runs. + */ + String getHostname(); + + /** + * Returns true when this log represents + * the creation of the associated job. + */ + boolean isCreationLog(); + + /** + * Returns true when this log represents + * the failed execution of the associated job. + */ + boolean isFailureLog(); + + /** + * Returns true when this log represents + * the successful execution of the associated job. + */ + boolean isSuccessLog(); + + /** + * Returns true when this log represents + * the deletion of the associated job. + */ + boolean isDeletionLog(); + + /** The time the historic job log will be removed. */ + Date getRemovalTime(); + + /** + * Returns the ID of the batch associated with the job or {@code null} if no batch is associated with the job. + * @return the ID of the batch associated with the job + */ + String getBatchId(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricJobLogQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricJobLogQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..cad7ee9beb08df30aadfe94a3d1a04dfbcdec522 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricJobLogQuery.java @@ -0,0 +1,174 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.Query; + +/** + * @author Roman Smirnov + * + */ +public interface HistoricJobLogQuery extends Query { + + /** Only select historic job log entries with the id. */ + HistoricJobLogQuery logId(String logId); + + /** Only select historic job log entries with the given job id. */ + HistoricJobLogQuery jobId(String jobId); + + /** Only select historic job log entries with the given exception message. */ + HistoricJobLogQuery jobExceptionMessage(String exceptionMessage); + + /** Only select historic job log entries with the given job definition id. */ + HistoricJobLogQuery jobDefinitionId(String jobDefinitionId); + + /** Only select historic job log entries with the given job definition type. */ + HistoricJobLogQuery jobDefinitionType(String jobDefinitionType); + + /** Only select historic job log entries with the given job definition configuration type. */ + HistoricJobLogQuery jobDefinitionConfiguration(String jobDefinitionConfiguration); + + /** Only select historic job log entries which are associated with one of the given activity ids. **/ + HistoricJobLogQuery activityIdIn(String... activityIds); + + /** Only select historic job log entries which are associated with failures of one of the given activity ids. **/ + HistoricJobLogQuery failedActivityIdIn(String... activityIds); + + /** Only select historic job log entries which are associated with one of the given execution ids. **/ + HistoricJobLogQuery executionIdIn(String... executionIds); + + /** Only select historic job log entries with the process instance id. */ + HistoricJobLogQuery processInstanceId(String processInstanceId); + + /** Only select historic job log entries with the process definition id. */ + HistoricJobLogQuery processDefinitionId(String processDefinitionId); + + /** Only select historic job log entries with the process instance key. */ + HistoricJobLogQuery processDefinitionKey(String processDefinitionKey); + + /** Only select historic job log entries with the deployment id. */ + HistoricJobLogQuery deploymentId(String deploymentId); + + /** Only select historic job log entries that belong to one of the given tenant ids. */ + HistoricJobLogQuery tenantIdIn(String... tenantIds); + + /** Only selects historic job log entries that have no tenant id. */ + HistoricJobLogQuery withoutTenantId(); + + /** Only selects historic job log entries that belong to the given host name. */ + HistoricJobLogQuery hostname(String hostname); + + /** + * Only select log entries where the job had a priority higher than or + * equal to the given priority. + * + * @since 7.4 + */ + HistoricJobLogQuery jobPriorityHigherThanOrEquals(long priority); + + /** + * Only select log entries where the job had a priority lower than or + * equal to the given priority. + * + * @since 7.4 + */ + HistoricJobLogQuery jobPriorityLowerThanOrEquals(long priority); + + /** Only select created historic job log entries. */ + HistoricJobLogQuery creationLog(); + + /** Only select failed historic job log entries. */ + HistoricJobLogQuery failureLog(); + + /** + * Only select historic job logs which belongs to a + * successful executed job. + */ + HistoricJobLogQuery successLog(); + + /** Only select deleted historic job log entries. */ + HistoricJobLogQuery deletionLog(); + + /** Order by timestamp (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByTimestamp(); + + /** Order by job id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByJobId(); + + /** Order by job due date (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByJobDueDate(); + + /** Order by job retries (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByJobRetries(); + + /** + * Order by job priority (needs to be followed by {@link #asc()} or {@link #desc()}). + * + * @since 7.4 + */ + HistoricJobLogQuery orderByJobPriority(); + + /** Order by job definition id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByJobDefinitionId(); + + /** Order by activity id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByActivityId(); + + /** Order by execution id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByExecutionId(); + + /** Order by process instance id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByProcessInstanceId(); + + /** Order by process definition id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByProcessDefinitionId(); + + /** Order by process definition key (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByProcessDefinitionKey(); + + /** Order by deployment id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricJobLogQuery orderByDeploymentId(); + + + /** + *

Sort the {@link HistoricJobLog historic job logs} in the order in which + * they occurred and needs to be followed by {@link #asc()} or {@link #desc()}.

+ * + *

The set of all {@link HistoricJobLog historic job logs} is a partially ordered + * set. Due to this fact {@link HistoricJobLog historic job logs} with different + * {@link HistoricJobLog#getJobId() job ids} are incomparable. Only {@link + * HistoricJobLog historic job logs} with the same {@link HistoricJobLog#getJobId() job id} can + * be totally ordered by using {@link #jobId(String)} and {@link #orderPartiallyByOccurrence()} + * which will return a result set ordered by its occurrence.

+ * + * @since 7.3 + */ + HistoricJobLogQuery orderPartiallyByOccurrence(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of job log entries without tenant id is database-specific. + */ + HistoricJobLogQuery orderByTenantId(); + + /** + * Order by hostname (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of job log entries without hostname is database-specific. + */ + HistoricJobLogQuery orderByHostname(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..debc37cf7c5890d25b374baa2bf18395a285e923 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstance.java @@ -0,0 +1,126 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; +import org.camunda.bpm.engine.IdentityService; +import org.camunda.bpm.engine.runtime.ProcessInstance; + +/** + * A single execution of a whole process definition that is stored permanently. + * + * @author Christian Stettler + * @author Askar Akhmerov + */ +public interface HistoricProcessInstance { + + String STATE_ACTIVE = "ACTIVE"; + String STATE_SUSPENDED = "SUSPENDED"; + String STATE_COMPLETED = "COMPLETED"; + String STATE_EXTERNALLY_TERMINATED = "EXTERNALLY_TERMINATED"; + String STATE_INTERNALLY_TERMINATED = "INTERNALLY_TERMINATED"; + + /** The process instance id (== as the id for the runtime {@link ProcessInstance process instance}). */ + String getId(); + + /** The user provided unique reference to this process instance. */ + String getBusinessKey(); + + /** The process definition key reference. */ + String getProcessDefinitionKey(); + + /** The process definition reference. */ + String getProcessDefinitionId(); + + /** The process definition name. */ + String getProcessDefinitionName(); + + /** The process definition version. */ + Integer getProcessDefinitionVersion(); + + /** The time the process was started. */ + Date getStartTime(); + + /** The time the process was ended. */ + Date getEndTime(); + + /** The time the historic process instance will be removed. */ + Date getRemovalTime(); + + /** The difference between {@link #getEndTime()} and {@link #getStartTime()} . */ + Long getDurationInMillis(); + + /** Reference to the activity in which this process instance ended. + * Note that a process instance can have multiple end events, in this case it might not be deterministic + * which activity id will be referenced here. Use a {@link HistoricActivityInstanceQuery} instead to query + * for end events of the process instance (use the activityTYpe attribute) + * */ + @Deprecated + String getEndActivityId(); + + /** The authenticated user that started this process instance. + * @see IdentityService#setAuthenticatedUserId(String) */ + String getStartUserId(); + + /** The start activity. */ + String getStartActivityId(); + + /** Obtains the reason for the process instance's deletion. */ + String getDeleteReason(); + + /** + * The process instance id of a potential super process instance or null if no super process instance exists + */ + String getSuperProcessInstanceId(); + + /** + * The process instance id of the top-level (root) process instance or null if no root process instance exists + */ + String getRootProcessInstanceId(); + + /** + * The case instance id of a potential super case instance or null if no super case instance exists + */ + String getSuperCaseInstanceId(); + + /** + * The case instance id of a potential super case instance or null if no super case instance exists + */ + String getCaseInstanceId(); + + /** + * The id of the tenant this historic process instance belongs to. Can be null + * if the historic process instance belongs to no single tenant. + */ + String getTenantId(); + + /** + * Return current state of HistoricProcessInstance, following values are recognized during process engine operations: + * + * STATE_ACTIVE - running process instance + * STATE_SUSPENDED - suspended process instances + * STATE_COMPLETED - completed through normal end event + * STATE_EXTERNALLY_TERMINATED - terminated externally, for instance through REST API + * STATE_INTERNALLY_TERMINATED - terminated internally, for instance by terminating boundary event + */ + String getState(); + + /** + * The id of the original process instance which was restarted. + */ + String getRestartedProcessInstanceId(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..2d0d7edca7ab6b595b148ffcc27a6d9a5765364f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstanceQuery.java @@ -0,0 +1,526 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.query.Query; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; + +/** + * Allows programmatic querying of {@link HistoricProcessInstance}s. + * + * @author Tom Baeyens + * @author Joram Barrez + * @author Falko Menge + */ +public interface HistoricProcessInstanceQuery extends Query { + + /** + * Only select historic process instances with the given process instance. + * {@link ProcessInstance) ids and {@link HistoricProcessInstance} ids match. + */ + HistoricProcessInstanceQuery processInstanceId(String processInstanceId); + + /** + * Only select historic process instances whose id is in the given set of ids. + * {@link ProcessInstance) ids and {@link HistoricProcessInstance} ids match. + */ + HistoricProcessInstanceQuery processInstanceIds(Set processInstanceIds); + + /** + * Only select historic process instances whose id is not in the given set of ids. + * {@link ProcessInstance) ids and {@link HistoricProcessInstance} ids match. + */ + HistoricProcessInstanceQuery processInstanceIdNotIn(String... processInstanceIdNotIn); + + /** + * Only select historic process instances for the given root process instance id + */ + HistoricProcessInstanceQuery rootProcessInstanceId(String rootProcessInstanceId); + + /** + * Only select historic process instances for the given process definition + */ + HistoricProcessInstanceQuery processDefinitionId(String processDefinitionId); + + /** + * Only select historic process instances that are defined by a process + * definition with the given key. + */ + HistoricProcessInstanceQuery processDefinitionKey(String processDefinitionKey); + + /** + * Only select historic process instances that are defined by any given process + * definition key. + */ + HistoricProcessInstanceQuery processDefinitionKeyIn(String... processDefinitionKeys); + + /** + * Only select historic process instances that don't have a process-definition of which the key is present in the given list + */ + HistoricProcessInstanceQuery processDefinitionKeyNotIn(List processDefinitionKeys); + + /** + * Only select historic process instances that are defined by a process + * definition with the given name. + */ + HistoricProcessInstanceQuery processDefinitionName(String processDefinitionName); + + /** + * Only select historic process instances that are defined by process definition which name + * is like the given value. + * + * @param nameLike The string can include the wildcard character '%' to express + * like-strategy: starts with (string%), ends with (%string) or contains (%string%). + */ + HistoricProcessInstanceQuery processDefinitionNameLike(String nameLike); + + /** + * Only select historic process instances with the given business key + */ + HistoricProcessInstanceQuery processInstanceBusinessKey(String processInstanceBusinessKey); + + /** + * Only select historic process instances whose business key is in the given set. + */ + HistoricProcessInstanceQuery processInstanceBusinessKeyIn(String... processInstanceBusinessKeyIn); + + /** + * Only select historic process instances which had a business key like the given value. + * + * @param processInstanceBusinessKeyLike The string can include the wildcard character '%' to express + * like-strategy: starts with (string%), ends with (%string) or contains (%string%). + */ + HistoricProcessInstanceQuery processInstanceBusinessKeyLike(String processInstanceBusinessKeyLike); + + /** + * Only select historic process instances that are completely finished. + */ + HistoricProcessInstanceQuery finished(); + + /** + * Only select historic process instance that are not yet finished. + */ + HistoricProcessInstanceQuery unfinished(); + + /** + * Only select historic process instances with incidents + * + * @return HistoricProcessInstanceQuery + */ + HistoricProcessInstanceQuery withIncidents(); + + /** + * Only select historic process instances with root incidents + * + * @return HistoricProcessInstanceQuery + */ + HistoricProcessInstanceQuery withRootIncidents(); + + /** + * Only select historic process instances that have incidents with given ids. + */ + HistoricProcessInstanceQuery incidentIdIn(String... incidentIds); + + /** + * Only select historic process instances with incident status either 'open' or 'resolved'. + * To get all process instances with incidents, use {@link HistoricProcessInstanceQuery#withIncidents()}. + * + * @param status indicates the incident status, which is either 'open' or 'resolved' + * @return {@link HistoricProcessInstanceQuery} + */ + HistoricProcessInstanceQuery incidentStatus(String status); + + /** + * Only selects process instances with the given incident type. + */ + HistoricProcessInstanceQuery incidentType(String incidentType); + + /** + * Only select historic process instances with the given incident message. + * + * @param incidentMessage Incidents Message for which the historic process instances should be selected + * @return HistoricProcessInstanceQuery + */ + HistoricProcessInstanceQuery incidentMessage(String incidentMessage); + + /** + * Only select historic process instances which had an incident message like the given value. + * + * @param incidentMessageLike The string can include the wildcard character '%' to express + * like-strategy: starts with (string%), ends with (%string) or contains (%string%). + * @return HistoricProcessInstanceQuery + */ + HistoricProcessInstanceQuery incidentMessageLike(String incidentMessageLike); + + /** + * Only select historic process instances which are associated with jobs that have exceptions and retries left. + * + * @return HistoricProcessInstanceQuery + */ + HistoricProcessInstanceQuery withJobsRetrying(); + + /** + * Only select historic process instances which are associated with the given case instance id. + */ + HistoricProcessInstanceQuery caseInstanceId(String caseInstanceId); + + /** + * The query will match the names of variables in a case-insensitive way. + */ + HistoricProcessInstanceQuery matchVariableNamesIgnoreCase(); + + /** + * The query will match the values of variables in a case-insensitive way. + */ + HistoricProcessInstanceQuery matchVariableValuesIgnoreCase(); + + /** + * Only select process instances which had a global variable with the given value + * when they ended. Only select process instances which have a variable value + * greater than the passed value. The type only applies to already ended + * process instances, otherwise use a {@link ProcessInstanceQuery} instead! The type of the + * variable is determined based on the value, using types configured in + * {@link ProcessEngineConfigurationImpl#getVariableSerializers()}. Byte-arrays and + * {@link Serializable} objects (which are not primitive type wrappers) are + * not supported. + * + * @param name of the variable, cannot be null. + */ + HistoricProcessInstanceQuery variableValueEquals(String name, Object value); + + /** + * Only select process instances which had a global variable with the given name, but + * with a different value than the passed value when they ended. Only select + * process instances which have a variable value greater than the passed + * value. Byte-arrays and {@link Serializable} objects (which are not + * primitive type wrappers) are not supported. + * + * @param name of the variable, cannot be null. + */ + HistoricProcessInstanceQuery variableValueNotEquals(String name, Object value); + + /** + * Only select process instances which had a global variable value greater than the + * passed value when they ended. Booleans, Byte-arrays and + * {@link Serializable} objects (which are not primitive type wrappers) are + * not supported. Only select process instances which have a variable value + * greater than the passed value. + * + * @param name cannot be null. + * @param value cannot be null. + */ + HistoricProcessInstanceQuery variableValueGreaterThan(String name, Object value); + + /** + * Only select process instances which had a global variable value greater than or + * equal to the passed value when they ended. Booleans, Byte-arrays and + * {@link Serializable} objects (which are not primitive type wrappers) are + * not supported. Only applies to already ended process instances, otherwise + * use a {@link ProcessInstanceQuery} instead! + * + * @param name cannot be null. + * @param value cannot be null. + */ + HistoricProcessInstanceQuery variableValueGreaterThanOrEqual(String name, Object value); + + /** + * Only select process instances which had a global variable value less than the + * passed value when the ended. Only applies to already ended process + * instances, otherwise use a {@link ProcessInstanceQuery} instead! Booleans, + * Byte-arrays and {@link Serializable} objects (which are not primitive type + * wrappers) are not supported. + * + * @param name cannot be null. + * @param value cannot be null. + */ + HistoricProcessInstanceQuery variableValueLessThan(String name, Object value); + + /** + * Only select process instances which has a global variable value less than or equal + * to the passed value when they ended. Only applies to already ended process + * instances, otherwise use a {@link ProcessInstanceQuery} instead! Booleans, + * Byte-arrays and {@link Serializable} objects (which are not primitive type + * wrappers) are not supported. + * + * @param name cannot be null. + * @param value cannot be null. + */ + HistoricProcessInstanceQuery variableValueLessThanOrEqual(String name, Object value); + + /** + * Only select process instances which had global variable value like the given value + * when they ended. Only applies to already ended process instances, otherwise + * use a {@link ProcessInstanceQuery} instead! This can be used on string + * variables only. + * + * @param name cannot be null. + * @param value cannot be null. The string can include the + * wildcard character '%' to express like-strategy: starts with + * (string%), ends with (%string) or contains (%string%). + */ + HistoricProcessInstanceQuery variableValueLike(String name, String value); + + /** + * Only select historic process instances that were started before the given date. + */ + HistoricProcessInstanceQuery startedBefore(Date date); + + /** + * Only select historic process instances that were started after the given date. + */ + HistoricProcessInstanceQuery startedAfter(Date date); + + /** + * Only select historic process instances that were started before the given date. + */ + HistoricProcessInstanceQuery finishedBefore(Date date); + + /** + * Only select historic process instances that were started after the given date. + */ + HistoricProcessInstanceQuery finishedAfter(Date date); + + /** + * Only select historic process instance that are started by the given user. + */ + HistoricProcessInstanceQuery startedBy(String userId); + + /** + * Order by the process instance id (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricProcessInstanceQuery orderByProcessInstanceId(); + + /** + * Order by the process definition id (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricProcessInstanceQuery orderByProcessDefinitionId(); + + /** + * Order by the process definition key (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricProcessInstanceQuery orderByProcessDefinitionKey(); + + /** + * Order by the process definition name (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricProcessInstanceQuery orderByProcessDefinitionName(); + + /** + * Order by the process definition version (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricProcessInstanceQuery orderByProcessDefinitionVersion(); + + /** + * Order by the business key (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricProcessInstanceQuery orderByProcessInstanceBusinessKey(); + + /** + * Order by the start time (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricProcessInstanceQuery orderByProcessInstanceStartTime(); + + /** + * Order by the end time (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricProcessInstanceQuery orderByProcessInstanceEndTime(); + + /** + * Order by the duration of the process instance (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricProcessInstanceQuery orderByProcessInstanceDuration(); + + /** + * Only select historic process instances that are top level process instances. + */ + HistoricProcessInstanceQuery rootProcessInstances(); + + /** + * Only select historic process instances started by the given process + * instance. {@link ProcessInstance) ids and {@link HistoricProcessInstance} + * ids match. + */ + HistoricProcessInstanceQuery superProcessInstanceId(String superProcessInstanceId); + + /** + * Only select historic process instances having a sub process instance + * with the given process instance id. + *

+ * Note that there will always be maximum only one + * such process instance that can be the result of this query. + */ + HistoricProcessInstanceQuery subProcessInstanceId(String subProcessInstanceId); + + /** + * Only select historic process instances started by the given case + * instance. + */ + HistoricProcessInstanceQuery superCaseInstanceId(String superCaseInstanceId); + + /** + * Only select historic process instances having a sub case instance + * with the given case instance id. + *

+ * Note that there will always be maximum only one + * such process instance that can be the result of this query. + */ + HistoricProcessInstanceQuery subCaseInstanceId(String subCaseInstanceId); + + /** + * Only select historic process instances with one of the given tenant ids. + */ + HistoricProcessInstanceQuery tenantIdIn(String... tenantIds); + + /** + * Only selects historic process instances which have no tenant id. + */ + HistoricProcessInstanceQuery withoutTenantId(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of historic process instances without tenant id is database-specific. + */ + HistoricProcessInstanceQuery orderByTenantId(); + + /** + * Only select historic process instances that were started as of the provided + * date. (Date will be adjusted to reflect midnight) + * + * @deprecated use {@link #startedAfter(Date)} and {@link #startedBefore(Date)} instead + */ + @Deprecated + HistoricProcessInstanceQuery startDateBy(Date date); + + /** + * Only select historic process instances that were started on the provided date. + * + * @deprecated use {@link #startedAfter(Date)} and {@link #startedBefore(Date)} instead + */ + @Deprecated + HistoricProcessInstanceQuery startDateOn(Date date); + + /** + * Only select historic process instances that were finished as of the + * provided date. (Date will be adjusted to reflect one second before midnight) + * + * @deprecated use {@link #startedAfter(Date)} and {@link #startedBefore(Date)} instead + */ + @Deprecated + HistoricProcessInstanceQuery finishDateBy(Date date); + + /** + * Only select historic process instances that were finished on provided date. + * + * @deprecated use {@link #startedAfter(Date)} and {@link #startedBefore(Date)} instead + */ + @Deprecated + HistoricProcessInstanceQuery finishDateOn(Date date); + + /** + * Only select historic process instances that executed an activity after the given date. + */ + HistoricProcessInstanceQuery executedActivityAfter(Date date); + + /** + * Only select historic process instances that executed an activity before the given date. + */ + HistoricProcessInstanceQuery executedActivityBefore(Date date); + + /** + * Only select historic process instances that executed activities with given ids. + */ + HistoricProcessInstanceQuery executedActivityIdIn(String... ids); + + /** + * Only select historic process instances that have active activities with given ids. + */ + HistoricProcessInstanceQuery activeActivityIdIn(String... ids); + + /** + * Only select historic process instances with an active activity with one of the given ids. + * In contrast to the `activeActivityIdIn` filter, it can query for async and incident activities. + */ + HistoricProcessInstanceQuery activityIdIn(String... ids); + + /** + * Only select historic process instances that executed an job after the given date. + */ + HistoricProcessInstanceQuery executedJobAfter(Date date); + + /** + * Only select historic process instances that executed an job before the given date. + */ + HistoricProcessInstanceQuery executedJobBefore(Date date); + + /** + * Only select historic process instances that are active. + */ + HistoricProcessInstanceQuery active(); + + /** + * Only select historic process instances that are suspended. + */ + HistoricProcessInstanceQuery suspended(); + + /** + * Only select historic process instances that are completed. + */ + HistoricProcessInstanceQuery completed(); + + /** + * Only select historic process instances that are externallyTerminated. + */ + HistoricProcessInstanceQuery externallyTerminated(); + + /** + * Only select historic process instances that are internallyTerminated. + */ + HistoricProcessInstanceQuery internallyTerminated(); + + /** + *

After calling or(), a chain of several filter criteria could follow. Each filter criterion that follows or() + * will be linked together with an OR expression until the OR query is terminated. To terminate the OR query right + * after the last filter criterion was applied, {@link #endOr()} must be invoked.

+ * + * @return an object of the type {@link HistoricProcessInstanceQuery} on which an arbitrary amount of filter criteria could be applied. + * The several filter criteria will be linked together by an OR expression. + * @throws ProcessEngineException when or() has been invoked directly after or() or after or() and trailing filter + * criteria. To prevent throwing this exception, {@link #endOr()} must be invoked after a chain of filter criteria to + * mark the end of the OR query. + */ + HistoricProcessInstanceQuery or(); + + /** + *

endOr() terminates an OR query on which an arbitrary amount of filter criteria were applied. To terminate the + * OR query which has been started by invoking {@link #or()}, endOr() must be invoked. Filter criteria which are + * applied after calling endOr() are linked together by an AND expression.

+ * + * @return an object of the type {@link HistoricProcessInstanceQuery} on which an arbitrary amount of filter criteria could be applied. + * The filter criteria will be linked together by an AND expression. + * @throws ProcessEngineException when endOr() has been invoked before {@link #or()} was invoked. To prevent throwing + * this exception, {@link #or()} must be invoked first. + */ + HistoricProcessInstanceQuery endOr(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstanceReport.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstanceReport.java new file mode 100644 index 0000000000000000000000000000000000000000..dccee67f3dfb120c154a44c575ae531d9d402e1d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricProcessInstanceReport.java @@ -0,0 +1,61 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.query.Report; + +/** + *

Defines a report query for {@link HistoricProcessInstance}s.

+ * + * @author Roman Smirnov + * + */ +public interface HistoricProcessInstanceReport extends Report { + + /** + * Only takes historic process instances into account that were started before the given date. + * + * @throws NotValidException if the given started before date is null + * + */ + HistoricProcessInstanceReport startedBefore(Date startedBefore); + + /** + * Only takes historic process instances into account that were started after the given date. + * + * @throws NotValidException if the given started after date is null + */ + HistoricProcessInstanceReport startedAfter(Date startedAfter); + + /** + * Only takes historic process instances into account for the given process definition ids. + * + * @throws NotValidException if one of the given ids is null + */ + HistoricProcessInstanceReport processDefinitionIdIn(String... processDefinitionIds); + + /** + * Only takes historic process instances into account for the given process definition keys. + * + * @throws NotValidException if one of the given ids is null + */ + HistoricProcessInstanceReport processDefinitionKeyIn(String... processDefinitionKeys); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..4b0c395f0163c68d643c7016956e909d44ea451e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstance.java @@ -0,0 +1,118 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + + +/** + * Represents a historic task instance (waiting, finished or deleted) that is stored permanent for + * statistics, audit and other business intelligence purposes. + * + * @author Tom Baeyens + */ +public interface HistoricTaskInstance { + + /** + * The unique identifier of this historic task instance. This is the same identifier as the + * runtime Task instance. + */ + String getId(); + + /** Process definition key reference. */ + String getProcessDefinitionKey(); + + /** Process definition reference. */ + String getProcessDefinitionId(); + + /** Root process instance reference. */ + String getRootProcessInstanceId(); + + /** Process instance reference. */ + String getProcessInstanceId(); + + /** Execution reference. */ + String getExecutionId(); + + /** Case definition key reference. */ + String getCaseDefinitionKey(); + + /** Case definition reference. */ + String getCaseDefinitionId(); + + /** Case instance reference. */ + String getCaseInstanceId(); + + /** Case execution reference. */ + String getCaseExecutionId(); + + /** Activity instance reference. */ + String getActivityInstanceId(); + + /** The latest name given to this task. */ + String getName(); + + /** The latest description given to this task. */ + String getDescription(); + + /** The reason why this task was deleted {'completed' | 'deleted' | any other user defined string }. */ + String getDeleteReason(); + + /** Task owner */ + String getOwner(); + + /** The latest assignee given to this task. */ + String getAssignee(); + + /** Time when the task started. */ + Date getStartTime(); + + /** Time when the task was deleted or completed. */ + Date getEndTime(); + + /** Difference between {@link #getEndTime()} and {@link #getStartTime()} in milliseconds. */ + Long getDurationInMillis(); + + /** Task definition key. */ + String getTaskDefinitionKey(); + + /** Task priority **/ + int getPriority(); + + /** Task due date **/ + Date getDueDate(); + + /** The parent task of this task, in case this task was a subtask */ + String getParentTaskId(); + + /** Task follow-up date */ + Date getFollowUpDate(); + + /** + * The id of the tenant this historic task instance belongs to. Can be null + * if the historic task instance belongs to no single tenant. + */ + String getTenantId(); + + /** The time the historic task instance will be removed. */ + Date getRemovalTime(); + + /** + * Task State also referred as lifeCycleState + */ + String getTaskState(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..4202c63f6b5fceb3e90211e866742f505e00c988 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstanceQuery.java @@ -0,0 +1,477 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.io.Serializable; +import java.util.Date; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.query.Query; +import org.camunda.bpm.engine.task.Task; + + +/** + * Allows programmatic querying for {@link HistoricTaskInstance}s. + * + * @author Tom Baeyens + */ +public interface HistoricTaskInstanceQuery extends Query { + + /** Only select historic task instances for the given task id. */ + HistoricTaskInstanceQuery taskId(String taskId); + + /** Only select historic task instances for the given process instance. */ + HistoricTaskInstanceQuery processInstanceId(String processInstanceId); + + /** Only select historic task instances for the given root process instance. */ + HistoricTaskInstanceQuery rootProcessInstanceId(String rootProcessInstanceId); + + /** Only select historic tasks for the given process instance business key */ + HistoricTaskInstanceQuery processInstanceBusinessKey(String processInstanceBusinessKey); + + /** + * Only select historic tasks for any of the given the given process instance business keys. + */ + HistoricTaskInstanceQuery processInstanceBusinessKeyIn(String... processInstanceBusinessKeys); + + /** Only select historic tasks matching the given process instance business key. + * The syntax is that of SQL: for example usage: nameLike(%camunda%)*/ + HistoricTaskInstanceQuery processInstanceBusinessKeyLike(String processInstanceBusinessKey); + + /** Only select historic task instances for the given execution. */ + HistoricTaskInstanceQuery executionId(String executionId); + + /** Only select historic task instances which have one of the given activity instance ids. **/ + HistoricTaskInstanceQuery activityInstanceIdIn(String... activityInstanceIds); + + /** Only select historic task instances for the given process definition. */ + HistoricTaskInstanceQuery processDefinitionId(String processDefinitionId); + + /** + * Only select historic task instances which are part of a (historic) process instance + * which has the given process definition key. + */ + HistoricTaskInstanceQuery processDefinitionKey(String processDefinitionKey); + + /** + * Only select historic task instances which are part of a (historic) process instance + * which has the given definition name. + */ + HistoricTaskInstanceQuery processDefinitionName(String processDefinitionName); + + /** Only select historic task instances for the given case definition. */ + HistoricTaskInstanceQuery caseDefinitionId(String caseDefinitionId); + + /** + * Only select historic task instances which are part of a case instance + * which has the given case definition key. + */ + HistoricTaskInstanceQuery caseDefinitionKey(String caseDefinitionKey); + + /** + * Only select historic task instances which are part of a (historic) case instance + * which has the given case definition name. + */ + HistoricTaskInstanceQuery caseDefinitionName(String caseDefinitionName); + + /** + * Only select historic task instances for the given case instance. + */ + HistoricTaskInstanceQuery caseInstanceId(String caseInstanceId); + + /** + * Only select historic task instances for the given case execution id. + */ + HistoricTaskInstanceQuery caseExecutionId(String caseExecutionId); + + /** + * Only select historic task instances with the given task name. + * This is the last name given to the task. + * The query will match the names of historic task instances in a case-insensitive way. + */ + HistoricTaskInstanceQuery taskName(String taskName); + + /** + * Only select historic task instances with a task name like the given value. + * This is the last name given to the task. + * The syntax that should be used is the same as in SQL, eg. %activiti%. + * The query will match the names of historic task instances in a case-insensitive way. + */ + HistoricTaskInstanceQuery taskNameLike(String taskNameLike); + + /** + * Only select historic task instances with the given task description. + * This is the last description given to the task. + * The query will match the descriptions of historic task instances in a case-insensitive way. + */ + HistoricTaskInstanceQuery taskDescription(String taskDescription); + + /** + * Only select historic task instances with a task description like the given value. + * This is the last description given to the task. + * The syntax that should be used is the same as in SQL, eg. %activiti%. + * The query will match the descriptions of historice task instances in a case-insensitive way. + */ + HistoricTaskInstanceQuery taskDescriptionLike(String taskDescriptionLike); + + /** + * Only select historic task instances with the given task definition key. + * @see Task#getTaskDefinitionKey() + */ + HistoricTaskInstanceQuery taskDefinitionKey(String taskDefinitionKey); + + /** + * Only select historic task instances with one of the given task definition keys. + * @see Task#getTaskDefinitionKey() + */ + HistoricTaskInstanceQuery taskDefinitionKeyIn(String... taskDefinitionKeys); + + /** Only select historic task instances with the given task delete reason. */ + HistoricTaskInstanceQuery taskDeleteReason(String taskDeleteReason); + + /** + * Only select historic task instances with a task description like the given value. + * The syntax that should be used is the same as in SQL, eg. %activiti%. + */ + HistoricTaskInstanceQuery taskDeleteReasonLike(String taskDeleteReasonLike); + + /** Only select historic task instances with an assignee. */ + HistoricTaskInstanceQuery taskAssigned(); + + /** Only select historic task instances without an assignee. */ + HistoricTaskInstanceQuery taskUnassigned(); + + /** + * Only select historic task instances which were last taskAssigned to the given assignee. + */ + HistoricTaskInstanceQuery taskAssignee(String taskAssignee); + + /** + * Only select historic task instances which were last taskAssigned to an assignee like + * the given value. + * The syntax that should be used is the same as in SQL, eg. %activiti%. + */ + HistoricTaskInstanceQuery taskAssigneeLike(String taskAssigneeLike); + + /** + * Only select historic task instances which have the given owner. + */ + HistoricTaskInstanceQuery taskOwner(String taskOwner); + + /** + * Only select historic task instances which have an owner like the one specified. + * The syntax that should be used is the same as in SQL, eg. %activiti%. + */ + HistoricTaskInstanceQuery taskOwnerLike(String taskOwnerLike); + + /** + * Only select historic task instances with the given priority. + */ + HistoricTaskInstanceQuery taskPriority(Integer taskPriority); + + /** + * Only select historic task instances which are finished. + */ + HistoricTaskInstanceQuery finished(); + + /** + * Only select historic task instances which aren't finished yet. + */ + HistoricTaskInstanceQuery unfinished(); + + /** + * Only select historic task instances which are part of a process + * instance which is already finished. + */ + HistoricTaskInstanceQuery processFinished(); + + /** + * Only select historic task instances which are part of a process + * instance which is not finished yet. + */ + HistoricTaskInstanceQuery processUnfinished(); + + /** + * Only select historic task instances which have mapping + * with Historic identity links based on user id + * + * @since 7.5 + */ + HistoricTaskInstanceQuery taskInvolvedUser(String involvedUser); + + /** + * Only select historic task instances which have mapping + * with Historic identity links based on group id + * + * @since 7.5 + */ + HistoricTaskInstanceQuery taskInvolvedGroup(String involvedGroup); + + /** + * Only select historic task instances which have mapping + * with Historic identity links with the condition of user being a candidate + * + * @since 7.5 + */ + HistoricTaskInstanceQuery taskHadCandidateUser(String candidateUser); + + /** + * Only select historic task instances which have mapping + * with Historic identity links with the condition of group being a candidate + * + * @since 7.5 + */ + HistoricTaskInstanceQuery taskHadCandidateGroup(String candidateGroup); + + /** Only select historic task instances which have a candidate group */ + HistoricTaskInstanceQuery withCandidateGroups(); + + /** Only select historic task instances which have no candidate group */ + HistoricTaskInstanceQuery withoutCandidateGroups(); + + /** + * The query will match the names of task and process variables in a case-insensitive way. + */ + HistoricTaskInstanceQuery matchVariableNamesIgnoreCase(); + + /** + * The query will match the values of task and process variables in a case-insensitive way. + */ + HistoricTaskInstanceQuery matchVariableValuesIgnoreCase(); + + /** + * Only select historic task instances which have a local task variable with the + * given name set to the given value. Make sure history-level is configured + * >= AUDIT when this feature is used. + */ + HistoricTaskInstanceQuery taskVariableValueEquals(String variableName, Object variableValue); + + /** Only select subtasks of the given parent task */ + HistoricTaskInstanceQuery taskParentTaskId(String parentTaskId); + + /** + * Only select historic task instances which are part of a process instance which have a variable + * with the given name set to the given value. The last variable value in the variable updates + * ({@link HistoricDetail}) will be used, so make sure history-level is configured + * >= AUDIT when this feature is used. + */ + HistoricTaskInstanceQuery processVariableValueEquals(String variableName, Object variableValue); + + /** + * Only select historic task instances which have a variable with the given name, but + * with a different value than the passed value. + * Byte-arrays and {@link Serializable} objects (which are not primitive type wrappers) + * are not supported. + */ + HistoricTaskInstanceQuery processVariableValueNotEquals(String variableName, Object variableValue); + + /** + * Only select historic task instances which are part of a process that have a variable + * with the given name and matching the given value. + * The syntax is that of SQL: for example usage: valueLike(%value%) + * */ + HistoricTaskInstanceQuery processVariableValueLike(String variableName, Object variableValue); + + /** + * Only select historic task instances which are part of a process that have a variable + * with the given name and not matching the given value. + * The syntax is that of SQL: for example usage: valueNotLike(%value%) + * */ + HistoricTaskInstanceQuery processVariableValueNotLike(String variableName, Object variableValue); + + /** + * Only select historic task instances which are part of a process that have a variable + * with the given name and a value greater than the given one. + */ + HistoricTaskInstanceQuery processVariableValueGreaterThan(String variableName, Object variableValue); + + /** + * Only select historic task instances which are part of a process that have a variable + * with the given name and a value greater than or equal to the given one. + */ + HistoricTaskInstanceQuery processVariableValueGreaterThanOrEquals(String variableName, Object variableValue); + + /** + * Only select historic task instances which are part of a process that have a variable + * with the given name and a value less than the given one. + */ + HistoricTaskInstanceQuery processVariableValueLessThan(String variableName, Object variableValue); + + /** + * Only select historic task instances which are part of a process that have a variable + * with the given name and a value less than or equal to the given one. + */ + HistoricTaskInstanceQuery processVariableValueLessThanOrEquals(String variableName, Object variableValue); + + /** + * Only select select historic task instances with the given due date. + */ + HistoricTaskInstanceQuery taskDueDate(Date dueDate); + + /** + * Only select select historic task instances which have a due date before the given date. + */ + HistoricTaskInstanceQuery taskDueBefore(Date dueDate); + + /** + * Only select select historic task instances which have a due date after the given date. + */ + HistoricTaskInstanceQuery taskDueAfter(Date dueDate); + + /** + * Only select select historic task instances that have no due date. + */ + HistoricTaskInstanceQuery withoutTaskDueDate(); + + /** + * Only select select historic task instances with the given follow-up date. + */ + HistoricTaskInstanceQuery taskFollowUpDate(Date followUpDate); + + /** + * Only select select historic task instances which have a follow-up date before the given date. + */ + HistoricTaskInstanceQuery taskFollowUpBefore(Date followUpDate); + + /** + * Only select select historic task instances which have a follow-up date after the given date. + */ + HistoricTaskInstanceQuery taskFollowUpAfter(Date followUpDate); + + /** Only select historic task instances with one of the given tenant ids. */ + HistoricTaskInstanceQuery tenantIdIn(String... tenantIds); + + /** Only selects historic task instances that have no tenant id. */ + HistoricTaskInstanceQuery withoutTenantId(); + + /** + * Only select tasks where end time is after given date + */ + HistoricTaskInstanceQuery finishedAfter(Date date); + + /** + * Only select tasks where end time is before given date + */ + HistoricTaskInstanceQuery finishedBefore(Date date); + + /** + * Only select tasks where started after given date + */ + HistoricTaskInstanceQuery startedAfter(Date date); + + /** + * Only select tasks where started before given date + */ + HistoricTaskInstanceQuery startedBefore(Date date); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of historic task instances without tenant id is database-specific. + */ + HistoricTaskInstanceQuery orderByTenantId(); + + /** Order by task id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByTaskId(); + + /** + * Order by the historic activity instance id this task was used in + * (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricTaskInstanceQuery orderByHistoricActivityInstanceId(); + + /** Order by process definition id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByProcessDefinitionId(); + + /** Order by process instance id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByProcessInstanceId(); + + /** Order by execution id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByExecutionId(); + + /** Order by duration (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByHistoricTaskInstanceDuration(); + + /** Order by end time (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByHistoricTaskInstanceEndTime(); + + /** Order by start time (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByHistoricActivityInstanceStartTime(); + + /** Order by task name (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByTaskName(); + + /** Order by task description (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByTaskDescription(); + + /** Order by task assignee (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByTaskAssignee(); + + /** Order by task owner (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByTaskOwner(); + + /** Order by task due date (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByTaskDueDate(); + + /** Order by task follow-up date (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByTaskFollowUpDate(); + + /** Order by task delete reason (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByDeleteReason(); + + /** Order by task definition key (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByTaskDefinitionKey(); + + /** Order by task priority key (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByTaskPriority(); + + /** Order by case definition id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByCaseDefinitionId(); + + /** Order by case instance id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByCaseInstanceId(); + + /** Order by case execution id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + HistoricTaskInstanceQuery orderByCaseExecutionId(); + + /** + *

After calling or(), a chain of several filter criteria could follow. Each filter criterion that follows or() + * will be linked together with an OR expression until the OR query is terminated. To terminate the OR query right + * after the last filter criterion was applied, {@link #endOr()} must be invoked.

+ * + * @return an object of the type {@link HistoricTaskInstanceQuery} on which an arbitrary amount of filter criteria could be applied. + * The several filter criteria will be linked together by an OR expression. + * + * @throws ProcessEngineException when or() has been invoked directly after or() or after or() and trailing filter + * criteria. To prevent throwing this exception, {@link #endOr()} must be invoked after a chain of filter criteria to + * mark the end of the OR query. + * */ + HistoricTaskInstanceQuery or(); + + /** + *

endOr() terminates an OR query on which an arbitrary amount of filter criteria were applied. To terminate the + * OR query which has been started by invoking {@link #or()}, endOr() must be invoked. Filter criteria which are + * applied after calling endOr() are linked together by an AND expression.

+ * + * @return an object of the type {@link HistoricTaskInstanceQuery} on which an arbitrary amount of filter criteria could be applied. + * The filter criteria will be linked together by an AND expression. + * + * @throws ProcessEngineException when endOr() has been invoked before {@link #or()} was invoked. To prevent throwing + * this exception, {@link #or()} must be invoked first. + * */ + HistoricTaskInstanceQuery endOr(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstanceReport.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstanceReport.java new file mode 100644 index 0000000000000000000000000000000000000000..cdb58e15e2d4ffbde32a19c7c65a0b54e970da3f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstanceReport.java @@ -0,0 +1,76 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.AuthorizationException; +import org.camunda.bpm.engine.authorization.Permissions; +import org.camunda.bpm.engine.authorization.Resources; +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.query.Report; + +/** + * @author Stefan Hentschel. + */ +public interface HistoricTaskInstanceReport extends Report { + + /** + *

Sets the completed after date for constraining the query to search for all tasks + * which are completed after a certain date.

+ * + * @param completedAfter A {@link Date} to define the granularity of the report + * + * @throws NotValidException + * When the given date is null. + */ + HistoricTaskInstanceReport completedAfter(Date completedAfter); + + /** + *

Sets the completed before date for constraining the query to search for all tasks + * which are completed before a certain date.

+ * + * @param completedBefore A {@link Date} to define the granularity of the report + * + * @throws NotValidException + * When the given date is null. + */ + HistoricTaskInstanceReport completedBefore(Date completedBefore); + + /** + *

Executes the task report query and returns a list of {@link HistoricTaskInstanceReportResult}s

+ * + * @throws AuthorizationException + * If the user has no {@link Permissions#READ_HISTORY} permission + * on any {@link Resources#PROCESS_DEFINITION}. + * + * @return a list of {@link HistoricTaskInstanceReportResult}s + */ + List countByProcessDefinitionKey(); + + /** + *

Executes the task report query and returns a list of {@link HistoricTaskInstanceReportResult}s

+ * + * @throws AuthorizationException + * If the user has no {@link Permissions#READ_HISTORY} permission + * on any {@link Resources#PROCESS_DEFINITION}. + * + * @return a list of {@link HistoricTaskInstanceReportResult}s + */ + List countByTaskName(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstanceReportResult.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstanceReportResult.java new file mode 100644 index 0000000000000000000000000000000000000000..c86b33f992d59e969060c32e322d79e299d89cef --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricTaskInstanceReportResult.java @@ -0,0 +1,56 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +/** + * @author Stefan Hentschel. + */ +public interface HistoricTaskInstanceReportResult { + + /** + *

Returns the count of the grouped items.

+ */ + Long getCount(); + + /** + *

Returns the process definition key for the selected definition key.

+ */ + String getProcessDefinitionKey(); + + /** + *

Returns the process definition id for the selected definition key

+ */ + String getProcessDefinitionId(); + + /** + *

Returns the process definition name for the selected definition key

+ */ + String getProcessDefinitionName(); + + /** + *

Returns the name of the task

+ * + * @return A task name when the query is triggered with a 'countByTaskName'. Else the return + * value is null. + */ + String getTaskName(); + + /** + *

Returns the id of the tenant task

+ */ + String getTenantId(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricVariableInstance.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricVariableInstance.java new file mode 100644 index 0000000000000000000000000000000000000000..ace040ffdf92c3a15a63a2e46f26ecb3dcfa6821 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricVariableInstance.java @@ -0,0 +1,165 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.variable.value.TypedValue; + +/** + * A single process variable containing the last value when its process instance has finished. + * It is only available when HISTORY_LEVEL is set >= AUDIT + * + * @author Christian Lipphardt (camunda) + * @author ruecker + */ +public interface HistoricVariableInstance { + + String STATE_CREATED = "CREATED"; + String STATE_DELETED = "DELETED"; + + /** + * @return the Id of this variable instance + */ + String getId(); + + /** + * Returns the name of this variable instance. + */ + String getName(); + + /** + * Returns the name of the type of this variable instance + * + * @return the type name of the variable + */ + String getTypeName(); + + /** + * Returns the value of this variable instance. + */ + Object getValue(); + + /** + * Returns the {@link TypedValue} of this variable instance. + */ + TypedValue getTypedValue(); + + /** + * Returns the name of this variable instance. + * + *

Deprecated since 7.2: use {@link #getName()} instead.

+ * + */ + @Deprecated + String getVariableName(); + + /** + *

Returns the name of the type of this variable instance

+ * + *

Deprecated since 7.2: use {@link #getTypeName()} instead.

+ * + */ + @Deprecated + String getVariableTypeName(); + + /** + * The process definition key reference. + */ + String getProcessDefinitionKey(); + + /** + * The process definition reference. + */ + String getProcessDefinitionId(); + + /** + * The root process instance reference. + */ + String getRootProcessInstanceId(); + + /** + * The process instance reference. + */ + String getProcessInstanceId(); + + /** + * Return the corresponding execution id. + */ + String getExecutionId(); + + /** + * Returns the corresponding activity instance id. + */ + @Deprecated + String getActivtyInstanceId(); + + /** + * Returns the corresponding activity instance id. + */ + String getActivityInstanceId(); + + /** + * The case definition key reference. + */ + String getCaseDefinitionKey(); + + /** + * The case definition reference. + */ + String getCaseDefinitionId(); + + /** + * The case instance reference. + */ + String getCaseInstanceId(); + + /** + * Return the corresponding case execution id. + */ + String getCaseExecutionId(); + + /** + * Return the corresponding task id. + */ + String getTaskId(); + + /** + * If the variable value could not be loaded, this returns the error message. + * @return an error message indicating why the variable value could not be loaded. + */ + String getErrorMessage(); + + /** + * The id of the tenant this variable belongs to. Can be null + * if the variable belongs to no single tenant. + */ + String getTenantId(); + + /** + * The current state of the variable. Can be 'CREATED' or 'DELETED' + */ + String getState(); + + /** + * The time when the variable was created. + */ + Date getCreateTime(); + + /** The time when the historic variable instance will be removed. */ + Date getRemovalTime(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricVariableInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricVariableInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..722676bd6397c21ccda236827a7c1247eeba0a22 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricVariableInstanceQuery.java @@ -0,0 +1,139 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; +import org.camunda.bpm.engine.query.Query; + + +/** + * Programmatic querying for {@link HistoricVariableInstance}s. + * + * @author Christian Lipphardt (camunda) + */ +public interface HistoricVariableInstanceQuery extends Query { + + /** Only select the variable with the given Id + * @param id of the variable to select + * @return the query object */ + HistoricVariableInstanceQuery variableId(String id); + + /** Only select historic process variables with the given process instance. */ + HistoricVariableInstanceQuery processInstanceId(String processInstanceId); + + /** Only select historic process variables for the given process definition */ + HistoricVariableInstanceQuery processDefinitionId(String processDefinitionId); + + /** Only select historic process variables for the given process definition key */ + HistoricVariableInstanceQuery processDefinitionKey(String processDefinitionKey); + + /** Only select historic case variables with the given case instance. */ + HistoricVariableInstanceQuery caseInstanceId(String caseInstanceId); + + /** Only select historic process variables with the given variable name. */ + HistoricVariableInstanceQuery variableName(String variableName); + + /** Only select historic process variables where the given variable name is like. */ + HistoricVariableInstanceQuery variableNameLike(String variableNameLike); + + /** Only select historic process variables which match one of the given variable types. */ + HistoricVariableInstanceQuery variableTypeIn(String... variableTypes); + + /** The query will match the names of task and process variables in a case-insensitive way. */ + HistoricVariableInstanceQuery matchVariableNamesIgnoreCase(); + + /** The query will match the values of task and process variables in a case-insensitive way. */ + HistoricVariableInstanceQuery matchVariableValuesIgnoreCase(); + + /** only select historic process variables with the given name and value */ + HistoricVariableInstanceQuery variableValueEquals(String variableName, Object variableValue); + + HistoricVariableInstanceQuery orderByProcessInstanceId(); + + HistoricVariableInstanceQuery orderByVariableName(); + + /** + * Order by the creation time (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricVariableInstanceQuery orderByCreationTime(); + + /** Only select historic process variables with the given process instance ids. */ + HistoricVariableInstanceQuery processInstanceIdIn(String... processInstanceIds); + + /** Only select historic variable instances which have one of the task ids. **/ + HistoricVariableInstanceQuery taskIdIn(String... taskIds); + + /** Only select historic variable instances which have one of the executions ids. **/ + HistoricVariableInstanceQuery executionIdIn(String... executionIds); + + /** Only select historic variable instances which have one of the case executions ids. **/ + HistoricVariableInstanceQuery caseExecutionIdIn(String... caseExecutionIds); + + /** Only select historic variable instances with one of the given case activity ids. **/ + HistoricVariableInstanceQuery caseActivityIdIn(String... caseActivityIds); + + /** Only select historic variable instances which have one of the activity instance ids. **/ + HistoricVariableInstanceQuery activityInstanceIdIn(String... activityInstanceIds); + + /** Only select historic variable instances with one of the given tenant ids. */ + HistoricVariableInstanceQuery tenantIdIn(String... tenantIds); + + /** Only selects historic variable instances that have no tenant id. */ + HistoricVariableInstanceQuery withoutTenantId(); + + /** + * Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). + * Note that the ordering of historic variable instances without tenant id is database-specific. + */ + HistoricVariableInstanceQuery orderByTenantId(); + + /** + * Order by id (needs to be followed by {@link #asc()} or {@link #desc()}). + */ + HistoricVariableInstanceQuery orderByVariableId(); + + /** + * Disable fetching of byte array and file values. By default, the query will fetch such values. + * By calling this method you can prevent the values of (potentially large) blob data chunks + * to be fetched. The variables themselves are nonetheless included in the query result. + * + * @return the query builder + */ + HistoricVariableInstanceQuery disableBinaryFetching(); + + /** + * Disable deserialization of variable values that are custom objects. By default, the query + * will attempt to deserialize the value of these variables. By calling this method you can + * prevent such attempts in environments where their classes are not available. + * Independent of this setting, variable serialized values are accessible. + */ + HistoricVariableInstanceQuery disableCustomObjectDeserialization(); + + /** + * Include variables that has been already deleted during the execution + */ + HistoricVariableInstanceQuery includeDeleted(); + + /** Only select historic process variables with the given variable names. */ + HistoricVariableInstanceQuery variableNameIn(String... names); + + /** + * Only select historic process variables that were created after the given date. + */ + HistoricVariableInstanceQuery createdAfter(Date date); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricVariableUpdate.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricVariableUpdate.java new file mode 100644 index 0000000000000000000000000000000000000000..c2787a2444ec11094207404f9c35011d551af021 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/HistoricVariableUpdate.java @@ -0,0 +1,68 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.variable.value.TypedValue; + +/** Update of a process variable. This is only available if history + * level is configured to FULL. + * + * @author Tom Baeyens + */ +public interface HistoricVariableUpdate extends HistoricDetail { + + String getVariableName(); + + /** + * Returns the id of the corresponding variable instance. + */ + String getVariableInstanceId(); + + /** + * Returns the type name of the variable + * + * @return the type name of the variable + */ + String getTypeName(); + + /** + * @return the name of the variable type. + * @deprecated since 7.2. Use {@link #getTypeName()} + */ + @Deprecated + String getVariableTypeName(); + + Object getValue(); + + /** + * @return the {@link TypedValue} for this variable update + */ + TypedValue getTypedValue(); + + int getRevision(); + + /** + * If the variable value could not be loaded, this returns the error message. + * @return an error message indicating why the variable value could not be loaded. + */ + String getErrorMessage(); + + /** + * @return true if the detail historic variable update is created during the process instance start + */ + Boolean isInitial(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/IncidentState.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/IncidentState.java new file mode 100644 index 0000000000000000000000000000000000000000..c105d695ffdb2ac475af5c75772d0b3bfad04a92 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/IncidentState.java @@ -0,0 +1,76 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + + +/** + * @author Roman Smirnov + * + */ +public interface IncidentState { + + IncidentState DEFAULT = new IncidentStateImpl(0, "open"); + IncidentState RESOLVED = new IncidentStateImpl(1, "resolved"); + IncidentState DELETED = new IncidentStateImpl(2, "deleted"); + + int getStateCode(); + + ///////////////////////////////////////////////////// default implementation + + static class IncidentStateImpl implements IncidentState { + + public final int stateCode; + protected final String name; + + public IncidentStateImpl(int suspensionCode, String string) { + this.stateCode = suspensionCode; + this.name = string; + } + + public int getStateCode() { + return stateCode; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + stateCode; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + IncidentStateImpl other = (IncidentStateImpl) obj; + if (stateCode != other.stateCode) + return false; + return true; + } + + @Override + public String toString() { + return name; + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/JobState.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/JobState.java new file mode 100644 index 0000000000000000000000000000000000000000..30644782aa0787e631299f9db9747e5ac507ad03 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/JobState.java @@ -0,0 +1,77 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + + +/** + * @author Roman Smirnov + * + */ +public interface JobState { + + JobState CREATED = new JobStateImpl(0, "created"); + JobState FAILED = new JobStateImpl(1, "failed"); + JobState SUCCESSFUL = new JobStateImpl(2, "successful"); + JobState DELETED = new JobStateImpl(3, "deleted"); + + int getStateCode(); + + ///////////////////////////////////////////////////// default implementation + + static class JobStateImpl implements JobState { + + public final int stateCode; + protected final String name; + + public JobStateImpl(int stateCode, String string) { + this.stateCode = stateCode; + this.name = string; + } + + public int getStateCode() { + return stateCode; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + stateCode; + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + JobStateImpl other = (JobStateImpl) obj; + if (stateCode != other.stateCode) + return false; + return true; + } + + @Override + public String toString() { + return name; + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricActivityInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricActivityInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..bdf07825a6eff257e3b2c12ebb1e9be53d24b680 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricActivityInstanceQuery.java @@ -0,0 +1,27 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.NativeQuery; + +/** + * Allows querying of {@link HistoricActivityInstanceQuery}s via native (SQL) queries + * @author Bernd Ruecker (camunda) + */ +public interface NativeHistoricActivityInstanceQuery extends NativeQuery { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricCaseActivityInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricCaseActivityInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..ae3a0d5f63ea8e54a7bfbe5569e9a64fc70b9802 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricCaseActivityInstanceQuery.java @@ -0,0 +1,28 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.NativeQuery; + +/** + * Allows querying of {@link HistoricCaseActivityInstance}s via native (SQL) queries + * + * @author Sebastian Menski + */ +public interface NativeHistoricCaseActivityInstanceQuery extends NativeQuery { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricCaseInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricCaseInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..1a95427a899e6e5d4f3df6d941c55d749d5009eb --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricCaseInstanceQuery.java @@ -0,0 +1,28 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.NativeQuery; + +/** + * Allows querying of {@link HistoricCaseInstance}s via native (SQL) queries + * + * @author Sebastian Menski + */ +public interface NativeHistoricCaseInstanceQuery extends NativeQuery { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricDecisionInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricDecisionInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..cfe6320ba069c49bfef8fc432ec3f87df039cd16 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricDecisionInstanceQuery.java @@ -0,0 +1,28 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.NativeQuery; + +/** + * Allows querying of {@link HistoricDecisionInstance}s via native (SQL) queries. + * + * @author Philipp Ossler + */ +public interface NativeHistoricDecisionInstanceQuery extends NativeQuery { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricProcessInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricProcessInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..502cf5e1d41508fedcdc3f5b6555da34dbfd798d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricProcessInstanceQuery.java @@ -0,0 +1,27 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.NativeQuery; + +/** + * Allows querying of {@link HistoricTaskInstanceQuery}s via native (SQL) queries + * @author Bernd Ruecker (camunda) + */ +public interface NativeHistoricProcessInstanceQuery extends NativeQuery { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricTaskInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricTaskInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..e39fadc44e251d406ca46dc3d8ea67e088b1b05b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricTaskInstanceQuery.java @@ -0,0 +1,27 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.NativeQuery; + +/** + * Allows querying of {@link HistoricTaskInstanceQuery}s via native (SQL) queries + * @author Bernd Ruecker (camunda) + */ +public interface NativeHistoricTaskInstanceQuery extends NativeQuery { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricVariableInstanceQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricVariableInstanceQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..0e0ffcb3b10a6feff4e9fd73dd9f613e03735450 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/NativeHistoricVariableInstanceQuery.java @@ -0,0 +1,35 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.NativeQuery; + +/** + * Allows querying of {@link org.camunda.bpm.engine.history.HistoricVariableInstanceQuery}s via native (SQL) queries + * @author Ramona Koch + */ +public interface NativeHistoricVariableInstanceQuery extends NativeQuery { + + /** + * Disable deserialization of variable values that are custom objects. By default, the query + * will attempt to deserialize the value of these variables. By calling this method you can + * prevent such attempts in environments where their classes are not available. + * Independent of this setting, variable serialized values are accessible. + */ + NativeHistoricVariableInstanceQuery disableCustomObjectDeserialization(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/ReportResult.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/ReportResult.java new file mode 100644 index 0000000000000000000000000000000000000000..c06f533d73e070a7b2382e6fcafaca78eefe522f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/ReportResult.java @@ -0,0 +1,62 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.query.PeriodUnit; + +/** + * This interface defines basic methods for resulting reports. + * + * @author Roman Smirnov + * + */ +public interface ReportResult { + + /** + *

Returns a period which specifies a time span within a year.

+ * + *

The returned period must be interpreted in conjunction + * with the returned {@link PeriodUnit} of {@link #getPeriodUnit()}.

+ * + *

For example:

+ *
    + *
  • {@link #getPeriodUnit()} returns {@link PeriodUnit#MONTH} + *
  • {@link #getPeriod()} returns 3 + *
+ * + *

The returned period 3 must be interpreted as + * the third month of the year (i.e. it represents + * the month March).

+ * + *

If the {@link #getPeriodUnit()} returns {@link PeriodUnit#QUARTER}, + * then the returned period 3 must be interpreted as the third + * quarter of the year.

+ * + * @return an integer representing span of time within a year + */ + int getPeriod(); + + /** + *

Returns the unit of the period.

+ * + * @return a {@link PeriodUnit} + * + * @see #getPeriod() + */ + PeriodUnit getPeriodUnit(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeSelectModeForHistoricBatchesBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeSelectModeForHistoricBatchesBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..b3ad045250955249e240e8b0189b2294cf46a49e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeSelectModeForHistoricBatchesBuilder.java @@ -0,0 +1,51 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +/** + * Fluent builder to select the mode to set the removal time for historic batches. + * + * @author Tassilo Weidner + */ +public interface SetRemovalTimeSelectModeForHistoricBatchesBuilder extends SetRemovalTimeToHistoricBatchesBuilder { + + /** + * Sets the removal time to an absolute date. + * + * @param removalTime supposed to be set to historic entities. + * @return the builder. + */ + SetRemovalTimeToHistoricBatchesBuilder absoluteRemovalTime(Date removalTime); + + /** + * Calculates the removal time dynamically based on the time to + * live of the respective batch and the engine's removal time strategy. + * + * @return the builder. + */ + SetRemovalTimeToHistoricBatchesBuilder calculatedRemovalTime(); + + /** + *

Sets the removal time to {@code null}. + * + * @return the builder. + */ + SetRemovalTimeToHistoricBatchesBuilder clearedRemovalTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeSelectModeForHistoricDecisionInstancesBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeSelectModeForHistoricDecisionInstancesBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..4b02d4520bac2f24815d29ad6177059efbd83737 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeSelectModeForHistoricDecisionInstancesBuilder.java @@ -0,0 +1,54 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +/** + * Fluent builder to select the mode to set the removal time for historic decision instances. + * + * @author Tassilo Weidner + */ +public interface SetRemovalTimeSelectModeForHistoricDecisionInstancesBuilder extends SetRemovalTimeToHistoricDecisionInstancesBuilder { + + /** + * Sets the removal time to an absolute date. + * + * @param removalTime supposed to be set to historic entities. + * @return the builder. + */ + SetRemovalTimeToHistoricDecisionInstancesBuilder absoluteRemovalTime(Date removalTime); + + /** + *

Calculates the removal time dynamically based on the respective decision definition time to + * live and the engine's removal time strategy. + * + *

In case {@link SetRemovalTimeToHistoricDecisionInstancesBuilder#hierarchical()} is enabled, the removal time is being calculated + * based on the base time and time to live of the historic root decision instance. + * + * @return the builder. + */ + SetRemovalTimeToHistoricDecisionInstancesBuilder calculatedRemovalTime(); + + /** + *

Sets the removal time to {@code null}. + * + * @return the builder. + */ + SetRemovalTimeToHistoricDecisionInstancesBuilder clearedRemovalTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeSelectModeForHistoricProcessInstancesBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeSelectModeForHistoricProcessInstancesBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..a0e61973b0639952db7176a1c9c269c12bbd138a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeSelectModeForHistoricProcessInstancesBuilder.java @@ -0,0 +1,54 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +/** + * Fluent builder to select the mode to set the removal time for historic process instances. + * + * @author Tassilo Weidner + */ +public interface SetRemovalTimeSelectModeForHistoricProcessInstancesBuilder extends SetRemovalTimeToHistoricProcessInstancesBuilder { + + /** + * Sets the removal time to an absolute date. + * + * @param removalTime supposed to be set to historic entities. + * @return the builder. + */ + SetRemovalTimeToHistoricProcessInstancesBuilder absoluteRemovalTime(Date removalTime); + + /** + *

Calculates the removal time dynamically based on the respective process definition time to + * live and the process engine's removal time strategy. + * + *

In case {@link #hierarchical()} is enabled, the removal time is being calculated + * based on the base time and time to live of the historic root process instance. + * + * @return the builder. + */ + SetRemovalTimeToHistoricProcessInstancesBuilder calculatedRemovalTime(); + + /** + *

Sets the removal time to {@code null}. + * + * @return the builder. + */ + SetRemovalTimeToHistoricProcessInstancesBuilder clearedRemovalTime(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeToHistoricBatchesBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeToHistoricBatchesBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..278c9ee504416c3d3a2b714b1adf54ed047d5a3b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeToHistoricBatchesBuilder.java @@ -0,0 +1,64 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.AuthorizationException; +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.authorization.BatchPermissions; +import org.camunda.bpm.engine.authorization.Permissions; +import org.camunda.bpm.engine.authorization.Resources; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.batch.history.HistoricBatchQuery; + +/** + * Fluent builder to set the removal time to historic batches and + * all associated historic entities. + * + * @author Tassilo Weidner + */ +public interface SetRemovalTimeToHistoricBatchesBuilder { + + /** + * Selects historic batches by the given query. + * + * @param historicBatchQuery to be evaluated. + * @return the builder. + */ + SetRemovalTimeToHistoricBatchesBuilder byQuery(HistoricBatchQuery historicBatchQuery); + + /** + * Selects historic batches by the given ids. + * + * @param historicBatchIds supposed to be affected. + * @return the builder. + */ + SetRemovalTimeToHistoricBatchesBuilder byIds(String... historicBatchIds); + + /** + * Sets the removal time asynchronously as batch. The returned batch can be used to + * track the progress of setting a removal time. + * + * @throws BadUserRequestException when no historic batches could be found. + * @throws AuthorizationException + * when no {@link BatchPermissions#CREATE_BATCH_SET_REMOVAL_TIME CREATE_BATCH_SET_REMOVAL_TIME} + * or no permission {@link Permissions#CREATE CREATE} permission is granted on {@link Resources#BATCH}. + * + * @return the batch which sets the removal time asynchronously. + */ + Batch executeAsync(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeToHistoricDecisionInstancesBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeToHistoricDecisionInstancesBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..1c50dca8fbba18058310dcd2a6330bf1ab8ea062 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeToHistoricDecisionInstancesBuilder.java @@ -0,0 +1,75 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.AuthorizationException; +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.authorization.BatchPermissions; +import org.camunda.bpm.engine.authorization.Permissions; +import org.camunda.bpm.engine.authorization.Resources; +import org.camunda.bpm.engine.batch.Batch; + +/** + * Fluent builder to set the removal time to historic decision instances and + * all associated historic entities. + * + * @author Tassilo Weidner + */ +public interface SetRemovalTimeToHistoricDecisionInstancesBuilder { + + /** + * Selects historic decision instances by the given query. + * + * @param historicDecisionInstanceQuery to be evaluated. + * @return the builder. + */ + SetRemovalTimeToHistoricDecisionInstancesBuilder byQuery(HistoricDecisionInstanceQuery historicDecisionInstanceQuery); + + /** + * Selects historic process instances by the given ids. + * + * @param historicProcessInstanceIds supposed to be affected. + * @return the builder. + */ + SetRemovalTimeToHistoricDecisionInstancesBuilder byIds(String... historicProcessInstanceIds); + + /** + * Takes additionally historic decision instances into account that are part of + * the hierarchy of the given historic decision instances. + * + * If the root decision instance id of the given historic decision instance is {@code null}, + * the hierarchy is ignored. This is the case for instances that were started with a version + * prior 7.10. + * + * @return the builder. + */ + SetRemovalTimeToHistoricDecisionInstancesBuilder hierarchical(); + + /** + * Sets the removal time asynchronously as batch. The returned batch can be used to + * track the progress of setting a removal time. + * + * @throws BadUserRequestException when no historic decision instances could be found. + * @throws AuthorizationException + * when no {@link BatchPermissions#CREATE_BATCH_SET_REMOVAL_TIME CREATE_BATCH_SET_REMOVAL_TIME} + * or no permission {@link Permissions#CREATE CREATE} permission is granted on {@link Resources#BATCH}. + * + * @return the batch which sets the removal time asynchronously. + */ + Batch executeAsync(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeToHistoricProcessInstancesBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeToHistoricProcessInstancesBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..1148b3c8d95dce832191ae1d200eb4f58a2b7cad --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/SetRemovalTimeToHistoricProcessInstancesBuilder.java @@ -0,0 +1,106 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import org.camunda.bpm.engine.AuthorizationException; +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.authorization.BatchPermissions; +import org.camunda.bpm.engine.authorization.Permissions; +import org.camunda.bpm.engine.authorization.Resources; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.removaltime.ProcessSetRemovalTimeJobHandler; + +/** + * Fluent builder to set the removal time to historic process instances and + * all associated historic entities. + * + * @author Tassilo Weidner + */ +public interface SetRemovalTimeToHistoricProcessInstancesBuilder { + + /** + * Selects historic process instances by the given query. + * + * @param historicProcessInstanceQuery to be evaluated. + * @return the builder. + */ + SetRemovalTimeToHistoricProcessInstancesBuilder byQuery(HistoricProcessInstanceQuery historicProcessInstanceQuery); + + /** + * Selects historic decision instances by the given ids. + * + * @param historicProcessInstanceIds supposed to be affected. + * @return the builder. + */ + SetRemovalTimeToHistoricProcessInstancesBuilder byIds(String... historicProcessInstanceIds); + + /** + * Takes additionally those historic process instances into account that are part of + * the hierarchy of the given historic process instance. + * + * If the root process instance id of the given historic process instance is {@code null}, + * the hierarchy is ignored. This is the case for instances that were started with a version + * prior 7.10. + * + * @return the builder. + */ + SetRemovalTimeToHistoricProcessInstancesBuilder hierarchical(); + + /** + * Handles removal time updates in chunks, taking into account the defined + * size in {@code removalTimeUpdateChunkSize} in the process engine + * configuration. The size of the chunks can also be overridden per call with + * the {@link #chunkSize(int)} option. Enabling this option can lead to + * multiple executions of the resulting jobs, preventing the database + * transaction from timing out by limiting the number of rows to update. + * + * @since 7.20 + * + * @return the builder. + */ + SetRemovalTimeToHistoricProcessInstancesBuilder updateInChunks(); + + /** + * Defines the size of the chunks in which removal time updates are processed. + * The value must be a positive integer value that doesn't exceed the + * {@link ProcessSetRemovalTimeJobHandler#MAX_CHUNK_SIZE}. + * + * Only has an effect if {@link #updateInChunks()} is invoked as well. + * + * If undefined, the operation uses the `removalTimeUpdateChunkSize` defined + * in the process engine configuration. + * + * @since 7.20 + * + * @return the builder. + */ + SetRemovalTimeToHistoricProcessInstancesBuilder chunkSize(int chunkSize); + + /** + * Sets the removal time asynchronously as batch. The returned batch can be used to + * track the progress of setting a removal time. + * + * @throws BadUserRequestException when no historic process instances could be found. + * @throws AuthorizationException + * when no {@link BatchPermissions#CREATE_BATCH_SET_REMOVAL_TIME CREATE_BATCH_SET_REMOVAL_TIME} + * or no permission {@link Permissions#CREATE CREATE} permission is granted on {@link Resources#BATCH}. + * + * @return the batch which sets the removal time asynchronously. + */ + Batch executeAsync(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/UserOperationLogEntry.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/UserOperationLogEntry.java new file mode 100644 index 0000000000000000000000000000000000000000..5f4f425ca5bd67a24dfac1e218f14051408de772 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/UserOperationLogEntry.java @@ -0,0 +1,245 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; +import org.camunda.bpm.engine.EntityTypes; + + +/** + * Log entry about an operation performed by a user. This is used for logging + * actions such as creating a new task, completing a task, + * canceling a process instance, ... + * + *

Operation Type

+ *

The type of the operation which has been performed. A user may create a new task, + * complete a task, delegate a tasks, etc... Check this class for a list of built-in + * operation type constants.

+ * + *

Entity Type

+ *

The type of the entity on which the operation was performed. Operations may be + * performed on tasks, attachments, ...

+ * + *

Affected Entity Criteria

+ *

+ * The methods that reference other entities (except users), such as {@link #getProcessInstanceId()} + * or {@link #getProcessDefinitionId()}, describe which entities were affected + * by the operation and represent restriction criteria. + * A null return value of any of those methods means that regarding + * this criterion, any entity was affected. + *

+ *

+ * For example, if an operation suspends all process instances that belong to a certain + * process definition id, one operation log entry is created. + * Its return value for the method {@link #getProcessInstanceId()} is null, + * while {@link #getProcessDefinitionId()} returns an id. Thus, the return values + * of these methods can be understood as selection criteria of instances of the entity type + * that were affected by the operation. + *

+ * + *

Additional Considerations

+ *

The event describes which user has requested out the operation and the time + * at which the operation was performed. Furthermore, one operation can result in multiple + * {@link UserOperationLogEntry} entities whicha are linked by the value of the + * {@link #getOperationId()} method.

+ * + * @author Danny Gräf + * @author Daniel Meyer + * + */ +public interface UserOperationLogEntry { + + /** @deprecated Please use {@link EntityTypes#TASK} instead. */ + @Deprecated + String ENTITY_TYPE_TASK = EntityTypes.TASK; + /** @deprecated Please use {@link EntityTypes#IDENTITY_LINK} instead. */ + @Deprecated + String ENTITY_TYPE_IDENTITY_LINK = EntityTypes.IDENTITY_LINK; + /** @deprecated Please use {@link EntityTypes#ATTACHMENT} instead. */ + @Deprecated + String ENTITY_TYPE_ATTACHMENT = EntityTypes.ATTACHMENT; + + String OPERATION_TYPE_ASSIGN = "Assign"; + String OPERATION_TYPE_CLAIM = "Claim"; + String OPERATION_TYPE_COMPLETE = "Complete"; + String OPERATION_TYPE_CREATE = "Create"; + String OPERATION_TYPE_DELEGATE = "Delegate"; + String OPERATION_TYPE_DELETE = "Delete"; + String OPERATION_TYPE_RESOLVE = "Resolve"; + + String OPERATION_TYPE_SET_OWNER = "SetOwner"; + String OPERATION_TYPE_SET_PRIORITY = "SetPriority"; + String OPERATION_TYPE_SET_NAME = "SetName"; + String OPERATION_TYPE_SET_DESCRIPTION = "SetDescription"; + String OPERATION_TYPE_SET_FOLLOW_UP_DATE = "SetFollowUpDate"; + + String OPERATION_TYPE_UPDATE = "Update"; + String OPERATION_TYPE_ACTIVATE = "Activate"; + String OPERATION_TYPE_SUSPEND = "Suspend"; + String OPERATION_TYPE_MIGRATE = "Migrate"; + String OPERATION_TYPE_ADD_USER_LINK = "AddUserLink"; + String OPERATION_TYPE_DELETE_USER_LINK = "DeleteUserLink"; + String OPERATION_TYPE_ADD_GROUP_LINK = "AddGroupLink"; + String OPERATION_TYPE_DELETE_GROUP_LINK = "DeleteGroupLink"; + String OPERATION_TYPE_SET_DUEDATE = "SetDueDate"; + String OPERATION_TYPE_RECALC_DUEDATE = "RecalculateDueDate"; + String OPERATION_TYPE_UNLOCK = "Unlock"; + String OPERATION_TYPE_EXECUTE = "Execute"; + String OPERATION_TYPE_EVALUATE = "Evaluate"; + + String OPERATION_TYPE_ADD_ATTACHMENT = "AddAttachment"; + String OPERATION_TYPE_DELETE_ATTACHMENT = "DeleteAttachment"; + + String OPERATION_TYPE_SUSPEND_JOB_DEFINITION = "SuspendJobDefinition"; + String OPERATION_TYPE_ACTIVATE_JOB_DEFINITION = "ActivateJobDefinition"; + String OPERATION_TYPE_SUSPEND_PROCESS_DEFINITION = "SuspendProcessDefinition"; + String OPERATION_TYPE_ACTIVATE_PROCESS_DEFINITION = "ActivateProcessDefinition"; + + String OPERATION_TYPE_CREATE_HISTORY_CLEANUP_JOB = "CreateHistoryCleanupJobs"; + String OPERATION_TYPE_UPDATE_HISTORY_TIME_TO_LIVE = "UpdateHistoryTimeToLive"; + String OPERATION_TYPE_DELETE_HISTORY = "DeleteHistory"; + + String OPERATION_TYPE_MODIFY_PROCESS_INSTANCE = "ModifyProcessInstance"; + String OPERATION_TYPE_RESTART_PROCESS_INSTANCE = "RestartProcessInstance"; + String OPERATION_TYPE_SUSPEND_JOB = "SuspendJob"; + String OPERATION_TYPE_ACTIVATE_JOB = "ActivateJob"; + String OPERATION_TYPE_SET_JOB_RETRIES = "SetJobRetries"; + String OPERATION_TYPE_SET_EXTERNAL_TASK_RETRIES = "SetExternalTaskRetries"; + String OPERATION_TYPE_SET_VARIABLE = "SetVariable"; + String OPERATION_TYPE_SET_VARIABLES = "SetVariables"; + + String OPERATION_TYPE_UPDATE_COMMENT = "UpdateComment"; + String OPERATION_TYPE_DELETE_COMMENT = "DeleteComment"; + + String OPERATION_TYPE_REMOVE_VARIABLE = "RemoveVariable"; + String OPERATION_TYPE_MODIFY_VARIABLE = "ModifyVariable"; + + String OPERATION_TYPE_SUSPEND_BATCH = "SuspendBatch"; + String OPERATION_TYPE_ACTIVATE_BATCH = "ActivateBatch"; + + String OPERATION_TYPE_CREATE_INCIDENT = "CreateIncident"; + + String OPERATION_TYPE_SET_REMOVAL_TIME = "SetRemovalTime"; + + String OPERATION_TYPE_SET_ANNOTATION = "SetAnnotation"; + String OPERATION_TYPE_CLEAR_ANNOTATION = "ClearAnnotation"; + + String OPERATION_TYPE_CORRELATE_MESSAGE = "CorrelateMessage"; + + String CATEGORY_ADMIN = "Admin"; + String CATEGORY_OPERATOR = "Operator"; + String CATEGORY_TASK_WORKER = "TaskWorker"; + + /** The unique identifier of this log entry. */ + String getId(); + + /** Deployment reference */ + String getDeploymentId(); + + /** Process definition reference. */ + String getProcessDefinitionId(); + + /** + * Key of the process definition this log entry belongs to; null means any. + */ + String getProcessDefinitionKey(); + + /** Root process instance reference. */ + String getRootProcessInstanceId(); + + /** Process instance reference. */ + String getProcessInstanceId(); + + /** Execution reference. */ + String getExecutionId(); + + /** Case definition reference. */ + String getCaseDefinitionId(); + + /** Case instance reference. */ + String getCaseInstanceId(); + + /** Case execution reference. */ + String getCaseExecutionId(); + + /** Task instance reference. */ + String getTaskId(); + + /** Job instance reference. */ + String getJobId(); + + /** Job definition reference. */ + String getJobDefinitionId(); + + /** Batch reference. */ + String getBatchId(); + + /** The User who performed the operation */ + String getUserId(); + + /** Timestamp of this change. */ + Date getTimestamp(); + + /** + * The unique identifier of this operation. + * + * If an operation modifies multiple properties, multiple {@link UserOperationLogEntry} instances will be + * created with a common operationId. This allows grouping multiple entries which are part of a composite operation. + */ + String getOperationId(); + + /** External task reference. */ + String getExternalTaskId(); + + /** + * Type of this operation, like create, assign, claim and so on. + * + * @see #OPERATION_TYPE_ASSIGN and other fields beginning with OPERATION_TYPE + */ + String getOperationType(); + + /** + * The type of the entity on which this operation was executed. + * + * @see #ENTITY_TYPE_TASK and other fields beginning with ENTITY_TYPE + */ + String getEntityType(); + + /** The property changed by this operation. */ + String getProperty(); + + /** The original value of the property. */ + String getOrgValue(); + + /** The new value of the property. */ + String getNewValue(); + + /** The time the historic user operation log will be removed. */ + Date getRemovalTime(); + + /** The category this entry is associated with */ + String getCategory(); + + /** An arbitrary annotation set by a user for auditing reasons */ + String getAnnotation(); + + /** + * The id of the tenant this user operation log belongs to. Can be null + * if the user operation log belongs to no single tenant. + */ + String getTenantId(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/UserOperationLogQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/UserOperationLogQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..2c7afb213234416f814fd16c3eebe3692cbcbd84 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/UserOperationLogQuery.java @@ -0,0 +1,152 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.history; + +import java.util.Date; + +import org.camunda.bpm.engine.EntityTypes; +import org.camunda.bpm.engine.TaskService; +import org.camunda.bpm.engine.query.Query; + + +/** + * Programmatic querying for {@link UserOperationLogEntry} instances. + * + * @author Danny Gräf + */ +public interface UserOperationLogQuery extends Query { + + /** + * Query for operations on entities of a given type only. This allows you to restrict the + * result set to all operations which were performed on the same Entity (ie. all Task Operations, + * All IdentityLink Operations ...) + * + * @see EntityTypes#TASK + * @see EntityTypes#IDENTITY_LINK + * @see EntityTypes#ATTACHMENT + */ + UserOperationLogQuery entityType(String entityType); + + /** + * Query for operations on entities of a given type only. This allows you to restrict the + * result set to all operations which were performed on the same Entity (ie. all Task Operations, + * All IdentityLink Operations ...) + * + * @see EntityTypes#TASK + * @see EntityTypes#IDENTITY_LINK + * @see EntityTypes#ATTACHMENT + */ + UserOperationLogQuery entityTypeIn(String... entityTypes); + + /** + * Query for operations of a given type only. Types of operations depend on the entity on which the operation + * was performed. For Instance: Tasks may be delegated, claimed, completed ... + * Check the {@link UserOperationLogEntry} class for a list of constants of supported operations. + */ + UserOperationLogQuery operationType(String operationType); + + /** Query entries which are existing for the given deployment id. */ + UserOperationLogQuery deploymentId(String deploymentId); + + /** Query entries which are existing for the given process definition id. */ + UserOperationLogQuery processDefinitionId(String processDefinitionId); + + /** Query entries which are operate on all process definitions of the given key. */ + UserOperationLogQuery processDefinitionKey(String processDefinitionKey); + + /** Query entries which are existing for the given process instance. */ + UserOperationLogQuery processInstanceId(String processInstanceId); + + /** Query entries which are existing for the given execution. */ + UserOperationLogQuery executionId(String executionId); + + /** Query entries which are existing for the given case definition id. */ + UserOperationLogQuery caseDefinitionId(String caseDefinitionId); + + /** Query entries which are existing for the given case instance. */ + UserOperationLogQuery caseInstanceId(String caseInstanceId); + + /** Query entries which are existing for the given case execution. */ + UserOperationLogQuery caseExecutionId(String caseExecutionId); + + /** Query entries which are existing for the task. */ + UserOperationLogQuery taskId(String taskId); + + /** Query entries which are existing for the job. */ + UserOperationLogQuery jobId(String jobId); + + /** Query entries which are existing for the job definition. */ + UserOperationLogQuery jobDefinitionId(String jobDefinitionId); + + /** Query entries which are existing for the batch. */ + UserOperationLogQuery batchId(String batchId); + + /** Query entries which are existing for the user. */ + UserOperationLogQuery userId(String userId); + + /** Query entries of a composite operation. + * This allows grouping multiple updates which are part of the same operation: + * for instance, a User may update multiple fields of a UserTask when calling {@link TaskService#saveTask(org.camunda.bpm.engine.task.Task)} + * which will be logged as separate {@link UserOperationLogEntry OperationLogEntries} with the same 'operationId' + * */ + UserOperationLogQuery operationId(String operationId); + + /** Query entries which are existing for the external task. */ + UserOperationLogQuery externalTaskId(String externalTaskId); + + /** Query entries that changed a property. */ + UserOperationLogQuery property(String property); + + /** + * Query for operations of the given category only. This allows you to restrict the + * result set to all operations which were performed in the same domain (ie. all Task Worker Operations, + * All Admin Operations ...) + * + * @see UserOperationLogEntry#CATEGORY_ADMIN + * @see UserOperationLogEntry#CATEGORY_OPERATOR + * @see UserOperationLogEntry#CATEGORY_TASK_WORKER + */ + UserOperationLogQuery category(String category); + + /** + * Query for operations of given categories only. This allows you to restrict the + * result set to all operations which were performed in the same domain (ie. all Task Worker Operations, + * All Admin Operations ...) + * + * @see UserOperationLogEntry#CATEGORY_ADMIN + * @see UserOperationLogEntry#CATEGORY_OPERATOR + * @see UserOperationLogEntry#CATEGORY_TASK_WORKER + */ + UserOperationLogQuery categoryIn(String... categories); + + /** Query entries after the time stamp. */ + UserOperationLogQuery afterTimestamp(Date after); + + /** Query entries before the time stamp. */ + UserOperationLogQuery beforeTimestamp(Date before); + + /** Order by time stamp (needs to be followed by {@link #asc()} or {@link #desc()}). */ + UserOperationLogQuery orderByTimestamp(); + + /** + * Only select entries which have the given tenant id. + **/ + UserOperationLogQuery tenantIdIn(String... tenantIds); + + /** Only selects entries that have no tenant id. */ + UserOperationLogQuery withoutTenantId(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/package.html b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/package.html new file mode 100644 index 0000000000000000000000000000000000000000..8672dd11621d10de7d9f703ed61b8c5883a641d3 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/history/package.html @@ -0,0 +1,5 @@ + + + Classes related to the {@link org.camunda.bpm.engine.HistoryService}. + + \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/Group.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/Group.java new file mode 100644 index 0000000000000000000000000000000000000000..fdb5e8f4c5ca7898fb87c9e67abbb8b3822c3292 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/Group.java @@ -0,0 +1,39 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import java.io.Serializable; + +import org.camunda.bpm.engine.IdentityService; + + +/** + * Represents a group, used in {@link IdentityService}. + * + * @author Tom Baeyens + */ +public interface Group extends Serializable { + + String getId(); + void setId(String id); + + String getName(); + void setName(String name); + + String getType(); + void setType(String string); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/GroupQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/GroupQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..6269d76627a1e48413ffb24bcfdacbae7383895a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/GroupQuery.java @@ -0,0 +1,65 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import org.camunda.bpm.engine.query.Query; + + +/** + * Allows to programmatically query for {@link Group}s. + * + * @author Joram Barrez + */ +public interface GroupQuery extends Query { + + /** Only select {@link Group}s with the given id. */ + GroupQuery groupId(String groupId); + + /** Only select {@link Group}s with the given ids */ + GroupQuery groupIdIn(String... ids); + + /** Only select {@link Group}s with the given name. */ + GroupQuery groupName(String groupName); + + /** Only select {@link Group}s where the name matches the given parameter. + * The syntax to use is that of SQL, eg. %activiti%. */ + GroupQuery groupNameLike(String groupNameLike); + + /** Only select {@link Group}s which have the given type. */ + GroupQuery groupType(String groupType); + + /** Only selects {@link Group}s where the given user is a member of. */ + GroupQuery groupMember(String groupMemberUserId); + + /** Only select {@link Group}S that are potential starter for the given process definition. */ + GroupQuery potentialStarter(String procDefId); + + /** Only select {@link Group}s that belongs to the given tenant. */ + GroupQuery memberOfTenant(String tenantId); + + //sorting //////////////////////////////////////////////////////// + + /** Order by group id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + GroupQuery orderByGroupId(); + + /** Order by group name (needs to be followed by {@link #asc()} or {@link #desc()}). */ + GroupQuery orderByGroupName(); + + /** Order by group type (needs to be followed by {@link #asc()} or {@link #desc()}). */ + GroupQuery orderByGroupType(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/NativeUserQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/NativeUserQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..d8067abeecc793dcd1e55e5a7ffd32fca78d07d8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/NativeUserQuery.java @@ -0,0 +1,27 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import org.camunda.bpm.engine.query.NativeQuery; + +/** + * Allows querying of {@link User}s via native (SQL) queries + * @author Svetlana Dorokhova + */ +public interface NativeUserQuery extends NativeQuery { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/PasswordPolicy.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/PasswordPolicy.java new file mode 100644 index 0000000000000000000000000000000000000000..56db62c70f1aa6e8a2b8b9a0eb8f6efd2652b071 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/PasswordPolicy.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import java.util.List; + +/** + * Contains a list of {@link PasswordPolicyRule rules} that must be matched by + * passwords for engine-managed users. + * + * @author Miklas Boskamp + */ +public interface PasswordPolicy { + + /** + * A list of rules that must be matched by user passwords. + * @return the list + */ + List getRules(); +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/PasswordPolicyResult.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/PasswordPolicyResult.java new file mode 100644 index 0000000000000000000000000000000000000000..6afb16fa9709d9a0c7a27f601828a47468e46d7b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/PasswordPolicyResult.java @@ -0,0 +1,50 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import java.util.List; + +/** + * The result of a password which was checked against a {@link PasswordPolicy}. + * + * @author Miklas Boskamp + * + */ +public interface PasswordPolicyResult { + + /** + * Indicator of the overall result of the check. + * + * @return true if all rules passed, false if at + * least one rule was violated. + */ + public boolean isValid(); + + /** + * List of all rules that were violated during the check. + * + * @return all violated rules. + */ + public List getViolatedRules(); + + /** + * List of all rules that were fulfilled during the check. + * + * @return all fulfilled rules. + */ + public List getFulfilledRules(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/PasswordPolicyRule.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/PasswordPolicyRule.java new file mode 100644 index 0000000000000000000000000000000000000000..943c98deb23f46e6e56abb267417783ced3d491b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/PasswordPolicyRule.java @@ -0,0 +1,77 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import org.camunda.bpm.engine.IdentityService; + +import java.util.Map; + +/** + * Describes a rule of a {@link PasswordPolicy}. All rules attached to a + * {@link PasswordPolicy} must be matched by passwords for engine-managed users + * to be policy compliant. + * + * @author Miklas Boskamp + */ +public interface PasswordPolicyRule { + + /** + * Placeholder string that can be used to display a description of this rule. + * The actual description text must be managed on the calling side. + * + * @return the placeholder for the description text. + */ + String getPlaceholder(); + + /** + * Additional parameter that can be used to display a meaningful description. + * + * @return a map of parameters + */ + Map getParameters(); + + /** + * Checks the given password against this rule. + * + *

Heads-up: The return value is not respected when + * {@link PasswordPolicyRule#execute(String, User)} is implemented.

+ * + * @param candidatePassword + * which is checked against a password policy + * @return true if the given password matches this rule. + * false if the given password is not compliant with this + * rule. + */ + boolean execute(String candidatePassword); + + /** + * Checks the given password and the user against this rule. + * + * @param candidatePassword + * which is checked against a password policy + * @param user + * to be taken into account when checking the candidate password. Can be {@code null} + * when {@link IdentityService#checkPassword(String, String)} is called. + * @return true if the given password matches this rule. + * false if the given password is not compliant with this + * rule. + */ + default boolean execute(String candidatePassword, User user) { + return execute(candidatePassword); + } + +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/Picture.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/Picture.java new file mode 100644 index 0000000000000000000000000000000000000000..cd4b55a157ea81d7c3f8efdc164e7002a700595f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/Picture.java @@ -0,0 +1,47 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + + +/** + * @author Tom Baeyens + */ +public class Picture { + + protected byte[] bytes; + protected String mimeType; + + public Picture(byte[] bytes, String mimeType) { + this.bytes = bytes; + this.mimeType = mimeType; + } + + public byte[] getBytes() { + return bytes; + } + + public InputStream getInputStream() { + return new ByteArrayInputStream(bytes); + } + + public String getMimeType() { + return mimeType; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/Tenant.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/Tenant.java new file mode 100644 index 0000000000000000000000000000000000000000..0bfd53a43cf85b8e618dab1db51d2da97d498f62 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/Tenant.java @@ -0,0 +1,42 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import java.io.Serializable; + +import org.camunda.bpm.engine.IdentityService; + +/** + * Represents a tenant, used in {@link IdentityService}. + */ +public interface Tenant extends Serializable { + + /** + * @return the id of the tenant + */ + String getId(); + + void setId(String id); + + /** + * @return the name of the tenant + */ + String getName(); + + void setName(String name); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/TenantQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/TenantQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..05dd6b4793e02d1687e3a7a188b10e21bb3f53bc --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/TenantQuery.java @@ -0,0 +1,58 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import org.camunda.bpm.engine.query.Query; + + +/** + * Allows to programmatically query for {@link Tenant}s. + */ +public interface TenantQuery extends Query { + + /** Only select {@link Tenant}s with the given id. */ + TenantQuery tenantId(String tenantId); + + /** Only select {@link Tenant}s with the given ids */ + TenantQuery tenantIdIn(String... ids); + + /** Only select {@link Tenant}s with the given name. */ + TenantQuery tenantName(String tenantName); + + /** Only select {@link Tenant}s where the name matches the given parameter. + * The syntax to use is that of SQL, eg. %tenant%. */ + TenantQuery tenantNameLike(String tenantNameLike); + + /** Only select {@link Tenant}s where the given user is member of. */ + TenantQuery userMember(String userId); + + /** Only select {@link Tenant}s where the given group is member of. */ + TenantQuery groupMember(String groupId); + + /** Selects the {@link Tenant}s which belongs to one of the user's groups. + * Can only be used in combination with {@link #userMember(String)} */ + TenantQuery includingGroupsOfUser(boolean includingGroups); + + //sorting //////////////////////////////////////////////////////// + + /** Order by tenant id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + TenantQuery orderByTenantId(); + + /** Order by tenant name (needs to be followed by {@link #asc()} or {@link #desc()}). */ + TenantQuery orderByTenantName(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/User.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/User.java new file mode 100644 index 0000000000000000000000000000000000000000..f21315cc2292631453a3131aadefa13fa6b1fd87 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/User.java @@ -0,0 +1,44 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import java.io.Serializable; + +import org.camunda.bpm.engine.IdentityService; + + +/** + * Represents a user, used in {@link IdentityService}. + * @author Tom Baeyens + */ +public interface User extends Serializable { + + String getId(); + void setId(String id); + + String getFirstName(); + void setFirstName(String firstName); + + void setLastName(String lastName); + String getLastName(); + + void setEmail(String email); + String getEmail(); + + String getPassword(); + void setPassword(String password); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/UserQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/UserQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..e9b3b0a8f6a5c4b5ef550895d52eb4c22ccda136 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/UserQuery.java @@ -0,0 +1,82 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.identity; + +import org.camunda.bpm.engine.query.Query; + + +/** + * Allows programmatic querying of {@link User} + * + * @author Joram Barrez + */ +public interface UserQuery extends Query { + + /** Only select {@link User}s with the given id/ */ + UserQuery userId(String id); + + /** Only select {@link User}s with the given ids */ + UserQuery userIdIn(String... ids); + + /** Only select {@link User}s with the given firstName. */ + UserQuery userFirstName(String firstName); + + /** Only select {@link User}s where the first name matches the given parameter. + * The syntax is that of SQL, eg. %activivi%. + */ + UserQuery userFirstNameLike(String firstNameLike); + + /** Only select {@link User}s with the given lastName. */ + UserQuery userLastName(String lastName); + + /** Only select {@link User}s where the last name matches the given parameter. + * The syntax is that of SQL, eg. %activivi%. + */ + UserQuery userLastNameLike(String lastNameLike); + + /** Only those {@link User}s with the given email addres. */ + UserQuery userEmail(String email); + + /** Only select {@link User}s where the email matches the given parameter. + * The syntax is that of SQL, eg. %activivi%. + */ + UserQuery userEmailLike(String emailLike); + + /** Only select {@link User}s that belong to the given group. */ + UserQuery memberOfGroup(String groupId); + + /** Only select {@link User}S that are potential starter for the given process definition. */ + UserQuery potentialStarter(String procDefId); + + /** Only select {@link User}s that belongs to the given tenant. */ + UserQuery memberOfTenant(String tenantId); + + //sorting //////////////////////////////////////////////////////// + + /** Order by user id (needs to be followed by {@link #asc()} or {@link #desc()}). */ + UserQuery orderByUserId(); + + /** Order by user first name (needs to be followed by {@link #asc()} or {@link #desc()}). */ + UserQuery orderByUserFirstName(); + + /** Order by user last name (needs to be followed by {@link #asc()} or {@link #desc()}). */ + UserQuery orderByUserLastName(); + + /** Order by user email (needs to be followed by {@link #asc()} or {@link #desc()}). */ + UserQuery orderByUserEmail(); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/package.html b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/package.html new file mode 100644 index 0000000000000000000000000000000000000000..19b8afd4fc7572d2e886fc25eb85dc629e80160e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/identity/package.html @@ -0,0 +1,5 @@ + + + classes related to the {@link org.camunda.bpm.engine.IdentityService}. + + \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractDefinitionDeployer.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractDefinitionDeployer.java new file mode 100644 index 0000000000000000000000000000000000000000..e596ae5051da3a6ddb33e51ab92e908967d018f0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractDefinitionDeployer.java @@ -0,0 +1,365 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.cfg.IdGenerator; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.cmd.CommandLogger; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.core.model.Properties; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.deploy.Deployer; +import org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache; +import org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ResourceEntity; +import org.camunda.bpm.engine.impl.repository.ResourceDefinitionEntity; + +/** + * {@link Deployer} responsible to parse resource files and create the proper entities. + * This class is extended by specific resource deployers. + * + * Note: Implementations must be thread-safe. In particular they should not keep deployment-specific state. + */ +public abstract class AbstractDefinitionDeployer implements Deployer { + + public static final String[] DIAGRAM_SUFFIXES = new String[] { "png", "jpg", "gif", "svg" }; + + private final CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; + + protected IdGenerator idGenerator; + + public IdGenerator getIdGenerator() { + return idGenerator; + } + + public void setIdGenerator(IdGenerator idGenerator) { + this.idGenerator = idGenerator; + } + + public void deploy(DeploymentEntity deployment) { + LOG.debugProcessingDeployment(deployment.getName()); + Properties properties = new Properties(); + List definitions = parseDefinitionResources(deployment, properties); + ensureNoDuplicateDefinitionKeys(definitions); + postProcessDefinitions(deployment, definitions, properties); + } + + protected List parseDefinitionResources(DeploymentEntity deployment, Properties properties) { + List definitions = new ArrayList(); + for (ResourceEntity resource : deployment.getResources().values()) { + LOG.debugProcessingResource(resource.getName()); + if (isResourceHandled(resource)) { + definitions.addAll(transformResource(deployment, resource, properties)); + } + } + return definitions; + } + + protected boolean isResourceHandled(ResourceEntity resource) { + String resourceName = resource.getName(); + + for (String suffix : getResourcesSuffixes()) { + if (resourceName.endsWith(suffix)) { + return true; + } + } + + return false; + } + + /** + * @return the list of resource suffixes for this cacheDeployer + */ + protected abstract String[] getResourcesSuffixes(); + + protected Collection transformResource(DeploymentEntity deployment, ResourceEntity resource, Properties properties) { + String resourceName = resource.getName(); + List definitions = transformDefinitions(deployment, resource, properties); + + for (DefinitionEntity definition : definitions) { + definition.setResourceName(resourceName); + + String diagramResourceName = getDiagramResourceForDefinition(deployment, resourceName, definition, deployment.getResources()); + if (diagramResourceName != null) { + definition.setDiagramResourceName(diagramResourceName); + } + } + + return definitions; + } + + + /** + * Transform the resource entity into definition entities. + * + * @param deployment the deployment the resources belongs to + * @param resource the resource to transform + * @return a list of transformed definition entities + */ + protected abstract List transformDefinitions(DeploymentEntity deployment, ResourceEntity resource, Properties properties); + + /** + * Returns the default name of the image resource for a certain definition. + * + * It will first look for an image resource which matches the definition + * specifically, before resorting to an image resource which matches the file + * containing the definition. + * + * Example: if the deployment contains a BPMN 2.0 xml resource called + * 'abc.bpmn20.xml' containing only one process with key 'myProcess', then + * this method will look for an image resources called 'abc.myProcess.png' + * (or .jpg, or .gif, etc.) or 'abc.png' if the previous one wasn't found. + * + * Example 2: if the deployment contains a BPMN 2.0 xml resource called + * 'abc.bpmn20.xml' containing three processes (with keys a, b and c), + * then this method will first look for an image resource called 'abc.a.png' + * before looking for 'abc.png' (likewise for b and c). + * Note that if abc.a.png, abc.b.png and abc.c.png don't exist, all + * processes will have the same image: abc.png. + * + * @return null if no matching image resource is found. + */ + protected String getDiagramResourceForDefinition(DeploymentEntity deployment, String resourceName, DefinitionEntity definition, Map resources) { + for (String diagramSuffix: getDiagramSuffixes()) { + String definitionDiagramResource = getDefinitionDiagramResourceName(resourceName, definition, diagramSuffix); + String diagramForFileResource = getGeneralDiagramResourceName(resourceName, definition, diagramSuffix); + if (resources.containsKey(definitionDiagramResource)) { + return definitionDiagramResource; + } else if (resources.containsKey(diagramForFileResource)) { + return diagramForFileResource; + } + } + // no matching diagram found + return null; + } + + protected String getDefinitionDiagramResourceName(String resourceName, DefinitionEntity definition, String diagramSuffix) { + String fileResourceBase = stripDefinitionFileSuffix(resourceName); + String definitionKey = definition.getKey(); + + return fileResourceBase + definitionKey + "." + diagramSuffix; + } + + protected String getGeneralDiagramResourceName(String resourceName, DefinitionEntity definition, String diagramSuffix) { + String fileResourceBase = stripDefinitionFileSuffix(resourceName); + + return fileResourceBase + diagramSuffix; + } + + protected String stripDefinitionFileSuffix(String resourceName) { + for (String suffix : getResourcesSuffixes()) { + if(resourceName.endsWith(suffix)) { + return resourceName.substring(0, resourceName.length() - suffix.length()); + } + } + return resourceName; + } + + protected String[] getDiagramSuffixes() { + return DIAGRAM_SUFFIXES; + } + + protected void ensureNoDuplicateDefinitionKeys(List definitions) { + Set keys = new HashSet(); + + for (DefinitionEntity definition : definitions) { + + String key = definition.getKey(); + + if (keys.contains(key)) { + throw new ProcessEngineException("The deployment contains definitions with the same key '" + key + "' (id attribute), this is not allowed"); + } + + keys.add(key); + } + } + + protected void postProcessDefinitions(DeploymentEntity deployment, List definitions, Properties properties) { + if (deployment.isNew()) { + // if the deployment is new persist the new definitions + persistDefinitions(deployment, definitions, properties); + } else { + // if the current deployment is not a new one, + // then load the already existing definitions + loadDefinitions(deployment, definitions, properties); + } + } + + protected void persistDefinitions(DeploymentEntity deployment, List definitions, Properties properties) { + for (DefinitionEntity definition : definitions) { + String definitionKey = definition.getKey(); + String tenantId = deployment.getTenantId(); + + DefinitionEntity latestDefinition = findLatestDefinitionByKeyAndTenantId(definitionKey, tenantId); + + updateDefinitionByLatestDefinition(deployment, definition, latestDefinition); + + persistDefinition(definition); + registerDefinition(deployment, definition, properties); + } + } + + protected void updateDefinitionByLatestDefinition(DeploymentEntity deployment, DefinitionEntity definition, DefinitionEntity latestDefinition) { + definition.setVersion(getNextVersion(deployment, definition, latestDefinition)); + definition.setId(generateDefinitionId(deployment, definition, latestDefinition)); + definition.setDeploymentId(deployment.getId()); + definition.setTenantId(deployment.getTenantId()); + } + + protected void loadDefinitions(DeploymentEntity deployment, List definitions, Properties properties) { + for (DefinitionEntity definition : definitions) { + String deploymentId = deployment.getId(); + String definitionKey = definition.getKey(); + + DefinitionEntity persistedDefinition = findDefinitionByDeploymentAndKey(deploymentId, definitionKey); + handlePersistedDefinition(definition, persistedDefinition, deployment, properties); + } + } + + protected void handlePersistedDefinition(DefinitionEntity definition, + DefinitionEntity persistedDefinition, DeploymentEntity deployment, Properties properties) { + persistedDefinitionLoaded(deployment, definition, persistedDefinition); + updateDefinitionByPersistedDefinition(deployment, definition, persistedDefinition); + registerDefinition(deployment, definition, properties); + } + + protected void updateDefinitionByPersistedDefinition(DeploymentEntity deployment, DefinitionEntity definition, DefinitionEntity persistedDefinition) { + definition.setVersion(persistedDefinition.getVersion()); + definition.setId(persistedDefinition.getId()); + definition.setDeploymentId(deployment.getId()); + definition.setTenantId(persistedDefinition.getTenantId()); + } + + /** + * Called when a previous version of a definition was loaded from the persistent store. + * + * @param deployment the deployment of the definition + * @param definition the definition entity + * @param persistedDefinition the loaded definition entity + */ + protected void persistedDefinitionLoaded(DeploymentEntity deployment, DefinitionEntity definition, DefinitionEntity persistedDefinition) { + // do nothing; + } + + /** + * Find a definition entity by deployment id and definition key. + * @param deploymentId the deployment id + * @param definitionKey the definition key + * @return the corresponding definition entity or null if non is found + */ + protected abstract DefinitionEntity findDefinitionByDeploymentAndKey(String deploymentId, String definitionKey); + + /** + * Find the last deployed definition entity by definition key and tenant id. + * + * @return the corresponding definition entity or null if non is found + */ + protected abstract DefinitionEntity findLatestDefinitionByKeyAndTenantId(String definitionKey, String tenantId); + + /** + * Persist definition entity into the database. + * @param definition the definition entity + */ + protected abstract void persistDefinition(DefinitionEntity definition); + + protected void registerDefinition(DeploymentEntity deployment, DefinitionEntity definition, Properties properties) { + DeploymentCache deploymentCache = getDeploymentCache(); + + // Add to cache + addDefinitionToDeploymentCache(deploymentCache, definition); + + definitionAddedToDeploymentCache(deployment, definition, properties); + + // Add to deployment for further usage + deployment.addDeployedArtifact(definition); + } + + /** + * Add a definition to the deployment cache + * + * @param deploymentCache the deployment cache + * @param definition the definition to add + */ + protected abstract void addDefinitionToDeploymentCache(DeploymentCache deploymentCache, DefinitionEntity definition); + + /** + * Called after a definition was added to the deployment cache. + * + * @param deployment the deployment of the definition + * @param definition the definition entity + */ + protected void definitionAddedToDeploymentCache(DeploymentEntity deployment, DefinitionEntity definition, Properties properties) { + // do nothing + } + + /** + * per default we increment the latest definition version by one - but you + * might want to hook in some own logic here, e.g. to align definition + * versions with deployment / build versions. + */ + protected int getNextVersion(DeploymentEntity deployment, DefinitionEntity newDefinition, DefinitionEntity latestDefinition) { + int result = 1; + if (latestDefinition != null) { + int latestVersion = latestDefinition.getVersion(); + result = latestVersion + 1; + } + return result; + } + + /** + * create an id for the definition. The default is to ask the {@link IdGenerator} + * and add the definition key and version if that does not exceed 64 characters. + * You might want to hook in your own implementation here. + */ + protected String generateDefinitionId(DeploymentEntity deployment, DefinitionEntity newDefinition, DefinitionEntity latestDefinition) { + String nextId = idGenerator.getNextId(); + + String definitionKey = newDefinition.getKey(); + int definitionVersion = newDefinition.getVersion(); + + String definitionId = definitionKey + + ":" + definitionVersion + + ":" + nextId; + + // ACT-115: maximum id length is 64 characters + if (definitionId.length() > 64) { + definitionId = nextId; + } + return definitionId; + } + + protected ProcessEngineConfigurationImpl getProcessEngineConfiguration() { + return Context.getProcessEngineConfiguration(); + } + + protected CommandContext getCommandContext() { + return Context.getCommandContext(); + } + + protected DeploymentCache getDeploymentCache() { + return getProcessEngineConfiguration().getDeploymentCache(); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractNativeQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractNativeQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..7efaaca3fbe874a27c1d7c0bb84a26d55e83ee76 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractNativeQuery.java @@ -0,0 +1,178 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.io.Serializable; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.query.NativeQuery; + +/** + * Abstract superclass for all native query types. + * + * @author Bernd Ruecker (camunda) + */ +public abstract class AbstractNativeQuery, U> implements Command, NativeQuery, + Serializable { + + private static final long serialVersionUID = 1L; + + private static enum ResultType { + LIST, LIST_PAGE, SINGLE_RESULT, COUNT + } + + protected transient CommandExecutor commandExecutor; + protected transient CommandContext commandContext; + + protected int maxResults = Integer.MAX_VALUE; + protected int firstResult = 0; + protected ResultType resultType; + + private Map parameters = new HashMap(); + private String sqlStatement; + + protected AbstractNativeQuery(CommandExecutor commandExecutor) { + this.commandExecutor = commandExecutor; + } + + public AbstractNativeQuery(CommandContext commandContext) { + this.commandContext = commandContext; + } + + public AbstractNativeQuery setCommandExecutor(CommandExecutor commandExecutor) { + this.commandExecutor = commandExecutor; + return this; + } + + @SuppressWarnings("unchecked") + public T sql(String sqlStatement) { + this.sqlStatement = sqlStatement; + return (T) this; + } + + @SuppressWarnings("unchecked") + public T parameter(String name, Object value) { + parameters.put(name, value); + return (T) this; + } + + @SuppressWarnings("unchecked") + public U singleResult() { + this.resultType = ResultType.SINGLE_RESULT; + if (commandExecutor != null) { + return (U) commandExecutor.execute(this); + } + return executeSingleResult(Context.getCommandContext()); + } + + @SuppressWarnings("unchecked") + public List list() { + this.resultType = ResultType.LIST; + if (commandExecutor != null) { + return (List) commandExecutor.execute(this); + } + return executeList(Context.getCommandContext(), getParameterMap(), 0, Integer.MAX_VALUE); + } + + @SuppressWarnings("unchecked") + public List listPage(int firstResult, int maxResults) { + this.firstResult =firstResult; + this.maxResults = maxResults; + this.resultType = ResultType.LIST_PAGE; + if (commandExecutor!=null) { + return (List) commandExecutor.execute(this); + } + return executeList(Context.getCommandContext(), getParameterMap(), firstResult, maxResults); + } + + public long count() { + this.resultType = ResultType.COUNT; + if (commandExecutor != null) { + return (Long) commandExecutor.execute(this); + } + return executeCount(Context.getCommandContext(), getParameterMap()); + } + + public Object execute(CommandContext commandContext) { + if (resultType == ResultType.LIST) { + return executeList(commandContext, getParameterMap(), 0, Integer.MAX_VALUE); + } else if (resultType == ResultType.LIST_PAGE) { + Map parameterMap = getParameterMap(); + parameterMap.put("resultType", "LIST_PAGE"); + parameterMap.put("firstResult", firstResult); + parameterMap.put("maxResults", maxResults); + parameterMap.put("internalOrderBy", "RES.ID_ asc"); + + int firstRow = firstResult + 1; + parameterMap.put("firstRow", firstRow); + int lastRow = 0; + if(maxResults == Integer.MAX_VALUE) { + lastRow = maxResults; + } else { + lastRow = firstResult + maxResults + 1; + } + parameterMap.put("lastRow", lastRow); + return executeList(commandContext, parameterMap, firstResult, maxResults); + } else if (resultType == ResultType.SINGLE_RESULT) { + return executeSingleResult(commandContext); + } else { + return executeCount(commandContext, getParameterMap()); + } + } + + public abstract long executeCount(CommandContext commandContext, Map parameterMap); + + /** + * Executes the actual query to retrieve the list of results. + * @param maxResults + * @param firstResult + * + * @param page + * used if the results must be paged. If null, no paging will be + * applied. + */ + public abstract List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults); + + public U executeSingleResult(CommandContext commandContext) { + List results = executeList(commandContext, getParameterMap(), 0, Integer.MAX_VALUE); + if (results.size() == 1) { + return results.get(0); + } else if (results.size() > 1) { + throw new ProcessEngineException("Query return " + results.size() + " results instead of max 1"); + } + return null; + } + + private Map getParameterMap() { + HashMap parameterMap = new HashMap(); + parameterMap.put("sql", sqlStatement); + parameterMap.putAll(parameters); + return parameterMap; + } + + public Map getParameters() { + return parameters; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractQuery.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractQuery.java new file mode 100644 index 0000000000000000000000000000000000000000..b772d1b9b2a3664e543ffc7e2175ffea2ea842f8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractQuery.java @@ -0,0 +1,420 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNull; + +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.impl.QueryValidators.AdhocQueryValidator; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.ListQueryParameterObject; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.ImmutablePair; +import org.camunda.bpm.engine.impl.util.QueryMaxResultsLimitUtil; +import org.camunda.bpm.engine.query.Query; +import org.camunda.bpm.engine.query.QueryProperty; +import org.joda.time.DateTime; + + +/** + * Abstract superclass for all query types. + * + * @author Joram Barrez + */ +public abstract class AbstractQuery, U> extends ListQueryParameterObject implements Command, Query, Serializable { + + private static final long serialVersionUID = 1L; + + public static final String SORTORDER_ASC = "asc"; + public static final String SORTORDER_DESC = "desc"; + + protected enum ResultType { + LIST, LIST_PAGE, LIST_IDS, LIST_DEPLOYMENT_ID_MAPPINGS, SINGLE_RESULT, COUNT + } + protected transient CommandExecutor commandExecutor; + + protected ResultType resultType; + + protected Map expressions = new HashMap<>(); + + protected Set>> validators = new HashSet<>(); + + protected boolean maxResultsLimitEnabled; + + protected AbstractQuery() { + } + + protected AbstractQuery(CommandExecutor commandExecutor) { + this.commandExecutor = commandExecutor; + + // all queries that are created with a dedicated command executor + // are treated as adhoc queries (i.e. queries not created in the context + // of a command) + addValidator(AdhocQueryValidator.>get()); + } + + public AbstractQuery setCommandExecutor(CommandExecutor commandExecutor) { + this.commandExecutor = commandExecutor; + return this; + } + + public T orderBy(QueryProperty property) { + return orderBy(new QueryOrderingProperty(null, property)); + } + + @SuppressWarnings("unchecked") + public T orderBy(QueryOrderingProperty orderProperty) { + this.orderingProperties.add(orderProperty); + return (T) this; + } + + public T asc() { + return direction(Direction.ASCENDING); + } + + public T desc() { + return direction(Direction.DESCENDING); + } + + @SuppressWarnings("unchecked") + public T direction(Direction direction) { + QueryOrderingProperty currentOrderingProperty = null; + + if (!orderingProperties.isEmpty()) { + currentOrderingProperty = orderingProperties.get(orderingProperties.size() - 1); + } + + ensureNotNull(NotValidException.class, "You should call any of the orderBy methods first before specifying a direction", "currentOrderingProperty", currentOrderingProperty); + + if (currentOrderingProperty.getDirection() != null) { + ensureNull(NotValidException.class, "Invalid query: can specify only one direction desc() or asc() for an ordering constraint", "direction", direction); + } + + currentOrderingProperty.setDirection(direction); + return (T) this; + } + + protected void checkQueryOk() { + + for (QueryOrderingProperty orderingProperty : orderingProperties) { + ensureNotNull(NotValidException.class, "Invalid query: call asc() or desc() after using orderByXX()", "direction", orderingProperty.getDirection()); + } + + } + + @SuppressWarnings("unchecked") + public U singleResult() { + this.resultType = ResultType.SINGLE_RESULT; + return (U) executeResult(resultType); + } + + @SuppressWarnings("unchecked") + public List list() { + this.resultType = ResultType.LIST; + return (List) executeResult(resultType); + } + + @SuppressWarnings("unchecked") + public List listPage(int firstResult, int maxResults) { + this.firstResult = firstResult; + this.maxResults = maxResults; + this.resultType = ResultType.LIST_PAGE; + return (List) executeResult(resultType); + } + + public Object executeResult(ResultType resultType) { + + if (commandExecutor != null) { + if (!maxResultsLimitEnabled) { + maxResultsLimitEnabled = Context.getCommandContext() == null; + } + + return commandExecutor.execute(this); + } + + switch (resultType) { + case SINGLE_RESULT: + return executeSingleResult(Context.getCommandContext()); + case LIST_PAGE: + case LIST: + return evaluateExpressionsAndExecuteList(Context.getCommandContext(), null); + default: + throw new ProcessEngineException("Unknown result type!"); + } + } + + public long count() { + this.resultType = ResultType.COUNT; + if (commandExecutor!=null) { + return (Long) commandExecutor.execute(this); + } + return evaluateExpressionsAndExecuteCount(Context.getCommandContext()); + } + + @SuppressWarnings("unchecked") + public List unlimitedList() { + this.resultType = ResultType.LIST; + if (commandExecutor != null) { + return (List) commandExecutor.execute(this); + } + return evaluateExpressionsAndExecuteList(Context.getCommandContext(), null); + } + + public Object execute(CommandContext commandContext) { + if (resultType==ResultType.LIST) { + return evaluateExpressionsAndExecuteList(commandContext, null); + } else if (resultType==ResultType.SINGLE_RESULT) { + return executeSingleResult(commandContext); + } else if (resultType==ResultType.LIST_PAGE) { + return evaluateExpressionsAndExecuteList(commandContext, null); + } else if (resultType == ResultType.LIST_IDS) { + return evaluateExpressionsAndExecuteIdsList(commandContext); + } else if (resultType == ResultType.LIST_DEPLOYMENT_ID_MAPPINGS) { + return evaluateExpressionsAndExecuteDeploymentIdMappingsList(commandContext); + } else { + return evaluateExpressionsAndExecuteCount(commandContext); + } + } + + public long evaluateExpressionsAndExecuteCount(CommandContext commandContext) { + validate(); + evaluateExpressions(); + return !hasExcludingConditions() ? executeCount(commandContext) : 0l; + } + + public abstract long executeCount(CommandContext commandContext); + + public List evaluateExpressionsAndExecuteList(CommandContext commandContext, Page page) { + checkMaxResultsLimit(); + validate(); + evaluateExpressions(); + return !hasExcludingConditions() ? executeList(commandContext, page) : new ArrayList<>(); + } + + /** + * Whether or not the query has excluding conditions. If the query has excluding conditions, + * (e.g. task due date before and after are excluding), the SQL query is avoided and a default result is + * returned. The returned result is the same as if the SQL was executed and there were no entries. + * + * @return {@code true} if the query does have excluding conditions, {@code false} otherwise + */ + protected boolean hasExcludingConditions() { + return false; + } + + /** + * Executes the actual query to retrieve the list of results. + * @param page used if the results must be paged. If null, no paging will be applied. + */ + public abstract List executeList(CommandContext commandContext, Page page); + + public U executeSingleResult(CommandContext commandContext) { + disableMaxResultsLimit(); + List results = evaluateExpressionsAndExecuteList(commandContext, new Page(0, 2)); + if (results.size() == 1) { + return results.get(0); + } else if (results.size() > 1) { + throw new ProcessEngineException("Query return "+results.size()+" results instead of max 1"); + } + return null; + } + + public Map getExpressions() { + return expressions; + } + + public void setExpressions(Map expressions) { + this.expressions = expressions; + } + + public void addExpression(String key, String expression) { + this.expressions.put(key, expression); + } + + protected void evaluateExpressions() { + // we cannot iterate directly on the entry set cause the expressions + // are removed by the setter methods during the iteration + ArrayList> entries = new ArrayList<>(expressions.entrySet()); + + for (Map.Entry entry : entries) { + String methodName = entry.getKey(); + String expression = entry.getValue(); + + Object value; + + try { + value = Context.getProcessEngineConfiguration() + .getExpressionManager() + .createExpression(expression) + .getValue(null); + } + catch (ProcessEngineException e) { + throw new ProcessEngineException("Unable to resolve expression '" + expression + "' for method '" + methodName + "' on class '" + getClass().getCanonicalName() + "'", e); + } + + // automatically convert DateTime to date + if (value instanceof DateTime) { + value = ((DateTime) value).toDate(); + } + + try { + Method method = getMethod(methodName); + method.invoke(this, value); + } catch (InvocationTargetException e) { + throw new ProcessEngineException("Unable to invoke method '" + methodName + "' on class '" + getClass().getCanonicalName() + "'", e); + } catch (IllegalAccessException e) { + throw new ProcessEngineException("Unable to access method '" + methodName + "' on class '" + getClass().getCanonicalName() + "'", e); + } + } + } + + protected Method getMethod(String methodName) { + for (Method method : getClass().getDeclaredMethods()) { + if (method.getName().equals(methodName)) { + return method; + } + } + throw new ProcessEngineException("Unable to find method '" + methodName + "' on class '" + getClass().getCanonicalName() + "'"); + } + + public T extend(T extendingQuery) { + throw new ProcessEngineException("Extending of query type '" + extendingQuery.getClass().getCanonicalName() + "' currently not supported"); + } + + protected void mergeOrdering(AbstractQuery extendedQuery, AbstractQuery extendingQuery) { + extendedQuery.orderingProperties = this.orderingProperties; + if (extendingQuery.orderingProperties != null) { + if (extendedQuery.orderingProperties == null) { + extendedQuery.orderingProperties = extendingQuery.orderingProperties; + } + else { + extendedQuery.orderingProperties.addAll(extendingQuery.orderingProperties); + } + } + } + + protected void mergeExpressions(AbstractQuery extendedQuery, AbstractQuery extendingQuery) { + Map mergedExpressions = new HashMap<>(extendingQuery.getExpressions()); + for (Map.Entry entry : this.getExpressions().entrySet()) { + if (!mergedExpressions.containsKey(entry.getKey())) { + mergedExpressions.put(entry.getKey(), entry.getValue()); + } + } + extendedQuery.setExpressions(mergedExpressions); + } + + public void validate() { + for (Validator> validator : validators) { + validate(validator); + } + } + + public void validate(Validator> validator) { + validator.validate(this); + } + + public void addValidator(Validator> validator) { + validators.add(validator); + } + + public void removeValidator(Validator> validator) { + validators.remove(validator); + } + + @SuppressWarnings("unchecked") + public List listIds() { + this.resultType = ResultType.LIST_IDS; + List ids = null; + if (commandExecutor != null) { + ids = (List) commandExecutor.execute(this); + } else { + ids = evaluateExpressionsAndExecuteIdsList(Context.getCommandContext()); + } + + if (ids != null) { + QueryMaxResultsLimitUtil.checkMaxResultsLimit(ids.size()); + } + + return ids; + } + + @SuppressWarnings("unchecked") + public List> listDeploymentIdMappings() { + this.resultType = ResultType.LIST_DEPLOYMENT_ID_MAPPINGS; + List> ids = null; + if (commandExecutor != null) { + ids = (List>) commandExecutor.execute(this); + } else { + ids = evaluateExpressionsAndExecuteDeploymentIdMappingsList(Context.getCommandContext()); + } + + if (ids != null) { + QueryMaxResultsLimitUtil.checkMaxResultsLimit(ids.size()); + } + + return ids; + } + + public List evaluateExpressionsAndExecuteIdsList(CommandContext commandContext) { + validate(); + evaluateExpressions(); + return !hasExcludingConditions() ? executeIdsList(commandContext) : new ArrayList<>(); + } + + public List executeIdsList(CommandContext commandContext) { + throw new UnsupportedOperationException("executeIdsList not supported by " + getClass().getCanonicalName()); + } + + public List> evaluateExpressionsAndExecuteDeploymentIdMappingsList(CommandContext commandContext) { + validate(); + evaluateExpressions(); + return !hasExcludingConditions() ? executeDeploymentIdMappingsList(commandContext) : new ArrayList<>(); + } + + public List> executeDeploymentIdMappingsList(CommandContext commandContext) { + throw new UnsupportedOperationException("executeDeploymentIdMappingsList not supported by " + getClass().getCanonicalName()); + } + + protected void checkMaxResultsLimit() { + if (maxResultsLimitEnabled) { + QueryMaxResultsLimitUtil.checkMaxResultsLimit(maxResults); + } + } + + public void enableMaxResultsLimit() { + maxResultsLimitEnabled = true; + } + + public void disableMaxResultsLimit() { + maxResultsLimitEnabled = false; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractQueryVariableValueCondition.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractQueryVariableValueCondition.java new file mode 100644 index 0000000000000000000000000000000000000000..67564e1848abaa7fe69e606875f7d8d02fb8f28c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractQueryVariableValueCondition.java @@ -0,0 +1,39 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; + +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; + + +/** + * @author Thorben Lindhauer + * + */ +public abstract class AbstractQueryVariableValueCondition { + + protected QueryVariableValue wrappedQueryValue; + + public AbstractQueryVariableValueCondition(QueryVariableValue variableValue) { + this.wrappedQueryValue = variableValue; + } + + public abstract void initializeValue(VariableSerializers serializers, String dbType); + + public abstract List getDisjunctiveConditions(); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractVariableQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractVariableQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8bb329c614ae50f2a85d5cf151c4ae5b0e5c76bc --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AbstractVariableQueryImpl.java @@ -0,0 +1,194 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.List; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; +import org.camunda.bpm.engine.query.Query; + + +/** + * Abstract query class that adds methods to query for variable values. + * + * @author Frederik Heremans + */ +public abstract class AbstractVariableQueryImpl, U> extends AbstractQuery { + + private static final long serialVersionUID = 1L; + + protected List queryVariableValues = new ArrayList<>(); + + protected Boolean variableNamesIgnoreCase; + protected Boolean variableValuesIgnoreCase; + + public AbstractVariableQueryImpl() { + } + + public AbstractVariableQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + @Override + public abstract long executeCount(CommandContext commandContext) ; + + @Override + public abstract List executeList(CommandContext commandContext, Page page); + + + @SuppressWarnings("unchecked") + public T variableValueEquals(String name, Object value) { + addVariable(name, value, QueryOperator.EQUALS, true); + return (T) this; + } + + @SuppressWarnings("unchecked") + public T variableValueNotEquals(String name, Object value) { + addVariable(name, value, QueryOperator.NOT_EQUALS, true); + return (T) this; + } + + @SuppressWarnings("unchecked") + public T variableValueGreaterThan(String name, Object value) { + addVariable(name, value, QueryOperator.GREATER_THAN, true); + return (T) this; + } + + @SuppressWarnings("unchecked") + public T variableValueGreaterThanOrEqual(String name, Object value) { + addVariable(name, value, QueryOperator.GREATER_THAN_OR_EQUAL, true); + return (T) this; + } + + @SuppressWarnings("unchecked") + public T variableValueLessThan(String name, Object value) { + addVariable(name, value, QueryOperator.LESS_THAN, true); + return (T) this; + } + + @SuppressWarnings("unchecked") + public T variableValueLessThanOrEqual(String name, Object value) { + addVariable(name, value, QueryOperator.LESS_THAN_OR_EQUAL, true); + return (T) this; + } + + @SuppressWarnings("unchecked") + public T variableValueLike(String name, String value) { + addVariable(name, value, QueryOperator.LIKE, true); + return (T)this; + } + + @SuppressWarnings("unchecked") + public T variableValueNotLike(String name, String value) { + addVariable(name, value, QueryOperator.NOT_LIKE, true); + return (T)this; + } + + @SuppressWarnings("unchecked") + public T matchVariableNamesIgnoreCase() { + this.variableNamesIgnoreCase = true; + for (QueryVariableValue variable : getQueryVariableValues()) { + variable.setVariableNameIgnoreCase(true); + } + return (T)this; + } + + @SuppressWarnings("unchecked") + public T matchVariableValuesIgnoreCase() { + this.variableValuesIgnoreCase = true; + for (QueryVariableValue variable : getQueryVariableValues()) { + variable.setVariableValueIgnoreCase(true); + } + return (T)this; + } + + protected void addVariable(String name, Object value, QueryOperator operator, boolean processInstanceScope) { + QueryVariableValue queryVariableValue = createQueryVariableValue(name, value, operator, processInstanceScope); + getQueryVariableValues().add(queryVariableValue); + } + + protected QueryVariableValue createQueryVariableValue(String name, Object value, QueryOperator operator, boolean processInstanceScope) { + validateVariable(name, value, operator); + + boolean shouldMatchVariableValuesIgnoreCase = Boolean.TRUE.equals(variableValuesIgnoreCase) && value != null && String.class.isAssignableFrom(value.getClass()); + boolean shouldMatchVariableNamesIgnoreCase = Boolean.TRUE.equals(variableNamesIgnoreCase); + + return new QueryVariableValue(name, value, operator, processInstanceScope, shouldMatchVariableNamesIgnoreCase, shouldMatchVariableValuesIgnoreCase); + } + + protected void validateVariable(String name, Object value, QueryOperator operator) { + ensureNotNull(NotValidException.class, "name", name); + if(value == null || isBoolean(value)) { + // Null-values and booleans can only be used in EQUALS and NOT_EQUALS + switch(operator) { + case GREATER_THAN: + throw new NotValidException("Booleans and null cannot be used in 'greater than' condition"); + case LESS_THAN: + throw new NotValidException("Booleans and null cannot be used in 'less than' condition"); + case GREATER_THAN_OR_EQUAL: + throw new NotValidException("Booleans and null cannot be used in 'greater than or equal' condition"); + case LESS_THAN_OR_EQUAL: + throw new NotValidException("Booleans and null cannot be used in 'less than or equal' condition"); + case LIKE: + throw new NotValidException("Booleans and null cannot be used in 'like' condition"); + case NOT_LIKE: + throw new NotValidException("Booleans and null cannot be used in 'not like' condition"); + default: + break; + } + } + } + + private boolean isBoolean(Object value) { + if (value == null) { + return false; + } + return Boolean.class.isAssignableFrom(value.getClass()) || boolean.class.isAssignableFrom(value.getClass()); + } + + protected void ensureVariablesInitialized() { + if (!getQueryVariableValues().isEmpty()) { + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + VariableSerializers variableSerializers = processEngineConfiguration.getVariableSerializers(); + String dbType = processEngineConfiguration.getDatabaseType(); + for(QueryVariableValue queryVariableValue : getQueryVariableValues()) { + queryVariableValue.initialize(variableSerializers, dbType); + } + } + } + + public List getQueryVariableValues() { + return queryVariableValues; + } + + public Boolean isVariableNamesIgnoreCase() { + return variableNamesIgnoreCase; + } + + public Boolean isVariableValuesIgnoreCase() { + return variableValuesIgnoreCase; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ActivityExecutionTreeMapping.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ActivityExecutionTreeMapping.java new file mode 100644 index 0000000000000000000000000000000000000000..7174c7a91eb98f191d6dcab3f4d815c733b7b953 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ActivityExecutionTreeMapping.java @@ -0,0 +1,177 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl; +import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl; +import org.camunda.bpm.engine.impl.pvm.runtime.CompensationBehavior; +import org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl; +import org.camunda.bpm.engine.impl.util.EnsureUtil; +import org.camunda.bpm.engine.runtime.ActivityInstance; + +/** + * Maps an activity (plain activities + their containing flow scopes) to the scope executions + * that are executing them. For every instance of a scope, there is one such execution. + * + * @author Thorben Lindhauer + */ +public class ActivityExecutionTreeMapping { + + protected Map> activityExecutionMapping; + protected CommandContext commandContext; + protected String processInstanceId; + protected ProcessDefinitionImpl processDefinition; + + public ActivityExecutionTreeMapping(CommandContext commandContext, String processInstanceId) { + this.activityExecutionMapping = new HashMap>(); + this.commandContext = commandContext; + this.processInstanceId = processInstanceId; + + initialize(); + } + + protected void submitExecution(ExecutionEntity execution, ScopeImpl scope) { + getExecutions(scope).add(execution); + } + + public Set getExecutions(ScopeImpl activity) { + Set executionsForActivity = activityExecutionMapping.get(activity); + if (executionsForActivity == null) { + executionsForActivity = new HashSet(); + activityExecutionMapping.put(activity, executionsForActivity); + } + + return executionsForActivity; + } + + public ExecutionEntity getExecution(ActivityInstance activityInstance) { + ScopeImpl scope = null; + + if (activityInstance.getId().equals(activityInstance.getProcessInstanceId())) { + scope = processDefinition; + } + else { + scope = processDefinition.findActivity(activityInstance.getActivityId()); + } + + return intersect( + getExecutions(scope), + activityInstance.getExecutionIds()); + } + + protected ExecutionEntity intersect(Set executions, String[] executionIds) { + Set executionIdSet = new HashSet(); + for (String executionId : executionIds) { + executionIdSet.add(executionId); + } + + for (ExecutionEntity execution : executions) { + if (executionIdSet.contains(execution.getId())) { + return execution; + } + } + throw new ProcessEngineException("Could not determine execution"); + } + + protected void initialize() { + ExecutionEntity processInstance = commandContext.getExecutionManager().findExecutionById(processInstanceId); + this.processDefinition = processInstance.getProcessDefinition(); + + List executions = fetchExecutionsForProcessInstance(processInstance); + executions.add(processInstance); + + List leaves = findLeaves(executions); + + assignExecutionsToActivities(leaves); + } + + protected void assignExecutionsToActivities(List leaves) { + for (ExecutionEntity leaf : leaves) { + ScopeImpl activity = leaf.getActivity(); + + if (activity != null) { + if (leaf.getActivityInstanceId() != null) { + EnsureUtil.ensureNotNull("activity", activity); + submitExecution(leaf, activity); + } + mergeScopeExecutions(leaf); + + + } + else if (leaf.isProcessInstanceExecution()) { + submitExecution(leaf, leaf.getProcessDefinition()); + } + } + } + + protected void mergeScopeExecutions(ExecutionEntity leaf) { + Map mapping = leaf.createActivityExecutionMapping(); + + for (Map.Entry mappingEntry : mapping.entrySet()) { + ScopeImpl scope = mappingEntry.getKey(); + ExecutionEntity scopeExecution = (ExecutionEntity) mappingEntry.getValue(); + + submitExecution(scopeExecution, scope); + } + + + } + + protected List fetchExecutionsForProcessInstance(ExecutionEntity execution) { + List executions = new ArrayList(); + executions.addAll(execution.getExecutions()); + for (ExecutionEntity child : execution.getExecutions()) { + executions.addAll(fetchExecutionsForProcessInstance(child)); + } + + return executions; + } + + protected List findLeaves(List executions) { + List leaves = new ArrayList(); + + for (ExecutionEntity execution : executions) { + if (isLeaf(execution)) { + leaves.add(execution); + } + } + + return leaves; + } + + /** + * event-scope executions are not considered in this mapping and must be ignored + */ + protected boolean isLeaf(ExecutionEntity execution) { + if (CompensationBehavior.isCompensationThrowing(execution)) { + return true; + } + else { + return !execution.isEventScope() && execution.getNonEventScopeExecutions().isEmpty(); + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ActivityStatisticsQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ActivityStatisticsQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b2b8fb65b59898f7b9df8ccfb10806dbcc0216ad --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ActivityStatisticsQueryImpl.java @@ -0,0 +1,139 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.List; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.db.PermissionCheck; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.management.ActivityStatistics; +import org.camunda.bpm.engine.management.ActivityStatisticsQuery; + +public class ActivityStatisticsQueryImpl extends + AbstractQuery implements ActivityStatisticsQuery{ + + protected static final long serialVersionUID = 1L; + protected boolean includeFailedJobs = false; + protected String processDefinitionId; + protected boolean includeIncidents; + protected String includeIncidentsForType; + + // for internal use + protected List processInstancePermissionChecks = new ArrayList(); + protected List jobPermissionChecks = new ArrayList(); + protected List incidentPermissionChecks = new ArrayList(); + + public ActivityStatisticsQueryImpl(String processDefinitionId, CommandExecutor executor) { + super(executor); + this.processDefinitionId = processDefinitionId; + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return + commandContext + .getStatisticsManager() + .getStatisticsCountGroupedByActivity(this); + } + + public List executeList( + CommandContext commandContext, Page page) { + checkQueryOk(); + return + commandContext + .getStatisticsManager() + .getStatisticsGroupedByActivity(this, page); + } + + public ActivityStatisticsQuery includeFailedJobs() { + includeFailedJobs = true; + return this; + } + + public ActivityStatisticsQuery includeIncidents() { + includeIncidents = true; + return this; + } + + public ActivityStatisticsQuery includeIncidentsForType(String incidentType) { + this.includeIncidentsForType = incidentType; + return this; + } + + public boolean isFailedJobsToInclude() { + return includeFailedJobs; + } + + public boolean isIncidentsToInclude() { + return includeIncidents || includeIncidentsForType != null; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + protected void checkQueryOk() { + super.checkQueryOk(); + ensureNotNull("No valid process definition id supplied", "processDefinitionId", processDefinitionId); + if (includeIncidents && includeIncidentsForType != null) { + throw new ProcessEngineException("Invalid query: It is not possible to use includeIncident() and includeIncidentForType() to execute one query."); + } + } + + // getter/setter for authorization check + + public List getProcessInstancePermissionChecks() { + return processInstancePermissionChecks; + } + + public void setProcessInstancePermissionChecks(List processInstancePermissionChecks) { + this.processInstancePermissionChecks = processInstancePermissionChecks; + } + + public void addProcessInstancePermissionCheck(List permissionChecks) { + processInstancePermissionChecks.addAll(permissionChecks); + } + + public List getJobPermissionChecks() { + return jobPermissionChecks; + } + + public void setJobPermissionChecks(List jobPermissionChecks) { + this.jobPermissionChecks = jobPermissionChecks; + } + + public void addJobPermissionCheck(List permissionChecks) { + jobPermissionChecks.addAll(permissionChecks); + } + + public List getIncidentPermissionChecks() { + return incidentPermissionChecks; + } + + public void setIncidentPermissionChecks(List incidentPermissionChecks) { + this.incidentPermissionChecks = incidentPermissionChecks; + } + + public void addIncidentPermissionCheck(List permissionChecks) { + incidentPermissionChecks.addAll(permissionChecks); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AuthorizationQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AuthorizationQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..5eda344c516186ad10df71c1176e3600882de7b7 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AuthorizationQueryImpl.java @@ -0,0 +1,201 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.Arrays; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.authorization.Authorization; +import org.camunda.bpm.engine.authorization.AuthorizationQuery; +import org.camunda.bpm.engine.authorization.Permission; +import org.camunda.bpm.engine.authorization.Resource; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.ResourceTypeUtil; + +/** + * @author Daniel Meyer + * + */ +public class AuthorizationQueryImpl extends AbstractQuery implements AuthorizationQuery { + + private static final long serialVersionUID = 1L; + + protected String id; + protected String[] userIds; + protected String[] groupIds; + protected int resourceType; + protected String resourceId; + protected int permission = 0; + protected Integer authorizationType; + protected boolean queryByPermission = false; + protected boolean queryByResourceType = false; + + private Set resourcesIntersection = new HashSet<>(); + + public AuthorizationQueryImpl() { + } + + public AuthorizationQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public AuthorizationQuery authorizationId(String id) { + this.id = id; + return this; + } + + public AuthorizationQuery userIdIn(String... userIdIn) { + if(groupIds != null) { + throw new ProcessEngineException("Cannot query for user and group authorizations at the same time."); + } + this.userIds = userIdIn; + return this; + } + + public AuthorizationQuery groupIdIn(String... groupIdIn) { + if(userIds != null) { + throw new ProcessEngineException("Cannot query for user and group authorizations at the same time."); + } + this.groupIds = groupIdIn; + return this; + } + + public AuthorizationQuery resourceType(Resource resource) { + return resourceType(resource.resourceType()); + } + + public AuthorizationQuery resourceType(int resourceType) { + this.resourceType = resourceType; + queryByResourceType = true; + return this; + } + + public AuthorizationQuery resourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + public AuthorizationQuery hasPermission(Permission p) { + queryByPermission = true; + + if (resourcesIntersection.size() == 0) { + resourcesIntersection.addAll(Arrays.asList(p.getTypes())); + } else { + resourcesIntersection.retainAll(new HashSet(Arrays.asList(p.getTypes()))); + } + + this.permission |= p.getValue(); + return this; + } + + public AuthorizationQuery authorizationType(Integer type) { + this.authorizationType = type; + return this; + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext.getAuthorizationManager() + .selectAuthorizationCountByQueryCriteria(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext.getAuthorizationManager() + .selectAuthorizationByQueryCriteria(this); + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() + || containsIncompatiblePermissions() + || containsIncompatibleResourceType(); + } + + /** + * check whether there are any compatible resources + * for all of the filtered permission parameters + */ + private boolean containsIncompatiblePermissions() { + return queryByPermission && resourcesIntersection.isEmpty(); + } + + /** + * check whether the permissions' resources + * are compatible to the filtered resource parameter + */ + private boolean containsIncompatibleResourceType() { + if (queryByResourceType && queryByPermission) { + Resource[] resources = resourcesIntersection.toArray(new Resource[resourcesIntersection.size()]); + return !ResourceTypeUtil.resourceIsContainedInArray(resourceType, resources); + } + return false; + } + + // getters //////////////////////////// + + public String getId() { + return id; + } + + public boolean isQueryByPermission() { + return queryByPermission; + } + + public String[] getUserIds() { + return userIds; + } + + public String[] getGroupIds() { + return groupIds; + } + + public int getResourceType() { + return resourceType; + } + + public String getResourceId() { + return resourceId; + } + + public int getPermission() { + return permission; + } + + public boolean isQueryByResourceType() { + return queryByResourceType; + } + + public Set getResourcesIntersection() { + return resourcesIntersection; + } + + public AuthorizationQuery orderByResourceType() { + orderBy(AuthorizationQueryProperty.RESOURCE_TYPE); + return this; + } + + public AuthorizationQuery orderByResourceId() { + orderBy(AuthorizationQueryProperty.RESOURCE_ID); + return this; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AuthorizationQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AuthorizationQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..593b0311dae93e02e88efa677a676fdeb5097632 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AuthorizationQueryProperty.java @@ -0,0 +1,31 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.authorization.AuthorizationQuery; +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * Contains the possible properties that can be used in an {@link AuthorizationQuery}. + * + * @author Daniel Meyer + */ +public interface AuthorizationQueryProperty { + + public static final QueryProperty RESOURCE_TYPE = new QueryPropertyImpl("RESOURCE_TYPE_"); + public static final QueryProperty RESOURCE_ID = new QueryPropertyImpl("RESOURCE_ID_"); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AuthorizationServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AuthorizationServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..0a01dce3ebb0c551e93fbfd132b53267601e3dba --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/AuthorizationServiceImpl.java @@ -0,0 +1,61 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; + +import org.camunda.bpm.engine.AuthorizationService; +import org.camunda.bpm.engine.authorization.Authorization; +import org.camunda.bpm.engine.authorization.AuthorizationQuery; +import org.camunda.bpm.engine.authorization.Permission; +import org.camunda.bpm.engine.authorization.Resource; +import org.camunda.bpm.engine.impl.cmd.AuthorizationCheckCmd; +import org.camunda.bpm.engine.impl.cmd.CreateAuthorizationCommand; +import org.camunda.bpm.engine.impl.cmd.DeleteAuthorizationCmd; +import org.camunda.bpm.engine.impl.cmd.SaveAuthorizationCmd; + +/** + * @author Daniel Meyer + * + */ +public class AuthorizationServiceImpl extends ServiceImpl implements AuthorizationService { + + public AuthorizationQuery createAuthorizationQuery() { + return new AuthorizationQueryImpl(commandExecutor); + } + + public Authorization createNewAuthorization(int type) { + return commandExecutor.execute(new CreateAuthorizationCommand(type)); + } + + public Authorization saveAuthorization(Authorization authorization) { + return commandExecutor.execute(new SaveAuthorizationCmd(authorization)); + } + + public void deleteAuthorization(String authorizationId) { + commandExecutor.execute(new DeleteAuthorizationCmd(authorizationId)); + } + + public boolean isUserAuthorized(String userId, List groupIds, Permission permission, Resource resource) { + return commandExecutor.execute(new AuthorizationCheckCmd(userId, groupIds, permission, resource, null)); + } + + public boolean isUserAuthorized(String userId, List groupIds, Permission permission, Resource resource, String resourceId) { + return commandExecutor.execute(new AuthorizationCheckCmd(userId, groupIds, permission, resource, resourceId)); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/BatchQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/BatchQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..a8952a6587d913c5981c4d239ae8a783b03a268f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/BatchQueryProperty.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.batch.BatchQuery; +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * Contains the possible properties that can be used in a {@link BatchQuery}. + * + */ +public interface BatchQueryProperty { + + QueryProperty ID = new QueryPropertyImpl("ID_"); + + QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + + QueryProperty START_TIME = new QueryPropertyImpl("START_TIME_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/BootstrapEngineCommand.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/BootstrapEngineCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..b4d0d3e52e56b8922defa231ab5390c16d4f201e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/BootstrapEngineCommand.java @@ -0,0 +1,172 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.UUID; + +import org.camunda.bpm.engine.ProcessEngineBootstrapCommand; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.DbEntity; +import org.camunda.bpm.engine.impl.db.EnginePersistenceLogger; +import org.camunda.bpm.engine.impl.db.entitymanager.OptimisticLockingListener; +import org.camunda.bpm.engine.impl.db.entitymanager.OptimisticLockingResult; +import org.camunda.bpm.engine.impl.db.entitymanager.operation.DbOperation; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.EverLivingJobEntity; +import org.camunda.bpm.engine.impl.persistence.entity.PropertyEntity; +import org.camunda.bpm.engine.impl.persistence.entity.PropertyManager; +import org.camunda.bpm.engine.impl.telemetry.dto.TelemetryDataImpl; +import org.camunda.bpm.engine.impl.telemetry.dto.LicenseKeyDataImpl; + +/** + * @author Nikola Koevski + */ +public class BootstrapEngineCommand implements ProcessEngineBootstrapCommand { + + private final static EnginePersistenceLogger LOG = ProcessEngineLogger.PERSISTENCE_LOGGER; + + protected static final String INSTALLATION_PROPERTY_NAME = "camunda.installation.id"; + + @Override + public Void execute(CommandContext commandContext) { + + initializeInstallationId(commandContext); + + checkDeploymentLockExists(commandContext); + + if (isHistoryCleanupEnabled(commandContext)) { + checkHistoryCleanupLockExists(commandContext); + createHistoryCleanupJob(commandContext); + } + + // installationId needs to be updated in the telemetry data + updateTelemetryData(commandContext); + + return null; + } + + protected void createHistoryCleanupJob(CommandContext commandContext) { + if (Context.getProcessEngineConfiguration().getManagementService().getTableMetaData("ACT_RU_JOB") != null) { + // CAM-9671: avoid transaction rollback due to the OLE being caught in CommandContext#close + commandContext.getDbEntityManager().registerOptimisticLockingListener(new OptimisticLockingListener() { + + @Override + public Class getEntityType() { + return EverLivingJobEntity.class; + } + + @Override + public OptimisticLockingResult failedOperation(DbOperation operation) { + + // nothing to do, reconfiguration will be handled later on + return OptimisticLockingResult.IGNORE; + } + }); + Context.getProcessEngineConfiguration().getHistoryService().cleanUpHistoryAsync(); + } + } + + public void checkDeploymentLockExists(CommandContext commandContext) { + PropertyEntity deploymentLockProperty = commandContext.getPropertyManager().findPropertyById("deployment.lock"); + if (deploymentLockProperty == null) { + LOG.noDeploymentLockPropertyFound(); + } + } + + public void checkHistoryCleanupLockExists(CommandContext commandContext) { + PropertyEntity historyCleanupLockProperty = commandContext.getPropertyManager().findPropertyById("history.cleanup.job.lock"); + if (historyCleanupLockProperty == null) { + LOG.noHistoryCleanupLockPropertyFound(); + } + } + + protected boolean isHistoryCleanupEnabled(CommandContext commandContext) { + return commandContext.getProcessEngineConfiguration() + .isHistoryCleanupEnabled(); + } + + public void initializeInstallationId(CommandContext commandContext) { + checkInstallationIdLockExists(commandContext); + + String databaseInstallationId = databaseInstallationId(commandContext); + + if (databaseInstallationId == null || databaseInstallationId.isEmpty()) { + + acquireExclusiveInstallationIdLock(commandContext); + databaseInstallationId = databaseInstallationId(commandContext); + + if (databaseInstallationId == null || databaseInstallationId.isEmpty()) { + LOG.noInstallationIdPropertyFound(); + createInstallationProperty(commandContext); + } + } else { + LOG.installationIdPropertyFound(databaseInstallationId); + commandContext.getProcessEngineConfiguration().setInstallationId(databaseInstallationId); + } + } + + protected void createInstallationProperty(CommandContext commandContext) { + String installationId = UUID.randomUUID().toString(); + PropertyEntity property = new PropertyEntity(INSTALLATION_PROPERTY_NAME, installationId); + commandContext.getPropertyManager().insert(property); + LOG.creatingInstallationPropertyInDatabase(property.getValue()); + commandContext.getProcessEngineConfiguration().setInstallationId(installationId); + } + + protected String databaseInstallationId(CommandContext commandContext) { + try { + PropertyEntity installationIdProperty = commandContext.getPropertyManager().findPropertyById(INSTALLATION_PROPERTY_NAME); + return installationIdProperty != null ? installationIdProperty.getValue() : null; + } catch (Exception e) { + LOG.couldNotSelectInstallationId(e.getMessage()); + return null; + } + } + + protected void checkInstallationIdLockExists(CommandContext commandContext) { + PropertyEntity installationIdProperty = commandContext.getPropertyManager().findPropertyById("installationId.lock"); + if (installationIdProperty == null) { + LOG.noInstallationIdLockPropertyFound(); + } + } + + protected void updateTelemetryData(CommandContext commandContext) { + ProcessEngineConfigurationImpl processEngineConfiguration = commandContext.getProcessEngineConfiguration(); + String installationId = processEngineConfiguration.getInstallationId(); + + TelemetryDataImpl telemetryData = processEngineConfiguration.getTelemetryData(); + + // set installationId in the telemetry data + telemetryData.setInstallation(installationId); + + // set the persisted license key in the telemetry data and registry + ManagementServiceImpl managementService = (ManagementServiceImpl) processEngineConfiguration.getManagementService(); + String licenseKey = managementService.getLicenseKey(); + if (licenseKey != null) { + LicenseKeyDataImpl licenseKeyData = LicenseKeyDataImpl.fromRawString(licenseKey); + managementService.setLicenseKeyForDiagnostics(licenseKeyData); + telemetryData.getProduct().getInternals().setLicenseKey(licenseKeyData); + } + } + + protected void acquireExclusiveInstallationIdLock(CommandContext commandContext) { + PropertyManager propertyManager = commandContext.getPropertyManager(); + //exclusive lock + propertyManager.acquireExclusiveLockForInstallationId(); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricBatchReportImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricBatchReportImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..68dea48cdc65da15cc5100549d81d585c8a98669 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricBatchReportImpl.java @@ -0,0 +1,126 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.camunda.bpm.engine.history.CleanableHistoricBatchReport; +import org.camunda.bpm.engine.history.CleanableHistoricBatchReportResult; +import org.camunda.bpm.engine.impl.batch.BatchJobHandler; +import org.camunda.bpm.engine.impl.cfg.CommandChecker; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + +import static org.camunda.bpm.engine.ProcessEngineConfiguration.HISTORY_CLEANUP_STRATEGY_REMOVAL_TIME_BASED; + +public class CleanableHistoricBatchReportImpl extends AbstractQuery implements CleanableHistoricBatchReport { + + private static final long serialVersionUID = 1L; + + protected Date currentTimestamp; + + protected boolean isHistoryCleanupStrategyRemovalTimeBased; + + public CleanableHistoricBatchReportImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + @Override + public CleanableHistoricBatchReport orderByFinishedBatchOperation() { + orderBy(CleanableHistoricInstanceReportProperty.FINISHED_AMOUNT); + return this; + } + + @Override + public long executeCount(CommandContext commandContext) { + provideHistoryCleanupStrategy(commandContext); + + checkQueryOk(); + checkPermissions(commandContext); + + Map batchOperationsForHistoryCleanup = commandContext.getProcessEngineConfiguration().getParsedBatchOperationsForHistoryCleanup(); + + if (isHistoryCleanupStrategyRemovalTimeBased()) { + addBatchOperationsWithoutTTL(batchOperationsForHistoryCleanup); + } + + return commandContext.getHistoricBatchManager().findCleanableHistoricBatchesReportCountByCriteria(this, batchOperationsForHistoryCleanup); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + provideHistoryCleanupStrategy(commandContext); + + checkQueryOk(); + checkPermissions(commandContext); + + Map batchOperationsForHistoryCleanup = commandContext.getProcessEngineConfiguration().getParsedBatchOperationsForHistoryCleanup(); + + if (isHistoryCleanupStrategyRemovalTimeBased()) { + addBatchOperationsWithoutTTL(batchOperationsForHistoryCleanup); + } + + return commandContext.getHistoricBatchManager().findCleanableHistoricBatchesReportByCriteria(this, page, batchOperationsForHistoryCleanup); + } + + protected void addBatchOperationsWithoutTTL(Map batchOperations) { + Map> batchJobHandlers = Context.getProcessEngineConfiguration().getBatchHandlers(); + + Set batchOperationKeys = null; + if (batchJobHandlers != null) { + batchOperationKeys = batchJobHandlers.keySet(); + } + + if (batchOperationKeys != null) { + for (String batchOperation : batchOperationKeys) { + Integer ttl = batchOperations.get(batchOperation); + batchOperations.put(batchOperation, ttl); + + } + } + } + + public Date getCurrentTimestamp() { + return currentTimestamp; + } + + public void setCurrentTimestamp(Date currentTimestamp) { + this.currentTimestamp = currentTimestamp; + } + + private void checkPermissions(CommandContext commandContext) { + for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { + checker.checkReadHistoricBatch(); + } + } + + protected void provideHistoryCleanupStrategy(CommandContext commandContext) { + String historyCleanupStrategy = commandContext.getProcessEngineConfiguration() + .getHistoryCleanupStrategy(); + + isHistoryCleanupStrategyRemovalTimeBased = HISTORY_CLEANUP_STRATEGY_REMOVAL_TIME_BASED.equals(historyCleanupStrategy); + } + + public boolean isHistoryCleanupStrategyRemovalTimeBased() { + return isHistoryCleanupStrategyRemovalTimeBased; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricCaseInstanceReportImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricCaseInstanceReportImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ac8d81f4cdda3d3c63c17893f6906f6e6b3f10fa --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricCaseInstanceReportImpl.java @@ -0,0 +1,143 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport; +import org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReportResult; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + +public class CleanableHistoricCaseInstanceReportImpl extends AbstractQuery implements CleanableHistoricCaseInstanceReport { + + private static final long serialVersionUID = 1L; + + protected String[] caseDefinitionIdIn; + protected String[] caseDefinitionKeyIn; + protected String[] tenantIdIn; + protected boolean isTenantIdSet = false; + protected boolean isCompact = false; + + protected Date currentTimestamp; + + public CleanableHistoricCaseInstanceReportImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + @Override + public CleanableHistoricCaseInstanceReport caseDefinitionIdIn(String... caseDefinitionIds) { + ensureNotNull(NotValidException.class, "", "caseDefinitionIdIn", (Object[]) caseDefinitionIds); + this.caseDefinitionIdIn = caseDefinitionIds; + return this; + } + + @Override + public CleanableHistoricCaseInstanceReport caseDefinitionKeyIn(String... caseDefinitionKeys) { + ensureNotNull(NotValidException.class, "", "caseDefinitionKeyIn", (Object[]) caseDefinitionKeys); + this.caseDefinitionKeyIn = caseDefinitionKeys; + return this; + } + + @Override + public CleanableHistoricCaseInstanceReport tenantIdIn(String... tenantIds) { + ensureNotNull(NotValidException.class, "", "tenantIdIn", (Object[]) tenantIds); + this.tenantIdIn = tenantIds; + isTenantIdSet = true; + return this; + } + + @Override + public CleanableHistoricCaseInstanceReport withoutTenantId() { + this.tenantIdIn = null; + isTenantIdSet = true; + return this; + } + + @Override + public CleanableHistoricCaseInstanceReport compact() { + this.isCompact = true; + return this; + } + + @Override + public CleanableHistoricCaseInstanceReport orderByFinished() { + orderBy(CleanableHistoricInstanceReportProperty.FINISHED_AMOUNT); + return this; + } + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricCaseInstanceManager() + .findCleanableHistoricCaseInstancesReportCountByCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getHistoricCaseInstanceManager() + .findCleanableHistoricCaseInstancesReportByCriteria(this, page); + } + + public String[] getCaseDefinitionIdIn() { + return caseDefinitionIdIn; + } + + public void setCaseDefinitionIdIn(String[] caseDefinitionIdIn) { + this.caseDefinitionIdIn = caseDefinitionIdIn; + } + + public String[] getCaseDefinitionKeyIn() { + return caseDefinitionKeyIn; + } + + public void setCaseDefinitionKeyIn(String[] caseDefinitionKeyIn) { + this.caseDefinitionKeyIn = caseDefinitionKeyIn; + } + + public Date getCurrentTimestamp() { + return currentTimestamp; + } + + public void setCurrentTimestamp(Date currentTimestamp) { + this.currentTimestamp = currentTimestamp; + } + + public String[] getTenantIdIn() { + return tenantIdIn; + } + + public void setTenantIdIn(String[] tenantIdIn) { + this.tenantIdIn = tenantIdIn; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public boolean isCompact() { + return isCompact; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricDecisionInstanceReportImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricDecisionInstanceReportImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..19608910e074dff869974cc9e0cb1cd6eaea2858 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricDecisionInstanceReportImpl.java @@ -0,0 +1,161 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.ProcessEngineConfiguration.HISTORY_CLEANUP_STRATEGY_REMOVAL_TIME_BASED; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReport; +import org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReportResult; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + +public class CleanableHistoricDecisionInstanceReportImpl extends AbstractQuery implements CleanableHistoricDecisionInstanceReport { + + private static final long serialVersionUID = 1L; + + protected String[] decisionDefinitionIdIn; + protected String[] decisionDefinitionKeyIn; + protected String[] tenantIdIn; + protected boolean isTenantIdSet = false; + protected boolean isCompact = false; + + protected Date currentTimestamp; + + protected boolean isHistoryCleanupStrategyRemovalTimeBased; + + public CleanableHistoricDecisionInstanceReportImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + @Override + public CleanableHistoricDecisionInstanceReport decisionDefinitionIdIn(String... decisionDefinitionIds) { + ensureNotNull(NotValidException.class, "", "decisionDefinitionIdIn", (Object[]) decisionDefinitionIds); + this.decisionDefinitionIdIn = decisionDefinitionIds; + return this; + } + + @Override + public CleanableHistoricDecisionInstanceReport decisionDefinitionKeyIn(String... decisionDefinitionKeys) { + ensureNotNull(NotValidException.class, "", "decisionDefinitionKeyIn", (Object[]) decisionDefinitionKeys); + this.decisionDefinitionKeyIn = decisionDefinitionKeys; + return this; + } + + @Override + public CleanableHistoricDecisionInstanceReport tenantIdIn(String... tenantIds) { + ensureNotNull(NotValidException.class, "", "tenantIdIn", (Object[]) tenantIds); + this.tenantIdIn = tenantIds; + isTenantIdSet = true; + return this; + } + + @Override + public CleanableHistoricDecisionInstanceReport withoutTenantId() { + this.tenantIdIn = null; + isTenantIdSet = true; + return this; + } + + @Override + public CleanableHistoricDecisionInstanceReport compact() { + this.isCompact = true; + return this; + } + + @Override + public CleanableHistoricDecisionInstanceReport orderByFinished() { + orderBy(CleanableHistoricInstanceReportProperty.FINISHED_AMOUNT); + return this; + } + + @Override + public long executeCount(CommandContext commandContext) { + provideHistoryCleanupStrategy(commandContext); + + checkQueryOk(); + return commandContext + .getHistoricDecisionInstanceManager() + .findCleanableHistoricDecisionInstancesReportCountByCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + provideHistoryCleanupStrategy(commandContext); + + checkQueryOk(); + return commandContext + .getHistoricDecisionInstanceManager() + .findCleanableHistoricDecisionInstancesReportByCriteria(this, page); + } + + public String[] getDecisionDefinitionIdIn() { + return decisionDefinitionIdIn; + } + + public void setDecisionDefinitionIdIn(String[] decisionDefinitionIdIn) { + this.decisionDefinitionIdIn = decisionDefinitionIdIn; + } + + public String[] getDecisionDefinitionKeyIn() { + return decisionDefinitionKeyIn; + } + + public void setDecisionDefinitionKeyIn(String[] decisionDefinitionKeyIn) { + this.decisionDefinitionKeyIn = decisionDefinitionKeyIn; + } + + public Date getCurrentTimestamp() { + return currentTimestamp; + } + + public void setCurrentTimestamp(Date currentTimestamp) { + this.currentTimestamp = currentTimestamp; + } + + public String[] getTenantIdIn() { + return tenantIdIn; + } + + public void setTenantIdIn(String[] tenantIdIn) { + this.tenantIdIn = tenantIdIn; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public boolean isCompact() { + return isCompact; + } + + protected void provideHistoryCleanupStrategy(CommandContext commandContext) { + String historyCleanupStrategy = commandContext.getProcessEngineConfiguration() + .getHistoryCleanupStrategy(); + + isHistoryCleanupStrategyRemovalTimeBased = HISTORY_CLEANUP_STRATEGY_REMOVAL_TIME_BASED.equals(historyCleanupStrategy); + } + + public boolean isHistoryCleanupStrategyRemovalTimeBased() { + return isHistoryCleanupStrategyRemovalTimeBased; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricInstanceReportProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricInstanceReportProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..3e28fdb8bdc14ec00e24ae89de4e3831a75cae0e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricInstanceReportProperty.java @@ -0,0 +1,24 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +public interface CleanableHistoricInstanceReportProperty { + + public static final QueryProperty FINISHED_AMOUNT = new QueryPropertyImpl("FINISHED_"); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricProcessInstanceReportImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricProcessInstanceReportImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f428f6fe6a95964ae03ead71bdf1c42258285674 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CleanableHistoricProcessInstanceReportImpl.java @@ -0,0 +1,151 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.ProcessEngineConfiguration.HISTORY_CLEANUP_STRATEGY_REMOVAL_TIME_BASED; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReport; +import org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReportResult; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + +public class CleanableHistoricProcessInstanceReportImpl extends AbstractQuery implements CleanableHistoricProcessInstanceReport { + + private static final long serialVersionUID = 1L; + + protected String[] processDefinitionIdIn; + protected String[] processDefinitionKeyIn; + protected String[] tenantIdIn; + protected boolean isTenantIdSet = false; + protected boolean isCompact = false; + + protected Date currentTimestamp; + + protected boolean isHistoryCleanupStrategyRemovalTimeBased; + + public CleanableHistoricProcessInstanceReportImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public CleanableHistoricProcessInstanceReport processDefinitionIdIn(String... processDefinitionIds) { + ensureNotNull(NotValidException.class, "", "processDefinitionIdIn", (Object[]) processDefinitionIds); + this.processDefinitionIdIn = processDefinitionIds; + return this; + } + + public CleanableHistoricProcessInstanceReport processDefinitionKeyIn(String... processDefinitionKeys) { + ensureNotNull(NotValidException.class, "", "processDefinitionKeyIn", (Object[]) processDefinitionKeys); + this.processDefinitionKeyIn = processDefinitionKeys; + return this; + } + + @Override + public CleanableHistoricProcessInstanceReport tenantIdIn(String... tenantIds) { + ensureNotNull(NotValidException.class, "", "tenantIdIn", (Object[]) tenantIds); + this.tenantIdIn = tenantIds; + isTenantIdSet = true; + return this; + } + + @Override + public CleanableHistoricProcessInstanceReport withoutTenantId() { + this.tenantIdIn = null; + isTenantIdSet = true; + return this; + } + + @Override + public CleanableHistoricProcessInstanceReport compact() { + this.isCompact = true; + return this; + } + + @Override + public CleanableHistoricProcessInstanceReport orderByFinished() { + orderBy(CleanableHistoricInstanceReportProperty.FINISHED_AMOUNT); + return this; + } + + @Override + public long executeCount(CommandContext commandContext) { + provideHistoryCleanupStrategy(commandContext); + + checkQueryOk(); + return commandContext + .getHistoricProcessInstanceManager() + .findCleanableHistoricProcessInstancesReportCountByCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, final Page page) { + provideHistoryCleanupStrategy(commandContext); + + checkQueryOk(); + return commandContext + .getHistoricProcessInstanceManager() + .findCleanableHistoricProcessInstancesReportByCriteria(this, page); + } + + public Date getCurrentTimestamp() { + return currentTimestamp; + } + + public void setCurrentTimestamp(Date currentTimestamp) { + this.currentTimestamp = currentTimestamp; + } + + public String[] getProcessDefinitionIdIn() { + return processDefinitionIdIn; + } + + public String[] getProcessDefinitionKeyIn() { + return processDefinitionKeyIn; + } + + public String[] getTenantIdIn() { + return tenantIdIn; + } + + public void setTenantIdIn(String[] tenantIdIn) { + this.tenantIdIn = tenantIdIn; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public boolean isCompact() { + return isCompact; + } + + protected void provideHistoryCleanupStrategy(CommandContext commandContext) { + String historyCleanupStrategy = commandContext.getProcessEngineConfiguration() + .getHistoryCleanupStrategy(); + + isHistoryCleanupStrategyRemovalTimeBased = HISTORY_CLEANUP_STRATEGY_REMOVAL_TIME_BASED.equals(historyCleanupStrategy); + } + + public boolean isHistoryCleanupStrategyRemovalTimeBased() { + return isHistoryCleanupStrategyRemovalTimeBased; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CompositeQueryVariableValueCondition.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CompositeQueryVariableValueCondition.java new file mode 100644 index 0000000000000000000000000000000000000000..e1f9b1f33b8e6f5aafb061a0e78b10f13448c3f5 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/CompositeQueryVariableValueCondition.java @@ -0,0 +1,61 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; +import org.camunda.bpm.engine.variable.type.ValueType; +import org.camunda.bpm.engine.variable.type.ValueTypeResolver; +import org.camunda.bpm.engine.variable.value.TypedValue; + +/** + * @author Thorben Lindhauer + * + */ +public class CompositeQueryVariableValueCondition extends AbstractQueryVariableValueCondition { + + protected List aggregatedValues = new ArrayList<>(); + + public CompositeQueryVariableValueCondition(QueryVariableValue variableValue) { + super(variableValue); + } + + public void initializeValue(VariableSerializers serializers, String dbType) { + TypedValue typedValue = wrappedQueryValue.getTypedValue(); + + ValueTypeResolver resolver = Context.getProcessEngineConfiguration().getValueTypeResolver(); + Collection concreteTypes = resolver.getSubTypes(typedValue.getType()); + + for (ValueType type : concreteTypes) { + if (type.canConvertFromTypedValue(typedValue)) { + TypedValue convertedValue = type.convertFromTypedValue(typedValue); + SingleQueryVariableValueCondition aggregatedValue = new SingleQueryVariableValueCondition(wrappedQueryValue); + aggregatedValue.initializeValue(serializers, convertedValue, dbType); + aggregatedValues.add(aggregatedValue); + } + } + } + + public List getDisjunctiveConditions() { + return aggregatedValues; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Condition.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Condition.java new file mode 100644 index 0000000000000000000000000000000000000000..9702c32072e7d7b498e465451ecf57b065851c72 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Condition.java @@ -0,0 +1,57 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.VariableScope; + + + +/** + * @author Tom Baeyens + * @author Christopher Zell + */ +public interface Condition { + + /** + * Evaluates the condition and returns the result. + * The scope will be the same as the execution. + * + * @param execution the execution which is used to evaluate the condition + * @return the result + */ + boolean evaluate(DelegateExecution execution); + + /** + * Evaluates the condition and returns the result. + * + * @param scope the variable scope which can differ of the execution + * @param execution the execution which is used to evaluate the condition + * @return the result + */ + boolean evaluate(VariableScope scope, DelegateExecution execution); + + /** + * Tries to evaluate the condition. If the property which is used in the condition does not exist + * false will be returned. + * + * @param scope the variable scope which can differ of the execution + * @param execution the execution which is used to evaluate the condition + * @return the result + */ + boolean tryEvaluate(VariableScope scope, DelegateExecution execution); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ConditionEvaluationBuilderImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ConditionEvaluationBuilderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..320d0b96d1dc8e9c2bc9ed2403291d6a75289c29 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ConditionEvaluationBuilderImpl.java @@ -0,0 +1,129 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.impl.cmd.EvaluateStartConditionCmd; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.ConditionEvaluationBuilder; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; + +public class ConditionEvaluationBuilderImpl implements ConditionEvaluationBuilder { + protected CommandExecutor commandExecutor; + + protected String businessKey; + protected String processDefinitionId; + + protected VariableMap variables = new VariableMapImpl(); + + protected String tenantId = null; + protected boolean isTenantIdSet = false; + + public ConditionEvaluationBuilderImpl(CommandExecutor commandExecutor) { + ensureNotNull("commandExecutor", commandExecutor); + this.commandExecutor = commandExecutor; + } + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } + + public String getBusinessKey() { + return businessKey; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public VariableMap getVariables() { + return variables; + } + + public String getTenantId() { + return tenantId; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + protected T execute(Command command) { + return commandExecutor.execute(command); + } + + @Override + public ConditionEvaluationBuilder processInstanceBusinessKey(String businessKey) { + ensureNotNull("businessKey", businessKey); + this.businessKey = businessKey; + return this; + } + + @Override + public ConditionEvaluationBuilder processDefinitionId(String processDefinitionId) { + ensureNotNull("processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + @Override + public ConditionEvaluationBuilder setVariable(String variableName, Object variableValue) { + ensureNotNull("variableName", variableName); + this.variables.put(variableName, variableValue); + return this; + } + + @Override + public ConditionEvaluationBuilder setVariables(Map variables) { + ensureNotNull("variables", variables); + if (variables != null) { + this.variables.putAll(variables); + } + return this; + } + + @Override + public ConditionEvaluationBuilder tenantId(String tenantId) { + ensureNotNull( + "The tenant-id cannot be null. Use 'withoutTenantId()' if you want to evaluate conditional start event with a process definition which has no tenant-id.", + "tenantId", tenantId); + + isTenantIdSet = true; + this.tenantId = tenantId; + return this; + } + + @Override + public ConditionEvaluationBuilder withoutTenantId() { + isTenantIdSet = true; + tenantId = null; + return this; + } + + @Override + public List evaluateStartConditions() { + return execute(new EvaluateStartConditionCmd(this)); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DecisionServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DecisionServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..25f6020dc4cf273751a08fb11f15b08463b50902 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DecisionServiceImpl.java @@ -0,0 +1,68 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.Map; + +import org.camunda.bpm.dmn.engine.DmnDecisionTableResult; +import org.camunda.bpm.engine.DecisionService; +import org.camunda.bpm.engine.dmn.DecisionEvaluationBuilder; +import org.camunda.bpm.engine.dmn.DecisionsEvaluationBuilder; +import org.camunda.bpm.engine.impl.dmn.DecisionEvaluationBuilderImpl; +import org.camunda.bpm.engine.impl.dmn.DecisionTableEvaluationBuilderImpl; + +/** + * @author Philipp Ossler + */ +public class DecisionServiceImpl extends ServiceImpl implements DecisionService { + + public DmnDecisionTableResult evaluateDecisionTableById(String decisionDefinitionId, Map variables) { + return evaluateDecisionTableById(decisionDefinitionId) + .variables(variables) + .evaluate(); + } + + public DmnDecisionTableResult evaluateDecisionTableByKey(String decisionDefinitionKey, Map variables) { + return evaluateDecisionTableByKey(decisionDefinitionKey) + .variables(variables) + .evaluate(); + } + + public DmnDecisionTableResult evaluateDecisionTableByKeyAndVersion(String decisionDefinitionKey, Integer version, Map variables) { + return evaluateDecisionTableByKey(decisionDefinitionKey) + .version(version) + .variables(variables) + .evaluate(); + } + + public DecisionEvaluationBuilder evaluateDecisionTableByKey(String decisionDefinitionKey) { + return DecisionTableEvaluationBuilderImpl.evaluateDecisionTableByKey(commandExecutor, decisionDefinitionKey); + } + + public DecisionEvaluationBuilder evaluateDecisionTableById(String decisionDefinitionId) { + return DecisionTableEvaluationBuilderImpl.evaluateDecisionTableById(commandExecutor, decisionDefinitionId); + } + + public DecisionsEvaluationBuilder evaluateDecisionByKey(String decisionDefinitionKey) { + return DecisionEvaluationBuilderImpl.evaluateDecisionByKey(commandExecutor, decisionDefinitionKey); + } + + public DecisionsEvaluationBuilder evaluateDecisionById(String decisionDefinitionId) { + return DecisionEvaluationBuilderImpl.evaluateDecisionById(commandExecutor, decisionDefinitionId); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DefaultArtifactFactory.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DefaultArtifactFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..287fa790b01227c902aa18cbf46bea3329bce00a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DefaultArtifactFactory.java @@ -0,0 +1,41 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.ArtifactFactory; +import org.camunda.bpm.engine.ProcessEngineException; + +/** + * Default ArtifactService implementation. + * This version uses Class.newInstance() to create + * new Artifacts. + * This is the default behaviour like has been in old + * camunda/activity versions. + * + * @since 7.2.0 + * @author Mark Struberg + */ +public class DefaultArtifactFactory implements ArtifactFactory { + @Override + public T getArtifact(Class clazz) { + try { + return clazz.newInstance(); + } catch (Exception e) { + throw new ProcessEngineException("couldn't instantiate class " + clazz.getName(), e); + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DefaultPriorityProvider.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DefaultPriorityProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..71c26b6aac43299206454dcd9501fb42fcd58fd7 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DefaultPriorityProvider.java @@ -0,0 +1,190 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.context.ProcessApplicationContextUtil; +import org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl; + +/** + * Represents a default priority provider, which contains some functionality to evaluate the priority. + * Can be used as base class for other priority providers. * + * + * @author Christopher Zell + * @param the type of the param to determine the priority + */ +public abstract class DefaultPriorityProvider implements PriorityProvider { + + /** + * The default priority. + */ + public static long DEFAULT_PRIORITY = 0; + + /** + * The default priority in case of resolution failure. + */ + public static long DEFAULT_PRIORITY_ON_RESOLUTION_FAILURE = 0; + + /** + * Returns the default priority. + * + * @return the default priority + */ + public long getDefaultPriority() { + return DEFAULT_PRIORITY; + } + + /** + * Returns the default priority in case of resolution failure. + * + * @return the default priority + */ + public long getDefaultPriorityOnResolutionFailure() { + return DEFAULT_PRIORITY_ON_RESOLUTION_FAILURE; + } + + /** + * Evaluates a given value provider with the given execution entity to determine + * the correct value. The error message heading is used for the error message + * if the validation fails because the value is no valid priority. + * + * @param valueProvider the provider which contains the value + * @param execution the execution entity + * @param errorMessageHeading the heading which is used for the error message + * @return the valid priority value + */ + protected Long evaluateValueProvider(ParameterValueProvider valueProvider, ExecutionEntity execution, String errorMessageHeading) { + Object value; + try { + value = valueProvider.getValue(execution); + + } catch (ProcessEngineException e) { + + if (Context.getProcessEngineConfiguration().isEnableGracefulDegradationOnContextSwitchFailure() + && isSymptomOfContextSwitchFailure(e, execution)) { + + value = getDefaultPriorityOnResolutionFailure(); + logNotDeterminingPriority(execution, value, e); + } + else { + throw e; + } + } + + if (!(value instanceof Number)) { + throw new ProcessEngineException(errorMessageHeading + ": Priority value is not an Integer"); + } + else { + Number numberValue = (Number) value; + if (isValidLongValue(numberValue)) { + return numberValue.longValue(); + } + else { + throw new ProcessEngineException(errorMessageHeading + ": Priority value must be either Short, Integer, or Long"); + } + } + } + + @Override + public long determinePriority(ExecutionEntity execution, T param, String jobDefinitionId) { + if (param != null || execution != null) { + Long specificPriority = getSpecificPriority(execution, param, jobDefinitionId); + if (specificPriority != null) { + return specificPriority; + } + + Long processDefinitionPriority = getProcessDefinitionPriority(execution, param); + if (processDefinitionPriority != null) { + return processDefinitionPriority; + } + } + return getDefaultPriority(); + } + + /** + * Returns the priority defined in the specific entity. Like a job definition priority or + * an activity priority. The result can also be null in that case the process + * priority will be used. + * + * @param execution the current execution + * @param param the generic param + * @param jobDefinitionId the job definition id if related to a job + * @return the specific priority + */ + protected abstract Long getSpecificPriority(ExecutionEntity execution, T param, String jobDefinitionId); + + /** + * Returns the priority defined in the process definition. Can also be null + * in that case the fallback is the default priority. + * + * @param execution the current execution + * @param param the generic param + * @return the priority defined in the process definition + */ + protected abstract Long getProcessDefinitionPriority(ExecutionEntity execution, T param); + + /** + * Returns the priority which is defined in the given process definition. + * The priority value is identified with the given propertyKey. + * Returns null if the process definition is null or no priority was defined. + * + * @param processDefinition the process definition that should contains the priority + * @param propertyKey the key which identifies the property + * @param execution the current execution + * @param errorMsgHead the error message header which is used if the evaluation fails + * @return the priority defined in the given process + */ + protected Long getProcessDefinedPriority(ProcessDefinitionImpl processDefinition, String propertyKey, ExecutionEntity execution, String errorMsgHead) { + if (processDefinition != null) { + ParameterValueProvider priorityProvider = (ParameterValueProvider) processDefinition.getProperty(propertyKey); + if (priorityProvider != null) { + return evaluateValueProvider(priorityProvider, execution, errorMsgHead); + } + } + return null; + } + /** + * Logs the exception which was thrown if the priority can not be determined. + * + * @param execution the current execution entity + * @param value the current value + * @param e the exception which was catched + */ + protected abstract void logNotDeterminingPriority(ExecutionEntity execution, Object value, ProcessEngineException e); + + + protected boolean isSymptomOfContextSwitchFailure(Throwable t, ExecutionEntity contextExecution) { + // a context switch failure can occur, if the current engine has no PA registration for the deployment + // subclasses may assert the actual throwable to narrow down the diagnose + return ProcessApplicationContextUtil.getTargetProcessApplication(contextExecution) == null; + } + + /** + * Checks if the given number is a valid long value. + * @param value the number which should be checked + * @return true if is a valid long value, false otherwise + */ + protected boolean isValidLongValue(Number value) { + return + value instanceof Short || + value instanceof Integer || + value instanceof Long; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DeploymentQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DeploymentQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..77f55b788dd7217e8f93d4e0e1f0d098274cbd8e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DeploymentQueryImpl.java @@ -0,0 +1,187 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.CompareUtil; +import org.camunda.bpm.engine.repository.Deployment; +import org.camunda.bpm.engine.repository.DeploymentQuery; + + +/** + * @author Tom Baeyens + * @author Joram Barrez + * @author Ingo Richtsmeier + */ +public class DeploymentQueryImpl extends AbstractQuery implements DeploymentQuery, Serializable { + + private static final long serialVersionUID = 1L; + protected String deploymentId; + protected String name; + protected String nameLike; + protected boolean sourceQueryParamEnabled; + protected String source; + protected Date deploymentBefore; + protected Date deploymentAfter; + + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + protected boolean includeDeploymentsWithoutTenantId = false; + + public DeploymentQueryImpl() { + } + + public DeploymentQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public DeploymentQueryImpl deploymentId(String deploymentId) { + ensureNotNull("Deployment id", deploymentId); + this.deploymentId = deploymentId; + return this; + } + + public DeploymentQueryImpl deploymentName(String deploymentName) { + ensureNotNull("deploymentName", deploymentName); + this.name = deploymentName; + return this; + } + + public DeploymentQueryImpl deploymentNameLike(String nameLike) { + ensureNotNull("deploymentNameLike", nameLike); + this.nameLike = nameLike; + return this; + } + + public DeploymentQuery deploymentSource(String source) { + sourceQueryParamEnabled = true; + this.source = source; + return this; + } + + public DeploymentQuery deploymentBefore(Date before) { + ensureNotNull("deploymentBefore", before); + this.deploymentBefore = before; + return this; + } + + public DeploymentQuery deploymentAfter(Date after) { + ensureNotNull("deploymentAfter", after); + this.deploymentAfter = after; + return this; + } + + public DeploymentQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public DeploymentQuery withoutTenantId() { + isTenantIdSet = true; + this.tenantIds = null; + return this; + } + + public DeploymentQuery includeDeploymentsWithoutTenantId() { + this.includeDeploymentsWithoutTenantId = true; + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() || CompareUtil.areNotInAscendingOrder(deploymentAfter, deploymentBefore); + } + + //sorting //////////////////////////////////////////////////////// + + public DeploymentQuery orderByDeploymentId() { + return orderBy(DeploymentQueryProperty.DEPLOYMENT_ID); + } + + public DeploymentQuery orderByDeploymenTime() { + return orderBy(DeploymentQueryProperty.DEPLOY_TIME); + } + + public DeploymentQuery orderByDeploymentTime() { + return orderBy(DeploymentQueryProperty.DEPLOY_TIME); + } + + public DeploymentQuery orderByDeploymentName() { + return orderBy(DeploymentQueryProperty.DEPLOYMENT_NAME); + } + + public DeploymentQuery orderByTenantId() { + return orderBy(DeploymentQueryProperty.TENANT_ID); + } + + //results //////////////////////////////////////////////////////// + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getDeploymentManager() + .findDeploymentCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getDeploymentManager() + .findDeploymentsByQueryCriteria(this, page); + } + + //getters //////////////////////////////////////////////////////// + + public String getDeploymentId() { + return deploymentId; + } + + public String getName() { + return name; + } + + public String getNameLike() { + return nameLike; + } + + public boolean isSourceQueryParamEnabled() { + return sourceQueryParamEnabled; + } + + public String getSource() { + return source; + } + + public Date getDeploymentBefore() { + return deploymentBefore; + } + + public Date getDeploymentAfter() { + return deploymentAfter; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DeploymentQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DeploymentQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..2be958a30cabb9dec8b04d04aca1b89636eb3682 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DeploymentQueryProperty.java @@ -0,0 +1,36 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; +import org.camunda.bpm.engine.repository.DeploymentQuery; + + + +/** + * Contains the possible properties that can be used in a {@link DeploymentQuery}. + * + * @author Joram Barrez + */ +public interface DeploymentQueryProperty { + + public static final QueryProperty DEPLOYMENT_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty DEPLOYMENT_NAME = new QueryPropertyImpl("NAME_"); + public static final QueryProperty DEPLOY_TIME = new QueryPropertyImpl("DEPLOY_TIME_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DeploymentStatisticsQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DeploymentStatisticsQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ffdd1e749a81f2276d338c68b822c0e6bd9b7182 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/DeploymentStatisticsQueryImpl.java @@ -0,0 +1,132 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.ArrayList; +import java.util.List; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.db.PermissionCheck; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.management.DeploymentStatistics; +import org.camunda.bpm.engine.management.DeploymentStatisticsQuery; + +public class DeploymentStatisticsQueryImpl extends AbstractQuery +implements DeploymentStatisticsQuery { + + protected static final long serialVersionUID = 1L; + protected boolean includeFailedJobs = false; + protected boolean includeIncidents = false; + protected String includeIncidentsForType; + + // for internal use + protected List processInstancePermissionChecks = new ArrayList(); + protected List jobPermissionChecks = new ArrayList(); + protected List incidentPermissionChecks = new ArrayList(); + + public DeploymentStatisticsQueryImpl(CommandExecutor executor) { + super(executor); + } + + public DeploymentStatisticsQuery includeFailedJobs() { + includeFailedJobs = true; + return this; + } + + public DeploymentStatisticsQuery includeIncidents() { + includeIncidents = true; + return this; + } + + public DeploymentStatisticsQuery includeIncidentsForType(String incidentType) { + this.includeIncidentsForType = incidentType; + return this; + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return + commandContext + .getStatisticsManager() + .getStatisticsCountGroupedByDeployment(this); + } + + @Override + public List executeList(CommandContext commandContext, + Page page) { + checkQueryOk(); + return + commandContext + .getStatisticsManager() + .getStatisticsGroupedByDeployment(this, page); + } + + public boolean isFailedJobsToInclude() { + return includeFailedJobs; + } + + public boolean isIncidentsToInclude() { + return includeIncidents || includeIncidentsForType != null; + } + + protected void checkQueryOk() { + super.checkQueryOk(); + if (includeIncidents && includeIncidentsForType != null) { + throw new ProcessEngineException("Invalid query: It is not possible to use includeIncident() and includeIncidentForType() to execute one query."); + } + } + + // getter/setter for authorization check + + public List getProcessInstancePermissionChecks() { + return processInstancePermissionChecks; + } + + public void setProcessInstancePermissionChecks(List processInstancePermissionChecks) { + this.processInstancePermissionChecks = processInstancePermissionChecks; + } + + public void addProcessInstancePermissionCheck(List permissionChecks) { + processInstancePermissionChecks.addAll(permissionChecks); + } + + public List getJobPermissionChecks() { + return jobPermissionChecks; + } + + public void setJobPermissionChecks(List jobPermissionChecks) { + this.jobPermissionChecks = jobPermissionChecks; + } + + public void addJobPermissionCheck(List permissionChecks) { + jobPermissionChecks.addAll(permissionChecks); + } + + public List getIncidentPermissionChecks() { + return incidentPermissionChecks; + } + + public void setIncidentPermissionChecks(List incidentPermissionChecks) { + this.incidentPermissionChecks = incidentPermissionChecks; + } + + public void addIncidentPermissionCheck(List permissionChecks) { + incidentPermissionChecks.addAll(permissionChecks); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Direction.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Direction.java new file mode 100644 index 0000000000000000000000000000000000000000..10e9f07249d2d983843423597b7de8153b0a4f9b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Direction.java @@ -0,0 +1,53 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.HashMap; +import java.util.Map; + + +/** + * @author Tom Baeyens + */ +public class Direction { + + private static final Map directions = new HashMap(); + + public static final Direction ASCENDING = new Direction("asc"); + public static final Direction DESCENDING = new Direction("desc"); + + private String name; + + public Direction(String name) { + this.name = name; + directions.put(name, this); + } + + public String getName() { + return name; + } + + public String toString() { + return "Direction[" + + "name=" + name + + "]"; + } + + public static Direction findByName(String directionName) { + return directions.get(directionName); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/EventSubscriptionQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/EventSubscriptionQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..5a0dadd753160ec2198b5554a21dcca6d32728c8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/EventSubscriptionQueryImpl.java @@ -0,0 +1,159 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.io.Serializable; +import java.util.List; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.EventSubscription; +import org.camunda.bpm.engine.runtime.EventSubscriptionQuery; + + +/** + * @author Daniel Meyer + */ +public class EventSubscriptionQueryImpl + extends AbstractQuery + implements Serializable, EventSubscriptionQuery { + + private static final long serialVersionUID = 1L; + + protected String eventSubscriptionId; + protected String eventName; + protected String eventType; + protected String executionId; + protected String processInstanceId; + protected String activityId; + + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + protected boolean includeEventSubscriptionsWithoutTenantId = false; + + public EventSubscriptionQueryImpl() { + } + + public EventSubscriptionQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public EventSubscriptionQuery eventSubscriptionId(String id) { + ensureNotNull("event subscription id", id); + this.eventSubscriptionId = id; + return this; + } + + public EventSubscriptionQuery eventName(String eventName) { + ensureNotNull("event name", eventName); + this.eventName = eventName; + return this; + } + + public EventSubscriptionQueryImpl executionId(String executionId) { + ensureNotNull("execution id", executionId); + this.executionId = executionId; + return this; + } + + public EventSubscriptionQuery processInstanceId(String processInstanceId) { + ensureNotNull("process instance id", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + public EventSubscriptionQueryImpl activityId(String activityId) { + ensureNotNull("activity id", activityId); + this.activityId = activityId; + return this; + } + + public EventSubscriptionQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public EventSubscriptionQuery withoutTenantId() { + isTenantIdSet = true; + this.tenantIds = null; + return this; + } + + public EventSubscriptionQuery includeEventSubscriptionsWithoutTenantId() { + this.includeEventSubscriptionsWithoutTenantId = true; + return this; + } + + public EventSubscriptionQueryImpl eventType(String eventType) { + ensureNotNull("event type", eventType); + this.eventType = eventType; + return this; + } + + public EventSubscriptionQuery orderByCreated() { + return orderBy(EventSubscriptionQueryProperty.CREATED); + } + + public EventSubscriptionQuery orderByTenantId() { + return orderBy(EventSubscriptionQueryProperty.TENANT_ID); + } + + //results ////////////////////////////////////////// + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getEventSubscriptionManager() + .findEventSubscriptionCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getEventSubscriptionManager() + .findEventSubscriptionsByQueryCriteria(this,page); + } + + //getters ////////////////////////////////////////// + + + public String getEventSubscriptionId() { + return eventSubscriptionId; + } + public String getEventName() { + return eventName; + } + public String getEventType() { + return eventType; + } + public String getExecutionId() { + return executionId; + } + public String getProcessInstanceId() { + return processInstanceId; + } + public String getActivityId() { + return activityId; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/EventSubscriptionQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/EventSubscriptionQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..82924ee3785314442cbf990a82e0281d79b32ea8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/EventSubscriptionQueryProperty.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + + + +/** + * @author Daniel Meyer + */ +public interface EventSubscriptionQueryProperty { + + // properties used in event subscription queries: + + public final static QueryProperty CREATED = new QueryPropertyImpl("CREATED_"); + + public final static QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/EventSubscriptionQueryValue.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/EventSubscriptionQueryValue.java new file mode 100644 index 0000000000000000000000000000000000000000..266f9600498a6de89330a104f615f5803d21f385 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/EventSubscriptionQueryValue.java @@ -0,0 +1,55 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.io.Serializable; + + +/** + * @author Daniel Meyer + */ +public class EventSubscriptionQueryValue implements Serializable { + + private static final long serialVersionUID = 1L; + + protected String eventType; + protected String eventName; + + public EventSubscriptionQueryValue(String eventName, String eventType) { + this.eventName = eventName; + this.eventType = eventType; + } + + public String getEventType() { + return eventType; + } + + public void setEventType(String eventType) { + this.eventType = eventType; + } + + public String getEventName() { + return eventName; + } + + public void setEventName(String eventName) { + this.eventName = eventName; + } + + + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExecutionQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExecutionQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..73465e175ade7f665b6af126017e4434635bd008 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExecutionQueryImpl.java @@ -0,0 +1,290 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.List; +import org.camunda.bpm.engine.impl.event.EventType; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.SuspensionState; +import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.runtime.ExecutionQuery; + + +/** + * @author Joram Barrez + * @author Frederik Heremans + * @author Daniel Meyer + */ +public class ExecutionQueryImpl extends AbstractVariableQueryImpl + implements ExecutionQuery { + + private static final long serialVersionUID = 1L; + protected String processDefinitionId; + protected String processDefinitionKey; + protected String businessKey; + protected String activityId; + protected String executionId; + protected String processInstanceId; + protected List eventSubscriptions; + protected SuspensionState suspensionState; + protected String incidentType; + protected String incidentId; + protected String incidentMessage; + protected String incidentMessageLike; + + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + + public ExecutionQueryImpl() { + } + + public ExecutionQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public ExecutionQueryImpl processDefinitionId(String processDefinitionId) { + ensureNotNull("Process definition id", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + public ExecutionQueryImpl processDefinitionKey(String processDefinitionKey) { + ensureNotNull("Process definition key", processDefinitionKey); + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public ExecutionQueryImpl processInstanceId(String processInstanceId) { + ensureNotNull("Process instance id", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + public ExecutionQuery processInstanceBusinessKey(String businessKey) { + ensureNotNull("Business key", businessKey); + this.businessKey = businessKey; + return this; + } + + public ExecutionQueryImpl executionId(String executionId) { + ensureNotNull("Execution id", executionId); + this.executionId = executionId; + return this; + } + + public ExecutionQueryImpl activityId(String activityId) { + this.activityId = activityId; + return this; + } + + public ExecutionQuery signalEventSubscription(String signalName) { + return eventSubscription(EventType.SIGNAL, signalName); + } + + public ExecutionQuery signalEventSubscriptionName(String signalName) { + return eventSubscription(EventType.SIGNAL, signalName); + } + + public ExecutionQuery messageEventSubscriptionName(String messageName) { + return eventSubscription(EventType.MESSAGE, messageName); + } + + public ExecutionQuery messageEventSubscription() { + return eventSubscription(EventType.MESSAGE, null); + } + + public ExecutionQuery eventSubscription(EventType eventType, String eventName) { + ensureNotNull("event type", eventType); + if (!EventType.MESSAGE.equals(eventType)) { + // event name is optional for message events + ensureNotNull("event name", eventName); + } + if(eventSubscriptions == null) { + eventSubscriptions = new ArrayList(); + } + eventSubscriptions.add(new EventSubscriptionQueryValue(eventName, eventType.name())); + return this; + } + + public ExecutionQuery suspended() { + this.suspensionState = SuspensionState.SUSPENDED; + return this; + } + + public ExecutionQuery active() { + this.suspensionState = SuspensionState.ACTIVE; + return this; + } + + public ExecutionQuery processVariableValueEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.EQUALS, false); + return this; + } + + public ExecutionQuery processVariableValueNotEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.NOT_EQUALS, false); + return this; + } + + public ExecutionQuery incidentType(String incidentType) { + ensureNotNull("incident type", incidentType); + this.incidentType = incidentType; + return this; + } + + public ExecutionQuery incidentId(String incidentId) { + ensureNotNull("incident id", incidentId); + this.incidentId = incidentId; + return this; + } + + public ExecutionQuery incidentMessage(String incidentMessage) { + ensureNotNull("incident message", incidentMessage); + this.incidentMessage = incidentMessage; + return this; + } + + public ExecutionQuery incidentMessageLike(String incidentMessageLike) { + ensureNotNull("incident messageLike", incidentMessageLike); + this.incidentMessageLike = incidentMessageLike; + return this; + } + + public ExecutionQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public ExecutionQuery withoutTenantId() { + this.tenantIds = null; + isTenantIdSet = true; + return this; + } + + //ordering //////////////////////////////////////////////////// + + public ExecutionQueryImpl orderByProcessInstanceId() { + orderBy(ExecutionQueryProperty.PROCESS_INSTANCE_ID); + return this; + } + + public ExecutionQueryImpl orderByProcessDefinitionId() { + orderBy(new QueryOrderingProperty(QueryOrderingProperty.RELATION_PROCESS_DEFINITION, ExecutionQueryProperty.PROCESS_DEFINITION_ID)); + return this; + } + + public ExecutionQueryImpl orderByProcessDefinitionKey() { + orderBy(new QueryOrderingProperty(QueryOrderingProperty.RELATION_PROCESS_DEFINITION, ExecutionQueryProperty.PROCESS_DEFINITION_KEY)); + return this; + } + + public ExecutionQuery orderByTenantId() { + orderBy(ExecutionQueryProperty.TENANT_ID); + return this; + } + + //results //////////////////////////////////////////////////// + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + ensureVariablesInitialized(); + return commandContext + .getExecutionManager() + .findExecutionCountByQueryCriteria(this); + } + + @Override + @SuppressWarnings("unchecked") + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + ensureVariablesInitialized(); + return (List) commandContext + .getExecutionManager() + .findExecutionsByQueryCriteria(this, page); + } + + //getters //////////////////////////////////////////////////// + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getActivityId() { + return activityId; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getProcessInstanceIds() { + return null; + } + + public String getBusinessKey() { + return businessKey; + } + + public String getExecutionId() { + return executionId; + } + + public SuspensionState getSuspensionState() { + return suspensionState; + } + + public void setSuspensionState(SuspensionState suspensionState) { + this.suspensionState = suspensionState; + } + + public List getEventSubscriptions() { + return eventSubscriptions; + } + + public void setEventSubscriptions(List eventSubscriptions) { + this.eventSubscriptions = eventSubscriptions; + } + + public String getIncidentId() { + return incidentId; + } + + public String getIncidentType() { + return incidentType; + } + + public String getIncidentMessage() { + return incidentMessage; + } + + public String getIncidentMessageLike() { + return incidentMessageLike; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExecutionQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExecutionQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..5886ed04040aefd8d7de58ef5e2c8069578ca806 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExecutionQueryProperty.java @@ -0,0 +1,35 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; +import org.camunda.bpm.engine.runtime.ExecutionQuery; + +/** + * Contains the possible properties that can be used in a {@link ExecutionQuery}. + * + * @author Joram Barrez + */ +public interface ExecutionQueryProperty { + + public static final QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROC_INST_ID_"); + public static final QueryProperty PROCESS_DEFINITION_KEY = new QueryPropertyImpl("KEY_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty SEQUENCE_COUNTER = new QueryPropertyImpl("SEQUENCE_COUNTER_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExternalTaskQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExternalTaskQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..c6576f483f8431ebc87a61458d808c6f64ffcc3e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExternalTaskQueryImpl.java @@ -0,0 +1,489 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.externaltask.ExternalTask; +import org.camunda.bpm.engine.externaltask.ExternalTaskQuery; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.SuspensionState; +import org.camunda.bpm.engine.impl.util.ClockUtil; +import org.camunda.bpm.engine.impl.util.CompareUtil; +import org.camunda.bpm.engine.impl.util.ImmutablePair; +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import static java.lang.Boolean.TRUE; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotEmpty; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +/** + * @author Thorben Lindhauer + * @author Christopher Zell + */ +public class ExternalTaskQueryImpl extends AbstractQuery implements ExternalTaskQuery { + + private static final long serialVersionUID = 1L; + + protected String externalTaskId; + protected Set externalTaskIds; + protected String workerId; + protected Date lockExpirationBefore; + protected Date lockExpirationAfter; + protected String topicName; + protected Boolean locked; + protected Boolean notLocked; + protected String executionId; + protected String processInstanceId; + protected String[] processInstanceIdIn; + protected String processDefinitionKey; + protected String[] processDefinitionKeys; + protected String processDefinitionId; + protected String processDefinitionName; + protected String processDefinitionNameLike; + protected String activityId; + protected String[] activityIdIn; + protected SuspensionState suspensionState; + protected Long priorityHigherThanOrEquals; + protected Long priorityLowerThanOrEquals; + protected Boolean variableNamesIgnoreCase; + protected Boolean variableValuesIgnoreCase; + protected List variables = new ArrayList<>(); + protected Boolean retriesLeft; + protected String[] tenantIds; + + public ExternalTaskQueryImpl() { + } + + public ExternalTaskQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public ExternalTaskQuery externalTaskId(String externalTaskId) { + ensureNotNull("externalTaskId", externalTaskId); + this.externalTaskId = externalTaskId; + return this; + } + + @Override + public ExternalTaskQuery externalTaskIdIn(Set externalTaskIds) { + ensureNotEmpty("Set of external task ids", externalTaskIds); + this.externalTaskIds = externalTaskIds; + return this; + } + + public ExternalTaskQuery workerId(String workerId) { + ensureNotNull("workerId", workerId); + this.workerId = workerId; + return this; + } + + public ExternalTaskQuery lockExpirationBefore(Date lockExpirationDate) { + ensureNotNull("lockExpirationBefore", lockExpirationDate); + this.lockExpirationBefore = lockExpirationDate; + return this; + } + + public ExternalTaskQuery lockExpirationAfter(Date lockExpirationDate) { + ensureNotNull("lockExpirationAfter", lockExpirationDate); + this.lockExpirationAfter = lockExpirationDate; + return this; + } + + public ExternalTaskQuery topicName(String topicName) { + ensureNotNull("topicName", topicName); + this.topicName = topicName; + return this; + } + + public ExternalTaskQuery locked() { + this.locked = TRUE; + return this; + } + + public ExternalTaskQuery notLocked() { + this.notLocked = TRUE; + return this; + } + + public ExternalTaskQuery executionId(String executionId) { + ensureNotNull("executionId", executionId); + this.executionId = executionId; + return this; + } + + public ExternalTaskQuery processInstanceId(String processInstanceId) { + ensureNotNull("processInstanceId", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + public ExternalTaskQuery processInstanceIdIn(String... processInstanceIdIn) { + ensureNotNull("processInstanceIdIn", (Object[]) processInstanceIdIn); + this.processInstanceIdIn = processInstanceIdIn; + return this; + } + + @Override + public ExternalTaskQuery processDefinitionKey(String processDefinitionKey) { + this.processDefinitionKey = processDefinitionKey; + return this; + } + + @Override + public ExternalTaskQuery processDefinitionKeyIn(String... processDefinitionKeys) { + this.processDefinitionKeys = processDefinitionKeys; + return this; + } + + public ExternalTaskQuery processDefinitionId(String processDefinitionId) { + ensureNotNull("processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + @Override + public ExternalTaskQuery processDefinitionName(String processDefinitionName) { + this.processDefinitionName = processDefinitionName; + return this; + } + + @Override + public ExternalTaskQuery processDefinitionNameLike(String processDefinitionName) { + this.processDefinitionNameLike = processDefinitionName; + return this; + } + + public ExternalTaskQuery activityId(String activityId) { + ensureNotNull("activityId", activityId); + this.activityId = activityId; + return this; + } + + public ExternalTaskQuery activityIdIn(String... activityIdIn) { + ensureNotNull("activityIdIn", (Object[]) activityIdIn); + this.activityIdIn = activityIdIn; + return this; + } + @Override + public ExternalTaskQuery priorityHigherThanOrEquals(long priority) { + this.priorityHigherThanOrEquals = priority; + return this; + } + + @Override + public ExternalTaskQuery priorityLowerThanOrEquals(long priority) { + this.priorityLowerThanOrEquals = priority; + return this; + } + + @Override + public ExternalTaskQuery processVariableValueEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.EQUALS); + return this; + } + + @Override + public ExternalTaskQuery processVariableValueNotEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.NOT_EQUALS); + return this; + } + + @Override + public ExternalTaskQuery processVariableValueLike(String variableName, String variableValue) { + addVariable(variableName, variableValue, QueryOperator.LIKE); + return this; + } + + @Override + public ExternalTaskQuery processVariableValueNotLike(String variableName, String variableValue) { + addVariable(variableName, variableValue, QueryOperator.NOT_LIKE); + return this; + } + + @Override + public ExternalTaskQuery processVariableValueGreaterThan(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.GREATER_THAN); + return this; + } + + @Override + public ExternalTaskQuery processVariableValueGreaterThanOrEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.GREATER_THAN_OR_EQUAL); + return this; + } + + @Override + public ExternalTaskQuery processVariableValueLessThan(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LESS_THAN); + return this; + } + + @Override + public ExternalTaskQuery processVariableValueLessThanOrEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LESS_THAN_OR_EQUAL); + return this; + } + + @Override + public ExternalTaskQuery matchVariableNamesIgnoreCase() { + this.variableNamesIgnoreCase = true; + for (QueryVariableValue variable : this.variables) { + variable.setVariableNameIgnoreCase(true); + } + return this; + } + + @Override + public ExternalTaskQuery matchVariableValuesIgnoreCase() { + this.variableValuesIgnoreCase = true; + for (QueryVariableValue variable : this.variables) { + variable.setVariableValueIgnoreCase(true); + } + return this; + } + + public void addVariable(String name, Object value, QueryOperator operator) { + ensureNotNull("name", name); + + if(value == null || isBoolean(value)) { + // Null-values and booleans can only be used in EQUALS and NOT_EQUALS + switch(operator) { + case GREATER_THAN: + throw new ProcessEngineException("Booleans and null cannot be used in 'greater than' condition"); + case LESS_THAN: + throw new ProcessEngineException("Booleans and null cannot be used in 'less than' condition"); + case GREATER_THAN_OR_EQUAL: + throw new ProcessEngineException("Booleans and null cannot be used in 'greater than or equal' condition"); + case LESS_THAN_OR_EQUAL: + throw new ProcessEngineException("Booleans and null cannot be used in 'less than or equal' condition"); + case LIKE: + throw new ProcessEngineException("Booleans and null cannot be used in 'like' condition"); + case NOT_LIKE: + throw new ProcessEngineException("Booleans and null cannot be used in 'not like' condition"); + default: + break; + } + } + boolean shouldMatchVariableValuesIgnoreCase = TRUE.equals(variableValuesIgnoreCase) && value != null && String.class.isAssignableFrom(value.getClass()); + addVariable(new QueryVariableValue(name, value, operator, false, TRUE.equals(variableNamesIgnoreCase), shouldMatchVariableValuesIgnoreCase)); + } + + protected void addVariable(QueryVariableValue queryVariableValue) { + variables.add(queryVariableValue); + } + + private boolean isBoolean(Object value) { + if (value == null) { + return false; + } + return Boolean.class.isAssignableFrom(value.getClass()) || boolean.class.isAssignableFrom(value.getClass()); + } + + public ExternalTaskQuery suspended() { + this.suspensionState = SuspensionState.SUSPENDED; + return this; + } + + public ExternalTaskQuery active() { + this.suspensionState = SuspensionState.ACTIVE; + return this; + } + + public ExternalTaskQuery withRetriesLeft() { + this.retriesLeft = TRUE; + return this; + } + + public ExternalTaskQuery noRetriesLeft() { + this.retriesLeft = Boolean.FALSE; + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() + || CompareUtil.areNotInAscendingOrder(priorityHigherThanOrEquals, priorityLowerThanOrEquals); + } + + public ExternalTaskQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + return this; + } + + public ExternalTaskQuery orderById() { + return orderBy(ExternalTaskQueryProperty.ID); + } + + public ExternalTaskQuery orderByLockExpirationTime() { + return orderBy(ExternalTaskQueryProperty.LOCK_EXPIRATION_TIME); + } + + public ExternalTaskQuery orderByProcessInstanceId() { + return orderBy(ExternalTaskQueryProperty.PROCESS_INSTANCE_ID); + } + + public ExternalTaskQuery orderByProcessDefinitionId() { + return orderBy(ExternalTaskQueryProperty.PROCESS_DEFINITION_ID); + } + + public ExternalTaskQuery orderByProcessDefinitionKey() { + return orderBy(ExternalTaskQueryProperty.PROCESS_DEFINITION_KEY); + } + + public ExternalTaskQuery orderByTenantId() { + return orderBy(ExternalTaskQueryProperty.TENANT_ID); + } + + @Override + public ExternalTaskQuery orderByPriority() { + return orderBy(ExternalTaskQueryProperty.PRIORITY); + } + + @Override + public ExternalTaskQuery orderByCreateTime() { + return orderBy(ExternalTaskQueryProperty.CREATE_TIME); + } + + @Override + public long executeCount(CommandContext commandContext) { + ensureVariablesInitialized(); + checkQueryOk(); + return commandContext + .getExternalTaskManager() + .findExternalTaskCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + ensureVariablesInitialized(); + checkQueryOk(); + return commandContext + .getExternalTaskManager() + .findExternalTasksByQueryCriteria(this); + } + + public List executeIdsList(CommandContext commandContext) { + ensureVariablesInitialized(); + checkQueryOk(); + return commandContext + .getExternalTaskManager() + .findExternalTaskIdsByQueryCriteria(this); + } + + @Override + public List> executeDeploymentIdMappingsList(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getExternalTaskManager() + .findDeploymentIdMappingsByQueryCriteria(this); + } + + public String getExternalTaskId() { + return externalTaskId; + } + + public String getWorkerId() { + return workerId; + } + + public Date getLockExpirationBefore() { + return lockExpirationBefore; + } + + public Date getLockExpirationAfter() { + return lockExpirationAfter; + } + + public String getTopicName() { + return topicName; + } + + public Boolean getLocked() { + return locked; + } + + public Boolean getNotLocked() { + return notLocked; + } + + public String getExecutionId() { + return executionId; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public String[] getProcessDefinitionKeys() { + return processDefinitionKeys; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getProcessDefinitionName() { + return processDefinitionName; + } + + public String getProcessDefinitionNameLike() { + return processDefinitionNameLike; + } + + public String getActivityId() { + return activityId; + } + + public SuspensionState getSuspensionState() { + return suspensionState; + } + + public Boolean getRetriesLeft() { + return retriesLeft; + } + + public Date getNow() { + return ClockUtil.getCurrentTime(); + } + + protected void ensureVariablesInitialized() { + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + VariableSerializers variableSerializers = processEngineConfiguration.getVariableSerializers(); + String dbType = processEngineConfiguration.getDatabaseType(); + for(QueryVariableValue var : variables) { + var.initialize(variableSerializers, dbType); + } + } + + public List getVariables() { + return variables; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExternalTaskQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExternalTaskQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..bf5ab84169b69a5994a13cf85ff5c4ffe0ab3ae8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExternalTaskQueryProperty.java @@ -0,0 +1,36 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * @author Thorben Lindhauer + * + */ +public interface ExternalTaskQueryProperty { + + QueryProperty ID = new QueryPropertyImpl("ID_"); + QueryProperty LOCK_EXPIRATION_TIME = new QueryPropertyImpl("LOCK_EXP_TIME_"); + QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROC_INST_ID_"); + QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("PROC_DEF_ID_"); + QueryProperty PROCESS_DEFINITION_KEY = new QueryPropertyImpl("PROC_DEF_KEY_"); + QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + QueryProperty PRIORITY = new QueryPropertyImpl("PRIORITY_"); + QueryProperty CREATE_TIME = new QueryPropertyImpl("CREATE_TIME_"); + +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExternalTaskServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExternalTaskServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..83170e091613bf4985504a0cb4ea6b4d0513a493 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ExternalTaskServiceImpl.java @@ -0,0 +1,175 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; +import org.camunda.bpm.engine.ExternalTaskService; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.externaltask.ExternalTaskQuery; +import org.camunda.bpm.engine.externaltask.ExternalTaskQueryBuilder; +import org.camunda.bpm.engine.externaltask.FetchAndLockBuilder; +import org.camunda.bpm.engine.impl.externaltask.FetchAndLockBuilderImpl; +import org.camunda.bpm.engine.externaltask.UpdateExternalTaskRetriesSelectBuilder; +import org.camunda.bpm.engine.impl.cmd.CompleteExternalTaskCmd; +import org.camunda.bpm.engine.impl.cmd.ExtendLockOnExternalTaskCmd; +import org.camunda.bpm.engine.impl.cmd.GetExternalTaskErrorDetailsCmd; +import org.camunda.bpm.engine.impl.cmd.GetTopicNamesCmd; +import org.camunda.bpm.engine.impl.cmd.HandleExternalTaskBpmnErrorCmd; +import org.camunda.bpm.engine.impl.cmd.HandleExternalTaskFailureCmd; +import org.camunda.bpm.engine.impl.cmd.LockExternalTaskCmd; +import org.camunda.bpm.engine.impl.cmd.SetExternalTaskPriorityCmd; +import org.camunda.bpm.engine.impl.cmd.SetExternalTaskRetriesCmd; +import org.camunda.bpm.engine.impl.cmd.UnlockExternalTaskCmd; +import org.camunda.bpm.engine.impl.cmd.UpdateExternalTaskRetriesBuilderImpl; +import org.camunda.bpm.engine.impl.externaltask.ExternalTaskQueryTopicBuilderImpl; + +/** + * @author Thorben Lindhauer + * @author Christopher Zell + * @author Askar Akhmerov + */ +public class ExternalTaskServiceImpl extends ServiceImpl implements ExternalTaskService { + + @Override + public ExternalTaskQueryBuilder fetchAndLock(int maxTasks, String workerId) { + return fetchAndLock(maxTasks, workerId, false); + } + + @Override + public ExternalTaskQueryBuilder fetchAndLock(int maxTasks, String workerId, boolean usePriority) { + return new ExternalTaskQueryTopicBuilderImpl(commandExecutor, workerId, maxTasks, usePriority); + } + + @Override + public FetchAndLockBuilder fetchAndLock() { + return new FetchAndLockBuilderImpl(commandExecutor); + } + + @Override + public void lock(String externalTaskId, String workerId, long lockDuration) { + commandExecutor.execute(new LockExternalTaskCmd(externalTaskId, workerId, lockDuration)); + } + + @Override + public void complete(String externalTaskId, String workerId) { + complete(externalTaskId, workerId, null, null); + } + + @Override + public void complete(String externalTaskId, String workerId, Map variables) { + complete(externalTaskId, workerId, variables, null); + } + + @Override + public void complete(String externalTaskId, String workerId, Map variables, Map localVariables) { + commandExecutor.execute(new CompleteExternalTaskCmd(externalTaskId, workerId, variables, localVariables)); + } + + @Override + public void handleFailure(String externalTaskId, String workerId, String errorMessage, int retries, long retryDuration) { + this.handleFailure(externalTaskId,workerId,errorMessage,null,retries,retryDuration); + } + + @Override + public void handleFailure(String externalTaskId, String workerId, String errorMessage, String errorDetails, int retries, long retryDuration) { + this.handleFailure(externalTaskId, workerId, errorMessage, errorDetails, retries, retryDuration, null, null); + } + + @Override + public void handleFailure(String externalTaskId, String workerId, String errorMessage, String errorDetails, int retries, long retryDuration, Map variables, Map localVariables) { + commandExecutor.execute(new HandleExternalTaskFailureCmd(externalTaskId, workerId, errorMessage, errorDetails, retries, retryDuration, variables, localVariables)); + } + + @Override + public void handleBpmnError(String externalTaskId, String workerId, String errorCode) { + handleBpmnError(externalTaskId, workerId, errorCode, null, null); + } + + @Override + public void handleBpmnError(String externalTaskId, String workerId, String errorCode, String errorMessage) { + handleBpmnError(externalTaskId, workerId, errorCode, errorMessage, null); + } + + @Override + public void handleBpmnError(String externalTaskId, String workerId, String errorCode, String errorMessage, Map variables) { + commandExecutor.execute(new HandleExternalTaskBpmnErrorCmd(externalTaskId, workerId, errorCode, errorMessage, variables)); + } + + @Override + public void unlock(String externalTaskId) { + commandExecutor.execute(new UnlockExternalTaskCmd(externalTaskId)); + } + + public void setRetries(String externalTaskId, int retries, boolean writeUserOperationLog) { + commandExecutor.execute(new SetExternalTaskRetriesCmd(externalTaskId, retries, writeUserOperationLog)); + } + + @Override + public void setPriority(String externalTaskId, long priority) { + commandExecutor.execute(new SetExternalTaskPriorityCmd(externalTaskId, priority)); + } + + public ExternalTaskQuery createExternalTaskQuery() { + return new ExternalTaskQueryImpl(commandExecutor); + } + + @Override + public List getTopicNames() { + return commandExecutor.execute(new GetTopicNamesCmd(false,false,false)); + } + + @Override + public List getTopicNames(boolean withLockedTasks, boolean withUnlockedTasks, boolean withRetriesLeft) { + return commandExecutor.execute(new GetTopicNamesCmd(withLockedTasks, withUnlockedTasks, withRetriesLeft)); + } + + public String getExternalTaskErrorDetails(String externalTaskId) { + return commandExecutor.execute(new GetExternalTaskErrorDetailsCmd(externalTaskId)); + } + + @Override + public void setRetries(String externalTaskId, int retries) { + setRetries(externalTaskId, retries, true); + } + + @Override + public void setRetries(List externalTaskIds, int retries) { + updateRetries() + .externalTaskIds(externalTaskIds) + .set(retries); + } + + @Override + public Batch setRetriesAsync(List externalTaskIds, ExternalTaskQuery externalTaskQuery, int retries) { + return updateRetries() + .externalTaskIds(externalTaskIds) + .externalTaskQuery(externalTaskQuery) + .setAsync(retries); + } + + @Override + public UpdateExternalTaskRetriesSelectBuilder updateRetries() { + return new UpdateExternalTaskRetriesBuilderImpl(commandExecutor); + } + + @Override + public void extendLock(String externalTaskId, String workerId, long lockDuration) { + commandExecutor.execute(new ExtendLockOnExternalTaskCmd(externalTaskId, workerId, lockDuration)); + } + +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/FilterServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/FilterServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..3ee88826c0f3abdff9e7868fb7309b8e1d06de5d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/FilterServiceImpl.java @@ -0,0 +1,108 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; + +import org.camunda.bpm.engine.EntityTypes; +import org.camunda.bpm.engine.FilterService; +import org.camunda.bpm.engine.filter.Filter; +import org.camunda.bpm.engine.filter.FilterQuery; +import org.camunda.bpm.engine.impl.cmd.CreateFilterCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteFilterCmd; +import org.camunda.bpm.engine.impl.cmd.ExecuteFilterCountCmd; +import org.camunda.bpm.engine.impl.cmd.ExecuteFilterListCmd; +import org.camunda.bpm.engine.impl.cmd.ExecuteFilterListPageCmd; +import org.camunda.bpm.engine.impl.cmd.ExecuteFilterSingleResultCmd; +import org.camunda.bpm.engine.impl.cmd.GetFilterCmd; +import org.camunda.bpm.engine.impl.cmd.SaveFilterCmd; +import org.camunda.bpm.engine.impl.filter.FilterQueryImpl; +import org.camunda.bpm.engine.query.Query; + + +/** + * @author Sebastian Menski + */ +public class FilterServiceImpl extends ServiceImpl implements FilterService { + + public Filter newTaskFilter() { + return commandExecutor.execute(new CreateFilterCmd(EntityTypes.TASK)); + } + + public Filter newTaskFilter(String filterName) { + return newTaskFilter().setName(filterName); + } + + public FilterQuery createFilterQuery() { + return new FilterQueryImpl(commandExecutor); + } + + public FilterQuery createTaskFilterQuery() { + return new FilterQueryImpl(commandExecutor).filterResourceType(EntityTypes.TASK); + } + + public Filter saveFilter(Filter filter) { + return commandExecutor.execute(new SaveFilterCmd(filter)); + } + + public Filter getFilter(String filterId) { + return commandExecutor.execute(new GetFilterCmd(filterId)); + } + + public void deleteFilter(String filterId) { + commandExecutor.execute(new DeleteFilterCmd(filterId)); + } + + @SuppressWarnings("unchecked") + public List list(String filterId) { + return (List) commandExecutor.execute(new ExecuteFilterListCmd(filterId)); + } + + @SuppressWarnings("unchecked") + public > List list(String filterId, Q extendingQuery) { + return (List) commandExecutor.execute(new ExecuteFilterListCmd(filterId, extendingQuery)); + } + + @SuppressWarnings("unchecked") + public List listPage(String filterId, int firstResult, int maxResults) { + return (List) commandExecutor.execute(new ExecuteFilterListPageCmd(filterId, firstResult, maxResults)); + } + + @SuppressWarnings("unchecked") + public > List listPage(String filterId, Q extendingQuery, int firstResult, int maxResults) { + return (List) commandExecutor.execute(new ExecuteFilterListPageCmd(filterId, extendingQuery, firstResult, maxResults)); + } + + @SuppressWarnings("unchecked") + public T singleResult(String filterId) { + return (T) commandExecutor.execute(new ExecuteFilterSingleResultCmd(filterId)); + } + + @SuppressWarnings("unchecked") + public > T singleResult(String filterId, Q extendingQuery) { + return (T) commandExecutor.execute(new ExecuteFilterSingleResultCmd(filterId, extendingQuery)); + } + + public Long count(String filterId) { + return commandExecutor.execute(new ExecuteFilterCountCmd(filterId)); + } + + public Long count(String filterId, Query extendingQuery) { + return commandExecutor.execute(new ExecuteFilterCountCmd(filterId, extendingQuery)); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/FormServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/FormServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..bda8cab05cd94ac7b2b6370c61e3a41de67517ee --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/FormServiceImpl.java @@ -0,0 +1,130 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.io.InputStream; +import java.util.Collection; +import java.util.Map; + +import org.camunda.bpm.engine.FormService; +import org.camunda.bpm.engine.form.StartFormData; +import org.camunda.bpm.engine.form.TaskFormData; +import org.camunda.bpm.engine.impl.cmd.GetDeployedStartFormCmd; +import org.camunda.bpm.engine.impl.cmd.GetFormKeyCmd; +import org.camunda.bpm.engine.impl.cmd.GetRenderedStartFormCmd; +import org.camunda.bpm.engine.impl.cmd.GetRenderedTaskFormCmd; +import org.camunda.bpm.engine.impl.cmd.GetStartFormCmd; +import org.camunda.bpm.engine.impl.cmd.GetStartFormVariablesCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskFormCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskFormVariablesCmd; +import org.camunda.bpm.engine.impl.cmd.SubmitStartFormCmd; +import org.camunda.bpm.engine.impl.cmd.SubmitTaskFormCmd; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.variable.VariableMap; + + +/** + * @author Tom Baeyens + * @author Falko Menge (camunda) + */ +public class FormServiceImpl extends ServiceImpl implements FormService { + + public Object getRenderedStartForm(String processDefinitionId) { + return commandExecutor.execute(new GetRenderedStartFormCmd(processDefinitionId, null)); + } + + public Object getRenderedStartForm(String processDefinitionId, String engineName) { + return commandExecutor.execute(new GetRenderedStartFormCmd(processDefinitionId, engineName)); + } + + public Object getRenderedTaskForm(String taskId) { + return commandExecutor.execute(new GetRenderedTaskFormCmd(taskId, null)); + } + + public Object getRenderedTaskForm(String taskId, String engineName) { + return commandExecutor.execute(new GetRenderedTaskFormCmd(taskId, engineName)); + } + + public StartFormData getStartFormData(String processDefinitionId) { + return commandExecutor.execute(new GetStartFormCmd(processDefinitionId)); + } + + public TaskFormData getTaskFormData(String taskId) { + return commandExecutor.execute(new GetTaskFormCmd(taskId)); + } + + public ProcessInstance submitStartFormData(String processDefinitionId, Map properties) { + return commandExecutor.execute(new SubmitStartFormCmd(processDefinitionId, null, (Map) properties)); + } + + public ProcessInstance submitStartFormData(String processDefinitionId, String businessKey, Map properties) { + return commandExecutor.execute(new SubmitStartFormCmd(processDefinitionId, businessKey, (Map) properties)); + } + + public ProcessInstance submitStartForm(String processDefinitionId, Map properties) { + return commandExecutor.execute(new SubmitStartFormCmd(processDefinitionId, null, properties)); + } + + public ProcessInstance submitStartForm(String processDefinitionId, String businessKey, Map properties) { + return commandExecutor.execute(new SubmitStartFormCmd(processDefinitionId, businessKey, properties)); + } + + public void submitTaskFormData(String taskId, Map properties) { + submitTaskForm(taskId, (Map) properties); + } + + public void submitTaskForm(String taskId, Map properties) { + commandExecutor.execute(new SubmitTaskFormCmd(taskId, properties, false, false)); + } + + public VariableMap submitTaskFormWithVariablesInReturn(String taskId, Map properties, boolean deserializeValues) { + return commandExecutor.execute(new SubmitTaskFormCmd(taskId, properties, true, deserializeValues)); + } + + public String getStartFormKey(String processDefinitionId) { + return commandExecutor.execute(new GetFormKeyCmd(processDefinitionId)); + } + + public String getTaskFormKey(String processDefinitionId, String taskDefinitionKey) { + return commandExecutor.execute(new GetFormKeyCmd(processDefinitionId, taskDefinitionKey)); + } + + public VariableMap getStartFormVariables(String processDefinitionId) { + return getStartFormVariables(processDefinitionId, null, true); + } + + public VariableMap getStartFormVariables(String processDefinitionId, Collection formVariables, boolean deserializeObjectValues) { + return commandExecutor.execute(new GetStartFormVariablesCmd(processDefinitionId, formVariables, deserializeObjectValues)); + } + + public VariableMap getTaskFormVariables(String taskId) { + return getTaskFormVariables(taskId, null, true); + } + + public VariableMap getTaskFormVariables(String taskId, Collection formVariables, boolean deserializeObjectValues) { + return commandExecutor.execute(new GetTaskFormVariablesCmd(taskId, formVariables, deserializeObjectValues)); + } + + public InputStream getDeployedStartForm(String processDefinitionId) { + return commandExecutor.execute(new GetDeployedStartFormCmd(processDefinitionId)); + } + + public InputStream getDeployedTaskForm(String taskId) { + return commandExecutor.execute(new GetDeployedTaskFormCmd(taskId)); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/GetDeployedTaskFormCmd.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/GetDeployedTaskFormCmd.java new file mode 100644 index 0000000000000000000000000000000000000000..95134155195a9cb127c47a14b44caba0f8231f8f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/GetDeployedTaskFormCmd.java @@ -0,0 +1,54 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.form.FormData; +import org.camunda.bpm.engine.impl.cfg.CommandChecker; +import org.camunda.bpm.engine.impl.cmd.AbstractGetDeployedFormCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskFormCmd; +import org.camunda.bpm.engine.impl.persistence.entity.TaskEntity; +import org.camunda.bpm.engine.impl.util.EnsureUtil; + +/** + * + * @author Anna Pazola + * + */ +public class GetDeployedTaskFormCmd extends AbstractGetDeployedFormCmd { + + protected String taskId; + + public GetDeployedTaskFormCmd(String taskId) { + EnsureUtil.ensureNotNull(BadUserRequestException.class, "Task id cannot be null", "taskId", taskId); + this.taskId = taskId; + } + + @Override + protected FormData getFormData() { + return commandContext.runWithoutAuthorization(new GetTaskFormCmd(taskId)); + } + + @Override + protected void checkAuthorization() { + TaskEntity taskEntity = commandContext.getTaskManager().findTaskById(taskId); + for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { + checker.checkReadTask(taskEntity); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/GroupQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/GroupQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..5c9948e0997e165f05d966654c14934a8a41e761 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/GroupQueryImpl.java @@ -0,0 +1,133 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import org.camunda.bpm.engine.identity.Group; +import org.camunda.bpm.engine.identity.GroupQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + + +/** + * @author Joram Barrez + */ +public abstract class GroupQueryImpl extends AbstractQuery implements GroupQuery { + + private static final long serialVersionUID = 1L; + protected String id; + protected String[] ids; + protected String name; + protected String nameLike; + protected String type; + protected String userId; + protected String procDefId; + protected String tenantId; + + public GroupQueryImpl() { + } + + public GroupQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public GroupQuery groupId(String id) { + ensureNotNull("Provided id", id); + this.id = id; + return this; + } + + public GroupQuery groupIdIn(String... ids) { + ensureNotNull("Provided ids", (Object[]) ids); + this.ids = ids; + return this; + } + + public GroupQuery groupName(String name) { + ensureNotNull("Provided name", name); + this.name = name; + return this; + } + + public GroupQuery groupNameLike(String nameLike) { + ensureNotNull("Provided nameLike", nameLike); + this.nameLike = nameLike; + return this; + } + + public GroupQuery groupType(String type) { + ensureNotNull("Provided type", type); + this.type = type; + return this; + } + + public GroupQuery groupMember(String userId) { + ensureNotNull("Provided userId", userId); + this.userId = userId; + return this; + } + + public GroupQuery potentialStarter(String procDefId) { + ensureNotNull("Provided processDefinitionId", procDefId); + this.procDefId = procDefId; + return this; + } + + public GroupQuery memberOfTenant(String tenantId) { + ensureNotNull("Provided tenantId", tenantId); + this.tenantId = tenantId; + return this; + } + + //sorting //////////////////////////////////////////////////////// + + public GroupQuery orderByGroupId() { + return orderBy(GroupQueryProperty.GROUP_ID); + } + + public GroupQuery orderByGroupName() { + return orderBy(GroupQueryProperty.NAME); + } + + public GroupQuery orderByGroupType() { + return orderBy(GroupQueryProperty.TYPE); + } + + //getters //////////////////////////////////////////////////////// + + public String getId() { + return id; + } + public String getName() { + return name; + } + public String getNameLike() { + return nameLike; + } + public String getType() { + return type; + } + public String getUserId() { + return userId; + } + public String getTenantId() { + return tenantId; + } + public String[] getIds() { + return ids; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/GroupQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/GroupQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..9cf8095f6b5bea58f9a31b8746a8769090e8ee50 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/GroupQueryProperty.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.identity.GroupQuery; +import org.camunda.bpm.engine.query.QueryProperty; + + + +/** + * Contains the possible properties that can be used by the {@link GroupQuery}. + * + * @author Joram Barrez + */ +public interface GroupQueryProperty { + + public static final QueryProperty GROUP_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty NAME = new QueryPropertyImpl("NAME_"); + public static final QueryProperty TYPE = new QueryPropertyImpl("TYPE_"); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e392f941848480e77bebe4d7581fdd1ce1577532 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityInstanceQueryImpl.java @@ -0,0 +1,305 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.history.HistoricActivityInstance; +import org.camunda.bpm.engine.history.HistoricActivityInstanceQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState; +import org.camunda.bpm.engine.impl.util.CompareUtil; + +/** + * @author Tom Baeyens + */ +public class HistoricActivityInstanceQueryImpl extends AbstractQuery + implements HistoricActivityInstanceQuery { + + private static final long serialVersionUID = 1L; + protected String activityInstanceId; + protected String processInstanceId; + protected String executionId; + protected String processDefinitionId; + protected String activityId; + protected String activityName; + protected String activityNameLike; + protected String activityType; + protected String assignee; + protected boolean finished; + protected boolean unfinished; + protected Date startedBefore; + protected Date startedAfter; + protected Date finishedBefore; + protected Date finishedAfter; + protected ActivityInstanceState activityInstanceState; + protected String[] tenantIds; + protected boolean isTenantIdSet; + + public HistoricActivityInstanceQueryImpl() { + } + + public HistoricActivityInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricActivityInstanceManager() + .findHistoricActivityInstanceCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getHistoricActivityInstanceManager() + .findHistoricActivityInstancesByQueryCriteria(this, page); + } + + public HistoricActivityInstanceQueryImpl processInstanceId(String processInstanceId) { + this.processInstanceId = processInstanceId; + return this; + } + + public HistoricActivityInstanceQueryImpl executionId(String executionId) { + this.executionId = executionId; + return this; + } + + public HistoricActivityInstanceQueryImpl processDefinitionId(String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + return this; + } + + public HistoricActivityInstanceQueryImpl activityId(String activityId) { + this.activityId = activityId; + return this; + } + + public HistoricActivityInstanceQueryImpl activityName(String activityName) { + this.activityName = activityName; + return this; + } + + public HistoricActivityInstanceQueryImpl activityNameLike(String activityNameLike) { + this.activityNameLike = activityNameLike; + return this; + } + + public HistoricActivityInstanceQueryImpl activityType(String activityType) { + this.activityType = activityType; + return this; + } + + public HistoricActivityInstanceQueryImpl taskAssignee(String assignee) { + this.assignee = assignee; + return this; + } + + public HistoricActivityInstanceQueryImpl finished() { + this.finished = true; + return this; + } + + public HistoricActivityInstanceQueryImpl unfinished() { + this.unfinished = true; + return this; + } + + public HistoricActivityInstanceQueryImpl completeScope() { + if (activityInstanceState != null) { + throw new ProcessEngineException("Already querying for activity instance state <" + activityInstanceState + ">"); + } + + this.activityInstanceState = ActivityInstanceState.SCOPE_COMPLETE; + return this; + } + + public HistoricActivityInstanceQueryImpl canceled() { + if (activityInstanceState != null) { + throw new ProcessEngineException("Already querying for activity instance state <" + activityInstanceState + ">"); + } + this.activityInstanceState = ActivityInstanceState.CANCELED; + return this; + } + + public HistoricActivityInstanceQueryImpl startedAfter(Date date) { + startedAfter = date; + return this; + } + + public HistoricActivityInstanceQueryImpl startedBefore(Date date) { + startedBefore = date; + return this; + } + + public HistoricActivityInstanceQueryImpl finishedAfter(Date date) { + finishedAfter = date; + return this; + } + + public HistoricActivityInstanceQueryImpl finishedBefore(Date date) { + finishedBefore = date; + return this; + } + + public HistoricActivityInstanceQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricActivityInstanceQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() + || CompareUtil.areNotInAscendingOrder(startedAfter, startedBefore) + || CompareUtil.areNotInAscendingOrder(finishedAfter, finishedBefore); + } + + // ordering ///////////////////////////////////////////////////////////////// + + public HistoricActivityInstanceQueryImpl orderByHistoricActivityInstanceDuration() { + orderBy(HistoricActivityInstanceQueryProperty.DURATION); + return this; + } + + public HistoricActivityInstanceQueryImpl orderByHistoricActivityInstanceEndTime() { + orderBy(HistoricActivityInstanceQueryProperty.END); + return this; + } + + public HistoricActivityInstanceQueryImpl orderByExecutionId() { + orderBy(HistoricActivityInstanceQueryProperty.EXECUTION_ID); + return this; + } + + public HistoricActivityInstanceQueryImpl orderByHistoricActivityInstanceId() { + orderBy(HistoricActivityInstanceQueryProperty.HISTORIC_ACTIVITY_INSTANCE_ID); + return this; + } + + public HistoricActivityInstanceQueryImpl orderByProcessDefinitionId() { + orderBy(HistoricActivityInstanceQueryProperty.PROCESS_DEFINITION_ID); + return this; + } + + public HistoricActivityInstanceQueryImpl orderByProcessInstanceId() { + orderBy(HistoricActivityInstanceQueryProperty.PROCESS_INSTANCE_ID); + return this; + } + + public HistoricActivityInstanceQueryImpl orderByHistoricActivityInstanceStartTime() { + orderBy(HistoricActivityInstanceQueryProperty.START); + return this; + } + + public HistoricActivityInstanceQuery orderByActivityId() { + orderBy(HistoricActivityInstanceQueryProperty.ACTIVITY_ID); + return this; + } + + public HistoricActivityInstanceQueryImpl orderByActivityName() { + orderBy(HistoricActivityInstanceQueryProperty.ACTIVITY_NAME); + return this; + } + + public HistoricActivityInstanceQueryImpl orderByActivityType() { + orderBy(HistoricActivityInstanceQueryProperty.ACTIVITY_TYPE); + return this; + } + + public HistoricActivityInstanceQuery orderPartiallyByOccurrence() { + orderBy(HistoricActivityInstanceQueryProperty.SEQUENCE_COUNTER); + return this; + } + + public HistoricActivityInstanceQuery orderByTenantId() { + return orderBy(HistoricActivityInstanceQueryProperty.TENANT_ID); + } + + public HistoricActivityInstanceQueryImpl activityInstanceId(String activityInstanceId) { + this.activityInstanceId = activityInstanceId; + return this; + } + + // getters and setters ////////////////////////////////////////////////////// + + public String getProcessInstanceId() { + return processInstanceId; + } + public String getExecutionId() { + return executionId; + } + public String getProcessDefinitionId() { + return processDefinitionId; + } + public String getActivityId() { + return activityId; + } + public String getActivityName() { + return activityName; + } + public String getActivityType() { + return activityType; + } + public String getAssignee() { + return assignee; + } + public boolean isFinished() { + return finished; + } + public boolean isUnfinished() { + return unfinished; + } + public String getActivityInstanceId() { + return activityInstanceId; + } + public Date getStartedAfter() { + return startedAfter; + } + public Date getStartedBefore() { + return startedBefore; + } + public Date getFinishedAfter() { + return finishedAfter; + } + public Date getFinishedBefore() { + return finishedBefore; + } + public ActivityInstanceState getActivityInstanceState() { + return activityInstanceState; + } + public boolean isTenantIdSet() { + return isTenantIdSet; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityInstanceQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityInstanceQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..a881c509360c33681add81c58fc7dc203aa0131c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityInstanceQueryProperty.java @@ -0,0 +1,42 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.history.HistoricActivityInstanceQuery; +import org.camunda.bpm.engine.query.QueryProperty; + + +/** + * Contains the possible properties which can be used in a {@link HistoricActivityInstanceQuery}. + * + * @author Tom Baeyens + */ +public interface HistoricActivityInstanceQueryProperty { + + public static final QueryProperty HISTORIC_ACTIVITY_INSTANCE_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROC_INST_ID_"); + public static final QueryProperty EXECUTION_ID = new QueryPropertyImpl("EXECUTION_ID_"); + public static final QueryProperty ACTIVITY_ID = new QueryPropertyImpl("ACT_ID_"); + public static final QueryProperty ACTIVITY_NAME = new QueryPropertyImpl("ACT_NAME_"); + public static final QueryProperty ACTIVITY_TYPE = new QueryPropertyImpl("ACT_TYPE_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("PROC_DEF_ID_"); + public static final QueryProperty START = new QueryPropertyImpl("START_TIME_"); + public static final QueryProperty END = new QueryPropertyImpl("END_TIME_"); + public static final QueryProperty DURATION = new QueryPropertyImpl("DURATION_"); + public static final QueryProperty SEQUENCE_COUNTER = new QueryPropertyImpl("SEQUENCE_COUNTER_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityStatisticsQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityStatisticsQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..c5a069c91ffe11c84a5bbeac9a1fc97a8438245a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityStatisticsQueryImpl.java @@ -0,0 +1,157 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.Date; +import java.util.List; +import org.camunda.bpm.engine.history.HistoricActivityStatistics; +import org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +/** + * + * @author Roman Smirnov + * + */ +public class HistoricActivityStatisticsQueryImpl extends AbstractQuery implements HistoricActivityStatisticsQuery { + + private static final long serialVersionUID = 1L; + + protected String processDefinitionId; + + protected boolean includeFinished; + protected boolean includeCanceled; + protected boolean includeCompleteScope; + protected boolean includeIncidents; + + protected Date startedBefore; + protected Date startedAfter; + protected Date finishedBefore; + protected Date finishedAfter; + + protected String[] processInstanceIds; + + public HistoricActivityStatisticsQueryImpl(String processDefinitionId, CommandExecutor commandExecutor) { + super(commandExecutor); + this.processDefinitionId = processDefinitionId; + } + + public HistoricActivityStatisticsQuery includeFinished() { + includeFinished = true; + return this; + } + + public HistoricActivityStatisticsQuery includeCanceled() { + includeCanceled = true; + return this; + } + + public HistoricActivityStatisticsQuery includeCompleteScope() { + includeCompleteScope = true; + return this; + } + + public HistoricActivityStatisticsQuery includeIncidents() { + includeIncidents = true; + return this; + } + + @Override + public HistoricActivityStatisticsQuery startedAfter(Date date) { + startedAfter = date; + return this; + } + + @Override + public HistoricActivityStatisticsQuery startedBefore(Date date) { + startedBefore = date; + return this; + } + + @Override + public HistoricActivityStatisticsQuery finishedAfter(Date date) { + finishedAfter = date; + return this; + } + + @Override + public HistoricActivityStatisticsQuery finishedBefore(Date date) { + finishedBefore = date; + return this; + } + + @Override + public HistoricActivityStatisticsQuery processInstanceIdIn(String... processInstanceIds) { + ensureNotNull("processInstanceIds", (Object[]) processInstanceIds); + this.processInstanceIds = processInstanceIds; + return this; + } + + public HistoricActivityStatisticsQuery orderByActivityId() { + return orderBy(HistoricActivityStatisticsQueryProperty.ACTIVITY_ID_); + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return + commandContext + .getHistoricStatisticsManager() + .getHistoricStatisticsCountGroupedByActivity(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return + commandContext + .getHistoricStatisticsManager() + .getHistoricStatisticsGroupedByActivity(this, page); + } + + protected void checkQueryOk() { + super.checkQueryOk(); + ensureNotNull("No valid process definition id supplied", "processDefinitionId", processDefinitionId); + } + + // getters ///////////////////////////////////////////////// + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public boolean isIncludeFinished() { + return includeFinished; + } + + public boolean isIncludeCanceled() { + return includeCanceled; + } + + public boolean isIncludeCompleteScope() { + return includeCompleteScope; + } + + public String[] getProcessInstanceIds() { + return processInstanceIds; + } + + public boolean isIncludeIncidents() { + return includeIncidents; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityStatisticsQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityStatisticsQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..5a8f9a3cb8d0a7155902f932723c868b3b384dd3 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricActivityStatisticsQueryProperty.java @@ -0,0 +1,30 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * + * @author Roman Smirnov + * + */ +public interface HistoricActivityStatisticsQueryProperty { + + public static final QueryProperty ACTIVITY_ID_ = new QueryPropertyImpl("ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricBatchQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricBatchQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..256d73ecf5c2b418fbdf158c8aa9665fb143d3d2 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricBatchQueryProperty.java @@ -0,0 +1,33 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.batch.history.HistoricBatchQuery; +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * Contains the possible properties that can be used in a {@link HistoricBatchQuery}. + * + */ +public interface HistoricBatchQueryProperty { + + QueryProperty ID = new QueryPropertyImpl("ID_"); + QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + QueryProperty START_TIME = new QueryPropertyImpl("START_TIME_"); + QueryProperty END_TIME = new QueryPropertyImpl("END_TIME_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseActivityInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseActivityInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..457e012ee171015aaebc9a50506621bc5e99d4c4 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseActivityInstanceQueryImpl.java @@ -0,0 +1,350 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState.ACTIVE; +import static org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState.AVAILABLE; +import static org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState.COMPLETED; +import static org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState.DISABLED; +import static org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState.ENABLED; +import static org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState.SUSPENDED; +import static org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState.TERMINATED; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNull; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.HistoricCaseActivityInstance; +import org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.CompareUtil; + +/** + * @author Sebastian Menski + */ +public class HistoricCaseActivityInstanceQueryImpl extends AbstractQuery implements HistoricCaseActivityInstanceQuery { + + private static final long serialVersionUID = 1L; + + protected String[] caseActivityInstanceIds; + protected String[] caseActivityIds; + + protected String caseInstanceId; + protected String caseDefinitionId; + protected String caseActivityName; + protected String caseActivityType; + protected Date createdBefore; + protected Date createdAfter; + protected Date endedBefore; + protected Date endedAfter; + protected Boolean ended; + protected Integer caseActivityInstanceState; + protected Boolean required; + protected String[] tenantIds; + protected boolean isTenantIdSet; + + public HistoricCaseActivityInstanceQueryImpl() { + } + + public HistoricCaseActivityInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricCaseActivityInstanceManager() + .findHistoricCaseActivityInstanceCountByQueryCriteria(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getHistoricCaseActivityInstanceManager() + .findHistoricCaseActivityInstancesByQueryCriteria(this, page); + } + + public HistoricCaseActivityInstanceQuery caseActivityInstanceId(String caseActivityInstanceId) { + ensureNotNull(NotValidException.class, "caseActivityInstanceId", caseActivityInstanceId); + return caseActivityInstanceIdIn(caseActivityInstanceId); + } + + public HistoricCaseActivityInstanceQuery caseActivityInstanceIdIn(String... caseActivityInstanceIds) { + ensureNotNull(NotValidException.class, "caseActivityInstanceIds", (Object[]) caseActivityInstanceIds); + this.caseActivityInstanceIds = caseActivityInstanceIds; + return this; + } + + public HistoricCaseActivityInstanceQuery caseInstanceId(String caseInstanceId) { + ensureNotNull(NotValidException.class, "caseInstanceId", caseInstanceId); + this.caseInstanceId = caseInstanceId; + return this; + } + + public HistoricCaseActivityInstanceQuery caseDefinitionId(String caseDefinitionId) { + ensureNotNull(NotValidException.class, "caseDefinitionId", caseDefinitionId); + this.caseDefinitionId = caseDefinitionId; + return this; + } + + public HistoricCaseActivityInstanceQuery caseExecutionId(String caseExecutionId) { + ensureNotNull(NotValidException.class, "caseExecutionId", caseExecutionId); + return caseActivityInstanceIdIn(caseExecutionId); + } + + public HistoricCaseActivityInstanceQuery caseActivityId(String caseActivityId) { + ensureNotNull(NotValidException.class, "caseActivityId", caseActivityId); + return caseActivityIdIn(caseActivityId); + } + + public HistoricCaseActivityInstanceQuery caseActivityIdIn(String... caseActivityIds) { + ensureNotNull(NotValidException.class, "caseActivityIds", (Object[]) caseActivityIds); + this.caseActivityIds = caseActivityIds; + return this; + } + + public HistoricCaseActivityInstanceQuery caseActivityName(String caseActivityName) { + ensureNotNull(NotValidException.class, "caseActivityName", caseActivityName); + this.caseActivityName = caseActivityName; + return this; + } + + public HistoricCaseActivityInstanceQuery caseActivityType(String caseActivityType) { + ensureNotNull(NotValidException.class, "caseActivityType", caseActivityType); + this.caseActivityType = caseActivityType; + return this; + } + + public HistoricCaseActivityInstanceQuery createdBefore(Date date) { + ensureNotNull(NotValidException.class, "createdBefore", date); + this.createdBefore = date; + return this; + } + + public HistoricCaseActivityInstanceQuery createdAfter(Date date) { + ensureNotNull(NotValidException.class, "createdAfter", date); + this.createdAfter = date; + return this; + } + + public HistoricCaseActivityInstanceQuery endedBefore(Date date) { + ensureNotNull(NotValidException.class, "finishedBefore", date); + this.endedBefore = date; + return this; + } + + public HistoricCaseActivityInstanceQuery endedAfter(Date date) { + ensureNotNull(NotValidException.class, "finishedAfter", date); + this.endedAfter = date; + return this; + } + + public HistoricCaseActivityInstanceQuery required() { + this.required = true; + return this; + } + + public HistoricCaseActivityInstanceQuery ended() { + this.ended = true; + return this; + } + + public HistoricCaseActivityInstanceQuery notEnded() { + this.ended = false; + return this; + } + + public HistoricCaseActivityInstanceQuery available() { + ensureNull(NotValidException.class, "Already querying for case activity instance state '" + caseActivityInstanceState + "'", "caseActivityState", caseActivityInstanceState); + this.caseActivityInstanceState = AVAILABLE.getStateCode(); + return this; + } + + public HistoricCaseActivityInstanceQuery enabled() { + ensureNull(NotValidException.class, "Already querying for case activity instance state '" + caseActivityInstanceState + "'", "caseActivityState", caseActivityInstanceState); + this.caseActivityInstanceState = ENABLED.getStateCode(); + return this; + } + + public HistoricCaseActivityInstanceQuery disabled() { + ensureNull(NotValidException.class, "Already querying for case activity instance state '" + caseActivityInstanceState + "'", "caseActivityState", caseActivityInstanceState); + this.caseActivityInstanceState = DISABLED.getStateCode(); + return this; + } + + public HistoricCaseActivityInstanceQuery active() { + ensureNull(NotValidException.class, "Already querying for case activity instance state '" + caseActivityInstanceState + "'", "caseActivityState", caseActivityInstanceState); + this.caseActivityInstanceState = ACTIVE.getStateCode(); + return this; + } + + public HistoricCaseActivityInstanceQuery suspended() { + ensureNull(NotValidException.class, "Already querying for case activity instance state '" + caseActivityInstanceState + "'", "caseActivityState", caseActivityInstanceState); + this.caseActivityInstanceState = SUSPENDED.getStateCode(); + return this; + } + + public HistoricCaseActivityInstanceQuery completed() { + ensureNull(NotValidException.class, "Already querying for case activity instance state '" + caseActivityInstanceState + "'", "caseActivityState", caseActivityInstanceState); + this.caseActivityInstanceState = COMPLETED.getStateCode(); + return this; + } + + public HistoricCaseActivityInstanceQuery terminated() { + ensureNull(NotValidException.class, "Already querying for case activity instance state '" + caseActivityInstanceState + "'", "caseActivityState", caseActivityInstanceState); + this.caseActivityInstanceState = TERMINATED.getStateCode(); + return this; + } + + public HistoricCaseActivityInstanceQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricCaseActivityInstanceQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() + || CompareUtil.areNotInAscendingOrder(createdAfter, createdBefore) + || CompareUtil.areNotInAscendingOrder(endedAfter, endedBefore); + } + + // ordering + + public HistoricCaseActivityInstanceQuery orderByHistoricCaseActivityInstanceId() { + orderBy(HistoricCaseActivityInstanceQueryProperty.HISTORIC_CASE_ACTIVITY_INSTANCE_ID); + return this; + } + + public HistoricCaseActivityInstanceQuery orderByCaseInstanceId() { + orderBy(HistoricCaseActivityInstanceQueryProperty.CASE_INSTANCE_ID); + return this; + } + + public HistoricCaseActivityInstanceQuery orderByCaseExecutionId() { + orderBy(HistoricCaseActivityInstanceQueryProperty.HISTORIC_CASE_ACTIVITY_INSTANCE_ID); + return this; + } + + public HistoricCaseActivityInstanceQuery orderByCaseActivityId() { + orderBy(HistoricCaseActivityInstanceQueryProperty.CASE_ACTIVITY_ID); + return this; + } + + public HistoricCaseActivityInstanceQuery orderByCaseActivityName() { + orderBy(HistoricCaseActivityInstanceQueryProperty.CASE_ACTIVITY_NAME); + return this; + } + + public HistoricCaseActivityInstanceQuery orderByCaseActivityType() { + orderBy(HistoricCaseActivityInstanceQueryProperty.CASE_ACTIVITY_TYPE); + return this; + } + + public HistoricCaseActivityInstanceQuery orderByHistoricCaseActivityInstanceCreateTime() { + orderBy(HistoricCaseActivityInstanceQueryProperty.CREATE); + return this; + } + + public HistoricCaseActivityInstanceQuery orderByHistoricCaseActivityInstanceEndTime() { + orderBy(HistoricCaseActivityInstanceQueryProperty.END); + return this; + } + + public HistoricCaseActivityInstanceQuery orderByHistoricCaseActivityInstanceDuration() { + orderBy(HistoricCaseActivityInstanceQueryProperty.DURATION); + return this; + } + + public HistoricCaseActivityInstanceQuery orderByCaseDefinitionId() { + orderBy(HistoricCaseActivityInstanceQueryProperty.CASE_DEFINITION_ID); + return this; + } + + public HistoricCaseActivityInstanceQuery orderByTenantId() { + return orderBy(HistoricCaseActivityInstanceQueryProperty.TENANT_ID); + } + + // getter + + public String[] getCaseActivityInstanceIds() { + return caseActivityInstanceIds; + } + + public String getCaseInstanceId() { + return caseInstanceId; + } + + public String getCaseDefinitionId() { + return caseDefinitionId; + } + + public String[] getCaseActivityIds() { + return caseActivityIds; + } + + public String getCaseActivityName() { + return caseActivityName; + } + + public String getCaseActivityType() { + return caseActivityType; + } + + public Date getCreatedBefore() { + return createdBefore; + } + + public Date getCreatedAfter() { + return createdAfter; + } + + public Date getEndedBefore() { + return endedBefore; + } + + public Date getEndedAfter() { + return endedAfter; + } + + public Boolean getEnded() { + return ended; + } + + public Integer getCaseActivityInstanceState() { + return caseActivityInstanceState; + } + + public Boolean isRequired() { + return required; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseActivityInstanceQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseActivityInstanceQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..bac594fa16184dd0c9ee37fa3b2f5c5e425fc5af --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseActivityInstanceQueryProperty.java @@ -0,0 +1,41 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery; +import org.camunda.bpm.engine.query.QueryProperty; + + +/** + * Contains the possible properties which can be used in a {@link HistoricCaseActivityInstanceQuery}. + * + * @author Sebastian Menski + */ +public interface HistoricCaseActivityInstanceQueryProperty { + + public static final QueryProperty HISTORIC_CASE_ACTIVITY_INSTANCE_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty CASE_INSTANCE_ID = new QueryPropertyImpl("CASE_INST_ID_"); + public static final QueryProperty CASE_ACTIVITY_ID = new QueryPropertyImpl("CASE_ACT_ID_"); + public static final QueryProperty CASE_ACTIVITY_NAME = new QueryPropertyImpl("CASE_ACT_NAME_"); + public static final QueryProperty CASE_ACTIVITY_TYPE = new QueryPropertyImpl("CASE_ACT_TYPE_"); + public static final QueryProperty CASE_DEFINITION_ID = new QueryPropertyImpl("CASE_DEF_ID_"); + public static final QueryProperty CREATE = new QueryPropertyImpl("CREATE_TIME_"); + public static final QueryProperty END = new QueryPropertyImpl("END_TIME_"); + public static final QueryProperty DURATION = new QueryPropertyImpl("DURATION_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseActivityStatisticsQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseActivityStatisticsQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b760d80a200339f608ac7c5ad22106f882f6e758 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseActivityStatisticsQueryImpl.java @@ -0,0 +1,69 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.List; + +import org.camunda.bpm.engine.history.HistoricCaseActivityStatistics; +import org.camunda.bpm.engine.history.HistoricCaseActivityStatisticsQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + +/** + * @author smirnov + * + */ +public class HistoricCaseActivityStatisticsQueryImpl extends AbstractQuery implements + HistoricCaseActivityStatisticsQuery { + + private static final long serialVersionUID = 1L; + + protected String caseDefinitionId; + + public HistoricCaseActivityStatisticsQueryImpl(String caseDefinitionId, CommandExecutor commandExecutor) { + super(commandExecutor); + this.caseDefinitionId = caseDefinitionId; + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return + commandContext + .getHistoricStatisticsManager() + .getHistoricStatisticsCountGroupedByCaseActivity(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return + commandContext + .getHistoricStatisticsManager() + .getHistoricStatisticsGroupedByCaseActivity(this, page); + } + + protected void checkQueryOk() { + super.checkQueryOk(); + ensureNotNull("No valid case definition id supplied", "caseDefinitionId", caseDefinitionId); + } + + public String getCaseDefinitionId() { + return caseDefinitionId; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..86eef0f3ac9d3ab2d09f72c439111b4648ac7adf --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseInstanceQueryImpl.java @@ -0,0 +1,371 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotContainsEmptyString; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotContainsNull; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotEmpty; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNull; + +import java.util.Date; +import java.util.List; +import java.util.Set; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.HistoricCaseInstance; +import org.camunda.bpm.engine.history.HistoricCaseInstanceQuery; +import org.camunda.bpm.engine.impl.cmmn.execution.CaseExecutionState; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.CompareUtil; + +/** + * @author Sebastian Menski + */ +public class HistoricCaseInstanceQueryImpl extends AbstractVariableQueryImpl implements HistoricCaseInstanceQuery { + + private static final long serialVersionUID = 1L; + protected String caseInstanceId; + protected Set caseInstanceIds; + protected String caseDefinitionId; + protected String caseDefinitionName; + protected String caseDefinitionNameLike; + protected String businessKey; + protected String businessKeyLike; + protected Integer state; + protected Boolean notClosed; + protected String createdBy; + protected String superCaseInstanceId; + protected String subCaseInstanceId; + protected String superProcessInstanceId; + protected String subProcessInstanceId; + protected List caseKeyNotIn; + protected Date createdBefore; + protected Date createdAfter; + protected Date closedBefore; + protected Date closedAfter; + protected String caseDefinitionKey; + protected String[] caseActivityIds; + + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + + public HistoricCaseInstanceQueryImpl() { + } + + public HistoricCaseInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public HistoricCaseInstanceQueryImpl caseInstanceId(String caseInstanceId) { + this.caseInstanceId = caseInstanceId; + return this; + } + + public HistoricCaseInstanceQuery caseInstanceIds(Set caseInstanceIds) { + ensureNotEmpty("Set of case instance ids", caseInstanceIds); + this.caseInstanceIds = caseInstanceIds; + return this; + } + + public HistoricCaseInstanceQueryImpl caseDefinitionId(String caseDefinitionId) { + this.caseDefinitionId = caseDefinitionId; + return this; + } + + public HistoricCaseInstanceQuery caseDefinitionKey(String caseDefinitionKey) { + this.caseDefinitionKey = caseDefinitionKey; + return this; + } + + public HistoricCaseInstanceQuery caseDefinitionName(String caseDefinitionName) { + this.caseDefinitionName = caseDefinitionName; + return this; + } + + public HistoricCaseInstanceQuery caseDefinitionNameLike(String nameLike) { + this.caseDefinitionNameLike = nameLike; + return this; + } + + public HistoricCaseInstanceQuery caseInstanceBusinessKey(String businessKey) { + this.businessKey = businessKey; + return this; + } + + public HistoricCaseInstanceQuery caseInstanceBusinessKeyLike(String businessKeyLike) { + this.businessKeyLike = businessKeyLike; + return this; + } + + public HistoricCaseInstanceQuery createdBy(String userId) { + this.createdBy = userId; + return this; + } + + public HistoricCaseInstanceQuery caseDefinitionKeyNotIn(List caseDefinitionKeys) { + ensureNotContainsNull("caseDefinitionKeys", caseDefinitionKeys); + ensureNotContainsEmptyString("caseDefinitionKeys", caseDefinitionKeys); + this.caseKeyNotIn = caseDefinitionKeys; + return this; + } + + public HistoricCaseInstanceQuery caseActivityIdIn(String... caseActivityIds) { + ensureNotNull("caseActivityIds", (Object[]) caseActivityIds); + this.caseActivityIds = caseActivityIds; + return this; + } + + public HistoricCaseInstanceQuery createdAfter(Date date) { + createdAfter = date; + return this; + } + + public HistoricCaseInstanceQuery createdBefore(Date date) { + createdBefore = date; + return this; + } + + public HistoricCaseInstanceQuery closedAfter(Date date) { + if (state!= null && (!state.equals(CaseExecutionState.CLOSED.getStateCode()))) { + throw new NotValidException("Already querying for case instance state '" + state + "'"); + } + + closedAfter = date; + state = CaseExecutionState.CLOSED.getStateCode(); + return this; + } + + public HistoricCaseInstanceQuery closedBefore(Date date) { + if (state!= null && (!state.equals(CaseExecutionState.CLOSED.getStateCode()))) { + throw new NotValidException("Already querying for case instance state '" + state + "'"); + } + + closedBefore = date; + state = CaseExecutionState.CLOSED.getStateCode(); + return this; + } + + public HistoricCaseInstanceQuery superCaseInstanceId(String superCaseInstanceId) { + this.superCaseInstanceId = superCaseInstanceId; + return this; + } + + public HistoricCaseInstanceQuery subCaseInstanceId(String subCaseInstanceId) { + this.subCaseInstanceId = subCaseInstanceId; + return this; + } + + public HistoricCaseInstanceQuery superProcessInstanceId(String superProcessInstanceId) { + this.superProcessInstanceId = superProcessInstanceId; + return this; + } + + public HistoricCaseInstanceQuery subProcessInstanceId(String subProcessInstanceId) { + this.subProcessInstanceId = subProcessInstanceId; + return this; + } + + public HistoricCaseInstanceQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public HistoricCaseInstanceQuery withoutTenantId() { + tenantIds = null; + isTenantIdSet = true; + return this; + } + + public HistoricCaseInstanceQuery active() { + ensureNull(NotValidException.class, "Already querying for case instance state '" + state + "'", "state", state); + this.state = CaseExecutionState.ACTIVE.getStateCode(); + return this; + } + + public HistoricCaseInstanceQuery completed() { + ensureNull(NotValidException.class, "Already querying for case instance state '" + state + "'", "state", state); + this.state = CaseExecutionState.COMPLETED.getStateCode(); + return this; + } + + public HistoricCaseInstanceQuery terminated() { + ensureNull(NotValidException.class, "Already querying for case instance state '" + state + "'", "state", state); + this.state = CaseExecutionState.TERMINATED.getStateCode(); + return this; + } + + public HistoricCaseInstanceQuery failed() { + ensureNull(NotValidException.class, "Already querying for case instance state '" + state + "'", "state", state); + this.state = CaseExecutionState.FAILED.getStateCode(); + return this; + } + + public HistoricCaseInstanceQuery suspended() { + ensureNull(NotValidException.class, "Already querying for case instance state '" + state + "'", "state", state); + this.state = CaseExecutionState.SUSPENDED.getStateCode(); + return this; + } + + public HistoricCaseInstanceQuery closed() { + ensureNull(NotValidException.class, "Already querying for case instance state '" + state + "'", "state", state); + this.state = CaseExecutionState.CLOSED.getStateCode(); + return this; + } + + public HistoricCaseInstanceQuery notClosed() { + this.notClosed = true; + return this; + } + + public HistoricCaseInstanceQuery orderByCaseInstanceBusinessKey() { + return orderBy(HistoricCaseInstanceQueryProperty.BUSINESS_KEY); + } + + public HistoricCaseInstanceQuery orderByCaseInstanceDuration() { + return orderBy(HistoricCaseInstanceQueryProperty.DURATION); + } + + public HistoricCaseInstanceQuery orderByCaseInstanceCreateTime() { + return orderBy(HistoricCaseInstanceQueryProperty.CREATE_TIME); + } + + public HistoricCaseInstanceQuery orderByCaseInstanceCloseTime() { + return orderBy(HistoricCaseInstanceQueryProperty.CLOSE_TIME); + } + + public HistoricCaseInstanceQuery orderByCaseDefinitionId() { + return orderBy(HistoricCaseInstanceQueryProperty.PROCESS_DEFINITION_ID); + } + + public HistoricCaseInstanceQuery orderByCaseInstanceId() { + return orderBy(HistoricCaseInstanceQueryProperty.PROCESS_INSTANCE_ID_); + } + + public HistoricCaseInstanceQuery orderByTenantId() { + return orderBy(HistoricCaseInstanceQueryProperty.TENANT_ID); + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + ensureVariablesInitialized(); + return commandContext + .getHistoricCaseInstanceManager() + .findHistoricCaseInstanceCountByQueryCriteria(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + ensureVariablesInitialized(); + return commandContext + .getHistoricCaseInstanceManager() + .findHistoricCaseInstancesByQueryCriteria(this, page); + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() + || CompareUtil.areNotInAscendingOrder(createdAfter, createdBefore) + || CompareUtil.areNotInAscendingOrder(closedAfter, closedBefore) + || CompareUtil.elementIsNotContainedInList(caseInstanceId, caseInstanceIds) + || CompareUtil.elementIsContainedInList(caseDefinitionKey, caseKeyNotIn); + } + + public String getBusinessKey() { + return businessKey; + } + + public String getBusinessKeyLike() { + return businessKeyLike; + } + + public String getCaseDefinitionId() { + return caseDefinitionId; + } + + public String getCaseDefinitionKey() { + return caseDefinitionKey; + } + + public String getCaseDefinitionIdLike() { + return caseDefinitionKey + ":%:%"; + } + + public String getCaseDefinitionName() { + return caseDefinitionName; + } + + public String getCaseDefinitionNameLike() { + return caseDefinitionNameLike; + } + + public String getCaseInstanceId() { + return caseInstanceId; + } + + public Set getCaseInstanceIds() { + return caseInstanceIds; + } + + public String getStartedBy() { + return createdBy; + } + + public String getSuperCaseInstanceId() { + return superCaseInstanceId; + } + + public void setSuperCaseInstanceId(String superCaseInstanceId) { + this.superCaseInstanceId = superCaseInstanceId; + } + + public List getCaseKeyNotIn() { + return caseKeyNotIn; + } + + public Date getCreatedAfter() { + return createdAfter; + } + + public Date getCreatedBefore() { + return createdBefore; + } + + public Date getClosedAfter() { + return closedAfter; + } + + public Date getClosedBefore() { + return closedBefore; + } + + public String getSubCaseInstanceId() { + return subCaseInstanceId; + } + + public String getSuperProcessInstanceId() { + return superProcessInstanceId; + } + + public String getSubProcessInstanceId() { + return subProcessInstanceId; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseInstanceQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseInstanceQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..a3990a10aedba1681f3864146a7e89e4361fc004 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricCaseInstanceQueryProperty.java @@ -0,0 +1,37 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + + +/** + * Contains the possible properties which can be used in a {@link HistoricCaseInstanceQueryProperty}. + * + * @author Sebastian Menski + */ +public interface HistoricCaseInstanceQueryProperty { + + public static final QueryProperty PROCESS_INSTANCE_ID_ = new QueryPropertyImpl("CASE_INST_ID_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("CASE_DEF_ID_"); + public static final QueryProperty BUSINESS_KEY = new QueryPropertyImpl("BUSINESS_KEY_"); + public static final QueryProperty CREATE_TIME = new QueryPropertyImpl("CREATE_TIME_"); + public static final QueryProperty CLOSE_TIME = new QueryPropertyImpl("CLOSE_TIME_"); + public static final QueryProperty DURATION = new QueryPropertyImpl("DURATION_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDecisionInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDecisionInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a977ed1904451dbf8d81c66b796c37aad3933778 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDecisionInstanceQueryImpl.java @@ -0,0 +1,400 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.HistoricDecisionInstance; +import org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.ImmutablePair; + +/** + * @author Philipp Ossler + */ +public class HistoricDecisionInstanceQueryImpl extends AbstractQuery implements HistoricDecisionInstanceQuery { + + private static final long serialVersionUID = 1L; + + protected String decisionInstanceId; + protected String[] decisionInstanceIdIn; + + protected String decisionDefinitionId; + protected String[] decisionDefinitionIdIn; + + protected String decisionDefinitionKey; + protected String[] decisionDefinitionKeyIn; + + protected String decisionDefinitionName; + protected String decisionDefinitionNameLike; + + protected String processDefinitionKey; + protected String processDefinitionId; + protected String processInstanceId; + + protected String caseDefinitionKey; + protected String caseDefinitionId; + protected String caseInstanceId; + + protected String[] activityInstanceIds; + protected String[] activityIds; + + protected Date evaluatedBefore; + protected Date evaluatedAfter; + + protected String userId; + + protected boolean includeInput = false; + protected boolean includeOutputs = false; + + protected boolean isByteArrayFetchingEnabled = true; + protected boolean isCustomObjectDeserializationEnabled = true; + + protected String rootDecisionInstanceId; + protected boolean rootDecisionInstancesOnly = false; + + protected String decisionRequirementsDefinitionId; + protected String decisionRequirementsDefinitionKey; + + protected String[] tenantIds; + protected boolean isTenantIdSet; + + public HistoricDecisionInstanceQueryImpl() { + } + + public HistoricDecisionInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public HistoricDecisionInstanceQuery decisionInstanceId(String decisionInstanceId) { + ensureNotNull(NotValidException.class, "decisionInstanceId", decisionInstanceId); + this.decisionInstanceId = decisionInstanceId; + return this; + } + + public HistoricDecisionInstanceQuery decisionInstanceIdIn(String... decisionInstanceIdIn) { + ensureNotNull("decisionInstanceIdIn", (Object[]) decisionInstanceIdIn); + this.decisionInstanceIdIn = decisionInstanceIdIn; + return this; + } + + public HistoricDecisionInstanceQuery decisionDefinitionId(String decisionDefinitionId) { + ensureNotNull(NotValidException.class, "decisionDefinitionId", decisionDefinitionId); + this.decisionDefinitionId = decisionDefinitionId; + return this; + } + + @Override + public HistoricDecisionInstanceQuery decisionDefinitionIdIn(String... decisionDefinitionIdIn) { + ensureNotNull(NotValidException.class, "decisionDefinitionIdIn", decisionDefinitionIdIn); + this.decisionDefinitionIdIn = decisionDefinitionIdIn; + return this; + } + + @Override + public HistoricDecisionInstanceQuery decisionDefinitionKey(String decisionDefinitionKey) { + ensureNotNull(NotValidException.class, "decisionDefinitionKey", decisionDefinitionKey); + this.decisionDefinitionKey = decisionDefinitionKey; + return this; + } + + @Override + public HistoricDecisionInstanceQuery decisionDefinitionKeyIn(String... decisionDefinitionKeyIn) { + ensureNotNull(NotValidException.class, "decisionDefinitionKeyIn", decisionDefinitionKeyIn); + this.decisionDefinitionKeyIn = decisionDefinitionKeyIn; + return this; + } + + @Override + public HistoricDecisionInstanceQuery decisionDefinitionName(String decisionDefinitionName) { + ensureNotNull(NotValidException.class, "decisionDefinitionName", decisionDefinitionName); + this.decisionDefinitionName = decisionDefinitionName; + return this; + } + + @Override + public HistoricDecisionInstanceQuery decisionDefinitionNameLike(String decisionDefinitionNameLike) { + ensureNotNull(NotValidException.class, "decisionDefinitionNameLike", decisionDefinitionNameLike); + this.decisionDefinitionNameLike = decisionDefinitionNameLike; + return this; + } + + @Override + public HistoricDecisionInstanceQuery processDefinitionKey(String processDefinitionKey) { + ensureNotNull(NotValidException.class, "processDefinitionKey", processDefinitionKey); + this.processDefinitionKey = processDefinitionKey; + return this; + } + + @Override + public HistoricDecisionInstanceQuery processDefinitionId(String processDefinitionId) { + ensureNotNull(NotValidException.class, "processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + @Override + public HistoricDecisionInstanceQuery processInstanceId(String processInstanceId) { + ensureNotNull(NotValidException.class, "processInstanceId", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + @Override + public HistoricDecisionInstanceQuery caseDefinitionKey(String caseDefinitionKey) { + ensureNotNull(NotValidException.class, "caseDefinitionKey", caseDefinitionKey); + this.caseDefinitionKey = caseDefinitionKey; + return this; + } + + @Override + public HistoricDecisionInstanceQuery caseDefinitionId(String caseDefinitionId) { + ensureNotNull(NotValidException.class, "caseDefinitionId", caseDefinitionId); + this.caseDefinitionId = caseDefinitionId; + return this; + } + + @Override + public HistoricDecisionInstanceQuery caseInstanceId(String caseInstanceId) { + ensureNotNull(NotValidException.class, "caseInstanceId", caseInstanceId); + this.caseInstanceId = caseInstanceId; + return this; + } + + @Override + public HistoricDecisionInstanceQuery activityIdIn(String... activityIds) { + ensureNotNull("activityIds", (Object[]) activityIds); + this.activityIds = activityIds; + return this; + } + + public HistoricDecisionInstanceQuery activityInstanceIdIn(String... activityInstanceIds) { + ensureNotNull("activityInstanceIds", (Object[]) activityInstanceIds); + this.activityInstanceIds = activityInstanceIds; + return this; + } + + public HistoricDecisionInstanceQuery evaluatedBefore(Date evaluatedBefore) { + ensureNotNull(NotValidException.class, "evaluatedBefore", evaluatedBefore); + this.evaluatedBefore = evaluatedBefore; + return this; + } + + public HistoricDecisionInstanceQuery evaluatedAfter(Date evaluatedAfter) { + ensureNotNull(NotValidException.class, "evaluatedAfter", evaluatedAfter); + this.evaluatedAfter = evaluatedAfter; + return this; + } + + public HistoricDecisionInstanceQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricDecisionInstanceQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + public HistoricDecisionInstanceQuery orderByTenantId() { + return orderBy(HistoricDecisionInstanceQueryProperty.TENANT_ID); + } + + @Override + public HistoricDecisionInstanceQuery userId(String userId) { + ensureNotNull(NotValidException.class, "userId", userId); + this.userId = userId; + return this; + } + + @Override + public HistoricDecisionInstanceQuery orderByEvaluationTime() { + orderBy(HistoricDecisionInstanceQueryProperty.EVALUATION_TIME); + return this; + } + + @Override + public HistoricDecisionInstanceQuery orderByDecisionInstanceId(){ + orderBy(HistoricDecisionInstanceQueryProperty.DECISION_INSTANCE_ID); + return this; + } + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricDecisionInstanceManager() + .findHistoricDecisionInstanceCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getHistoricDecisionInstanceManager() + .findHistoricDecisionInstancesByQueryCriteria(this, page); + } + + @Override + public List> executeDeploymentIdMappingsList(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricDecisionInstanceManager() + .findHistoricDecisionInstanceDeploymentIdMappingsByQueryCriteria(this); + } + + public String getDecisionDefinitionId() { + return decisionDefinitionId; + } + + public String getDecisionDefinitionKey() { + return decisionDefinitionKey; + } + + public String getDecisionDefinitionName() { + return decisionDefinitionName; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getCaseDefinitionKey() { + return caseDefinitionKey; + } + + public String getCaseDefinitionId() { + return caseDefinitionId; + } + + public String getCaseInstanceId() { + return caseInstanceId; + } + + public String[] getActivityInstanceIds() { + return activityInstanceIds; + } + + public String[] getActivityIds() { + return activityIds; + } + + public String[] getTenantIds() { + return tenantIds; + } + + public HistoricDecisionInstanceQuery includeInputs() { + includeInput = true; + return this; + } + + @Override + public HistoricDecisionInstanceQuery includeOutputs() { + includeOutputs = true; + return this; + } + + public boolean isIncludeInput() { + return includeInput; + } + + public boolean isIncludeOutputs() { + return includeOutputs; + } + + @Override + public HistoricDecisionInstanceQuery disableBinaryFetching() { + isByteArrayFetchingEnabled = false; + return this; + } + + @Override + public HistoricDecisionInstanceQuery disableCustomObjectDeserialization() { + isCustomObjectDeserializationEnabled = false; + return this; + } + + public boolean isByteArrayFetchingEnabled() { + return isByteArrayFetchingEnabled; + } + + public boolean isCustomObjectDeserializationEnabled() { + return isCustomObjectDeserializationEnabled; + } + + public String getRootDecisionInstanceId() { + return rootDecisionInstanceId; + } + + public HistoricDecisionInstanceQuery rootDecisionInstanceId(String rootDecisionInstanceId) { + ensureNotNull(NotValidException.class, "rootDecisionInstanceId", rootDecisionInstanceId); + this.rootDecisionInstanceId = rootDecisionInstanceId; + return this; + } + + public boolean isRootDecisionInstancesOnly() { + return rootDecisionInstancesOnly; + } + + public HistoricDecisionInstanceQuery rootDecisionInstancesOnly() { + this.rootDecisionInstancesOnly = true; + return this; + } + + @Override + public HistoricDecisionInstanceQuery decisionRequirementsDefinitionId(String decisionRequirementsDefinitionId) { + ensureNotNull(NotValidException.class, "decisionRequirementsDefinitionId", decisionRequirementsDefinitionId); + this.decisionRequirementsDefinitionId = decisionRequirementsDefinitionId; + return this; + } + + @Override + public HistoricDecisionInstanceQuery decisionRequirementsDefinitionKey(String decisionRequirementsDefinitionKey) { + ensureNotNull(NotValidException.class, "decisionRequirementsDefinitionKey", decisionRequirementsDefinitionKey); + this.decisionRequirementsDefinitionKey = decisionRequirementsDefinitionKey; + return this; + } + + public String getDecisionRequirementsDefinitionId() { + return decisionRequirementsDefinitionId; + } + + public String getDecisionRequirementsDefinitionKey() { + return decisionRequirementsDefinitionKey; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDecisionInstanceQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDecisionInstanceQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..5c399066fb135040bb1217f4760a1b9deed83c1c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDecisionInstanceQueryProperty.java @@ -0,0 +1,33 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery; +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * Properties which can be used in {@link HistoricDecisionInstanceQuery} to sort historic decision instances. + * + * @author Philipp Ossler + */ +public interface HistoricDecisionInstanceQueryProperty { + + public static final QueryProperty DECISION_INSTANCE_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty EVALUATION_TIME = new QueryPropertyImpl("EVAL_TIME_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDecisionInstanceStatisticsQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDecisionInstanceStatisticsQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..734d26a7f2eb2d6a380368dfd419d8e913be6922 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDecisionInstanceStatisticsQueryImpl.java @@ -0,0 +1,87 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.EnsureUtil; +import org.camunda.bpm.engine.history.HistoricDecisionInstanceStatistics; +import org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery; + +import java.util.List; + + +/** + * @author Askar Akhmerov + */ +public class HistoricDecisionInstanceStatisticsQueryImpl extends + AbstractQuery implements HistoricDecisionInstanceStatisticsQuery { + + protected final String decisionRequirementsDefinitionId; + protected String decisionInstanceId; + + public HistoricDecisionInstanceStatisticsQueryImpl(String decisionRequirementsDefinitionId, CommandExecutor commandExecutor) { + super(commandExecutor); + this.decisionRequirementsDefinitionId = decisionRequirementsDefinitionId; + } + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + + long count = commandContext + .getStatisticsManager() + .getStatisticsCountGroupedByDecisionRequirementsDefinition(this); + + return count; + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + + List statisticsList = commandContext + .getStatisticsManager() + .getStatisticsGroupedByDecisionRequirementsDefinition(this, page); + + return statisticsList; + } + + protected void checkQueryOk() { + super.checkQueryOk(); + EnsureUtil.ensureNotNull("decisionRequirementsDefinitionId", decisionRequirementsDefinitionId); + } + + public String getDecisionRequirementsDefinitionId() { + return decisionRequirementsDefinitionId; + } + + @Override + public HistoricDecisionInstanceStatisticsQuery decisionInstanceId(String decisionInstanceId) { + this.decisionInstanceId = decisionInstanceId; + return this; + } + + public String getDecisionInstanceId() { + return decisionInstanceId; + } + + public void setDecisionInstanceId(String decisionInstanceId) { + this.decisionInstanceId = decisionInstanceId; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDetailQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDetailQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..1a97312d92f30153b38505047af222bbb49d4324 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDetailQueryImpl.java @@ -0,0 +1,356 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Date; +import java.util.List; +import org.camunda.bpm.engine.history.HistoricDetail; +import org.camunda.bpm.engine.history.HistoricDetailQuery; +import org.camunda.bpm.engine.impl.cmd.CommandLogger; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.HistoricDetailVariableInstanceUpdateEntity; +import org.camunda.bpm.engine.impl.variable.serializer.AbstractTypedValueSerializer; + + +/** + * @author Tom Baeyens + */ +public class HistoricDetailQueryImpl extends AbstractQuery implements HistoricDetailQuery { + + private final static CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; + + private static final long serialVersionUID = 1L; + protected String detailId; + protected String taskId; + protected String processInstanceId; + protected String caseInstanceId; + protected String executionId; + protected String caseExecutionId; + protected String activityId; + protected String activityInstanceId; + protected String type; + protected String variableInstanceId; + protected String[] variableTypes; + protected String variableNameLike; + protected String[] tenantIds; + protected boolean isTenantIdSet; + protected String[] processInstanceIds; + protected String userOperationId; + protected Long sequenceCounter; + protected Date occurredBefore; + protected Date occurredAfter; + protected boolean initial = false; + + protected boolean excludeTaskRelated = false; + protected boolean isByteArrayFetchingEnabled = true; + protected boolean isCustomObjectDeserializationEnabled = true; + + public HistoricDetailQueryImpl() { + } + + public HistoricDetailQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public HistoricDetailQuery detailId(String id) { + ensureNotNull("detailId", id); + this.detailId = id; + return this; + } + + public HistoricDetailQuery variableInstanceId(String variableInstanceId) { + ensureNotNull("variableInstanceId", variableInstanceId); + this.variableInstanceId = variableInstanceId; + return this; + } + + public HistoricDetailQuery variableTypeIn(String... variableTypes) { + ensureNotNull("Variable types", (Object[]) variableTypes); + this.variableTypes = lowerCase(variableTypes); + return this; + } + + public HistoricDetailQuery variableNameLike(String variableNameLike) { + ensureNotNull("Variable name like", variableNameLike); + this.variableNameLike = variableNameLike; + return this; + } + + private String[] lowerCase(String... variableTypes) { + for (int i = 0; i < variableTypes.length; i++) { + variableTypes[i] = variableTypes[i].toLowerCase(); + } + return variableTypes; + } + + public HistoricDetailQuery processInstanceId(String processInstanceId) { + this.processInstanceId = processInstanceId; + return this; + } + + public HistoricDetailQuery caseInstanceId(String caseInstanceId) { + ensureNotNull("Case instance id", caseInstanceId); + this.caseInstanceId = caseInstanceId; + return this; + } + + public HistoricDetailQuery executionId(String executionId) { + this.executionId = executionId; + return this; + } + + public HistoricDetailQuery caseExecutionId(String caseExecutionId) { + ensureNotNull("Case execution id", caseExecutionId); + this.caseExecutionId = caseExecutionId; + return this; + } + + public HistoricDetailQuery activityId(String activityId) { + this.activityId = activityId; + return this; + } + + public HistoricDetailQuery activityInstanceId(String activityInstanceId) { + this.activityInstanceId = activityInstanceId; + return this; + } + + public HistoricDetailQuery taskId(String taskId) { + this.taskId = taskId; + return this; + } + + public HistoricDetailQuery formProperties() { + this.type = "FormProperty"; + return this; + } + + public HistoricDetailQuery formFields() { + this.type = "FormProperty"; + return this; + } + + public HistoricDetailQuery variableUpdates() { + this.type = "VariableUpdate"; + return this; + } + + public HistoricDetailQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricDetailQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + public HistoricDetailQuery processInstanceIdIn(String... processInstanceIds) { + ensureNotNull("Process Instance Ids", (Object[]) processInstanceIds); + this.processInstanceIds = processInstanceIds; + return this; + } + + public HistoricDetailQuery userOperationId(String userOperationId) { + ensureNotNull("userOperationId", userOperationId); + this.userOperationId = userOperationId; + return this; + } + + public HistoricDetailQueryImpl sequenceCounter(long sequenceCounter) { + this.sequenceCounter = sequenceCounter; + return this; + } + + public HistoricDetailQuery excludeTaskDetails() { + this.excludeTaskRelated = true; + return this; + } + + public HistoricDetailQuery occurredBefore(Date date) { + ensureNotNull("occurred before", date); + occurredBefore = date; + return this; + } + + public HistoricDetailQuery occurredAfter(Date date) { + ensureNotNull("occurred after", date); + occurredAfter = date; + return this; + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricDetailManager() + .findHistoricDetailCountByQueryCriteria(this); + } + + public HistoricDetailQuery disableBinaryFetching() { + this.isByteArrayFetchingEnabled = false; + return this; + } + + public HistoricDetailQuery disableCustomObjectDeserialization() { + this.isCustomObjectDeserializationEnabled = false; + return this; + } + + @Override + public HistoricDetailQuery initial() { + this.initial = true; + return this; + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + List historicDetails = commandContext + .getHistoricDetailManager() + .findHistoricDetailsByQueryCriteria(this, page); + if (historicDetails!=null) { + for (HistoricDetail historicDetail: historicDetails) { + if (historicDetail instanceof HistoricDetailVariableInstanceUpdateEntity) { + HistoricDetailVariableInstanceUpdateEntity entity = (HistoricDetailVariableInstanceUpdateEntity) historicDetail; + if (shouldFetchValue(entity)) { + try { + entity.getTypedValue(isCustomObjectDeserializationEnabled); + + } catch(Exception t) { + // do not fail if one of the variables fails to load + LOG.exceptionWhileGettingValueForVariable(t); + } + } + + } + } + } + return historicDetails; + } + + protected boolean shouldFetchValue(HistoricDetailVariableInstanceUpdateEntity entity) { + // do not fetch values for byte arrays eagerly (unless requested by the user) + return isByteArrayFetchingEnabled + || !AbstractTypedValueSerializer.BINARY_VALUE_TYPES.contains(entity.getSerializer().getType().getName()); + } + + // order by ///////////////////////////////////////////////////////////////// + + public HistoricDetailQuery orderByProcessInstanceId() { + orderBy(HistoricDetailQueryProperty.PROCESS_INSTANCE_ID); + return this; + } + + public HistoricDetailQuery orderByTime() { + orderBy(HistoricDetailQueryProperty.TIME); + return this; + } + + public HistoricDetailQuery orderByVariableName() { + orderBy(HistoricDetailQueryProperty.VARIABLE_NAME); + return this; + } + + public HistoricDetailQuery orderByFormPropertyId() { + orderBy(HistoricDetailQueryProperty.VARIABLE_NAME); + return this; + } + + public HistoricDetailQuery orderByVariableRevision() { + orderBy(HistoricDetailQueryProperty.VARIABLE_REVISION); + return this; + } + + public HistoricDetailQuery orderByVariableType() { + orderBy(HistoricDetailQueryProperty.VARIABLE_TYPE); + return this; + } + + public HistoricDetailQuery orderPartiallyByOccurrence() { + orderBy(HistoricDetailQueryProperty.SEQUENCE_COUNTER); + return this; + } + + public HistoricDetailQuery orderByTenantId() { + return orderBy(HistoricDetailQueryProperty.TENANT_ID); + } + + // getters and setters ////////////////////////////////////////////////////// + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getCaseInstanceId() { + return caseInstanceId; + } + + public String getExecutionId() { + return executionId; + } + + public String getCaseExecutionId() { + return caseExecutionId; + } + + public String getTaskId() { + return taskId; + } + + public String getActivityId() { + return activityId; + } + + public String getType() { + return type; + } + + public boolean getExcludeTaskRelated() { + return excludeTaskRelated; + } + + public String getDetailId() { + return detailId; + } + + public String[] getProcessInstanceIds() { + return processInstanceIds; + } + + public Date getOccurredBefore() { + return occurredBefore; + } + + public Date getOccurredAfter() { + return occurredAfter; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public boolean isInitial() { + return initial; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDetailQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDetailQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..98944947301d56c209fb6ca7375760736fc58aff --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricDetailQueryProperty.java @@ -0,0 +1,37 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.history.HistoricDetailQuery; +import org.camunda.bpm.engine.query.QueryProperty; + + +/** + * Contains the possible properties which can be used in a {@link HistoricDetailQuery}. + * + * @author Tom Baeyens + */ +public interface HistoricDetailQueryProperty { + + public static final QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROC_INST_ID_"); + public static final QueryProperty VARIABLE_NAME = new QueryPropertyImpl("NAME_"); + public static final QueryProperty VARIABLE_TYPE = new QueryPropertyImpl("TYPE_"); + public static final QueryProperty VARIABLE_REVISION = new QueryPropertyImpl("REV_"); + public static final QueryProperty TIME = new QueryPropertyImpl("TIME_"); + public static final QueryProperty SEQUENCE_COUNTER = new QueryPropertyImpl("SEQUENCE_COUNTER_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricExternalTaskLogQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricExternalTaskLogQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..826cc60fda72815a4fb66991c9c232d153cd3a8b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricExternalTaskLogQueryImpl.java @@ -0,0 +1,303 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.ExternalTaskState; +import org.camunda.bpm.engine.history.HistoricExternalTaskLog; +import org.camunda.bpm.engine.history.HistoricExternalTaskLogQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.CollectionUtil; + +import java.util.List; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.*; + +public class HistoricExternalTaskLogQueryImpl extends AbstractQuery implements HistoricExternalTaskLogQuery { + + private static final long serialVersionUID = 1L; + + protected String id; + protected String externalTaskId; + protected String topicName; + protected String workerId; + protected String errorMessage; + protected String[] activityIds; + protected String[] activityInstanceIds; + protected String[] executionIds; + protected String processInstanceId; + protected String processDefinitionId; + protected String processDefinitionKey; + protected Long priorityHigherThanOrEqual; + protected Long priorityLowerThanOrEqual; + protected String[] tenantIds; + protected boolean isTenantIdSet; + protected ExternalTaskState state; + + public HistoricExternalTaskLogQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + // query parameter //////////////////////////////////////////// + + @Override + public HistoricExternalTaskLogQuery logId(String historicExternalTaskLogId) { + ensureNotNull(NotValidException.class, "historicExternalTaskLogId", historicExternalTaskLogId); + this.id = historicExternalTaskLogId; + return this; + } + + @Override + public HistoricExternalTaskLogQuery externalTaskId(String externalTaskId) { + ensureNotNull(NotValidException.class, "externalTaskId", externalTaskId); + this.externalTaskId = externalTaskId; + return this; + } + + @Override + public HistoricExternalTaskLogQuery topicName(String topicName) { + ensureNotNull(NotValidException.class, "topicName", topicName); + this.topicName = topicName; + return this; + } + + @Override + public HistoricExternalTaskLogQuery workerId(String workerId) { + ensureNotNull(NotValidException.class, "workerId", workerId); + this.workerId = workerId; + return this; + } + + @Override + public HistoricExternalTaskLogQuery errorMessage(String errorMessage) { + ensureNotNull(NotValidException.class, "errorMessage", errorMessage); + this.errorMessage = errorMessage; + return this; + } + + @Override + public HistoricExternalTaskLogQuery activityIdIn(String... activityIds) { + ensureNotNull(NotValidException.class, "activityIds", (Object[]) activityIds); + List activityIdList = CollectionUtil.asArrayList(activityIds); + ensureNotContainsNull("activityIds", activityIdList); + ensureNotContainsEmptyString("activityIds", activityIdList); + this.activityIds = activityIds; + return this; + } + + @Override + public HistoricExternalTaskLogQuery activityInstanceIdIn(String... activityInstanceIds) { + ensureNotNull(NotValidException.class, "activityIds", (Object[]) activityInstanceIds); + List activityInstanceIdList = CollectionUtil.asArrayList(activityInstanceIds); + ensureNotContainsNull("activityInstanceIds", activityInstanceIdList); + ensureNotContainsEmptyString("activityInstanceIds", activityInstanceIdList); + this.activityInstanceIds = activityInstanceIds; + return this; + } + + @Override + public HistoricExternalTaskLogQuery executionIdIn(String... executionIds) { + ensureNotNull(NotValidException.class, "activityIds", (Object[]) executionIds); + List executionIdList = CollectionUtil.asArrayList(executionIds); + ensureNotContainsNull("executionIds", executionIdList); + ensureNotContainsEmptyString("executionIds", executionIdList); + this.executionIds = executionIds; + return this; + } + + @Override + public HistoricExternalTaskLogQuery processInstanceId(String processInstanceId) { + ensureNotNull(NotValidException.class, "processInstanceId", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + @Override + public HistoricExternalTaskLogQuery processDefinitionId(String processDefinitionId) { + ensureNotNull(NotValidException.class, "processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + @Override + public HistoricExternalTaskLogQuery processDefinitionKey(String processDefinitionKey) { + ensureNotNull(NotValidException.class, "processDefinitionKey", processDefinitionKey); + this.processDefinitionKey = processDefinitionKey; + return this; + } + + @Override + public HistoricExternalTaskLogQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricExternalTaskLogQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricExternalTaskLogQuery priorityHigherThanOrEquals(long priority) { + this.priorityHigherThanOrEqual = priority; + return this; + } + + @Override + public HistoricExternalTaskLogQuery priorityLowerThanOrEquals(long priority) { + this.priorityLowerThanOrEqual = priority; + return this; + } + + @Override + public HistoricExternalTaskLogQuery creationLog() { + setState(ExternalTaskState.CREATED); + return this; + } + + @Override + public HistoricExternalTaskLogQuery failureLog() { + setState(ExternalTaskState.FAILED); + return this; + } + + @Override + public HistoricExternalTaskLogQuery successLog() { + setState(ExternalTaskState.SUCCESSFUL); + return this; + } + + @Override + public HistoricExternalTaskLogQuery deletionLog() { + setState(ExternalTaskState.DELETED); + return this; + } + + // order by ////////////////////////////////////////////// + + + @Override + public HistoricExternalTaskLogQuery orderByTimestamp() { + orderBy(HistoricExternalTaskLogQueryProperty.TIMESTAMP); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByExternalTaskId() { + orderBy(HistoricExternalTaskLogQueryProperty.EXTERNAL_TASK_ID); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByRetries() { + orderBy(HistoricExternalTaskLogQueryProperty.RETRIES); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByPriority() { + orderBy(HistoricExternalTaskLogQueryProperty.PRIORITY); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByTopicName() { + orderBy(HistoricExternalTaskLogQueryProperty.TOPIC_NAME); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByWorkerId() { + orderBy(HistoricExternalTaskLogQueryProperty.WORKER_ID); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByActivityId() { + orderBy(HistoricExternalTaskLogQueryProperty.ACTIVITY_ID); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByActivityInstanceId() { + orderBy(HistoricExternalTaskLogQueryProperty.ACTIVITY_INSTANCE_ID); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByExecutionId() { + orderBy(HistoricExternalTaskLogQueryProperty.EXECUTION_ID); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByProcessInstanceId() { + orderBy(HistoricExternalTaskLogQueryProperty.PROCESS_INSTANCE_ID); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByProcessDefinitionId() { + orderBy(HistoricExternalTaskLogQueryProperty.PROCESS_DEFINITION_ID); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByProcessDefinitionKey() { + orderBy(HistoricExternalTaskLogQueryProperty.PROCESS_DEFINITION_KEY); + return this; + } + + @Override + public HistoricExternalTaskLogQuery orderByTenantId() { + orderBy(HistoricExternalTaskLogQueryProperty.TENANT_ID); + return this; + } + + // results ////////////////////////////////////////////////////////////// + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricExternalTaskLogManager() + .findHistoricExternalTaskLogsCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getHistoricExternalTaskLogManager() + .findHistoricExternalTaskLogsByQueryCriteria(this, page); + } + + // getters & setters //////////////////////////////////////////////////////////// + + protected void setState(ExternalTaskState state) { + this.state = state; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricExternalTaskLogQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricExternalTaskLogQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..83d8c4ea996811b7160161f1af68dbeb0235e7da --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricExternalTaskLogQueryProperty.java @@ -0,0 +1,37 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +public interface HistoricExternalTaskLogQueryProperty { + + QueryProperty EXTERNAL_TASK_ID = new QueryPropertyImpl("EXT_TASK_ID_"); + QueryProperty TIMESTAMP = new QueryPropertyImpl("TIMESTAMP_"); + QueryProperty TOPIC_NAME = new QueryPropertyImpl("TOPIC_NAME_"); + QueryProperty WORKER_ID = new QueryPropertyImpl("WORKER_ID_"); + QueryProperty ACTIVITY_ID = new QueryPropertyImpl("ACT_ID_"); + QueryProperty ACTIVITY_INSTANCE_ID = new QueryPropertyImpl("ACT_INST_ID_"); + QueryProperty EXECUTION_ID = new QueryPropertyImpl("EXECUTION_ID_"); + QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROC_INST_ID_"); + QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("PROC_DEF_ID_"); + QueryProperty PROCESS_DEFINITION_KEY = new QueryPropertyImpl("PROC_DEF_KEY_"); + QueryProperty RETRIES = new QueryPropertyImpl("RETRIES_"); + QueryProperty PRIORITY = new QueryPropertyImpl("PRIORITY_"); + QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIdentityLinkLogQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIdentityLinkLogQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..503549a8653b90dc0ae055ef08da2aecce3f5623 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIdentityLinkLogQueryImpl.java @@ -0,0 +1,260 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.history.HistoricIdentityLinkLog; +import org.camunda.bpm.engine.history.HistoricIdentityLinkLogQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + + /** + * @author Deivarayan Azhagappan + * + */ +public class HistoricIdentityLinkLogQueryImpl extends AbstractVariableQueryImpl + implements HistoricIdentityLinkLogQuery { + + private static final long serialVersionUID = 1L; + protected Date dateBefore; + protected Date dateAfter; + protected String type; + protected String userId; + protected String groupId; + protected String taskId; + protected String processDefinitionId; + protected String processDefinitionKey; + protected String operationType; + protected String assignerId; + protected String[] tenantIds; + protected boolean isTenantIdSet; + + public HistoricIdentityLinkLogQueryImpl() { + } + + public HistoricIdentityLinkLogQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public String getType() { + return type; + } + + public String getUserId() { + return userId; + } + + public String getGroupId() { + return groupId; + } + + public String getTaskId() { + return taskId; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public String getOperationType() { + return operationType; + } + + public String getAssignerId() { + return assignerId; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public HistoricIdentityLinkLogQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + public Date getDateBefore() { + return dateBefore; + } + + public Date getDateAfter() { + return dateAfter; + } + + @Override + public HistoricIdentityLinkLogQuery type(String type) { + ensureNotNull("type", type); + this.type = type; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery dateBefore(Date dateBefore) { + ensureNotNull("dateBefore", dateBefore); + this.dateBefore = dateBefore; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery dateAfter(Date dateAfter) { + ensureNotNull("dateAfter", dateAfter); + this.dateAfter = dateAfter; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery userId(String userId) { + ensureNotNull("userId", userId); + this.userId = userId; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery groupId(String groupId) { + ensureNotNull("groupId", groupId); + this.groupId = groupId; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery taskId(String taskId) { + ensureNotNull("taskId", taskId); + this.taskId = taskId; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery processDefinitionId(String processDefinitionId) { + ensureNotNull("processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery processDefinitionKey(String processDefinitionKey) { + ensureNotNull("processDefinitionKey", processDefinitionKey); + this.processDefinitionKey = processDefinitionKey; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery operationType(String operationType) { + ensureNotNull("operationType", operationType); + this.operationType = operationType; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery assignerId(String assignerId) { + ensureNotNull("assignerId", assignerId); + this.assignerId = assignerId; + return this; + } + + @Override + public HistoricIdentityLinkLogQuery orderByTime() { + orderBy(HistoricIdentityLinkLogQueryProperty.TIME); + return this; + } + + @Override + public HistoricIdentityLinkLogQuery orderByType() { + orderBy(HistoricIdentityLinkLogQueryProperty.TYPE); + return this; + } + + @Override + public HistoricIdentityLinkLogQuery orderByUserId() { + orderBy(HistoricIdentityLinkLogQueryProperty.USER_ID); + return this; + } + + @Override + public HistoricIdentityLinkLogQuery orderByGroupId() { + orderBy(HistoricIdentityLinkLogQueryProperty.GROUP_ID); + return this; + } + + @Override + public HistoricIdentityLinkLogQuery orderByTaskId() { + orderBy(HistoricIdentityLinkLogQueryProperty.TASK_ID); + return this; + } + + @Override + public HistoricIdentityLinkLogQuery orderByProcessDefinitionId() { + orderBy(HistoricIdentityLinkLogQueryProperty.PROC_DEFINITION_ID); + return this; + } + + @Override + public HistoricIdentityLinkLogQuery orderByProcessDefinitionKey() { + orderBy(HistoricIdentityLinkLogQueryProperty.PROC_DEFINITION_KEY); + return this; + } + + @Override + public HistoricIdentityLinkLogQuery orderByOperationType() { + orderBy(HistoricIdentityLinkLogQueryProperty.OPERATION_TYPE); + return this; + } + + @Override + public HistoricIdentityLinkLogQuery orderByAssignerId() { + orderBy(HistoricIdentityLinkLogQueryProperty.ASSIGNER_ID); + return this; + } + + @Override + public HistoricIdentityLinkLogQuery orderByTenantId() { + orderBy(HistoricIdentityLinkLogQueryProperty.TENANT_ID); + return this; + } + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricIdentityLinkManager() + .findHistoricIdentityLinkLogCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getHistoricIdentityLinkManager() + .findHistoricIdentityLinkLogByQueryCriteria(this, page); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIdentityLinkLogQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIdentityLinkLogQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..0d0a050d57f8697a3aecc53b2d44e60b033ee37b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIdentityLinkLogQueryProperty.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +public interface HistoricIdentityLinkLogQueryProperty { + + public static final QueryProperty ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty TIME = new QueryPropertyImpl("TIMESTAMP_"); + public static final QueryProperty TYPE = new QueryPropertyImpl("TYPE_"); + public static final QueryProperty USER_ID = new QueryPropertyImpl("USER_ID_"); + public static final QueryProperty GROUP_ID = new QueryPropertyImpl("GROUP_ID_"); + public static final QueryProperty TASK_ID = new QueryPropertyImpl("TASK_ID_"); + public static final QueryProperty PROC_DEFINITION_ID = new QueryPropertyImpl("PROC_DEF_ID_"); + public static final QueryProperty PROC_DEFINITION_KEY = new QueryPropertyImpl("PROC_DEF_KEY_"); + public static final QueryProperty OPERATION_TYPE = new QueryPropertyImpl("OPERATION_TYPE_"); + public static final QueryProperty ASSIGNER_ID = new QueryPropertyImpl("ASSIGNER_ID_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIncidentQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIncidentQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..95553a9975cc31f2f877036b15463834a86d468b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIncidentQueryImpl.java @@ -0,0 +1,390 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.List; +import java.util.Date; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.history.HistoricIncident; +import org.camunda.bpm.engine.history.HistoricIncidentQuery; +import org.camunda.bpm.engine.history.IncidentState; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + +/** + * @author Roman Smirnov + * + */ +public class HistoricIncidentQueryImpl extends AbstractVariableQueryImpl implements HistoricIncidentQuery { + + private static final long serialVersionUID = 1L; + + protected String id; + protected String incidentType; + protected String incidentMessage; + protected String incidentMessageLike; + protected String executionId; + protected String activityId; + protected Date createTimeBefore; + protected Date createTimeAfter; + protected Date endTimeBefore; + protected Date endTimeAfter; + protected String failedActivityId; + protected String processInstanceId; + protected String processDefinitionId; + protected String processDefinitionKey; + protected String[] processDefinitionKeys; + protected String causeIncidentId; + protected String rootCauseIncidentId; + protected String configuration; + protected String historyConfiguration; + protected IncidentState incidentState; + protected String[] tenantIds; + protected boolean isTenantIdSet; + protected String[] jobDefinitionIds; + + public HistoricIncidentQueryImpl() { + } + + public HistoricIncidentQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public HistoricIncidentQuery incidentId(String incidentId) { + ensureNotNull("incidentId", incidentId); + this.id = incidentId; + return this; + } + + public HistoricIncidentQuery incidentType(String incidentType) { + ensureNotNull("incidentType", incidentType); + this.incidentType = incidentType; + return this; + } + + public HistoricIncidentQuery incidentMessage(String incidentMessage) { + ensureNotNull("incidentMessage", incidentMessage); + this.incidentMessage = incidentMessage; + return this; + } + + public HistoricIncidentQuery incidentMessageLike(String incidentMessageLike) { + ensureNotNull("incidentMessageLike", incidentMessageLike); + this.incidentMessageLike = incidentMessageLike; + return this; + } + + public HistoricIncidentQuery executionId(String executionId) { + ensureNotNull("executionId", executionId); + this.executionId = executionId; + return this; + } + + public HistoricIncidentQuery createTimeBefore(Date createTimeBefore) { + ensureNotNull("createTimeBefore", createTimeBefore); + this.createTimeBefore = createTimeBefore; + return this; + } + + public HistoricIncidentQuery createTimeAfter(Date createTimeAfter) { + ensureNotNull("createTimeAfter", createTimeAfter); + this.createTimeAfter = createTimeAfter; + return this; + } + + public HistoricIncidentQuery endTimeBefore(Date endTimeBefore) { + ensureNotNull("endTimeBefore", endTimeBefore); + this.endTimeBefore = endTimeBefore; + return this; + } + + public HistoricIncidentQuery endTimeAfter(Date endTimeAfter) { + ensureNotNull("endTimeAfter", endTimeAfter); + this.endTimeAfter = endTimeAfter; + return this; + } + + public HistoricIncidentQuery activityId(String activityId) { + ensureNotNull("activityId", activityId); + this.activityId = activityId; + return this; + } + + public HistoricIncidentQuery failedActivityId(String activityId) { + ensureNotNull("failedActivityId", activityId); + this.failedActivityId = activityId; + return this; + } + + public HistoricIncidentQuery processInstanceId(String processInstanceId) { + ensureNotNull("processInstanceId", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + public HistoricIncidentQuery processDefinitionId(String processDefinitionId) { + ensureNotNull("processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + public HistoricIncidentQuery processDefinitionKey(String processDefinitionKey) { + ensureNotNull("processDefinitionKey", processDefinitionKey); + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public HistoricIncidentQuery processDefinitionKeyIn(String... processDefinitionKeys) { + ensureNotNull("processDefinitionKeys", (Object[]) processDefinitionKeys); + this.processDefinitionKeys = processDefinitionKeys; + return this; + } + + + public HistoricIncidentQuery causeIncidentId(String causeIncidentId) { + ensureNotNull("causeIncidentId", causeIncidentId); + this.causeIncidentId = causeIncidentId; + return this; + } + + public HistoricIncidentQuery rootCauseIncidentId(String rootCauseIncidentId) { + ensureNotNull("rootCauseIncidentId", rootCauseIncidentId); + this.rootCauseIncidentId = rootCauseIncidentId; + return this; + } + + public HistoricIncidentQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricIncidentQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + public HistoricIncidentQuery configuration(String configuration) { + ensureNotNull("configuration", configuration); + this.configuration = configuration; + return this; + } + + public HistoricIncidentQuery historyConfiguration(String historyConfiguration) { + ensureNotNull("historyConfiguration", historyConfiguration); + this.historyConfiguration = historyConfiguration; + return this; + } + + public HistoricIncidentQuery jobDefinitionIdIn(String... jobDefinitionIds) { + ensureNotNull("jobDefinitionIds", (Object[]) jobDefinitionIds); + this.jobDefinitionIds = jobDefinitionIds; + return this; + } + + public HistoricIncidentQuery open() { + if (incidentState != null) { + throw new ProcessEngineException("Already querying for incident state <" + incidentState + ">"); + } + incidentState = IncidentState.DEFAULT; + return this; + } + + public HistoricIncidentQuery resolved() { + if (incidentState != null) { + throw new ProcessEngineException("Already querying for incident state <" + incidentState + ">"); + } + incidentState = IncidentState.RESOLVED; + return this; + } + + public HistoricIncidentQuery deleted() { + if (incidentState != null) { + throw new ProcessEngineException("Already querying for incident state <" + incidentState + ">"); + } + incidentState = IncidentState.DELETED; + return this; + } + + // ordering //////////////////////////////////////////////////// + + public HistoricIncidentQuery orderByIncidentId() { + orderBy(HistoricIncidentQueryProperty.INCIDENT_ID); + return this; + } + + @Override + public HistoricIncidentQuery orderByIncidentMessage() { + orderBy(HistoricIncidentQueryProperty.INCIDENT_MESSAGE); + return this; + } + + + public HistoricIncidentQuery orderByCreateTime() { + orderBy(HistoricIncidentQueryProperty.INCIDENT_CREATE_TIME); + return this; + } + + public HistoricIncidentQuery orderByEndTime() { + orderBy(HistoricIncidentQueryProperty.INCIDENT_END_TIME); + return this; + } + + public HistoricIncidentQuery orderByIncidentType() { + orderBy(HistoricIncidentQueryProperty.INCIDENT_TYPE); + return this; + } + + public HistoricIncidentQuery orderByExecutionId() { + orderBy(HistoricIncidentQueryProperty.EXECUTION_ID); + return this; + } + + public HistoricIncidentQuery orderByActivityId() { + orderBy(HistoricIncidentQueryProperty.ACTIVITY_ID); + return this; + } + + public HistoricIncidentQuery orderByProcessInstanceId() { + orderBy(HistoricIncidentQueryProperty.PROCESS_INSTANCE_ID); + return this; + } + + public HistoricIncidentQuery orderByProcessDefinitionKey() { + orderBy(HistoricIncidentQueryProperty.PROCESS_DEFINITION_KEY); + return this; + } + + public HistoricIncidentQuery orderByProcessDefinitionId() { + orderBy(HistoricIncidentQueryProperty.PROCESS_DEFINITION_ID); + return this; + } + + public HistoricIncidentQuery orderByCauseIncidentId() { + orderBy(HistoricIncidentQueryProperty.CAUSE_INCIDENT_ID); + return this; + } + + public HistoricIncidentQuery orderByRootCauseIncidentId() { + orderBy(HistoricIncidentQueryProperty.ROOT_CAUSE_INCIDENT_ID); + return this; + } + + public HistoricIncidentQuery orderByConfiguration() { + orderBy(HistoricIncidentQueryProperty.CONFIGURATION); + return this; + } + + public HistoricIncidentQuery orderByHistoryConfiguration() { + orderBy(HistoricIncidentQueryProperty.HISTORY_CONFIGURATION); + return this; + } + + public HistoricIncidentQuery orderByIncidentState() { + orderBy(HistoricIncidentQueryProperty.INCIDENT_STATE); + return this; + } + + public HistoricIncidentQuery orderByTenantId() { + return orderBy(HistoricIncidentQueryProperty.TENANT_ID); + } + + // results //////////////////////////////////////////////////// + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricIncidentManager() + .findHistoricIncidentCountByQueryCriteria(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getHistoricIncidentManager() + .findHistoricIncidentByQueryCriteria(this, page); + } + + + // getters ///////////////////////////////////////////////////// + + public String getId() { + return id; + } + + public String getIncidentType() { + return incidentType; + } + + public String getIncidentMessage() { + return incidentMessage; + } + + public String getExecutionId() { + return executionId; + } + + public String getActivityId() { + return activityId; + } + + public String getFailedActivityId() { + return failedActivityId; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String[] getProcessDefinitionKeys() { + return processDefinitionKeys; + } + + public String getCauseIncidentId() { + return causeIncidentId; + } + + public String getRootCauseIncidentId() { + return rootCauseIncidentId; + } + + public String getConfiguration() { + return configuration; + } + + public String getHistoryConfiguration() { + return historyConfiguration; + } + + public IncidentState getIncidentState() { + return incidentState; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIncidentQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIncidentQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..638b67580eea39e7a445019905e48594b5d39a57 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricIncidentQueryProperty.java @@ -0,0 +1,44 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * @author Roman Smirnov + * + */ +public interface HistoricIncidentQueryProperty { + + public static final QueryProperty INCIDENT_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty INCIDENT_MESSAGE = new QueryPropertyImpl("INCIDENT_MSG_"); + public static final QueryProperty INCIDENT_CREATE_TIME = new QueryPropertyImpl("CREATE_TIME_"); + public static final QueryProperty INCIDENT_END_TIME = new QueryPropertyImpl("END_TIME_"); + public static final QueryProperty INCIDENT_TYPE = new QueryPropertyImpl("INCIDENT_TYPE_"); + public static final QueryProperty EXECUTION_ID = new QueryPropertyImpl("EXECUTION_ID_"); + public static final QueryProperty ACTIVITY_ID = new QueryPropertyImpl("ACTIVITY_ID_"); + public static final QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROC_INST_ID_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("PROC_DEF_ID_"); + public static final QueryProperty PROCESS_DEFINITION_KEY = new QueryPropertyImpl("PROC_DEF_KEY_"); + public static final QueryProperty CAUSE_INCIDENT_ID = new QueryPropertyImpl("CAUSE_INCIDENT_ID_"); + public static final QueryProperty ROOT_CAUSE_INCIDENT_ID = new QueryPropertyImpl("ROOT_CAUSE_INCIDENT_ID_"); + public static final QueryProperty HISTORY_CONFIGURATION = new QueryPropertyImpl("HISTORY_CONFIGURATION_"); + public static final QueryProperty CONFIGURATION = new QueryPropertyImpl("CONFIGURATION_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + public static final QueryProperty INCIDENT_STATE = new QueryPropertyImpl("INCIDENT_STATE_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricJobLogQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricJobLogQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..2cd50a4f800f7030e86f8582592c89f5b311ae32 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricJobLogQueryImpl.java @@ -0,0 +1,377 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotContainsEmptyString; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotContainsNull; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotEmpty; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.List; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.HistoricJobLog; +import org.camunda.bpm.engine.history.HistoricJobLogQuery; +import org.camunda.bpm.engine.history.JobState; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.CollectionUtil; +import org.camunda.bpm.engine.impl.util.CompareUtil; + +/** + * @author Roman Smirnov + * + */ +public class HistoricJobLogQueryImpl extends AbstractQuery implements HistoricJobLogQuery { + + private static final long serialVersionUID = 1L; + + protected String id; + protected String jobId; + protected String jobExceptionMessage; + protected String jobDefinitionId; + protected String jobDefinitionType; + protected String jobDefinitionConfiguration; + protected String[] activityIds; + protected String[] failedActivityIds; + protected String[] executionIds; + protected String processInstanceId; + protected String processDefinitionId; + protected String processDefinitionKey; + protected String deploymentId; + protected JobState state; + protected Long jobPriorityHigherThanOrEqual; + protected Long jobPriorityLowerThanOrEqual; + protected String[] tenantIds; + protected boolean isTenantIdSet; + protected String hostname; + + public HistoricJobLogQueryImpl() { + } + + public HistoricJobLogQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + // query parameter //////////////////////////////////////////// + + public HistoricJobLogQuery logId(String historicJobLogId) { + ensureNotNull(NotValidException.class, "historicJobLogId", historicJobLogId); + this.id = historicJobLogId; + return this; + } + + public HistoricJobLogQuery jobId(String jobId) { + ensureNotNull(NotValidException.class, "jobId", jobId); + this.jobId = jobId; + return this; + } + + public HistoricJobLogQuery jobExceptionMessage(String jobExceptionMessage) { + ensureNotNull(NotValidException.class, "jobExceptionMessage", jobExceptionMessage); + this.jobExceptionMessage = jobExceptionMessage; + return this; + } + + public HistoricJobLogQuery jobDefinitionId(String jobDefinitionId) { + ensureNotNull(NotValidException.class, "jobDefinitionId", jobDefinitionId); + this.jobDefinitionId = jobDefinitionId; + return this; + } + + public HistoricJobLogQuery jobDefinitionType(String jobDefinitionType) { + ensureNotNull(NotValidException.class, "jobDefinitionType", jobDefinitionType); + this.jobDefinitionType = jobDefinitionType; + return this; + } + + public HistoricJobLogQuery jobDefinitionConfiguration(String jobDefinitionConfiguration) { + ensureNotNull(NotValidException.class, "jobDefinitionConfiguration", jobDefinitionConfiguration); + this.jobDefinitionConfiguration = jobDefinitionConfiguration; + return this; + } + + public HistoricJobLogQuery activityIdIn(String... activityIds) { + List activityIdList = CollectionUtil.asArrayList(activityIds); + ensureNotContainsNull("activityIds", activityIdList); + ensureNotContainsEmptyString("activityIds", activityIdList); + this.activityIds = activityIds; + return this; + } + + public HistoricJobLogQuery failedActivityIdIn(String... activityIds) { + List activityIdList = CollectionUtil.asArrayList(activityIds); + ensureNotContainsNull("activityIds", activityIdList); + ensureNotContainsEmptyString("activityIds", activityIdList); + this.failedActivityIds = activityIds; + return this; + } + + public HistoricJobLogQuery executionIdIn(String... executionIds) { + List executionIdList = CollectionUtil.asArrayList(executionIds); + ensureNotContainsNull("executionIds", executionIdList); + ensureNotContainsEmptyString("executionIds", executionIdList); + this.executionIds = executionIds; + return this; + } + + public HistoricJobLogQuery processInstanceId(String processInstanceId) { + ensureNotNull(NotValidException.class, "processInstanceId", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + public HistoricJobLogQuery processDefinitionId(String processDefinitionId) { + ensureNotNull(NotValidException.class, "processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + public HistoricJobLogQuery processDefinitionKey(String processDefinitionKey) { + ensureNotNull(NotValidException.class, "processDefinitionKey", processDefinitionKey); + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public HistoricJobLogQuery deploymentId(String deploymentId) { + ensureNotNull(NotValidException.class, "deploymentId", deploymentId); + this.deploymentId = deploymentId; + return this; + } + + public HistoricJobLogQuery jobPriorityHigherThanOrEquals(long priority) { + this.jobPriorityHigherThanOrEqual = priority; + return this; + } + + public HistoricJobLogQuery jobPriorityLowerThanOrEquals(long priority) { + this.jobPriorityLowerThanOrEqual = priority; + return this; + } + + public HistoricJobLogQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricJobLogQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricJobLogQuery hostname(String hostname) { + ensureNotEmpty("hostName", hostname); + this.hostname = hostname; + return this; + } + + public HistoricJobLogQuery creationLog() { + setState(JobState.CREATED); + return this; + } + + public HistoricJobLogQuery failureLog() { + setState(JobState.FAILED); + return this; + } + + public HistoricJobLogQuery successLog() { + setState(JobState.SUCCESSFUL); + return this; + } + + public HistoricJobLogQuery deletionLog() { + setState(JobState.DELETED); + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() + || CompareUtil.areNotInAscendingOrder(jobPriorityHigherThanOrEqual, jobPriorityLowerThanOrEqual); + } + + // order by ////////////////////////////////////////////// + + public HistoricJobLogQuery orderByTimestamp() { + orderBy(HistoricJobLogQueryProperty.TIMESTAMP); + return this; + } + + public HistoricJobLogQuery orderByJobId() { + orderBy(HistoricJobLogQueryProperty.JOB_ID); + return this; + } + + public HistoricJobLogQuery orderByJobDueDate() { + orderBy(HistoricJobLogQueryProperty.DUEDATE); + return this; + } + + public HistoricJobLogQuery orderByJobRetries() { + orderBy(HistoricJobLogQueryProperty.RETRIES); + return this; + } + + public HistoricJobLogQuery orderByJobPriority() { + orderBy(HistoricJobLogQueryProperty.PRIORITY); + return this; + } + + public HistoricJobLogQuery orderByJobDefinitionId() { + orderBy(HistoricJobLogQueryProperty.JOB_DEFINITION_ID); + return this; + } + + public HistoricJobLogQuery orderByActivityId() { + orderBy(HistoricJobLogQueryProperty.ACTIVITY_ID); + return this; + } + + public HistoricJobLogQuery orderByExecutionId() { + orderBy(HistoricJobLogQueryProperty.EXECUTION_ID); + return this; + } + + public HistoricJobLogQuery orderByProcessInstanceId() { + orderBy(HistoricJobLogQueryProperty.PROCESS_INSTANCE_ID); + return this; + } + + public HistoricJobLogQuery orderByProcessDefinitionId() { + orderBy(HistoricJobLogQueryProperty.PROCESS_DEFINITION_ID); + return this; + } + + public HistoricJobLogQuery orderByProcessDefinitionKey() { + orderBy(HistoricJobLogQueryProperty.PROCESS_DEFINITION_KEY); + return this; + } + + public HistoricJobLogQuery orderByDeploymentId() { + orderBy(HistoricJobLogQueryProperty.DEPLOYMENT_ID); + return this; + } + + public HistoricJobLogQuery orderPartiallyByOccurrence() { + orderBy(HistoricJobLogQueryProperty.SEQUENCE_COUNTER); + return this; + } + + public HistoricJobLogQuery orderByTenantId() { + return orderBy(HistoricJobLogQueryProperty.TENANT_ID); + } + + @Override + public HistoricJobLogQuery orderByHostname() { + return orderBy(HistoricJobLogQueryProperty.HOSTNAME); + } + + // results ////////////////////////////////////////////////////////////// + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricJobLogManager() + .findHistoricJobLogsCountByQueryCriteria(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getHistoricJobLogManager() + .findHistoricJobLogsByQueryCriteria(this, page); + } + + // getter ////////////////////////////////// + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public String getJobId() { + return jobId; + } + + public String getJobExceptionMessage() { + return jobExceptionMessage; + } + + public String getJobDefinitionId() { + return jobDefinitionId; + } + + public String getJobDefinitionType() { + return jobDefinitionType; + } + + public String getJobDefinitionConfiguration() { + return jobDefinitionConfiguration; + } + + public String[] getActivityIds() { + return activityIds; + } + + public String[] getFailedActivityIds() { + return failedActivityIds; + } + + public String[] getExecutionIds() { + return executionIds; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public String getDeploymentId() { + return deploymentId; + } + + public JobState getState() { + return state; + } + + public String[] getTenantIds() { + return tenantIds; + } + + public String getHostname() { + return hostname; + } + + // setter ////////////////////////////////// + + protected void setState(JobState state) { + this.state = state; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricJobLogQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricJobLogQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..2a0088742d13802d36b6952bea7fc91cd5b6314e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricJobLogQueryProperty.java @@ -0,0 +1,43 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * @author Roman Smirnov + * + */ +public interface HistoricJobLogQueryProperty { + + public static final QueryProperty JOB_ID = new QueryPropertyImpl("JOB_ID_"); + public static final QueryProperty JOB_DEFINITION_ID = new QueryPropertyImpl("JOB_DEF_ID_"); + public static final QueryProperty TIMESTAMP = new QueryPropertyImpl("TIMESTAMP_"); + public static final QueryProperty ACTIVITY_ID = new QueryPropertyImpl("ACT_ID_"); + public static final QueryProperty EXECUTION_ID = new QueryPropertyImpl("EXECUTION_ID_"); + public static final QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROCESS_INSTANCE_ID_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("PROCESS_DEF_ID_"); + public static final QueryProperty PROCESS_DEFINITION_KEY = new QueryPropertyImpl("PROCESS_DEF_KEY_"); + public static final QueryProperty DEPLOYMENT_ID = new QueryPropertyImpl("DEPLOYMENT_ID_"); + public static final QueryProperty DUEDATE = new QueryPropertyImpl("JOB_DUEDATE_"); + public static final QueryProperty RETRIES = new QueryPropertyImpl("JOB_RETRIES_"); + public static final QueryProperty PRIORITY = new QueryPropertyImpl("JOB_PRIORITY_"); + public static final QueryProperty SEQUENCE_COUNTER = new QueryPropertyImpl("SEQUENCE_COUNTER_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + public static final QueryProperty HOSTNAME = new QueryPropertyImpl("HOSTNAME_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricProcessInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricProcessInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..c1dbc0ad7c383d8f1e42354b525a70ca82e6f21a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricProcessInstanceQueryImpl.java @@ -0,0 +1,899 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotContainsEmptyString; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotContainsNull; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotEmpty; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureEmpty; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.ImmutablePair; +import org.camunda.bpm.engine.impl.util.CompareUtil; +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; + +/** + * @author Tom Baeyens + * @author Falko Menge + * @author Bernd Ruecker + */ +public class HistoricProcessInstanceQueryImpl extends AbstractVariableQueryImpl implements HistoricProcessInstanceQuery { + + private static final long serialVersionUID = 1L; + protected String processInstanceId; + protected String rootProcessInstanceId; + protected String processDefinitionId; + protected String processDefinitionName; + protected String processDefinitionNameLike; + protected String businessKey; + protected String[] businessKeyIn; + protected String businessKeyLike; + protected boolean finished = false; + protected boolean unfinished = false; + protected boolean withJobsRetrying = false; + protected boolean withIncidents = false; + protected boolean withRootIncidents = false; + protected String incidentType; + protected String incidentStatus; + protected String incidentMessage; + protected String incidentMessageLike; + protected String startedBy; + protected boolean isRootProcessInstances; + protected String superProcessInstanceId; + protected String subProcessInstanceId; + protected String superCaseInstanceId; + protected String subCaseInstanceId; + protected List processKeyNotIn; + protected Date startedBefore; + protected Date startedAfter; + protected Date finishedBefore; + protected Date finishedAfter; + protected Date executedActivityAfter; + protected Date executedActivityBefore; + protected Date executedJobAfter; + protected Date executedJobBefore; + protected String processDefinitionKey; + protected String[] processDefinitionKeys; + protected Set processInstanceIds; + protected String[] processInstanceIdNotIn; + protected String[] tenantIds; + protected boolean isTenantIdSet; + protected String[] executedActivityIds; + protected String[] activeActivityIds; + protected String[] activityIds; + protected String[] incidentIds; + protected Set state = new HashSet<>(); + + protected String caseInstanceId; + + protected List queries = new ArrayList<>(Collections.singletonList(this)); + protected boolean isOrQueryActive = false; + + protected Map> queryVariableNameToValuesMap = new HashMap<>(); + + public HistoricProcessInstanceQueryImpl() { + } + + public HistoricProcessInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public HistoricProcessInstanceQueryImpl processInstanceId(String processInstanceId) { + this.processInstanceId = processInstanceId; + return this; + } + + public HistoricProcessInstanceQuery processInstanceIds(Set processInstanceIds) { + ensureNotEmpty("Set of process instance ids", processInstanceIds); + this.processInstanceIds = processInstanceIds; + return this; + } + + public HistoricProcessInstanceQuery processInstanceIdNotIn(String... processInstanceIdNotIn){ + ensureNotNull("processInstanceIdNotIn", (Object[]) processInstanceIdNotIn); + this.processInstanceIdNotIn = processInstanceIdNotIn; + return this; + } + + public HistoricProcessInstanceQuery rootProcessInstanceId(String rootProcessInstanceId) { + ensureNotNull("Root process instance id", rootProcessInstanceId); + this.rootProcessInstanceId = rootProcessInstanceId; + return this; + } + + public HistoricProcessInstanceQueryImpl processDefinitionId(String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + return this; + } + + public HistoricProcessInstanceQuery processDefinitionKey(String processDefinitionKey) { + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public HistoricProcessInstanceQuery processDefinitionKeyIn(String... processDefinitionKeys) { + ensureNotNull("processDefinitionKeys", (Object[]) processDefinitionKeys); + this.processDefinitionKeys = processDefinitionKeys; + return this; + } + + public HistoricProcessInstanceQuery processDefinitionName(String processDefinitionName) { + this.processDefinitionName = processDefinitionName; + return this; + } + + public HistoricProcessInstanceQuery processDefinitionNameLike(String nameLike) { + this.processDefinitionNameLike = nameLike; + return this; + } + + public HistoricProcessInstanceQuery processInstanceBusinessKey(String businessKey) { + this.businessKey = businessKey; + return this; + } + + public HistoricProcessInstanceQuery processInstanceBusinessKeyIn(String... businessKeyIn) { + this.businessKeyIn = businessKeyIn; + return this; + } + + public HistoricProcessInstanceQuery processInstanceBusinessKeyLike(String businessKeyLike) { + this.businessKeyLike = businessKeyLike; + return this; + } + + public HistoricProcessInstanceQuery finished() { + this.finished = true; + return this; + } + + public HistoricProcessInstanceQuery unfinished() { + this.unfinished = true; + return this; + } + + public HistoricProcessInstanceQuery withIncidents() { + this.withIncidents = true; + + return this; + } + + public HistoricProcessInstanceQuery withRootIncidents() { + this.withRootIncidents = true; + return this; + } + + public HistoricProcessInstanceQuery incidentIdIn(String... incidentIds) { + ensureNotNull("incidentIds", (Object[]) incidentIds); + this.incidentIds = incidentIds; + return this; + } + + public HistoricProcessInstanceQuery incidentType(String incidentType) { + ensureNotNull("incident type", incidentType); + this.incidentType = incidentType; + return this; + } + + @Override + public HistoricProcessInstanceQuery incidentStatus(String status) { + this.incidentStatus = status; + return this; + } + + public HistoricProcessInstanceQuery incidentMessage(String incidentMessage) { + ensureNotNull("incidentMessage", incidentMessage); + this.incidentMessage = incidentMessage; + + return this; + } + + public HistoricProcessInstanceQuery incidentMessageLike(String incidentMessageLike) { + ensureNotNull("incidentMessageLike", incidentMessageLike); + this.incidentMessageLike = incidentMessageLike; + + return this; + } + + @Override + public HistoricProcessInstanceQuery withJobsRetrying(){ + this.withJobsRetrying = true; + return this; + } + + public HistoricProcessInstanceQuery startedBy(String userId) { + this.startedBy = userId; + return this; + } + + public HistoricProcessInstanceQuery processDefinitionKeyNotIn(List processDefinitionKeys) { + ensureNotContainsNull("processDefinitionKeys", processDefinitionKeys); + ensureNotContainsEmptyString("processDefinitionKeys", processDefinitionKeys); + this.processKeyNotIn = processDefinitionKeys; + return this; + } + + public HistoricProcessInstanceQuery startedAfter(Date date) { + startedAfter = date; + return this; + } + + public HistoricProcessInstanceQuery startedBefore(Date date) { + startedBefore = date; + return this; + } + + public HistoricProcessInstanceQuery finishedAfter(Date date) { + finishedAfter = date; + finished = true; + return this; + } + + public HistoricProcessInstanceQuery finishedBefore(Date date) { + finishedBefore = date; + finished = true; + return this; + } + + public HistoricProcessInstanceQuery rootProcessInstances() { + if (superProcessInstanceId != null) { + throw new BadUserRequestException("Invalid query usage: cannot set both rootProcessInstances and superProcessInstanceId"); + } + if (superCaseInstanceId != null) { + throw new BadUserRequestException("Invalid query usage: cannot set both rootProcessInstances and superCaseInstanceId"); + } + isRootProcessInstances = true; + return this; + } + + public HistoricProcessInstanceQuery superProcessInstanceId(String superProcessInstanceId) { + if (isRootProcessInstances) { + throw new BadUserRequestException("Invalid query usage: cannot set both rootProcessInstances and superProcessInstanceId"); + } + this.superProcessInstanceId = superProcessInstanceId; + return this; + } + + public HistoricProcessInstanceQuery subProcessInstanceId(String subProcessInstanceId) { + this.subProcessInstanceId = subProcessInstanceId; + return this; + } + + public HistoricProcessInstanceQuery superCaseInstanceId(String superCaseInstanceId) { + if (isRootProcessInstances) { + throw new BadUserRequestException("Invalid query usage: cannot set both rootProcessInstances and superCaseInstanceId"); + } + this.superCaseInstanceId = superCaseInstanceId; + return this; + } + + public HistoricProcessInstanceQuery subCaseInstanceId(String subCaseInstanceId) { + this.subCaseInstanceId = subCaseInstanceId; + return this; + } + + public HistoricProcessInstanceQuery caseInstanceId(String caseInstanceId) { + this.caseInstanceId = caseInstanceId; + return this; + } + + public HistoricProcessInstanceQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + public HistoricProcessInstanceQuery withoutTenantId() { + tenantIds = null; + isTenantIdSet = true; + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() + || (finished && unfinished) + || CompareUtil.areNotInAscendingOrder(startedAfter, startedBefore) + || CompareUtil.areNotInAscendingOrder(finishedAfter, finishedBefore) + || CompareUtil.elementIsContainedInList(processDefinitionKey, processKeyNotIn) + || CompareUtil.elementIsNotContainedInList(processInstanceId, processInstanceIds) + || CompareUtil.elementIsContainedInArray(processInstanceId, processInstanceIdNotIn) + || CompareUtil.elementsAreContainedInArray(processInstanceIds, processInstanceIdNotIn); + } + + public HistoricProcessInstanceQuery orderByProcessInstanceBusinessKey() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessInstanceBusinessKey() within 'or' query"); + } + return orderBy(HistoricProcessInstanceQueryProperty.BUSINESS_KEY); + } + + public HistoricProcessInstanceQuery orderByProcessInstanceDuration() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessInstanceDuration() within 'or' query"); + } + return orderBy(HistoricProcessInstanceQueryProperty.DURATION); + } + + public HistoricProcessInstanceQuery orderByProcessInstanceStartTime() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessInstanceStartTime() within 'or' query"); + } + return orderBy(HistoricProcessInstanceQueryProperty.START_TIME); + } + + public HistoricProcessInstanceQuery orderByProcessInstanceEndTime() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessInstanceEndTime() within 'or' query"); + } + return orderBy(HistoricProcessInstanceQueryProperty.END_TIME); + } + + public HistoricProcessInstanceQuery orderByProcessDefinitionId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessDefinitionId() within 'or' query"); + } + return orderBy(HistoricProcessInstanceQueryProperty.PROCESS_DEFINITION_ID); + } + + public HistoricProcessInstanceQuery orderByProcessDefinitionKey() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessDefinitionKey() within 'or' query"); + } + return orderBy(HistoricProcessInstanceQueryProperty.PROCESS_DEFINITION_KEY); + } + + public HistoricProcessInstanceQuery orderByProcessDefinitionName() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessDefinitionName() within 'or' query"); + } + return orderBy(HistoricProcessInstanceQueryProperty.PROCESS_DEFINITION_NAME); + } + + public HistoricProcessInstanceQuery orderByProcessDefinitionVersion() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessDefinitionVersion() within 'or' query"); + } + return orderBy(HistoricProcessInstanceQueryProperty.PROCESS_DEFINITION_VERSION); + } + + public HistoricProcessInstanceQuery orderByProcessInstanceId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessInstanceId() within 'or' query"); + } + return orderBy(HistoricProcessInstanceQueryProperty.PROCESS_INSTANCE_ID_); + } + + public HistoricProcessInstanceQuery orderByTenantId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTenantId() within 'or' query"); + } + return orderBy(HistoricProcessInstanceQueryProperty.TENANT_ID); + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + ensureVariablesInitialized(); + return commandContext + .getHistoricProcessInstanceManager() + .findHistoricProcessInstanceCountByQueryCriteria(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + ensureVariablesInitialized(); + return commandContext + .getHistoricProcessInstanceManager() + .findHistoricProcessInstancesByQueryCriteria(this, page); + } + + public List executeIdsList(CommandContext commandContext) { + checkQueryOk(); + ensureVariablesInitialized(); + return commandContext + .getHistoricProcessInstanceManager() + .findHistoricProcessInstanceIds(this); + } + + @Override + public List> executeDeploymentIdMappingsList(CommandContext commandContext) { + checkQueryOk(); + ensureVariablesInitialized(); + return commandContext + .getHistoricProcessInstanceManager() + .findDeploymentIdMappingsByQueryCriteria(this); + } + + public List getQueryVariableValues() { + return queryVariableNameToValuesMap.values() + .stream() + .flatMap(Set::stream) + .collect(Collectors.toList()); + } + + public Map> getQueryVariableNameToValuesMap() { + return queryVariableNameToValuesMap; + } + + @Override + protected void ensureVariablesInitialized() { + super.ensureVariablesInitialized(); + + if (!queries.isEmpty()) { + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + VariableSerializers variableSerializers = processEngineConfiguration.getVariableSerializers(); + String dbType = processEngineConfiguration.getDatabaseType(); + + for (HistoricProcessInstanceQueryImpl orQuery: queries) { + for (QueryVariableValue var : orQuery.getQueryVariableValues()) { + var.initialize(variableSerializers, dbType); + } + } + } + } + + @Override + protected void addVariable(String name, Object value, QueryOperator operator, boolean processInstanceScope) { + QueryVariableValue queryVariableValue = createQueryVariableValue(name, value, operator, processInstanceScope); + + Set queryVariableValues = queryVariableNameToValuesMap.get(name); + if (queryVariableValues == null) { + queryVariableNameToValuesMap.put(name, new HashSet<>(Collections.singletonList(queryVariableValue))); + + } else { + queryVariableValues.add(queryVariableValue); + + } + } + + public List getQueries() { + return queries; + } + + public void addOrQuery(HistoricProcessInstanceQueryImpl orQuery) { + orQuery.isOrQueryActive = true; + this.queries.add(orQuery); + } + + public void setOrQueryActive() { + isOrQueryActive = true; + } + + public boolean isOrQueryActive() { + return isOrQueryActive; + } + + public String[] getActiveActivityIds() { + return activeActivityIds; + } + + public String[] getActivityIds() { + return activityIds; + } + + public String getBusinessKey() { + return businessKey; + } + + public String[] getBusinessKeyIn() { + return businessKeyIn; + } + + public String getBusinessKeyLike() { + return businessKeyLike; + } + + public String[] getExecutedActivityIds() { + return executedActivityIds; + } + + public Date getExecutedActivityAfter() { + return executedActivityAfter; + } + + public Date getExecutedActivityBefore() { + return executedActivityBefore; + } + + public Date getExecutedJobAfter() { + return executedJobAfter; + } + + public Date getExecutedJobBefore() { + return executedJobBefore; + } + + public boolean isOpen() { + return unfinished; + } + + public boolean isUnfinished() { + return unfinished; + } + + public boolean isFinished() { + return finished; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public String[] getProcessDefinitionKeys() { + return processDefinitionKeys; + } + + public String getProcessDefinitionIdLike() { + return processDefinitionKey + ":%:%"; + } + + public String getProcessDefinitionName() { + return processDefinitionName; + } + + public String getProcessDefinitionNameLike() { + return processDefinitionNameLike; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getRootProcessInstanceId() { + return rootProcessInstanceId; + } + + public Set getProcessInstanceIds() { + return processInstanceIds; + } + + public String[] getProcessInstanceIdNotIn() { + return processInstanceIdNotIn; + } + + public String getStartedBy() { + return startedBy; + } + + public String getSuperProcessInstanceId() { + return superProcessInstanceId; + } + + public void setSuperProcessInstanceId(String superProcessInstanceId) { + this.superProcessInstanceId = superProcessInstanceId; + } + + public List getProcessKeyNotIn() { + return processKeyNotIn; + } + + public Date getStartedAfter() { + return startedAfter; + } + + public Date getStartedBefore() { + return startedBefore; + } + + public Date getFinishedAfter() { + return finishedAfter; + } + + public Date getFinishedBefore() { + return finishedBefore; + } + + public String getCaseInstanceId() { + return caseInstanceId; + } + + public String getIncidentType() { + return incidentType; + } + + public String getIncidentMessage() { + return this.incidentMessage; + } + + public String getIncidentMessageLike() { + return this.incidentMessageLike; + } + + public String getIncidentStatus() { + return incidentStatus; + } + + public Set getState() { + return state; + } + + public Date getFinishDateBy() { + return finishDateBy; + } + + public Date getStartDateBy() { + return startDateBy; + } + + public Date getStartDateOn() { + return startDateOn; + } + + public Date getStartDateOnBegin() { + return startDateOnBegin; + } + + public Date getStartDateOnEnd() { + return startDateOnEnd; + } + + public Date getFinishDateOn() { + return finishDateOn; + } + + public Date getFinishDateOnBegin() { + return finishDateOnBegin; + } + + public Date getFinishDateOnEnd() { + return finishDateOnEnd; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public boolean getIsTenantIdSet() { + return isTenantIdSet; + } + + public boolean isWithJobsRetrying(){ + return withJobsRetrying; + } + + public boolean isWithIncidents() { + return withIncidents; + } + + public boolean isWithRootIncidents() { + return withRootIncidents; + } + + // below is deprecated and to be removed in 5.12 + + protected Date startDateBy; + protected Date startDateOn; + protected Date finishDateBy; + protected Date finishDateOn; + protected Date startDateOnBegin; + protected Date startDateOnEnd; + protected Date finishDateOnBegin; + protected Date finishDateOnEnd; + + @Deprecated + public HistoricProcessInstanceQuery startDateBy(Date date) { + this.startDateBy = this.calculateMidnight(date); + return this; + } + + @Deprecated + public HistoricProcessInstanceQuery startDateOn(Date date) { + this.startDateOn = date; + this.startDateOnBegin = this.calculateMidnight(date); + this.startDateOnEnd = this.calculateBeforeMidnight(date); + return this; + } + + @Deprecated + public HistoricProcessInstanceQuery finishDateBy(Date date) { + this.finishDateBy = this.calculateBeforeMidnight(date); + return this; + } + + @Deprecated + public HistoricProcessInstanceQuery finishDateOn(Date date) { + this.finishDateOn = date; + this.finishDateOnBegin = this.calculateMidnight(date); + this.finishDateOnEnd = this.calculateBeforeMidnight(date); + return this; + } + + @Deprecated + private Date calculateBeforeMidnight(Date date){ + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.add(Calendar.DAY_OF_MONTH, 1); + cal.add(Calendar.SECOND, -1); + return cal.getTime(); + } + + @Deprecated + private Date calculateMidnight(Date date){ + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + cal.set(Calendar.MILLISECOND, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.HOUR, 0); + return cal.getTime(); + } + + public boolean isRootProcessInstances() { + return isRootProcessInstances; + } + + public String getSubProcessInstanceId() { + return subProcessInstanceId; + } + + public String getSuperCaseInstanceId() { + return superCaseInstanceId; + } + + public String getSubCaseInstanceId() { + return subCaseInstanceId; + } + + public String[] getTenantIds() { + return tenantIds; + } + + public String[] getIncidentIds() { + return incidentIds; + } + + @Override + public HistoricProcessInstanceQuery executedActivityAfter(Date date) { + this.executedActivityAfter = date; + return this; + } + + @Override + public HistoricProcessInstanceQuery executedActivityBefore(Date date) { + this.executedActivityBefore = date; + return this; + } + + @Override + public HistoricProcessInstanceQuery executedJobAfter(Date date) { + this.executedJobAfter = date; + return this; + } + + @Override + public HistoricProcessInstanceQuery executedJobBefore(Date date) { + this.executedJobBefore = date; + return this; + } + + @Override + public HistoricProcessInstanceQuery executedActivityIdIn(String... ids) { + ensureNotNull(BadUserRequestException.class, "activity ids", (Object[]) ids); + ensureNotContainsNull(BadUserRequestException.class, "activity ids", Arrays.asList(ids)); + this.executedActivityIds = ids; + return this; + } + + @Override + public HistoricProcessInstanceQuery activeActivityIdIn(String... ids) { + ensureNotNull(BadUserRequestException.class, "activity ids", (Object[]) ids); + ensureNotContainsNull(BadUserRequestException.class, "activity ids", Arrays.asList(ids)); + this.activeActivityIds = ids; + return this; + } + + @Override + public HistoricProcessInstanceQuery activityIdIn(String... ids) { + ensureNotNull(BadUserRequestException.class, "activity ids", (Object[]) ids); + ensureNotContainsNull(BadUserRequestException.class, "activity ids", Arrays.asList(ids)); + this.activityIds = ids; + return this; + } + + @Override + public HistoricProcessInstanceQuery active() { + if(!isOrQueryActive) { + ensureEmpty(BadUserRequestException.class, "Already querying for historic process instance with another state", state); + } + state.add(HistoricProcessInstance.STATE_ACTIVE); + return this; + } + + @Override + public HistoricProcessInstanceQuery suspended() { + if(!isOrQueryActive) { + ensureEmpty(BadUserRequestException.class, "Already querying for historic process instance with another state", state); + } + state.add(HistoricProcessInstance.STATE_SUSPENDED); + return this; + } + + @Override + public HistoricProcessInstanceQuery completed() { + if(!isOrQueryActive) { + ensureEmpty(BadUserRequestException.class, "Already querying for historic process instance with another state", state); + } + state.add(HistoricProcessInstance.STATE_COMPLETED); + return this; + } + + @Override + public HistoricProcessInstanceQuery externallyTerminated() { + if(!isOrQueryActive) { + ensureEmpty(BadUserRequestException.class, "Already querying for historic process instance with another state", state); + } + state.add(HistoricProcessInstance.STATE_EXTERNALLY_TERMINATED); + return this; + } + + @Override + public HistoricProcessInstanceQuery internallyTerminated() { + if(!isOrQueryActive) { + ensureEmpty(BadUserRequestException.class, "Already querying for historic process instance with another state", state); + } + state.add(HistoricProcessInstance.STATE_INTERNALLY_TERMINATED); + return this; + } + + @Override + public HistoricProcessInstanceQuery or() { + if (this != queries.get(0)) { + throw new ProcessEngineException("Invalid query usage: cannot set or() within 'or' query"); + } + + HistoricProcessInstanceQueryImpl orQuery = new HistoricProcessInstanceQueryImpl(); + orQuery.isOrQueryActive = true; + orQuery.queries = queries; + queries.add(orQuery); + return orQuery; + } + + @Override + public HistoricProcessInstanceQuery endOr() { + if (!queries.isEmpty() && this != queries.get(queries.size()-1)) { + throw new ProcessEngineException("Invalid query usage: cannot set endOr() before or()"); + } + + return queries.get(0); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricProcessInstanceQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricProcessInstanceQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..edf2c1ecd7d58594197fc02fc33cdebab41bf643 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricProcessInstanceQueryProperty.java @@ -0,0 +1,40 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + + +/** + * Contains the possible properties which can be used in a {@link HistoricProcessInstanceQueryProperty}. + * + * @author Joram Barrez + */ +public interface HistoricProcessInstanceQueryProperty { + + public static final QueryProperty PROCESS_INSTANCE_ID_ = new QueryPropertyImpl("PROC_INST_ID_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("PROC_DEF_ID_"); + public static final QueryProperty PROCESS_DEFINITION_KEY = new QueryPropertyImpl("PROC_DEF_KEY_"); + public static final QueryProperty PROCESS_DEFINITION_NAME = new QueryPropertyImpl("NAME_"); + public static final QueryProperty PROCESS_DEFINITION_VERSION = new QueryPropertyImpl("VERSION_"); + public static final QueryProperty BUSINESS_KEY = new QueryPropertyImpl("BUSINESS_KEY_"); + public static final QueryProperty START_TIME = new QueryPropertyImpl("START_TIME_"); + public static final QueryProperty END_TIME = new QueryPropertyImpl("END_TIME_"); + public static final QueryProperty DURATION = new QueryPropertyImpl("DURATION_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricProcessInstanceReportImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricProcessInstanceReportImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..71cd68ffcc65898d25a1db7468b699745a94ff47 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricProcessInstanceReportImpl.java @@ -0,0 +1,185 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.CompareUtil.areNotInAscendingOrder; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.DurationReportResult; +import org.camunda.bpm.engine.history.HistoricProcessInstanceReport; +import org.camunda.bpm.engine.impl.cfg.CommandChecker; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.TenantCheck; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.query.PeriodUnit; +import org.camunda.bpm.engine.repository.ProcessDefinition; + +/** + * @author Roman Smirnov + * + */ +public class HistoricProcessInstanceReportImpl implements HistoricProcessInstanceReport { + + private static final long serialVersionUID = 1L; + + protected Date startedAfter; + protected Date startedBefore; + protected String[] processDefinitionIdIn; + protected String[] processDefinitionKeyIn; + + protected PeriodUnit durationPeriodUnit; + + protected CommandExecutor commandExecutor; + + protected TenantCheck tenantCheck = new TenantCheck(); + + public HistoricProcessInstanceReportImpl(CommandExecutor commandExecutor) { + this.commandExecutor = commandExecutor; + } + + // query parameter /////////////////////////////////////////////// + + public HistoricProcessInstanceReport startedAfter(Date startedAfter) { + ensureNotNull(NotValidException.class, "startedAfter", startedAfter); + this.startedAfter = startedAfter; + return this; + } + + public HistoricProcessInstanceReport startedBefore(Date startedBefore) { + ensureNotNull(NotValidException.class, "startedBefore", startedBefore); + this.startedBefore = startedBefore; + return this; + } + + public HistoricProcessInstanceReport processDefinitionIdIn(String... processDefinitionIds) { + ensureNotNull(NotValidException.class, "", "processDefinitionIdIn", (Object[]) processDefinitionIds); + this.processDefinitionIdIn = processDefinitionIds; + return this; + } + + public HistoricProcessInstanceReport processDefinitionKeyIn(String... processDefinitionKeys) { + ensureNotNull(NotValidException.class, "", "processDefinitionKeyIn", (Object[]) processDefinitionKeys); + this.processDefinitionKeyIn = processDefinitionKeys; + return this; + } + + // report execution ///////////////////////////////////////////// + + public List duration(PeriodUnit periodUnit) { + ensureNotNull(NotValidException.class, "periodUnit", periodUnit); + this.durationPeriodUnit = periodUnit; + + CommandContext commandContext = Context.getCommandContext(); + + if(commandContext == null) { + return commandExecutor.execute(new ExecuteDurationReportCmd()); + } + else { + return executeDurationReport(commandContext); + } + + } + + public List executeDurationReport(CommandContext commandContext) { + + doAuthCheck(commandContext); + + if(areNotInAscendingOrder(startedAfter, startedBefore)) { + return Collections.emptyList(); + } + + return commandContext + .getHistoricReportManager() + .selectHistoricProcessInstanceDurationReport(this); + + } + + protected void doAuthCheck(CommandContext commandContext) { + // since a report does only make sense in context of historic + // data, the authorization check will be performed here + for (CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { + if (processDefinitionIdIn == null && processDefinitionKeyIn == null) { + checker.checkReadHistoryAnyProcessDefinition(); + } else { + List processDefinitionKeys = new ArrayList(); + if (processDefinitionKeyIn != null) { + processDefinitionKeys.addAll(Arrays.asList(processDefinitionKeyIn)); + } + + if (processDefinitionIdIn != null) { + for (String processDefinitionId : processDefinitionIdIn) { + ProcessDefinition processDefinition = commandContext.getProcessDefinitionManager() + .findLatestProcessDefinitionById(processDefinitionId); + + if (processDefinition != null && processDefinition.getKey() != null) { + processDefinitionKeys.add(processDefinition.getKey()); + } + } + } + + if (!processDefinitionKeys.isEmpty()) { + for (String processDefinitionKey : processDefinitionKeys) { + checker.checkReadHistoryProcessDefinition(processDefinitionKey); + } + } + } + } + } + + // getter ////////////////////////////////////////////////////// + + public Date getStartedAfter() { + return startedAfter; + } + + public Date getStartedBefore() { + return startedBefore; + } + + public String[] getProcessDefinitionIdIn() { + return processDefinitionIdIn; + } + + public String[] getProcessDefinitionKeyIn() { + return processDefinitionKeyIn; + } + + public TenantCheck getTenantCheck() { + return tenantCheck; + } + + public String getReportPeriodUnitName() { + return durationPeriodUnit.name(); + } + + protected class ExecuteDurationReportCmd implements Command> { + + @Override + public List execute(CommandContext commandContext) { + return executeDurationReport(commandContext); + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricTaskInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricTaskInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..447d52de33c3c175398063c93798a0088cded31c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricTaskInstanceQueryImpl.java @@ -0,0 +1,1058 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static java.lang.Boolean.TRUE; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.HistoricTaskInstance; +import org.camunda.bpm.engine.history.HistoricTaskInstanceQuery; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.CompareUtil; +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; + + +/** + * @author Tom Baeyens + */ +public class HistoricTaskInstanceQueryImpl extends AbstractQuery implements HistoricTaskInstanceQuery { + + private static final long serialVersionUID = 1L; + protected String processDefinitionId; + protected String processDefinitionKey; + protected String processDefinitionName; + protected String processInstanceId; + protected String rootProcessInstanceId; + protected String processInstanceBusinessKey; + protected String[] processInstanceBusinessKeys; + protected String processInstanceBusinessKeyLike; + protected String executionId; + protected String[] activityInstanceIds; + protected String taskId; + protected String taskName; + protected String taskNameLike; + protected String taskParentTaskId; + protected String taskDescription; + protected String taskDescriptionLike; + protected String taskDeleteReason; + protected String taskDeleteReasonLike; + protected String taskOwner; + protected String taskOwnerLike; + protected Boolean assigned; + protected Boolean unassigned; + protected String taskAssignee; + protected String taskAssigneeLike; + protected String[] taskDefinitionKeys; + protected String taskInvolvedUser; + protected String taskInvolvedGroup; + protected String taskHadCandidateUser; + protected String taskHadCandidateGroup; + protected Boolean withCandidateGroups; + protected Boolean withoutCandidateGroups; + protected Integer taskPriority; + protected boolean finished; + protected boolean unfinished; + protected boolean processFinished; + protected boolean processUnfinished; + protected List variables = new ArrayList<>(); + protected Boolean variableNamesIgnoreCase; + protected Boolean variableValuesIgnoreCase; + + protected Date dueDate; + protected Date dueAfter; + protected Date dueBefore; + protected boolean isWithoutTaskDueDate; + + protected Date followUpDate; + protected Date followUpBefore; + protected Date followUpAfter; + + protected String[] tenantIds; + protected boolean isTenantIdSet; + + protected String caseDefinitionId; + protected String caseDefinitionKey; + protected String caseDefinitionName; + protected String caseInstanceId; + protected String caseExecutionId; + + protected Date finishedAfter; + protected Date finishedBefore; + protected Date startedAfter; + protected Date startedBefore; + + protected List queries = new ArrayList<>(Arrays.asList(this)); + protected boolean isOrQueryActive = false; + + public HistoricTaskInstanceQueryImpl() { + } + + public HistoricTaskInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + @Override + public long executeCount(CommandContext commandContext) { + ensureVariablesInitialized(); + checkQueryOk(); + return commandContext + .getHistoricTaskInstanceManager() + .findHistoricTaskInstanceCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + ensureVariablesInitialized(); + checkQueryOk(); + return commandContext + .getHistoricTaskInstanceManager() + .findHistoricTaskInstancesByQueryCriteria(this, page); + } + + + public HistoricTaskInstanceQueryImpl processInstanceId(String processInstanceId) { + this.processInstanceId = processInstanceId; + return this; + } + + @Override + public HistoricTaskInstanceQueryImpl rootProcessInstanceId(String rootProcessInstanceId) { + this.rootProcessInstanceId = rootProcessInstanceId; + return this; + } + + public HistoricTaskInstanceQuery processInstanceBusinessKey(String processInstanceBusinessKey) { + this.processInstanceBusinessKey = processInstanceBusinessKey; + return this; + } + + @Override + public HistoricTaskInstanceQuery processInstanceBusinessKeyIn(String... processInstanceBusinessKeys) { + ensureNotNull("processInstanceBusinessKeys", (Object[]) processInstanceBusinessKeys); + this.processInstanceBusinessKeys = processInstanceBusinessKeys; + return this; + } + + @Override + public HistoricTaskInstanceQuery processInstanceBusinessKeyLike(String processInstanceBusinessKey) { + this.processInstanceBusinessKeyLike = processInstanceBusinessKey; + return this; + } + + public HistoricTaskInstanceQueryImpl executionId(String executionId) { + this.executionId = executionId; + return this; + } + + public HistoricTaskInstanceQuery activityInstanceIdIn(String... activityInstanceIds) { + ensureNotNull("activityInstanceIds", (Object[]) activityInstanceIds); + this.activityInstanceIds = activityInstanceIds; + return this; + } + + public HistoricTaskInstanceQueryImpl processDefinitionId(String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + return this; + } + + public HistoricTaskInstanceQuery processDefinitionKey(String processDefinitionKey) { + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public HistoricTaskInstanceQuery processDefinitionName(String processDefinitionName) { + this.processDefinitionName = processDefinitionName; + return this; + } + + public HistoricTaskInstanceQuery taskId(String taskId) { + this.taskId = taskId; + return this; + } + public HistoricTaskInstanceQueryImpl taskName(String taskName) { + this.taskName = taskName; + return this; + } + + public HistoricTaskInstanceQueryImpl taskNameLike(String taskNameLike) { + this.taskNameLike = taskNameLike; + return this; + } + + public HistoricTaskInstanceQuery taskParentTaskId(String parentTaskId) { + this.taskParentTaskId = parentTaskId; + return this; + } + + public HistoricTaskInstanceQueryImpl taskDescription(String taskDescription) { + this.taskDescription = taskDescription; + return this; + } + + public HistoricTaskInstanceQueryImpl taskDescriptionLike(String taskDescriptionLike) { + this.taskDescriptionLike = taskDescriptionLike; + return this; + } + + public HistoricTaskInstanceQueryImpl taskDeleteReason(String taskDeleteReason) { + this.taskDeleteReason = taskDeleteReason; + return this; + } + + public HistoricTaskInstanceQueryImpl taskDeleteReasonLike(String taskDeleteReasonLike) { + this.taskDeleteReasonLike = taskDeleteReasonLike; + return this; + } + + public HistoricTaskInstanceQueryImpl taskAssigned() { + this.assigned = true; + return this; + } + + public HistoricTaskInstanceQueryImpl taskUnassigned() { + this.unassigned = true; + return this; + } + + public HistoricTaskInstanceQueryImpl taskAssignee(String taskAssignee) { + this.taskAssignee = taskAssignee; + return this; + } + + public HistoricTaskInstanceQueryImpl taskAssigneeLike(String taskAssigneeLike) { + this.taskAssigneeLike = taskAssigneeLike; + return this; + } + + public HistoricTaskInstanceQueryImpl taskOwner(String taskOwner) { + this.taskOwner = taskOwner; + return this; + } + + public HistoricTaskInstanceQueryImpl taskOwnerLike(String taskOwnerLike) { + this.taskOwnerLike = taskOwnerLike; + return this; + } + + public HistoricTaskInstanceQuery caseDefinitionId(String caseDefinitionId) { + this.caseDefinitionId = caseDefinitionId; + return this; + } + + public HistoricTaskInstanceQuery caseDefinitionKey(String caseDefinitionKey) { + this.caseDefinitionKey = caseDefinitionKey; + return this; + } + + public HistoricTaskInstanceQuery caseDefinitionName(String caseDefinitionName) { + this.caseDefinitionName = caseDefinitionName; + return this; + } + + public HistoricTaskInstanceQuery caseInstanceId(String caseInstanceId) { + this.caseInstanceId = caseInstanceId; + return this; + } + + public HistoricTaskInstanceQuery caseExecutionId(String caseExecutionId) { + this.caseExecutionId = caseExecutionId; + return this; + } + + public HistoricTaskInstanceQueryImpl finished() { + this.finished = true; + return this; + } + + public HistoricTaskInstanceQueryImpl unfinished() { + this.unfinished = true; + return this; + } + + @Override + public HistoricTaskInstanceQuery matchVariableNamesIgnoreCase() { + this.variableNamesIgnoreCase = true; + for (QueryVariableValue variable : this.variables) { + variable.setVariableNameIgnoreCase(true); + } + return this; + } + + @Override + public HistoricTaskInstanceQuery matchVariableValuesIgnoreCase() { + this.variableValuesIgnoreCase = true; + for (QueryVariableValue variable : this.variables) { + variable.setVariableValueIgnoreCase(true); + } + return this; + } + + public HistoricTaskInstanceQueryImpl taskVariableValueEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.EQUALS, true, false); + return this; + } + + public HistoricTaskInstanceQuery processVariableValueEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.EQUALS, false, true); + return this; + } + + @Override + public HistoricTaskInstanceQuery processVariableValueNotEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.NOT_EQUALS, false, true); + return this; + } + + public HistoricTaskInstanceQuery processVariableValueLike(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LIKE, false, true); + return this; + } + + public HistoricTaskInstanceQuery processVariableValueNotLike(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.NOT_LIKE, false, true); + return this; + } + + @Override + public HistoricTaskInstanceQuery processVariableValueGreaterThan(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.GREATER_THAN, false, true); + return this; + } + + @Override + public HistoricTaskInstanceQuery processVariableValueGreaterThanOrEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.GREATER_THAN_OR_EQUAL, false, true); + return this; + } + + @Override + public HistoricTaskInstanceQuery processVariableValueLessThan(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LESS_THAN, false, true); + return this; + } + + @Override + public HistoricTaskInstanceQuery processVariableValueLessThanOrEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LESS_THAN_OR_EQUAL, false, true); + return this; + } + + public HistoricTaskInstanceQuery taskDefinitionKey(String taskDefinitionKey) { + return taskDefinitionKeyIn(taskDefinitionKey); + } + + public HistoricTaskInstanceQuery taskDefinitionKeyIn(String... taskDefinitionKeys) { + ensureNotNull(NotValidException.class, "taskDefinitionKeys", (Object[]) taskDefinitionKeys); + this.taskDefinitionKeys = taskDefinitionKeys; + return this; + } + + public HistoricTaskInstanceQuery taskPriority(Integer taskPriority) { + this.taskPriority = taskPriority; + return this; + } + + public HistoricTaskInstanceQuery processFinished() { + this.processFinished = true; + return this; + } + + public HistoricTaskInstanceQuery taskInvolvedUser(String userId){ + this.taskInvolvedUser = userId; + return this; + } + + public HistoricTaskInstanceQuery taskInvolvedGroup(String groupId){ + this.taskInvolvedGroup = groupId; + return this; + } + + public HistoricTaskInstanceQuery taskHadCandidateUser(String userId){ + this.taskHadCandidateUser = userId; + return this; + } + + public HistoricTaskInstanceQuery taskHadCandidateGroup(String groupId){ + this.taskHadCandidateGroup = groupId; + return this; + } + + public HistoricTaskInstanceQuery withCandidateGroups() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set withCandidateGroups() within 'or' query"); + } + + this.withCandidateGroups = true; + return this; + } + + public HistoricTaskInstanceQuery withoutCandidateGroups() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set withoutCandidateGroups() within 'or' query"); + } + + this.withoutCandidateGroups = true; + return this; + } + + public HistoricTaskInstanceQuery processUnfinished() { + this.processUnfinished = true; + return this; + } + + protected void ensureVariablesInitialized() { + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + VariableSerializers variableSerializers = processEngineConfiguration.getVariableSerializers(); + String dbType = processEngineConfiguration.getDatabaseType(); + for(QueryVariableValue var : variables) { + var.initialize(variableSerializers, dbType); + } + + if (!queries.isEmpty()) { + for (HistoricTaskInstanceQueryImpl orQuery: queries) { + for (QueryVariableValue var : orQuery.variables) { + var.initialize(variableSerializers, dbType); + } + } + } + } + + public void addVariable(String name, Object value, QueryOperator operator, boolean isTaskVariable, boolean isProcessInstanceVariable) { + ensureNotNull("name", name); + if(value == null || isBoolean(value)) { + // Null-values and booleans can only be used in EQUALS and NOT_EQUALS + switch(operator) { + case GREATER_THAN: + throw new ProcessEngineException("Booleans and null cannot be used in 'greater than' condition"); + case LESS_THAN: + throw new ProcessEngineException("Booleans and null cannot be used in 'less than' condition"); + case GREATER_THAN_OR_EQUAL: + throw new ProcessEngineException("Booleans and null cannot be used in 'greater than or equal' condition"); + case LESS_THAN_OR_EQUAL: + throw new ProcessEngineException("Booleans and null cannot be used in 'less than or equal' condition"); + case LIKE: + throw new ProcessEngineException("Booleans and null cannot be used in 'like' condition"); + case NOT_LIKE: + throw new ProcessEngineException("Booleans and null cannot be used in 'not like' condition"); + default: + break; + } + } + boolean shouldMatchVariableValuesIgnoreCase = Boolean.TRUE.equals(variableValuesIgnoreCase) && value != null && String.class.isAssignableFrom(value.getClass()); + boolean shouldMatchVariableNamesIgnoreCase = Boolean.TRUE.equals(variableNamesIgnoreCase); + addVariable(new TaskQueryVariableValue(name, value, operator, isTaskVariable, isProcessInstanceVariable, shouldMatchVariableNamesIgnoreCase, shouldMatchVariableValuesIgnoreCase)); + } + + protected void addVariable(TaskQueryVariableValue taskQueryVariableValue) { + variables.add(taskQueryVariableValue); + } + + private boolean isBoolean(Object value) { + if (value == null) { + return false; + } + return Boolean.class.isAssignableFrom(value.getClass()) || boolean.class.isAssignableFrom(value.getClass()); + } + + public HistoricTaskInstanceQuery taskDueDate(Date dueDate) { + // The taskDueDate filter can't be used in an AND query with + // the withoutTaskDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (TRUE.equals(isWithoutTaskDueDate)) { + throw new ProcessEngineException("Invalid query usage: cannot set both taskDueDate and withoutTaskDueDate filters."); + } + } + + this.dueDate = dueDate; + return this; + } + + public HistoricTaskInstanceQuery taskDueAfter(Date dueAfter) { + // The taskDueAfter filter can't be used in an AND query with + // the withoutTaskDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (TRUE.equals(isWithoutTaskDueDate)) { + throw new ProcessEngineException("Invalid query usage: cannot set both taskDueAfter and withoutTaskDueDate filters."); + } + } + + this.dueAfter = dueAfter; + return this; + } + + public HistoricTaskInstanceQuery taskDueBefore(Date dueBefore) { + // The taskDueBefore filter can't be used in an AND query with + // the withoutTaskDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (TRUE.equals(isWithoutTaskDueDate)) { + throw new ProcessEngineException("Invalid query usage: cannot set both taskDueBefore and withoutTaskDueDate filters."); + } + } + + this.dueBefore = dueBefore; + return this; + } + + @Override + public HistoricTaskInstanceQuery withoutTaskDueDate() { + // The due date filters can't be used in an AND query with + // the withoutTaskDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (dueAfter != null || dueBefore != null || dueDate != null) { + throw new ProcessEngineException("Invalid query usage: cannot set both task due date (equal to, before, or after) and withoutTaskDueDate filters."); + } + } + + this.isWithoutTaskDueDate = true; + return this; + } + + public HistoricTaskInstanceQuery taskFollowUpDate(Date followUpDate) { + this.followUpDate = followUpDate; + return this; + } + + public HistoricTaskInstanceQuery taskFollowUpBefore(Date followUpBefore) { + this.followUpBefore = followUpBefore; + return this; + } + + public HistoricTaskInstanceQuery taskFollowUpAfter(Date followUpAfter) { + this.followUpAfter = followUpAfter; + return this; + } + + public HistoricTaskInstanceQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricTaskInstanceQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricTaskInstanceQuery finishedAfter(Date date) { + this.finishedAfter = date; + return this; + } + + @Override + public HistoricTaskInstanceQuery finishedBefore(Date date) { + this.finishedBefore = date; + return this; + } + + @Override + public HistoricTaskInstanceQuery startedAfter(Date date) { + this.startedAfter = date; + return this; + } + + @Override + public HistoricTaskInstanceQuery startedBefore(Date date) { + this.startedBefore = date; + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() + || (finished && unfinished) + ||(processFinished && processUnfinished) + || CompareUtil.areNotInAscendingOrder(startedAfter, startedBefore) + || CompareUtil.areNotInAscendingOrder(finishedAfter, finishedBefore) + || CompareUtil.areNotInAscendingOrder(dueAfter, dueDate, dueBefore) + || CompareUtil.areNotInAscendingOrder(followUpAfter, followUpDate, followUpBefore) + || CompareUtil.elementIsNotContainedInArray(processInstanceBusinessKey, processInstanceBusinessKeys); + } + + // ordering ///////////////////////////////////////////////////////////////// + + public HistoricTaskInstanceQueryImpl orderByTaskId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskId() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.HISTORIC_TASK_INSTANCE_ID); + return this; + } + + public HistoricTaskInstanceQueryImpl orderByHistoricActivityInstanceId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricActivityInstanceId() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.ACTIVITY_INSTANCE_ID); + return this; + } + + public HistoricTaskInstanceQueryImpl orderByProcessDefinitionId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessDefinitionId() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.PROCESS_DEFINITION_ID); + return this; + } + + public HistoricTaskInstanceQueryImpl orderByProcessInstanceId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessInstanceId() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.PROCESS_INSTANCE_ID); + return this; + } + + public HistoricTaskInstanceQueryImpl orderByExecutionId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByExecutionId() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.EXECUTION_ID); + return this; + } + + public HistoricTaskInstanceQueryImpl orderByHistoricTaskInstanceDuration() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricTaskInstanceDuration() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.DURATION); + return this; + } + + public HistoricTaskInstanceQueryImpl orderByHistoricTaskInstanceEndTime() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricTaskInstanceEndTime() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.END); + return this; + } + + public HistoricTaskInstanceQueryImpl orderByHistoricActivityInstanceStartTime() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByHistoricActivityInstanceStartTime() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.START); + return this; + } + + public HistoricTaskInstanceQueryImpl orderByTaskName() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskName() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.TASK_NAME); + return this; + } + + public HistoricTaskInstanceQueryImpl orderByTaskDescription() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskDescription() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.TASK_DESCRIPTION); + return this; + } + + public HistoricTaskInstanceQuery orderByTaskAssignee() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskAssignee() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.TASK_ASSIGNEE); + return this; + } + + public HistoricTaskInstanceQuery orderByTaskOwner() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskOwner() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.TASK_OWNER); + return this; + } + + public HistoricTaskInstanceQuery orderByTaskDueDate() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskDueDate() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.TASK_DUE_DATE); + return this; + } + + public HistoricTaskInstanceQuery orderByTaskFollowUpDate() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskFollowUpDate() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.TASK_FOLLOW_UP_DATE); + return this; + } + + public HistoricTaskInstanceQueryImpl orderByDeleteReason() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByDeleteReason() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.DELETE_REASON); + return this; + } + + public HistoricTaskInstanceQuery orderByTaskDefinitionKey() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskDefinitionKey() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.TASK_DEFINITION_KEY); + return this; + } + + public HistoricTaskInstanceQuery orderByTaskPriority() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTaskPriority() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.TASK_PRIORITY); + return this; + } + + public HistoricTaskInstanceQuery orderByCaseDefinitionId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByCaseDefinitionId() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.CASE_DEFINITION_ID); + return this; + } + + public HistoricTaskInstanceQuery orderByCaseInstanceId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByCaseInstanceId() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.CASE_INSTANCE_ID); + return this; + } + + public HistoricTaskInstanceQuery orderByCaseExecutionId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByCaseExecutionId() within 'or' query"); + } + + orderBy(HistoricTaskInstanceQueryProperty.CASE_EXECUTION_ID); + return this; + } + + public HistoricTaskInstanceQuery orderByTenantId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTenantId() within 'or' query"); + } + + return orderBy(HistoricTaskInstanceQueryProperty.TENANT_ID); + } + + // getters and setters ////////////////////////////////////////////////////// + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getRootProcessInstanceId() { + return rootProcessInstanceId; + } + + public String getProcessInstanceBusinessKey() { + return processInstanceBusinessKey; + } + + public String[] getProcessInstanceBusinessKeys() { + return processInstanceBusinessKeys; + } + + public String getProcessInstanceBusinessKeyLike() { + return processInstanceBusinessKeyLike; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public String getProcessDefinitionName() { + return processDefinitionName; + } + + public String getExecutionId() { + return executionId; + } + + public String[] getActivityInstanceIds() { + return activityInstanceIds; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public Boolean isAssigned() { + return assigned; + } + + public Boolean isUnassigned() { + return unassigned; + } + + public Boolean isWithCandidateGroups() { + return withCandidateGroups; + } + + public Boolean isWithoutCandidateGroups() { + return withoutCandidateGroups; + } + + public boolean isFinished() { + return finished; + } + + public boolean isProcessFinished() { + return processFinished; + } + + public boolean isUnfinished() { + return unfinished; + } + + public boolean isProcessUnfinished() { + return processUnfinished; + } + + public Date getDueDate() { + return dueDate; + } + + public Date getDueBefore() { + return dueBefore; + } + + public Date getDueAfter() { + return dueAfter; + } + + public boolean isWithoutTaskDueDate() { + return isWithoutTaskDueDate; + } + + public Date getFollowUpDate() { + return followUpDate; + } + + public Date getFollowUpBefore() { + return followUpBefore; + } + + public Date getFollowUpAfter() { + return followUpAfter; + } + + public String getTaskName() { + return taskName; + } + + public String getTaskNameLike() { + return taskNameLike; + } + + public String getTaskDescription() { + return taskDescription; + } + + public String getTaskDescriptionLike() { + return taskDescriptionLike; + } + + public String getTaskDeleteReason() { + return taskDeleteReason; + } + + public String getTaskDeleteReasonLike() { + return taskDeleteReasonLike; + } + + public String getTaskAssignee() { + return taskAssignee; + } + + public String getTaskAssigneeLike() { + return taskAssigneeLike; + } + + public String getTaskId() { + return taskId; + } + + public String getTaskInvolvedGroup() { + return taskInvolvedGroup; + } + + public String getTaskInvolvedUser() { + return taskInvolvedUser; + } + + public String getTaskHadCandidateGroup() { + return taskHadCandidateGroup; + } + + public String getTaskHadCandidateUser() { + return taskHadCandidateUser; + } + + public String[] getTaskDefinitionKeys() { + return taskDefinitionKeys; + } + + public List getVariables() { + return variables; + } + + public Boolean getVariableNamesIgnoreCase() { + return variableNamesIgnoreCase; + } + + public Boolean getVariableValuesIgnoreCase() { + return variableValuesIgnoreCase; + } + + public String getTaskOwnerLike() { + return taskOwnerLike; + } + + public String getTaskOwner() { + return taskOwner; + } + + public Integer getTaskPriority() { + return taskPriority; + } + + public String getTaskParentTaskId() { + return taskParentTaskId; + } + + public String[] getTenantIds() { + return tenantIds; + } + + public String getCaseDefinitionId() { + return caseDefinitionId; + } + + public String getCaseDefinitionKey() { + return caseDefinitionKey; + } + + public String getCaseDefinitionName() { + return caseDefinitionName; + } + + public String getCaseInstanceId() { + return caseInstanceId; + } + + public String getCaseExecutionId() { + return caseExecutionId; + } + + public Date getFinishedAfter() { + return finishedAfter; + } + + public Date getFinishedBefore() { + return finishedBefore; + } + + public Date getStartedAfter() { + return startedAfter; + } + + public Date getStartedBefore() { + return startedBefore; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public List getQueries() { + return queries; + } + + public boolean isOrQueryActive() { + return isOrQueryActive; + } + + public void addOrQuery(HistoricTaskInstanceQueryImpl orQuery) { + orQuery.isOrQueryActive = true; + this.queries.add(orQuery); + } + + public void setOrQueryActive() { + isOrQueryActive = true; + } + + @Override + public HistoricTaskInstanceQuery or() { + if (this != queries.get(0)) { + throw new ProcessEngineException("Invalid query usage: cannot set or() within 'or' query"); + } + + HistoricTaskInstanceQueryImpl orQuery = new HistoricTaskInstanceQueryImpl(); + orQuery.isOrQueryActive = true; + orQuery.queries = queries; + queries.add(orQuery); + return orQuery; + } + + @Override + public HistoricTaskInstanceQuery endOr() { + if (!queries.isEmpty() && this != queries.get(queries.size()-1)) { + throw new ProcessEngineException("Invalid query usage: cannot set endOr() before or()"); + } + + return queries.get(0); + } + +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricTaskInstanceQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricTaskInstanceQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..18e9cac6dc2d34e7c9f8ef8c22ec7314f908d2ad --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricTaskInstanceQueryProperty.java @@ -0,0 +1,49 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + + +/** + * @author Tom Baeyens + */ +public interface HistoricTaskInstanceQueryProperty { + + public static final QueryProperty HISTORIC_TASK_INSTANCE_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("PROC_DEF_ID_"); + public static final QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROC_INST_ID_"); + public static final QueryProperty EXECUTION_ID = new QueryPropertyImpl("EXECUTION_ID_"); + public static final QueryProperty ACTIVITY_INSTANCE_ID = new QueryPropertyImpl("ACT_INST_ID_"); + public static final QueryProperty TASK_NAME = new QueryPropertyImpl("NAME_"); + public static final QueryProperty TASK_DESCRIPTION = new QueryPropertyImpl("DESCRIPTION_"); + public static final QueryProperty TASK_ASSIGNEE = new QueryPropertyImpl("ASSIGNEE_"); + public static final QueryProperty TASK_OWNER = new QueryPropertyImpl("OWNER_"); + public static final QueryProperty TASK_DEFINITION_KEY = new QueryPropertyImpl("TASK_DEF_KEY_"); + public static final QueryProperty DELETE_REASON = new QueryPropertyImpl("DELETE_REASON_"); + public static final QueryProperty START = new QueryPropertyImpl("START_TIME_"); + public static final QueryProperty END = new QueryPropertyImpl("END_TIME_"); + public static final QueryProperty DURATION = new QueryPropertyImpl("DURATION_"); + public static final QueryProperty TASK_PRIORITY = new QueryPropertyImpl("PRIORITY_"); + public static final QueryProperty TASK_DUE_DATE = new QueryPropertyImpl("DUE_DATE_"); + public static final QueryProperty TASK_FOLLOW_UP_DATE = new QueryPropertyImpl("FOLLOW_UP_DATE_"); + public static final QueryProperty CASE_DEFINITION_ID = new QueryPropertyImpl("CASE_DEFINITION_ID_"); + public static final QueryProperty CASE_INSTANCE_ID = new QueryPropertyImpl("CASE_INSTANCE_ID_"); + public static final QueryProperty CASE_EXECUTION_ID = new QueryPropertyImpl("CASE_EXECUTION_ID_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricTaskInstanceReportImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricTaskInstanceReportImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..850714b29b8ef2f5710dfdc245edb6cf102ac141 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricTaskInstanceReportImpl.java @@ -0,0 +1,163 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.DurationReportResult; +import org.camunda.bpm.engine.history.HistoricTaskInstanceReport; +import org.camunda.bpm.engine.history.HistoricTaskInstanceReportResult; +import org.camunda.bpm.engine.impl.cfg.CommandChecker; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.TenantCheck; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.query.PeriodUnit; + +/** + * @author Stefan Hentschel. + */ +public class HistoricTaskInstanceReportImpl implements HistoricTaskInstanceReport { + + protected Date completedAfter; + protected Date completedBefore; + + protected PeriodUnit durationPeriodUnit; + + protected CommandExecutor commandExecutor; + + protected TenantCheck tenantCheck = new TenantCheck(); + + public HistoricTaskInstanceReportImpl(CommandExecutor commandExecutor) { + this.commandExecutor = commandExecutor; + } + + @Override + public List countByProcessDefinitionKey() { + CommandContext commandContext = Context.getCommandContext(); + + if(commandContext == null) { + return commandExecutor.execute(new HistoricTaskInstanceCountByProcessDefinitionKey()); + } + else { + return executeCountByProcessDefinitionKey(commandContext); + } + } + + protected List executeCountByProcessDefinitionKey(CommandContext commandContext) { + return commandContext.getTaskReportManager() + .selectHistoricTaskInstanceCountByProcDefKeyReport(this); + } + + @Override + public List countByTaskName() { + CommandContext commandContext = Context.getCommandContext(); + + if(commandContext == null) { + return commandExecutor.execute(new HistoricTaskInstanceCountByNameCmd()); + } + else { + return executeCountByTaskName(commandContext); + } + } + + protected List executeCountByTaskName(CommandContext commandContext) { + return commandContext.getTaskReportManager() + .selectHistoricTaskInstanceCountByTaskNameReport(this); + } + + @Override + public List duration(PeriodUnit periodUnit) { + ensureNotNull(NotValidException.class, "periodUnit", periodUnit); + this.durationPeriodUnit = periodUnit; + + CommandContext commandContext = Context.getCommandContext(); + + if(commandContext == null) { + return commandExecutor.execute(new ExecuteDurationCmd()); + } + else { + return executeDuration(commandContext); + } + } + + + protected List executeDuration(CommandContext commandContext) { + return commandContext.getTaskReportManager() + .createHistoricTaskDurationReport(this); + } + + public Date getCompletedAfter() { + return completedAfter; + } + + public Date getCompletedBefore() { + return completedBefore; + } + + @Override + public HistoricTaskInstanceReport completedAfter(Date completedAfter) { + ensureNotNull(NotValidException.class, "completedAfter", completedAfter); + this.completedAfter = completedAfter; + return this; + } + + @Override + public HistoricTaskInstanceReport completedBefore(Date completedBefore) { + ensureNotNull(NotValidException.class, "completedBefore", completedBefore); + this.completedBefore = completedBefore; + return this; + } + + public TenantCheck getTenantCheck() { + return tenantCheck; + } + + public String getReportPeriodUnitName() { + return durationPeriodUnit.name(); + } + + protected class ExecuteDurationCmd implements Command> { + + @Override + public List execute(CommandContext commandContext) { + return executeDuration(commandContext); + } + } + + protected class HistoricTaskInstanceCountByNameCmd implements Command> { + + @Override + public List execute(CommandContext commandContext) { + return executeCountByTaskName(commandContext); + } + } + + protected class HistoricTaskInstanceCountByProcessDefinitionKey implements Command> { + + @Override + public List execute(CommandContext commandContext) { + return executeCountByProcessDefinitionKey(commandContext); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricVariableInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricVariableInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a737216db7f8e2eac34cdc6ee4bafafc676a2cb2 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricVariableInstanceQueryImpl.java @@ -0,0 +1,398 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.camunda.bpm.engine.history.HistoricVariableInstanceQuery; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.cmd.CommandLogger; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity; +import org.camunda.bpm.engine.impl.variable.serializer.AbstractTypedValueSerializer; +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; + +/** + * @author Christian Lipphardt (camunda) + */ +public class HistoricVariableInstanceQueryImpl extends AbstractQuery implements + HistoricVariableInstanceQuery { + + private final static CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; + + private static final long serialVersionUID = 1L; + + protected List variableNameIn; + protected String variableId; + protected String processInstanceId; + protected String processDefinitionId; + protected String processDefinitionKey; + protected String caseInstanceId; + protected String variableName; + protected String variableNameLike; + protected QueryVariableValue queryVariableValue; + protected Boolean variableNamesIgnoreCase; + protected Boolean variableValuesIgnoreCase; + protected String[] variableTypes; + protected String[] taskIds; + protected String[] executionIds; + protected String[] caseExecutionIds; + protected String[] caseActivityIds; + protected String[] activityInstanceIds; + + protected String[] tenantIds; + protected boolean isTenantIdSet; + + protected String[] processInstanceIds; + protected boolean includeDeleted = false; + + protected boolean isByteArrayFetchingEnabled = true; + protected boolean isCustomObjectDeserializationEnabled = true; + protected String variableIdAfter; + protected Date createdAfter; + + public HistoricVariableInstanceQueryImpl() { + } + + public HistoricVariableInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public HistoricVariableInstanceQuery idAfter(String id) { + variableIdAfter = id; + return this; + } + + public String getVariableIdAfter() { + return variableIdAfter; + } + + public HistoricVariableInstanceQuery createdAfter(Date date) { + createdAfter = date; + return this; + } + + public HistoricVariableInstanceQuery variableNameIn(String... names) { + ensureNotNull("Variable names", (Object[]) names); + variableNameIn = Arrays.asList(names); + return this; + } + + public HistoricVariableInstanceQuery variableId(String id) { + ensureNotNull("variableId", id); + this.variableId = id; + return this; + } + + public HistoricVariableInstanceQueryImpl processInstanceId(String processInstanceId) { + ensureNotNull("processInstanceId", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + public HistoricVariableInstanceQuery processDefinitionId(String processDefinitionId) { + ensureNotNull("processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + public HistoricVariableInstanceQuery processDefinitionKey(String processDefinitionKey) { + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public HistoricVariableInstanceQuery caseInstanceId(String caseInstanceId) { + ensureNotNull("caseInstanceId", caseInstanceId); + this.caseInstanceId = caseInstanceId; + return this; + } + + @Override + public HistoricVariableInstanceQuery variableTypeIn(String... variableTypes) { + ensureNotNull("Variable types", (Object[]) variableTypes); + this.variableTypes = lowerCase(variableTypes); + return this; + } + + @Override + public HistoricVariableInstanceQuery matchVariableNamesIgnoreCase() { + this.variableNamesIgnoreCase = true; + if (queryVariableValue != null) { + queryVariableValue.variableNameIgnoreCase = true; + } + return this; + } + + @Override + public HistoricVariableInstanceQuery matchVariableValuesIgnoreCase() { + this.variableValuesIgnoreCase = true; + if (queryVariableValue != null) { + queryVariableValue.variableValueIgnoreCase = true; + } + return this; + } + + private String[] lowerCase(String... variableTypes) { + for (int i = 0; i < variableTypes.length; i++) { + variableTypes[i] = variableTypes[i].toLowerCase(); + } + return variableTypes; + } + + /** Only select historic process variables with the given process instance ids. */ + public HistoricVariableInstanceQuery processInstanceIdIn(String... processInstanceIds) { + ensureNotNull("Process Instance Ids", (Object[]) processInstanceIds); + this.processInstanceIds = processInstanceIds; + return this; + } + + public HistoricVariableInstanceQuery taskIdIn(String... taskIds) { + ensureNotNull("Task Ids", (Object[]) taskIds); + this.taskIds = taskIds; + return this; + } + + public HistoricVariableInstanceQuery executionIdIn(String... executionIds) { + ensureNotNull("Execution Ids", (Object[]) executionIds); + this.executionIds = executionIds; + return this; + } + + public HistoricVariableInstanceQuery caseExecutionIdIn(String... caseExecutionIds) { + ensureNotNull("Case execution ids", (Object[]) caseExecutionIds); + this.caseExecutionIds = caseExecutionIds; + return this; + } + + public HistoricVariableInstanceQuery caseActivityIdIn(String... caseActivityIds) { + ensureNotNull("Case activity ids", (Object[]) caseActivityIds); + this.caseActivityIds = caseActivityIds; + return this; + } + + public HistoricVariableInstanceQuery activityInstanceIdIn(String... activityInstanceIds) { + ensureNotNull("Activity Instance Ids", (Object[]) activityInstanceIds); + this.activityInstanceIds = activityInstanceIds; + return this; + } + + public HistoricVariableInstanceQuery variableName(String variableName) { + ensureNotNull("variableName", variableName); + this.variableName = variableName; + return this; + } + + public HistoricVariableInstanceQuery variableValueEquals(String variableName, Object variableValue) { + ensureNotNull("variableName", variableName); + ensureNotNull("variableValue", variableValue); + this.variableName = variableName; + queryVariableValue = new QueryVariableValue(variableName, variableValue, QueryOperator.EQUALS, true, Boolean.TRUE.equals(variableNamesIgnoreCase), Boolean.TRUE.equals(variableValuesIgnoreCase)); + return this; + } + + public HistoricVariableInstanceQuery variableNameLike(String variableNameLike) { + ensureNotNull("variableNameLike", variableNameLike); + this.variableNameLike = variableNameLike; + return this; + } + + protected void ensureVariablesInitialized() { + if (this.queryVariableValue != null) { + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + VariableSerializers variableSerializers = processEngineConfiguration.getVariableSerializers(); + String dbType = processEngineConfiguration.getDatabaseType(); + queryVariableValue.initialize(variableSerializers, dbType); + } + } + + public HistoricVariableInstanceQuery disableBinaryFetching() { + isByteArrayFetchingEnabled = false; + return this; + } + + public HistoricVariableInstanceQuery disableCustomObjectDeserialization() { + this.isCustomObjectDeserializationEnabled = false; + return this; + } + + public HistoricVariableInstanceQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + @Override + public HistoricVariableInstanceQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + ensureVariablesInitialized(); + return commandContext.getHistoricVariableInstanceManager().findHistoricVariableInstanceCountByQueryCriteria(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + ensureVariablesInitialized(); + List historicVariableInstances = commandContext + .getHistoricVariableInstanceManager() + .findHistoricVariableInstancesByQueryCriteria(this, page); + + if (historicVariableInstances!=null) { + for (HistoricVariableInstance historicVariableInstance: historicVariableInstances) { + + HistoricVariableInstanceEntity variableInstanceEntity = (HistoricVariableInstanceEntity) historicVariableInstance; + if (shouldFetchValue(variableInstanceEntity)) { + try { + variableInstanceEntity.getTypedValue(isCustomObjectDeserializationEnabled); + + } catch(Exception t) { + // do not fail if one of the variables fails to load + LOG.exceptionWhileGettingValueForVariable(t); + } + } + + } + } + return historicVariableInstances; + } + + protected boolean shouldFetchValue(HistoricVariableInstanceEntity entity) { + // do not fetch values for byte arrays eagerly (unless requested by the user) + return isByteArrayFetchingEnabled + || !AbstractTypedValueSerializer.BINARY_VALUE_TYPES.contains(entity.getSerializer().getType().getName()); + } + + // order by ///////////////////////////////////////////////////////////////// + + public HistoricVariableInstanceQuery orderByProcessInstanceId() { + orderBy(HistoricVariableInstanceQueryProperty.PROCESS_INSTANCE_ID); + return this; + } + + public HistoricVariableInstanceQuery orderByVariableName() { + orderBy(HistoricVariableInstanceQueryProperty.VARIABLE_NAME); + return this; + } + + public HistoricVariableInstanceQuery orderByTenantId() { + orderBy(HistoricVariableInstanceQueryProperty.TENANT_ID); + return this; + } + + public HistoricVariableInstanceQuery orderByVariableId() { + orderBy(HistoricVariableInstanceQueryProperty.VARIABLE_ID); + return this; + } + + public HistoricVariableInstanceQuery orderByCreationTime() { + orderBy(HistoricVariableInstanceQueryProperty.CREATE_TIME); + return this; + } + + // getters and setters ////////////////////////////////////////////////////// + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getCaseInstanceId() { + return caseInstanceId; + } + + public String[] getActivityInstanceIds() { + return activityInstanceIds; + } + + public String[] getProcessInstanceIds() { + return processInstanceIds; + } + + public String[] getTaskIds() { + return taskIds; + } + + public String[] getExecutionIds() { + return executionIds; + } + + public String[] getCaseExecutionIds() { + return caseExecutionIds; + } + + public String[] getCaseActivityIds() { + return caseActivityIds; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public String getVariableName() { + return variableName; + } + + public String getVariableNameLike() { + return variableNameLike; + } + + public QueryVariableValue getQueryVariableValue() { + return queryVariableValue; + } + + public Boolean getVariableNamesIgnoreCase() { + return variableNamesIgnoreCase; + } + + public Boolean getVariableValuesIgnoreCase() { + return variableValuesIgnoreCase; + } + + @Override + public HistoricVariableInstanceQuery includeDeleted() { + includeDeleted = true; + return this; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public List getVariableNameIn() { + return variableNameIn; + } + + public Date getCreatedAfter() { + return createdAfter; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricVariableInstanceQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricVariableInstanceQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..30111115b2e2e0e711d5aa5fb3c6ee506da7f52e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoricVariableInstanceQueryProperty.java @@ -0,0 +1,35 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.history.HistoricVariableInstanceQuery; +import org.camunda.bpm.engine.query.QueryProperty; + + +/** + * Contains the possible properties which can be used in a {@link HistoricVariableInstanceQuery}. + * + * @author Christian Lipphardt (camunda) + */ +public interface HistoricVariableInstanceQueryProperty { + + QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROC_INST_ID_"); + QueryProperty VARIABLE_NAME = new QueryPropertyImpl("NAME_"); + QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + QueryProperty VARIABLE_ID = new QueryPropertyImpl("ID_"); + QueryProperty CREATE_TIME = new QueryPropertyImpl("CREATE_TIME_"); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoryLevelSetupCommand.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoryLevelSetupCommand.java new file mode 100644 index 0000000000000000000000000000000000000000..d304476e98228e178a0883dbe5fe847ecbcddebb --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoryLevelSetupCommand.java @@ -0,0 +1,119 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.ProcessEngineConfiguration; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.cmd.DetermineHistoryLevelCmd; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.EnginePersistenceLogger; +import org.camunda.bpm.engine.impl.db.entitymanager.DbEntityManager; +import org.camunda.bpm.engine.impl.history.HistoryLevel; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.PropertyEntity; +import org.camunda.bpm.engine.impl.persistence.entity.PropertyManager; + +public final class HistoryLevelSetupCommand implements Command { + + private final static EnginePersistenceLogger LOG = ProcessEngineLogger.PERSISTENCE_LOGGER; + + public Void execute(CommandContext commandContext) { + + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + + checkStartupLockExists(commandContext); + + HistoryLevel databaseHistoryLevel = new DetermineHistoryLevelCmd(processEngineConfiguration.getHistoryLevels()).execute(commandContext); + determineAutoHistoryLevel(processEngineConfiguration, databaseHistoryLevel); + + HistoryLevel configuredHistoryLevel = processEngineConfiguration.getHistoryLevel(); + + if (databaseHistoryLevel == null) { + + acquireExclusiveLock(commandContext); + databaseHistoryLevel = new DetermineHistoryLevelCmd(processEngineConfiguration.getHistoryLevels()).execute(commandContext); + + if (databaseHistoryLevel == null) { + LOG.noHistoryLevelPropertyFound(); + dbCreateHistoryLevel(commandContext); + } + } else { + if (configuredHistoryLevel.getId() != databaseHistoryLevel.getId()) { + throw new ProcessEngineException("historyLevel mismatch: configuration says " + configuredHistoryLevel + + " and database says " + databaseHistoryLevel); + } + } + + return null; + } + + public static void dbCreateHistoryLevel(CommandContext commandContext) { + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + HistoryLevel configuredHistoryLevel = processEngineConfiguration.getHistoryLevel(); + PropertyEntity property = new PropertyEntity("historyLevel", Integer.toString(configuredHistoryLevel.getId())); + commandContext.getSession(DbEntityManager.class).insert(property); + LOG.creatingHistoryLevelPropertyInDatabase(configuredHistoryLevel); + } + + /** + * + * @return Integer value representing the history level or null if none found + */ + public static Integer databaseHistoryLevel(CommandContext commandContext) { + + try { + PropertyEntity historyLevelProperty = commandContext.getPropertyManager().findPropertyById("historyLevel"); + return historyLevelProperty != null ? Integer.valueOf(historyLevelProperty.getValue()) : null; + } + catch (Exception e) { + LOG.couldNotSelectHistoryLevel(e.getMessage()); + return null; + } + + } + + protected void determineAutoHistoryLevel(ProcessEngineConfigurationImpl engineConfiguration, HistoryLevel databaseHistoryLevel) { + HistoryLevel configuredHistoryLevel = engineConfiguration.getHistoryLevel(); + + if (configuredHistoryLevel == null + && ProcessEngineConfiguration.HISTORY_AUTO.equals(engineConfiguration.getHistory())) { + + // automatically determine history level or use default AUDIT + if (databaseHistoryLevel != null) { + engineConfiguration.setHistoryLevel(databaseHistoryLevel); + } + else { + engineConfiguration.setHistoryLevel(engineConfiguration.getDefaultHistoryLevel()); + } + } + } + + protected void checkStartupLockExists(CommandContext commandContext) { + PropertyEntity historyStartupProperty = commandContext.getPropertyManager().findPropertyById("startup.lock"); + if (historyStartupProperty == null) { + LOG.noStartupLockPropertyFound(); + } + } + + protected void acquireExclusiveLock(CommandContext commandContext) { + PropertyManager propertyManager = commandContext.getPropertyManager(); + //exclusive lock + propertyManager.acquireExclusiveLockForStartup(); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoryServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoryServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..7b85afca37d5cd6dd7da2a2e68e7c8078fde3a7e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoryServiceImpl.java @@ -0,0 +1,354 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.Arrays; +import java.util.List; + +import org.camunda.bpm.engine.HistoryService; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.batch.history.HistoricBatchQuery; +import org.camunda.bpm.engine.history.CleanableHistoricBatchReport; +import org.camunda.bpm.engine.history.CleanableHistoricCaseInstanceReport; +import org.camunda.bpm.engine.history.CleanableHistoricDecisionInstanceReport; +import org.camunda.bpm.engine.history.CleanableHistoricProcessInstanceReport; +import org.camunda.bpm.engine.history.HistoricActivityInstanceQuery; +import org.camunda.bpm.engine.history.HistoricActivityStatisticsQuery; +import org.camunda.bpm.engine.history.HistoricCaseActivityInstanceQuery; +import org.camunda.bpm.engine.history.HistoricCaseActivityStatisticsQuery; +import org.camunda.bpm.engine.history.HistoricCaseInstanceQuery; +import org.camunda.bpm.engine.history.HistoricDecisionInstanceQuery; +import org.camunda.bpm.engine.history.HistoricDecisionInstanceStatisticsQuery; +import org.camunda.bpm.engine.history.HistoricDetailQuery; +import org.camunda.bpm.engine.history.HistoricExternalTaskLogQuery; +import org.camunda.bpm.engine.history.HistoricIncidentQuery; +import org.camunda.bpm.engine.history.HistoricJobLogQuery; +import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; +import org.camunda.bpm.engine.history.HistoricProcessInstanceReport; +import org.camunda.bpm.engine.history.HistoricTaskInstanceQuery; +import org.camunda.bpm.engine.history.HistoricTaskInstanceReport; +import org.camunda.bpm.engine.history.HistoricVariableInstanceQuery; +import org.camunda.bpm.engine.history.NativeHistoricActivityInstanceQuery; +import org.camunda.bpm.engine.history.NativeHistoricCaseActivityInstanceQuery; +import org.camunda.bpm.engine.history.NativeHistoricCaseInstanceQuery; +import org.camunda.bpm.engine.history.NativeHistoricDecisionInstanceQuery; +import org.camunda.bpm.engine.history.NativeHistoricProcessInstanceQuery; +import org.camunda.bpm.engine.history.NativeHistoricTaskInstanceQuery; +import org.camunda.bpm.engine.history.NativeHistoricVariableInstanceQuery; +import org.camunda.bpm.engine.history.SetRemovalTimeSelectModeForHistoricBatchesBuilder; +import org.camunda.bpm.engine.history.SetRemovalTimeSelectModeForHistoricDecisionInstancesBuilder; +import org.camunda.bpm.engine.history.SetRemovalTimeSelectModeForHistoricProcessInstancesBuilder; +import org.camunda.bpm.engine.history.SetRemovalTimeToHistoricBatchesBuilder; +import org.camunda.bpm.engine.history.SetRemovalTimeToHistoricDecisionInstancesBuilder; +import org.camunda.bpm.engine.history.UserOperationLogQuery; +import org.camunda.bpm.engine.impl.batch.history.DeleteHistoricBatchCmd; +import org.camunda.bpm.engine.impl.batch.history.HistoricBatchQueryImpl; +import org.camunda.bpm.engine.impl.cmd.DeleteHistoricCaseInstanceCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteHistoricCaseInstancesBulkCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteHistoricProcessInstancesCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteHistoricTaskInstanceCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteHistoricVariableInstanceCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteHistoricVariableInstancesByProcessInstanceIdCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteUserOperationLogEntryCmd; +import org.camunda.bpm.engine.impl.cmd.FindHistoryCleanupJobsCmd; +import org.camunda.bpm.engine.impl.cmd.GetHistoricExternalTaskLogErrorDetailsCmd; +import org.camunda.bpm.engine.impl.cmd.GetHistoricJobLogExceptionStacktraceCmd; +import org.camunda.bpm.engine.impl.cmd.HistoryCleanupCmd; +import org.camunda.bpm.engine.impl.cmd.batch.DeleteHistoricProcessInstancesBatchCmd; +import org.camunda.bpm.engine.impl.dmn.cmd.DeleteHistoricDecisionInstanceByDefinitionIdCmd; +import org.camunda.bpm.engine.impl.dmn.cmd.DeleteHistoricDecisionInstanceByInstanceIdCmd; +import org.camunda.bpm.engine.impl.dmn.cmd.DeleteHistoricDecisionInstancesBatchCmd; +import org.camunda.bpm.engine.impl.dmn.cmd.DeleteHistoricDecisionInstancesBulkCmd; +import org.camunda.bpm.engine.history.SetRemovalTimeToHistoricProcessInstancesBuilder; +import org.camunda.bpm.engine.impl.history.SetRemovalTimeToHistoricBatchesBuilderImpl; +import org.camunda.bpm.engine.impl.history.SetRemovalTimeToHistoricDecisionInstancesBuilderImpl; +import org.camunda.bpm.engine.impl.history.SetRemovalTimeToHistoricProcessInstancesBuilderImpl; +import org.camunda.bpm.engine.runtime.Job; + +/** + * @author Tom Baeyens + * @author Bernd Ruecker (camunda) + * @author Christian Stettler + */ +public class HistoryServiceImpl extends ServiceImpl implements HistoryService { + + public HistoricProcessInstanceQuery createHistoricProcessInstanceQuery() { + return new HistoricProcessInstanceQueryImpl(commandExecutor); + } + + public HistoricActivityInstanceQuery createHistoricActivityInstanceQuery() { + return new HistoricActivityInstanceQueryImpl(commandExecutor); + } + + public HistoricActivityStatisticsQuery createHistoricActivityStatisticsQuery(String processDefinitionId) { + return new HistoricActivityStatisticsQueryImpl(processDefinitionId, commandExecutor); + } + + public HistoricCaseActivityStatisticsQuery createHistoricCaseActivityStatisticsQuery(String caseDefinitionId) { + return new HistoricCaseActivityStatisticsQueryImpl(caseDefinitionId, commandExecutor); + } + + public HistoricTaskInstanceQuery createHistoricTaskInstanceQuery() { + return new HistoricTaskInstanceQueryImpl(commandExecutor); + } + + public HistoricDetailQuery createHistoricDetailQuery() { + return new HistoricDetailQueryImpl(commandExecutor); + } + + public UserOperationLogQuery createUserOperationLogQuery() { + return new UserOperationLogQueryImpl(commandExecutor); + } + + public HistoricVariableInstanceQuery createHistoricVariableInstanceQuery() { + return new HistoricVariableInstanceQueryImpl(commandExecutor); + } + + public HistoricIncidentQuery createHistoricIncidentQuery() { + return new HistoricIncidentQueryImpl(commandExecutor); + } + + public HistoricIdentityLinkLogQueryImpl createHistoricIdentityLinkLogQuery() { + return new HistoricIdentityLinkLogQueryImpl(commandExecutor); + } + + public HistoricCaseInstanceQuery createHistoricCaseInstanceQuery() { + return new HistoricCaseInstanceQueryImpl(commandExecutor); + } + + public HistoricCaseActivityInstanceQuery createHistoricCaseActivityInstanceQuery() { + return new HistoricCaseActivityInstanceQueryImpl(commandExecutor); + } + + public HistoricDecisionInstanceQuery createHistoricDecisionInstanceQuery() { + return new HistoricDecisionInstanceQueryImpl(commandExecutor); + } + + public void deleteHistoricTaskInstance(String taskId) { + commandExecutor.execute(new DeleteHistoricTaskInstanceCmd(taskId)); + } + + public void deleteHistoricProcessInstance(String processInstanceId) { + deleteHistoricProcessInstances(Arrays.asList(processInstanceId)); + } + + public void deleteHistoricProcessInstanceIfExists(String processInstanceId) { + deleteHistoricProcessInstancesIfExists(Arrays.asList(processInstanceId)); + } + + public void deleteHistoricProcessInstances(List processInstanceIds) { + commandExecutor.execute(new DeleteHistoricProcessInstancesCmd(processInstanceIds, true)); + } + + public void deleteHistoricProcessInstancesIfExists(List processInstanceIds) { + commandExecutor.execute(new DeleteHistoricProcessInstancesCmd(processInstanceIds, false)); + } + + public void deleteHistoricProcessInstancesBulk(List processInstanceIds){ + deleteHistoricProcessInstances(processInstanceIds); + } + + public Job cleanUpHistoryAsync() { + return cleanUpHistoryAsync(false); + } + + public Job cleanUpHistoryAsync(boolean immediatelyDue) { + return commandExecutor.execute(new HistoryCleanupCmd(immediatelyDue)); + } + + @Override + public Job findHistoryCleanupJob() { + final List jobs = commandExecutor.execute(new FindHistoryCleanupJobsCmd()); + if (jobs.size() > 0) { + return jobs.get(0); + } else { + return null; + } + } + + @Override + public List findHistoryCleanupJobs() { + return commandExecutor.execute(new FindHistoryCleanupJobsCmd()); + } + + public Batch deleteHistoricProcessInstancesAsync(List processInstanceIds, String deleteReason) { + return this.deleteHistoricProcessInstancesAsync(processInstanceIds,null,deleteReason); + } + + public Batch deleteHistoricProcessInstancesAsync(HistoricProcessInstanceQuery query, String deleteReason) { + return this.deleteHistoricProcessInstancesAsync(null,query,deleteReason); + } + + public Batch deleteHistoricProcessInstancesAsync(List processInstanceIds, HistoricProcessInstanceQuery query, String deleteReason){ + return commandExecutor.execute(new DeleteHistoricProcessInstancesBatchCmd(processInstanceIds, query, deleteReason)); + } + + public void deleteUserOperationLogEntry(String entryId) { + commandExecutor.execute(new DeleteUserOperationLogEntryCmd(entryId)); + } + + public void deleteHistoricCaseInstance(String caseInstanceId) { + commandExecutor.execute(new DeleteHistoricCaseInstanceCmd(caseInstanceId)); + } + + public void deleteHistoricCaseInstancesBulk(List caseInstanceIds) { + commandExecutor.execute(new DeleteHistoricCaseInstancesBulkCmd(caseInstanceIds)); + } + + public void deleteHistoricDecisionInstance(String decisionDefinitionId) { + deleteHistoricDecisionInstanceByDefinitionId(decisionDefinitionId); + } + + @Override + public void deleteHistoricDecisionInstancesBulk(List decisionInstanceIds) { + commandExecutor.execute(new DeleteHistoricDecisionInstancesBulkCmd(decisionInstanceIds)); + } + + public void deleteHistoricDecisionInstanceByDefinitionId(String decisionDefinitionId) { + commandExecutor.execute(new DeleteHistoricDecisionInstanceByDefinitionIdCmd(decisionDefinitionId)); + } + + public void deleteHistoricDecisionInstanceByInstanceId(String historicDecisionInstanceId){ + commandExecutor.execute(new DeleteHistoricDecisionInstanceByInstanceIdCmd(historicDecisionInstanceId)); + } + + public Batch deleteHistoricDecisionInstancesAsync(List decisionInstanceIds, String deleteReason) { + return deleteHistoricDecisionInstancesAsync(decisionInstanceIds, null, deleteReason); + } + + public Batch deleteHistoricDecisionInstancesAsync(HistoricDecisionInstanceQuery query, String deleteReason) { + return deleteHistoricDecisionInstancesAsync(null, query, deleteReason); + } + + public Batch deleteHistoricDecisionInstancesAsync(List decisionInstanceIds, HistoricDecisionInstanceQuery query, String deleteReason) { + return commandExecutor.execute(new DeleteHistoricDecisionInstancesBatchCmd(decisionInstanceIds, query, deleteReason)); + } + + @Override + public void deleteHistoricVariableInstance(String variableInstanceId) { + commandExecutor.execute(new DeleteHistoricVariableInstanceCmd(variableInstanceId)); + } + + @Override + public void deleteHistoricVariableInstancesByProcessInstanceId(String processInstanceId) { + commandExecutor.execute(new DeleteHistoricVariableInstancesByProcessInstanceIdCmd(processInstanceId)); + } + + public NativeHistoricProcessInstanceQuery createNativeHistoricProcessInstanceQuery() { + return new NativeHistoricProcessInstanceQueryImpl(commandExecutor); + } + + public NativeHistoricTaskInstanceQuery createNativeHistoricTaskInstanceQuery() { + return new NativeHistoricTaskInstanceQueryImpl(commandExecutor); + } + + public NativeHistoricActivityInstanceQuery createNativeHistoricActivityInstanceQuery() { + return new NativeHistoricActivityInstanceQueryImpl(commandExecutor); + } + + public NativeHistoricCaseInstanceQuery createNativeHistoricCaseInstanceQuery() { + return new NativeHistoricCaseInstanceQueryImpl(commandExecutor); + } + + public NativeHistoricCaseActivityInstanceQuery createNativeHistoricCaseActivityInstanceQuery() { + return new NativeHistoricCaseActivityInstanceQueryImpl(commandExecutor); + } + + public NativeHistoricDecisionInstanceQuery createNativeHistoricDecisionInstanceQuery() { + return new NativeHistoryDecisionInstanceQueryImpl(commandExecutor); + } + + public NativeHistoricVariableInstanceQuery createNativeHistoricVariableInstanceQuery() { + return new NativeHistoricVariableInstanceQueryImpl(commandExecutor); + } + + public HistoricJobLogQuery createHistoricJobLogQuery() { + return new HistoricJobLogQueryImpl(commandExecutor); + } + + public String getHistoricJobLogExceptionStacktrace(String historicJobLogId) { + return commandExecutor.execute(new GetHistoricJobLogExceptionStacktraceCmd(historicJobLogId)); + } + + public HistoricProcessInstanceReport createHistoricProcessInstanceReport() { + return new HistoricProcessInstanceReportImpl(commandExecutor); + } + + public HistoricTaskInstanceReport createHistoricTaskInstanceReport() { + return new HistoricTaskInstanceReportImpl(commandExecutor); + } + + public CleanableHistoricProcessInstanceReport createCleanableHistoricProcessInstanceReport() { + return new CleanableHistoricProcessInstanceReportImpl(commandExecutor); + } + + public CleanableHistoricDecisionInstanceReport createCleanableHistoricDecisionInstanceReport() { + return new CleanableHistoricDecisionInstanceReportImpl(commandExecutor); + } + + public CleanableHistoricCaseInstanceReport createCleanableHistoricCaseInstanceReport() { + return new CleanableHistoricCaseInstanceReportImpl(commandExecutor); + } + + public CleanableHistoricBatchReport createCleanableHistoricBatchReport() { + return new CleanableHistoricBatchReportImpl(commandExecutor); + } + + public HistoricBatchQuery createHistoricBatchQuery() { + return new HistoricBatchQueryImpl(commandExecutor); + } + + public void deleteHistoricBatch(String batchId) { + commandExecutor.execute(new DeleteHistoricBatchCmd(batchId)); + } + + @Override + public HistoricDecisionInstanceStatisticsQuery createHistoricDecisionInstanceStatisticsQuery(String decisionRequirementsDefinitionId) { + return new HistoricDecisionInstanceStatisticsQueryImpl(decisionRequirementsDefinitionId, commandExecutor); + } + + @Override + public HistoricExternalTaskLogQuery createHistoricExternalTaskLogQuery() { + return new HistoricExternalTaskLogQueryImpl(commandExecutor); + } + + @Override + public String getHistoricExternalTaskLogErrorDetails(String historicExternalTaskLogId) { + return commandExecutor.execute(new GetHistoricExternalTaskLogErrorDetailsCmd(historicExternalTaskLogId)); + } + + public SetRemovalTimeSelectModeForHistoricProcessInstancesBuilder setRemovalTimeToHistoricProcessInstances() { + return new SetRemovalTimeToHistoricProcessInstancesBuilderImpl(commandExecutor); + } + + public SetRemovalTimeSelectModeForHistoricDecisionInstancesBuilder setRemovalTimeToHistoricDecisionInstances() { + return new SetRemovalTimeToHistoricDecisionInstancesBuilderImpl(commandExecutor); + } + + public SetRemovalTimeSelectModeForHistoricBatchesBuilder setRemovalTimeToHistoricBatches() { + return new SetRemovalTimeToHistoricBatchesBuilderImpl(commandExecutor); + } + + public void setAnnotationForOperationLogById(String operationId, String annotation) { + commandExecutor.execute(new SetAnnotationForOperationLog(operationId, annotation)); + } + + public void clearAnnotationForOperationLogById(String operationId) { + commandExecutor.execute(new SetAnnotationForOperationLog(operationId, null)); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoryTimeToLiveParser.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoryTimeToLiveParser.java new file mode 100644 index 0000000000000000000000000000000000000000..f4855c8a12e11b3d84470c4af4912dbc14f7feb5 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/HistoryTimeToLiveParser.java @@ -0,0 +1,143 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse.CAMUNDA_BPMN_EXTENSIONS_NS; + +import java.util.Objects; +import org.camunda.bpm.engine.exception.NotAllowedException; +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.impl.cfg.ConfigurationLogger; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.util.ParseUtil; +import org.camunda.bpm.engine.impl.util.xml.Element; +import org.camunda.bpm.model.cmmn.instance.Case; +import org.camunda.bpm.model.dmn.instance.Decision; + +/** + * Class that encapsulates the business logic of parsing HistoryTimeToLive of different deployable resources (process, definition, case). + */ +public class HistoryTimeToLiveParser { + + protected static final ConfigurationLogger LOG = ConfigurationLogger.CONFIG_LOGGER; + + protected final boolean enforceNonNullValue; + protected final String httlConfigValue; + + protected HistoryTimeToLiveParser(boolean enforceNonNullValue, String httlConfigValue) { + this.enforceNonNullValue = enforceNonNullValue; + this.httlConfigValue = httlConfigValue; + } + + public static HistoryTimeToLiveParser create() { + ProcessEngineConfigurationImpl config = Context.getProcessEngineConfiguration(); + Objects.requireNonNull(config, "HistoryTimeToLiveParser requires a non null config to be created"); + + return create(config); + } + + public static HistoryTimeToLiveParser create(CommandContext context) { + ProcessEngineConfigurationImpl config = context.getProcessEngineConfiguration(); + + return create(config); + } + + public static HistoryTimeToLiveParser create(ProcessEngineConfigurationImpl config) { + boolean enforceHistoryTimeToLive = config.isEnforceHistoryTimeToLive(); + String historyTimeToLive = config.getHistoryTimeToLive(); + + return new HistoryTimeToLiveParser(enforceHistoryTimeToLive, historyTimeToLive); + } + + public void validate(Integer historyTimeToLive) { + if (enforceNonNullValue && historyTimeToLive == null) { + throw new NotAllowedException("Null historyTimeToLive values are not allowed"); + } + } + + public Integer parse(Element processElement, String definitionKey, boolean skipEnforceTtl) { + String historyTimeToLiveString = processElement.attributeNS(CAMUNDA_BPMN_EXTENSIONS_NS, "historyTimeToLive"); + + return parseAndValidate(historyTimeToLiveString, definitionKey, skipEnforceTtl); + } + + public Integer parse(Case caseElement, String definitionKey, boolean skipEnforceTtl) { + String historyTimeToLiveString = caseElement.getCamundaHistoryTimeToLiveString(); + + return parseAndValidate(historyTimeToLiveString, definitionKey, skipEnforceTtl); + } + + public Integer parse(Decision decision, String definitionKey, boolean skipEnforceTtl) { + String historyTimeToLiveString = decision.getCamundaHistoryTimeToLiveString(); + + return parseAndValidate(historyTimeToLiveString, definitionKey, skipEnforceTtl); + } + + /** + * Parses the given HistoryTimeToLive String expression and then executes any applicable validation before returning + * the parsed value. + * + * @param historyTimeToLiveString the history time to live string expression in ISO-8601 format + * @param definitionKey the correlated definition key that this historyTimeToLive was fetched from + * (process definition key for processes, decision definition key for decisions, case definition key for cases). + * @param skipEnforceTtl skips enforcing the TTL. + * @return the parsed integer value of history time to live + * @throws NotValidException in case enforcement of non-null values is on and the parsed result was null + */ + protected Integer parseAndValidate(String historyTimeToLiveString, String definitionKey, boolean skipEnforceTtl) throws NotValidException { + HTTLParsedResult result = new HTTLParsedResult(historyTimeToLiveString); + + if (!skipEnforceTtl) { + if (result.isInValidAgainstConfig()) { + throw LOG.logErrorNoTTLConfigured(); + } + + if (result.hasLongerModelValueThanGlobalConfig()) { + LOG.logModelHTTLLongerThanGlobalConfiguration(definitionKey); + } + } + + return result.valueAsInteger; + } + + protected class HTTLParsedResult { + + protected final boolean systemDefaultConfigWillBeUsed; + protected final String value; + protected final Integer valueAsInteger; + + public HTTLParsedResult(String historyTimeToLiveString) { + this.systemDefaultConfigWillBeUsed = (historyTimeToLiveString == null); + this.value = systemDefaultConfigWillBeUsed ? httlConfigValue : historyTimeToLiveString; + this.valueAsInteger = ParseUtil.parseHistoryTimeToLive(value); + } + + protected boolean isInValidAgainstConfig() { + return enforceNonNullValue && (valueAsInteger == null); + } + + protected boolean hasLongerModelValueThanGlobalConfig() { + return !systemDefaultConfigWillBeUsed // only values originating from models make sense to be logged + && valueAsInteger != null + && httlConfigValue != null && !httlConfigValue.isEmpty() + && valueAsInteger > ParseUtil.parseHistoryTimeToLive(httlConfigValue); + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/IdentityServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/IdentityServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a25f55278516c16d7441efeb51c5da1985d79d5f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/IdentityServiceImpl.java @@ -0,0 +1,318 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.IdentityService; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.identity.PasswordPolicyResult; +import org.camunda.bpm.engine.identity.Group; +import org.camunda.bpm.engine.identity.GroupQuery; +import org.camunda.bpm.engine.identity.NativeUserQuery; +import org.camunda.bpm.engine.identity.PasswordPolicy; +import org.camunda.bpm.engine.identity.PasswordPolicyRule; +import org.camunda.bpm.engine.identity.Picture; +import org.camunda.bpm.engine.identity.Tenant; +import org.camunda.bpm.engine.identity.TenantQuery; +import org.camunda.bpm.engine.identity.User; +import org.camunda.bpm.engine.identity.UserQuery; +import org.camunda.bpm.engine.impl.cmd.CheckPassword; +import org.camunda.bpm.engine.impl.cmd.GetPasswordPolicyCmd; +import org.camunda.bpm.engine.impl.cmd.CreateGroupCmd; +import org.camunda.bpm.engine.impl.cmd.CreateGroupQueryCmd; +import org.camunda.bpm.engine.impl.cmd.CreateMembershipCmd; +import org.camunda.bpm.engine.impl.cmd.CreateNativeUserQueryCmd; +import org.camunda.bpm.engine.impl.cmd.CreateTenantCmd; +import org.camunda.bpm.engine.impl.cmd.CreateTenantGroupMembershipCmd; +import org.camunda.bpm.engine.impl.cmd.CreateTenantQueryCmd; +import org.camunda.bpm.engine.impl.cmd.CreateTenantUserMembershipCmd; +import org.camunda.bpm.engine.impl.cmd.CreateUserCmd; +import org.camunda.bpm.engine.impl.cmd.CreateUserQueryCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteGroupCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteMembershipCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteTenantCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteTenantGroupMembershipCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteTenantUserMembershipCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteUserCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteUserInfoCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteUserPictureCmd; +import org.camunda.bpm.engine.impl.cmd.GetUserAccountCmd; +import org.camunda.bpm.engine.impl.cmd.GetUserInfoCmd; +import org.camunda.bpm.engine.impl.cmd.GetUserInfoKeysCmd; +import org.camunda.bpm.engine.impl.cmd.GetUserPictureCmd; +import org.camunda.bpm.engine.impl.cmd.IsIdentityServiceReadOnlyCmd; +import org.camunda.bpm.engine.impl.cmd.SaveGroupCmd; +import org.camunda.bpm.engine.impl.cmd.SaveTenantCmd; +import org.camunda.bpm.engine.impl.cmd.SaveUserCmd; +import org.camunda.bpm.engine.impl.cmd.SetUserInfoCmd; +import org.camunda.bpm.engine.impl.cmd.SetUserPictureCmd; +import org.camunda.bpm.engine.impl.cmd.UnlockUserCmd; +import org.camunda.bpm.engine.impl.identity.Account; +import org.camunda.bpm.engine.impl.identity.Authentication; +import org.camunda.bpm.engine.impl.identity.PasswordPolicyResultImpl; +import org.camunda.bpm.engine.impl.persistence.entity.IdentityInfoEntity; +import org.camunda.bpm.engine.impl.util.EnsureUtil; +import org.camunda.bpm.engine.impl.util.ExceptionUtil; + + +/** + * @author Tom Baeyens + */ +public class IdentityServiceImpl extends ServiceImpl implements IdentityService { + + /** thread local holding the current authentication */ + private ThreadLocal currentAuthentication = new ThreadLocal(); + + public boolean isReadOnly() { + return commandExecutor.execute(new IsIdentityServiceReadOnlyCmd()); + } + + public Group newGroup(String groupId) { + return commandExecutor.execute(new CreateGroupCmd(groupId)); + } + + public User newUser(String userId) { + return commandExecutor.execute(new CreateUserCmd(userId)); + } + + public Tenant newTenant(String tenantId) { + return commandExecutor.execute(new CreateTenantCmd(tenantId)); + } + + public void saveGroup(Group group) { + + try { + commandExecutor.execute(new SaveGroupCmd(group)); + } catch (ProcessEngineException ex) { + if (ExceptionUtil.checkConstraintViolationException(ex)) { + throw new BadUserRequestException("The group already exists", ex); + } + throw ex; + } + } + + public void saveUser(User user) { + saveUser(user, false); + } + + public void saveUser(User user, boolean skipPasswordPolicy) { + try { + commandExecutor.execute(new SaveUserCmd(user, skipPasswordPolicy)); + } catch (ProcessEngineException ex) { + if (ExceptionUtil.checkConstraintViolationException(ex)) { + throw new BadUserRequestException("The user already exists", ex); + } + throw ex; + } + } + + public void saveTenant(Tenant tenant) { + + try { + commandExecutor.execute(new SaveTenantCmd(tenant)); + } catch (ProcessEngineException ex) { + if (ExceptionUtil.checkConstraintViolationException(ex)) { + throw new BadUserRequestException("The tenant already exists", ex); + } + throw ex; + } + } + + public UserQuery createUserQuery() { + return commandExecutor.execute(new CreateUserQueryCmd()); + } + + @Override + public NativeUserQuery createNativeUserQuery() { + return commandExecutor.execute(new CreateNativeUserQueryCmd()); + } + + public GroupQuery createGroupQuery() { + return commandExecutor.execute(new CreateGroupQueryCmd()); + } + + public TenantQuery createTenantQuery() { + return commandExecutor.execute(new CreateTenantQueryCmd()); + } + + public void createMembership(String userId, String groupId) { + commandExecutor.execute(new CreateMembershipCmd(userId, groupId)); + } + + public void deleteGroup(String groupId) { + commandExecutor.execute(new DeleteGroupCmd(groupId)); + } + + public void deleteMembership(String userId, String groupId) { + commandExecutor.execute(new DeleteMembershipCmd(userId, groupId)); + } + + public boolean checkPassword(String userId, String password) { + return commandExecutor.execute(new CheckPassword(userId, password)); + } + + public PasswordPolicyResult checkPasswordAgainstPolicy(String candidatePassword, User user) { + return checkPasswordAgainstPolicy(getPasswordPolicy(), candidatePassword, user); + } + + public PasswordPolicyResult checkPasswordAgainstPolicy(String password) { + return checkPasswordAgainstPolicy(getPasswordPolicy(), password, null); + } + + public PasswordPolicyResult checkPasswordAgainstPolicy(PasswordPolicy policy, + String candidatePassword, + User user) { + EnsureUtil.ensureNotNull("policy", policy); + EnsureUtil.ensureNotNull("password", candidatePassword); + + List violatedRules = new ArrayList<>(); + List fulfilledRules = new ArrayList<>(); + + for (PasswordPolicyRule rule : policy.getRules()) { + if (rule.execute(candidatePassword, user)) { + fulfilledRules.add(rule); + } else { + violatedRules.add(rule); + } + } + return new PasswordPolicyResultImpl(violatedRules, fulfilledRules); + + } + + public PasswordPolicyResult checkPasswordAgainstPolicy(PasswordPolicy policy, String password) { + return checkPasswordAgainstPolicy(policy, password, null); + } + + public PasswordPolicy getPasswordPolicy() { + return commandExecutor.execute(new GetPasswordPolicyCmd()); + } + + public void unlockUser(String userId) { + commandExecutor.execute(new UnlockUserCmd(userId)); + } + + public void deleteUser(String userId) { + commandExecutor.execute(new DeleteUserCmd(userId)); + } + + public void deleteTenant(String tenantId) { + commandExecutor.execute(new DeleteTenantCmd(tenantId)); + } + + public void setUserPicture(String userId, Picture picture) { + commandExecutor.execute(new SetUserPictureCmd(userId, picture)); + } + + public Picture getUserPicture(String userId) { + return commandExecutor.execute(new GetUserPictureCmd(userId)); + } + + public void deleteUserPicture(String userId) { + commandExecutor.execute(new DeleteUserPictureCmd(userId)); + } + + public void setAuthenticatedUserId(String authenticatedUserId) { + setAuthentication(new Authentication(authenticatedUserId, null)); + } + + public void setAuthentication(Authentication auth) { + if(auth == null) { + clearAuthentication(); + } else { + if (auth.getUserId() != null) { + EnsureUtil.ensureValidIndividualResourceId("Invalid user id provided", auth.getUserId()); + } + if (auth.getGroupIds() != null) { + EnsureUtil.ensureValidIndividualResourceIds("At least one invalid group id provided", auth.getGroupIds()); + } + if (auth.getTenantIds() != null) { + EnsureUtil.ensureValidIndividualResourceIds("At least one invalid tenant id provided", auth.getTenantIds()); + } + + currentAuthentication.set(auth); + } + } + + public void setAuthentication(String userId, List groups) { + setAuthentication(new Authentication(userId, groups)); + } + + public void setAuthentication(String userId, List groups, List tenantIds) { + setAuthentication(new Authentication(userId, groups, tenantIds)); + } + + public void clearAuthentication() { + currentAuthentication.remove(); + } + + public Authentication getCurrentAuthentication() { + return currentAuthentication.get(); + } + + public String getUserInfo(String userId, String key) { + return commandExecutor.execute(new GetUserInfoCmd(userId, key)); + } + + public List getUserInfoKeys(String userId) { + return commandExecutor.execute(new GetUserInfoKeysCmd(userId, IdentityInfoEntity.TYPE_USERINFO)); + } + + public List getUserAccountNames(String userId) { + return commandExecutor.execute(new GetUserInfoKeysCmd(userId, IdentityInfoEntity.TYPE_USERACCOUNT)); + } + + public void setUserInfo(String userId, String key, String value) { + commandExecutor.execute(new SetUserInfoCmd(userId, key, value)); + } + + public void deleteUserInfo(String userId, String key) { + commandExecutor.execute(new DeleteUserInfoCmd(userId, key)); + } + + public void deleteUserAccount(String userId, String accountName) { + commandExecutor.execute(new DeleteUserInfoCmd(userId, accountName)); + } + + public Account getUserAccount(String userId, String userPassword, String accountName) { + return commandExecutor.execute(new GetUserAccountCmd(userId, userPassword, accountName)); + } + + public void setUserAccount(String userId, String userPassword, String accountName, String accountUsername, String accountPassword, Map accountDetails) { + commandExecutor.execute(new SetUserInfoCmd(userId, userPassword, accountName, accountUsername, accountPassword, accountDetails)); + } + + public void createTenantUserMembership(String tenantId, String userId) { + commandExecutor.execute(new CreateTenantUserMembershipCmd(tenantId, userId)); + } + + public void createTenantGroupMembership(String tenantId, String groupId) { + commandExecutor.execute(new CreateTenantGroupMembershipCmd(tenantId, groupId)); + } + + public void deleteTenantUserMembership(String tenantId, String userId) { + commandExecutor.execute(new DeleteTenantUserMembershipCmd(tenantId, userId)); + } + + public void deleteTenantGroupMembership(String tenantId, String groupId) { + commandExecutor.execute(new DeleteTenantGroupMembershipCmd(tenantId, groupId)); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/IncidentQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/IncidentQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..09b70f1aba71ba1182dc686d51b24f2338345d7a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/IncidentQueryImpl.java @@ -0,0 +1,233 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.Incident; +import org.camunda.bpm.engine.runtime.IncidentQuery; + +/** + * @author roman.smirnov + */ +public class IncidentQueryImpl extends AbstractQuery implements IncidentQuery, Serializable { + + private static final long serialVersionUID = 1L; + + protected String id; + protected String incidentType; + protected String incidentMessage; + protected String incidentMessageLike; + protected String executionId; + protected Date incidentTimestampBefore; + protected Date incidentTimestampAfter; + protected String activityId; + protected String failedActivityId; + protected String processInstanceId; + protected String processDefinitionId; + protected String[] processDefinitionKeys; + protected String causeIncidentId; + protected String rootCauseIncidentId; + protected String configuration; + protected String[] tenantIds; + protected String[] jobDefinitionIds; + + public IncidentQueryImpl() { + } + + public IncidentQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public IncidentQuery incidentId(String incidentId) { + this.id = incidentId; + return this; + } + + public IncidentQuery incidentType(String incidentType) { + this.incidentType = incidentType; + return this; + } + + public IncidentQuery incidentMessage(String incidentMessage) { + this.incidentMessage = incidentMessage; + return this; + } + + public IncidentQuery incidentMessageLike(String incidentMessageLike) { + this.incidentMessageLike = incidentMessageLike; + return this; + } + + public IncidentQuery executionId(String executionId) { + this.executionId = executionId; + return this; + } + + public IncidentQuery incidentTimestampBefore(Date incidentTimestampBefore) { + this.incidentTimestampBefore = incidentTimestampBefore; + return this; + } + + public IncidentQuery incidentTimestampAfter(Date incidentTimestampAfter) { + this.incidentTimestampAfter = incidentTimestampAfter; + return this; + } + + public IncidentQuery activityId(String activityId) { + this.activityId = activityId; + return this; + } + + public IncidentQuery failedActivityId(String activityId) { + this.failedActivityId = activityId; + return this; + } + + public IncidentQuery processInstanceId(String processInstanceId) { + this.processInstanceId = processInstanceId; + return this; + } + + public IncidentQuery processDefinitionId(String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + return this; + } + + public IncidentQuery processDefinitionKeyIn(String... processDefinitionKeys) { + ensureNotNull("processDefinitionKeys", (Object[]) processDefinitionKeys); + this.processDefinitionKeys = processDefinitionKeys; + return this; + } + + public IncidentQuery causeIncidentId(String causeIncidentId) { + this.causeIncidentId = causeIncidentId; + return this; + } + + public IncidentQuery rootCauseIncidentId(String rootCauseIncidentId) { + this.rootCauseIncidentId = rootCauseIncidentId; + return this; + } + + public IncidentQuery configuration(String configuration) { + this.configuration = configuration; + return this; + } + + public IncidentQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + return this; + } + + public IncidentQuery jobDefinitionIdIn(String... jobDefinitionIds) { + ensureNotNull("jobDefinitionIds", (Object[]) jobDefinitionIds); + this.jobDefinitionIds = jobDefinitionIds; + return this; + } + + //ordering //////////////////////////////////////////////////// + + public IncidentQuery orderByIncidentId() { + orderBy(IncidentQueryProperty.INCIDENT_ID); + return this; + } + + public IncidentQuery orderByIncidentTimestamp() { + orderBy(IncidentQueryProperty.INCIDENT_TIMESTAMP); + return this; + } + + public IncidentQuery orderByIncidentType() { + orderBy(IncidentQueryProperty.INCIDENT_TYPE); + return this; + } + + public IncidentQuery orderByExecutionId() { + orderBy(IncidentQueryProperty.EXECUTION_ID); + return this; + } + + public IncidentQuery orderByActivityId() { + orderBy(IncidentQueryProperty.ACTIVITY_ID); + return this; + } + + public IncidentQuery orderByProcessInstanceId() { + orderBy(IncidentQueryProperty.PROCESS_INSTANCE_ID); + return this; + } + + public IncidentQuery orderByProcessDefinitionId() { + orderBy(IncidentQueryProperty.PROCESS_DEFINITION_ID); + return this; + } + + public IncidentQuery orderByCauseIncidentId() { + orderBy(IncidentQueryProperty.CAUSE_INCIDENT_ID); + return this; + } + + public IncidentQuery orderByRootCauseIncidentId() { + orderBy(IncidentQueryProperty.ROOT_CAUSE_INCIDENT_ID); + return this; + } + + public IncidentQuery orderByConfiguration() { + orderBy(IncidentQueryProperty.CONFIGURATION); + return this; + } + + public IncidentQuery orderByTenantId() { + return orderBy(IncidentQueryProperty.TENANT_ID); + } + + @Override + public IncidentQuery orderByIncidentMessage() { + return orderBy(IncidentQueryProperty.INCIDENT_MESSAGE); + } + + //results //////////////////////////////////////////////////// + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getIncidentManager() + .findIncidentCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getIncidentManager() + .findIncidentByQueryCriteria(this, page); + } + + public String[] getProcessDefinitionKeys() { + return processDefinitionKeys; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/IncidentQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/IncidentQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..66e3ab4bdaab0a7f84949dacf2e0c8836faeeae6 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/IncidentQueryProperty.java @@ -0,0 +1,39 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * @author roman.smirnov + */ +public interface IncidentQueryProperty { + + public static final QueryProperty INCIDENT_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty INCIDENT_MESSAGE = new QueryPropertyImpl("INCIDENT_MSG_"); + public static final QueryProperty INCIDENT_TIMESTAMP = new QueryPropertyImpl("INCIDENT_TIMESTAMP_"); + public static final QueryProperty INCIDENT_TYPE = new QueryPropertyImpl("INCIDENT_TYPE_"); + public static final QueryProperty EXECUTION_ID = new QueryPropertyImpl("EXECUTION_ID_"); + public static final QueryProperty ACTIVITY_ID = new QueryPropertyImpl("ACTIVITY_ID_"); + public static final QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROC_INST_ID_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("PROC_DEF_ID_"); + public static final QueryProperty CAUSE_INCIDENT_ID = new QueryPropertyImpl("CAUSE_INCIDENT_ID_"); + public static final QueryProperty ROOT_CAUSE_INCIDENT_ID = new QueryPropertyImpl("ROOT_CAUSE_INCIDENT_ID_"); + public static final QueryProperty CONFIGURATION = new QueryPropertyImpl("CONFIGURATION_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobDefinitionQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobDefinitionQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..dc3cb942372dc3de624b98dde6a712f21ff3e426 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobDefinitionQueryImpl.java @@ -0,0 +1,208 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.io.Serializable; +import java.util.List; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.SuspensionState; +import org.camunda.bpm.engine.management.JobDefinition; +import org.camunda.bpm.engine.management.JobDefinitionQuery; + +/** + * @author roman.smirnov + */ +public class JobDefinitionQueryImpl extends AbstractQuery implements JobDefinitionQuery, Serializable { + + private static final long serialVersionUID = 1L; + + protected String id; + protected String[] activityIds; + protected String processDefinitionId; + protected String processDefinitionKey; + protected String jobType; + protected String jobConfiguration; + protected SuspensionState suspensionState; + protected Boolean withOverridingJobPriority; + + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + protected boolean includeJobDefinitionsWithoutTenantId = false; + + public JobDefinitionQueryImpl() { + } + + public JobDefinitionQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public JobDefinitionQuery jobDefinitionId(String jobDefinitionId) { + ensureNotNull("Job definition id", jobDefinitionId); + this.id = jobDefinitionId; + return this; + } + + public JobDefinitionQuery activityIdIn(String... activityIds) { + ensureNotNull("Activity ids", (Object[]) activityIds); + this.activityIds = activityIds; + return this; + } + + public JobDefinitionQuery processDefinitionId(String processDefinitionId) { + ensureNotNull("Process definition id", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + public JobDefinitionQuery processDefinitionKey(String processDefinitionKey) { + ensureNotNull("Process definition key", processDefinitionKey); + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public JobDefinitionQuery jobType(String jobType) { + ensureNotNull("Job type", jobType); + this.jobType = jobType; + return this; + } + + public JobDefinitionQuery jobConfiguration(String jobConfiguration) { + ensureNotNull("Job configuration", jobConfiguration); + this.jobConfiguration = jobConfiguration; + return this; + } + + public JobDefinitionQuery active() { + this.suspensionState = SuspensionState.ACTIVE; + return this; + } + + public JobDefinitionQuery suspended() { + this.suspensionState = SuspensionState.SUSPENDED; + return this; + } + + public JobDefinitionQuery withOverridingJobPriority() { + this.withOverridingJobPriority = true; + return this; + } + + public JobDefinitionQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public JobDefinitionQuery withoutTenantId() { + isTenantIdSet = true; + this.tenantIds = null; + return this; + } + + public JobDefinitionQuery includeJobDefinitionsWithoutTenantId() { + this.includeJobDefinitionsWithoutTenantId = true; + return this; + } + + // order by /////////////////////////////////////////// + + public JobDefinitionQuery orderByJobDefinitionId() { + return orderBy(JobDefinitionQueryProperty.JOB_DEFINITION_ID); + } + + public JobDefinitionQuery orderByActivityId() { + return orderBy(JobDefinitionQueryProperty.ACTIVITY_ID); + } + + public JobDefinitionQuery orderByProcessDefinitionId() { + return orderBy(JobDefinitionQueryProperty.PROCESS_DEFINITION_ID); + } + + public JobDefinitionQuery orderByProcessDefinitionKey() { + return orderBy(JobDefinitionQueryProperty.PROCESS_DEFINITION_KEY); + } + + public JobDefinitionQuery orderByJobType() { + return orderBy(JobDefinitionQueryProperty.JOB_TYPE); + } + + public JobDefinitionQuery orderByJobConfiguration() { + return orderBy(JobDefinitionQueryProperty.JOB_CONFIGURATION); + } + + public JobDefinitionQuery orderByTenantId() { + return orderBy(JobDefinitionQueryProperty.TENANT_ID); + } + + // results //////////////////////////////////////////// + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getJobDefinitionManager() + .findJobDefinitionCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getJobDefinitionManager() + .findJobDefnitionByQueryCriteria(this, page); + } + + // getters ///////////////////////////////////////////// + + public String getId() { + return id; + } + + public String[] getActivityIds() { + return activityIds; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public String getJobType() { + return jobType; + } + + public String getJobConfiguration() { + return jobConfiguration; + } + + public SuspensionState getSuspensionState() { + return suspensionState; + } + + public Boolean getWithOverridingJobPriority() { + return withOverridingJobPriority; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobDefinitionQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobDefinitionQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..f59bbca92bb6c67a7473732b1cdb63b644a4b60d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobDefinitionQueryProperty.java @@ -0,0 +1,37 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.management.JobDefinitionQuery; +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * Contains the possible properties that can be used in a {@link JobDefinitionQuery}. + * + * @author roman.smirnov + */ +public interface JobDefinitionQueryProperty { + + public static final QueryProperty JOB_DEFINITION_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty ACTIVITY_ID = new QueryPropertyImpl("ACT_ID_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("PROC_DEF_ID_"); + public static final QueryProperty PROCESS_DEFINITION_KEY = new QueryPropertyImpl("PROC_DEF_KEY_"); + public static final QueryProperty JOB_TYPE = new QueryPropertyImpl("JOB_TYPE_"); + public static final QueryProperty JOB_CONFIGURATION = new QueryPropertyImpl("JOB_CONFIGURATION_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..40b9305de3be1c01a8889f977457270e1751419e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobQueryImpl.java @@ -0,0 +1,415 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotEmpty; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Set; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.SuspensionState; +import org.camunda.bpm.engine.impl.util.ClockUtil; +import org.camunda.bpm.engine.impl.util.CompareUtil; +import org.camunda.bpm.engine.impl.util.ImmutablePair; +import org.camunda.bpm.engine.runtime.Job; +import org.camunda.bpm.engine.runtime.JobQuery; + + +/** + * @author Joram Barrez + * @author Tom Baeyens + * @author Falko Menge + */ +public class JobQueryImpl extends AbstractQuery implements JobQuery, Serializable { + + private static final long serialVersionUID = 1L; + protected String activityId; + protected String id; + protected Set ids; + protected String jobDefinitionId; + protected String rootProcessInstanceId; + protected String processInstanceId; + protected Set processInstanceIds; + protected String executionId; + protected String processDefinitionId; + protected String processDefinitionKey; + protected boolean retriesLeft; + protected boolean executable; + protected boolean onlyTimers; + protected boolean onlyMessages; + protected Date duedateHigherThan; + protected Date duedateLowerThan; + protected Date duedateHigherThanOrEqual; + protected Date duedateLowerThanOrEqual; + protected Date createdBefore; + protected Date createdAfter; + protected Long priorityHigherThanOrEqual; + protected Long priorityLowerThanOrEqual; + protected boolean withException; + protected String exceptionMessage; + protected String failedActivityId; + protected boolean noRetriesLeft; + protected SuspensionState suspensionState; + protected boolean acquired; + + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + protected boolean includeJobsWithoutTenantId = false; + + public JobQueryImpl() { + } + + public JobQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public JobQuery jobId(String jobId) { + ensureNotNull("Provided job id", jobId); + this.id = jobId; + return this; + } + + public JobQuery jobIds(Set ids) { + ensureNotEmpty("Set of job ids", ids); + this.ids = ids; + return this; + } + + public JobQuery jobDefinitionId(String jobDefinitionId) { + ensureNotNull("Provided job definition id", jobDefinitionId); + this.jobDefinitionId = jobDefinitionId; + return this; + } + + public JobQueryImpl rootProcessInstanceId(String rootProcessInstanceId) { + ensureNotNull("Provided root process instance id", rootProcessInstanceId); + this.rootProcessInstanceId = rootProcessInstanceId; + return this; + } + + public JobQueryImpl processInstanceId(String processInstanceId) { + ensureNotNull("Provided process instance id", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + public JobQuery processInstanceIds(Set processInstanceIds) { + ensureNotEmpty("Set of process instance ids", processInstanceIds); + this.processInstanceIds = processInstanceIds; + return this; + } + + public JobQueryImpl executionId(String executionId) { + ensureNotNull("Provided execution id", executionId); + this.executionId = executionId; + return this; + } + + public JobQuery processDefinitionId(String processDefinitionId) { + ensureNotNull("Provided process definition id", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + public JobQuery processDefinitionKey(String processDefinitionKey) { + ensureNotNull("Provided process instance key", processDefinitionKey); + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public JobQuery activityId(String activityId){ + ensureNotNull("Provided activity id", activityId); + this.activityId = activityId; + return this; + } + + public JobQuery withRetriesLeft() { + retriesLeft = true; + return this; + } + + public JobQuery executable() { + executable = true; + return this; + } + + public JobQuery timers() { + if (onlyMessages) { + throw new ProcessEngineException("Cannot combine onlyTimers() with onlyMessages() in the same query"); + } + this.onlyTimers = true; + return this; + } + + public JobQuery messages() { + if (onlyTimers) { + throw new ProcessEngineException("Cannot combine onlyTimers() with onlyMessages() in the same query"); + } + this.onlyMessages = true; + return this; + } + + public JobQuery duedateHigherThan(Date date) { + ensureNotNull("Provided date", date); + this.duedateHigherThan = date; + return this; + } + + public JobQuery duedateLowerThan(Date date) { + ensureNotNull("Provided date", date); + this.duedateLowerThan = date; + return this; + } + + public JobQuery duedateHigherThen(Date date) { + return duedateHigherThan(date); + } + + public JobQuery duedateHigherThenOrEquals(Date date) { + ensureNotNull("Provided date", date); + this.duedateHigherThanOrEqual = date; + return this; + } + + public JobQuery duedateLowerThen(Date date) { + return duedateLowerThan(date); + } + + public JobQuery duedateLowerThenOrEquals(Date date) { + ensureNotNull("Provided date", date); + this.duedateLowerThanOrEqual = date; + return this; + } + + @Override + public JobQuery createdBefore(Date date) { + ensureNotNull("Provided date", date); + this.createdBefore = date; + return this; + } + + @Override + public JobQuery createdAfter(Date date) { + ensureNotNull("Provided date", date); + this.createdAfter = date; + return this; + } + + public JobQuery priorityHigherThanOrEquals(long priority) { + this.priorityHigherThanOrEqual = priority; + return this; + } + + public JobQuery priorityLowerThanOrEquals(long priority) { + this.priorityLowerThanOrEqual = priority; + return this; + } + + public JobQuery withException() { + this.withException = true; + return this; + } + + public JobQuery exceptionMessage(String exceptionMessage) { + ensureNotNull("Provided exception message", exceptionMessage); + this.exceptionMessage = exceptionMessage; + return this; + } + + public JobQuery failedActivityId(String activityId){ + ensureNotNull("Provided activity id", activityId); + this.failedActivityId = activityId; + return this; + } + + public JobQuery noRetriesLeft() { + noRetriesLeft = true; + return this; + } + + public JobQuery active() { + suspensionState = SuspensionState.ACTIVE; + return this; + } + + public JobQuery suspended() { + suspensionState = SuspensionState.SUSPENDED; + return this; + } + + public JobQuery acquired() { + acquired = true; + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() + || CompareUtil.areNotInAscendingOrder(priorityHigherThanOrEqual, priorityLowerThanOrEqual) + || hasExcludingDueDateParameters() + || CompareUtil.areNotInAscendingOrder(createdAfter, createdBefore); + } + + private boolean hasExcludingDueDateParameters() { + List dueDates = new ArrayList<>(); + if (duedateHigherThan != null && duedateHigherThanOrEqual != null) { + dueDates.add(CompareUtil.min(duedateHigherThan, duedateHigherThanOrEqual)); + dueDates.add(CompareUtil.max(duedateHigherThan, duedateHigherThanOrEqual)); + } else if (duedateHigherThan != null) { + dueDates.add(duedateHigherThan); + } else if (duedateHigherThanOrEqual != null) { + dueDates.add(duedateHigherThanOrEqual); + } + + if (duedateLowerThan != null && duedateLowerThanOrEqual != null) { + dueDates.add(CompareUtil.min(duedateLowerThan, duedateLowerThanOrEqual)); + dueDates.add(CompareUtil.max(duedateLowerThan, duedateLowerThanOrEqual)); + } else if (duedateLowerThan != null) { + dueDates.add(duedateLowerThan); + } else if (duedateLowerThanOrEqual != null) { + dueDates.add(duedateLowerThanOrEqual); + } + + return CompareUtil.areNotInAscendingOrder(dueDates); + } + + public JobQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public JobQuery withoutTenantId() { + isTenantIdSet = true; + this.tenantIds = null; + return this; + } + + public JobQuery includeJobsWithoutTenantId() { + this.includeJobsWithoutTenantId = true; + return this; + } + + //sorting ////////////////////////////////////////// + + public JobQuery orderByJobDuedate() { + return orderBy(JobQueryProperty.DUEDATE); + } + + public JobQuery orderByExecutionId() { + return orderBy(JobQueryProperty.EXECUTION_ID); + } + + public JobQuery orderByJobId() { + return orderBy(JobQueryProperty.JOB_ID); + } + + public JobQuery orderByProcessInstanceId() { + return orderBy(JobQueryProperty.PROCESS_INSTANCE_ID); + } + + public JobQuery orderByProcessDefinitionId() { + return orderBy(JobQueryProperty.PROCESS_DEFINITION_ID); + } + + public JobQuery orderByProcessDefinitionKey() { + return orderBy(JobQueryProperty.PROCESS_DEFINITION_KEY); + } + + public JobQuery orderByJobRetries() { + return orderBy(JobQueryProperty.RETRIES); + } + + public JobQuery orderByJobPriority() { + return orderBy(JobQueryProperty.PRIORITY); + } + + public JobQuery orderByTenantId() { + return orderBy(JobQueryProperty.TENANT_ID); + } + + //results ////////////////////////////////////////// + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getJobManager() + .findJobCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getJobManager() + .findJobsByQueryCriteria(this, page); + } + + @Override + public List> executeDeploymentIdMappingsList(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getJobManager() + .findDeploymentIdMappingsByQueryCriteria(this); + } + + //getters ////////////////////////////////////////// + + public Set getIds() { + return ids; + } + public String getRootProcessInstanceId() { + return rootProcessInstanceId; + } + public String getProcessInstanceId() { + return processInstanceId; + } + public Set getProcessInstanceIds() { + return processInstanceIds; + } + public String getExecutionId() { + return executionId; + } + public boolean getRetriesLeft() { + return retriesLeft; + } + public boolean getExecutable() { + return executable; + } + public Date getNow() { + return ClockUtil.getCurrentTime(); + } + public boolean isWithException() { + return withException; + } + public String getExceptionMessage() { + return exceptionMessage; + } + public boolean getAcquired() { + return acquired; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..5841dc164a7ee88baddadf8fa3d540f386af003f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/JobQueryProperty.java @@ -0,0 +1,40 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; +import org.camunda.bpm.engine.runtime.JobQuery; + +/** + * Contains the possible properties that can be used in a {@link JobQuery}. + * + * @author Joram Barrez + */ +public interface JobQueryProperty { + + public static final QueryProperty JOB_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROCESS_INSTANCE_ID_"); + public static final QueryProperty EXECUTION_ID = new QueryPropertyImpl("EXECUTION_ID_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("PROCESS_DEF_ID_"); + public static final QueryProperty PROCESS_DEFINITION_KEY = new QueryPropertyImpl("PROCESS_DEF_KEY_"); + public static final QueryProperty DUEDATE = new QueryPropertyImpl("DUEDATE_"); + public static final QueryProperty RETRIES = new QueryPropertyImpl("RETRIES_"); + public static final QueryProperty TYPE = new QueryPropertyImpl("TYPE_"); + public static final QueryProperty PRIORITY = new QueryPropertyImpl("PRIORITY_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ManagementServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ManagementServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..10f2c872c782c2949ec23c305a786280a3cc331e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ManagementServiceImpl.java @@ -0,0 +1,776 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.sql.Connection; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.camunda.bpm.application.ProcessApplicationReference; +import org.camunda.bpm.application.ProcessApplicationRegistration; +import org.camunda.bpm.engine.ManagementService; +import org.camunda.bpm.engine.ProcessEngineConfiguration; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.batch.BatchQuery; +import org.camunda.bpm.engine.batch.BatchStatisticsQuery; +import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; +import org.camunda.bpm.engine.impl.batch.BatchQueryImpl; +import org.camunda.bpm.engine.impl.batch.BatchStatisticsQueryImpl; +import org.camunda.bpm.engine.impl.batch.DeleteBatchCmd; +import org.camunda.bpm.engine.impl.cfg.CommandChecker; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.cmd.ActivateBatchCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteJobCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteLicenseKeyCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteMetricsCmd; +import org.camunda.bpm.engine.impl.cmd.DeletePropertyCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteTaskMetricsCmd; +import org.camunda.bpm.engine.impl.cmd.GetHistoryLevelCmd; +import org.camunda.bpm.engine.impl.cmd.GetJobExceptionStacktraceCmd; +import org.camunda.bpm.engine.impl.cmd.GetLicenseKeyCmd; +import org.camunda.bpm.engine.impl.cmd.GetProcessApplicationForDeploymentCmd; +import org.camunda.bpm.engine.impl.cmd.GetPropertiesCmd; +import org.camunda.bpm.engine.impl.cmd.GetTableCountCmd; +import org.camunda.bpm.engine.impl.cmd.GetTableMetaDataCmd; +import org.camunda.bpm.engine.impl.cmd.GetTableNameCmd; +import org.camunda.bpm.engine.impl.cmd.GetTelemetryDataCmd; +import org.camunda.bpm.engine.impl.cmd.GetUniqueTaskWorkerCountCmd; +import org.camunda.bpm.engine.impl.cmd.IsTelemetryEnabledCmd; +import org.camunda.bpm.engine.impl.cmd.PurgeDatabaseAndCacheCmd; +import org.camunda.bpm.engine.impl.cmd.RecalculateJobDuedateCmd; +import org.camunda.bpm.engine.impl.cmd.RegisterDeploymentCmd; +import org.camunda.bpm.engine.impl.cmd.RegisterProcessApplicationCmd; +import org.camunda.bpm.engine.impl.cmd.ReportDbMetricsCmd; +import org.camunda.bpm.engine.impl.cmd.SetJobDefinitionPriorityCmd; +import org.camunda.bpm.engine.impl.cmd.SetJobDuedateCmd; +import org.camunda.bpm.engine.impl.cmd.SetJobPriorityCmd; +import org.camunda.bpm.engine.impl.cmd.SetLicenseKeyCmd; +import org.camunda.bpm.engine.impl.cmd.SetPropertyCmd; +import org.camunda.bpm.engine.impl.cmd.SuspendBatchCmd; +import org.camunda.bpm.engine.impl.cmd.TelemetryConfigureCmd; +import org.camunda.bpm.engine.impl.cmd.UnregisterDeploymentCmd; +import org.camunda.bpm.engine.impl.cmd.UnregisterProcessApplicationCmd; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.sql.DbSqlSession; +import org.camunda.bpm.engine.impl.db.sql.DbSqlSessionFactory; +import org.camunda.bpm.engine.impl.diagnostics.DiagnosticsRegistry; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.ExecuteJobHelper; +import org.camunda.bpm.engine.impl.management.PurgeReport; +import org.camunda.bpm.engine.impl.management.SetJobRetriesBuilderImpl; +import org.camunda.bpm.engine.impl.management.SetJobRetriesByJobsAsyncBuilderImpl; +import org.camunda.bpm.engine.impl.management.SetJobRetriesByProcessAsyncBuilderImpl; +import org.camunda.bpm.engine.impl.management.UpdateJobDefinitionSuspensionStateBuilderImpl; +import org.camunda.bpm.engine.impl.management.UpdateJobSuspensionStateBuilderImpl; +import org.camunda.bpm.engine.impl.metrics.MetricsQueryImpl; +import org.camunda.bpm.engine.impl.metrics.MetricsRegistry; +import org.camunda.bpm.engine.impl.telemetry.dto.LicenseKeyDataImpl; +import org.camunda.bpm.engine.management.ActivityStatisticsQuery; +import org.camunda.bpm.engine.management.DeploymentStatisticsQuery; +import org.camunda.bpm.engine.management.JobDefinitionQuery; +import org.camunda.bpm.engine.management.MetricsQuery; +import org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery; +import org.camunda.bpm.engine.management.SchemaLogQuery; +import org.camunda.bpm.engine.management.SetJobRetriesByJobsAsyncBuilder; +import org.camunda.bpm.engine.management.SetJobRetriesByProcessAsyncBuilder; +import org.camunda.bpm.engine.management.TableMetaData; +import org.camunda.bpm.engine.management.TablePageQuery; +import org.camunda.bpm.engine.management.UpdateJobDefinitionSuspensionStateSelectBuilder; +import org.camunda.bpm.engine.management.UpdateJobSuspensionStateSelectBuilder; +import org.camunda.bpm.engine.runtime.JobQuery; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; +import org.camunda.bpm.engine.telemetry.TelemetryData; + + +/** + * @author Tom Baeyens + * @author Joram Barrez + * @author Falko Menge + * @author Saeid Mizaei + * @author Askar AKhmerov + */ +public class ManagementServiceImpl extends ServiceImpl implements ManagementService { + + protected ProcessEngineConfiguration processEngineConfiguration; + + public ManagementServiceImpl(ProcessEngineConfiguration processEngineConfiguration) { + this.processEngineConfiguration = processEngineConfiguration; + } + + @Override + public ProcessApplicationRegistration registerProcessApplication(String deploymentId, ProcessApplicationReference reference) { + return commandExecutor.execute(new RegisterProcessApplicationCmd(deploymentId, reference)); + } + + @Override + public void unregisterProcessApplication(String deploymentId, boolean removeProcessesFromCache) { + commandExecutor.execute(new UnregisterProcessApplicationCmd(deploymentId, removeProcessesFromCache)); + } + + @Override + public void unregisterProcessApplication(Set deploymentIds, boolean removeProcessesFromCache) { + commandExecutor.execute(new UnregisterProcessApplicationCmd(deploymentIds, removeProcessesFromCache)); + } + + @Override + public String getProcessApplicationForDeployment(String deploymentId) { + return commandExecutor.execute(new GetProcessApplicationForDeploymentCmd(deploymentId)); + } + + @Override + public Map getTableCount() { + return commandExecutor.execute(new GetTableCountCmd()); + } + + @Override + public String getTableName(Class activitiEntityClass) { + return commandExecutor.execute(new GetTableNameCmd(activitiEntityClass)); + } + + @Override + public TableMetaData getTableMetaData(String tableName) { + return commandExecutor.execute(new GetTableMetaDataCmd(tableName)); + } + + @Override + public void executeJob(String jobId) { + ExecuteJobHelper.executeJob(jobId, commandExecutor); + } + + @Override + public void deleteJob(String jobId) { + commandExecutor.execute(new DeleteJobCmd(jobId)); + } + + @Override + public void setJobRetries(String jobId, int retries) { + setJobRetries(retries).jobId(jobId).execute(); + } + + @Override + public void setJobRetries(List jobIds, int retries) { + setJobRetries(retries).jobIds(jobIds).execute(); + } + + @Override + public void setJobRetriesByJobDefinitionId(String jobDefinitionId, int retries) { + setJobRetries(retries).jobDefinitionId(jobDefinitionId).execute(); + } + + @Override + public SetJobRetriesBuilderImpl setJobRetries(int retries) { + return new SetJobRetriesBuilderImpl(commandExecutor, retries); + } + + @Override + public Batch setJobRetriesAsync(List jobIds, int retries) { + return setJobRetriesByJobsAsync(retries) + .jobIds(jobIds) + .executeAsync(); + } + + @Override + public Batch setJobRetriesAsync(JobQuery jobQuery, int retries) { + return setJobRetriesByJobsAsync(retries) + .jobQuery(jobQuery) + .executeAsync(); + } + + @Override + public Batch setJobRetriesAsync(List jobIds, JobQuery jobQuery, int retries) { + return setJobRetriesByJobsAsync(retries) + .jobIds(jobIds) + .jobQuery(jobQuery) + .executeAsync(); + } + + @Override + public Batch setJobRetriesAsync(List processInstanceIds, ProcessInstanceQuery query, int retries) { + return setJobRetriesByProcessAsync(retries) + .processInstanceIds(processInstanceIds) + .processInstanceQuery(query) + .executeAsync(); + } + + @Override + public Batch setJobRetriesAsync(List processInstanceIds, ProcessInstanceQuery query, + HistoricProcessInstanceQuery historicProcessInstanceQuery, + int retries) { + return setJobRetriesByProcessAsync(retries) + .processInstanceIds(processInstanceIds) + .processInstanceQuery(query) + .historicProcessInstanceQuery(historicProcessInstanceQuery) + .executeAsync(); + } + + @Override + public SetJobRetriesByJobsAsyncBuilder setJobRetriesByJobsAsync(int retries) { + return new SetJobRetriesByJobsAsyncBuilderImpl(commandExecutor, retries); + } + + @Override + public SetJobRetriesByProcessAsyncBuilder setJobRetriesByProcessAsync(int retries) { + return new SetJobRetriesByProcessAsyncBuilderImpl(commandExecutor, retries); + } + + @Override + public void setJobDuedate(String jobId, Date newDuedate) { + setJobDuedate(jobId, newDuedate, false); + } + + @Override + public void setJobDuedate(String jobId, Date newDuedate, boolean cascade) { + commandExecutor.execute(new SetJobDuedateCmd(jobId, newDuedate, cascade)); + } + + @Override + public void recalculateJobDuedate(String jobId, boolean creationDateBased) { + commandExecutor.execute(new RecalculateJobDuedateCmd(jobId, creationDateBased)); + } + + @Override + public void setJobPriority(String jobId, long priority) { + commandExecutor.execute(new SetJobPriorityCmd(jobId, priority)); + } + + @Override + public TablePageQuery createTablePageQuery() { + return new TablePageQueryImpl(commandExecutor); + } + + @Override + public JobQuery createJobQuery() { + return new JobQueryImpl(commandExecutor); + } + + @Override + public JobDefinitionQuery createJobDefinitionQuery() { + return new JobDefinitionQueryImpl(commandExecutor); + } + + @Override + public String getJobExceptionStacktrace(String jobId) { + return commandExecutor.execute(new GetJobExceptionStacktraceCmd(jobId)); + } + + @Override + public Map getProperties() { + return commandExecutor.execute(new GetPropertiesCmd()); + } + + @Override + public void setProperty(String name, String value) { + commandExecutor.execute(new SetPropertyCmd(name, value)); + } + + @Override + public void deleteProperty(String name) { + commandExecutor.execute(new DeletePropertyCmd(name)); + } + + @Override + public void setLicenseKey(String licenseKey) { + commandExecutor.execute(new SetLicenseKeyCmd(licenseKey)); + } + + @Override + public String getLicenseKey() { + return commandExecutor.execute(new GetLicenseKeyCmd()); + } + + @Override + public void deleteLicenseKey() { + commandExecutor.execute(new DeleteLicenseKeyCmd(true)); + } + + @Override + public String databaseSchemaUpgrade(Connection connection, String catalog, String schema) { + return commandExecutor.execute(new DbSchemaUpgradeCmd(connection, catalog, schema)); + } + + /** + * Purges the database and the deployment cache. + */ + public PurgeReport purge() { + return commandExecutor.execute(new PurgeDatabaseAndCacheCmd()); + } + + + @Override + public ProcessDefinitionStatisticsQuery createProcessDefinitionStatisticsQuery() { + return new ProcessDefinitionStatisticsQueryImpl(commandExecutor); + } + + @Override + public ActivityStatisticsQuery createActivityStatisticsQuery(String processDefinitionId) { + return new ActivityStatisticsQueryImpl(processDefinitionId, commandExecutor); + } + + @Override + public DeploymentStatisticsQuery createDeploymentStatisticsQuery() { + return new DeploymentStatisticsQueryImpl(commandExecutor); + } + + @Override + public Set getRegisteredDeployments() { + return commandExecutor.execute(new GetRegisteredDeploymentsCmd()); + } + + @Override + public void registerDeploymentForJobExecutor(final String deploymentId) { + commandExecutor.execute(new RegisterDeploymentCmd(deploymentId)); + } + + @Override + public void unregisterDeploymentForJobExecutor(final String deploymentId) { + commandExecutor.execute(new UnregisterDeploymentCmd(deploymentId)); + } + + + @Override + public void activateJobDefinitionById(String jobDefinitionId) { + updateJobDefinitionSuspensionState() + .byJobDefinitionId(jobDefinitionId) + .activate(); + } + + @Override + public void activateJobDefinitionById(String jobDefinitionId, boolean activateJobs) { + updateJobDefinitionSuspensionState() + .byJobDefinitionId(jobDefinitionId) + .includeJobs(activateJobs) + .activate(); + } + + @Override + public void activateJobDefinitionById(String jobDefinitionId, boolean activateJobs, Date activationDate) { + updateJobDefinitionSuspensionState() + .byJobDefinitionId(jobDefinitionId) + .includeJobs(activateJobs) + .executionDate(activationDate) + .activate(); + } + + @Override + public void suspendJobDefinitionById(String jobDefinitionId) { + updateJobDefinitionSuspensionState() + .byJobDefinitionId(jobDefinitionId) + .suspend(); + } + + @Override + public void suspendJobDefinitionById(String jobDefinitionId, boolean suspendJobs) { + updateJobDefinitionSuspensionState() + .byJobDefinitionId(jobDefinitionId) + .includeJobs(suspendJobs) + .suspend(); + } + + @Override + public void suspendJobDefinitionById(String jobDefinitionId, boolean suspendJobs, Date suspensionDate) { + updateJobDefinitionSuspensionState() + .byJobDefinitionId(jobDefinitionId) + .includeJobs(suspendJobs) + .executionDate(suspensionDate) + .suspend(); + } + + @Override + public void activateJobDefinitionByProcessDefinitionId(String processDefinitionId) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .activate(); + } + + @Override + public void activateJobDefinitionByProcessDefinitionId(String processDefinitionId, boolean activateJobs) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .includeJobs(activateJobs) + .activate(); + } + + @Override + public void activateJobDefinitionByProcessDefinitionId(String processDefinitionId, boolean activateJobs, Date activationDate) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .includeJobs(activateJobs) + .executionDate(activationDate) + .activate(); + } + + @Override + public void suspendJobDefinitionByProcessDefinitionId(String processDefinitionId) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .suspend(); + } + + @Override + public void suspendJobDefinitionByProcessDefinitionId(String processDefinitionId, boolean suspendJobs) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .includeJobs(suspendJobs) + .suspend(); + } + + @Override + public void suspendJobDefinitionByProcessDefinitionId(String processDefinitionId, boolean suspendJobs, Date suspensionDate) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .includeJobs(suspendJobs) + .executionDate(suspensionDate) + .suspend(); + } + + @Override + public void activateJobDefinitionByProcessDefinitionKey(String processDefinitionKey) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .activate(); + } + + @Override + public void activateJobDefinitionByProcessDefinitionKey(String processDefinitionKey, boolean activateJobs) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .includeJobs(activateJobs) + .activate(); + } + + @Override + public void activateJobDefinitionByProcessDefinitionKey(String processDefinitionKey, boolean activateJobs, Date activationDate) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .includeJobs(activateJobs) + .executionDate(activationDate) + .activate(); + } + + @Override + public void suspendJobDefinitionByProcessDefinitionKey(String processDefinitionKey) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .suspend(); + } + + @Override + public void suspendJobDefinitionByProcessDefinitionKey(String processDefinitionKey, boolean suspendJobs) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .includeJobs(suspendJobs) + .suspend(); + } + + @Override + public void suspendJobDefinitionByProcessDefinitionKey(String processDefinitionKey, boolean suspendJobs, Date suspensionDate) { + updateJobDefinitionSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .includeJobs(suspendJobs) + .executionDate(suspensionDate) + .suspend(); + } + + @Override + public UpdateJobDefinitionSuspensionStateSelectBuilder updateJobDefinitionSuspensionState() { + return new UpdateJobDefinitionSuspensionStateBuilderImpl(commandExecutor); + } + + @Override + public void activateJobById(String jobId) { + updateJobSuspensionState() + .byJobId(jobId) + .activate(); + } + + @Override + public void activateJobByProcessInstanceId(String processInstanceId) { + updateJobSuspensionState() + .byProcessInstanceId(processInstanceId) + .activate(); + } + + @Override + public void activateJobByJobDefinitionId(String jobDefinitionId) { + updateJobSuspensionState() + .byJobDefinitionId(jobDefinitionId) + .activate(); + } + + @Override + public void activateJobByProcessDefinitionId(String processDefinitionId) { + updateJobSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .activate(); + } + + @Override + public void activateJobByProcessDefinitionKey(String processDefinitionKey) { + updateJobSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .activate(); + } + + @Override + public void suspendJobById(String jobId) { + updateJobSuspensionState() + .byJobId(jobId) + .suspend(); + } + + @Override + public void suspendJobByJobDefinitionId(String jobDefinitionId) { + updateJobSuspensionState() + .byJobDefinitionId(jobDefinitionId) + .suspend(); + } + + @Override + public void suspendJobByProcessInstanceId(String processInstanceId) { + updateJobSuspensionState() + .byProcessInstanceId(processInstanceId) + .suspend(); + } + + @Override + public void suspendJobByProcessDefinitionId(String processDefinitionId) { + updateJobSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .suspend(); + } + + @Override + public void suspendJobByProcessDefinitionKey(String processDefinitionKey) { + updateJobSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .suspend(); + } + + @Override + public UpdateJobSuspensionStateSelectBuilder updateJobSuspensionState() { + return new UpdateJobSuspensionStateBuilderImpl(commandExecutor); + } + + @Override + public int getHistoryLevel() { + return commandExecutor.execute(new GetHistoryLevelCmd()); + } + + @Override + public MetricsQuery createMetricsQuery() { + return new MetricsQueryImpl(commandExecutor); + } + + @Override + public void deleteMetrics(Date timestamp) { + commandExecutor.execute(new DeleteMetricsCmd(timestamp, null)); + } + + @Override + public void deleteMetrics(Date timestamp, String reporter) { + commandExecutor.execute(new DeleteMetricsCmd(timestamp, reporter)); + + } + + @Override + public void reportDbMetricsNow() { + commandExecutor.execute(new ReportDbMetricsCmd()); + } + + @Override + public long getUniqueTaskWorkerCount(Date startTime, Date endTime) { + return commandExecutor.execute(new GetUniqueTaskWorkerCountCmd(startTime, endTime)); + } + + @Override + public void deleteTaskMetrics(Date timestamp) { + commandExecutor.execute(new DeleteTaskMetricsCmd(timestamp)); + } + + @Override + public void setOverridingJobPriorityForJobDefinition(String jobDefinitionId, long priority) { + commandExecutor.execute(new SetJobDefinitionPriorityCmd(jobDefinitionId, priority, false)); + } + + @Override + public void setOverridingJobPriorityForJobDefinition(String jobDefinitionId, long priority, boolean cascade) { + commandExecutor.execute(new SetJobDefinitionPriorityCmd(jobDefinitionId, priority, true)); + } + + @Override + public void clearOverridingJobPriorityForJobDefinition(String jobDefinitionId) { + commandExecutor.execute(new SetJobDefinitionPriorityCmd(jobDefinitionId, null, false)); + } + + @Override + public BatchQuery createBatchQuery() { + return new BatchQueryImpl(commandExecutor); + } + + @Override + public void deleteBatch(String batchId, boolean cascade) { + commandExecutor.execute(new DeleteBatchCmd(batchId, cascade)); + } + + @Override + public void suspendBatchById(String batchId) { + commandExecutor.execute(new SuspendBatchCmd(batchId)); + } + + @Override + public void activateBatchById(String batchId) { + commandExecutor.execute(new ActivateBatchCmd(batchId)); + } + + @Override + public BatchStatisticsQuery createBatchStatisticsQuery() { + return new BatchStatisticsQueryImpl(commandExecutor); + } + + @Override + public SchemaLogQuery createSchemaLogQuery() { + return new SchemaLogQueryImpl(commandExecutor); + } + + /** + * @deprecated The sending telemetry feature is removed. + * Please remove the method references as they are no longer needed. + */ + @Deprecated + @Override + public void toggleTelemetry(boolean enabled) { + commandExecutor.execute(new TelemetryConfigureCmd(enabled)); + } + + /** + * @deprecated The sending telemetry feature is removed. + * Please remove the method references as they are no longer needed. + */ + @Deprecated + @Override + public Boolean isTelemetryEnabled() { + return commandExecutor.execute(new IsTelemetryEnabledCmd()); + } + + @Override + public TelemetryData getTelemetryData() { + return commandExecutor.execute(new GetTelemetryDataCmd()); + } + + /** + * Adds the web application name to the telemetry data of the engine. + * + * @param webapp + * the web application that is used with the engine + * @return whether the web application was successfully added or not + */ + public boolean addWebappToTelemetry(String webapp) { + DiagnosticsRegistry telemetryRegistry = ((ProcessEngineConfigurationImpl) processEngineConfiguration).getDiagnosticsRegistry(); + if (telemetryRegistry != null) { + telemetryRegistry.addWebapp(webapp); + return true; + } + return false; + } + + /** + * Adds the application server information to the telemetry data of the engine. + * + * @param appServerInfo + * a String containing information about the application server + */ + public void addApplicationServerInfoToTelemetry(String appServerInfo) { + DiagnosticsRegistry telemetryRegistry = ((ProcessEngineConfigurationImpl) processEngineConfiguration).getDiagnosticsRegistry(); + if (telemetryRegistry != null) { + telemetryRegistry.setApplicationServer(appServerInfo); + } + } + + /** + * Sets license key information to the telemetry data of the engine. + * + * @param licenseKeyData + * a data object containing various pieces of information + * about the installed license + */ + public void setLicenseKeyForDiagnostics(LicenseKeyDataImpl licenseKeyData) { + DiagnosticsRegistry diagnosticsRegistry = ((ProcessEngineConfigurationImpl) processEngineConfiguration).getDiagnosticsRegistry(); + if (diagnosticsRegistry != null) { + diagnosticsRegistry.setLicenseKey(licenseKeyData); + } + } + + public LicenseKeyDataImpl getLicenseKeyFromDiagnostics() { + DiagnosticsRegistry diagnosticsRegistry = ((ProcessEngineConfigurationImpl) processEngineConfiguration).getDiagnosticsRegistry(); + if (diagnosticsRegistry != null) { + return diagnosticsRegistry.getLicenseKey(); + } + return null; + } + + public void clearDiagnosticsData() { + DiagnosticsRegistry diagnosticsRegistry = ((ProcessEngineConfigurationImpl) processEngineConfiguration).getDiagnosticsRegistry(); + if (diagnosticsRegistry != null) { + diagnosticsRegistry.clear(); + } + MetricsRegistry metricsRegistry = ((ProcessEngineConfigurationImpl) processEngineConfiguration).getMetricsRegistry(); + if(metricsRegistry != null) { + metricsRegistry.clearDiagnosticsMetrics(); + } + deleteMetrics(null); + } + + protected class DbSchemaUpgradeCmd implements Command { + + protected Connection connection; + protected String catalog; + protected String schema; + + public DbSchemaUpgradeCmd(Connection connection, String catalog, String schema) { + this.connection = connection; + this.catalog = catalog; + this.schema = schema; + } + + @Override + public String execute(CommandContext commandContext) { + commandContext.getAuthorizationManager().checkCamundaAdmin(); + DbSqlSessionFactory dbSqlSessionFactory = (DbSqlSessionFactory) commandContext.getSessionFactories().get(DbSqlSession.class); + DbSqlSession dbSqlSession = dbSqlSessionFactory.openSession(connection, catalog, schema); + commandContext.getSessions().put(DbSqlSession.class, dbSqlSession); + dbSqlSession.dbSchemaUpdate(); + + return ""; + } + + } + + protected class GetRegisteredDeploymentsCmd implements Command> { + + @Override + public Set execute(CommandContext commandContext) { + commandContext.getAuthorizationManager().checkCamundaAdminOrPermission(CommandChecker::checkReadRegisteredDeployments); + Set registeredDeployments = Context.getProcessEngineConfiguration().getRegisteredDeployments(); + return new HashSet<>(registeredDeployments); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/MessageCorrelationAsyncBuilderImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/MessageCorrelationAsyncBuilderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..78f4a1ae8770de2ea56469c752c53550d45d0cc0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/MessageCorrelationAsyncBuilderImpl.java @@ -0,0 +1,125 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; +import org.camunda.bpm.engine.impl.cmd.batch.CorrelateAllMessageBatchCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.MessageCorrelationAsyncBuilder; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; + +public class MessageCorrelationAsyncBuilderImpl implements MessageCorrelationAsyncBuilder { + + protected CommandExecutor commandExecutor; + + protected String messageName; + protected Map payloadProcessInstanceVariables; + + protected List processInstanceIds; + protected ProcessInstanceQuery processInstanceQuery; + protected HistoricProcessInstanceQuery historicProcessInstanceQuery; + + public MessageCorrelationAsyncBuilderImpl(CommandExecutor commandExecutor, String messageName) { + this(messageName); + ensureNotNull("commandExecutor", commandExecutor); + this.commandExecutor = commandExecutor; + } + + private MessageCorrelationAsyncBuilderImpl(String messageName) { + this.messageName = messageName; + } + + public MessageCorrelationAsyncBuilder processInstanceIds(List ids) { + ensureNotNull("processInstanceIds", ids); + this.processInstanceIds = ids; + return this; + } + + @Override + public MessageCorrelationAsyncBuilder processInstanceQuery(ProcessInstanceQuery processInstanceQuery) { + ensureNotNull("processInstanceQuery", processInstanceQuery); + this.processInstanceQuery = processInstanceQuery; + return this; + } + + @Override + public MessageCorrelationAsyncBuilder historicProcessInstanceQuery(HistoricProcessInstanceQuery historicProcessInstanceQuery) { + ensureNotNull("historicProcessInstanceQuery", historicProcessInstanceQuery); + this.historicProcessInstanceQuery = historicProcessInstanceQuery; + return this; + } + + public MessageCorrelationAsyncBuilder setVariable(String variableName, Object variableValue) { + ensureNotNull("variableName", variableName); + ensurePayloadProcessInstanceVariablesInitialized(); + payloadProcessInstanceVariables.put(variableName, variableValue); + return this; + } + + public MessageCorrelationAsyncBuilder setVariables(Map variables) { + if (variables != null) { + ensurePayloadProcessInstanceVariablesInitialized(); + payloadProcessInstanceVariables.putAll(variables); + } + return this; + } + + protected void ensurePayloadProcessInstanceVariablesInitialized() { + if (payloadProcessInstanceVariables == null) { + payloadProcessInstanceVariables = new VariableMapImpl(); + } + } + + @Override + public Batch correlateAllAsync() { + return commandExecutor.execute(new CorrelateAllMessageBatchCmd(this)); + } + + // getters ////////////////////////////////// + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } + + public String getMessageName() { + return messageName; + } + + public List getProcessInstanceIds() { + return processInstanceIds; + } + + public ProcessInstanceQuery getProcessInstanceQuery() { + return processInstanceQuery; + } + + public HistoricProcessInstanceQuery getHistoricProcessInstanceQuery() { + return historicProcessInstanceQuery; + } + + public Map getPayloadProcessInstanceVariables() { + return payloadProcessInstanceVariables; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/MessageCorrelationBuilderImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/MessageCorrelationBuilderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f5c92bad293525ef7f8292980a5a8d466da6601a --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/MessageCorrelationBuilderImpl.java @@ -0,0 +1,414 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureFalse; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.impl.cmd.CommandLogger; +import org.camunda.bpm.engine.impl.cmd.CorrelateAllMessageCmd; +import org.camunda.bpm.engine.impl.cmd.CorrelateMessageCmd; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder; +import org.camunda.bpm.engine.runtime.MessageCorrelationResult; +import org.camunda.bpm.engine.runtime.MessageCorrelationResultWithVariables; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; + +/** + * @author Daniel Meyer + * @author Christopher Zell + * + */ +public class MessageCorrelationBuilderImpl implements MessageCorrelationBuilder { + + private final static CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; + + protected CommandExecutor commandExecutor; + protected CommandContext commandContext; + + protected boolean isExclusiveCorrelation = false; + + protected String messageName; + protected String businessKey; + protected String processInstanceId; + protected String processDefinitionId; + + protected VariableMap correlationProcessInstanceVariables; + protected VariableMap correlationLocalVariables; + protected VariableMap payloadProcessInstanceVariables; + protected VariableMap payloadProcessInstanceVariablesLocal; + protected VariableMap payloadProcessInstanceVariablesToTriggeredScope; + + protected String tenantId = null; + protected boolean isTenantIdSet = false; + + protected boolean startMessagesOnly = false; + protected boolean executionsOnly = false; + + public MessageCorrelationBuilderImpl(CommandExecutor commandExecutor, String messageName) { + this(messageName); + ensureNotNull("commandExecutor", commandExecutor); + this.commandExecutor = commandExecutor; + } + + public MessageCorrelationBuilderImpl(CommandContext commandContext, String messageName) { + this(messageName); + ensureNotNull("commandContext", commandContext); + this.commandContext = commandContext; + } + + private MessageCorrelationBuilderImpl(String messageName) { + this.messageName = messageName; + } + + public MessageCorrelationBuilder processInstanceBusinessKey(String businessKey) { + ensureNotNull("businessKey", businessKey); + this.businessKey = businessKey; + return this; + } + + public MessageCorrelationBuilder processInstanceVariableEquals(String variableName, Object variableValue) { + ensureNotNull("variableName", variableName); + ensureCorrelationProcessInstanceVariablesInitialized(); + + correlationProcessInstanceVariables.put(variableName, variableValue); + return this; + } + + public MessageCorrelationBuilder processInstanceVariablesEqual(Map variables) { + ensureNotNull("variables", variables); + ensureCorrelationProcessInstanceVariablesInitialized(); + + correlationProcessInstanceVariables.putAll(variables); + return this; + } + + public MessageCorrelationBuilder localVariableEquals(String variableName, Object variableValue) { + ensureNotNull("variableName", variableName); + ensureCorrelationLocalVariablesInitialized(); + + correlationLocalVariables.put(variableName, variableValue); + return this; + } + + public MessageCorrelationBuilder localVariablesEqual(Map variables) { + ensureNotNull("variables", variables); + ensureCorrelationLocalVariablesInitialized(); + + correlationLocalVariables.putAll(variables); + return this; + } + + protected void ensureCorrelationProcessInstanceVariablesInitialized() { + if(correlationProcessInstanceVariables == null) { + correlationProcessInstanceVariables = new VariableMapImpl(); + } + } + + protected void ensureCorrelationLocalVariablesInitialized() { + if(correlationLocalVariables == null) { + correlationLocalVariables = new VariableMapImpl(); + } + } + + public MessageCorrelationBuilder processInstanceId(String id) { + ensureNotNull("processInstanceId", id); + this.processInstanceId = id; + return this; + } + + public MessageCorrelationBuilder processDefinitionId(String processDefinitionId) { + ensureNotNull("processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + public MessageCorrelationBuilder setVariable(String variableName, Object variableValue) { + ensureNotNull("variableName", variableName); + ensurePayloadProcessInstanceVariablesInitialized(); + payloadProcessInstanceVariables.put(variableName, variableValue); + return this; + } + + public MessageCorrelationBuilder setVariableLocal(String variableName, Object variableValue) { + ensureNotNull("variableName", variableName); + ensurePayloadProcessInstanceVariablesLocalInitialized(); + payloadProcessInstanceVariablesLocal.put(variableName, variableValue); + return this; + } + + @Override + public MessageCorrelationBuilder setVariableToTriggeredScope(String variableName, Object variableValue) { + ensureNotNull("variableName", variableName); + ensurePayloadProcessInstanceVariablesToTriggeredScopeInitialized(); + payloadProcessInstanceVariablesToTriggeredScope.put(variableName, variableValue); + return this; + } + + public MessageCorrelationBuilder setVariables(Map variables) { + if (variables != null) { + ensurePayloadProcessInstanceVariablesInitialized(); + payloadProcessInstanceVariables.putAll(variables); + } + return this; + } + + @Override + public MessageCorrelationBuilder setVariablesLocal(Map variables) { + if (variables != null) { + ensurePayloadProcessInstanceVariablesLocalInitialized(); + payloadProcessInstanceVariablesLocal.putAll(variables); + } + return this; + } + + @Override + public MessageCorrelationBuilder setVariablesToTriggeredScope(Map variables) { + if (variables != null) { + ensurePayloadProcessInstanceVariablesToTriggeredScopeInitialized(); + payloadProcessInstanceVariablesToTriggeredScope.putAll(variables); + } + return this; + } + + protected void ensurePayloadProcessInstanceVariablesInitialized() { + if (payloadProcessInstanceVariables == null) { + payloadProcessInstanceVariables = new VariableMapImpl(); + } + } + + protected void ensurePayloadProcessInstanceVariablesLocalInitialized() { + if (payloadProcessInstanceVariablesLocal == null) { + payloadProcessInstanceVariablesLocal = new VariableMapImpl(); + } + } + + protected void ensurePayloadProcessInstanceVariablesToTriggeredScopeInitialized() { + if (payloadProcessInstanceVariablesToTriggeredScope == null) { + payloadProcessInstanceVariablesToTriggeredScope = new VariableMapImpl(); + } + } + + public MessageCorrelationBuilder tenantId(String tenantId) { + ensureNotNull( + "The tenant-id cannot be null. Use 'withoutTenantId()' if you want to correlate the message to a process definition or an execution which has no tenant-id.", + "tenantId", tenantId); + + isTenantIdSet = true; + this.tenantId = tenantId; + return this; + } + + public MessageCorrelationBuilder withoutTenantId() { + isTenantIdSet = true; + tenantId = null; + return this; + } + + @Override + public MessageCorrelationBuilder startMessageOnly() { + ensureFalse("Either startMessageOnly or executionsOnly can be set", executionsOnly); + startMessagesOnly = true; + return this; + } + + public MessageCorrelationBuilder executionsOnly() { + ensureFalse("Either startMessageOnly or executionsOnly can be set", startMessagesOnly); + executionsOnly = true; + return this; + } + + @Override + public void correlate() { + correlateWithResult(); + } + + @Override + public MessageCorrelationResult correlateWithResult() { + if (startMessagesOnly) { + ensureCorrelationVariablesNotSet(); + ensureProcessDefinitionAndTenantIdNotSet(); + } else { + ensureProcessDefinitionIdNotSet(); + ensureProcessInstanceAndTenantIdNotSet(); + } + return execute(new CorrelateMessageCmd(this, false, false, startMessagesOnly)); + } + + @Override + public MessageCorrelationResultWithVariables correlateWithResultAndVariables(boolean deserializeValues) { + if (startMessagesOnly) { + ensureCorrelationVariablesNotSet(); + ensureProcessDefinitionAndTenantIdNotSet(); + } else { + ensureProcessDefinitionIdNotSet(); + ensureProcessInstanceAndTenantIdNotSet(); + } + return execute(new CorrelateMessageCmd(this, true, deserializeValues, startMessagesOnly)); + } + + @Override + public void correlateExclusively() { + isExclusiveCorrelation = true; + + correlate(); + } + + @Override + public void correlateAll() { + correlateAllWithResult(); + } + + @Override + public List correlateAllWithResult() { + if (startMessagesOnly) { + ensureCorrelationVariablesNotSet(); + ensureProcessDefinitionAndTenantIdNotSet(); + // only one result can be expected + MessageCorrelationResult result = execute(new CorrelateMessageCmd(this, false, false, startMessagesOnly)); + return Arrays.asList(result); + } else { + ensureProcessDefinitionIdNotSet(); + ensureProcessInstanceAndTenantIdNotSet(); + return (List) execute(new CorrelateAllMessageCmd(this, false, false)); + } + } + + @Override + public List correlateAllWithResultAndVariables(boolean deserializeValues) { + if (startMessagesOnly) { + ensureCorrelationVariablesNotSet(); + ensureProcessDefinitionAndTenantIdNotSet(); + // only one result can be expected + MessageCorrelationResultWithVariables result = execute(new CorrelateMessageCmd(this, true, deserializeValues, startMessagesOnly)); + return Arrays.asList(result); + } else { + ensureProcessDefinitionIdNotSet(); + ensureProcessInstanceAndTenantIdNotSet(); + return (List) execute(new CorrelateAllMessageCmd(this, true, deserializeValues)); + } + } + + public ProcessInstance correlateStartMessage() { + startMessageOnly(); + MessageCorrelationResult result = correlateWithResult(); + return result.getProcessInstance(); + } + + protected void ensureProcessDefinitionIdNotSet() { + if(processDefinitionId != null) { + throw LOG.exceptionCorrelateMessageWithProcessDefinitionId(); + } + } + + protected void ensureProcessInstanceAndTenantIdNotSet() { + if (processInstanceId != null && isTenantIdSet) { + throw LOG.exceptionCorrelateMessageWithProcessInstanceAndTenantId(); + } + } + + protected void ensureCorrelationVariablesNotSet() { + if (correlationProcessInstanceVariables != null || correlationLocalVariables != null) { + throw LOG.exceptionCorrelateStartMessageWithCorrelationVariables(); + } + } + + protected void ensureProcessDefinitionAndTenantIdNotSet() { + if (processDefinitionId != null && isTenantIdSet) { + throw LOG.exceptionCorrelateMessageWithProcessDefinitionAndTenantId(); + } + } + + protected T execute(Command command) { + if(commandExecutor != null) { + return commandExecutor.execute(command); + } else { + return command.execute(commandContext); + } + } + + // getters ////////////////////////////////// + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } + + public CommandContext getCommandContext() { + return commandContext; + } + + public String getMessageName() { + return messageName; + } + + public String getBusinessKey() { + return businessKey; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public Map getCorrelationProcessInstanceVariables() { + return correlationProcessInstanceVariables; + } + + public Map getCorrelationLocalVariables() { + return correlationLocalVariables; + } + + public Map getPayloadProcessInstanceVariables() { + return payloadProcessInstanceVariables; + } + + public VariableMap getPayloadProcessInstanceVariablesLocal() { + return payloadProcessInstanceVariablesLocal; + } + + public VariableMap getPayloadProcessInstanceVariablesToTriggeredScope() { + return payloadProcessInstanceVariablesToTriggeredScope; + } + + public boolean isExclusiveCorrelation() { + return isExclusiveCorrelation; + } + + public String getTenantId() { + return tenantId; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public boolean isExecutionsOnly() { + return executionsOnly; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ModificationBatchConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ModificationBatchConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..10d6d00cd3a5f75b00c525e395870ecb381426db --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ModificationBatchConfiguration.java @@ -0,0 +1,63 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; +import org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand; + +public class ModificationBatchConfiguration extends BatchConfiguration { + + protected List instructions; + protected boolean skipCustomListeners; + protected boolean skipIoMappings; + protected String processDefinitionId; + + public ModificationBatchConfiguration(List ids, String processDefinitionId, List instructions, + boolean skipCustomListeners, boolean skipIoMappings) { + this(ids, null, processDefinitionId, instructions, skipCustomListeners, skipIoMappings); + } + + public ModificationBatchConfiguration(List ids, DeploymentMappings mappings, + String processDefinitionId, List instructions, + boolean skipCustomListeners, boolean skipIoMappings) { + super(ids, mappings); + this.instructions = instructions; + this.processDefinitionId = processDefinitionId; + this.skipCustomListeners = skipCustomListeners; + this.skipIoMappings = skipIoMappings; + } + + public List getInstructions() { + return instructions; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public boolean isSkipCustomListeners() { + return skipCustomListeners; + } + + public boolean isSkipIoMappings() { + return skipIoMappings; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ModificationBatchJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ModificationBatchJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..e4a7c45d1070b4fe4262e1859477115490e2ba11 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ModificationBatchJobHandler.java @@ -0,0 +1,105 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.json.ModificationBatchConfigurationJsonConverter; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; + +public class ModificationBatchJobHandler extends AbstractBatchJobHandler{ + + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_PROCESS_INSTANCE_MODIFICATION); + + @Override + public String getType() { + return Batch.TYPE_PROCESS_INSTANCE_MODIFICATION; + } + + @Override + protected void postProcessJob(ModificationBatchConfiguration configuration, JobEntity job, ModificationBatchConfiguration jobConfiguration) { + if (job.getDeploymentId() == null) { + CommandContext commandContext = Context.getCommandContext(); + ProcessDefinitionEntity processDefinitionEntity = commandContext.getProcessEngineConfiguration().getDeploymentCache() + .findDeployedProcessDefinitionById(configuration.getProcessDefinitionId()); + job.setDeploymentId(processDefinitionEntity.getDeploymentId()); + } + } + + @Override + public void executeHandler(ModificationBatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + + ModificationBuilderImpl executionBuilder = (ModificationBuilderImpl) commandContext.getProcessEngineConfiguration() + .getRuntimeService() + .createModification(batchConfiguration.getProcessDefinitionId()) + .processInstanceIds(batchConfiguration.getIds()); + + executionBuilder.setInstructions(batchConfiguration.getInstructions()); + + if (batchConfiguration.isSkipCustomListeners()) { + executionBuilder.skipCustomListeners(); + } + if (batchConfiguration.isSkipIoMappings()) { + executionBuilder.skipIoMappings(); + } + + executionBuilder.execute(false); + + } + + @Override + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + @Override + protected ModificationBatchConfiguration createJobConfiguration(ModificationBatchConfiguration configuration, List processIdsForJob) { + return new ModificationBatchConfiguration( + processIdsForJob, + configuration.getProcessDefinitionId(), + configuration.getInstructions(), + configuration.isSkipCustomListeners(), + configuration.isSkipIoMappings() + ); + } + + + @Override + protected ModificationBatchConfigurationJsonConverter getJsonConverterInstance() { + return ModificationBatchConfigurationJsonConverter.INSTANCE; + } + + protected ProcessDefinitionEntity getProcessDefinition(CommandContext commandContext, String processDefinitionId) { + return commandContext.getProcessEngineConfiguration() + .getDeploymentCache() + .findDeployedProcessDefinitionById(processDefinitionId); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ModificationBuilderImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ModificationBuilderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e943c4cf08853e2e49993e4677f4cd74b46dce3d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ModificationBuilderImpl.java @@ -0,0 +1,203 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; +import org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand; +import org.camunda.bpm.engine.impl.cmd.ActivityAfterInstantiationCmd; +import org.camunda.bpm.engine.impl.cmd.ActivityBeforeInstantiationCmd; +import org.camunda.bpm.engine.impl.cmd.ActivityCancellationCmd; +import org.camunda.bpm.engine.impl.cmd.ProcessInstanceModificationBatchCmd; +import org.camunda.bpm.engine.impl.cmd.ProcessInstanceModificationCmd; +import org.camunda.bpm.engine.impl.cmd.TransitionInstantiationCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.ModificationBuilder; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; + +public class ModificationBuilderImpl implements ModificationBuilder { + + protected CommandExecutor commandExecutor; + protected ProcessInstanceQuery processInstanceQuery; + protected HistoricProcessInstanceQuery historicProcessInstanceQuery; + protected List processInstanceIds; + protected List instructions; + protected String processDefinitionId; + + protected boolean skipCustomListeners; + protected boolean skipIoMappings; + protected String annotation; + + public ModificationBuilderImpl(CommandExecutor commandExecutor, String processDefinitionId) { + this.commandExecutor = commandExecutor; + ensureNotNull(NotValidException.class,"processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + processInstanceIds = new ArrayList(); + instructions = new ArrayList(); + } + + @Override + public ModificationBuilder startBeforeActivity(String activityId) { + ensureNotNull(NotValidException.class, "activityId", activityId); + instructions.add(new ActivityBeforeInstantiationCmd(activityId)); + return this; + } + + @Override + public ModificationBuilder startAfterActivity(String activityId) { + ensureNotNull(NotValidException.class, "activityId", activityId); + instructions.add(new ActivityAfterInstantiationCmd(activityId)); + return this; + } + + @Override + public ModificationBuilder startTransition(String transitionId) { + ensureNotNull(NotValidException.class, "transitionId", transitionId); + instructions.add(new TransitionInstantiationCmd(transitionId)); + return this; + } + + @Override + public ModificationBuilder cancelAllForActivity(String activityId) { + return cancelAllForActivity(activityId, false); + } + + @Override + public ModificationBuilder cancelAllForActivity(String activityId, boolean cancelCurrentActiveActivityInstances) { + ensureNotNull(NotValidException.class, "activityId", activityId); + ActivityCancellationCmd activityCancellationCmd = new ActivityCancellationCmd(activityId); + activityCancellationCmd.setCancelCurrentActiveActivityInstances(cancelCurrentActiveActivityInstances); + instructions.add(activityCancellationCmd); + return this; + } + + @Override + public ModificationBuilder processInstanceIds(List processInstanceIds) { + this.processInstanceIds = processInstanceIds; + return this; + } + + @Override + public ModificationBuilder processInstanceIds(String... processInstanceIds) { + if (processInstanceIds == null) { + this.processInstanceIds = Collections.emptyList(); + } + else { + this.processInstanceIds = Arrays.asList(processInstanceIds); + } + return this; + } + + @Override + public ModificationBuilder processInstanceQuery(ProcessInstanceQuery processInstanceQuery) { + this.processInstanceQuery = processInstanceQuery; + return this; + } + + @Override + public ModificationBuilder historicProcessInstanceQuery(HistoricProcessInstanceQuery historicProcessInstanceQuery) { + this.historicProcessInstanceQuery = historicProcessInstanceQuery; + return this; + } + + @Override + public ModificationBuilder skipCustomListeners() { + this.skipCustomListeners = true; + return this; + } + + @Override + public ModificationBuilder skipIoMappings() { + this.skipIoMappings = true; + return this; + } + + @Override + public ModificationBuilder setAnnotation(String annotation) { + this.annotation = annotation; + return this; + } + public void execute(boolean writeUserOperationLog) { + commandExecutor.execute(new ProcessInstanceModificationCmd(this, writeUserOperationLog)); + } + + @Override + public void execute() { + execute(true); + } + + @Override + public Batch executeAsync() { + return commandExecutor.execute(new ProcessInstanceModificationBatchCmd(this)); + } + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } + + public ProcessInstanceQuery getProcessInstanceQuery() { + return processInstanceQuery; + } + + public HistoricProcessInstanceQuery getHistoricProcessInstanceQuery() { + return historicProcessInstanceQuery; + } + + public List getProcessInstanceIds() { + return processInstanceIds; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public void setProcessDefinitionId(String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + } + + public List getInstructions() { + return instructions; + } + + public void setInstructions(List instructions) { + this.instructions = instructions; + } + + public boolean isSkipCustomListeners() { + return skipCustomListeners; + } + + public boolean isSkipIoMappings() { + return skipIoMappings; + } + + public String getAnnotation() { + return annotation; + } + + public void setAnnotationInternal(String annotation) { + this.annotation = annotation; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeExecutionQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeExecutionQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f7907b3f7c099319fee357d73a13a5f3da3bc041 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeExecutionQueryImpl.java @@ -0,0 +1,55 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.Execution; +import org.camunda.bpm.engine.runtime.NativeExecutionQuery; + + +public class NativeExecutionQueryImpl extends AbstractNativeQuery implements NativeExecutionQuery { + + private static final long serialVersionUID = 1L; + + public NativeExecutionQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeExecutionQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + + //results //////////////////////////////////////////////////////////////// + + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + return commandContext + .getExecutionManager() + .findExecutionsByNativeQuery(parameterMap, firstResult, maxResults); + } + + public long executeCount(CommandContext commandContext, Map parameterMap) { + return commandContext + .getExecutionManager() + .findExecutionCountByNativeQuery(parameterMap); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricActivityInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricActivityInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..d99cdb41ed29f34360b3dd8275d04c4a6e302bd0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricActivityInstanceQueryImpl.java @@ -0,0 +1,55 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.history.HistoricActivityInstance; +import org.camunda.bpm.engine.history.NativeHistoricActivityInstanceQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + + +public class NativeHistoricActivityInstanceQueryImpl extends AbstractNativeQuery implements NativeHistoricActivityInstanceQuery { + + private static final long serialVersionUID = 1L; + + public NativeHistoricActivityInstanceQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeHistoricActivityInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + + //results //////////////////////////////////////////////////////////////// + + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + return commandContext + .getHistoricActivityInstanceManager() + .findHistoricActivityInstancesByNativeQuery(parameterMap, firstResult, maxResults); + } + + public long executeCount(CommandContext commandContext, Map parameterMap) { + return commandContext + .getHistoricActivityInstanceManager() + .findHistoricActivityInstanceCountByNativeQuery(parameterMap); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricCaseActivityInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricCaseActivityInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..9a6fc50ec08a7dfff3d6fdcfbc3eb1480bc20bfa --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricCaseActivityInstanceQueryImpl.java @@ -0,0 +1,54 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.history.HistoricCaseActivityInstance; +import org.camunda.bpm.engine.history.NativeHistoricCaseActivityInstanceQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + + +public class NativeHistoricCaseActivityInstanceQueryImpl extends AbstractNativeQuery implements NativeHistoricCaseActivityInstanceQuery { + + private static final long serialVersionUID = 1L; + + public NativeHistoricCaseActivityInstanceQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeHistoricCaseActivityInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + //results //////////////////////////////////////////////////////////////// + + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + return commandContext + .getHistoricCaseActivityInstanceManager() + .findHistoricCaseActivityInstancesByNativeQuery(parameterMap, firstResult, maxResults); + } + + public long executeCount(CommandContext commandContext, Map parameterMap) { + return commandContext + .getHistoricCaseActivityInstanceManager() + .findHistoricCaseActivityInstanceCountByNativeQuery(parameterMap); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricCaseInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricCaseInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8c874ffc4f0d35d2473c7d4a4e4aac72290a50d6 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricCaseInstanceQueryImpl.java @@ -0,0 +1,54 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.history.HistoricCaseInstance; +import org.camunda.bpm.engine.history.NativeHistoricCaseInstanceQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + + +public class NativeHistoricCaseInstanceQueryImpl extends AbstractNativeQuery implements NativeHistoricCaseInstanceQuery { + + private static final long serialVersionUID = 1L; + + public NativeHistoricCaseInstanceQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeHistoricCaseInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + //results //////////////////////////////////////////////////////////////// + + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + return commandContext + .getHistoricCaseInstanceManager() + .findHistoricCaseInstancesByNativeQuery(parameterMap, firstResult, maxResults); + } + + public long executeCount(CommandContext commandContext, Map parameterMap) { + return commandContext + .getHistoricCaseInstanceManager() + .findHistoricCaseInstanceCountByNativeQuery(parameterMap); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricProcessInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricProcessInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b33254729e2dd95f45369a688edc72857868fd4e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricProcessInstanceQueryImpl.java @@ -0,0 +1,55 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.history.NativeHistoricProcessInstanceQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + + +public class NativeHistoricProcessInstanceQueryImpl extends AbstractNativeQuery implements NativeHistoricProcessInstanceQuery { + + private static final long serialVersionUID = 1L; + + public NativeHistoricProcessInstanceQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeHistoricProcessInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + + //results //////////////////////////////////////////////////////////////// + + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + return commandContext + .getHistoricProcessInstanceManager() + .findHistoricProcessInstancesByNativeQuery(parameterMap, firstResult, maxResults); + } + + public long executeCount(CommandContext commandContext, Map parameterMap) { + return commandContext + .getHistoricProcessInstanceManager() + .findHistoricProcessInstanceCountByNativeQuery(parameterMap); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricTaskInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricTaskInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..3c8fc0dcad5d5e689347c1cfd13214218e1af1fc --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricTaskInstanceQueryImpl.java @@ -0,0 +1,55 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.history.HistoricTaskInstance; +import org.camunda.bpm.engine.history.NativeHistoricTaskInstanceQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + + +public class NativeHistoricTaskInstanceQueryImpl extends AbstractNativeQuery implements NativeHistoricTaskInstanceQuery { + + private static final long serialVersionUID = 1L; + + public NativeHistoricTaskInstanceQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeHistoricTaskInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + + //results //////////////////////////////////////////////////////////////// + + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + return commandContext + .getHistoricTaskInstanceManager() + .findHistoricTaskInstancesByNativeQuery(parameterMap, firstResult, maxResults); + } + + public long executeCount(CommandContext commandContext, Map parameterMap) { + return commandContext + .getHistoricTaskInstanceManager() + .findHistoricTaskInstanceCountByNativeQuery(parameterMap); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricVariableInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricVariableInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f7d63511d7867cc670216bb1e4c50ed360256ebb --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoricVariableInstanceQueryImpl.java @@ -0,0 +1,82 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.history.HistoricVariableInstance; +import org.camunda.bpm.engine.history.NativeHistoricVariableInstanceQuery; +import org.camunda.bpm.engine.impl.cmd.CommandLogger; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.HistoricVariableInstanceEntity; + +import java.util.List; +import java.util.Map; + + +public class NativeHistoricVariableInstanceQueryImpl extends AbstractNativeQuery + implements NativeHistoricVariableInstanceQuery { + + private final static CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; + + private static final long serialVersionUID = 1L; + + protected boolean isCustomObjectDeserializationEnabled = true; + + public NativeHistoricVariableInstanceQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeHistoricVariableInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + + //results //////////////////////////////////////////////////////////////// + + @Override + public NativeHistoricVariableInstanceQuery disableCustomObjectDeserialization() { + this.isCustomObjectDeserializationEnabled = false; + return this; + } + + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + List historicVariableInstances = commandContext + .getHistoricVariableInstanceManager() + .findHistoricVariableInstancesByNativeQuery(parameterMap, firstResult, maxResults); + + if (historicVariableInstances!=null) { + for (HistoricVariableInstance historicVariableInstance: historicVariableInstances) { + + HistoricVariableInstanceEntity variableInstanceEntity = (HistoricVariableInstanceEntity) historicVariableInstance; + try { + variableInstanceEntity.getTypedValue(isCustomObjectDeserializationEnabled); + } catch(Exception t) { + // do not fail if one of the variables fails to load + LOG.exceptionWhileGettingValueForVariable(t); + } + } + } + return historicVariableInstances; + } + + public long executeCount(CommandContext commandContext, Map parameterMap) { + return commandContext + .getHistoricVariableInstanceManager() + .findHistoricVariableInstanceCountByNativeQuery(parameterMap); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoryDecisionInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoryDecisionInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..70c71333eb1666871e1940f781c07c658571de73 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeHistoryDecisionInstanceQueryImpl.java @@ -0,0 +1,57 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.history.HistoricDecisionInstance; +import org.camunda.bpm.engine.history.NativeHistoricDecisionInstanceQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + +/** + * @author Philipp Ossler + */ +public class NativeHistoryDecisionInstanceQueryImpl extends AbstractNativeQuery + implements NativeHistoricDecisionInstanceQuery { + + private static final long serialVersionUID = 1L; + + public NativeHistoryDecisionInstanceQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeHistoryDecisionInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + @Override + public long executeCount(CommandContext commandContext, Map parameterMap) { + return commandContext + .getHistoricDecisionInstanceManager() + .findHistoricDecisionInstanceCountByNativeQuery(parameterMap); + } + + @Override + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + return commandContext + .getHistoricDecisionInstanceManager() + .findHistoricDecisionInstancesByNativeQuery(parameterMap, firstResult, maxResults); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeProcessInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeProcessInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b281dba11e5c09f0bc9b41d7839901a9addfd244 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeProcessInstanceQueryImpl.java @@ -0,0 +1,56 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.NativeProcessInstanceQuery; +import org.camunda.bpm.engine.runtime.ProcessInstance; + + +public class NativeProcessInstanceQueryImpl extends AbstractNativeQuery implements NativeProcessInstanceQuery { + + private static final long serialVersionUID = 1L; + + public NativeProcessInstanceQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeProcessInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + + //results //////////////////////////////////////////////////////////////// + + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + return commandContext + .getExecutionManager() + .findProcessInstanceByNativeQuery(parameterMap, firstResult, maxResults); + } + + public long executeCount(CommandContext commandContext, Map parameterMap) { + return commandContext + .getExecutionManager() + // can use execution count, since the result type doesn't matter + .findExecutionCountByNativeQuery(parameterMap); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeTaskQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeTaskQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..1c2d8d5de786c123e187a6e4bf8bffde789f4799 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeTaskQueryImpl.java @@ -0,0 +1,55 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.task.NativeTaskQuery; +import org.camunda.bpm.engine.task.Task; + + +public class NativeTaskQueryImpl extends AbstractNativeQuery implements NativeTaskQuery { + + private static final long serialVersionUID = 1L; + + public NativeTaskQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeTaskQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + + //results //////////////////////////////////////////////////////////////// + + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + return commandContext + .getTaskManager() + .findTasksByNativeQuery(parameterMap, firstResult, maxResults); + } + + public long executeCount(CommandContext commandContext, Map parameterMap) { + return commandContext + .getTaskManager() + .findTaskCountByNativeQuery(parameterMap); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeUserQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeUserQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..48bf3bc3c44ee7c800715d8bb5110dc2bac4bc28 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/NativeUserQueryImpl.java @@ -0,0 +1,59 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; +import java.util.Map; +import org.camunda.bpm.engine.identity.NativeUserQuery; +import org.camunda.bpm.engine.identity.User; +import org.camunda.bpm.engine.impl.identity.db.DbReadOnlyIdentityServiceProvider; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + +/** + * @author Svetlana Dorokhova + */ +public class NativeUserQueryImpl extends AbstractNativeQuery implements NativeUserQuery { + + private static final long serialVersionUID = 1L; + + public NativeUserQueryImpl(CommandContext commandContext) { + super(commandContext); + } + + public NativeUserQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + + //results //////////////////////////////////////////////////////////////// + + public List executeList(CommandContext commandContext, Map parameterMap, int firstResult, int maxResults) { + final DbReadOnlyIdentityServiceProvider identityProvider = getIdentityProvider(commandContext); + return identityProvider.findUserByNativeQuery(parameterMap, firstResult, maxResults); + } + + public long executeCount(CommandContext commandContext, Map parameterMap) { + final DbReadOnlyIdentityServiceProvider identityProvider = getIdentityProvider(commandContext); + return identityProvider.findUserCountByNativeQuery(parameterMap); + } + + private DbReadOnlyIdentityServiceProvider getIdentityProvider(CommandContext commandContext) { + return (DbReadOnlyIdentityServiceProvider) commandContext.getReadOnlyIdentityProvider(); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/OperationLogQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/OperationLogQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..9ab80bb1e2d833ed55dbe1c10b38514791cc2653 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/OperationLogQueryProperty.java @@ -0,0 +1,31 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + + +/** + * Contains sortable properties which can be used in a {@link org.camunda.bpm.engine.history.UserOperationLogQuery}. + * + * @author Danny Gräf + */ +public class OperationLogQueryProperty { + + public static final QueryProperty TIMESTAMP = new QueryPropertyImpl("TIMESTAMP_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/OptimizeService.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/OptimizeService.java new file mode 100644 index 0000000000000000000000000000000000000000..3e19c7155e42fde739cfb79644c501bd557db6e0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/OptimizeService.java @@ -0,0 +1,143 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.history.HistoricActivityInstance; +import org.camunda.bpm.engine.history.HistoricDecisionInstance; +import org.camunda.bpm.engine.history.HistoricProcessInstance; +import org.camunda.bpm.engine.history.HistoricTaskInstance; +import org.camunda.bpm.engine.history.HistoricVariableUpdate; +import org.camunda.bpm.engine.history.UserOperationLogEntry; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeCompletedHistoricActivityInstanceQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeCompletedHistoricIncidentsQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeCompletedHistoricProcessInstanceQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeCompletedHistoricTaskInstanceQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeHistoricDecisionInstanceQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeHistoricIdentityLinkLogQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeHistoricUserOperationsLogQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeHistoricVariableUpdateQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeOpenHistoricIncidentsQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeRunningHistoricActivityInstanceQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeRunningHistoricProcessInstanceQueryCmd; +import org.camunda.bpm.engine.impl.cmd.optimize.OptimizeRunningHistoricTaskInstanceQueryCmd; +import org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentEntity; +import org.camunda.bpm.engine.impl.persistence.entity.optimize.OptimizeHistoricIdentityLinkLogEntity; + +import java.util.Date; +import java.util.List; + +public class OptimizeService extends ServiceImpl { + + public List getCompletedHistoricActivityInstances(Date finishedAfter, + Date finishedAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeCompletedHistoricActivityInstanceQueryCmd(finishedAfter, finishedAt, maxResults) + ); + } + + public List getRunningHistoricActivityInstances(Date startedAfter, + Date startedAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeRunningHistoricActivityInstanceQueryCmd(startedAfter, startedAt, maxResults) + ); + } + + public List getCompletedHistoricTaskInstances(Date finishedAfter, + Date finishedAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeCompletedHistoricTaskInstanceQueryCmd(finishedAfter, finishedAt, maxResults) + ); + } + + public List getRunningHistoricTaskInstances(Date startedAfter, + Date startedAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeRunningHistoricTaskInstanceQueryCmd(startedAfter, startedAt, maxResults) + ); + } + + public List getHistoricUserOperationLogs(Date occurredAfter, + Date occurredAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeHistoricUserOperationsLogQueryCmd(occurredAfter, occurredAt, maxResults) + ); + } + + public List getHistoricIdentityLinkLogs(Date occurredAfter, + Date occurredAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeHistoricIdentityLinkLogQueryCmd(occurredAfter, occurredAt, maxResults) + ); + } + + public List getCompletedHistoricProcessInstances(Date finishedAfter, + Date finishedAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeCompletedHistoricProcessInstanceQueryCmd(finishedAfter, finishedAt, maxResults) + ); + } + + public List getRunningHistoricProcessInstances(Date startedAfter, + Date startedAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeRunningHistoricProcessInstanceQueryCmd(startedAfter, startedAt, maxResults) + ); + } + + public List getHistoricVariableUpdates(Date occurredAfter, + Date occurredAt, + boolean excludeObjectValues, + int maxResults) { + return commandExecutor.execute( + new OptimizeHistoricVariableUpdateQueryCmd(occurredAfter, occurredAt, excludeObjectValues, maxResults) + ); + } + + public List getCompletedHistoricIncidents(Date finishedAfter, + Date finishedAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeCompletedHistoricIncidentsQueryCmd(finishedAfter, finishedAt, maxResults) + ); + } + + public List getOpenHistoricIncidents(Date createdAfter, + Date createdAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeOpenHistoricIncidentsQueryCmd(createdAfter, createdAt, maxResults) + ); + } + + public List getHistoricDecisionInstances(Date evaluatedAfter, + Date evaluatedAt, + int maxResults) { + return commandExecutor.execute( + new OptimizeHistoricDecisionInstanceQueryCmd(evaluatedAfter, evaluatedAt, maxResults) + ); + } + + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Page.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Page.java new file mode 100644 index 0000000000000000000000000000000000000000..c9caf6107179f1f9c3609b2de750173a6ffba3ce --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Page.java @@ -0,0 +1,43 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + + +/** + * holds the parameters of a page (partial result) for a query. + * + * @author Joram Barrez + * @author Tom Baeyens + */ +public class Page { + + protected int firstResult; + protected int maxResults; + + public Page(int firstResult, int maxResults) { + this.firstResult = firstResult; + this.maxResults = maxResults; + } + + public int getFirstResult() { + return firstResult; + } + + public int getMaxResults() { + return maxResults; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/PriorityProvider.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/PriorityProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..3f6e3adc939edfa2b5a06f7895260b8446c0bbf9 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/PriorityProvider.java @@ -0,0 +1,37 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; + +/** + * + * @author Christopher Zell + * @param the type of the extra param to determine the priority + */ +public interface PriorityProvider { + + /** + * @param execution may be null when the job is not created in the context of a + * running process instance (e.g. a timer start event) + * @param param extra parameter to determine priority on + * @param jobDefinitionId the job definition id if related to a job + * @return the determined priority + */ + long determinePriority(ExecutionEntity execution, T param, String jobDefinitionId); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessDefinitionQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessDefinitionQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..9310b5b1a9cd9d7629a221eedcd08027058a4dd5 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessDefinitionQueryImpl.java @@ -0,0 +1,565 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.identity.Group; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.CompositePermissionCheck; +import org.camunda.bpm.engine.impl.db.PermissionCheck; +import org.camunda.bpm.engine.impl.event.EventType; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.SuspensionState; +import org.camunda.bpm.engine.impl.util.CompareUtil; +import org.camunda.bpm.engine.repository.ProcessDefinition; +import org.camunda.bpm.engine.repository.ProcessDefinitionQuery; +import org.camunda.bpm.model.bpmn.BpmnModelInstance; +import org.camunda.bpm.model.bpmn.instance.Documentation; +import org.camunda.bpm.model.xml.instance.ModelElementInstance; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensurePositive; + + +/** + * @author Tom Baeyens + * @author Joram Barrez + * @author Daniel Meyer + * @author Saeid Mirzaei + */ +public class ProcessDefinitionQueryImpl extends AbstractQuery + implements ProcessDefinitionQuery { + + private static final long serialVersionUID = 1L; + protected String id; + protected String[] ids; + protected String category; + protected String categoryLike; + protected String name; + protected String nameLike; + protected String deploymentId; + protected Date deployedAfter; + protected Date deployedAt; + protected String key; + protected String[] keys; + protected String keyLike; + protected String resourceName; + protected String resourceNameLike; + protected Integer version; + protected boolean latest = false; + protected SuspensionState suspensionState; + protected String authorizationUserId; + protected List cachedCandidateGroups; + protected String procDefId; + protected String incidentType; + protected String incidentId; + protected String incidentMessage; + protected String incidentMessageLike; + + protected String eventSubscriptionName; + protected String eventSubscriptionType; + + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + protected boolean includeDefinitionsWithoutTenantId = false; + + protected boolean isVersionTagSet = false; + protected String versionTag; + protected String versionTagLike; + + protected boolean isStartableInTasklist = false; + protected boolean isNotStartableInTasklist = false; + protected boolean startablePermissionCheck = false; + // for internal use + protected List processDefinitionCreatePermissionChecks = new ArrayList(); + private boolean shouldJoinDeploymentTable = false; + + public ProcessDefinitionQueryImpl() { + } + + public ProcessDefinitionQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public ProcessDefinitionQuery processDefinitionId(String processDefinitionId) { + this.id = processDefinitionId; + return this; + } + + public ProcessDefinitionQuery processDefinitionIdIn(String... ids) { + this.ids = ids; + return this; + } + + public ProcessDefinitionQuery processDefinitionCategory(String category) { + ensureNotNull("category", category); + this.category = category; + return this; + } + + public ProcessDefinitionQuery processDefinitionCategoryLike(String categoryLike) { + ensureNotNull("categoryLike", categoryLike); + this.categoryLike = categoryLike; + return this; + } + + public ProcessDefinitionQuery processDefinitionName(String name) { + ensureNotNull("name", name); + this.name = name; + return this; + } + + public ProcessDefinitionQuery processDefinitionNameLike(String nameLike) { + ensureNotNull("nameLike", nameLike); + this.nameLike = nameLike; + return this; + } + + public ProcessDefinitionQuery deploymentId(String deploymentId) { + ensureNotNull("deploymentId", deploymentId); + this.deploymentId = deploymentId; + return this; + } + + public ProcessDefinitionQuery deployedAfter(Date deployedAfter) { + ensureNotNull("deployedAfter", deployedAfter); + shouldJoinDeploymentTable = true; + this.deployedAfter = deployedAfter; + return this; + } + + public ProcessDefinitionQuery deployedAt(Date deployedAt) { + ensureNotNull("deployedAt", deployedAt); + shouldJoinDeploymentTable = true; + this.deployedAt = deployedAt; + return this; + } + + public ProcessDefinitionQuery processDefinitionKey(String key) { + ensureNotNull("key", key); + this.key = key; + return this; + } + + public ProcessDefinitionQueryImpl processDefinitionKeysIn(String... processDefinitionKeys) { + return (ProcessDefinitionQueryImpl) processDefinitionKeyIn(processDefinitionKeys); + } + + public ProcessDefinitionQuery processDefinitionKeyIn(String... processDefinitionKeys) { + ensureNotNull("keys", (Object[]) processDefinitionKeys); + this.keys = processDefinitionKeys; + return this; + } + + public ProcessDefinitionQuery processDefinitionKeyLike(String keyLike) { + ensureNotNull("keyLike", keyLike); + this.keyLike = keyLike; + return this; + } + + public ProcessDefinitionQuery processDefinitionResourceName(String resourceName) { + ensureNotNull("resourceName", resourceName); + this.resourceName = resourceName; + return this; + } + + public ProcessDefinitionQuery processDefinitionResourceNameLike(String resourceNameLike) { + ensureNotNull("resourceNameLike", resourceNameLike); + this.resourceNameLike = resourceNameLike; + return this; + } + + public ProcessDefinitionQuery processDefinitionVersion(Integer version) { + ensureNotNull("version", version); + ensurePositive("version", version.longValue()); + this.version = version; + return this; + } + + public ProcessDefinitionQuery latestVersion() { + this.latest = true; + return this; + } + + public ProcessDefinitionQuery active() { + this.suspensionState = SuspensionState.ACTIVE; + return this; + } + + public ProcessDefinitionQuery suspended() { + this.suspensionState = SuspensionState.SUSPENDED; + return this; + } + + public ProcessDefinitionQuery messageEventSubscription(String messageName) { + return eventSubscription(EventType.MESSAGE, messageName); + } + + public ProcessDefinitionQuery messageEventSubscriptionName(String messageName) { + return eventSubscription(EventType.MESSAGE, messageName); + } + + public ProcessDefinitionQuery processDefinitionStarter(String procDefId) { + this.procDefId = procDefId; + return this; + } + + public ProcessDefinitionQuery eventSubscription(EventType eventType, String eventName) { + ensureNotNull("event type", eventType); + ensureNotNull("event name", eventName); + this.eventSubscriptionType = eventType.name(); + this.eventSubscriptionName = eventName; + return this; + } + + public ProcessDefinitionQuery incidentType(String incidentType) { + ensureNotNull("incident type", incidentType); + this.incidentType = incidentType; + return this; + } + + public ProcessDefinitionQuery incidentId(String incidentId) { + ensureNotNull("incident id", incidentId); + this.incidentId = incidentId; + return this; + } + + public ProcessDefinitionQuery incidentMessage(String incidentMessage) { + ensureNotNull("incident message", incidentMessage); + this.incidentMessage = incidentMessage; + return this; + } + + public ProcessDefinitionQuery incidentMessageLike(String incidentMessageLike) { + ensureNotNull("incident messageLike", incidentMessageLike); + this.incidentMessageLike = incidentMessageLike; + return this; + } + + public ProcessDefinitionQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public ProcessDefinitionQuery withoutTenantId() { + isTenantIdSet = true; + this.tenantIds = null; + return this; + } + + public ProcessDefinitionQuery includeProcessDefinitionsWithoutTenantId() { + this.includeDefinitionsWithoutTenantId = true; + return this; + } + + public ProcessDefinitionQuery versionTag(String versionTag) { + ensureNotNull("versionTag", versionTag); + this.versionTag = versionTag; + this.isVersionTagSet = true; + + return this; + } + + public ProcessDefinitionQuery versionTagLike(String versionTagLike) { + ensureNotNull("versionTagLike", versionTagLike); + this.versionTagLike = versionTagLike; + + return this; + } + + public ProcessDefinitionQuery withoutVersionTag() { + this.isVersionTagSet = true; + this.versionTag = null; + + return this; + } + + public ProcessDefinitionQuery startableInTasklist() { + this.isStartableInTasklist = true; + return this; + } + + public ProcessDefinitionQuery notStartableInTasklist() { + this.isNotStartableInTasklist = true; + return this; + } + + public ProcessDefinitionQuery startablePermissionCheck() { + this.startablePermissionCheck = true; + return this; + } + + //sorting //////////////////////////////////////////// + + public ProcessDefinitionQuery orderByDeploymentId() { + return orderBy(ProcessDefinitionQueryProperty.DEPLOYMENT_ID); + } + + public ProcessDefinitionQuery orderByDeploymentTime() { + shouldJoinDeploymentTable = true; + return orderBy(new QueryOrderingProperty(QueryOrderingProperty.RELATION_DEPLOYMENT, ProcessDefinitionQueryProperty.DEPLOY_TIME)); + } + + public ProcessDefinitionQuery orderByProcessDefinitionKey() { + return orderBy(ProcessDefinitionQueryProperty.PROCESS_DEFINITION_KEY); + } + + public ProcessDefinitionQuery orderByProcessDefinitionCategory() { + return orderBy(ProcessDefinitionQueryProperty.PROCESS_DEFINITION_CATEGORY); + } + + public ProcessDefinitionQuery orderByProcessDefinitionId() { + return orderBy(ProcessDefinitionQueryProperty.PROCESS_DEFINITION_ID); + } + + public ProcessDefinitionQuery orderByProcessDefinitionVersion() { + return orderBy(ProcessDefinitionQueryProperty.PROCESS_DEFINITION_VERSION); + } + + public ProcessDefinitionQuery orderByProcessDefinitionName() { + return orderBy(ProcessDefinitionQueryProperty.PROCESS_DEFINITION_NAME); + } + + public ProcessDefinitionQuery orderByTenantId() { + return orderBy(ProcessDefinitionQueryProperty.TENANT_ID); + } + + public ProcessDefinitionQuery orderByVersionTag() { + return orderBy(ProcessDefinitionQueryProperty.VERSION_TAG); + } + + public ProcessDefinitionQuery startableByUser(String userId) { + ensureNotNull("userId", userId); + this.authorizationUserId = userId; + + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() || CompareUtil.elementIsNotContainedInArray(id, ids); + } + + + //results //////////////////////////////////////////// + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + // fetch candidate groups + getCandidateGroups(); + return commandContext + .getProcessDefinitionManager() + .findProcessDefinitionCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + // fetch candidate groups + getCandidateGroups(); + List list = commandContext + .getProcessDefinitionManager() + .findProcessDefinitionsByQueryCriteria(this, page); + + boolean shouldQueryAddBpmnModelInstancesToCache = + commandContext.getProcessEngineConfiguration().getEnableFetchProcessDefinitionDescription(); + if(shouldQueryAddBpmnModelInstancesToCache) { + addProcessDefinitionToCacheAndRetrieveDocumentation(list); + } + + return list; + } + + protected void addProcessDefinitionToCacheAndRetrieveDocumentation(List list) { + for (ProcessDefinition processDefinition : list) { + + BpmnModelInstance bpmnModelInstance = Context.getProcessEngineConfiguration() + .getDeploymentCache() + .findBpmnModelInstanceForProcessDefinition((ProcessDefinitionEntity) processDefinition); + + ModelElementInstance processElement = bpmnModelInstance.getModelElementById(processDefinition.getKey()); + if (processElement != null) { + Collection documentations = processElement.getChildElementsByType(Documentation.class); + List docStrings = new ArrayList(); + for (Documentation documentation : documentations) { + docStrings.add(documentation.getTextContent()); + } + + ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) processDefinition; + processDefinitionEntity.setProperty(BpmnParse.PROPERTYNAME_DOCUMENTATION, BpmnParse.parseDocumentation(docStrings)); + } + + } + } + + @Override + public void checkQueryOk() { + super.checkQueryOk(); + + if (latest && ( (id != null) || (version != null) || (deploymentId != null) ) ){ + throw new ProcessEngineException("Calling latest() can only be used in combination with key(String) and keyLike(String) or name(String) and nameLike(String)"); + } + } + + //getters //////////////////////////////////////////// + + public String getDeploymentId() { + return deploymentId; + } + + public Date getDeployedAfter() { + return deployedAfter; + } + + public Date getDeployedAt() { + return deployedAt; + } + + public String getId() { + return id; + } + + public String[] getIds() { + return ids; + } + + public String getName() { + return name; + } + + public String getNameLike() { + return nameLike; + } + + public String getKey() { + return key; + } + + public String getKeyLike() { + return keyLike; + } + + public Integer getVersion() { + return version; + } + + public boolean isLatest() { + return latest; + } + + public String getCategory() { + return category; + } + + public String getCategoryLike() { + return categoryLike; + } + + public String getResourceName() { + return resourceName; + } + + public String getResourceNameLike() { + return resourceNameLike; + } + + public SuspensionState getSuspensionState() { + return suspensionState; + } + + public void setSuspensionState(SuspensionState suspensionState) { + this.suspensionState = suspensionState; + } + + public String getIncidentId() { + return incidentId; + } + + public String getIncidentType() { + return incidentType; + } + + public String getIncidentMessage() { + return incidentMessage; + } + + public String getIncidentMessageLike() { + return incidentMessageLike; + } + + public String getVersionTag() { + return versionTag; + } + + public boolean isStartableInTasklist() { + return isStartableInTasklist; + } + + public boolean isNotStartableInTasklist() { + return isNotStartableInTasklist; + } + + public boolean isStartablePermissionCheck() { + return startablePermissionCheck; + } + + public void setProcessDefinitionCreatePermissionChecks(List processDefinitionCreatePermissionChecks) { + this.processDefinitionCreatePermissionChecks = processDefinitionCreatePermissionChecks; + } + + public List getProcessDefinitionCreatePermissionChecks() { + return processDefinitionCreatePermissionChecks; + } + + public boolean isShouldJoinDeploymentTable() { + return shouldJoinDeploymentTable; + } + + public void addProcessDefinitionCreatePermissionCheck(CompositePermissionCheck processDefinitionCreatePermissionCheck) { + processDefinitionCreatePermissionChecks.addAll(processDefinitionCreatePermissionCheck.getAllPermissionChecks()); + } + + public List getCandidateGroups() { + if (cachedCandidateGroups != null) { + return cachedCandidateGroups; + } + + if(authorizationUserId != null) { + List groups = Context.getCommandContext() + .getReadOnlyIdentityProvider() + .createGroupQuery() + .groupMember(authorizationUserId) + .list(); + cachedCandidateGroups = groups.stream().map(Group::getId).collect(Collectors.toList()); + } + + return cachedCandidateGroups; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessDefinitionQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessDefinitionQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..e1a85ca32f6b8a9cba9131a323bd367a2149eb12 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessDefinitionQueryProperty.java @@ -0,0 +1,40 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; +import org.camunda.bpm.engine.repository.ProcessDefinitionQuery; + + +/** + * Contains the possible properties that can be used in a {@link ProcessDefinitionQuery}. + * + * @author Joram Barrez + */ +public interface ProcessDefinitionQueryProperty { + + public static final QueryProperty PROCESS_DEFINITION_KEY = new QueryPropertyImpl("KEY_"); + public static final QueryProperty PROCESS_DEFINITION_CATEGORY = new QueryPropertyImpl("CATEGORY_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty PROCESS_DEFINITION_VERSION = new QueryPropertyImpl("VERSION_"); + public static final QueryProperty PROCESS_DEFINITION_NAME = new QueryPropertyImpl("NAME_"); + public static final QueryProperty DEPLOYMENT_ID = new QueryPropertyImpl("DEPLOYMENT_ID_"); + public static final QueryProperty DEPLOY_TIME = new QueryPropertyImpl("DEPLOY_TIME_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + public static final QueryProperty VERSION_TAG = new QueryPropertyImpl("VERSION_TAG_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessDefinitionStatisticsQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessDefinitionStatisticsQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..3b1237391c9d80bf515abc3010a027074dac4244 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessDefinitionStatisticsQueryImpl.java @@ -0,0 +1,102 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.management.ProcessDefinitionStatistics; +import org.camunda.bpm.engine.management.ProcessDefinitionStatisticsQuery; + + +public class ProcessDefinitionStatisticsQueryImpl extends AbstractQuery + implements ProcessDefinitionStatisticsQuery { + + protected static final long serialVersionUID = 1L; + protected boolean includeFailedJobs = false; + protected boolean includeIncidents = false; + protected boolean includeRootIncidents = false; + protected String includeIncidentsForType; + + public ProcessDefinitionStatisticsQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return + commandContext + .getStatisticsManager() + .getStatisticsCountGroupedByProcessDefinitionVersion(this); + } + + @Override + public List executeList(CommandContext commandContext, + Page page) { + checkQueryOk(); + return + commandContext + .getStatisticsManager() + .getStatisticsGroupedByProcessDefinitionVersion(this, page); + } + + public ProcessDefinitionStatisticsQuery includeFailedJobs() { + includeFailedJobs = true; + return this; + } + + public ProcessDefinitionStatisticsQuery includeIncidents() { + includeIncidents = true; + return this; + } + + public ProcessDefinitionStatisticsQuery includeIncidentsForType(String incidentType) { + this.includeIncidentsForType = incidentType; + return this; + } + + public boolean isFailedJobsToInclude() { + return includeFailedJobs; + } + + public boolean isIncidentsToInclude() { + return includeIncidents || includeRootIncidents || includeIncidentsForType != null; + } + + protected void checkQueryOk() { + super.checkQueryOk(); + if (includeIncidents && includeIncidentsForType != null) { + throw new ProcessEngineException("Invalid query: It is not possible to use includeIncident() and includeIncidentForType() to execute one query."); + } + if (includeRootIncidents && includeIncidentsForType != null) { + throw new ProcessEngineException("Invalid query: It is not possible to use includeRootIncident() and includeIncidentForType() to execute one query."); + } + if (includeIncidents && includeRootIncidents) { + throw new ProcessEngineException("Invalid query: It is not possible to use includeIncident() and includeRootIncidents() to execute one query."); + } + } + + @Override + public ProcessDefinitionStatisticsQuery includeRootIncidents() { + this.includeRootIncidents = true; + return this; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessEngineImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessEngineImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..7ccb84533081cb66ba2d5f3f70fcfc9ef8bbea43 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessEngineImpl.java @@ -0,0 +1,248 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.Map; + +import org.camunda.bpm.engine.AuthorizationService; +import org.camunda.bpm.engine.CaseService; +import org.camunda.bpm.engine.DecisionService; +import org.camunda.bpm.engine.ExternalTaskService; +import org.camunda.bpm.engine.FilterService; +import org.camunda.bpm.engine.FormService; +import org.camunda.bpm.engine.HistoryService; +import org.camunda.bpm.engine.IdentityService; +import org.camunda.bpm.engine.ManagementService; +import org.camunda.bpm.engine.OptimisticLockingException; +import org.camunda.bpm.engine.ProcessEngine; +import org.camunda.bpm.engine.ProcessEngines; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.TaskService; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.cfg.TransactionContextFactory; +import org.camunda.bpm.engine.impl.el.ExpressionManager; +import org.camunda.bpm.engine.impl.history.HistoryLevel; +import org.camunda.bpm.engine.impl.history.event.SimpleIpBasedProvider; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.interceptor.SessionFactory; +import org.camunda.bpm.engine.impl.jobexecutor.JobExecutor; +import org.camunda.bpm.engine.impl.metrics.reporter.DbMetricsReporter; +import org.camunda.bpm.engine.impl.util.CompositeCondition; + +/** + * @author Tom Baeyens + */ +public class ProcessEngineImpl implements ProcessEngine { + + /** external task conditions used to signal long polling in rest API */ + public static final CompositeCondition EXT_TASK_CONDITIONS = new CompositeCondition(); + + private final static ProcessEngineLogger LOG = ProcessEngineLogger.INSTANCE; + + protected String name; + + protected RepositoryService repositoryService; + protected RuntimeService runtimeService; + protected HistoryService historicDataService; + protected IdentityService identityService; + protected TaskService taskService; + protected FormService formService; + protected ManagementService managementService; + protected AuthorizationService authorizationService; + protected CaseService caseService; + protected FilterService filterService; + protected ExternalTaskService externalTaskService; + protected DecisionService decisionService; + + protected String databaseSchemaUpdate; + protected JobExecutor jobExecutor; + protected CommandExecutor commandExecutor; + protected CommandExecutor commandExecutorSchemaOperations; + protected Map, SessionFactory> sessionFactories; + protected ExpressionManager expressionManager; + protected HistoryLevel historyLevel; + protected TransactionContextFactory transactionContextFactory; + protected ProcessEngineConfigurationImpl processEngineConfiguration; + + public ProcessEngineImpl(ProcessEngineConfigurationImpl processEngineConfiguration) { + + this.processEngineConfiguration = processEngineConfiguration; + this.name = processEngineConfiguration.getProcessEngineName(); + + this.repositoryService = processEngineConfiguration.getRepositoryService(); + this.runtimeService = processEngineConfiguration.getRuntimeService(); + this.historicDataService = processEngineConfiguration.getHistoryService(); + this.identityService = processEngineConfiguration.getIdentityService(); + this.taskService = processEngineConfiguration.getTaskService(); + this.formService = processEngineConfiguration.getFormService(); + this.managementService = processEngineConfiguration.getManagementService(); + this.authorizationService = processEngineConfiguration.getAuthorizationService(); + this.caseService = processEngineConfiguration.getCaseService(); + this.filterService = processEngineConfiguration.getFilterService(); + this.externalTaskService = processEngineConfiguration.getExternalTaskService(); + this.decisionService = processEngineConfiguration.getDecisionService(); + + this.databaseSchemaUpdate = processEngineConfiguration.getDatabaseSchemaUpdate(); + this.jobExecutor = processEngineConfiguration.getJobExecutor(); + this.commandExecutor = processEngineConfiguration.getCommandExecutorTxRequired(); + commandExecutorSchemaOperations = processEngineConfiguration.getCommandExecutorSchemaOperations(); + this.sessionFactories = processEngineConfiguration.getSessionFactories(); + this.historyLevel = processEngineConfiguration.getHistoryLevel(); + this.transactionContextFactory = processEngineConfiguration.getTransactionContextFactory(); + + executeSchemaOperations(); + + if (name == null) { + LOG.processEngineCreated(ProcessEngines.NAME_DEFAULT); + } else { + LOG.processEngineCreated(name); + } + + ProcessEngines.registerProcessEngine(this); + + if ((jobExecutor != null)) { + // register process engine with Job Executor + jobExecutor.registerProcessEngine(this); + } + + if (processEngineConfiguration.isMetricsEnabled()) { + String reporterId; + // only use a deprecated, custom MetricsReporterIdProvider, + // if no static hostname AND custom HostnameProvider are set. + // See ProcessEngineConfigurationImpl#initHostname() + if (processEngineConfiguration.getMetricsReporterIdProvider() != null + && processEngineConfiguration.getHostnameProvider() instanceof SimpleIpBasedProvider) { + reporterId = processEngineConfiguration.getMetricsReporterIdProvider().provideId(this); + } else { + reporterId = processEngineConfiguration.getHostname(); + } + + DbMetricsReporter dbMetricsReporter = processEngineConfiguration.getDbMetricsReporter(); + dbMetricsReporter.setReporterId(reporterId); + + if(processEngineConfiguration.isDbMetricsReporterActivate()) { + dbMetricsReporter.start(); + } + } + } + + protected void executeSchemaOperations() { + commandExecutorSchemaOperations.execute(processEngineConfiguration.getSchemaOperationsCommand()); + commandExecutorSchemaOperations.execute(processEngineConfiguration.getHistoryLevelCommand()); + + try { + commandExecutorSchemaOperations.execute(processEngineConfiguration.getProcessEngineBootstrapCommand()); + } catch (OptimisticLockingException ole) { + // if an OLE occurred during the process engine bootstrap, we suppress it + // since all the data has already been persisted by a previous process engine bootstrap + LOG.historyCleanupJobReconfigurationFailure(ole); + } + } + + @Override + public void close() { + + ProcessEngines.unregister(this); + + if(processEngineConfiguration.isMetricsEnabled()) { + processEngineConfiguration.getDbMetricsReporter().stop(); + } + + if ((jobExecutor != null)) { + // unregister process engine with Job Executor + jobExecutor.unregisterProcessEngine(this); + } + + commandExecutorSchemaOperations.execute(new SchemaOperationProcessEngineClose()); + + processEngineConfiguration.close(); + + LOG.processEngineClosed(name); + } + + @Override + public String getName() { + return name; + } + + @Override + public ProcessEngineConfigurationImpl getProcessEngineConfiguration() { + return processEngineConfiguration; + } + + @Override + public IdentityService getIdentityService() { + return identityService; + } + + @Override + public ManagementService getManagementService() { + return managementService; + } + + @Override + public TaskService getTaskService() { + return taskService; + } + + @Override + public HistoryService getHistoryService() { + return historicDataService; + } + + @Override + public RuntimeService getRuntimeService() { + return runtimeService; + } + + @Override + public RepositoryService getRepositoryService() { + return repositoryService; + } + + @Override + public FormService getFormService() { + return formService; + } + + @Override + public AuthorizationService getAuthorizationService() { + return authorizationService; + } + + @Override + public CaseService getCaseService() { + return caseService; + } + + @Override + public FilterService getFilterService() { + return filterService; + } + + @Override + public ExternalTaskService getExternalTaskService() { + return externalTaskService; + } + + @Override + public DecisionService getDecisionService() { + return decisionService; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessEngineInfoImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessEngineInfoImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e614b18b0449181ff77775b37c10f18ae7e1fcf3 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessEngineInfoImpl.java @@ -0,0 +1,50 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.io.Serializable; + +import org.camunda.bpm.engine.ProcessEngineInfo; + + +/** + * @author Tom Baeyens + */ +public class ProcessEngineInfoImpl implements Serializable, ProcessEngineInfo { + + private static final long serialVersionUID = 1L; + + String name; + String resourceUrl; + String exception; + + public ProcessEngineInfoImpl(String name, String resourceUrl, String exception) { + this.name = name; + this.resourceUrl = resourceUrl; + this.exception = exception; + } + + public String getName() { + return name; + } + public String getResourceUrl() { + return resourceUrl; + } + public String getException() { + return exception; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessEngineLogger.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessEngineLogger.java new file mode 100644 index 0000000000000000000000000000000000000000..e9370693e2fc0447a888e87d19325030f281ce35 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessEngineLogger.java @@ -0,0 +1,192 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.net.URL; +import org.camunda.bpm.application.impl.ProcessApplicationLogger; +import org.camunda.bpm.container.impl.ContainerIntegrationLogger; +import org.camunda.bpm.engine.ProcessEngineConfiguration; +import org.camunda.bpm.engine.impl.bpmn.behavior.BpmnBehaviorLogger; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParseLogger; +import org.camunda.bpm.engine.impl.cfg.ConfigurationLogger; +import org.camunda.bpm.engine.impl.cfg.TransactionLogger; +import org.camunda.bpm.engine.impl.cmd.CommandLogger; +import org.camunda.bpm.engine.impl.cmmn.behavior.CmmnBehaviorLogger; +import org.camunda.bpm.engine.impl.cmmn.operation.CmmnOperationLogger; +import org.camunda.bpm.engine.impl.cmmn.transformer.CmmnTransformerLogger; +import org.camunda.bpm.engine.impl.core.CoreLogger; +import org.camunda.bpm.engine.impl.db.EnginePersistenceLogger; +import org.camunda.bpm.engine.impl.digest.SecurityLogger; +import org.camunda.bpm.engine.impl.dmn.DecisionLogger; +import org.camunda.bpm.engine.impl.externaltask.ExternalTaskLogger; +import org.camunda.bpm.engine.impl.identity.IndentityLogger; +import org.camunda.bpm.engine.impl.incident.IncidentLogger; +import org.camunda.bpm.engine.impl.interceptor.ContextLogger; +import org.camunda.bpm.engine.impl.jobexecutor.JobExecutorLogger; +import org.camunda.bpm.engine.impl.metrics.MetricsLogger; +import org.camunda.bpm.engine.impl.migration.MigrationLogger; +import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; +import org.camunda.bpm.engine.impl.plugin.AdministratorAuthorizationPluginLogger; +import org.camunda.bpm.engine.impl.pvm.PvmLogger; +import org.camunda.bpm.engine.impl.scripting.ScriptLogger; +import org.camunda.bpm.engine.impl.test.TestLogger; +import org.camunda.bpm.engine.impl.util.EngineUtilLogger; +import org.camunda.commons.logging.BaseLogger; + +/** + * @author Stefan Hentschel. + */ +public class ProcessEngineLogger extends BaseLogger { + + public static final String PROJECT_CODE = "ENGINE"; + + public static final ProcessEngineLogger INSTANCE = BaseLogger.createLogger( + ProcessEngineLogger.class, PROJECT_CODE, "org.camunda.bpm.engine", "00"); + + public static final BpmnParseLogger BPMN_PARSE_LOGGER = BaseLogger.createLogger( + BpmnParseLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.bpmn.parser", "01"); + + public static final BpmnBehaviorLogger BPMN_BEHAVIOR_LOGGER = BaseLogger.createLogger( + BpmnBehaviorLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.bpmn.behavior", "02"); + + public static final EnginePersistenceLogger PERSISTENCE_LOGGER = BaseLogger.createLogger( + EnginePersistenceLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.persistence", "03"); + + public static final CmmnTransformerLogger CMMN_TRANSFORMER_LOGGER = BaseLogger.createLogger( + CmmnTransformerLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.cmmn.transformer", "04"); + + public static final CmmnBehaviorLogger CMNN_BEHAVIOR_LOGGER = BaseLogger.createLogger( + CmmnBehaviorLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.cmmn.behavior", "05"); + + public static final CmmnOperationLogger CMMN_OPERATION_LOGGER = BaseLogger.createLogger( + CmmnOperationLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.cmmn.operation", "06"); + + public static final ProcessApplicationLogger PROCESS_APPLICATION_LOGGER = BaseLogger.createLogger( + ProcessApplicationLogger.class, PROJECT_CODE, "org.camunda.bpm.application", "07"); + + public static final ContainerIntegrationLogger CONTAINER_INTEGRATION_LOGGER = BaseLogger.createLogger( + ContainerIntegrationLogger.class, PROJECT_CODE, "org.camunda.bpm.container", "08"); + + public static final EngineUtilLogger UTIL_LOGGER = BaseLogger.createLogger( + EngineUtilLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.util", "09"); + + public static final TransactionLogger TX_LOGGER = BaseLogger.createLogger( + TransactionLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.tx", "11"); + + public static final ConfigurationLogger CONFIG_LOGGER = BaseLogger.createLogger( + ConfigurationLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.cfg", "12"); + + public static final CommandLogger CMD_LOGGER = BaseLogger.createLogger( + CommandLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.cmd", "13"); + + public static final JobExecutorLogger JOB_EXECUTOR_LOGGER = BaseLogger.createLogger( + JobExecutorLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.jobexecutor", "14"); + + public static final TestLogger TEST_LOGGER = BaseLogger.createLogger( + TestLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.test", "15"); + + public static final ContextLogger CONTEXT_LOGGER = BaseLogger.createLogger( + ContextLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.context", "16"); + + public static final CoreLogger CORE_LOGGER = BaseLogger.createLogger( + CoreLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.core", "17"); + + public static final MetricsLogger METRICS_LOGGER = BaseLogger.createLogger( + MetricsLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.metrics", "18"); + + public static final AdministratorAuthorizationPluginLogger ADMIN_PLUGIN_LOGGER = BaseLogger.createLogger( + AdministratorAuthorizationPluginLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.plugin.admin", "19"); + + public static final PvmLogger PVM_LOGGER = BaseLogger.createLogger( + PvmLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.pvm", "20"); + + public static final ScriptLogger SCRIPT_LOGGER = BaseLogger.createLogger( + ScriptLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.script", "21"); + + public static final DecisionLogger DECISION_LOGGER = BaseLogger.createLogger( + DecisionLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.dmn", "22"); + + public static final MigrationLogger MIGRATION_LOGGER = BaseLogger.createLogger( + MigrationLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.migration", "23"); + + public static final ExternalTaskLogger EXTERNAL_TASK_LOGGER = BaseLogger.createLogger( + ExternalTaskLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.externaltask", "24"); + + public static final SecurityLogger SECURITY_LOGGER = BaseLogger.createLogger( + SecurityLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.security", "25"); + + public static final IncidentLogger INCIDENT_LOGGER = BaseLogger.createLogger( + IncidentLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.incident", "26"); + + public static final IndentityLogger INDENTITY_LOGGER = BaseLogger.createLogger( + IndentityLogger.class, PROJECT_CODE, "org.camunda.bpm.engine.identity", "27"); + // Use code 29 for the next logger. Skip 28 as it's previously used for telemetry feature that is removed from the code base now + + public static boolean shouldLogJobException(ProcessEngineConfiguration processEngineConfiguration, JobEntity currentJob) { + boolean enableReducedJobExceptionLogging = processEngineConfiguration.isEnableReducedJobExceptionLogging(); + return currentJob == null || !enableReducedJobExceptionLogging || enableReducedJobExceptionLogging && currentJob.getRetries() <= 1; + } + + public static boolean shouldLogCmdException(ProcessEngineConfiguration processEngineConfiguration) { + return processEngineConfiguration.isEnableCmdExceptionLogging(); + } + + public void processEngineCreated(String name) { + logInfo("001", "Process Engine {} created.", name); + } + + public void processEngineAlreadyInitialized() { + logInfo("002", "Process engine already initialized"); + } + + public void initializingProcessEngineForResource(URL resourceUrl) { + logInfo( + "003", "Initializing process engine for resource {}", resourceUrl); + } + + public void initializingProcessEngine(String name) { + logInfo( + "004", "Initializing process engine {}", name); + } + + public void exceptionWhileInitializingProcessengine(Throwable e) { + logError("005", "Exception while initializing process engine {}", e.getMessage(), e); + } + + public void exceptionWhileClosingProcessEngine(String string, Exception e) { + logError("006", "Exception while closing process engine {}", string, e); + } + + public void processEngineClosed(String name) { + logInfo("007", "Process Engine {} closed", name); + } + + public void historyCleanupJobReconfigurationFailure(Exception exception) { + logInfo( + "008", + "History Cleanup Job reconfiguration failed on Process Engine Bootstrap. Possible concurrent execution with the JobExecutor: {}", + exception.getMessage() + ); + } + + public void couldNotDetermineIp(Exception e) { + logWarn( + "009", "Could not determine local IP address for generating a host name", e); + } + +} + diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceModificationBuilderImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceModificationBuilderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..347204e942203f17422a8e8468d6f2839be4d03c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceModificationBuilderImpl.java @@ -0,0 +1,343 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.impl.cmd.AbstractInstantiationCmd; +import org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand; +import org.camunda.bpm.engine.impl.cmd.ActivityAfterInstantiationCmd; +import org.camunda.bpm.engine.impl.cmd.ActivityBeforeInstantiationCmd; +import org.camunda.bpm.engine.impl.cmd.ActivityCancellationCmd; +import org.camunda.bpm.engine.impl.cmd.ActivityInstanceCancellationCmd; +import org.camunda.bpm.engine.impl.cmd.ModifyProcessInstanceAsyncCmd; +import org.camunda.bpm.engine.impl.cmd.ModifyProcessInstanceCmd; +import org.camunda.bpm.engine.impl.cmd.TransitionInstanceCancellationCmd; +import org.camunda.bpm.engine.impl.cmd.TransitionInstantiationCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.ProcessInstanceModificationBuilder; +import org.camunda.bpm.engine.runtime.ProcessInstanceModificationInstantiationBuilder; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; + +/** + * @author Thorben Lindhauer + * + */ +public class ProcessInstanceModificationBuilderImpl implements ProcessInstanceModificationInstantiationBuilder { + + protected CommandExecutor commandExecutor; + protected CommandContext commandContext; + + protected String processInstanceId; + protected String modificationReason; + + protected boolean skipCustomListeners = false; + protected boolean skipIoMappings = false; + protected boolean externallyTerminated = false; + protected String annotation; + + protected List operations = new ArrayList(); + + // variables not associated with an activity that are to be set on the instance itself + protected VariableMap processVariables = new VariableMapImpl(); + + public ProcessInstanceModificationBuilderImpl(CommandExecutor commandExecutor, String processInstanceId) { + this(processInstanceId); + this.commandExecutor = commandExecutor; + } + + public ProcessInstanceModificationBuilderImpl(CommandContext commandContext, String processInstanceId) { + this(processInstanceId); + this.commandContext = commandContext; + } + + public ProcessInstanceModificationBuilderImpl(CommandContext commandContext, String processInstanceId, String modificationReason) { + this(processInstanceId); + this.commandContext = commandContext; + this.modificationReason = modificationReason; + } + + public ProcessInstanceModificationBuilderImpl(String processInstanceId) { + ensureNotNull(NotValidException.class, "processInstanceId", processInstanceId); + this.processInstanceId = processInstanceId; + } + + public ProcessInstanceModificationBuilderImpl() { + } + + @Override + public ProcessInstanceModificationBuilder cancelActivityInstance(String activityInstanceId) { + ensureNotNull(NotValidException.class, "activityInstanceId", activityInstanceId); + operations.add(new ActivityInstanceCancellationCmd(processInstanceId, activityInstanceId, this.modificationReason)); + return this; + } + + @Override + public ProcessInstanceModificationBuilder cancelTransitionInstance(String transitionInstanceId) { + ensureNotNull(NotValidException.class, "transitionInstanceId", transitionInstanceId); + operations.add(new TransitionInstanceCancellationCmd(processInstanceId, transitionInstanceId)); + return this; + } + + @Override + public ProcessInstanceModificationBuilder cancelAllForActivity(String activityId) { + ensureNotNull(NotValidException.class, "activityId", activityId); + operations.add(new ActivityCancellationCmd(processInstanceId, activityId)); + return this; + } + + @Override + public ProcessInstanceModificationBuilder cancellationSourceExternal(boolean external) { + this.externallyTerminated = external; + return this; + } + + @Override + public ProcessInstanceModificationInstantiationBuilder startBeforeActivity(String activityId) { + ensureNotNull(NotValidException.class, "activityId", activityId); + AbstractInstantiationCmd currentInstantiation = new ActivityBeforeInstantiationCmd(processInstanceId, activityId); + operations.add(currentInstantiation); + return this; + } + + @Override + public ProcessInstanceModificationInstantiationBuilder startBeforeActivity(String activityId, String ancestorActivityInstanceId) { + ensureNotNull(NotValidException.class, "activityId", activityId); + ensureNotNull(NotValidException.class, "ancestorActivityInstanceId", ancestorActivityInstanceId); + AbstractInstantiationCmd currentInstantiation = new ActivityBeforeInstantiationCmd(processInstanceId, activityId, ancestorActivityInstanceId); + operations.add(currentInstantiation); + return this; + } + + @Override + public ProcessInstanceModificationInstantiationBuilder startAfterActivity(String activityId) { + ensureNotNull(NotValidException.class, "activityId", activityId); + AbstractInstantiationCmd currentInstantiation = new ActivityAfterInstantiationCmd(processInstanceId, activityId); + operations.add(currentInstantiation); + return this; + } + + @Override + public ProcessInstanceModificationInstantiationBuilder startAfterActivity(String activityId, String ancestorActivityInstanceId) { + ensureNotNull(NotValidException.class, "activityId", activityId); + ensureNotNull(NotValidException.class, "ancestorActivityInstanceId", ancestorActivityInstanceId); + AbstractInstantiationCmd currentInstantiation = new ActivityAfterInstantiationCmd(processInstanceId, activityId, ancestorActivityInstanceId); + operations.add(currentInstantiation); + return this; + } + + @Override + public ProcessInstanceModificationInstantiationBuilder startTransition(String transitionId) { + ensureNotNull(NotValidException.class, "transitionId", transitionId); + AbstractInstantiationCmd currentInstantiation = new TransitionInstantiationCmd(processInstanceId, transitionId); + operations.add(currentInstantiation); + return this; + } + + @Override + public ProcessInstanceModificationInstantiationBuilder startTransition(String transitionId, String ancestorActivityInstanceId) { + ensureNotNull(NotValidException.class, "transitionId", transitionId); + ensureNotNull(NotValidException.class, "ancestorActivityInstanceId", ancestorActivityInstanceId); + AbstractInstantiationCmd currentInstantiation = new TransitionInstantiationCmd(processInstanceId, transitionId, ancestorActivityInstanceId); + operations.add(currentInstantiation); + return this; + } + + protected AbstractInstantiationCmd getCurrentInstantiation() { + if (operations.isEmpty()) { + return null; + } + + // casting should be safe + AbstractProcessInstanceModificationCommand lastInstantiationCmd = operations.get(operations.size() - 1); + + if (!(lastInstantiationCmd instanceof AbstractInstantiationCmd)) { + throw new ProcessEngineException("last instruction is not an instantiation"); + } + + return (AbstractInstantiationCmd) lastInstantiationCmd; + } + + @Override + public ProcessInstanceModificationInstantiationBuilder setVariable(String name, Object value) { + ensureNotNull(NotValidException.class, "Variable name must not be null", "name", name); + + AbstractInstantiationCmd currentInstantiation = getCurrentInstantiation(); + if (currentInstantiation != null) { + currentInstantiation.addVariable(name, value); + } + else { + processVariables.put(name, value); + } + + return this; + } + + @Override + public ProcessInstanceModificationInstantiationBuilder setVariableLocal(String name, Object value) { + ensureNotNull(NotValidException.class, "Variable name must not be null", "name", name); + + AbstractInstantiationCmd currentInstantiation = getCurrentInstantiation(); + if (currentInstantiation != null) { + currentInstantiation.addVariableLocal(name, value); + } + else { + processVariables.put(name, value); + } + + return this; + } + + @Override + public ProcessInstanceModificationInstantiationBuilder setVariables(Map variables) { + ensureNotNull(NotValidException.class, "Variable map must not be null", "variables", variables); + + AbstractInstantiationCmd currentInstantiation = getCurrentInstantiation(); + if (currentInstantiation != null) { + currentInstantiation.addVariables(variables); + } + else { + processVariables.putAll(variables); + } + return this; + } + + @Override + public ProcessInstanceModificationInstantiationBuilder setVariablesLocal(Map variables) { + ensureNotNull(NotValidException.class, "Variable map must not be null", "variablesLocal", variables); + + AbstractInstantiationCmd currentInstantiation = getCurrentInstantiation(); + if (currentInstantiation != null) { + currentInstantiation.addVariablesLocal(variables); + } + else { + processVariables.putAll(variables); + } + return this; + } + + @Override + public ProcessInstanceModificationBuilder setAnnotation(String annotation) { + ensureNotNull(NotValidException.class, "Annotation must not be null", "annotation", annotation); + this.annotation = annotation; + return this; + } + + @Override + public void execute() { + execute(false, false); + } + + @Override + public void execute(boolean skipCustomListeners, boolean skipIoMappings) { + execute(true, skipCustomListeners, skipIoMappings); + } + + public void execute(boolean writeUserOperationLog, boolean skipCustomListeners, boolean skipIoMappings) { + this.skipCustomListeners = skipCustomListeners; + this.skipIoMappings = skipIoMappings; + + ModifyProcessInstanceCmd cmd = new ModifyProcessInstanceCmd(this, writeUserOperationLog); + if (commandExecutor != null) { + commandExecutor.execute(cmd); + } else { + cmd.execute(commandContext); + } + } + + @Override + public Batch executeAsync() { + return executeAsync(false, false); + } + + @Override + public Batch executeAsync(boolean skipCustomListeners, boolean skipIoMappings) { + this.skipCustomListeners = skipCustomListeners; + this.skipIoMappings = skipIoMappings; + + return commandExecutor.execute(new ModifyProcessInstanceAsyncCmd(this)); + } + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } + + public CommandContext getCommandContext() { + return commandContext; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public List getModificationOperations() { + return operations; + } + + public void setModificationOperations(List operations) { + this.operations = operations; + } + + public boolean isSkipCustomListeners() { + return skipCustomListeners; + } + + public boolean isSkipIoMappings() { + return skipIoMappings; + } + + public boolean isExternallyTerminated() { + return externallyTerminated; + } + + public void setSkipCustomListeners(boolean skipCustomListeners) { + this.skipCustomListeners = skipCustomListeners; + } + + public void setSkipIoMappings(boolean skipIoMappings) { + this.skipIoMappings = skipIoMappings; + } + + public VariableMap getProcessVariables() { + return processVariables; + } + + public String getModificationReason() { + return modificationReason; + } + + public void setModificationReason(String modificationReason) { + this.modificationReason = modificationReason; + } + + public String getAnnotation() { + return annotation; + } + + public void setAnnotationInternal(String annotation) { + this.annotation = annotation; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceModificationInstruction.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceModificationInstruction.java new file mode 100644 index 0000000000000000000000000000000000000000..97e952e7b05f96d4472c1812611162e6e83a1f50 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceModificationInstruction.java @@ -0,0 +1,28 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; + +/** + * @author Thorben Lindhauer + * + */ +public interface ProcessInstanceModificationInstruction { + + void execute(CommandContext commandContext); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a4f700f68f07607bf182aa013213af4cf9206e45 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceQueryImpl.java @@ -0,0 +1,526 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotEmpty; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Set; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.SuspensionState; +import org.camunda.bpm.engine.impl.util.ImmutablePair; +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; + + +/** + * @author Tom Baeyens + * @author Joram Barrez + * @author Frederik Heremans + * @author Falko Menge + * @author Daniel Meyer + */ +public class ProcessInstanceQueryImpl extends AbstractVariableQueryImpl implements ProcessInstanceQuery, Serializable { + + private static final long serialVersionUID = 1L; + protected String processInstanceId; + protected String rootProcessInstanceId; + protected String businessKey; + protected String businessKeyLike; + protected String processDefinitionId; + protected Set processInstanceIds; + protected String processDefinitionKey; + protected String[] processDefinitionKeys; + protected String[] processDefinitionKeyNotIn; + protected String deploymentId; + protected String superProcessInstanceId; + protected String subProcessInstanceId; + protected SuspensionState suspensionState; + protected boolean withIncident; + protected String incidentType; + protected String incidentId; + protected String incidentMessage; + protected String incidentMessageLike; + protected String caseInstanceId; + protected String superCaseInstanceId; + protected String subCaseInstanceId; + protected String[] activityIds; + protected boolean isRootProcessInstances; + protected boolean isLeafProcessInstances; + + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + protected boolean isProcessDefinitionWithoutTenantId = false; + + // or query ///////////////////////////// + protected List queries = new ArrayList<>(Arrays.asList(this)); + protected boolean isOrQueryActive = false; + + public ProcessInstanceQueryImpl() { + } + + public ProcessInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public ProcessInstanceQueryImpl processInstanceId(String processInstanceId) { + ensureNotNull("Process instance id", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + public ProcessInstanceQueryImpl rootProcessInstanceId(String rootProcessInstanceId) { + ensureNotNull("Root process instance id", rootProcessInstanceId); + this.rootProcessInstanceId = rootProcessInstanceId; + return this; + } + + public ProcessInstanceQuery processInstanceIds(Set processInstanceIds) { + ensureNotEmpty("Set of process instance ids", processInstanceIds); + this.processInstanceIds = processInstanceIds; + return this; + } + + public ProcessInstanceQuery processInstanceBusinessKey(String businessKey) { + ensureNotNull("Business key", businessKey); + this.businessKey = businessKey; + return this; + } + + public ProcessInstanceQuery processInstanceBusinessKey(String businessKey, String processDefinitionKey) { + ensureNotNull("Business key", businessKey); + this.businessKey = businessKey; + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public ProcessInstanceQuery processInstanceBusinessKeyLike(String businessKeyLike) { + this.businessKeyLike = businessKeyLike; + return this; + } + + public ProcessInstanceQueryImpl processDefinitionId(String processDefinitionId) { + ensureNotNull("Process definition id", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + public ProcessInstanceQueryImpl processDefinitionKey(String processDefinitionKey) { + ensureNotNull("Process definition key", processDefinitionKey); + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public ProcessInstanceQuery processDefinitionKeyIn(String... processDefinitionKeys) { + ensureNotNull("processDefinitionKeys", (Object[]) processDefinitionKeys); + this.processDefinitionKeys = processDefinitionKeys; + return this; + } + + public ProcessInstanceQuery processDefinitionKeyNotIn(String... processDefinitionKeys) { + ensureNotNull("processDefinitionKeyNotIn", (Object[]) processDefinitionKeys); + this.processDefinitionKeyNotIn = processDefinitionKeys; + return this; + } + + public ProcessInstanceQuery deploymentId(String deploymentId) { + ensureNotNull("Deployment id", deploymentId); + this.deploymentId = deploymentId; + return this; + } + + public ProcessInstanceQuery superProcessInstanceId(String superProcessInstanceId) { + if (isRootProcessInstances) { + throw new ProcessEngineException("Invalid query usage: cannot set both rootProcessInstances and superProcessInstanceId"); + } + this.superProcessInstanceId = superProcessInstanceId; + return this; + } + + public ProcessInstanceQuery subProcessInstanceId(String subProcessInstanceId) { + this.subProcessInstanceId = subProcessInstanceId; + return this; + } + + public ProcessInstanceQuery caseInstanceId(String caseInstanceId) { + ensureNotNull("caseInstanceId", caseInstanceId); + this.caseInstanceId = caseInstanceId; + return this; + } + + public ProcessInstanceQuery superCaseInstanceId(String superCaseInstanceId) { + ensureNotNull("superCaseInstanceId", superCaseInstanceId); + this.superCaseInstanceId = superCaseInstanceId; + return this; + } + + public ProcessInstanceQuery subCaseInstanceId(String subCaseInstanceId) { + ensureNotNull("subCaseInstanceId", subCaseInstanceId); + this.subCaseInstanceId = subCaseInstanceId; + return this; + } + + public ProcessInstanceQuery orderByProcessInstanceId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessInstanceId() within 'or' query"); + } + + orderBy(ProcessInstanceQueryProperty.PROCESS_INSTANCE_ID); + return this; + } + + public ProcessInstanceQuery orderByProcessDefinitionId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessDefinitionId() within 'or' query"); + } + + orderBy(new QueryOrderingProperty(QueryOrderingProperty.RELATION_PROCESS_DEFINITION, + ProcessInstanceQueryProperty.PROCESS_DEFINITION_ID)); + return this; + } + + public ProcessInstanceQuery orderByProcessDefinitionKey() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByProcessDefinitionKey() within 'or' query"); + } + + orderBy(new QueryOrderingProperty(QueryOrderingProperty.RELATION_PROCESS_DEFINITION, + ProcessInstanceQueryProperty.PROCESS_DEFINITION_KEY)); + return this; + } + + public ProcessInstanceQuery orderByTenantId() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByTenantId() within 'or' query"); + } + + orderBy(ProcessInstanceQueryProperty.TENANT_ID); + return this; + } + + public ProcessInstanceQuery orderByBusinessKey() { + if (isOrQueryActive) { + throw new ProcessEngineException("Invalid query usage: cannot set orderByBusinessKey() within 'or' query"); + } + + orderBy(ProcessInstanceQueryProperty.BUSINESS_KEY); + return this; + } + + public ProcessInstanceQuery active() { + this.suspensionState = SuspensionState.ACTIVE; + return this; + } + + public ProcessInstanceQuery suspended() { + this.suspensionState = SuspensionState.SUSPENDED; + return this; + } + + public ProcessInstanceQuery withIncident() { + this.withIncident = true; + return this; + } + + public ProcessInstanceQuery incidentType(String incidentType) { + ensureNotNull("incident type", incidentType); + this.incidentType = incidentType; + return this; + } + + public ProcessInstanceQuery incidentId(String incidentId) { + ensureNotNull("incident id", incidentId); + this.incidentId = incidentId; + return this; + } + + public ProcessInstanceQuery incidentMessage(String incidentMessage) { + ensureNotNull("incident message", incidentMessage); + this.incidentMessage = incidentMessage; + return this; + } + + public ProcessInstanceQuery incidentMessageLike(String incidentMessageLike) { + ensureNotNull("incident messageLike", incidentMessageLike); + this.incidentMessageLike = incidentMessageLike; + return this; + } + + public ProcessInstanceQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public ProcessInstanceQuery withoutTenantId() { + tenantIds = null; + isTenantIdSet = true; + return this; + } + + public ProcessInstanceQuery activityIdIn(String... activityIds) { + ensureNotNull("activity ids", (Object[]) activityIds); + this.activityIds = activityIds; + return this; + } + + public ProcessInstanceQuery rootProcessInstances() { + if (superProcessInstanceId != null) { + throw new ProcessEngineException("Invalid query usage: cannot set both rootProcessInstances and superProcessInstanceId"); + } + isRootProcessInstances = true; + return this; + } + + public ProcessInstanceQuery leafProcessInstances() { + if(subProcessInstanceId != null) { + throw new ProcessEngineException("Invalid query usage: cannot set both leafProcessInstances and subProcessInstanceId"); + } + isLeafProcessInstances = true; + return this; + } + + public ProcessInstanceQuery processDefinitionWithoutTenantId() { + isProcessDefinitionWithoutTenantId = true; + return this; + } + + //results ///////////////////////////////////////////////////////////////// + + @Override + protected void checkQueryOk() { + ensureVariablesInitialized(); + + super.checkQueryOk(); + } + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + + return commandContext + .getExecutionManager() + .findProcessInstanceCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + + return commandContext + .getExecutionManager() + .findProcessInstancesByQueryCriteria(this, page); + } + + public List executeIdsList(CommandContext commandContext) { + checkQueryOk(); + + return commandContext + .getExecutionManager() + .findProcessInstancesIdsByQueryCriteria(this); + } + + @Override + public List> executeDeploymentIdMappingsList(CommandContext commandContext) { + checkQueryOk(); + + return commandContext + .getExecutionManager() + .findDeploymentIdMappingsByQueryCriteria(this); + } + + @Override + protected void ensureVariablesInitialized() { + super.ensureVariablesInitialized(); + + if (!queries.isEmpty()) { + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + VariableSerializers variableSerializers = processEngineConfiguration.getVariableSerializers(); + String dbType = processEngineConfiguration.getDatabaseType(); + + for (ProcessInstanceQueryImpl orQuery: queries) { + for (QueryVariableValue var : orQuery.getQueryVariableValues()) { + var.initialize(variableSerializers, dbType); + } + } + } + } + + //getters ///////////////////////////////////////////////////////////////// + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String getRootProcessInstanceId() { + return rootProcessInstanceId; + } + + public Set getProcessInstanceIds() { + return processInstanceIds; + } + + public List getQueries() { + return queries; + } + + public void addOrQuery(ProcessInstanceQueryImpl orQuery) { + orQuery.isOrQueryActive = true; + this.queries.add(orQuery); + } + + public void setOrQueryActive() { + isOrQueryActive = true; + } + + public boolean isOrQueryActive() { + return isOrQueryActive; + } + + public String[] getActivityIds() { + return activityIds; + } + + public String getBusinessKey() { + return businessKey; + } + + public String getBusinessKeyLike() { + return businessKeyLike; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public String[] getProcessDefinitionKeys() { + return processDefinitionKeys; + } + + public String[] getProcessDefinitionKeyNotIn() { + return processDefinitionKeyNotIn; + } + + public String getDeploymentId() { + return deploymentId; + } + + public String getSuperProcessInstanceId() { + return superProcessInstanceId; + } + + public String getSubProcessInstanceId() { + return subProcessInstanceId; + } + + public SuspensionState getSuspensionState() { + return suspensionState; + } + + public void setSuspensionState(SuspensionState suspensionState) { + this.suspensionState = suspensionState; + } + + public boolean isWithIncident() { + return withIncident; + } + + public String getIncidentId() { + return incidentId; + } + + public String getIncidentType() { + return incidentType; + } + + public String getIncidentMessage() { + return incidentMessage; + } + + public String getIncidentMessageLike() { + return incidentMessageLike; + } + + public String getCaseInstanceId() { + return caseInstanceId; + } + + public String getSuperCaseInstanceId() { + return superCaseInstanceId; + } + + public String getSubCaseInstanceId() { + return subCaseInstanceId; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public boolean isRootProcessInstances() { + return isRootProcessInstances; + } + + public boolean isProcessDefinitionWithoutTenantId() { + return isProcessDefinitionWithoutTenantId; + } + + public boolean isLeafProcessInstances() { + return isLeafProcessInstances; + } + + public String[] getTenantIds() { + return tenantIds; + } + + @Override + public ProcessInstanceQuery or() { + if (this != queries.get(0)) { + throw new ProcessEngineException("Invalid query usage: cannot set or() within 'or' query"); + } + + ProcessInstanceQueryImpl orQuery = new ProcessInstanceQueryImpl(); + orQuery.isOrQueryActive = true; + orQuery.queries = queries; + queries.add(orQuery); + return orQuery; + } + + @Override + public ProcessInstanceQuery endOr() { + if (!queries.isEmpty() && this != queries.get(queries.size()-1)) { + throw new ProcessEngineException("Invalid query usage: cannot set endOr() before or()"); + } + + return queries.get(0); + } +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..1859d18c5b4599ee3e233fd81a176670bd2cf242 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstanceQueryProperty.java @@ -0,0 +1,36 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; + + +/** + * Contains the possible properties that can be used in a {@link ProcessInstanceQuery}. + * + * @author Joram Barrez + */ +public interface ProcessInstanceQueryProperty { + + public static final QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty PROCESS_DEFINITION_KEY = new QueryPropertyImpl("KEY_"); + public static final QueryProperty PROCESS_DEFINITION_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + public static final QueryProperty BUSINESS_KEY = new QueryPropertyImpl("BUSINESS_KEY_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstantiationBuilderImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstantiationBuilderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..d8139d218c78377ef3dd75a67bbbd22f67fd24ec --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ProcessInstantiationBuilderImpl.java @@ -0,0 +1,231 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureOnlyOneNotNull; + +import java.util.Map; + +import org.camunda.bpm.engine.impl.cmd.CommandLogger; +import org.camunda.bpm.engine.impl.cmd.StartProcessInstanceAtActivitiesCmd; +import org.camunda.bpm.engine.impl.cmd.StartProcessInstanceCmd; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.runtime.ProcessInstanceWithVariables; +import org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder; + +/** + * Simply wraps a modification builder because their API is equivalent. + * + * @author Thorben Lindhauer + */ +public class ProcessInstantiationBuilderImpl implements ProcessInstantiationBuilder { + + private final static CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; + + protected CommandExecutor commandExecutor; + + protected String processDefinitionId; + protected String processDefinitionKey; + + protected String businessKey; + protected String caseInstanceId; + protected String tenantId; + + protected String processDefinitionTenantId; + protected boolean isProcessDefinitionTenantIdSet = false; + + protected String restartedProcessInstanceId; + + protected ProcessInstanceModificationBuilderImpl modificationBuilder; + + protected ProcessInstantiationBuilderImpl(CommandExecutor commandExecutor) { + modificationBuilder = new ProcessInstanceModificationBuilderImpl(); + + this.commandExecutor = commandExecutor; + } + + public ProcessInstantiationBuilder startBeforeActivity(String activityId) { + modificationBuilder.startBeforeActivity(activityId); + return this; + } + + public ProcessInstantiationBuilder startAfterActivity(String activityId) { + modificationBuilder.startAfterActivity(activityId); + return this; + } + + public ProcessInstantiationBuilder startTransition(String transitionId) { + modificationBuilder.startTransition(transitionId); + return this; + } + + public ProcessInstantiationBuilder setVariable(String name, Object value) { + modificationBuilder.setVariable(name, value); + return this; + } + + public ProcessInstantiationBuilder setVariableLocal(String name, Object value) { + modificationBuilder.setVariableLocal(name, value); + return this; + } + + public ProcessInstantiationBuilder setVariables(Map variables) { + if (variables != null) { + modificationBuilder.setVariables(variables); + } + return this; + } + + public ProcessInstantiationBuilder setVariablesLocal(Map variables) { + if (variables != null) { + modificationBuilder.setVariablesLocal(variables); + } + return this; + } + + public ProcessInstantiationBuilder businessKey(String businessKey) { + this.businessKey = businessKey; + return this; + } + + public ProcessInstantiationBuilder caseInstanceId(String caseInstanceId) { + this.caseInstanceId = caseInstanceId; + return this; + } + + public ProcessInstantiationBuilder tenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + public ProcessInstantiationBuilder processDefinitionTenantId(String tenantId) { + this.processDefinitionTenantId = tenantId; + isProcessDefinitionTenantIdSet = true; + return this; + } + + public ProcessInstantiationBuilder processDefinitionWithoutTenantId() { + this.processDefinitionTenantId = null; + isProcessDefinitionTenantIdSet = true; + return this; + } + + public ProcessInstance execute() { + return execute(false, false); + } + + public ProcessInstance execute(boolean skipCustomListeners, boolean skipIoMappings) { + return executeWithVariablesInReturn(skipCustomListeners, skipIoMappings); + } + + @Override + public ProcessInstanceWithVariables executeWithVariablesInReturn() { + return executeWithVariablesInReturn(false, false); + } + + @Override + public ProcessInstanceWithVariables executeWithVariablesInReturn(boolean skipCustomListeners, boolean skipIoMappings) { + ensureOnlyOneNotNull("either process definition id or key must be set", processDefinitionId, processDefinitionKey); + + if (isProcessDefinitionTenantIdSet && processDefinitionId != null) { + throw LOG.exceptionStartProcessInstanceByIdAndTenantId(); + } + + Command command; + + if (modificationBuilder.getModificationOperations().isEmpty()) { + + if(skipCustomListeners || skipIoMappings) { + throw LOG.exceptionStartProcessInstanceAtStartActivityAndSkipListenersOrMapping(); + } + // start at the default start activity + command = new StartProcessInstanceCmd(this); + + } else { + // start at any activity using the instructions + modificationBuilder.setSkipCustomListeners(skipCustomListeners); + modificationBuilder.setSkipIoMappings(skipIoMappings); + + command = new StartProcessInstanceAtActivitiesCmd(this); + } + + return commandExecutor.execute(command); + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public ProcessInstanceModificationBuilderImpl getModificationBuilder() { + return modificationBuilder; + } + + public String getBusinessKey() { + return businessKey; + } + + public String getCaseInstanceId() { + return caseInstanceId; + } + + public Map getVariables() { + return modificationBuilder.getProcessVariables(); + } + + public String getTenantId() { + return tenantId; + } + + public String getProcessDefinitionTenantId() { + return processDefinitionTenantId; + } + + public boolean isProcessDefinitionTenantIdSet() { + return isProcessDefinitionTenantIdSet; + } + + public void setModificationBuilder(ProcessInstanceModificationBuilderImpl modificationBuilder) { + this.modificationBuilder = modificationBuilder; + } + + public void setRestartedProcessInstanceId(String restartedProcessInstanceId){ + this.restartedProcessInstanceId = restartedProcessInstanceId; + } + + public String getRestartedProcessInstanceId(){ + return restartedProcessInstanceId; + } + + public static ProcessInstantiationBuilder createProcessInstanceById(CommandExecutor commandExecutor, String processDefinitionId) { + ProcessInstantiationBuilderImpl builder = new ProcessInstantiationBuilderImpl(commandExecutor); + builder.processDefinitionId = processDefinitionId; + return builder; + } + + public static ProcessInstantiationBuilder createProcessInstanceByKey(CommandExecutor commandExecutor, String processDefinitionKey) { + ProcessInstantiationBuilderImpl builder = new ProcessInstantiationBuilderImpl(commandExecutor); + builder.processDefinitionKey = processDefinitionKey; + return builder; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryEntityRelationCondition.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryEntityRelationCondition.java new file mode 100644 index 0000000000000000000000000000000000000000..733b6af639e46d1b59f824d322c8872a4e990871 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryEntityRelationCondition.java @@ -0,0 +1,76 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * Specifies a condition by which two entity types can be related. + * comparisonProperty and scalarValue + * are exclusive, i.e. one of the should be null. + * + * @author Thorben Lindhauer + */ +public class QueryEntityRelationCondition { + + protected QueryProperty property; + protected QueryProperty comparisonProperty; + protected Object scalarValue; + + public QueryEntityRelationCondition(QueryProperty queryProperty, Object scalarValue) { + this(queryProperty, null, scalarValue); + } + + public QueryEntityRelationCondition(QueryProperty queryProperty, QueryProperty comparisonProperty) { + this(queryProperty, comparisonProperty, null); + } + + public QueryEntityRelationCondition(QueryProperty queryProperty, QueryProperty comparisonProperty, + Object scalarValue) { + this.property = queryProperty; + this.comparisonProperty = comparisonProperty; + this.scalarValue = scalarValue; + } + + public QueryProperty getProperty() { + return property; + } + + public QueryProperty getComparisonProperty() { + return comparisonProperty; + } + + public Object getScalarValue() { + return scalarValue; + } + + /** + * This assumes that scalarValue and comparisonProperty are mutually exclusive. + * Either a condition is expressed is by a scalar value, or with a property of another entity. + */ + public boolean isPropertyComparison() { + return comparisonProperty != null; + } + + public String toString() { + return "QueryEntityRelationCondition[" + + "property=" + property + + ", comparisonProperty=" + comparisonProperty + + ", scalarValue=" + scalarValue + + "]"; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryOperator.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryOperator.java new file mode 100644 index 0000000000000000000000000000000000000000..7d2c60d3eedc79ae80815c9478d94e5e583e2ca8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryOperator.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + + +/** + * Used to indicate the operator that should be used to comparing values in a query clause. + * + * @author Frederik Heremans + */ +public enum QueryOperator { + EQUALS, + NOT_EQUALS, + GREATER_THAN, + GREATER_THAN_OR_EQUAL, + LESS_THAN, + LESS_THAN_OR_EQUAL, + LIKE, + NOT_LIKE +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryOrderingProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryOrderingProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..e1b2cce4ad919fc28a5869b5c6354783bc1de0d0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryOrderingProperty.java @@ -0,0 +1,152 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.io.Serializable; +import java.util.List; + +import org.camunda.bpm.engine.query.QueryProperty; +import org.camunda.bpm.engine.runtime.VariableInstance; +import org.camunda.bpm.engine.task.Task; +import org.camunda.bpm.engine.task.TaskQuery; + +/** + *

A QueryOrderingProperty specifies a condition by which the results of a query should be + * sorted. It can either specify a sorting by a property of the entities to be selected or + * a sorting by a property of a related entity. For example in a {@link TaskQuery}, + * the entity to be selected is {@link Task} while a related entity could be a + * {@link VariableInstance}.

+ * + *

It is made up of the following:

+ * + *

+ *

+ *
relation
+ *
A symbolic name that identifies a related entity. null if + * an ordering over a property of the entity to be selected is expressed.
+ *
queryProperty
+ *
The property to be sorted on. An instance of {@link QueryProperty}.
+ *
direction
+ *
The ordering direction, refer to {@link Direction}
+ *
relationConditions
+ *
A list of constraints that describe the nature of the relation to another entity + * (or in SQL terms, the joining conditions). Is null if relation + * is null. Contains instances of {@link QueryEntityRelationCondition}.
+ *
+ *

+ * + * @author Thorben Lindhauer + */ +public class QueryOrderingProperty implements Serializable { + + public static final String RELATION_VARIABLE = "variable"; + public static final String RELATION_PROCESS_DEFINITION = "process-definition"; + public static final String RELATION_CASE_DEFINITION = "case-definition"; + public static final String RELATION_DEPLOYMENT = "deployment"; + + protected static final long serialVersionUID = 1L; + + protected String relation; + protected QueryProperty queryProperty; + protected Direction direction; + protected List relationConditions; + + public QueryOrderingProperty() { + } + + public QueryOrderingProperty(QueryProperty queryProperty, Direction direction) { + this.queryProperty = queryProperty; + this.direction = direction; + } + + public QueryOrderingProperty(String relation, QueryProperty queryProperty) { + this.relation = relation; + this.queryProperty = queryProperty; + } + + public QueryProperty getQueryProperty() { + return queryProperty; + } + + public void setQueryProperty(QueryProperty queryProperty) { + this.queryProperty = queryProperty; + } + + public void setDirection(Direction direction) { + this.direction = direction; + } + + public Direction getDirection() { + return direction; + } + + public List getRelationConditions() { + return relationConditions; + } + + public void setRelationConditions(List relationConditions) { + this.relationConditions = relationConditions; + } + + public boolean hasRelationConditions() { + return relationConditions != null && !relationConditions.isEmpty(); + } + + public String getRelation() { + return relation; + } + + public void setRelation(String relation) { + this.relation = relation; + } + + /** + * @return whether this ordering property is contained in the default fields + * of the base entity (e.g. task.NAME_ is a contained property; LOWER(task.NAME_) or + * variable.TEXT_ (given a task query) is not contained) + */ + public boolean isContainedProperty() { + return relation == null && queryProperty.getFunction() == null; + } + + @Override + public String toString() { + + return "QueryOrderingProperty[" + + "relation=" + relation + + ", queryProperty=" + queryProperty + + ", direction=" + direction + + ", relationConditions=" + getRelationConditionsString() + + "]"; + } + + public String getRelationConditionsString() { + StringBuilder builder = new StringBuilder(); + builder.append("["); + if(relationConditions != null) { + for (int i = 0; i < relationConditions.size(); i++) { + if (i > 0) { + builder.append(","); + } + builder.append(relationConditions.get(i)); + } + } + builder.append("]"); + return builder.toString(); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryPropertyImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryPropertyImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..2ed5cab9e0757870ff0358da6bc98328f78da8ae --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryPropertyImpl.java @@ -0,0 +1,87 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * + * @author Thorben Lindhauer + * + */ +public class QueryPropertyImpl implements QueryProperty { + + private static final long serialVersionUID = 1L; + + protected String name; + + protected String function; + + public QueryPropertyImpl(String name) { + this(name, null); + } + + public QueryPropertyImpl(String name, String function) { + this.name = name; + this.function = function; + } + + public String getName() { + return name; + } + + public String getFunction() { + return function; + } + + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((function == null) ? 0 : function.hashCode()); + result = prime * result + ((name == null) ? 0 : name.hashCode()); + return result; + } + + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + QueryPropertyImpl other = (QueryPropertyImpl) obj; + if (function == null) { + if (other.function != null) + return false; + } else if (!function.equals(other.function)) + return false; + if (name == null) { + if (other.name != null) + return false; + } else if (!name.equals(other.name)) + return false; + return true; + } + + public String toString() { + return "QueryProperty[" + + "name=" + name + + ", function=" + function + + "]"; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryValidators.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryValidators.java new file mode 100644 index 0000000000000000000000000000000000000000..32363895bfebdc7aa044b088b7043033c28b1bc5 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryValidators.java @@ -0,0 +1,75 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.impl.context.Context; + +/** + * @author Thorben Lindhauer + * + */ +public class QueryValidators { + + public static class AdhocQueryValidator> implements Validator { + + @SuppressWarnings("rawtypes") + public static final AdhocQueryValidator INSTANCE = new AdhocQueryValidator(); + + private AdhocQueryValidator() { + } + + @Override + public void validate(T query) { + if (!Context.getProcessEngineConfiguration().isEnableExpressionsInAdhocQueries() && + !query.getExpressions().isEmpty()) { + throw new BadUserRequestException("Expressions are forbidden in adhoc queries. This behavior can be toggled" + + " in the process engine configuration"); + } + } + + @SuppressWarnings("unchecked") + public static > AdhocQueryValidator get() { + return (AdhocQueryValidator) INSTANCE; + } + + } + + public static class StoredQueryValidator> implements Validator { + + @SuppressWarnings("rawtypes") + public static final StoredQueryValidator INSTANCE = new StoredQueryValidator(); + + private StoredQueryValidator() { + } + + @Override + public void validate(T query) { + if (!Context.getProcessEngineConfiguration().isEnableExpressionsInStoredQueries() && + !query.getExpressions().isEmpty()) { + throw new BadUserRequestException("Expressions are forbidden in stored queries. This behavior can be toggled" + + " in the process engine configuration"); + } + } + + @SuppressWarnings("unchecked") + public static > StoredQueryValidator get() { + return (StoredQueryValidator) INSTANCE; + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryVariableValue.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryVariableValue.java new file mode 100644 index 0000000000000000000000000000000000000000..2bd64d3cf09dcff98a3c66e537d58a94bd934f06 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/QueryVariableValue.java @@ -0,0 +1,133 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.io.Serializable; +import java.util.List; +import java.util.Objects; + +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; +import org.camunda.bpm.engine.variable.Variables; +import org.camunda.bpm.engine.variable.value.TypedValue; + + +/** + * Represents a variable value used in queries. + * + * @author Frederik Heremans + */ +public class QueryVariableValue implements Serializable { + protected static final long serialVersionUID = 1L; + protected String name; + protected TypedValue value; + protected QueryOperator operator; + protected boolean local; + + protected AbstractQueryVariableValueCondition valueCondition; + + protected boolean variableNameIgnoreCase; + protected boolean variableValueIgnoreCase; + + public QueryVariableValue(String name, Object value, QueryOperator operator, boolean local) { + this(name, value, operator, local, false, false); + } + + public QueryVariableValue(String name, Object value, QueryOperator operator, boolean local, boolean variableNameIgnoreCase, boolean variableValueIgnoreCase) { + this.name = name; + this.value = Variables.untypedValue(value); + this.operator = operator; + this.local = local; + this.variableNameIgnoreCase = variableNameIgnoreCase; + this.variableValueIgnoreCase = variableValueIgnoreCase; + } + + public void initialize(VariableSerializers serializers, String dbType) { + if (value.getType() != null && value.getType().isAbstract()) { + valueCondition = new CompositeQueryVariableValueCondition(this); + } else { + valueCondition = new SingleQueryVariableValueCondition(this); + } + + valueCondition.initializeValue(serializers, dbType); + } + + public List getValueConditions() { + return valueCondition.getDisjunctiveConditions(); + } + + public String getName() { + return name; + } + + public QueryOperator getOperator() { + if(operator != null) { + return operator; + } + return QueryOperator.EQUALS; + } + + public String getOperatorName() { + return getOperator().toString(); + } + + public Object getValue() { + return value.getValue(); + } + + public TypedValue getTypedValue() { + return value; + } + + public boolean isLocal() { + return local; + } + + + public boolean isVariableNameIgnoreCase() { + return variableNameIgnoreCase; + } + + public void setVariableNameIgnoreCase(boolean variableNameIgnoreCase) { + this.variableNameIgnoreCase = variableNameIgnoreCase; + } + + public boolean isVariableValueIgnoreCase() { + return variableValueIgnoreCase; + } + + public void setVariableValueIgnoreCase(boolean variableValueIgnoreCase) { + this.variableValueIgnoreCase = variableValueIgnoreCase; + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + QueryVariableValue that = (QueryVariableValue) o; + return local == that.local && variableNameIgnoreCase == that.variableNameIgnoreCase + && variableValueIgnoreCase == that.variableValueIgnoreCase && name.equals(that.name) && value.equals(that.value) + && operator == that.operator && Objects.equals(valueCondition, that.valueCondition); + } + + @Override + public int hashCode() { + return Objects.hash(name, value, operator, local, valueCondition, variableNameIgnoreCase, variableValueIgnoreCase); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RepositoryServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RepositoryServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..881d2a72c9ae0c07b2855398ca5b96b2c4e2a136 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RepositoryServiceImpl.java @@ -0,0 +1,444 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.io.InputStream; +import java.nio.charset.Charset; +import java.util.Collection; +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.application.ProcessApplicationReference; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.exception.DeploymentResourceNotFoundException; +import org.camunda.bpm.engine.exception.NotFoundException; +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.exception.NullValueException; +import org.camunda.bpm.engine.exception.cmmn.CaseDefinitionNotFoundException; +import org.camunda.bpm.engine.exception.cmmn.CmmnModelInstanceNotFoundException; +import org.camunda.bpm.engine.exception.dmn.DecisionDefinitionNotFoundException; +import org.camunda.bpm.engine.exception.dmn.DmnModelInstanceNotFoundException; +import org.camunda.bpm.engine.impl.cmd.AddIdentityLinkForProcessDefinitionCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteDeploymentCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteIdentityLinkForProcessDefinitionCmd; +import org.camunda.bpm.engine.impl.cmd.DeployCmd; +import org.camunda.bpm.engine.impl.cmd.GetDeployedProcessDefinitionCmd; +import org.camunda.bpm.engine.impl.cmd.GetDeploymentBpmnModelInstanceCmd; +import org.camunda.bpm.engine.impl.cmd.GetDeploymentProcessDiagramCmd; +import org.camunda.bpm.engine.impl.cmd.GetDeploymentProcessDiagramLayoutCmd; +import org.camunda.bpm.engine.impl.cmd.GetDeploymentProcessModelCmd; +import org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceCmd; +import org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceForIdCmd; +import org.camunda.bpm.engine.impl.cmd.GetDeploymentResourceNamesCmd; +import org.camunda.bpm.engine.impl.cmd.GetDeploymentResourcesCmd; +import org.camunda.bpm.engine.impl.cmd.GetIdentityLinksForProcessDefinitionCmd; +import org.camunda.bpm.engine.impl.cmd.GetStaticCalledProcessDefinitionCmd; +import org.camunda.bpm.engine.impl.cmd.UpdateDecisionDefinitionHistoryTimeToLiveCmd; +import org.camunda.bpm.engine.impl.cmd.UpdateProcessDefinitionHistoryTimeToLiveCmd; +import org.camunda.bpm.engine.impl.cmmn.cmd.GetDeploymentCaseDefinitionCmd; +import org.camunda.bpm.engine.impl.cmmn.cmd.GetDeploymentCaseDiagramCmd; +import org.camunda.bpm.engine.impl.cmmn.cmd.GetDeploymentCaseModelCmd; +import org.camunda.bpm.engine.impl.cmmn.cmd.GetDeploymentCmmnModelInstanceCmd; +import org.camunda.bpm.engine.impl.cmmn.cmd.UpdateCaseDefinitionHistoryTimeToLiveCmd; +import org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionQueryImpl; +import org.camunda.bpm.engine.impl.dmn.cmd.GetDeploymentDecisionDefinitionCmd; +import org.camunda.bpm.engine.impl.dmn.cmd.GetDeploymentDecisionDiagramCmd; +import org.camunda.bpm.engine.impl.dmn.cmd.GetDeploymentDecisionModelCmd; +import org.camunda.bpm.engine.impl.dmn.cmd.GetDeploymentDecisionRequirementsDefinitionCmd; +import org.camunda.bpm.engine.impl.dmn.cmd.GetDeploymentDecisionRequirementsDiagramCmd; +import org.camunda.bpm.engine.impl.dmn.cmd.GetDeploymentDecisionRequirementsModelCmd; +import org.camunda.bpm.engine.impl.dmn.cmd.GetDeploymentDmnModelInstanceCmd; +import org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionQueryImpl; +import org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionRequirementsDefinitionQueryImpl; +import org.camunda.bpm.engine.impl.pvm.ReadOnlyProcessDefinition; +import org.camunda.bpm.engine.impl.repository.DeleteProcessDefinitionsBuilderImpl; +import org.camunda.bpm.engine.impl.repository.DeploymentBuilderImpl; +import org.camunda.bpm.engine.impl.repository.ProcessApplicationDeploymentBuilderImpl; +import org.camunda.bpm.engine.impl.repository.UpdateProcessDefinitionSuspensionStateBuilderImpl; +import org.camunda.bpm.engine.repository.*; +import org.camunda.bpm.engine.task.IdentityLink; +import org.camunda.bpm.model.bpmn.BpmnModelInstance; +import org.camunda.bpm.model.cmmn.CmmnModelInstance; +import org.camunda.bpm.model.dmn.DmnModelInstance; + +/** + * @author Tom Baeyens + * @author Falko Menge + * @author Joram Barrez + */ +public class RepositoryServiceImpl extends ServiceImpl implements RepositoryService { + + protected Charset deploymentCharset; + + public Charset getDeploymentCharset() { + return deploymentCharset; + } + + public void setDeploymentCharset(Charset deploymentCharset) { + this.deploymentCharset = deploymentCharset; + } + + public DeploymentBuilder createDeployment() { + return new DeploymentBuilderImpl(this); + } + + public ProcessApplicationDeploymentBuilder createDeployment(ProcessApplicationReference processApplication) { + return new ProcessApplicationDeploymentBuilderImpl(this, processApplication); + } + + public DeploymentWithDefinitions deployWithResult(DeploymentBuilderImpl deploymentBuilder) { + return commandExecutor.execute(new DeployCmd(deploymentBuilder)); + } + + public void deleteDeployment(String deploymentId) { + commandExecutor.execute(new DeleteDeploymentCmd(deploymentId, false, false, false)); + } + + public void deleteDeploymentCascade(String deploymentId) { + commandExecutor.execute(new DeleteDeploymentCmd(deploymentId, true, false, false)); + } + + public void deleteDeployment(String deploymentId, boolean cascade) { + commandExecutor.execute(new DeleteDeploymentCmd(deploymentId, cascade, false, false)); + } + + public void deleteDeployment(String deploymentId, boolean cascade, boolean skipCustomListeners) { + commandExecutor.execute(new DeleteDeploymentCmd(deploymentId, cascade, skipCustomListeners, false)); + } + + @Override + public void deleteDeployment(String deploymentId, boolean cascade, boolean skipCustomListeners, boolean skipIoMappings) { + commandExecutor.execute(new DeleteDeploymentCmd(deploymentId, cascade, skipCustomListeners, skipIoMappings)); + } + + @Override + public void deleteProcessDefinition(String processDefinitionId) { + deleteProcessDefinition(processDefinitionId, false); + } + + @Override + public void deleteProcessDefinition(String processDefinitionId, boolean cascade) { + deleteProcessDefinition(processDefinitionId, cascade, false); + } + + @Override + public void deleteProcessDefinition(String processDefinitionId, boolean cascade, boolean skipCustomListeners) { + deleteProcessDefinition(processDefinitionId, cascade, skipCustomListeners, false); + } + + @Override + public void deleteProcessDefinition(String processDefinitionId, boolean cascade, boolean skipCustomListeners, boolean skipIoMappings) { + DeleteProcessDefinitionsBuilder builder = deleteProcessDefinitions().byIds(processDefinitionId); + + if (cascade) { + builder.cascade(); + } + + if (skipCustomListeners) { + builder.skipCustomListeners(); + } + + if (skipIoMappings) { + builder.skipIoMappings(); + } + + builder.delete(); + } + + @Override + public DeleteProcessDefinitionsSelectBuilder deleteProcessDefinitions() { + return new DeleteProcessDefinitionsBuilderImpl(commandExecutor); + } + + public ProcessDefinitionQuery createProcessDefinitionQuery() { + return new ProcessDefinitionQueryImpl(commandExecutor); + } + + public CaseDefinitionQuery createCaseDefinitionQuery() { + return new CaseDefinitionQueryImpl(commandExecutor); + } + + public DecisionDefinitionQuery createDecisionDefinitionQuery() { + return new DecisionDefinitionQueryImpl(commandExecutor); + } + + public DecisionRequirementsDefinitionQuery createDecisionRequirementsDefinitionQuery() { + return new DecisionRequirementsDefinitionQueryImpl(commandExecutor); + } + + @SuppressWarnings("unchecked") + public List getDeploymentResourceNames(String deploymentId) { + return commandExecutor.execute(new GetDeploymentResourceNamesCmd(deploymentId)); + } + + @SuppressWarnings("unchecked") + public List getDeploymentResources(String deploymentId) { + return commandExecutor.execute(new GetDeploymentResourcesCmd(deploymentId)); + } + + public InputStream getResourceAsStream(String deploymentId, String resourceName) { + return commandExecutor.execute(new GetDeploymentResourceCmd(deploymentId, resourceName)); + } + + public InputStream getResourceAsStreamById(String deploymentId, String resourceId) { + return commandExecutor.execute(new GetDeploymentResourceForIdCmd(deploymentId, resourceId)); + } + + public DeploymentQuery createDeploymentQuery() { + return new DeploymentQueryImpl(commandExecutor); + } + + public ProcessDefinition getProcessDefinition(String processDefinitionId) { + return commandExecutor.execute(new GetDeployedProcessDefinitionCmd(processDefinitionId, true)); + } + + public ReadOnlyProcessDefinition getDeployedProcessDefinition(String processDefinitionId) { + return commandExecutor.execute(new GetDeployedProcessDefinitionCmd(processDefinitionId, true)); + } + + public void suspendProcessDefinitionById(String processDefinitionId) { + updateProcessDefinitionSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .suspend(); + } + + public void suspendProcessDefinitionById(String processDefinitionId, boolean suspendProcessInstances, Date suspensionDate) { + updateProcessDefinitionSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .includeProcessInstances(suspendProcessInstances) + .executionDate(suspensionDate) + .suspend(); + } + + public void suspendProcessDefinitionByKey(String processDefinitionKey) { + updateProcessDefinitionSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .suspend(); + } + + public void suspendProcessDefinitionByKey(String processDefinitionKey, boolean suspendProcessInstances, Date suspensionDate) { + updateProcessDefinitionSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .includeProcessInstances(suspendProcessInstances) + .executionDate(suspensionDate) + .suspend(); + } + + public void activateProcessDefinitionById(String processDefinitionId) { + updateProcessDefinitionSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .activate(); + } + + public void activateProcessDefinitionById(String processDefinitionId, boolean activateProcessInstances, Date activationDate) { + updateProcessDefinitionSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .includeProcessInstances(activateProcessInstances) + .executionDate(activationDate) + .activate(); + } + + public void activateProcessDefinitionByKey(String processDefinitionKey) { + updateProcessDefinitionSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .activate(); + } + + public void activateProcessDefinitionByKey(String processDefinitionKey, boolean activateProcessInstances, Date activationDate) { + updateProcessDefinitionSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .includeProcessInstances(activateProcessInstances) + .executionDate(activationDate) + .activate(); + } + + public UpdateProcessDefinitionSuspensionStateSelectBuilder updateProcessDefinitionSuspensionState() { + return new UpdateProcessDefinitionSuspensionStateBuilderImpl(commandExecutor); + } + + public void updateProcessDefinitionHistoryTimeToLive(String processDefinitionId, Integer historyTimeToLive){ + commandExecutor.execute(new UpdateProcessDefinitionHistoryTimeToLiveCmd(processDefinitionId, historyTimeToLive)); + } + + public void updateDecisionDefinitionHistoryTimeToLive(String decisionDefinitionId, Integer historyTimeToLive){ + commandExecutor.execute(new UpdateDecisionDefinitionHistoryTimeToLiveCmd(decisionDefinitionId, historyTimeToLive)); + } + + public void updateCaseDefinitionHistoryTimeToLive(String caseDefinitionId, Integer historyTimeToLive){ + commandExecutor.execute(new UpdateCaseDefinitionHistoryTimeToLiveCmd(caseDefinitionId, historyTimeToLive)); + } + + public InputStream getProcessModel(String processDefinitionId) { + return commandExecutor.execute(new GetDeploymentProcessModelCmd(processDefinitionId)); + } + + public InputStream getProcessDiagram(String processDefinitionId) { + return commandExecutor.execute(new GetDeploymentProcessDiagramCmd(processDefinitionId)); + } + + public InputStream getCaseDiagram(String caseDefinitionId) { + return commandExecutor.execute(new GetDeploymentCaseDiagramCmd(caseDefinitionId)); + } + + public DiagramLayout getProcessDiagramLayout(String processDefinitionId) { + return commandExecutor.execute(new GetDeploymentProcessDiagramLayoutCmd(processDefinitionId)); + } + + public BpmnModelInstance getBpmnModelInstance(String processDefinitionId) { + return commandExecutor.execute(new GetDeploymentBpmnModelInstanceCmd(processDefinitionId)); + } + + public CmmnModelInstance getCmmnModelInstance(String caseDefinitionId) { + try { + return commandExecutor.execute(new GetDeploymentCmmnModelInstanceCmd(caseDefinitionId)); + + } catch (NullValueException e) { + throw new NotValidException(e.getMessage(), e); + + } catch (CmmnModelInstanceNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + + } catch (DeploymentResourceNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + + } + } + + public DmnModelInstance getDmnModelInstance(String decisionDefinitionId) { + try { + return commandExecutor.execute(new GetDeploymentDmnModelInstanceCmd(decisionDefinitionId)); + + } catch (NullValueException e) { + throw new NotValidException(e.getMessage(), e); + + } catch (DmnModelInstanceNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + + } catch (DeploymentResourceNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + + } + } + + public void addCandidateStarterUser(String processDefinitionId, String userId) { + commandExecutor.execute(new AddIdentityLinkForProcessDefinitionCmd(processDefinitionId, userId, null)); + } + + public void addCandidateStarterGroup(String processDefinitionId, String groupId) { + commandExecutor.execute(new AddIdentityLinkForProcessDefinitionCmd(processDefinitionId, null, groupId)); + } + + public void deleteCandidateStarterGroup(String processDefinitionId, String groupId) { + commandExecutor.execute(new DeleteIdentityLinkForProcessDefinitionCmd(processDefinitionId, null, groupId)); + } + + public void deleteCandidateStarterUser(String processDefinitionId, String userId) { + commandExecutor.execute(new DeleteIdentityLinkForProcessDefinitionCmd(processDefinitionId, userId, null)); + } + + public List getIdentityLinksForProcessDefinition(String processDefinitionId) { + return commandExecutor.execute(new GetIdentityLinksForProcessDefinitionCmd(processDefinitionId)); + } + + public CaseDefinition getCaseDefinition(String caseDefinitionId) { + try { + return commandExecutor.execute(new GetDeploymentCaseDefinitionCmd(caseDefinitionId)); + + } catch (NullValueException e) { + throw new NotValidException(e.getMessage(), e); + + } catch (CaseDefinitionNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + + } + } + + public InputStream getCaseModel(String caseDefinitionId) { + try { + return commandExecutor.execute(new GetDeploymentCaseModelCmd(caseDefinitionId)); + + } catch (NullValueException e) { + throw new NotValidException(e.getMessage(), e); + + } catch (CaseDefinitionNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + + } catch (DeploymentResourceNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + + } + + } + + public DecisionDefinition getDecisionDefinition(String decisionDefinitionId) { + try { + return commandExecutor.execute(new GetDeploymentDecisionDefinitionCmd(decisionDefinitionId)); + } catch (NullValueException e) { + throw new NotValidException(e.getMessage(), e); + } catch (DecisionDefinitionNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + } + } + + public DecisionRequirementsDefinition getDecisionRequirementsDefinition(String decisionRequirementsDefinitionId) { + try { + return commandExecutor.execute(new GetDeploymentDecisionRequirementsDefinitionCmd(decisionRequirementsDefinitionId)); + } catch (NullValueException e) { + throw new NotValidException(e.getMessage(), e); + } catch (DecisionDefinitionNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + } + } + + public InputStream getDecisionModel(String decisionDefinitionId) { + try { + return commandExecutor.execute(new GetDeploymentDecisionModelCmd(decisionDefinitionId)); + } catch (NullValueException e) { + throw new NotValidException(e.getMessage(), e); + } catch (DecisionDefinitionNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + } catch (DeploymentResourceNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + } + } + + public InputStream getDecisionRequirementsModel(String decisionRequirementsDefinitionId) { + try { + return commandExecutor.execute(new GetDeploymentDecisionRequirementsModelCmd(decisionRequirementsDefinitionId)); + } catch (NullValueException e) { + throw new NotValidException(e.getMessage(), e); + } catch (DecisionDefinitionNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + } catch (DeploymentResourceNotFoundException e) { + throw new NotFoundException(e.getMessage(), e); + } + } + + public InputStream getDecisionDiagram(String decisionDefinitionId) { + return commandExecutor.execute(new GetDeploymentDecisionDiagramCmd(decisionDefinitionId)); + } + + public InputStream getDecisionRequirementsDiagram(String decisionRequirementsDefinitionId) { + return commandExecutor.execute(new GetDeploymentDecisionRequirementsDiagramCmd(decisionRequirementsDefinitionId)); + } + + @Override + public Collection getStaticCalledProcessDefinitions(String processDefinitionId) { + return commandExecutor.execute(new GetStaticCalledProcessDefinitionCmd(processDefinitionId)); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstanceBuilderImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstanceBuilderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..0776cbb20c902a4bdc8c502fe07b342700723a42 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstanceBuilderImpl.java @@ -0,0 +1,174 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; +import org.camunda.bpm.engine.impl.batch.RestartProcessInstancesBatchCmd; +import org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand; +import org.camunda.bpm.engine.impl.cmd.ActivityAfterInstantiationCmd; +import org.camunda.bpm.engine.impl.cmd.ActivityBeforeInstantiationCmd; +import org.camunda.bpm.engine.impl.cmd.RestartProcessInstancesCmd; +import org.camunda.bpm.engine.impl.cmd.TransitionInstantiationCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.RestartProcessInstanceBuilder; + +/** + * @author Anna Pazola + */ +public class RestartProcessInstanceBuilderImpl implements RestartProcessInstanceBuilder { + + protected CommandExecutor commandExecutor; + protected List processInstanceIds; + protected List instructions; + protected String processDefinitionId; + protected HistoricProcessInstanceQuery query; + protected boolean initialVariables; + protected boolean skipCustomListeners; + protected boolean skipIoMappings; + protected boolean withoutBusinessKey; + + public RestartProcessInstanceBuilderImpl(CommandExecutor commandExecutor, String processDefinitionId) { + ensureNotNull(NotValidException.class, "processDefinitionId", processDefinitionId); + this.commandExecutor = commandExecutor; + this.instructions = new ArrayList(); + this.processDefinitionId = processDefinitionId; + this.processInstanceIds = new ArrayList(); + } + + public RestartProcessInstanceBuilderImpl(String processDefinitionId) { + this(null, processDefinitionId); + } + + @Override + public RestartProcessInstanceBuilder startBeforeActivity(String activityId) { + ensureNotNull(NotValidException.class, "activityId", activityId); + instructions.add(new ActivityBeforeInstantiationCmd(null, activityId)); + return this; + } + + @Override + public RestartProcessInstanceBuilder startAfterActivity(String activityId) { + ensureNotNull(NotValidException.class, "activityId", activityId); + instructions.add(new ActivityAfterInstantiationCmd(null, activityId)); + return this; + } + + @Override + public RestartProcessInstanceBuilder startTransition(String transitionId) { + ensureNotNull(NotValidException.class, "activityId", transitionId); + instructions.add(new TransitionInstantiationCmd(null, transitionId)); + return this; + } + + public void execute() { + commandExecutor.execute(new RestartProcessInstancesCmd(commandExecutor, this)); + } + + public Batch executeAsync() { + return commandExecutor.execute(new RestartProcessInstancesBatchCmd(commandExecutor, this)); + } + + public List getInstructions() { + return instructions; + } + + public List getProcessInstanceIds() { + return processInstanceIds; + } + + @Override + public RestartProcessInstanceBuilder processInstanceIds(String... processInstanceIds) { + this.processInstanceIds.addAll(Arrays.asList(processInstanceIds)); + return this; + } + + @Override + public RestartProcessInstanceBuilder historicProcessInstanceQuery(HistoricProcessInstanceQuery query) { + this.query = query; + return this; + } + + public HistoricProcessInstanceQuery getHistoricProcessInstanceQuery() { + return query; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public void setInstructions(List instructions) { + this.instructions = instructions; + } + + public void setProcessDefinitionId(String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + } + + @Override + public RestartProcessInstanceBuilder processInstanceIds(List processInstanceIds) { + this.processInstanceIds.addAll(processInstanceIds); + return this; + } + + @Override + public RestartProcessInstanceBuilder initialSetOfVariables() { + this.initialVariables = true; + return this; + } + + public boolean isInitialVariables() { + return initialVariables; + } + + @Override + public RestartProcessInstanceBuilder skipCustomListeners() { + this.skipCustomListeners = true; + return this; + } + + @Override + public RestartProcessInstanceBuilder skipIoMappings() { + this.skipIoMappings = true; + return this; + } + + public boolean isSkipCustomListeners() { + return skipCustomListeners; + } + + public boolean isSkipIoMappings() { + return skipIoMappings; + } + + @Override + public RestartProcessInstanceBuilder withoutBusinessKey() { + withoutBusinessKey = true; + return this; + } + + public boolean isWithoutBusinessKey() { + return withoutBusinessKey; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesBatchConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesBatchConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..4ddb307d04d83682745b410d0d6bed99e24dff1b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesBatchConfiguration.java @@ -0,0 +1,104 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; +import org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand; + +/** + * + * @author Anna Pazola + * + */ +public class RestartProcessInstancesBatchConfiguration extends BatchConfiguration { + + protected List instructions; + protected String processDefinitionId; + protected boolean initialVariables; + protected boolean skipCustomListeners; + protected boolean skipIoMappings; + protected boolean withoutBusinessKey; + + public RestartProcessInstancesBatchConfiguration(List processInstanceIds, + List instructions, String processDefinitionId, + boolean initialVariables, boolean skipCustomListeners, boolean skipIoMappings, boolean withoutBusinessKey) { + this(processInstanceIds, null, instructions, processDefinitionId, initialVariables, skipCustomListeners, skipIoMappings, withoutBusinessKey); + } + + public RestartProcessInstancesBatchConfiguration(List processInstanceIds, DeploymentMappings mappings, + List instructions, String processDefinitionId, + boolean initialVariables, boolean skipCustomListeners, boolean skipIoMappings, boolean withoutBusinessKey) { + super(processInstanceIds, mappings); + this.instructions = instructions; + this.processDefinitionId = processDefinitionId; + this.initialVariables = initialVariables; + this.skipCustomListeners = skipCustomListeners; + this.skipIoMappings = skipIoMappings; + this.withoutBusinessKey = withoutBusinessKey; + } + + public List getInstructions() { + return instructions; + } + + public void setInstructions(List instructions) { + this.instructions = instructions; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public void setProcessDefinitionId(String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + } + + public boolean isInitialVariables() { + return initialVariables; + } + + public void setInitialVariables(boolean initialVariables) { + this.initialVariables = initialVariables; + } + + public boolean isSkipCustomListeners() { + return skipCustomListeners; + } + + public void setSkipCustomListeners(boolean skipCustomListeners) { + this.skipCustomListeners = skipCustomListeners; + } + + public boolean isSkipIoMappings() { + return skipIoMappings; + } + + public void setSkipIoMappings(boolean skipIoMappings) { + this.skipIoMappings = skipIoMappings; + } + + public boolean isWithoutBusinessKey() { + return withoutBusinessKey; + } + + public void setWithoutBusinessKey(boolean withoutBusinessKey) { + this.withoutBusinessKey = withoutBusinessKey; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesBatchConfigurationJsonConverter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesBatchConfigurationJsonConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..e2298921b1584de37063489d4b07f640d6ed8f3f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesBatchConfigurationJsonConverter.java @@ -0,0 +1,78 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.AbstractBatchConfigurationObjectConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappingJsonConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; +import org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand; +import org.camunda.bpm.engine.impl.json.ModificationCmdJsonConverter; +import org.camunda.bpm.engine.impl.util.JsonUtil; +import com.google.gson.JsonObject; + +public class RestartProcessInstancesBatchConfigurationJsonConverter + extends AbstractBatchConfigurationObjectConverter { + + public static final RestartProcessInstancesBatchConfigurationJsonConverter INSTANCE = new RestartProcessInstancesBatchConfigurationJsonConverter(); + + public static final String PROCESS_INSTANCE_IDS = "processInstanceIds"; + public static final String PROCESS_INSTANCE_ID_MAPPINGS = "processInstanceIdMappings"; + public static final String INSTRUCTIONS = "instructions"; + public static final String PROCESS_DEFINITION_ID = "processDefinitionId"; + public static final String INITIAL_VARIABLES = "initialVariables"; + public static final String SKIP_CUSTOM_LISTENERS = "skipCustomListeners"; + public static final String SKIP_IO_MAPPINGS = "skipIoMappings"; + public static final String WITHOUT_BUSINESS_KEY = "withoutBusinessKey"; + + @Override + public JsonObject writeConfiguration(RestartProcessInstancesBatchConfiguration configuration) { + JsonObject json = JsonUtil.createObject(); + + JsonUtil.addListField(json, PROCESS_INSTANCE_IDS, configuration.getIds()); + JsonUtil.addListField(json, PROCESS_INSTANCE_ID_MAPPINGS, DeploymentMappingJsonConverter.INSTANCE, configuration.getIdMappings()); + JsonUtil.addField(json, PROCESS_DEFINITION_ID, configuration.getProcessDefinitionId()); + JsonUtil.addListField(json, INSTRUCTIONS, ModificationCmdJsonConverter.INSTANCE, configuration.getInstructions()); + JsonUtil.addField(json, INITIAL_VARIABLES, configuration.isInitialVariables()); + JsonUtil.addField(json, SKIP_CUSTOM_LISTENERS, configuration.isSkipCustomListeners()); + JsonUtil.addField(json, SKIP_IO_MAPPINGS, configuration.isSkipIoMappings()); + JsonUtil.addField(json, WITHOUT_BUSINESS_KEY, configuration.isWithoutBusinessKey()); + + return json; + } + + @Override + public RestartProcessInstancesBatchConfiguration readConfiguration(JsonObject json) { + List processInstanceIds = readProcessInstanceIds(json); + DeploymentMappings idMappings = readIdMappings(json); + List instructions = JsonUtil.asList(JsonUtil.getArray(json, INSTRUCTIONS), ModificationCmdJsonConverter.INSTANCE); + + return new RestartProcessInstancesBatchConfiguration(processInstanceIds, idMappings, instructions, + JsonUtil.getString(json, PROCESS_DEFINITION_ID), JsonUtil.getBoolean(json, INITIAL_VARIABLES), + JsonUtil.getBoolean(json, SKIP_CUSTOM_LISTENERS), JsonUtil.getBoolean(json, SKIP_IO_MAPPINGS), + JsonUtil.getBoolean(json, WITHOUT_BUSINESS_KEY)); + } + + protected List readProcessInstanceIds(JsonObject jsonObject) { + return JsonUtil.asStringList(JsonUtil.getArray(jsonObject, PROCESS_INSTANCE_IDS)); + } + + protected DeploymentMappings readIdMappings(JsonObject jsonObject) { + return JsonUtil.asList(JsonUtil.getArray(jsonObject, PROCESS_INSTANCE_ID_MAPPINGS), DeploymentMappingJsonConverter.INSTANCE, DeploymentMappings::new); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..cd518f831e85c3517d2b32d19f0d2de7d007b9be --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RestartProcessInstancesJobHandler.java @@ -0,0 +1,113 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.List; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.cmd.RestartProcessInstancesCmd; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; + +/** + * + * @author Anna Pazola + * + */ +public class RestartProcessInstancesJobHandler extends AbstractBatchJobHandler{ + + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_PROCESS_INSTANCE_RESTART); + + @Override + public String getType() { + return Batch.TYPE_PROCESS_INSTANCE_RESTART; + } + + @Override + protected void postProcessJob(RestartProcessInstancesBatchConfiguration configuration, JobEntity job, RestartProcessInstancesBatchConfiguration jobConfiguration) { + if (job.getDeploymentId() == null) { + CommandContext commandContext = Context.getCommandContext(); + ProcessDefinitionEntity processDefinitionEntity = commandContext.getProcessEngineConfiguration().getDeploymentCache() + .findDeployedProcessDefinitionById(configuration.getProcessDefinitionId()); + job.setDeploymentId(processDefinitionEntity.getDeploymentId()); + } + } + + @Override + public void executeHandler(RestartProcessInstancesBatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + + String processDefinitionId = batchConfiguration.getProcessDefinitionId(); + RestartProcessInstanceBuilderImpl builder = + new RestartProcessInstanceBuilderImpl(processDefinitionId); + + builder.processInstanceIds(batchConfiguration.getIds()); + + builder.setInstructions(batchConfiguration.getInstructions()); + + if (batchConfiguration.isInitialVariables()) { + builder.initialSetOfVariables(); + } + + if (batchConfiguration.isSkipCustomListeners()) { + builder.skipCustomListeners(); + } + + if (batchConfiguration.isWithoutBusinessKey()) { + builder.withoutBusinessKey(); + } + + if (batchConfiguration.isSkipIoMappings()) { + builder.skipIoMappings(); + } + + CommandExecutor commandExecutor = commandContext.getProcessEngineConfiguration() + .getCommandExecutorTxRequired(); + commandContext.executeWithOperationLogPrevented( + new RestartProcessInstancesCmd(commandExecutor, builder)); + + } + + @Override + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + @Override + protected RestartProcessInstancesBatchConfiguration createJobConfiguration(RestartProcessInstancesBatchConfiguration configuration, + List processIdsForJob) { + return new RestartProcessInstancesBatchConfiguration(processIdsForJob, configuration.getInstructions(), configuration.getProcessDefinitionId(), + configuration.isInitialVariables(), configuration.isSkipCustomListeners(), configuration.isSkipIoMappings(), configuration.isWithoutBusinessKey()); + } + + @Override + protected RestartProcessInstancesBatchConfigurationJsonConverter getJsonConverterInstance() { + return RestartProcessInstancesBatchConfigurationJsonConverter.INSTANCE; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RuntimeServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RuntimeServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..506d4e628b114e9f35b67205ad10f3ebc229b0e3 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/RuntimeServiceImpl.java @@ -0,0 +1,828 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.form.FormData; +import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; +import org.camunda.bpm.engine.impl.cmd.CreateIncidentCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteProcessInstanceCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteProcessInstancesCmd; +import org.camunda.bpm.engine.impl.cmd.FindActiveActivityIdsCmd; +import org.camunda.bpm.engine.impl.cmd.GetActivityInstanceCmd; +import org.camunda.bpm.engine.impl.cmd.GetExecutionVariableCmd; +import org.camunda.bpm.engine.impl.cmd.GetExecutionVariableTypedCmd; +import org.camunda.bpm.engine.impl.cmd.GetExecutionVariablesCmd; +import org.camunda.bpm.engine.impl.cmd.GetStartFormCmd; +import org.camunda.bpm.engine.impl.cmd.MessageEventReceivedCmd; +import org.camunda.bpm.engine.impl.cmd.PatchExecutionVariablesCmd; +import org.camunda.bpm.engine.impl.cmd.RemoveExecutionVariablesCmd; +import org.camunda.bpm.engine.impl.cmd.ResolveIncidentCmd; +import org.camunda.bpm.engine.impl.cmd.SetAnnotationForIncidentCmd; +import org.camunda.bpm.engine.impl.cmd.SetExecutionVariablesCmd; +import org.camunda.bpm.engine.impl.cmd.SignalCmd; +import org.camunda.bpm.engine.impl.cmd.batch.DeleteProcessInstanceBatchCmd; +import org.camunda.bpm.engine.impl.cmd.batch.variables.SetVariablesToProcessInstancesBatchCmd; +import org.camunda.bpm.engine.impl.migration.MigrationPlanBuilderImpl; +import org.camunda.bpm.engine.impl.migration.MigrationPlanExecutionBuilderImpl; +import org.camunda.bpm.engine.impl.runtime.UpdateProcessInstanceSuspensionStateBuilderImpl; +import org.camunda.bpm.engine.impl.util.ExceptionUtil; +import org.camunda.bpm.engine.migration.MigrationPlan; +import org.camunda.bpm.engine.migration.MigrationPlanBuilder; +import org.camunda.bpm.engine.migration.MigrationPlanExecutionBuilder; +import org.camunda.bpm.engine.runtime.ActivityInstance; +import org.camunda.bpm.engine.runtime.ConditionEvaluationBuilder; +import org.camunda.bpm.engine.runtime.EventSubscriptionQuery; +import org.camunda.bpm.engine.runtime.ExecutionQuery; +import org.camunda.bpm.engine.runtime.Incident; +import org.camunda.bpm.engine.runtime.IncidentQuery; +import org.camunda.bpm.engine.runtime.MessageCorrelationAsyncBuilder; +import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder; +import org.camunda.bpm.engine.runtime.ModificationBuilder; +import org.camunda.bpm.engine.runtime.NativeExecutionQuery; +import org.camunda.bpm.engine.runtime.NativeProcessInstanceQuery; +import org.camunda.bpm.engine.runtime.ProcessInstance; +import org.camunda.bpm.engine.runtime.ProcessInstanceModificationBuilder; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; +import org.camunda.bpm.engine.runtime.ProcessInstantiationBuilder; +import org.camunda.bpm.engine.runtime.RestartProcessInstanceBuilder; +import org.camunda.bpm.engine.runtime.SignalEventReceivedBuilder; +import org.camunda.bpm.engine.runtime.UpdateProcessInstanceSuspensionStateSelectBuilder; +import org.camunda.bpm.engine.runtime.VariableInstanceQuery; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.value.TypedValue; + +/** + * @author Tom Baeyens + * @author Daniel Meyer + */ +public class RuntimeServiceImpl extends ServiceImpl implements RuntimeService { + + @Override + public ProcessInstance startProcessInstanceByKey(String processDefinitionKey) { + return createProcessInstanceByKey(processDefinitionKey) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, String businessKey) { + return createProcessInstanceByKey(processDefinitionKey) + .businessKey(businessKey) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, String businessKey, String caseInstanceId) { + return createProcessInstanceByKey(processDefinitionKey) + .businessKey(businessKey) + .caseInstanceId(caseInstanceId) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, Map variables) { + return createProcessInstanceByKey(processDefinitionKey) + .setVariables(variables) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, String businessKey, Map variables) { + return createProcessInstanceByKey(processDefinitionKey) + .businessKey(businessKey) + .setVariables(variables) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceByKey(String processDefinitionKey, String businessKey, String caseInstanceId, Map variables) { + return createProcessInstanceByKey(processDefinitionKey) + .businessKey(businessKey) + .caseInstanceId(caseInstanceId) + .setVariables(variables) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceById(String processDefinitionId) { + return createProcessInstanceById(processDefinitionId) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceById(String processDefinitionId, String businessKey) { + return createProcessInstanceById(processDefinitionId) + .businessKey(businessKey) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceById(String processDefinitionId, String businessKey, String caseInstanceId) { + return createProcessInstanceById(processDefinitionId) + .businessKey(businessKey) + .caseInstanceId(caseInstanceId) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceById(String processDefinitionId, Map variables) { + return createProcessInstanceById(processDefinitionId) + .setVariables(variables) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceById(String processDefinitionId, String businessKey, Map variables) { + return createProcessInstanceById(processDefinitionId) + .businessKey(businessKey) + .setVariables(variables) + .execute(); + } + + @Override + public ProcessInstance startProcessInstanceById(String processDefinitionId, String businessKey, String caseInstanceId, Map variables) { + return createProcessInstanceById(processDefinitionId) + .businessKey(businessKey) + .caseInstanceId(caseInstanceId) + .setVariables(variables) + .execute(); + } + + @Override + public void deleteProcessInstance(String processInstanceId, String deleteReason) { + deleteProcessInstance(processInstanceId,deleteReason,false); + } + + @Override + public Batch deleteProcessInstancesAsync(List processInstanceIds, ProcessInstanceQuery processInstanceQuery, String deleteReason) { + return deleteProcessInstancesAsync(processInstanceIds, processInstanceQuery, deleteReason, false); + } + + @Override + public Batch deleteProcessInstancesAsync(List processInstanceIds, String deleteReason) { + return deleteProcessInstancesAsync(processInstanceIds, null, deleteReason, false); + } + + @Override + public Batch deleteProcessInstancesAsync(ProcessInstanceQuery processInstanceQuery, String deleteReason) { + return deleteProcessInstancesAsync(null, processInstanceQuery, deleteReason, false); + } + + @Override + public Batch deleteProcessInstancesAsync(List processInstanceIds, ProcessInstanceQuery processInstanceQuery, String deleteReason, boolean skipCustomListeners) { + return deleteProcessInstancesAsync(processInstanceIds, processInstanceQuery, deleteReason, skipCustomListeners, false); + } + + @Override + public Batch deleteProcessInstancesAsync(List processInstanceIds, ProcessInstanceQuery processInstanceQuery, String deleteReason, + boolean skipCustomListeners, boolean skipSubprocesses) { + + return commandExecutor.execute(new DeleteProcessInstanceBatchCmd( + processInstanceIds, + processInstanceQuery, + null, + deleteReason, + skipCustomListeners, + skipSubprocesses, + false + )); + } + + @Override + public Batch deleteProcessInstancesAsync(List processInstanceIds, + ProcessInstanceQuery processInstanceQuery, + HistoricProcessInstanceQuery historicProcessInstanceQuery, + String deleteReason, + boolean skipCustomListeners, + boolean skipSubprocesses) { + return deleteProcessInstancesAsync(processInstanceIds, processInstanceQuery, historicProcessInstanceQuery, + deleteReason, skipCustomListeners, skipSubprocesses, false); + } + + @Override + public Batch deleteProcessInstancesAsync(List processInstanceIds, + ProcessInstanceQuery processInstanceQuery, + HistoricProcessInstanceQuery historicProcessInstanceQuery, + String deleteReason, + boolean skipCustomListeners, + boolean skipSubprocesses, + boolean skipIoMappings) { + return commandExecutor.execute(new DeleteProcessInstanceBatchCmd( + processInstanceIds, + processInstanceQuery, + historicProcessInstanceQuery, + deleteReason, + skipCustomListeners, + skipSubprocesses, + skipIoMappings + )); + } + + @Override + public void deleteProcessInstance(String processInstanceId, String deleteReason, boolean skipCustomListeners) { + deleteProcessInstance(processInstanceId,deleteReason,skipCustomListeners,false); + } + + @Override + public void deleteProcessInstance(String processInstanceId, String deleteReason, boolean skipCustomListeners, boolean externallyTerminated) { + deleteProcessInstance(processInstanceId, deleteReason, skipCustomListeners, externallyTerminated, false); + } + + @Override + public void deleteProcessInstance(String processInstanceId, String deleteReason, boolean skipCustomListeners, boolean externallyTerminated, boolean skipIoMappings) { + deleteProcessInstance(processInstanceId, deleteReason, skipCustomListeners, externallyTerminated, skipIoMappings, false); + } + + @Override + public void deleteProcessInstance(String processInstanceId, String deleteReason, boolean skipCustomListeners, boolean externallyTerminated, boolean skipIoMappings, boolean skipSubprocesses) { + commandExecutor.execute(new DeleteProcessInstanceCmd(processInstanceId, deleteReason, skipCustomListeners, externallyTerminated, skipIoMappings, skipSubprocesses, true)); + } + + @Override + public void deleteProcessInstanceIfExists(String processInstanceId, String deleteReason, boolean skipCustomListeners, boolean externallyTerminated, boolean skipIoMappings, boolean skipSubprocesses) { + commandExecutor.execute(new DeleteProcessInstanceCmd(processInstanceId, deleteReason, skipCustomListeners, externallyTerminated, skipIoMappings, skipSubprocesses, false)); + } + + @Override + public void deleteProcessInstances(List processInstanceIds, String deleteReason, boolean skipCustomListeners, boolean externallyTerminated){ + deleteProcessInstances(processInstanceIds, deleteReason, skipCustomListeners, externallyTerminated, false, false); + } + + @Override + public void deleteProcessInstances(List processInstanceIds, + String deleteReason, + boolean skipCustomListeners, + boolean externallyTerminated, + boolean skipSubprocesses) { + deleteProcessInstances(processInstanceIds, deleteReason, skipCustomListeners, externallyTerminated, + skipSubprocesses, false); + } + + @Override + public void deleteProcessInstances(List processInstanceIds, String deleteReason, boolean skipCustomListeners, boolean externallyTerminated, boolean skipSubprocesses, boolean skipIoMappings){ + commandExecutor.execute(new DeleteProcessInstancesCmd(processInstanceIds, deleteReason, skipCustomListeners, externallyTerminated, skipSubprocesses, true, skipIoMappings)); + } + + @Override + public void deleteProcessInstancesIfExists(List processInstanceIds, String deleteReason, boolean skipCustomListeners, boolean externallyTerminated, boolean skipSubprocesses) { + commandExecutor.execute(new DeleteProcessInstancesCmd(processInstanceIds, deleteReason, skipCustomListeners, externallyTerminated, skipSubprocesses, false, false)); + } + + @Override + public ExecutionQuery createExecutionQuery() { + return new ExecutionQueryImpl(commandExecutor); + } + + @Override + public NativeExecutionQuery createNativeExecutionQuery() { + return new NativeExecutionQueryImpl(commandExecutor); + } + + @Override + public NativeProcessInstanceQuery createNativeProcessInstanceQuery() { + return new NativeProcessInstanceQueryImpl(commandExecutor); + } + + @Override + public IncidentQuery createIncidentQuery() { + return new IncidentQueryImpl(commandExecutor); + } + + + @Override + public EventSubscriptionQuery createEventSubscriptionQuery() { + return new EventSubscriptionQueryImpl(commandExecutor); + } + + @Override + public VariableInstanceQuery createVariableInstanceQuery() { + return new VariableInstanceQueryImpl(commandExecutor); + } + + @Override + public VariableMap getVariables(String executionId) { + return getVariablesTyped(executionId); + } + + @Override + public VariableMap getVariablesTyped(String executionId) { + return getVariablesTyped(executionId, true); + } + + @Override + public VariableMap getVariablesTyped(String executionId, boolean deserializeObjectValues) { + return commandExecutor.execute(new GetExecutionVariablesCmd(executionId, null, false, deserializeObjectValues)); + } + + @Override + public VariableMap getVariablesLocal(String executionId) { + return getVariablesLocalTyped(executionId); + } + + @Override + public VariableMap getVariablesLocalTyped(String executionId) { + return getVariablesLocalTyped(executionId, true); + } + + @Override + public VariableMap getVariablesLocalTyped(String executionId, boolean deserializeObjectValues) { + return commandExecutor.execute(new GetExecutionVariablesCmd(executionId, null, true, deserializeObjectValues)); + } + + @Override + public VariableMap getVariables(String executionId, Collection variableNames) { + return getVariablesTyped(executionId, variableNames, true); + } + + @Override + public VariableMap getVariablesTyped(String executionId, Collection variableNames, boolean deserializeObjectValues) { + return commandExecutor.execute(new GetExecutionVariablesCmd(executionId, variableNames, false, deserializeObjectValues)); + } + + @Override + public VariableMap getVariablesLocal(String executionId, Collection variableNames) { + return getVariablesLocalTyped(executionId, variableNames, true); + } + + @Override + public VariableMap getVariablesLocalTyped(String executionId, Collection variableNames, boolean deserializeObjectValues) { + return commandExecutor.execute(new GetExecutionVariablesCmd(executionId, variableNames, true, deserializeObjectValues)); + } + + @Override + public Object getVariable(String executionId, String variableName) { + return commandExecutor.execute(new GetExecutionVariableCmd(executionId, variableName, false)); + } + + @Override + public T getVariableTyped(String executionId, String variableName) { + return getVariableTyped(executionId, variableName, true); + } + + @Override + public T getVariableTyped(String executionId, String variableName, boolean deserializeObjectValue) { + return commandExecutor.execute(new GetExecutionVariableTypedCmd(executionId, variableName, false, deserializeObjectValue)); + } + + @Override + public T getVariableLocalTyped(String executionId, String variableName) { + return getVariableLocalTyped(executionId, variableName, true); + } + + @Override + public T getVariableLocalTyped(String executionId, String variableName, boolean deserializeObjectValue) { + return commandExecutor.execute(new GetExecutionVariableTypedCmd(executionId, variableName, true, deserializeObjectValue)); + } + + @Override + public Object getVariableLocal(String executionId, String variableName) { + return commandExecutor.execute(new GetExecutionVariableCmd(executionId, variableName, true)); + } + + @Override + public void setVariable(String executionId, String variableName, Object value) { + ensureNotNull("variableName", variableName); + Map variables = new HashMap(); + variables.put(variableName, value); + setVariables(executionId, variables); + } + + @Override + public void setVariableLocal(String executionId, String variableName, Object value) { + ensureNotNull("variableName", variableName); + Map variables = new HashMap(); + variables.put(variableName, value); + setVariablesLocal(executionId, variables); + } + + @Override + public void setVariables(String executionId, Map variables) { + setVariables(executionId, variables, false); + } + + @Override + public void setVariablesLocal(String executionId, Map variables) { + setVariables(executionId, variables, true); + } + + protected void setVariables(String executionId, Map variables, boolean local) { + try { + commandExecutor.execute(new SetExecutionVariablesCmd(executionId, variables, local)); + } catch (ProcessEngineException ex) { + if (ExceptionUtil.checkValueTooLongException(ex)) { + throw new BadUserRequestException("Variable value is too long", ex); + } + throw ex; + } + } + + public Batch setVariablesAsync(List processInstanceIds, + ProcessInstanceQuery processInstanceQuery, + HistoricProcessInstanceQuery historicProcessInstanceQuery, + Map variables) { + return commandExecutor.execute(new SetVariablesToProcessInstancesBatchCmd( + processInstanceIds, + processInstanceQuery, + historicProcessInstanceQuery, + variables + )); + } + + public Batch setVariablesAsync(List processInstanceIds, + Map variables) { + return commandExecutor.execute(new SetVariablesToProcessInstancesBatchCmd( + processInstanceIds, + null, + null, + variables + )); + } + + public Batch setVariablesAsync(ProcessInstanceQuery processInstanceQuery, + Map variables) { + return commandExecutor.execute(new SetVariablesToProcessInstancesBatchCmd( + null, + processInstanceQuery, + null, + variables + )); + } + + public Batch setVariablesAsync(HistoricProcessInstanceQuery historicProcessInstanceQuery, + Map variables) { + return commandExecutor.execute(new SetVariablesToProcessInstancesBatchCmd( + null, + null, + historicProcessInstanceQuery, + variables + )); + } + + @Override + public void removeVariable(String executionId, String variableName) { + Collection variableNames = new ArrayList(); + variableNames.add(variableName); + commandExecutor.execute(new RemoveExecutionVariablesCmd(executionId, variableNames, false)); + } + + @Override + public void removeVariableLocal(String executionId, String variableName) { + Collection variableNames = new ArrayList(); + variableNames.add(variableName); + commandExecutor.execute(new RemoveExecutionVariablesCmd(executionId, variableNames, true)); + + } + + @Override + public void removeVariables(String executionId, Collection variableNames) { + commandExecutor.execute(new RemoveExecutionVariablesCmd(executionId, variableNames, false)); + } + + @Override + public void removeVariablesLocal(String executionId, Collection variableNames) { + commandExecutor.execute(new RemoveExecutionVariablesCmd(executionId, variableNames, true)); + } + + public void updateVariables(String executionId, Map modifications, Collection deletions) { + updateVariables(executionId, modifications, deletions, false); + } + + public void updateVariablesLocal(String executionId, Map modifications, Collection deletions) { + updateVariables(executionId, modifications, deletions, true); + } + + protected void updateVariables(String executionId, Map modifications, Collection deletions, boolean local) { + try { + commandExecutor.execute(new PatchExecutionVariablesCmd(executionId, modifications, deletions, local)); + } catch (ProcessEngineException ex) { + if (ExceptionUtil.checkValueTooLongException(ex)) { + throw new BadUserRequestException("Variable value is too long", ex); + } + throw ex; + } + } + + + + @Override + public void signal(String executionId) { + commandExecutor.execute(new SignalCmd(executionId, null, null, null)); + } + + @Override + public void signal(String executionId, String signalName, Object signalData, Map processVariables) { + commandExecutor.execute(new SignalCmd(executionId, signalName, signalData, processVariables)); + } + + @Override + public void signal(String executionId, Map processVariables) { + commandExecutor.execute(new SignalCmd(executionId, null, null, processVariables)); + } + + @Override + public ProcessInstanceQuery createProcessInstanceQuery() { + return new ProcessInstanceQueryImpl(commandExecutor); + } + + @Override + public List getActiveActivityIds(String executionId) { + return commandExecutor.execute(new FindActiveActivityIdsCmd(executionId)); + } + + @Override + public ActivityInstance getActivityInstance(String processInstanceId) { + return commandExecutor.execute(new GetActivityInstanceCmd(processInstanceId)); + } + + public FormData getFormInstanceById(String processDefinitionId) { + return commandExecutor.execute(new GetStartFormCmd(processDefinitionId)); + } + + @Override + public void suspendProcessInstanceById(String processInstanceId) { + updateProcessInstanceSuspensionState() + .byProcessInstanceId(processInstanceId) + .suspend(); + } + + @Override + public void suspendProcessInstanceByProcessDefinitionId(String processDefinitionId) { + updateProcessInstanceSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .suspend(); + } + + @Override + public void suspendProcessInstanceByProcessDefinitionKey(String processDefinitionKey) { + updateProcessInstanceSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .suspend(); + } + + @Override + public void activateProcessInstanceById(String processInstanceId) { + updateProcessInstanceSuspensionState() + .byProcessInstanceId(processInstanceId) + .activate(); + } + + @Override + public void activateProcessInstanceByProcessDefinitionId(String processDefinitionId) { + updateProcessInstanceSuspensionState() + .byProcessDefinitionId(processDefinitionId) + .activate(); + } + + @Override + public void activateProcessInstanceByProcessDefinitionKey(String processDefinitionKey) { + updateProcessInstanceSuspensionState() + .byProcessDefinitionKey(processDefinitionKey) + .activate(); + } + + @Override + public UpdateProcessInstanceSuspensionStateSelectBuilder updateProcessInstanceSuspensionState() { + return new UpdateProcessInstanceSuspensionStateBuilderImpl(commandExecutor); + } + + @Override + public ProcessInstance startProcessInstanceByMessage(String messageName) { + return createMessageCorrelation(messageName).correlateStartMessage(); + } + + @Override + public ProcessInstance startProcessInstanceByMessage(String messageName, String businessKey) { + return createMessageCorrelation(messageName) + .processInstanceBusinessKey(businessKey) + .correlateStartMessage(); + } + + @Override + public ProcessInstance startProcessInstanceByMessage(String messageName, Map processVariables) { + return createMessageCorrelation(messageName) + .setVariables(processVariables) + .correlateStartMessage(); + } + + @Override + public ProcessInstance startProcessInstanceByMessage(String messageName, String businessKey, Map processVariables) { + return createMessageCorrelation(messageName) + .processInstanceBusinessKey(businessKey) + .setVariables(processVariables) + .correlateStartMessage(); + } + + @Override + public ProcessInstance startProcessInstanceByMessageAndProcessDefinitionId(String messageName, String processDefinitionId) { + return createMessageCorrelation(messageName) + .processDefinitionId(processDefinitionId) + .correlateStartMessage(); + } + + @Override + public ProcessInstance startProcessInstanceByMessageAndProcessDefinitionId(String messageName, String processDefinitionId, String businessKey) { + return createMessageCorrelation(messageName) + .processDefinitionId(processDefinitionId) + .processInstanceBusinessKey(businessKey) + .correlateStartMessage(); + } + + @Override + public ProcessInstance startProcessInstanceByMessageAndProcessDefinitionId(String messageName, String processDefinitionId, Map processVariables) { + return createMessageCorrelation(messageName) + .processDefinitionId(processDefinitionId) + .setVariables(processVariables) + .correlateStartMessage(); + } + + @Override + public ProcessInstance startProcessInstanceByMessageAndProcessDefinitionId(String messageName, String processDefinitionId, String businessKey, Map processVariables) { + return createMessageCorrelation(messageName) + .processDefinitionId(processDefinitionId) + .processInstanceBusinessKey(businessKey) + .setVariables(processVariables) + .correlateStartMessage(); + } + + @Override + public void signalEventReceived(String signalName) { + createSignalEvent(signalName).send(); + } + + @Override + public void signalEventReceived(String signalName, Map processVariables) { + createSignalEvent(signalName).setVariables(processVariables).send(); + } + + @Override + public void signalEventReceived(String signalName, String executionId) { + createSignalEvent(signalName).executionId(executionId).send(); + } + + @Override + public void signalEventReceived(String signalName, String executionId, Map processVariables) { + createSignalEvent(signalName).executionId(executionId).setVariables(processVariables).send(); + } + + @Override + public SignalEventReceivedBuilder createSignalEvent(String signalName) { + return new SignalEventReceivedBuilderImpl(commandExecutor, signalName); + } + + @Override + public void messageEventReceived(String messageName, String executionId) { + ensureNotNull("messageName", messageName); + commandExecutor.execute(new MessageEventReceivedCmd(messageName, executionId, null)); + } + + @Override + public void messageEventReceived(String messageName, String executionId, Map processVariables) { + ensureNotNull("messageName", messageName); + commandExecutor.execute(new MessageEventReceivedCmd(messageName, executionId, processVariables)); + } + + @Override + public MessageCorrelationBuilder createMessageCorrelation(String messageName) { + return new MessageCorrelationBuilderImpl(commandExecutor, messageName); + } + + @Override + public void correlateMessage(String messageName, Map correlationKeys, Map processVariables) { + createMessageCorrelation(messageName) + .processInstanceVariablesEqual(correlationKeys) + .setVariables(processVariables) + .correlate(); + } + + @Override + public void correlateMessage(String messageName, String businessKey, + Map correlationKeys, Map processVariables) { + + createMessageCorrelation(messageName) + .processInstanceVariablesEqual(correlationKeys) + .processInstanceBusinessKey(businessKey) + .setVariables(processVariables) + .correlate(); + } + + @Override + public void correlateMessage(String messageName) { + createMessageCorrelation(messageName).correlate(); + } + + @Override + public void correlateMessage(String messageName, String businessKey) { + createMessageCorrelation(messageName) + .processInstanceBusinessKey(businessKey) + .correlate(); + } + + @Override + public void correlateMessage(String messageName, Map correlationKeys) { + createMessageCorrelation(messageName) + .processInstanceVariablesEqual(correlationKeys) + .correlate(); + } + + @Override + public void correlateMessage(String messageName, String businessKey, Map processVariables) { + createMessageCorrelation(messageName) + .processInstanceBusinessKey(businessKey) + .setVariables(processVariables) + .correlate(); + } + + @Override + public MessageCorrelationAsyncBuilder createMessageCorrelationAsync(String messageName) { + return new MessageCorrelationAsyncBuilderImpl(commandExecutor, messageName); + } + + @Override + public ProcessInstanceModificationBuilder createProcessInstanceModification(String processInstanceId) { + return new ProcessInstanceModificationBuilderImpl(commandExecutor, processInstanceId); + } + + @Override + public ProcessInstantiationBuilder createProcessInstanceById(String processDefinitionId) { + return ProcessInstantiationBuilderImpl.createProcessInstanceById(commandExecutor, processDefinitionId); + } + + @Override + public ProcessInstantiationBuilder createProcessInstanceByKey(String processDefinitionKey) { + return ProcessInstantiationBuilderImpl.createProcessInstanceByKey(commandExecutor, processDefinitionKey); + } + + @Override + public MigrationPlanBuilder createMigrationPlan(String sourceProcessDefinitionId, String targetProcessDefinitionId) { + return new MigrationPlanBuilderImpl(commandExecutor, sourceProcessDefinitionId, targetProcessDefinitionId); + } + + @Override + public MigrationPlanExecutionBuilder newMigration(MigrationPlan migrationPlan) { + return new MigrationPlanExecutionBuilderImpl(commandExecutor, migrationPlan); + } + + @Override + public ModificationBuilder createModification(String processDefinitionId) { + return new ModificationBuilderImpl(commandExecutor, processDefinitionId); + } + + @Override + public RestartProcessInstanceBuilder restartProcessInstances(String processDefinitionId) { + return new RestartProcessInstanceBuilderImpl(commandExecutor, processDefinitionId); + } + + @Override + public Incident createIncident(String incidentType, String executionId, String configuration) { + return createIncident(incidentType, executionId, configuration, null); + } + + @Override + public Incident createIncident(String incidentType, String executionId, String configuration, String message) { + return commandExecutor.execute(new CreateIncidentCmd(incidentType, executionId, configuration, message)); + } + + @Override + public void resolveIncident(String incidentId) { + commandExecutor.execute(new ResolveIncidentCmd(incidentId)); + } + + @Override + public void setAnnotationForIncidentById(String incidentId, String annotation) { + commandExecutor.execute(new SetAnnotationForIncidentCmd(incidentId, annotation)); + } + + @Override + public void clearAnnotationForIncidentById(String incidentId) { + commandExecutor.execute(new SetAnnotationForIncidentCmd(incidentId, null)); + } + + @Override + public ConditionEvaluationBuilder createConditionEvaluation() { + return new ConditionEvaluationBuilderImpl(commandExecutor); + } +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SchemaLogQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SchemaLogQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f5164a29022e285361ccf1dc716058054f416d53 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SchemaLogQueryImpl.java @@ -0,0 +1,68 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.List; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.management.SchemaLogEntry; +import org.camunda.bpm.engine.management.SchemaLogQuery; +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * @author Miklas Boskamp + * + */ +public class SchemaLogQueryImpl extends AbstractQuery implements SchemaLogQuery { + + private static final long serialVersionUID = 1L; + private static final QueryProperty TIMESTAMP_PROPERTY = new QueryPropertyImpl("TIMESTAMP_"); + + protected String version; + + public SchemaLogQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + @Override + public SchemaLogQuery version(String version) { + ensureNotNull("version", version); + this.version = version; + return this; + } + + @Override + public SchemaLogQuery orderByTimestamp() { + orderBy(TIMESTAMP_PROPERTY); + return this; + } + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext.getSchemaLogManager().findSchemaLogEntryCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext.getSchemaLogManager().findSchemaLogEntriesByQueryCriteria(this, page); + } +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SchemaOperationProcessEngineClose.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SchemaOperationProcessEngineClose.java new file mode 100644 index 0000000000000000000000000000000000000000..023eb5dd2cd9a3897cc1b3196064d48337713cb9 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SchemaOperationProcessEngineClose.java @@ -0,0 +1,37 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.ProcessEngineConfiguration; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.PersistenceSession; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; + +/** + * @author Tom Baeyens + */ +final class SchemaOperationProcessEngineClose implements Command { + + public Object execute(CommandContext commandContext) { + String databaseSchemaUpdate = Context.getProcessEngineConfiguration().getDatabaseSchemaUpdate(); + if (ProcessEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP.equals(databaseSchemaUpdate)) { + commandContext.getSession(PersistenceSession.class).dbSchemaDrop(); + } + return null; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SchemaOperationsProcessEngineBuild.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SchemaOperationsProcessEngineBuild.java new file mode 100644 index 0000000000000000000000000000000000000000..ad9087abe26af00a5f938c56572ed516db238d5e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SchemaOperationsProcessEngineBuild.java @@ -0,0 +1,61 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.ProcessEngineConfiguration; +import org.camunda.bpm.engine.SchemaOperationsCommand; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.EnginePersistenceLogger; +import org.camunda.bpm.engine.impl.db.PersistenceSession; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.PropertyEntity; + +/** + * @author Tom Baeyens + * @author Roman Smirnov + * @author Sebastian Menski + * @author Daniel Meyer + */ +public class SchemaOperationsProcessEngineBuild implements SchemaOperationsCommand { + + private final static EnginePersistenceLogger LOG = ProcessEngineLogger.PERSISTENCE_LOGGER; + + public Void execute(CommandContext commandContext) { + String databaseSchemaUpdate = Context.getProcessEngineConfiguration().getDatabaseSchemaUpdate(); + PersistenceSession persistenceSession = commandContext.getSession(PersistenceSession.class); + if (ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE.equals(databaseSchemaUpdate)) { + try { + persistenceSession.dbSchemaDrop(); + } catch (RuntimeException e) { + // ignore + } + } + if ( ProcessEngineConfiguration.DB_SCHEMA_UPDATE_CREATE_DROP.equals(databaseSchemaUpdate) + || ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_DROP_CREATE.equals(databaseSchemaUpdate) + || ProcessEngineConfigurationImpl.DB_SCHEMA_UPDATE_CREATE.equals(databaseSchemaUpdate) + ) { + persistenceSession.dbSchemaCreate(); + } else if (ProcessEngineConfiguration.DB_SCHEMA_UPDATE_FALSE.equals(databaseSchemaUpdate)) { + persistenceSession.dbSchemaCheckVersion(); + } else if (ProcessEngineConfiguration.DB_SCHEMA_UPDATE_TRUE.equals(databaseSchemaUpdate)) { + persistenceSession.dbSchemaUpdate(); + } + + return null; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..29c5f276d2417016873cb9a3b30ec4e8c065dce4 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ServiceImpl.java @@ -0,0 +1,37 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + + + +/** + * @author Tom Baeyens + */ +public class ServiceImpl { + + protected CommandExecutor commandExecutor; + + public CommandExecutor getCommandExecutor() { + return commandExecutor; + } + + public void setCommandExecutor(CommandExecutor commandExecutor) { + this.commandExecutor = commandExecutor; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SetAnnotationForOperationLog.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SetAnnotationForOperationLog.java new file mode 100644 index 0000000000000000000000000000000000000000..b492836d63d43d77090753960ea8447e4db65579 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SetAnnotationForOperationLog.java @@ -0,0 +1,63 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.exception.NotValidException; +import org.camunda.bpm.engine.history.UserOperationLogEntry; +import org.camunda.bpm.engine.impl.cfg.CommandChecker; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.util.EnsureUtil; + +public class SetAnnotationForOperationLog implements Command { + + protected String operationId; + protected String annotation; + + public SetAnnotationForOperationLog(String operationId, String annotation) { + this.operationId = operationId; + this.annotation = annotation; + } + + @Override + public Void execute(CommandContext commandContext) { + EnsureUtil.ensureNotNull(NotValidException.class, "operation id", operationId); + + UserOperationLogEntry operationLogEntry = commandContext.getOperationLogManager().findOperationLogByOperationId(operationId); + EnsureUtil.ensureNotNull(BadUserRequestException.class, "operation", operationLogEntry); + + for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { + checker.checkUpdateUserOperationLog(operationLogEntry); + } + + commandContext.getOperationLogManager() + .updateOperationLogAnnotationByOperationId(operationId, annotation); + + if (annotation == null) { + commandContext.getOperationLogManager() + .logClearAnnotationOperation(operationId, operationLogEntry.getTenantId()); + + } else { + commandContext.getOperationLogManager() + .logSetAnnotationOperation(operationId, operationLogEntry.getTenantId()); + } + + return null; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SetJobsRetriesByProcessBatchCmd.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SetJobsRetriesByProcessBatchCmd.java new file mode 100644 index 0000000000000000000000000000000000000000..5c6300989550207a4b79f3944ba4ff98ccdb9994 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SetJobsRetriesByProcessBatchCmd.java @@ -0,0 +1,82 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; +import org.camunda.bpm.engine.impl.batch.BatchElementConfiguration; +import org.camunda.bpm.engine.impl.cmd.AbstractSetJobsRetriesBatchCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.util.CollectionUtil; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; + +/** + * @author Askar Akhmerov + */ +public class SetJobsRetriesByProcessBatchCmd extends AbstractSetJobsRetriesBatchCmd { + + protected final List processInstanceIds; + protected final ProcessInstanceQuery query; + protected HistoricProcessInstanceQuery historicProcessInstanceQuery; + + public SetJobsRetriesByProcessBatchCmd(List processInstanceIds, + ProcessInstanceQuery query, + HistoricProcessInstanceQuery historicProcessInstanceQuery, + int retries, + Date dueDate, + boolean isDueDateSet) { + this.processInstanceIds = processInstanceIds; + this.query = query; + this.historicProcessInstanceQuery = historicProcessInstanceQuery; + this.retries = retries; + this.dueDate = dueDate; + this.isDueDateSet = isDueDateSet; + } + + protected BatchElementConfiguration collectJobIds(CommandContext commandContext) { + Set collectedProcessInstanceIds = new HashSet<>(); + + if (query != null) { + collectedProcessInstanceIds.addAll(((ProcessInstanceQueryImpl)query).listIds()); + } + + if (historicProcessInstanceQuery != null) { + List ids = + ((HistoricProcessInstanceQueryImpl) historicProcessInstanceQuery).listIds(); + collectedProcessInstanceIds.addAll(ids); + } + + if (this.processInstanceIds != null) { + collectedProcessInstanceIds.addAll(this.processInstanceIds); + } + + BatchElementConfiguration elementConfiguration = new BatchElementConfiguration(); + + if (!CollectionUtil.isEmpty(collectedProcessInstanceIds)) { + JobQueryImpl jobQuery = new JobQueryImpl(); + jobQuery.processInstanceIds(collectedProcessInstanceIds); + elementConfiguration.addDeploymentMappings(commandContext.runWithoutAuthorization(jobQuery::listDeploymentIdMappings)); + } + + return elementConfiguration; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SignalEventReceivedBuilderImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SignalEventReceivedBuilderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ad98899e0c379fad9e4a19e4e3b74d3eb0abfe57 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SignalEventReceivedBuilderImpl.java @@ -0,0 +1,117 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Map; + +import org.camunda.bpm.engine.impl.cmd.CommandLogger; +import org.camunda.bpm.engine.impl.cmd.SignalEventReceivedCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.SignalEventReceivedBuilder; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; + +public class SignalEventReceivedBuilderImpl implements SignalEventReceivedBuilder { + + private final static CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; + + protected final CommandExecutor commandExecutor; + protected final String signalName; + + protected String executionId = null; + + protected String tenantId = null; + protected boolean isTenantIdSet = false; + + protected VariableMap variables = null; + + public SignalEventReceivedBuilderImpl(CommandExecutor commandExecutor, String signalName) { + this.commandExecutor = commandExecutor; + this.signalName = signalName; + } + + @Override + public SignalEventReceivedBuilder setVariables(Map variables) { + if (variables != null) { + + if (this.variables == null) { + this.variables = new VariableMapImpl(); + } + this.variables.putAll(variables); + } + return this; + } + + @Override + public SignalEventReceivedBuilder executionId(String executionId) { + ensureNotNull("executionId", executionId); + this.executionId = executionId; + return this; + } + + @Override + public SignalEventReceivedBuilder tenantId(String tenantId) { + ensureNotNull( + "The tenant-id cannot be null. Use 'withoutTenantId()' if you want to send the signal to a process definition or an execution which has no tenant-id.", + "tenantId", tenantId); + + this.tenantId = tenantId; + isTenantIdSet = true; + + return this; + } + + @Override + public SignalEventReceivedBuilder withoutTenantId() { + // tenant-id is null + isTenantIdSet = true; + return this; + } + + @Override + public void send() { + if (executionId != null && isTenantIdSet) { + throw LOG.exceptionDeliverSignalToSingleExecutionWithTenantId(); + } + + SignalEventReceivedCmd command = new SignalEventReceivedCmd(this); + commandExecutor.execute(command); + } + + public String getSignalName() { + return signalName; + } + + public String getExecutionId() { + return executionId; + } + + public String getTenantId() { + return tenantId; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public VariableMap getVariables() { + return variables; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SingleQueryVariableValueCondition.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SingleQueryVariableValueCondition.java new file mode 100644 index 0000000000000000000000000000000000000000..f5fb41f29d8c66efdae09038bc8dca64b028d71e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/SingleQueryVariableValueCondition.java @@ -0,0 +1,144 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.QueryOperator.*; + +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.db.sql.DbSqlSessionFactory; +import org.camunda.bpm.engine.impl.variable.serializer.TypedValueSerializer; +import org.camunda.bpm.engine.impl.variable.serializer.ValueFields; +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; +import org.camunda.bpm.engine.variable.impl.value.UntypedValueImpl; +import org.camunda.bpm.engine.variable.type.ValueType; +import org.camunda.bpm.engine.variable.value.TypedValue; + +/** + * @author Thorben Lindhauer + * + */ +public class SingleQueryVariableValueCondition extends AbstractQueryVariableValueCondition + implements ValueFields { + + protected String textValue; + protected String textValue2; + protected Long longValue; + protected Double doubleValue; + protected String type; + protected boolean findNulledEmptyStrings; + + public SingleQueryVariableValueCondition(QueryVariableValue variableValue) { + super(variableValue); + } + + public void initializeValue(VariableSerializers serializers, String dbType) { + TypedValue typedValue = wrappedQueryValue.getTypedValue(); + initializeValue(serializers, typedValue, dbType); + } + + public void initializeValue(VariableSerializers serializers, TypedValue typedValue, String dbType) { + TypedValueSerializer serializer = determineSerializer(serializers, typedValue); + + if(typedValue instanceof UntypedValueImpl) { + // type has been detected + typedValue = serializer.convertToTypedValue((UntypedValueImpl) typedValue); + } + serializer.writeValue(typedValue, this); + this.type = serializer.getName(); + if (ValueType.STRING.getName().equals(type) && DbSqlSessionFactory.ORACLE.equals(dbType)) { + if ("".equals(textValue) && Arrays.asList(EQUALS, NOT_EQUALS).contains(wrappedQueryValue.getOperator())) { + this.findNulledEmptyStrings = true; + } + } + } + + protected TypedValueSerializer determineSerializer(VariableSerializers serializers, TypedValue value) { + TypedValueSerializer serializer = serializers.findSerializerForValue(value); + + if(serializer.getType() == ValueType.BYTES){ + throw new ProcessEngineException("Variables of type ByteArray cannot be used to query"); + } + else if(serializer.getType() == ValueType.FILE){ + throw new ProcessEngineException("Variables of type File cannot be used to query"); + } + else { + if(!serializer.getType().isPrimitiveValueType()) { + throw new ProcessEngineException("Object values cannot be used to query"); + } + + } + + return serializer; + } + + public List getDisjunctiveConditions() { + return Collections.singletonList(this); + } + + public String getName() { + return wrappedQueryValue.getName(); + } + + public String getTextValue() { + return textValue; + } + public void setTextValue(String textValue) { + this.textValue = textValue; + } + public String getTextValue2() { + return textValue2; + } + public void setTextValue2(String textValue2) { + this.textValue2 = textValue2; + } + public Long getLongValue() { + return longValue; + } + public void setLongValue(Long longValue) { + this.longValue = longValue; + } + public Double getDoubleValue() { + return doubleValue; + } + public void setDoubleValue(Double doubleValue) { + this.doubleValue = doubleValue; + } + + public byte[] getByteArrayValue() { + return null; + } + + public void setByteArrayValue(byte[] bytes) { + } + + public String getType() { + return type; + } + + public boolean getFindNulledEmptyStrings() { + return findNulledEmptyStrings; + } + + public void setFindNulledEmptyStrings(boolean findNulledEmptyStrings) { + this.findNulledEmptyStrings = findNulledEmptyStrings; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TablePageQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TablePageQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f5d4e091b0d101f4e6c2ba3240d9a1914f4686c4 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TablePageQueryImpl.java @@ -0,0 +1,85 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.io.Serializable; + +import org.camunda.bpm.engine.impl.db.ListQueryParameterObject; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.management.TablePage; +import org.camunda.bpm.engine.management.TablePageQuery; + + +/** + * + * @author Joram Barrez + */ +public class TablePageQueryImpl extends ListQueryParameterObject implements TablePageQuery, Command, Serializable { + + private static final long serialVersionUID = 1L; + + transient CommandExecutor commandExecutor; + + protected String tableName; + protected String order; + + public TablePageQueryImpl() { + } + + public TablePageQueryImpl(CommandExecutor commandExecutor) { + this.commandExecutor = commandExecutor; + } + + public TablePageQueryImpl tableName(String tableName) { + this.tableName = tableName; + return this; + } + + public TablePageQueryImpl orderAsc(String column) { + this.orderingProperties.add(new QueryOrderingProperty(new QueryPropertyImpl(column), Direction.ASCENDING)); + return this; + } + + public TablePageQueryImpl orderDesc(String column) { + this.orderingProperties.add(new QueryOrderingProperty(new QueryPropertyImpl(column), Direction.DESCENDING)); + return this; + } + + public String getTableName() { + return tableName; + } + + public TablePage listPage(int firstResult, int maxResults) { + this.firstResult = firstResult; + this.maxResults = maxResults; + return commandExecutor.execute(this); + } + + public TablePage execute(CommandContext commandContext) { + commandContext.getAuthorizationManager().checkCamundaAdmin(); + return commandContext + .getTableDataManager() + .getTablePage(this); + } + + public String getOrder() { + return order; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b5fb64c0a5f265777f1e48a97a167a822137515b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryImpl.java @@ -0,0 +1,2479 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static java.lang.Boolean.TRUE; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotEmpty; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.identity.Group; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.SuspensionState; +import org.camunda.bpm.engine.impl.persistence.entity.TaskEntity; +import org.camunda.bpm.engine.impl.util.CompareUtil; +import org.camunda.bpm.engine.impl.variable.serializer.VariableSerializers; +import org.camunda.bpm.engine.task.DelegationState; +import org.camunda.bpm.engine.task.Task; +import org.camunda.bpm.engine.task.TaskQuery; +import org.camunda.bpm.engine.variable.type.ValueType; +import org.camunda.bpm.engine.impl.history.HistoryLevel; + +/** + * @author Joram Barrez + * @author Tom Baeyens + * @author Falko Menge + */ +public class TaskQueryImpl extends AbstractQuery implements TaskQuery { + + /* + * When adding a property filter that supports Tasklist filters, + * the following classes need to be modified: + * + *
    + *
  1. + * Update the {@code TaskQuery} interface; + *
  2. + *
  3. + * Implement the new property filter and getters/setters in {@code TaskQueryImpl}; + *
  4. + *
  5. + * Add the new property filter in the engine-rest {@code TaskQueryDto} class; + *
  6. + *
  7. + * Use the new filter in the engine-rest {@code TaskQueryDto#applyFilters} method. + * The method is used to provide Task filtering through the Rest API endpoint; + *
  8. + *
  9. + * Initialize the new property filter in the engine-rest + * {@code TaskQueryDto#fromQuery} method; The method is used to create a {@code TaskQueryDto} + * from a serialized ("saved") Task query. This is used in Tasklist filters; + *
  10. + *
  11. + * Add the property to the {@code JsonTaskQueryConverter} class, and make sure + * it is included in the {@code JsonTaskQueryConverter#toJsonObject} and + * {@code JsonTaskQueryConverter#toObject} methods. This is used to serialize/deserialize + * Task queries for Tasklist filter usage. + *
  12. + *
  13. + * Tests need to be added in: {@code TaskQueryTest} for Java API coverage, + * {@code TaskRestServiceQueryTest} for Rest API coverage and + * {@code FilterTaskQueryTest} for Tasklist filter coverage. + *
  14. + *
+ */ + + private static final long serialVersionUID = 1L; + protected String taskId; + protected String[] taskIdIn; + protected String name; + protected String nameNotEqual; + protected String nameLike; + protected String nameNotLike; + protected String description; + protected String descriptionLike; + protected Integer priority; + protected Integer minPriority; + protected Integer maxPriority; + protected String assignee; + protected String assigneeLike; + protected Set assigneeIn; + protected Set assigneeNotIn; + protected String involvedUser; + protected String owner; + protected Boolean unassigned; + protected Boolean assigned; + protected boolean noDelegationState = false; + protected DelegationState delegationState; + protected String candidateUser; + protected String candidateGroup; + protected String candidateGroupLike; + protected List candidateGroups; + protected Boolean withCandidateGroups; + protected Boolean withoutCandidateGroups; + protected Boolean withCandidateUsers; + protected Boolean withoutCandidateUsers; + protected Boolean includeAssignedTasks; + protected String processInstanceId; + protected String[] processInstanceIdIn; + protected String executionId; + protected String[] activityInstanceIdIn; + protected Date createTime; + protected Date createTimeBefore; + protected Date createTimeAfter; + protected Date updatedAfter; + protected String key; + protected String keyLike; + protected String[] taskDefinitionKeys; + protected String[] taskDefinitionKeyNotIn; + protected String processDefinitionKey; + protected String[] processDefinitionKeys; + protected String processDefinitionId; + protected String processDefinitionName; + protected String processDefinitionNameLike; + protected String processInstanceBusinessKey; + protected String[] processInstanceBusinessKeys; + protected String processInstanceBusinessKeyLike; + protected List variables = new ArrayList<>(); + protected Date dueDate; + protected Date dueBefore; + protected Date dueAfter; + protected Date followUpDate; + protected Date followUpBefore; + protected boolean followUpNullAccepted=false; + protected Date followUpAfter; + protected boolean excludeSubtasks = false; + protected SuspensionState suspensionState; + protected boolean initializeFormKeys = false; + protected boolean taskNameCaseInsensitive = false; + + protected Boolean variableNamesIgnoreCase; + protected Boolean variableValuesIgnoreCase; + + protected String parentTaskId; + protected boolean isWithoutTenantId = false; + protected boolean isWithoutDueDate = false; + + protected String[] tenantIds; + // case management ///////////////////////////// + protected String caseDefinitionKey; + protected String caseDefinitionId; + protected String caseDefinitionName; + protected String caseDefinitionNameLike; + protected String caseInstanceId; + protected String caseInstanceBusinessKey; + protected String caseInstanceBusinessKeyLike; + protected String caseExecutionId; + + protected List cachedCandidateGroups; + protected Map> cachedUserGroups; + + // or query ///////////////////////////// + protected List queries = new ArrayList<>(Arrays.asList(this)); + protected boolean isOrQueryActive = false; + protected boolean withCommentAttachmentInfo; + + public TaskQueryImpl() { + } + + public TaskQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + @Override + public TaskQueryImpl taskId(String taskId) { + ensureNotNull("Task id", taskId); + this.taskId = taskId; + return this; + } + + @Override + public TaskQueryImpl taskIdIn(String... taskIds) { + ensureNotNull("taskIds", (Object[]) taskIds); + this.taskIdIn = taskIds; + return this; + } + + @Override + public TaskQueryImpl taskName(String name) { + this.name = name; + return this; + } + + @Override + public TaskQueryImpl taskNameLike(String nameLike) { + ensureNotNull("Task nameLike", nameLike); + this.nameLike = nameLike; + return this; + } + + @Override + public TaskQueryImpl taskDescription(String description) { + ensureNotNull("Description", description); + this.description = description; + return this; + } + + @Override + public TaskQuery taskDescriptionLike(String descriptionLike) { + ensureNotNull("Task descriptionLike", descriptionLike); + this.descriptionLike = descriptionLike; + return this; + } + + @Override + public TaskQuery taskPriority(Integer priority) { + ensureNotNull("Priority", priority); + this.priority = priority; + return this; + } + + @Override + public TaskQuery taskMinPriority(Integer minPriority) { + ensureNotNull("Min Priority", minPriority); + this.minPriority = minPriority; + return this; + } + + @Override + public TaskQuery taskMaxPriority(Integer maxPriority) { + ensureNotNull("Max Priority", maxPriority); + this.maxPriority = maxPriority; + return this; + } + + @Override + public TaskQueryImpl taskAssignee(String assignee) { + ensureNotNull("Assignee", assignee); + this.assignee = assignee; + expressions.remove("taskAssignee"); + return this; + } + + @Override + public TaskQuery taskAssigneeExpression(String assigneeExpression) { + ensureNotNull("Assignee expression", assigneeExpression); + expressions.put("taskAssignee", assigneeExpression); + return this; + } + + @Override + public TaskQuery taskAssigneeLike(String assignee) { + ensureNotNull("Assignee", assignee); + this.assigneeLike = assignee; + expressions.remove("taskAssigneeLike"); + return this; + } + + @Override + public TaskQuery taskAssigneeLikeExpression(String assigneeLikeExpression) { + ensureNotNull("Assignee like expression", assigneeLikeExpression); + expressions.put("taskAssigneeLike", assigneeLikeExpression); + return this; + } + + @Override + public TaskQuery taskAssigneeIn(String... assignees) { + ensureNotNull("Assignees", assignees); + + Set assigneeIn = new HashSet<>(assignees.length); + assigneeIn.addAll(Arrays.asList(assignees)); + + this.assigneeIn = assigneeIn; + expressions.remove("taskAssigneeIn"); + + return this; + } + + @Override + public TaskQuery taskAssigneeNotIn(String... assignees) { + ensureNotNull("Assignees", assignees); + + Set assigneeNotIn = new HashSet<>(assignees.length); + assigneeNotIn.addAll(Arrays.asList(assignees)); + + this.assigneeNotIn = assigneeNotIn; + expressions.remove("taskAssigneeNotIn"); + + return this; + } + + @Override + public TaskQueryImpl taskOwner(String owner) { + ensureNotNull("Owner", owner); + this.owner = owner; + expressions.remove("taskOwner"); + return this; + } + + @Override + public TaskQuery taskOwnerExpression(String ownerExpression) { + ensureNotNull("Owner expression", ownerExpression); + expressions.put("taskOwner", ownerExpression); + return this; + } + + /** @see {@link #taskUnassigned} */ + @Override + @Deprecated + public TaskQuery taskUnnassigned() { + return taskUnassigned(); + } + + @Override + public TaskQuery taskUnassigned() { + this.unassigned = true; + return this; + } + + @Override + public TaskQuery taskAssigned() { + this.assigned = true; + return this; + } + + @Override + public TaskQuery taskDelegationState(DelegationState delegationState) { + if (delegationState == null) { + this.noDelegationState = true; + } else { + this.delegationState = delegationState; + } + return this; + } + + @Override + public TaskQueryImpl taskCandidateUser(String candidateUser) { + ensureNotNull("Candidate user", candidateUser); + if (!isOrQueryActive) { + if (candidateGroup != null || expressions.containsKey("taskCandidateGroup")) { + throw new ProcessEngineException("Invalid query usage: cannot set both candidateUser and candidateGroup"); + } + if (candidateGroups != null || expressions.containsKey("taskCandidateGroupIn")) { + throw new ProcessEngineException("Invalid query usage: cannot set both candidateUser and candidateGroupIn"); + } + } + + this.candidateUser = candidateUser; + expressions.remove("taskCandidateUser"); + return this; + } + + @Override + public TaskQuery taskCandidateUserExpression(String candidateUserExpression) { + ensureNotNull("Candidate user expression", candidateUserExpression); + + if (candidateGroup != null || expressions.containsKey("taskCandidateGroup")) { + throw new ProcessEngineException("Invalid query usage: cannot set both candidateUser and candidateGroup"); + } + if (candidateGroups != null || expressions.containsKey("taskCandidateGroupIn")) { + throw new ProcessEngineException("Invalid query usage: cannot set both candidateUser and candidateGroupIn"); + } + + expressions.put("taskCandidateUser", candidateUserExpression); + return this; + } + + @Override + public TaskQueryImpl taskInvolvedUser(String involvedUser) { + ensureNotNull("Involved user", involvedUser); + this.involvedUser = involvedUser; + expressions.remove("taskInvolvedUser"); + return this; + } + + @Override + public TaskQuery taskInvolvedUserExpression(String involvedUserExpression) { + ensureNotNull("Involved user expression", involvedUserExpression); + expressions.put("taskInvolvedUser", involvedUserExpression); + return this; + } + + @Override + public TaskQuery withCandidateGroups() { + ensureNotInOrQuery("withCandidateGroups()"); + this.withCandidateGroups = true; + return this; + } + + @Override + public TaskQuery withoutCandidateGroups() { + ensureNotInOrQuery("withoutCandidateGroups()"); + this.withoutCandidateGroups = true; + return this; + } + + @Override + public TaskQuery withCandidateUsers() { + ensureNotInOrQuery("withCandidateUsers()"); + this.withCandidateUsers = true; + return this; + } + + @Override + public TaskQuery withoutCandidateUsers() { + ensureNotInOrQuery("withoutCandidateUsers()"); + this.withoutCandidateUsers = true; + return this; + } + + @Override + public TaskQueryImpl taskCandidateGroup(String candidateGroup) { + ensureNotNull("Candidate group", candidateGroup); + + if (!isOrQueryActive) { + if (candidateUser != null || expressions.containsKey("taskCandidateUser")) { + throw new ProcessEngineException("Invalid query usage: cannot set both candidateGroup and candidateUser"); + } + } + + this.candidateGroup = candidateGroup; + expressions.remove("taskCandidateGroup"); + return this; + } + + @Override + public TaskQuery taskCandidateGroupExpression(String candidateGroupExpression) { + ensureNotNull("Candidate group expression", candidateGroupExpression); + + if (!isOrQueryActive) { + if (candidateUser != null || expressions.containsKey("taskCandidateUser")) { + throw new ProcessEngineException("Invalid query usage: cannot set both candidateGroup and candidateUser"); + } + } + + expressions.put("taskCandidateGroup", candidateGroupExpression); + return this; + } + + @Override + public TaskQuery taskCandidateGroupLike(String candidateGroupLike) { + ensureNotNull("Candidate group like", candidateGroupLike); + + if (!isOrQueryActive && (candidateUser != null || expressions.containsKey("taskCandidateUser"))) { + throw new ProcessEngineException("Invalid query usage: cannot set both candidateGroupLike and candidateUser"); + } + + this.candidateGroupLike = candidateGroupLike; + return this; + } + + @Override + public TaskQuery taskCandidateGroupIn(List candidateGroups) { + ensureNotEmpty("Candidate group list", candidateGroups); + + if (!isOrQueryActive) { + if (candidateUser != null || expressions.containsKey("taskCandidateUser")) { + throw new ProcessEngineException("Invalid query usage: cannot set both candidateGroupIn and candidateUser"); + } + } + + this.candidateGroups = candidateGroups; + expressions.remove("taskCandidateGroupIn"); + return this; + } + + @Override + public TaskQuery taskCandidateGroupInExpression(String candidateGroupsExpression) { + ensureNotEmpty("Candidate group list expression", candidateGroupsExpression); + + if (!isOrQueryActive) { + if (candidateUser != null || expressions.containsKey("taskCandidateUser")) { + throw new ProcessEngineException("Invalid query usage: cannot set both candidateGroupIn and candidateUser"); + } + } + + expressions.put("taskCandidateGroupIn", candidateGroupsExpression); + return this; + } + + @Override + public TaskQuery includeAssignedTasks() { + if (candidateUser == null && candidateGroup == null && candidateGroupLike == null && candidateGroups == null + && !isWithCandidateGroups() && !isWithoutCandidateGroups() && !isWithCandidateUsers() && !isWithoutCandidateUsers() + && !expressions.containsKey("taskCandidateUser") && !expressions.containsKey("taskCandidateGroup") + && !expressions.containsKey("taskCandidateGroupIn")) { + throw new ProcessEngineException("Invalid query usage: candidateUser, candidateGroup, candidateGroupLike, candidateGroupIn, withCandidateGroups, withoutCandidateGroups, withCandidateUsers, withoutCandidateUsers has to be called before 'includeAssignedTasks'."); + } + + includeAssignedTasks = true; + return this; + } + + public TaskQuery includeAssignedTasksInternal() { + includeAssignedTasks = true; + return this; + } + + @Override + public TaskQueryImpl processInstanceId(String processInstanceId) { + this.processInstanceId = processInstanceId; + return this; + } + + @Override + public TaskQuery processInstanceIdIn(String... processInstanceIds) { + this.processInstanceIdIn = processInstanceIds; + return this; + } + + @Override + public TaskQueryImpl processInstanceBusinessKey(String processInstanceBusinessKey) { + this.processInstanceBusinessKey = processInstanceBusinessKey; + expressions.remove("processInstanceBusinessKey"); + return this; + } + + @Override + public TaskQuery processInstanceBusinessKeyExpression(String processInstanceBusinessKeyExpression) { + ensureNotNull("processInstanceBusinessKey expression", processInstanceBusinessKeyExpression); + expressions.put("processInstanceBusinessKey", processInstanceBusinessKeyExpression); + return this; + } + + @Override + public TaskQuery processInstanceBusinessKeyIn(String... processInstanceBusinessKeys) { + this.processInstanceBusinessKeys = processInstanceBusinessKeys; + return this; + } + + @Override + public TaskQuery processInstanceBusinessKeyLike(String processInstanceBusinessKey) { + this.processInstanceBusinessKeyLike = processInstanceBusinessKey; + expressions.remove("processInstanceBusinessKeyLike"); + return this; + } + + @Override + public TaskQuery processInstanceBusinessKeyLikeExpression(String processInstanceBusinessKeyLikeExpression) { + ensureNotNull("processInstanceBusinessKeyLike expression", processInstanceBusinessKeyLikeExpression); + expressions.put("processInstanceBusinessKeyLike", processInstanceBusinessKeyLikeExpression); + return this; + } + + @Override + public TaskQueryImpl executionId(String executionId) { + this.executionId = executionId; + return this; + } + + @Override + public TaskQuery activityInstanceIdIn(String... activityInstanceIds) { + this.activityInstanceIdIn = activityInstanceIds; + return this; + } + + @Override + public TaskQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + + // The tenantIdIn filter can't be used in an AND query with + // the withoutTenantId filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (TRUE.equals(isWithoutTenantId)) { + throw new ProcessEngineException("Invalid query usage: cannot set both tenantIdIn and withoutTenantId filters."); + } + } + + this.tenantIds = tenantIds; + return this; + } + + @Override + public TaskQuery withoutTenantId() { + + // The tenantIdIn filter can't be used in an AND query with + // the withoutTenantId filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (tenantIds != null && tenantIds.length > 0) { + throw new ProcessEngineException("Invalid query usage: cannot set both tenantIdIn and withoutTenantId filters."); + } + } + + this.isWithoutTenantId = true; + return this; + } + + @Override + public TaskQueryImpl taskCreatedOn(Date createTime) { + this.createTime = createTime; + expressions.remove("taskCreatedOn"); + return this; + } + + @Override + public TaskQuery taskCreatedOnExpression(String createTimeExpression) { + expressions.put("taskCreatedOn", createTimeExpression); + return this; + } + + @Override + public TaskQuery taskCreatedBefore(Date before) { + this.createTimeBefore = before; + expressions.remove("taskCreatedBefore"); + return this; + } + + @Override + public TaskQuery taskCreatedBeforeExpression(String beforeExpression) { + expressions.put("taskCreatedBefore", beforeExpression); + return this; + } + + @Override + public TaskQuery taskCreatedAfter(Date after) { + this.createTimeAfter = after; + expressions.remove("taskCreatedAfter"); + return this; + } + + @Override + public TaskQuery taskCreatedAfterExpression(String afterExpression) { + expressions.put("taskCreatedAfter", afterExpression); + return this; + } + + @Override + public TaskQuery taskUpdatedAfter(Date after) { + this.updatedAfter = after; + expressions.remove("taskUpdatedAfter"); + return this; + } + + @Override + public TaskQuery taskUpdatedAfterExpression(String afterExpression) { + expressions.put("taskUpdatedAfter", afterExpression); + return this; + } + + @Override + public TaskQuery taskDefinitionKey(String key) { + this.key = key; + return this; + } + + @Override + public TaskQuery taskDefinitionKeyLike(String keyLike) { + this.keyLike = keyLike; + return this; + } + + @Override + public TaskQuery taskDefinitionKeyIn(String... taskDefinitionKeys) { + this.taskDefinitionKeys = taskDefinitionKeys; + return this; + } + + @Override + public TaskQuery taskDefinitionKeyNotIn(String... taskDefinitionKeyNotIn) { + this.taskDefinitionKeyNotIn = taskDefinitionKeyNotIn; + return this; + } + + @Override + public TaskQuery taskParentTaskId(String taskParentTaskId) { + this.parentTaskId = taskParentTaskId; + return this; + } + + @Override + public TaskQuery caseInstanceId(String caseInstanceId) { + ensureNotNull("caseInstanceId", caseInstanceId); + this.caseInstanceId = caseInstanceId; + return this; + } + + @Override + public TaskQuery caseInstanceBusinessKey(String caseInstanceBusinessKey) { + ensureNotNull("caseInstanceBusinessKey", caseInstanceBusinessKey); + this.caseInstanceBusinessKey = caseInstanceBusinessKey; + return this; + } + + @Override + public TaskQuery caseInstanceBusinessKeyLike(String caseInstanceBusinessKeyLike) { + ensureNotNull("caseInstanceBusinessKeyLike", caseInstanceBusinessKeyLike); + this.caseInstanceBusinessKeyLike = caseInstanceBusinessKeyLike; + return this; + } + + @Override + public TaskQuery caseExecutionId(String caseExecutionId) { + ensureNotNull("caseExecutionId", caseExecutionId); + this.caseExecutionId = caseExecutionId; + return this; + } + + @Override + public TaskQuery caseDefinitionId(String caseDefinitionId) { + ensureNotNull("caseDefinitionId", caseDefinitionId); + this.caseDefinitionId = caseDefinitionId; + return this; + } + + @Override + public TaskQuery caseDefinitionKey(String caseDefinitionKey) { + ensureNotNull("caseDefinitionKey", caseDefinitionKey); + this.caseDefinitionKey = caseDefinitionKey; + return this; + } + + @Override + public TaskQuery caseDefinitionName(String caseDefinitionName) { + ensureNotNull("caseDefinitionName", caseDefinitionName); + this.caseDefinitionName = caseDefinitionName; + return this; + } + + @Override + public TaskQuery caseDefinitionNameLike(String caseDefinitionNameLike) { + ensureNotNull("caseDefinitionNameLike", caseDefinitionNameLike); + this.caseDefinitionNameLike = caseDefinitionNameLike; + return this; + } + + @Override + public TaskQuery taskVariableValueEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.EQUALS, true, false); + return this; + } + + @Override + public TaskQuery taskVariableValueNotEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.NOT_EQUALS, true, false); + return this; + } + + @Override + public TaskQuery taskVariableValueLike(String variableName, String variableValue) { + addVariable(variableName, variableValue, QueryOperator.LIKE, true, false); + return this; + } + + @Override + public TaskQuery taskVariableValueGreaterThan(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.GREATER_THAN, true, false); + return this; + } + + @Override + public TaskQuery taskVariableValueGreaterThanOrEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.GREATER_THAN_OR_EQUAL, true, false); + return this; + } + + @Override + public TaskQuery taskVariableValueLessThan(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LESS_THAN, true, false); + return this; + } + + @Override + public TaskQuery taskVariableValueLessThanOrEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LESS_THAN_OR_EQUAL, true, false); + return this; + } + + @Override + public TaskQuery processVariableValueEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.EQUALS, false, true); + return this; + } + + @Override + public TaskQuery processVariableValueNotEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.NOT_EQUALS, false, true); + return this; + } + + @Override + public TaskQuery processVariableValueLike(String variableName, String variableValue) { + addVariable(variableName, variableValue, QueryOperator.LIKE, false, true); + return this; + } + + @Override + public TaskQuery processVariableValueNotLike(String variableName, String variableValue) { + addVariable(variableName, variableValue, QueryOperator.NOT_LIKE, false, true); + return this; + } + + @Override + public TaskQuery processVariableValueGreaterThan(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.GREATER_THAN, false, true); + return this; + } + + @Override + public TaskQuery processVariableValueGreaterThanOrEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.GREATER_THAN_OR_EQUAL, false, true); + return this; + } + + @Override + public TaskQuery processVariableValueLessThan(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LESS_THAN, false, true); + return this; + } + + @Override + public TaskQuery processVariableValueLessThanOrEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LESS_THAN_OR_EQUAL, false, true); + return this; + } + + @Override + public TaskQuery caseInstanceVariableValueEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.EQUALS, false, false); + return this; + } + + @Override + public TaskQuery caseInstanceVariableValueNotEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.NOT_EQUALS, false, false); + return this; + } + + @Override + public TaskQuery caseInstanceVariableValueLike(String variableName, String variableValue) { + addVariable(variableName, variableValue, QueryOperator.LIKE, false, false); + return this; + } + + @Override + public TaskQuery caseInstanceVariableValueNotLike(String variableName, String variableValue) { + addVariable(variableName, variableValue, QueryOperator.NOT_LIKE, false, false); + return this; + } + + @Override + public TaskQuery caseInstanceVariableValueGreaterThan(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.GREATER_THAN, false, false); + return this; + } + + @Override + public TaskQuery caseInstanceVariableValueGreaterThanOrEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.GREATER_THAN_OR_EQUAL, false, false); + return this; + } + + @Override + public TaskQuery caseInstanceVariableValueLessThan(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LESS_THAN, false, false); + return this; + } + + @Override + public TaskQuery caseInstanceVariableValueLessThanOrEquals(String variableName, Object variableValue) { + addVariable(variableName, variableValue, QueryOperator.LESS_THAN_OR_EQUAL, false, false); + return this; + } + + @Override + public TaskQuery processDefinitionKey(String processDefinitionKey) { + this.processDefinitionKey = processDefinitionKey; + return this; + } + + @Override + public TaskQuery processDefinitionKeyIn(String... processDefinitionKeys) { + this.processDefinitionKeys = processDefinitionKeys; + return this; + } + + @Override + public TaskQuery processDefinitionId(String processDefinitionId) { + this.processDefinitionId = processDefinitionId; + return this; + } + + @Override + public TaskQuery processDefinitionName(String processDefinitionName) { + this.processDefinitionName = processDefinitionName; + return this; + } + + @Override + public TaskQuery processDefinitionNameLike(String processDefinitionName) { + this.processDefinitionNameLike = processDefinitionName; + return this; + } + + @Override + public TaskQuery dueDate(Date dueDate) { + // The dueDate filter can't be used in an AND query with + // the withoutDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (TRUE.equals(isWithoutDueDate)) { + throw new ProcessEngineException("Invalid query usage: cannot set both dueDate and withoutDueDate filters."); + } + } + + this.dueDate = dueDate; + expressions.remove("dueDate"); + return this; + } + + @Override + public TaskQuery dueDateExpression(String dueDateExpression) { + // The dueDateExpression filter can't be used in an AND query with + // the withoutDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (TRUE.equals(isWithoutDueDate)) { + throw new ProcessEngineException("Invalid query usage: cannot set both dueDateExpression and withoutDueDate filters."); + } + } + + expressions.put("dueDate", dueDateExpression); + return this; + } + + @Override + public TaskQuery dueBefore(Date dueBefore) { + // The dueBefore filter can't be used in an AND query with + // the withoutDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (TRUE.equals(isWithoutDueDate)) { + throw new ProcessEngineException("Invalid query usage: cannot set both dueBefore and withoutDueDate filters."); + } + } + + this.dueBefore = dueBefore; + expressions.remove("dueBefore"); + return this; + } + + @Override + public TaskQuery dueBeforeExpression(String dueDate) { + // The dueBeforeExpression filter can't be used in an AND query with + // the withoutDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (TRUE.equals(isWithoutDueDate)) { + throw new ProcessEngineException("Invalid query usage: cannot set both dueBeforeExpression and withoutDueDate filters."); + } + } + + expressions.put("dueBefore", dueDate); + return this; + } + + @Override + public TaskQuery dueAfter(Date dueAfter) { + // The dueAfter filter can't be used in an AND query with + // the withoutDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (TRUE.equals(isWithoutDueDate)) { + throw new ProcessEngineException("Invalid query usage: cannot set both dueAfter and withoutDueDate filters."); + } + } + + this.dueAfter = dueAfter; + expressions.remove("dueAfter"); + return this; + } + + @Override + public TaskQuery dueAfterExpression(String dueDateExpression) { + // The dueAfterExpression filter can't be used in an AND query with + // the withoutDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (TRUE.equals(isWithoutDueDate)) { + throw new ProcessEngineException("Invalid query usage: cannot set both dueAfterExpression and withoutDueDate filters."); + } + } + + expressions.put("dueAfter", dueDateExpression); + return this; + } + + @Override + public TaskQuery withoutDueDate() { + // The due date filters can't be used in an AND query with + // the withoutDueDate filter. They can be combined in an OR query + if (!isOrQueryActive) { + if (dueAfter != null || dueBefore != null || dueDate != null || expressions.containsKey("dueDate") + || expressions.containsKey("dueBefore") || expressions.containsKey("dueAfter")) { + throw new ProcessEngineException("Invalid query usage: cannot set both due date (equal to, before, or after) and withoutDueDate filters."); + } + } + + this.isWithoutDueDate = true; + return this; + } + + @Override + public TaskQuery followUpDate(Date followUpDate) { + this.followUpDate = followUpDate; + expressions.remove("followUpDate"); + return this; + } + + @Override + public TaskQuery followUpDateExpression(String followUpDateExpression) { + expressions.put("followUpDate", followUpDateExpression); + return this; + } + + @Override + public TaskQuery followUpBefore(Date followUpBefore) { + this.followUpBefore = followUpBefore; + this.followUpNullAccepted = false; + expressions.remove("followUpBefore"); + return this; + } + + @Override + public TaskQuery followUpBeforeExpression(String followUpBeforeExpression) { + this.followUpNullAccepted = false; + expressions.put("followUpBefore", followUpBeforeExpression); + return this; + } + + @Override + public TaskQuery followUpBeforeOrNotExistent(Date followUpDate) { + this.followUpBefore = followUpDate; + this.followUpNullAccepted = true; + expressions.remove("followUpBeforeOrNotExistent"); + return this; + } + + @Override + public TaskQuery followUpBeforeOrNotExistentExpression(String followUpDateExpression) { + expressions.put("followUpBeforeOrNotExistent", followUpDateExpression); + this.followUpNullAccepted = true; + return this; + } + + public void setFollowUpNullAccepted(boolean followUpNullAccepted) { + this.followUpNullAccepted = followUpNullAccepted; + } + + @Override + public TaskQuery followUpAfter(Date followUpAfter) { + this.followUpAfter = followUpAfter; + expressions.remove("followUpAfter"); + return this; + } + + @Override + public TaskQuery followUpAfterExpression(String followUpAfterExpression) { + expressions.put("followUpAfter", followUpAfterExpression); + return this; + } + + @Override + public TaskQuery excludeSubtasks() { + this.excludeSubtasks = true; + return this; + } + + @Override + public TaskQuery active() { + this.suspensionState = SuspensionState.ACTIVE; + return this; + } + + @Override + public TaskQuery suspended() { + this.suspensionState = SuspensionState.SUSPENDED; + return this; + } + + @Override + public TaskQuery initializeFormKeys() { + ensureNotInOrQuery("initializeFormKeys()"); + this.initializeFormKeys = true; + return this; + } + + public TaskQuery taskNameCaseInsensitive() { + this.taskNameCaseInsensitive = true; + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() + || CompareUtil.areNotInAscendingOrder(minPriority, priority, maxPriority) + || CompareUtil.areNotInAscendingOrder(dueAfter, dueDate, dueBefore) + || CompareUtil.areNotInAscendingOrder(followUpAfter, followUpDate, followUpBefore) + || CompareUtil.areNotInAscendingOrder(createTimeAfter, createTime, createTimeBefore) + || CompareUtil.elementIsNotContainedInArray(key, taskDefinitionKeys) + || CompareUtil.elementIsContainedInArray(key, taskDefinitionKeyNotIn) + || CompareUtil.elementIsNotContainedInArray(processDefinitionKey, processDefinitionKeys) + || CompareUtil.elementIsNotContainedInArray(processInstanceBusinessKey, processInstanceBusinessKeys); + } + + @Override + public TaskQuery withCommentAttachmentInfo() { + this.withCommentAttachmentInfo = true; + return this; + } + + public List getCandidateGroups() { + if (cachedCandidateGroups != null) { + return cachedCandidateGroups; + } + + if (candidateGroup != null && candidateGroups != null) { + cachedCandidateGroups = new ArrayList<>(candidateGroups); + if (!isOrQueryActive) { + // get intersection of candidateGroups and candidateGroup + cachedCandidateGroups.retainAll(Collections.singletonList(candidateGroup)); + } else { + // get union of candidateGroups and candidateGroup + if (!candidateGroups.contains(candidateGroup)) { + cachedCandidateGroups.add(candidateGroup); + } + } + } else if (candidateGroup != null) { + cachedCandidateGroups = Collections.singletonList(candidateGroup); + } else if (candidateGroups != null) { + cachedCandidateGroups = candidateGroups; + } + + if (candidateUser != null) { + List groupsForCandidateUser = getGroupsForCandidateUser(candidateUser); + + if (cachedCandidateGroups == null) { + cachedCandidateGroups = groupsForCandidateUser; + } else { + for (String group : groupsForCandidateUser) { + if (!cachedCandidateGroups.contains(group)) { + cachedCandidateGroups.add(group); + } + } + } + } + + return cachedCandidateGroups; + } + + public Boolean isWithCandidateGroups() { + if (withCandidateGroups == null) { + return false; + } else { + return withCandidateGroups; + } + } + + public Boolean isWithCandidateUsers() { + if (withCandidateUsers == null) { + return false; + } else { + return withCandidateUsers; + } + } + + public Boolean isWithCandidateGroupsInternal() { + return withCandidateGroups; + } + + public Boolean isWithoutCandidateGroups() { + if (withoutCandidateGroups == null) { + return false; + } else { + return withoutCandidateGroups; + } + } + + public Boolean isWithoutCandidateUsers() { + if (withoutCandidateUsers == null) { + return false; + } else { + return withoutCandidateUsers; + } + } + + public Boolean isWithoutCandidateGroupsInternal() { + return withoutCandidateGroups; + } + + public List getCandidateGroupsInternal() { + return candidateGroups; + } + + protected List getGroupsForCandidateUser(String candidateUser) { + Map> cachedUserGroups = getCachedUserGroups(); + if (cachedUserGroups.containsKey(candidateUser)) { + return cachedUserGroups.get(candidateUser); + } + + List groups = Context.getCommandContext() + .getReadOnlyIdentityProvider() + .createGroupQuery() + .groupMember(candidateUser) + .list(); + + List groupIds = new ArrayList<>(); + for (Group group : groups) { + groupIds.add(group.getId()); + } + + cachedUserGroups.put(candidateUser, groupIds); + + return groupIds; + } + + protected Map> getCachedUserGroups() { + // store and retrieve cached user groups always from the first query + if (queries.get(0).cachedUserGroups == null) { + queries.get(0).cachedUserGroups = new HashMap<>(); + } + return queries.get(0).cachedUserGroups; + } + + protected void ensureOrExpressionsEvaluated() { + // skips first query as it has already been evaluated + for (int i = 1; i < queries.size(); i++) { + queries.get(i).validate(); + queries.get(i).evaluateExpressions(); + } + } + + protected void ensureVariablesInitialized() { + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + VariableSerializers variableSerializers = processEngineConfiguration.getVariableSerializers(); + String dbType = processEngineConfiguration.getDatabaseType(); + for(QueryVariableValue var : variables) { + var.initialize(variableSerializers, dbType); + } + + if (!queries.isEmpty()) { + for (TaskQueryImpl orQuery: queries) { + for (QueryVariableValue var : orQuery.variables) { + var.initialize(variableSerializers, dbType); + } + } + } + } + + protected void ensureNotInOrQuery(String methodName) { + if (isOrQueryActive) { + throw new ProcessEngineException(String.format("Invalid query usage: cannot set %s within 'or' query", methodName)); + } + } + + public void addVariable(String name, Object value, QueryOperator operator, boolean isTaskVariable, boolean isProcessInstanceVariable) { + ensureNotNull("name", name); + + if(value == null || isBoolean(value)) { + // Null-values and booleans can only be used in EQUALS and NOT_EQUALS + switch(operator) { + case GREATER_THAN: + throw new ProcessEngineException("Booleans and null cannot be used in 'greater than' condition"); + case LESS_THAN: + throw new ProcessEngineException("Booleans and null cannot be used in 'less than' condition"); + case GREATER_THAN_OR_EQUAL: + throw new ProcessEngineException("Booleans and null cannot be used in 'greater than or equal' condition"); + case LESS_THAN_OR_EQUAL: + throw new ProcessEngineException("Booleans and null cannot be used in 'less than or equal' condition"); + case LIKE: + throw new ProcessEngineException("Booleans and null cannot be used in 'like' condition"); + case NOT_LIKE: + throw new ProcessEngineException("Booleans and null cannot be used in 'not like' condition"); + default: + break; + } + } + + boolean shouldMatchVariableValuesIgnoreCase = TRUE.equals(variableValuesIgnoreCase) && value != null && String.class.isAssignableFrom(value.getClass()); + addVariable(new TaskQueryVariableValue(name, value, operator, isTaskVariable, isProcessInstanceVariable, TRUE.equals(variableNamesIgnoreCase), shouldMatchVariableValuesIgnoreCase)); + } + + protected void addVariable(TaskQueryVariableValue taskQueryVariableValue) { + variables.add(taskQueryVariableValue); + } + + private boolean isBoolean(Object value) { + if (value == null) { + return false; + } + return Boolean.class.isAssignableFrom(value.getClass()) || boolean.class.isAssignableFrom(value.getClass()); + } + + //ordering //////////////////////////////////////////////////////////////// + + @Override + public TaskQuery orderByTaskId() { + ensureNotInOrQuery("orderByTaskId()"); + return orderBy(TaskQueryProperty.TASK_ID); + } + + @Override + public TaskQuery orderByTaskName() { + ensureNotInOrQuery("orderByTaskName()"); + return orderBy(TaskQueryProperty.NAME); + } + + @Override + public TaskQuery orderByTaskNameCaseInsensitive() { + ensureNotInOrQuery("orderByTaskNameCaseInsensitive()"); + taskNameCaseInsensitive(); + return orderBy(TaskQueryProperty.NAME_CASE_INSENSITIVE); + } + + @Override + public TaskQuery orderByTaskDescription() { + ensureNotInOrQuery("orderByTaskDescription()"); + return orderBy(TaskQueryProperty.DESCRIPTION); + } + + @Override + public TaskQuery orderByTaskPriority() { + ensureNotInOrQuery("orderByTaskPriority()"); + return orderBy(TaskQueryProperty.PRIORITY); + } + + @Override + public TaskQuery orderByProcessInstanceId() { + ensureNotInOrQuery("orderByProcessInstanceId()"); + return orderBy(TaskQueryProperty.PROCESS_INSTANCE_ID); + } + + @Override + public TaskQuery orderByCaseInstanceId() { + ensureNotInOrQuery("orderByCaseInstanceId()"); + return orderBy(TaskQueryProperty.CASE_INSTANCE_ID); + } + + @Override + public TaskQuery orderByExecutionId() { + ensureNotInOrQuery("orderByExecutionId()"); + return orderBy(TaskQueryProperty.EXECUTION_ID); + } + + @Override + public TaskQuery orderByTenantId() { + ensureNotInOrQuery("orderByTenantId()"); + return orderBy(TaskQueryProperty.TENANT_ID); + } + + @Override + public TaskQuery orderByCaseExecutionId() { + ensureNotInOrQuery("orderByCaseExecutionId()"); + return orderBy(TaskQueryProperty.CASE_EXECUTION_ID); + } + + @Override + public TaskQuery orderByTaskAssignee() { + ensureNotInOrQuery("orderByTaskAssignee()"); + return orderBy(TaskQueryProperty.ASSIGNEE); + } + + @Override + public TaskQuery orderByTaskCreateTime() { + ensureNotInOrQuery("orderByTaskCreateTime()"); + return orderBy(TaskQueryProperty.CREATE_TIME); + } + + @Override + public TaskQuery orderByLastUpdated() { + ensureNotInOrQuery("orderByLastUpdated()"); + return orderBy(TaskQueryProperty.LAST_UPDATED); + } + + @Override + public TaskQuery orderByDueDate() { + ensureNotInOrQuery("orderByDueDate()"); + return orderBy(TaskQueryProperty.DUE_DATE); + } + + @Override + public TaskQuery orderByFollowUpDate() { + ensureNotInOrQuery("orderByFollowUpDate()"); + return orderBy(TaskQueryProperty.FOLLOW_UP_DATE); + } + + @Override + public TaskQuery orderByProcessVariable(String variableName, ValueType valueType) { + ensureNotInOrQuery("orderByProcessVariable()"); + ensureNotNull("variableName", variableName); + ensureNotNull("valueType", valueType); + + orderBy(VariableOrderProperty.forProcessInstanceVariable(variableName, valueType)); + return this; + } + + @Override + public TaskQuery orderByExecutionVariable(String variableName, ValueType valueType) { + ensureNotInOrQuery("orderByExecutionVariable()"); + ensureNotNull("variableName", variableName); + ensureNotNull("valueType", valueType); + + orderBy(VariableOrderProperty.forExecutionVariable(variableName, valueType)); + return this; + } + + @Override + public TaskQuery orderByTaskVariable(String variableName, ValueType valueType) { + ensureNotInOrQuery("orderByTaskVariable()"); + ensureNotNull("variableName", variableName); + ensureNotNull("valueType", valueType); + + orderBy(VariableOrderProperty.forTaskVariable(variableName, valueType)); + return this; + } + + @Override + public TaskQuery orderByCaseExecutionVariable(String variableName, ValueType valueType) { + ensureNotInOrQuery("orderByCaseExecutionVariable()"); + ensureNotNull("variableName", variableName); + ensureNotNull("valueType", valueType); + + orderBy(VariableOrderProperty.forCaseExecutionVariable(variableName, valueType)); + return this; + } + + @Override + public TaskQuery orderByCaseInstanceVariable(String variableName, ValueType valueType) { + ensureNotInOrQuery("orderByCaseInstanceVariable()"); + ensureNotNull("variableName", variableName); + ensureNotNull("valueType", valueType); + + orderBy(VariableOrderProperty.forCaseInstanceVariable(variableName, valueType)); + return this; + } + + //results //////////////////////////////////////////////////////////////// + + @Override + public List executeList(CommandContext commandContext, Page page) { + ensureOrExpressionsEvaluated(); + ensureVariablesInitialized(); + checkQueryOk(); + + resetCachedCandidateGroups(); + + //check if candidateGroup and candidateGroups intersect + if (getCandidateGroup() != null && getCandidateGroupsInternal() != null && getCandidateGroups().isEmpty()) { + return Collections.emptyList(); + } + + decideAuthorizationJoinType(commandContext); + + List taskList = commandContext + .getTaskManager() + .findTasksByQueryCriteria(this); + + if (initializeFormKeys) { + for (Task task : taskList) { + // initialize the form keys of the tasks + ((TaskEntity) task).initializeFormKey(); + } + } + + if (withCommentAttachmentInfo && !Context.getProcessEngineConfiguration().getHistoryLevel().equals(HistoryLevel.HISTORY_LEVEL_NONE)) { + for (Task task : taskList) { + // verify attachment and comments exists for the task + ((TaskEntity) task).initializeAttachmentAndComments(); + } + } + + return taskList; + } + + @Override + public long executeCount(CommandContext commandContext) { + ensureOrExpressionsEvaluated(); + ensureVariablesInitialized(); + checkQueryOk(); + + resetCachedCandidateGroups(); + + //check if candidateGroup and candidateGroups intersect + if (getCandidateGroup() != null && getCandidateGroupsInternal() != null && getCandidateGroups().isEmpty()) { + return 0; + } + + decideAuthorizationJoinType(commandContext); + + return commandContext + .getTaskManager() + .findTaskCountByQueryCriteria(this); + } + + protected void decideAuthorizationJoinType(CommandContext commandContext) { + boolean cmmnEnabled = commandContext.getProcessEngineConfiguration().isCmmnEnabled(); + authCheck.setUseLeftJoin(cmmnEnabled); + } + + protected void resetCachedCandidateGroups() { + cachedCandidateGroups = null; + for (int i = 1; i < queries.size(); i++) { + queries.get(i).cachedCandidateGroups = null; + } + } + + //getters //////////////////////////////////////////////////////////////// + + public String getName() { + return name; + } + + public String getNameNotEqual() { + return nameNotEqual; + } + + public String getNameLike() { + return nameLike; + } + + public String getNameNotLike() { + return nameNotLike; + } + + public String getAssignee() { + return assignee; + } + + public String getAssigneeLike() { + return assigneeLike; + } + + public Set getAssigneeIn() { + return assigneeIn; + } + + public Set getAssigneeNotIn() { + return assigneeNotIn; + } + + public String getInvolvedUser() { + return involvedUser; + } + + public String getOwner() { + return owner; + } + + public Boolean isAssigned() { + if (assigned == null) { + return false; + } else { + return assigned; + } + } + + public Boolean isAssignedInternal() { + return assigned; + } + + public boolean isUnassigned() { + if (unassigned == null) { + return false; + } + else { + return unassigned; + } + } + + public Boolean isUnassignedInternal() { + return unassigned; + } + + public DelegationState getDelegationState() { + return delegationState; + } + + public boolean isNoDelegationState() { + return noDelegationState; + } + + public String getDelegationStateString() { + return (delegationState!=null ? delegationState.toString() : null); + } + + public String getCandidateUser() { + return candidateUser; + } + + public String getCandidateGroup() { + return candidateGroup; + } + + public String getCandidateGroupLike() { + return candidateGroupLike; + } + + public boolean isIncludeAssignedTasks() { + return includeAssignedTasks != null ? includeAssignedTasks : false; + } + + public Boolean isIncludeAssignedTasksInternal() { + return includeAssignedTasks; + } + + public String getProcessInstanceId() { + return processInstanceId; + } + + public String[] getProcessInstanceIdIn() { + return processInstanceIdIn; + } + + public String getExecutionId() { + return executionId; + } + + public String[] getActivityInstanceIdIn() { + return activityInstanceIdIn; + } + + public String[] getTenantIds() { + return tenantIds; + } + + public String getTaskId() { + return taskId; + } + + public String[] getTaskIdIn() { + return taskIdIn; + } + + public String getDescription() { + return description; + } + + public String getDescriptionLike() { + return descriptionLike; + } + + public Integer getPriority() { + return priority; + } + + public Integer getMinPriority() { + return minPriority; + } + + public Integer getMaxPriority() { + return maxPriority; + } + + public Date getCreateTime() { + return createTime; + } + + public Date getCreateTimeBefore() { + return createTimeBefore; + } + + public Date getCreateTimeAfter() { + return createTimeAfter; + } + + public Date getUpdatedAfter() { + return updatedAfter; + } + + public String getKey() { + return key; + } + + public String[] getKeys() { + return taskDefinitionKeys; + } + + public String[] getKeyNotIn() { + return taskDefinitionKeyNotIn; + } + + public String getKeyLike() { + return keyLike; + } + + public String getParentTaskId() { + return parentTaskId; + } + + public List getVariables() { + return variables; + } + + public String getProcessDefinitionKey() { + return processDefinitionKey; + } + + public String[] getProcessDefinitionKeys() { + return processDefinitionKeys; + } + + public String getProcessDefinitionId() { + return processDefinitionId; + } + + public String getProcessDefinitionName() { + return processDefinitionName; + } + + public String getProcessDefinitionNameLike() { + return processDefinitionNameLike; + } + + public String getProcessInstanceBusinessKey() { + return processInstanceBusinessKey; + } + + public String[] getProcessInstanceBusinessKeys() { + return processInstanceBusinessKeys; + } + + public String getProcessInstanceBusinessKeyLike() { + return processInstanceBusinessKeyLike; + } + + public Date getDueDate() { + return dueDate; + } + + public Date getDueBefore() { + return dueBefore; + } + + public Date getDueAfter() { + return dueAfter; + } + + public Date getFollowUpDate() { + return followUpDate; + } + + public Date getFollowUpBefore() { + return followUpBefore; + } + + public Date getFollowUpAfter() { + return followUpAfter; + } + + public boolean isExcludeSubtasks() { + return excludeSubtasks; + } + + public SuspensionState getSuspensionState() { + return suspensionState; + } + + public String getCaseInstanceId() { + return caseInstanceId; + } + + public String getCaseInstanceBusinessKey() { + return caseInstanceBusinessKey; + } + + public String getCaseInstanceBusinessKeyLike() { + return caseInstanceBusinessKeyLike; + } + + public String getCaseExecutionId() { + return caseExecutionId; + } + + public String getCaseDefinitionId() { + return caseDefinitionId; + } + + public String getCaseDefinitionKey() { + return caseDefinitionKey; + } + + public String getCaseDefinitionName() { + return caseDefinitionName; + } + + public String getCaseDefinitionNameLike() { + return caseDefinitionNameLike; + } + + public boolean isInitializeFormKeys() { + return initializeFormKeys; + } + + public boolean isTaskNameCaseInsensitive() { + return taskNameCaseInsensitive; + } + + public boolean isWithoutTenantId() { + return isWithoutTenantId; + } + + public boolean isWithoutDueDate() { + return isWithoutDueDate; + } + + public String[] getTaskDefinitionKeys() { + return taskDefinitionKeys; + } + + public String[] getTaskDefinitionKeyNotIn() { + return taskDefinitionKeyNotIn; + } + + public boolean getIsTenantIdSet() { + return isWithoutTenantId; + } + + public Boolean isVariableNamesIgnoreCase() { + return variableNamesIgnoreCase; + } + + public Boolean isVariableValuesIgnoreCase() { + return variableValuesIgnoreCase; + } + + public List getQueries() { + return queries; + } + + public boolean isOrQueryActive() { + return isOrQueryActive; + } + + public void addOrQuery(TaskQueryImpl orQuery) { + orQuery.isOrQueryActive = true; + this.queries.add(orQuery); + } + + public void setOrQueryActive() { + isOrQueryActive = true; + } + + @Override + public TaskQuery extend(TaskQuery extending) { + TaskQueryImpl extendingQuery = (TaskQueryImpl) extending; + TaskQueryImpl extendedQuery = new TaskQueryImpl(); + + // only add the base query's validators to the new query; + // this is because the extending query's validators may not be applicable to the base + // query and should therefore be executed before extending the query + extendedQuery.validators = new HashSet<>(validators); + + if (extendingQuery.getName() != null) { + extendedQuery.taskName(extendingQuery.getName()); + } + else if (this.getName() != null) { + extendedQuery.taskName(this.getName()); + } + + if (extendingQuery.getNameLike() != null) { + extendedQuery.taskNameLike(extendingQuery.getNameLike()); + } + else if (this.getNameLike() != null) { + extendedQuery.taskNameLike(this.getNameLike()); + } + + if (extendingQuery.getNameNotEqual() != null) { + extendedQuery.taskNameNotEqual(extendingQuery.getNameNotEqual()); + } + else if (this.getNameNotEqual() != null) { + extendedQuery.taskNameNotEqual(this.getNameNotEqual()); + } + + if (extendingQuery.getNameNotLike() != null) { + extendedQuery.taskNameNotLike(extendingQuery.getNameNotLike()); + } + else if (this.getNameNotLike() != null) { + extendedQuery.taskNameNotLike(this.getNameNotLike()); + } + + if (extendingQuery.getAssignee() != null) { + extendedQuery.taskAssignee(extendingQuery.getAssignee()); + } + else if (this.getAssignee() != null) { + extendedQuery.taskAssignee(this.getAssignee()); + } + + if (extendingQuery.getAssigneeLike() != null) { + extendedQuery.taskAssigneeLike(extendingQuery.getAssigneeLike()); + } + else if (this.getAssigneeLike() != null) { + extendedQuery.taskAssigneeLike(this.getAssigneeLike()); + } + + if (extendingQuery.getAssigneeIn() != null) { + extendedQuery.taskAssigneeIn(extendingQuery + .getAssigneeIn() + .toArray(new String[extendingQuery.getAssigneeIn().size()])); + } + else if (this.getAssigneeIn() != null) { + extendedQuery.taskAssigneeIn(this.getAssigneeIn() + .toArray(new String[this.getAssigneeIn().size()])); + } + if (extendingQuery.getAssigneeNotIn() != null) { + extendedQuery.taskAssigneeNotIn(extendingQuery + .getAssigneeNotIn() + .toArray(new String[extendingQuery.getAssigneeNotIn().size()])); + } + else if (this.getAssigneeNotIn() != null) { + extendedQuery.taskAssigneeNotIn(this.getAssigneeNotIn() + .toArray(new String[this.getAssigneeNotIn().size()])); + } + + if (extendingQuery.getInvolvedUser() != null) { + extendedQuery.taskInvolvedUser(extendingQuery.getInvolvedUser()); + } + else if (this.getInvolvedUser() != null) { + extendedQuery.taskInvolvedUser(this.getInvolvedUser()); + } + + if (extendingQuery.getOwner() != null) { + extendedQuery.taskOwner(extendingQuery.getOwner()); + } + else if (this.getOwner() != null) { + extendedQuery.taskOwner(this.getOwner()); + } + + if (extendingQuery.isAssigned() || this.isAssigned()) { + extendedQuery.taskAssigned(); + } + + if (extendingQuery.isUnassigned() || this.isUnassigned()) { + extendedQuery.taskUnassigned(); + } + + if (extendingQuery.getDelegationState() != null) { + extendedQuery.taskDelegationState(extendingQuery.getDelegationState()); + } + else if (this.getDelegationState() != null) { + extendedQuery.taskDelegationState(this.getDelegationState()); + } + + if (extendingQuery.getCandidateUser() != null) { + extendedQuery.taskCandidateUser(extendingQuery.getCandidateUser()); + } + else if (this.getCandidateUser() != null) { + extendedQuery.taskCandidateUser(this.getCandidateUser()); + } + + if (extendingQuery.getCandidateGroup() != null) { + extendedQuery.taskCandidateGroup(extendingQuery.getCandidateGroup()); + } + else if (this.getCandidateGroup() != null) { + extendedQuery.taskCandidateGroup(this.getCandidateGroup()); + } + + if (extendingQuery.getCandidateGroupLike() != null) { + extendedQuery.taskCandidateGroupLike(extendingQuery.getCandidateGroupLike()); + } + else if (this.getCandidateGroupLike() != null) { + extendedQuery.taskCandidateGroupLike(this.getCandidateGroupLike()); + } + + if (extendingQuery.isWithCandidateGroups() || this.isWithCandidateGroups()) { + extendedQuery.withCandidateGroups(); + } + + if (extendingQuery.isWithCandidateUsers() || this.isWithCandidateUsers()) { + extendedQuery.withCandidateUsers(); + } + + if (extendingQuery.isWithoutCandidateGroups() || this.isWithoutCandidateGroups()) { + extendedQuery.withoutCandidateGroups(); + } + + if (extendingQuery.isWithoutCandidateUsers() || this.isWithoutCandidateUsers()) { + extendedQuery.withoutCandidateUsers(); + } + + if (extendingQuery.getCandidateGroupsInternal() != null) { + extendedQuery.taskCandidateGroupIn(extendingQuery.getCandidateGroupsInternal()); + } + else if (this.getCandidateGroupsInternal() != null) { + extendedQuery.taskCandidateGroupIn(this.getCandidateGroupsInternal()); + } + + if (extendingQuery.getProcessInstanceId() != null) { + extendedQuery.processInstanceId(extendingQuery.getProcessInstanceId()); + } + else if (this.getProcessInstanceId() != null) { + extendedQuery.processInstanceId(this.getProcessInstanceId()); + } + + if (extendingQuery.getProcessInstanceIdIn() != null) { + extendedQuery.processInstanceIdIn(extendingQuery.getProcessInstanceIdIn()); + } else if (this.processInstanceIdIn() != null) { + extendedQuery.processInstanceIdIn(this.getProcessInstanceIdIn()); + } + + if (extendingQuery.getExecutionId() != null) { + extendedQuery.executionId(extendingQuery.getExecutionId()); + } + else if (this.getExecutionId() != null) { + extendedQuery.executionId(this.getExecutionId()); + } + + if (extendingQuery.getActivityInstanceIdIn() != null) { + extendedQuery.activityInstanceIdIn(extendingQuery.getActivityInstanceIdIn()); + } + else if (this.getActivityInstanceIdIn() != null) { + extendedQuery.activityInstanceIdIn(this.getActivityInstanceIdIn()); + } + + if (extendingQuery.getTaskId() != null) { + extendedQuery.taskId(extendingQuery.getTaskId()); + } + else if (this.getTaskId() != null) { + extendedQuery.taskId(this.getTaskId()); + } + + if (extendingQuery.getTaskIdIn() != null) { + extendedQuery.taskIdIn(extendingQuery.getTaskIdIn()); + } else if (this.getTaskIdIn() != null) { + extendedQuery.taskIdIn(this.getTaskIdIn()); + } + + if (extendingQuery.getDescription() != null) { + extendedQuery.taskDescription(extendingQuery.getDescription()); + } + else if (this.getDescription() != null) { + extendedQuery.taskDescription(this.getDescription()); + } + + if (extendingQuery.getDescriptionLike() != null) { + extendedQuery.taskDescriptionLike(extendingQuery.getDescriptionLike()); + } + else if (this.getDescriptionLike() != null) { + extendedQuery.taskDescriptionLike(this.getDescriptionLike()); + } + + if (extendingQuery.getPriority() != null) { + extendedQuery.taskPriority(extendingQuery.getPriority()); + } + else if (this.getPriority() != null) { + extendedQuery.taskPriority(this.getPriority()); + } + + if (extendingQuery.getMinPriority() != null) { + extendedQuery.taskMinPriority(extendingQuery.getMinPriority()); + } + else if (this.getMinPriority() != null) { + extendedQuery.taskMinPriority(this.getMinPriority()); + } + + if (extendingQuery.getMaxPriority() != null) { + extendedQuery.taskMaxPriority(extendingQuery.getMaxPriority()); + } + else if (this.getMaxPriority() != null) { + extendedQuery.taskMaxPriority(this.getMaxPriority()); + } + + if (extendingQuery.getCreateTime() != null) { + extendedQuery.taskCreatedOn(extendingQuery.getCreateTime()); + } + else if (this.getCreateTime() != null) { + extendedQuery.taskCreatedOn(this.getCreateTime()); + } + + if (extendingQuery.getCreateTimeBefore() != null) { + extendedQuery.taskCreatedBefore(extendingQuery.getCreateTimeBefore()); + } + else if (this.getCreateTimeBefore() != null) { + extendedQuery.taskCreatedBefore(this.getCreateTimeBefore()); + } + + if (extendingQuery.getCreateTimeAfter() != null) { + extendedQuery.taskCreatedAfter(extendingQuery.getCreateTimeAfter()); + } + else if (this.getCreateTimeAfter() != null) { + extendedQuery.taskCreatedAfter(this.getCreateTimeAfter()); + } + + if(extendingQuery.getUpdatedAfter() != null) { + extendedQuery.taskUpdatedAfter(extendingQuery.getUpdatedAfter()); + } + else if(this.getUpdatedAfter() != null) { + extendedQuery.taskUpdatedAfter(this.getUpdatedAfter()); + } + + if (extendingQuery.getKey() != null) { + extendedQuery.taskDefinitionKey(extendingQuery.getKey()); + } + else if (this.getKey() != null) { + extendedQuery.taskDefinitionKey(this.getKey()); + } + + if (extendingQuery.getKeyLike() != null) { + extendedQuery.taskDefinitionKeyLike(extendingQuery.getKeyLike()); + } + else if (this.getKeyLike() != null) { + extendedQuery.taskDefinitionKeyLike(this.getKeyLike()); + } + + if (extendingQuery.getKeys() != null) { + extendedQuery.taskDefinitionKeyIn(extendingQuery.getKeys()); + } + else if (this.getKeys() != null) { + extendedQuery.taskDefinitionKeyIn(this.getKeys()); + } + + if (extendingQuery.getKeyNotIn() != null) { + extendedQuery.taskDefinitionKeyNotIn(extendingQuery.getKeyNotIn()); + } + else if (this.getKeyNotIn() != null) { + extendedQuery.taskDefinitionKeyNotIn(this.getKeyNotIn()); + } + + if (extendingQuery.getParentTaskId() != null) { + extendedQuery.taskParentTaskId(extendingQuery.getParentTaskId()); + } + else if (this.getParentTaskId() != null) { + extendedQuery.taskParentTaskId(this.getParentTaskId()); + } + + if (extendingQuery.getProcessDefinitionKey() != null) { + extendedQuery.processDefinitionKey(extendingQuery.getProcessDefinitionKey()); + } + else if (this.getProcessDefinitionKey() != null) { + extendedQuery.processDefinitionKey(this.getProcessDefinitionKey()); + } + + if (extendingQuery.getProcessDefinitionKeys() != null) { + extendedQuery.processDefinitionKeyIn(extendingQuery.getProcessDefinitionKeys()); + } + else if (this.getProcessDefinitionKeys() != null) { + extendedQuery.processDefinitionKeyIn(this.getProcessDefinitionKeys()); + } + + if (extendingQuery.getProcessDefinitionId() != null) { + extendedQuery.processDefinitionId(extendingQuery.getProcessDefinitionId()); + } + else if (this.getProcessDefinitionId() != null) { + extendedQuery.processDefinitionId(this.getProcessDefinitionId()); + } + + if (extendingQuery.getProcessDefinitionName() != null) { + extendedQuery.processDefinitionName(extendingQuery.getProcessDefinitionName()); + } + else if (this.getProcessDefinitionName() != null) { + extendedQuery.processDefinitionName(this.getProcessDefinitionName()); + } + + if (extendingQuery.getProcessDefinitionNameLike() != null) { + extendedQuery.processDefinitionNameLike(extendingQuery.getProcessDefinitionNameLike()); + } + else if (this.getProcessDefinitionNameLike() != null) { + extendedQuery.processDefinitionNameLike(this.getProcessDefinitionNameLike()); + } + + if (extendingQuery.getProcessInstanceBusinessKey() != null) { + extendedQuery.processInstanceBusinessKey(extendingQuery.getProcessInstanceBusinessKey()); + } + else if (this.getProcessInstanceBusinessKey() != null) { + extendedQuery.processInstanceBusinessKey(this.getProcessInstanceBusinessKey()); + } + + if (extendingQuery.getProcessInstanceBusinessKeyLike() != null) { + extendedQuery.processInstanceBusinessKeyLike(extendingQuery.getProcessInstanceBusinessKeyLike()); + } + else if (this.getProcessInstanceBusinessKeyLike() != null) { + extendedQuery.processInstanceBusinessKeyLike(this.getProcessInstanceBusinessKeyLike()); + } + + if (extendingQuery.getDueDate() != null) { + extendedQuery.dueDate(extendingQuery.getDueDate()); + } + else if (this.getDueDate() != null) { + extendedQuery.dueDate(this.getDueDate()); + } + + if (extendingQuery.getDueBefore() != null) { + extendedQuery.dueBefore(extendingQuery.getDueBefore()); + } + else if (this.getDueBefore() != null) { + extendedQuery.dueBefore(this.getDueBefore()); + } + + if (extendingQuery.getDueAfter() != null) { + extendedQuery.dueAfter(extendingQuery.getDueAfter()); + } + else if (this.getDueAfter() != null) { + extendedQuery.dueAfter(this.getDueAfter()); + } + + if (extendingQuery.isWithoutDueDate() || this.isWithoutDueDate()) { + extendedQuery.withoutDueDate(); + } + + if (extendingQuery.getFollowUpDate() != null) { + extendedQuery.followUpDate(extendingQuery.getFollowUpDate()); + } + else if (this.getFollowUpDate() != null) { + extendedQuery.followUpDate(this.getFollowUpDate()); + } + + if (extendingQuery.getFollowUpBefore() != null) { + extendedQuery.followUpBefore(extendingQuery.getFollowUpBefore()); + } + else if (this.getFollowUpBefore() != null) { + extendedQuery.followUpBefore(this.getFollowUpBefore()); + } + + if (extendingQuery.getFollowUpAfter() != null) { + extendedQuery.followUpAfter(extendingQuery.getFollowUpAfter()); + } + else if (this.getFollowUpAfter() != null) { + extendedQuery.followUpAfter(this.getFollowUpAfter()); + } + + if (extendingQuery.isFollowUpNullAccepted() || this.isFollowUpNullAccepted()) { + extendedQuery.setFollowUpNullAccepted(true); + } + + if (extendingQuery.isExcludeSubtasks() || this.isExcludeSubtasks()) { + extendedQuery.excludeSubtasks(); + } + + if (extendingQuery.getSuspensionState() != null) { + if (extendingQuery.getSuspensionState().equals(SuspensionState.ACTIVE)) { + extendedQuery.active(); + } + else if (extendingQuery.getSuspensionState().equals(SuspensionState.SUSPENDED)) { + extendedQuery.suspended(); + } + } + else if (this.getSuspensionState() != null) { + if (this.getSuspensionState().equals(SuspensionState.ACTIVE)) { + extendedQuery.active(); + } + else if (this.getSuspensionState().equals(SuspensionState.SUSPENDED)) { + extendedQuery.suspended(); + } + } + + if (extendingQuery.getCaseInstanceId() != null) { + extendedQuery.caseInstanceId(extendingQuery.getCaseInstanceId()); + } + else if (this.getCaseInstanceId() != null) { + extendedQuery.caseInstanceId(this.getCaseInstanceId()); + } + + if (extendingQuery.getCaseInstanceBusinessKey() != null) { + extendedQuery.caseInstanceBusinessKey(extendingQuery.getCaseInstanceBusinessKey()); + } + else if (this.getCaseInstanceBusinessKey() != null) { + extendedQuery.caseInstanceBusinessKey(this.getCaseInstanceBusinessKey()); + } + + if (extendingQuery.getCaseInstanceBusinessKeyLike() != null) { + extendedQuery.caseInstanceBusinessKeyLike(extendingQuery.getCaseInstanceBusinessKeyLike()); + } + else if (this.getCaseInstanceBusinessKeyLike() != null) { + extendedQuery.caseInstanceBusinessKeyLike(this.getCaseInstanceBusinessKeyLike()); + } + + if (extendingQuery.getCaseExecutionId() != null) { + extendedQuery.caseExecutionId(extendingQuery.getCaseExecutionId()); + } + else if (this.getCaseExecutionId() != null) { + extendedQuery.caseExecutionId(this.getCaseExecutionId()); + } + + if (extendingQuery.getCaseDefinitionId() != null) { + extendedQuery.caseDefinitionId(extendingQuery.getCaseDefinitionId()); + } + else if (this.getCaseDefinitionId() != null) { + extendedQuery.caseDefinitionId(this.getCaseDefinitionId()); + } + + if (extendingQuery.getCaseDefinitionKey() != null) { + extendedQuery.caseDefinitionKey(extendingQuery.getCaseDefinitionKey()); + } + else if (this.getCaseDefinitionKey() != null) { + extendedQuery.caseDefinitionKey(this.getCaseDefinitionKey()); + } + + if (extendingQuery.getCaseDefinitionName() != null) { + extendedQuery.caseDefinitionName(extendingQuery.getCaseDefinitionName()); + } + else if (this.getCaseDefinitionName() != null) { + extendedQuery.caseDefinitionName(this.getCaseDefinitionName()); + } + + if (extendingQuery.getCaseDefinitionNameLike() != null) { + extendedQuery.caseDefinitionNameLike(extendingQuery.getCaseDefinitionNameLike()); + } + else if (this.getCaseDefinitionNameLike() != null) { + extendedQuery.caseDefinitionNameLike(this.getCaseDefinitionNameLike()); + } + + if (extendingQuery.isInitializeFormKeys() || this.isInitializeFormKeys()) { + extendedQuery.initializeFormKeys(); + } + + if (extendingQuery.isTaskNameCaseInsensitive() || this.isTaskNameCaseInsensitive()) { + extendedQuery.taskNameCaseInsensitive(); + } + + if (extendingQuery.getTenantIds() != null) { + extendedQuery.tenantIdIn(extendingQuery.getTenantIds()); + } else if (this.getTenantIds() != null) { + extendedQuery.tenantIdIn(this.getTenantIds()); + } + + if (extendingQuery.isWithoutTenantId() || this.isWithoutTenantId()) { + extendedQuery.withoutTenantId(); + } + + // merge variables + mergeVariables(extendedQuery, extendingQuery); + + // merge expressions + mergeExpressions(extendedQuery, extendingQuery); + + // include taskAssigned tasks has to be set after expression as it asserts on already set + // candidate properties which could be expressions + if (extendingQuery.isIncludeAssignedTasks() || this.isIncludeAssignedTasks()) { + extendedQuery.includeAssignedTasks(); + } + + mergeOrdering(extendedQuery, extendingQuery); + + extendedQuery.queries = new ArrayList<>(Arrays.asList(extendedQuery)); + + if (queries.size() > 1) { + queries.remove(0); + extendedQuery.queries.addAll(queries); + } + + if (extendingQuery.queries.size() > 1) { + extendingQuery.queries.remove(0); + extendedQuery.queries.addAll(extendingQuery.queries); + } + + return extendedQuery; + } + + /** + * Simple implementation of variable merging. Variables are only overridden if they have the same name and are + * in the same scope (ie are process instance, task or case execution variables). + */ + protected void mergeVariables(TaskQueryImpl extendedQuery, TaskQueryImpl extendingQuery) { + List extendingVariables = extendingQuery.getVariables(); + + Set extendingVariablesComparable = new HashSet<>(); + + // set extending variables and save names for comparison of original variables + for (TaskQueryVariableValue extendingVariable : extendingVariables) { + extendedQuery.addVariable(extendingVariable); + extendingVariablesComparable.add(new TaskQueryVariableValueComparable(extendingVariable)); + } + + for (TaskQueryVariableValue originalVariable : this.getVariables()) { + if (!extendingVariablesComparable.contains(new TaskQueryVariableValueComparable(originalVariable))) { + extendedQuery.addVariable(originalVariable); + } + } + + } + + protected class TaskQueryVariableValueComparable { + + protected TaskQueryVariableValue variableValue; + + public TaskQueryVariableValueComparable(TaskQueryVariableValue variableValue) { + this.variableValue = variableValue; + } + + public TaskQueryVariableValue getVariableValue() { + return variableValue; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + TaskQueryVariableValue other = ((TaskQueryVariableValueComparable) o).getVariableValue(); + + return variableValue.getName().equals(other.getName()) + && variableValue.isProcessInstanceVariable() == other.isProcessInstanceVariable() + && variableValue.isLocal() == other.isLocal(); + } + + @Override + public int hashCode() { + int result = variableValue.getName() != null ? variableValue.getName().hashCode() : 0; + result = 31 * result + (variableValue.isProcessInstanceVariable() ? 1 : 0); + result = 31 * result + (variableValue.isLocal() ? 1 : 0); + return result; + } + + } + + public boolean isFollowUpNullAccepted() { + return followUpNullAccepted; + } + + @Override + public TaskQuery taskNameNotEqual(String name) { + this.nameNotEqual = name; + return this; + } + + @Override + public TaskQuery taskNameNotLike(String nameNotLike) { + ensureNotNull("Task nameNotLike", nameNotLike); + this.nameNotLike = nameNotLike; + return this; + } + + /** + * @return true if the query is not supposed to find CMMN or standalone tasks + */ + public boolean isQueryForProcessTasksOnly() { + ProcessEngineConfigurationImpl engineConfiguration = Context.getProcessEngineConfiguration(); + + return !engineConfiguration.isCmmnEnabled() && !engineConfiguration.isStandaloneTasksEnabled(); + } + + @Override + public TaskQuery or() { + if (this != queries.get(0)) { + throw new ProcessEngineException("Invalid query usage: cannot set or() within 'or' query"); + } + + TaskQueryImpl orQuery = new TaskQueryImpl(); + orQuery.isOrQueryActive = true; + orQuery.queries = queries; + queries.add(orQuery); + return orQuery; + } + + @Override + public TaskQuery endOr() { + if (!queries.isEmpty() && this != queries.get(queries.size()-1)) { + throw new ProcessEngineException("Invalid query usage: cannot set endOr() before or()"); + } + + return queries.get(0); + } + + @Override + public TaskQuery matchVariableNamesIgnoreCase() { + this.variableNamesIgnoreCase = true; + for (TaskQueryVariableValue variable : this.variables) { + variable.setVariableNameIgnoreCase(true); + } + return this; + } + + @Override + public TaskQuery matchVariableValuesIgnoreCase() { + this.variableValuesIgnoreCase = true; + for (TaskQueryVariableValue variable : this.variables) { + variable.setVariableValueIgnoreCase(true); + } + return this; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..b8238edb16905e1d8c478ed6b9350924638156e8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryProperty.java @@ -0,0 +1,47 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; +import org.camunda.bpm.engine.task.TaskQuery; + + + +/** + * Contains the possible properties that can be used in a {@link TaskQuery}. + * + * @author Joram Barrez + */ +public interface TaskQueryProperty { + + public static final QueryProperty TASK_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty NAME = new QueryPropertyImpl("NAME_"); + public static final QueryProperty NAME_CASE_INSENSITIVE = new QueryPropertyImpl("NAME_", "LOWER"); + public static final QueryProperty DESCRIPTION = new QueryPropertyImpl("DESCRIPTION_"); + public static final QueryProperty PRIORITY = new QueryPropertyImpl("PRIORITY_"); + public static final QueryProperty ASSIGNEE = new QueryPropertyImpl("ASSIGNEE_"); + public static final QueryProperty CREATE_TIME = new QueryPropertyImpl("CREATE_TIME_"); + public static final QueryProperty LAST_UPDATED = new QueryPropertyImpl("LAST_UPDATED_"); + public static final QueryProperty PROCESS_INSTANCE_ID = new QueryPropertyImpl("PROC_INST_ID_"); + public static final QueryProperty CASE_INSTANCE_ID = new QueryPropertyImpl("CASE_INST_ID_"); + public static final QueryProperty EXECUTION_ID = new QueryPropertyImpl("EXECUTION_ID_"); + public static final QueryProperty CASE_EXECUTION_ID = new QueryPropertyImpl("CASE_EXECUTION_ID_"); + public static final QueryProperty DUE_DATE = new QueryPropertyImpl("DUE_DATE_"); + public static final QueryProperty FOLLOW_UP_DATE = new QueryPropertyImpl("FOLLOW_UP_DATE_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryVariableValue.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryVariableValue.java new file mode 100644 index 0000000000000000000000000000000000000000..020465bed16660432fdb89ed5862d8d6d38d8efd --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskQueryVariableValue.java @@ -0,0 +1,57 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + + + +/** + * Represents a variable value used in a task query. + * + * @author Frederik Heremans + */ +public class TaskQueryVariableValue extends QueryVariableValue { + + private static final long serialVersionUID = 1L; + + protected boolean isProcessInstanceVariable; + + /** + *

The parameters isTaskVariable and isProcessInstanceVariable + * have the following meaning:

+ * + *
    + *
  • if isTaskVariable == true: only query after task variables
  • + *
  • if isTaskVariable == false && isProcessInstanceVariable == true: + * only query after process instance variables
  • + *
  • if isTaskVariable == false && isProcessInstanceVariable == false: + * only query after case instance variables
  • + *
+ */ + public TaskQueryVariableValue(String name, Object value, QueryOperator operator, boolean isTaskVariable, boolean isProcessInstanceVariable) { + this(name, value, operator, isTaskVariable, isProcessInstanceVariable, false, false); + } + + public TaskQueryVariableValue(String name, Object value, QueryOperator operator, boolean isTaskVariable, boolean isProcessInstanceVariable, boolean variableNameIgnoreCase, boolean variableValueIgnoreCase) { + super(name, value, operator, isTaskVariable, variableNameIgnoreCase, variableValueIgnoreCase); + this.isProcessInstanceVariable = isProcessInstanceVariable; + } + + + public boolean isProcessInstanceVariable() { + return isProcessInstanceVariable; + } +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskReportImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskReportImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..10f25a6156dbdc88753cfe87ff51b02bc94c81a2 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskReportImpl.java @@ -0,0 +1,65 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.io.Serializable; +import java.util.List; + +import org.camunda.bpm.engine.impl.db.TenantCheck; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.task.TaskCountByCandidateGroupResult; +import org.camunda.bpm.engine.task.TaskReport; + +/** + * @author Stefan Hentschel + * + */ +public class TaskReportImpl implements Serializable, TaskReport { + + private static final long serialVersionUID = 1L; + + protected transient CommandExecutor commandExecutor; + + protected TenantCheck tenantCheck = new TenantCheck(); + + public TaskReportImpl(CommandExecutor commandExecutor) { + this.commandExecutor = commandExecutor; + } + + protected List createTaskCountByCandidateGroupReport(CommandContext commandContext) { + return commandContext + .getTaskReportManager() + .createTaskCountByCandidateGroupReport(this); + } + + public TenantCheck getTenantCheck() { + return tenantCheck; + } + + public List taskCountByCandidateGroup() { + return commandExecutor.execute(new TaskCountByCandidateGroupCmd()); + } + + protected class TaskCountByCandidateGroupCmd implements Command> { + @Override + public List execute(CommandContext commandContext) { + return createTaskCountByCandidateGroupReport(commandContext); + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskServiceImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..a4f7a929829410f1193c32b96d5a600ebb60f33b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TaskServiceImpl.java @@ -0,0 +1,502 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.TaskService; +import org.camunda.bpm.engine.impl.cmd.AddCommentCmd; +import org.camunda.bpm.engine.impl.cmd.AddGroupIdentityLinkCmd; +import org.camunda.bpm.engine.impl.cmd.AddUserIdentityLinkCmd; +import org.camunda.bpm.engine.impl.cmd.AssignTaskCmd; +import org.camunda.bpm.engine.impl.cmd.ClaimTaskCmd; +import org.camunda.bpm.engine.impl.cmd.CompleteTaskCmd; +import org.camunda.bpm.engine.impl.cmd.CreateAttachmentCmd; +import org.camunda.bpm.engine.impl.cmd.CreateTaskCmd; +import org.camunda.bpm.engine.impl.cmd.DelegateTaskCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteAttachmentCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteGroupIdentityLinkCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteProcessInstanceCommentCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteTaskCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteTaskCommentCmd; +import org.camunda.bpm.engine.impl.cmd.DeleteUserIdentityLinkCmd; +import org.camunda.bpm.engine.impl.cmd.GetAttachmentCmd; +import org.camunda.bpm.engine.impl.cmd.GetAttachmentContentCmd; +import org.camunda.bpm.engine.impl.cmd.GetIdentityLinksForTaskCmd; +import org.camunda.bpm.engine.impl.cmd.GetProcessInstanceAttachmentsCmd; +import org.camunda.bpm.engine.impl.cmd.GetProcessInstanceCommentsCmd; +import org.camunda.bpm.engine.impl.cmd.GetSubTasksCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskAttachmentCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskAttachmentContentCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskAttachmentsCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskCommentCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskCommentsCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskEventsCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskVariableCmd; +import org.camunda.bpm.engine.impl.cmd.GetTaskVariableCmdTyped; +import org.camunda.bpm.engine.impl.cmd.GetTaskVariablesCmd; +import org.camunda.bpm.engine.impl.cmd.HandleTaskBpmnErrorCmd; +import org.camunda.bpm.engine.impl.cmd.HandleTaskEscalationCmd; +import org.camunda.bpm.engine.impl.cmd.PatchTaskVariablesCmd; +import org.camunda.bpm.engine.impl.cmd.RemoveTaskVariablesCmd; +import org.camunda.bpm.engine.impl.cmd.ResolveTaskCmd; +import org.camunda.bpm.engine.impl.cmd.SaveAttachmentCmd; +import org.camunda.bpm.engine.impl.cmd.SaveTaskCmd; +import org.camunda.bpm.engine.impl.cmd.SetTaskDescriptionCmd; +import org.camunda.bpm.engine.impl.cmd.SetTaskDueDateCmd; +import org.camunda.bpm.engine.impl.cmd.SetTaskFollowUpDateCmd; +import org.camunda.bpm.engine.impl.cmd.SetTaskNameCmd; +import org.camunda.bpm.engine.impl.cmd.SetTaskOwnerCmd; +import org.camunda.bpm.engine.impl.cmd.SetTaskPriorityCmd; +import org.camunda.bpm.engine.impl.cmd.SetTaskVariablesCmd; +import org.camunda.bpm.engine.impl.cmd.UpdateCommentCmd; +import org.camunda.bpm.engine.impl.util.ExceptionUtil; +import org.camunda.bpm.engine.task.Attachment; +import org.camunda.bpm.engine.task.Comment; +import org.camunda.bpm.engine.task.Event; +import org.camunda.bpm.engine.task.IdentityLink; +import org.camunda.bpm.engine.task.IdentityLinkType; +import org.camunda.bpm.engine.task.NativeTaskQuery; +import org.camunda.bpm.engine.task.Task; +import org.camunda.bpm.engine.task.TaskQuery; +import org.camunda.bpm.engine.task.TaskReport; +import org.camunda.bpm.engine.variable.VariableMap; +import org.camunda.bpm.engine.variable.value.TypedValue; + + +/** + * @author Tom Baeyens + * @author Joram Barrez + */ +public class TaskServiceImpl extends ServiceImpl implements TaskService { + + public Task newTask() { + return newTask(null); + } + + public Task newTask(String taskId) { + return commandExecutor.execute(new CreateTaskCmd(taskId)); + } + + public void saveTask(Task task) { + commandExecutor.execute(new SaveTaskCmd(task)); + } + + public void deleteTask(String taskId) { + commandExecutor.execute(new DeleteTaskCmd(taskId, null, false)); + } + + public void deleteTasks(Collection taskIds) { + commandExecutor.execute(new DeleteTaskCmd(taskIds, null, false)); + } + + public void deleteTask(String taskId, boolean cascade) { + commandExecutor.execute(new DeleteTaskCmd(taskId, null, cascade)); + } + + public void deleteTasks(Collection taskIds, boolean cascade) { + commandExecutor.execute(new DeleteTaskCmd(taskIds, null, cascade)); + } + + public void deleteTask(String taskId, String deleteReason) { + commandExecutor.execute(new DeleteTaskCmd(taskId, deleteReason, false)); + } + + public void deleteTasks(Collection taskIds, String deleteReason) { + commandExecutor.execute(new DeleteTaskCmd(taskIds, deleteReason, false)); + } + + public void setAssignee(String taskId, String userId) { + commandExecutor.execute(new AssignTaskCmd(taskId, userId)); + } + + public void setOwner(String taskId, String userId) { + commandExecutor.execute(new SetTaskOwnerCmd(taskId, userId)); + } + + public void addCandidateUser(String taskId, String userId) { + commandExecutor.execute(new AddUserIdentityLinkCmd(taskId, userId, IdentityLinkType.CANDIDATE)); + } + + public void addCandidateGroup(String taskId, String groupId) { + commandExecutor.execute(new AddGroupIdentityLinkCmd(taskId, groupId, IdentityLinkType.CANDIDATE)); + } + + public void addUserIdentityLink(String taskId, String userId, String identityLinkType) { + commandExecutor.execute(new AddUserIdentityLinkCmd(taskId, userId, identityLinkType)); + } + + public void addGroupIdentityLink(String taskId, String groupId, String identityLinkType) { + commandExecutor.execute(new AddGroupIdentityLinkCmd(taskId, groupId, identityLinkType)); + } + + public void deleteCandidateGroup(String taskId, String groupId) { + commandExecutor.execute(new DeleteGroupIdentityLinkCmd(taskId, groupId, IdentityLinkType.CANDIDATE)); + } + + public void deleteCandidateUser(String taskId, String userId) { + commandExecutor.execute(new DeleteUserIdentityLinkCmd(taskId, userId, IdentityLinkType.CANDIDATE)); + } + + public void deleteGroupIdentityLink(String taskId, String groupId, String identityLinkType) { + commandExecutor.execute(new DeleteGroupIdentityLinkCmd(taskId, groupId, identityLinkType)); + } + + public void deleteUserIdentityLink(String taskId, String userId, String identityLinkType) { + commandExecutor.execute(new DeleteUserIdentityLinkCmd(taskId, userId, identityLinkType)); + } + + public List getIdentityLinksForTask(String taskId) { + return commandExecutor.execute(new GetIdentityLinksForTaskCmd(taskId)); + } + + public void claim(String taskId, String userId) { + commandExecutor.execute(new ClaimTaskCmd(taskId, userId)); + } + + public void complete(String taskId) { + complete(taskId, null); + } + + public void complete(String taskId, Map variables) { + commandExecutor.execute(new CompleteTaskCmd(taskId, variables, false, false)); + } + + public VariableMap completeWithVariablesInReturn(String taskId, Map variables, boolean deserializeValues) { + return commandExecutor.execute(new CompleteTaskCmd(taskId, variables, true, deserializeValues)); + } + + public void delegateTask(String taskId, String userId) { + commandExecutor.execute(new DelegateTaskCmd(taskId, userId)); + } + + public void resolveTask(String taskId) { + commandExecutor.execute(new ResolveTaskCmd(taskId, null)); + } + + public void resolveTask(String taskId, Map variables) { + commandExecutor.execute(new ResolveTaskCmd(taskId, variables)); + } + + public void setPriority(String taskId, int priority) { + commandExecutor.execute(new SetTaskPriorityCmd(taskId, priority) ); + } + + @Override + public void setName(String taskId, String name) { + commandExecutor.execute(new SetTaskNameCmd(taskId, name)); + } + + @Override + public void setDescription(String taskId, String description) { + commandExecutor.execute(new SetTaskDescriptionCmd(taskId, description)); + } + + @Override + public void setDueDate(String taskId, Date dueDate) { + commandExecutor.execute(new SetTaskDueDateCmd(taskId, dueDate)); + } + + @Override + public void setFollowUpDate(String taskId, Date followUpDate) { + commandExecutor.execute(new SetTaskFollowUpDateCmd(taskId, followUpDate)); + } + + public TaskQuery createTaskQuery() { + return new TaskQueryImpl(commandExecutor); + } + + public NativeTaskQuery createNativeTaskQuery() { + return new NativeTaskQueryImpl(commandExecutor); + } + + public VariableMap getVariables(String taskId) { + return getVariablesTyped(taskId); + } + + public VariableMap getVariablesTyped(String taskId) { + return getVariablesTyped(taskId, true); + } + + public VariableMap getVariablesTyped(String taskId, boolean deserializeValues) { + return commandExecutor.execute(new GetTaskVariablesCmd(taskId, null, false, deserializeValues)); + } + + public VariableMap getVariablesLocal(String taskId) { + return getVariablesLocalTyped(taskId); + } + + public VariableMap getVariablesLocalTyped(String taskId) { + return getVariablesLocalTyped(taskId, true); + } + + public VariableMap getVariablesLocalTyped(String taskId, boolean deserializeValues) { + return commandExecutor.execute(new GetTaskVariablesCmd(taskId, null, true, deserializeValues)); + } + + public VariableMap getVariables(String taskId, Collection variableNames) { + return getVariablesTyped(taskId, variableNames, true); + } + + public VariableMap getVariablesTyped(String taskId, Collection variableNames, boolean deserializeValues) { + return commandExecutor.execute(new GetTaskVariablesCmd(taskId, variableNames, false, deserializeValues)); + } + + public VariableMap getVariablesLocal(String taskId, Collection variableNames) { + return getVariablesLocalTyped(taskId, variableNames, true); + } + + public VariableMap getVariablesLocalTyped(String taskId, Collection variableNames, boolean deserializeValues) { + return commandExecutor.execute(new GetTaskVariablesCmd(taskId, variableNames, true, deserializeValues)); + } + + public Object getVariable(String taskId, String variableName) { + return commandExecutor.execute(new GetTaskVariableCmd(taskId, variableName, false)); + } + + public Object getVariableLocal(String taskId, String variableName) { + return commandExecutor.execute(new GetTaskVariableCmd(taskId, variableName, true)); + } + + public T getVariableTyped(String taskId, String variableName) { + return getVariableTyped(taskId, variableName, false, true); + } + + public T getVariableTyped(String taskId, String variableName, boolean deserializeValue) { + return getVariableTyped(taskId, variableName, false, deserializeValue); + } + + public T getVariableLocalTyped(String taskId, String variableName) { + return getVariableTyped(taskId, variableName, true, true); + } + + public T getVariableLocalTyped(String taskId, String variableName, boolean deserializeValue) { + return getVariableTyped(taskId, variableName, true, deserializeValue); + } + + @SuppressWarnings("unchecked") + protected T getVariableTyped(String taskId, String variableName, boolean isLocal, boolean deserializeValue) { + return (T) commandExecutor.execute(new GetTaskVariableCmdTyped(taskId, variableName, isLocal, deserializeValue)); + } + + public void setVariable(String taskId, String variableName, Object value) { + ensureNotNull("variableName", variableName); + Map variables = new HashMap<>(); + variables.put(variableName, value); + setVariables(taskId, variables, false); + } + + public void setVariableLocal(String taskId, String variableName, Object value) { + ensureNotNull("variableName", variableName); + Map variables = new HashMap<>(); + variables.put(variableName, value); + setVariables(taskId, variables, true); + } + + public void setVariables(String taskId, Map variables) { + setVariables(taskId, variables, false); + } + + public void setVariablesLocal(String taskId, Map variables) { + setVariables(taskId, variables, true); + } + + protected void setVariables(String taskId, Map variables, boolean local) { + try { + commandExecutor.execute(new SetTaskVariablesCmd(taskId, variables, local)); + } catch (ProcessEngineException ex) { + if (ExceptionUtil.checkValueTooLongException(ex)) { + throw new BadUserRequestException("Variable value is too long", ex); + } + throw ex; + } + } + + public void updateVariablesLocal(String taskId, Map modifications, Collection deletions) { + updateVariables(taskId, modifications, deletions, true); + } + + public void updateVariables(String taskId, Map modifications, Collection deletions) { + updateVariables(taskId, modifications, deletions, false); + } + + protected void updateVariables(String taskId, Map modifications, Collection deletions, boolean local) { + try { + commandExecutor.execute(new PatchTaskVariablesCmd(taskId, modifications, deletions, local)); + } catch (ProcessEngineException ex) { + if (ExceptionUtil.checkValueTooLongException(ex)) { + throw new BadUserRequestException("Variable value is too long", ex); + } + throw ex; + } + } + + public void removeVariable(String taskId, String variableName) { + Collection variableNames = new ArrayList<>(); + variableNames.add(variableName); + commandExecutor.execute(new RemoveTaskVariablesCmd(taskId, variableNames, false)); + } + + public void removeVariableLocal(String taskId, String variableName) { + Collection variableNames = new ArrayList<>(1); + variableNames.add(variableName); + commandExecutor.execute(new RemoveTaskVariablesCmd(taskId, variableNames, true)); + } + + public void removeVariables(String taskId, Collection variableNames) { + commandExecutor.execute(new RemoveTaskVariablesCmd(taskId, variableNames, false)); + } + + public void removeVariablesLocal(String taskId, Collection variableNames) { + commandExecutor.execute(new RemoveTaskVariablesCmd(taskId, variableNames, true)); + } + + public void addComment(String taskId, String processInstance, String message) { + createComment(taskId, processInstance, message); + } + + public Comment createComment(String taskId, String processInstance, String message) { + return commandExecutor.execute(new AddCommentCmd(taskId, processInstance, message)); + } + + public void deleteTaskComment(String taskId, String commentId) { + commandExecutor.execute(new DeleteTaskCommentCmd(taskId, commentId)); + } + + public void deleteProcessInstanceComment(String processInstanceId, String commentId) { + commandExecutor.execute(new DeleteProcessInstanceCommentCmd(processInstanceId, commentId)); + } + + public void deleteTaskComments(String taskId) { + commandExecutor.execute(new DeleteTaskCommentCmd(taskId)); + } + + public void deleteProcessInstanceComments(String processInstanceId) { + commandExecutor.execute(new DeleteProcessInstanceCommentCmd(processInstanceId)); + } + + public void updateTaskComment(String taskId, String commentId, String message) { + commandExecutor.execute(new UpdateCommentCmd(taskId, null, commentId, message)); + } + + public void updateProcessInstanceComment(String processInstanceId, String commentId, String message) { + commandExecutor.execute(new UpdateCommentCmd(null, processInstanceId, commentId, message)); + } + + public List getTaskComments(String taskId) { + return commandExecutor.execute(new GetTaskCommentsCmd(taskId)); + } + + public Comment getTaskComment(String taskId, String commentId) { + return commandExecutor.execute(new GetTaskCommentCmd(taskId, commentId)); + } + + public List getTaskEvents(String taskId) { + return commandExecutor.execute(new GetTaskEventsCmd(taskId)); + } + + public List getProcessInstanceComments(String processInstanceId) { + return commandExecutor.execute(new GetProcessInstanceCommentsCmd(processInstanceId)); + } + + public Attachment createAttachment(String attachmentType, String taskId, String processInstanceId, String attachmentName, String attachmentDescription, InputStream content) { + return commandExecutor.execute(new CreateAttachmentCmd(attachmentType, taskId, processInstanceId, attachmentName, attachmentDescription, content, null)); + } + + public Attachment createAttachment(String attachmentType, String taskId, String processInstanceId, String attachmentName, String attachmentDescription, String url) { + return commandExecutor.execute(new CreateAttachmentCmd(attachmentType, taskId, processInstanceId, attachmentName, attachmentDescription, null, url)); + } + + public InputStream getAttachmentContent(String attachmentId) { + return commandExecutor.execute(new GetAttachmentContentCmd(attachmentId)); + } + + public InputStream getTaskAttachmentContent(String taskId, String attachmentId) { + return commandExecutor.execute(new GetTaskAttachmentContentCmd(taskId, attachmentId)); + } + + public void deleteAttachment(String attachmentId) { + commandExecutor.execute(new DeleteAttachmentCmd(attachmentId)); + } + + public void deleteTaskAttachment(String taskId, String attachmentId) { + commandExecutor.execute(new DeleteAttachmentCmd(taskId, attachmentId)); + } + + public Attachment getAttachment(String attachmentId) { + return commandExecutor.execute(new GetAttachmentCmd(attachmentId)); + } + + public Attachment getTaskAttachment(String taskId, String attachmentId) { + return commandExecutor.execute(new GetTaskAttachmentCmd(taskId, attachmentId)); + } + + public List getTaskAttachments(String taskId) { + return commandExecutor.execute(new GetTaskAttachmentsCmd(taskId)); + } + + public List getProcessInstanceAttachments(String processInstanceId) { + return commandExecutor.execute(new GetProcessInstanceAttachmentsCmd(processInstanceId)); + } + + public void saveAttachment(Attachment attachment) { + commandExecutor.execute(new SaveAttachmentCmd(attachment)); + } + + public List getSubTasks(String parentTaskId) { + return commandExecutor.execute(new GetSubTasksCmd(parentTaskId)); + } + + public TaskReport createTaskReport() { + return new TaskReportImpl(commandExecutor); + } + + @Override + public void handleBpmnError(String taskId, String errorCode) { + commandExecutor.execute(new HandleTaskBpmnErrorCmd(taskId, errorCode)); + } + + @Override + public void handleBpmnError(String taskId, String errorCode, String errorMessage) { + commandExecutor.execute(new HandleTaskBpmnErrorCmd(taskId, errorCode, errorMessage)); + } + + @Override + public void handleBpmnError(String taskId, String errorCode, String errorMessage, Map variables) { + commandExecutor.execute(new HandleTaskBpmnErrorCmd(taskId, errorCode, errorMessage, variables)); + } + + @Override + public void handleEscalation(String taskId, String escalationCode) { + commandExecutor.execute(new HandleTaskEscalationCmd(taskId, escalationCode)); + } + + @Override + public void handleEscalation(String taskId, String escalationCode, Map variables) { + commandExecutor.execute(new HandleTaskEscalationCmd(taskId, escalationCode, variables)); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TenantQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TenantQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..3bf82bac6b9693a0ecb31b738221245d72be18d6 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TenantQueryImpl.java @@ -0,0 +1,124 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import org.camunda.bpm.engine.identity.Tenant; +import org.camunda.bpm.engine.identity.TenantQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + +public abstract class TenantQueryImpl extends AbstractQuery implements TenantQuery { + + private static final long serialVersionUID = 1L; + protected String id; + protected String[] ids; + protected String name; + protected String nameLike; + protected String userId; + protected String groupId; + protected boolean includingGroups = false; + + public TenantQueryImpl() { + } + + public TenantQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public TenantQuery tenantId(String id) { + ensureNotNull("tenant ud", id); + this.id = id; + return this; + } + + public TenantQuery tenantIdIn(String... ids) { + ensureNotNull("tenant ids", (Object[]) ids); + this.ids = ids; + return this; + } + + public TenantQuery tenantName(String name) { + ensureNotNull("tenant name", name); + this.name = name; + return this; + } + + public TenantQuery tenantNameLike(String nameLike) { + ensureNotNull("tenant name like", nameLike); + this.nameLike = nameLike; + return this; + } + + public TenantQuery userMember(String userId) { + ensureNotNull("user id", userId); + this.userId = userId; + return this; + } + + public TenantQuery groupMember(String groupId) { + ensureNotNull("group id", groupId); + this.groupId = groupId; + return this; + } + + public TenantQuery includingGroupsOfUser(boolean includingGroups) { + this.includingGroups = includingGroups; + return this; + } + + //sorting //////////////////////////////////////////////////////// + + public TenantQuery orderByTenantId() { + return orderBy(TenantQueryProperty.GROUP_ID); + } + + public TenantQuery orderByTenantName() { + return orderBy(TenantQueryProperty.NAME); + } + + //getters //////////////////////////////////////////////////////// + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getNameLike() { + return nameLike; + } + + public String[] getIds() { + return ids; + } + + public String getUserId() { + return userId; + } + + public String getGroupId() { + return groupId; + } + + public boolean isIncludingGroups() { + return includingGroups; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TenantQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TenantQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..91d7e6b58efd779be8d6b1faa393eaeae4c8f2f4 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/TenantQueryProperty.java @@ -0,0 +1,30 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.identity.TenantQuery; +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * Contains the possible properties that can be used by the {@link TenantQuery}. + */ +public interface TenantQueryProperty { + + public static final QueryProperty GROUP_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty NAME = new QueryPropertyImpl("NAME_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UpdateProcessInstancesSuspensionStateBuilderImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UpdateProcessInstancesSuspensionStateBuilderImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ace1b13c96d62a8df83feff0b69191ac789b0f39 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UpdateProcessInstancesSuspensionStateBuilderImpl.java @@ -0,0 +1,103 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.history.HistoricProcessInstanceQuery; +import org.camunda.bpm.engine.impl.cmd.UpdateProcessInstancesSuspendStateBatchCmd; +import org.camunda.bpm.engine.impl.cmd.UpdateProcessInstancesSuspendStateCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.runtime.ProcessInstanceQuery; +import org.camunda.bpm.engine.runtime.UpdateProcessInstancesSuspensionStateBuilder; + +public class UpdateProcessInstancesSuspensionStateBuilderImpl implements UpdateProcessInstancesSuspensionStateBuilder { + + protected List processInstanceIds; + protected ProcessInstanceQuery processInstanceQuery; + protected HistoricProcessInstanceQuery historicProcessInstanceQuery; + protected CommandExecutor commandExecutor; + protected String processDefinitionId; + + public UpdateProcessInstancesSuspensionStateBuilderImpl(CommandExecutor commandExecutor) { + this.processInstanceIds = new ArrayList(); + this.commandExecutor = commandExecutor; + } + + public UpdateProcessInstancesSuspensionStateBuilderImpl(List processInstanceIds) { + this.processInstanceIds = processInstanceIds; + } + + @Override + public UpdateProcessInstancesSuspensionStateBuilder byProcessInstanceIds(List processInstanceIds) { + this.processInstanceIds.addAll(processInstanceIds); + return this; + } + + @Override + public UpdateProcessInstancesSuspensionStateBuilder byProcessInstanceIds(String... processInstanceIds) { + this.processInstanceIds.addAll(Arrays.asList(processInstanceIds)); + return this; + } + + @Override + public UpdateProcessInstancesSuspensionStateBuilder byProcessInstanceQuery(ProcessInstanceQuery processInstanceQuery) { + this.processInstanceQuery = processInstanceQuery; + return this; + } + + @Override + public UpdateProcessInstancesSuspensionStateBuilder byHistoricProcessInstanceQuery(HistoricProcessInstanceQuery historicProcessInstanceQuery) { + this.historicProcessInstanceQuery = historicProcessInstanceQuery; + return this; + } + + @Override + public void suspend() { + commandExecutor.execute(new UpdateProcessInstancesSuspendStateCmd(commandExecutor, this, true)); + } + + @Override + public void activate() { + commandExecutor.execute(new UpdateProcessInstancesSuspendStateCmd(commandExecutor, this, false)); + } + + @Override + public Batch suspendAsync() { + return commandExecutor.execute(new UpdateProcessInstancesSuspendStateBatchCmd(commandExecutor, this, true)); + } + + @Override + public Batch activateAsync() { + return commandExecutor.execute(new UpdateProcessInstancesSuspendStateBatchCmd(commandExecutor, this, false)); + } + + public List getProcessInstanceIds() { + return processInstanceIds; + } + + public ProcessInstanceQuery getProcessInstanceQuery() { + return processInstanceQuery; + } + + public HistoricProcessInstanceQuery getHistoricProcessInstanceQuery() { + return historicProcessInstanceQuery; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UserOperationLogQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UserOperationLogQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..eca41d1d7ac90b25570509898ac833ddff769f33 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UserOperationLogQueryImpl.java @@ -0,0 +1,246 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.Date; +import java.util.List; +import org.camunda.bpm.engine.history.UserOperationLogEntry; +import org.camunda.bpm.engine.history.UserOperationLogQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.util.CompareUtil; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + + +/** + * @author Danny Gräf + */ +public class UserOperationLogQueryImpl extends AbstractQuery implements UserOperationLogQuery { + + private static final long serialVersionUID = 1L; + protected String deploymentId; + protected String processDefinitionId; + protected String processDefinitionKey; + protected String processInstanceId; + protected String executionId; + protected String caseDefinitionId; + protected String caseInstanceId; + protected String caseExecutionId; + protected String taskId; + protected String jobId; + protected String jobDefinitionId; + protected String batchId; + protected String userId; + protected String operationId; + protected String externalTaskId; + protected String operationType; + protected String property; + protected String entityType; + protected String category; + protected Date timestampAfter; + protected Date timestampBefore; + protected String[] tenantIds; + protected boolean isTenantIdSet; + + protected String[] entityTypes; + protected String[] categories; + + public UserOperationLogQueryImpl() { + } + + public UserOperationLogQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public UserOperationLogQuery deploymentId(String deploymentId) { + ensureNotNull("deploymentId", deploymentId); + this.deploymentId = deploymentId; + return this; + } + + public UserOperationLogQuery processDefinitionId(String processDefinitionId) { + ensureNotNull("processDefinitionId", processDefinitionId); + this.processDefinitionId = processDefinitionId; + return this; + } + + public UserOperationLogQuery processDefinitionKey(String processDefinitionKey) { + ensureNotNull("processDefinitionKey", processDefinitionKey); + this.processDefinitionKey = processDefinitionKey; + return this; + } + + public UserOperationLogQuery processInstanceId(String processInstanceId) { + ensureNotNull("processInstanceId", processInstanceId); + this.processInstanceId = processInstanceId; + return this; + } + + public UserOperationLogQuery executionId(String executionId) { + ensureNotNull("executionId", executionId); + this.executionId = executionId; + return this; + } + + public UserOperationLogQuery caseDefinitionId(String caseDefinitionId) { + ensureNotNull("caseDefinitionId", caseDefinitionId); + this.caseDefinitionId = caseDefinitionId; + return this; + } + + public UserOperationLogQuery caseInstanceId(String caseInstanceId) { + ensureNotNull("caseInstanceId", caseInstanceId); + this.caseInstanceId = caseInstanceId; + return this; + } + + public UserOperationLogQuery caseExecutionId(String caseExecutionId) { + ensureNotNull("caseExecutionId", caseExecutionId); + this.caseExecutionId = caseExecutionId; + return this; + } + + + public UserOperationLogQuery taskId(String taskId) { + ensureNotNull("taskId", taskId); + this.taskId = taskId; + return this; + } + + public UserOperationLogQuery jobId(String jobId) { + ensureNotNull("jobId", jobId); + this.jobId = jobId; + return this; + } + + public UserOperationLogQuery jobDefinitionId(String jobDefinitionId) { + ensureNotNull("jobDefinitionId", jobDefinitionId); + this.jobDefinitionId = jobDefinitionId; + return this; + } + + public UserOperationLogQuery batchId(String batchId) { + ensureNotNull("batchId", batchId); + this.batchId = batchId; + return this; + } + + public UserOperationLogQuery userId(String userId) { + ensureNotNull("userId", userId); + this.userId = userId; + return this; + } + + public UserOperationLogQuery operationId(String operationId) { + ensureNotNull("operationId", operationId); + this.operationId = operationId; + return this; + } + + public UserOperationLogQuery externalTaskId(String externalTaskId) { + ensureNotNull("externalTaskId", externalTaskId); + this.externalTaskId = externalTaskId; + return this; + } + + public UserOperationLogQuery operationType(String operationType) { + ensureNotNull("operationType", operationType); + this.operationType = operationType; + return this; + } + + public UserOperationLogQuery property(String property) { + ensureNotNull("property", property); + this.property = property; + return this; + } + + public UserOperationLogQuery entityType(String entityType) { + ensureNotNull("entityType", entityType); + this.entityType = entityType; + return this; + } + + public UserOperationLogQuery entityTypeIn(String... entityTypes) { + ensureNotNull("entity types", (Object[]) entityTypes); + this.entityTypes = entityTypes; + return this; + } + + public UserOperationLogQuery category(String category) { + ensureNotNull("category", category); + this.category = category; + return this; + } + + public UserOperationLogQuery categoryIn(String... categories) { + ensureNotNull("categories", (Object[]) categories); + this.categories = categories; + return this; + } + + public UserOperationLogQuery afterTimestamp(Date after) { + this.timestampAfter = after; + return this; + } + + public UserOperationLogQuery beforeTimestamp(Date before) { + this.timestampBefore = before; + return this; + } + + public UserOperationLogQuery orderByTimestamp() { + return orderBy(OperationLogQueryProperty.TIMESTAMP); + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getOperationLogManager() + .findOperationLogEntryCountByQueryCriteria(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getOperationLogManager() + .findOperationLogEntriesByQueryCriteria(this, page); + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public UserOperationLogQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + this.isTenantIdSet = true; + return this; + } + + public UserOperationLogQuery withoutTenantId() { + this.tenantIds = null; + this.isTenantIdSet = true; + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() || CompareUtil.areNotInAscendingOrder(timestampAfter, timestampBefore); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UserQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UserQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..bb9fc48b8e7cbc285c52d7300c7e3b8db76c6e8e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UserQueryImpl.java @@ -0,0 +1,165 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import org.camunda.bpm.engine.identity.User; +import org.camunda.bpm.engine.identity.UserQuery; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + + +/** + * @author Joram Barrez + */ +public abstract class UserQueryImpl extends AbstractQuery implements UserQuery { + + private static final long serialVersionUID = 1L; + protected String id; + protected String[] ids; + protected String firstName; + protected String firstNameLike; + protected String lastName; + protected String lastNameLike; + protected String email; + protected String emailLike; + protected String groupId; + protected String procDefId; + protected String tenantId; + + public UserQueryImpl() { + } + + public UserQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public UserQuery userId(String id) { + ensureNotNull("Provided id", id); + this.id = id; + return this; + } + + public UserQuery userIdIn(String... ids) { + ensureNotNull("Provided ids", ids); + this.ids = ids; + return this; + } + + public UserQuery userFirstName(String firstName) { + this.firstName = firstName; + return this; + } + + public UserQuery userFirstNameLike(String firstNameLike) { + ensureNotNull("Provided firstNameLike", firstNameLike); + this.firstNameLike = firstNameLike; + return this; + } + + public UserQuery userLastName(String lastName) { + this.lastName = lastName; + return this; + } + + public UserQuery userLastNameLike(String lastNameLike) { + ensureNotNull("Provided lastNameLike", lastNameLike); + this.lastNameLike = lastNameLike; + return this; + } + + public UserQuery userEmail(String email) { + this.email = email; + return this; + } + + public UserQuery userEmailLike(String emailLike) { + ensureNotNull("Provided emailLike", emailLike); + this.emailLike = emailLike; + return this; + } + + public UserQuery memberOfGroup(String groupId) { + ensureNotNull("Provided groupId", groupId); + this.groupId = groupId; + return this; + } + + public UserQuery potentialStarter(String procDefId) { + ensureNotNull("Provided processDefinitionId", procDefId); + this.procDefId = procDefId; + return this; + + } + + public UserQuery memberOfTenant(String tenantId) { + ensureNotNull("Provided tenantId", tenantId); + this.tenantId = tenantId; + return this; + } + + //sorting ////////////////////////////////////////////////////////// + + public UserQuery orderByUserId() { + return orderBy(UserQueryProperty.USER_ID); + } + + public UserQuery orderByUserEmail() { + return orderBy(UserQueryProperty.EMAIL); + } + + public UserQuery orderByUserFirstName() { + return orderBy(UserQueryProperty.FIRST_NAME); + } + + public UserQuery orderByUserLastName() { + return orderBy(UserQueryProperty.LAST_NAME); + } + + //getters ////////////////////////////////////////////////////////// + + public String getId() { + return id; + } + public String[] getIds() { + return ids; + } + public String getFirstName() { + return firstName; + } + public String getFirstNameLike() { + return firstNameLike; + } + public String getLastName() { + return lastName; + } + public String getLastNameLike() { + return lastNameLike; + } + public String getEmail() { + return email; + } + public String getEmailLike() { + return emailLike; + } + public String getGroupId() { + return groupId; + } + public String getTenantId() { + return tenantId; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UserQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UserQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..b84a6c2017ca08d5a91d8dff1f036b8dd2a3afb2 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/UserQueryProperty.java @@ -0,0 +1,36 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.identity.UserQuery; +import org.camunda.bpm.engine.query.QueryProperty; + + + +/** + * Contains the possible properties that can be used by the {@link UserQuery}. + * + * @author Joram Barrez + */ +public interface UserQueryProperty { + + public static final QueryProperty USER_ID = new QueryPropertyImpl("ID_"); + public static final QueryProperty FIRST_NAME = new QueryPropertyImpl("FIRST_"); + public static final QueryProperty LAST_NAME = new QueryPropertyImpl("LAST_"); + public static final QueryProperty EMAIL = new QueryPropertyImpl("EMAIL_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Validator.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Validator.java new file mode 100644 index 0000000000000000000000000000000000000000..9e0ff8a78878d6ac3cebcd5924d88485d208878b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/Validator.java @@ -0,0 +1,30 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + + +/** + * Validators must be equal (in terms of {@link #equals(Object)}) if they validate + * the exact same thing. + * + * @author Thorben Lindhauer + */ +public interface Validator { + + void validate(T obj); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/VariableInstanceQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/VariableInstanceQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ab9d133610b6c825b82c3a159728aeb875ab162d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/VariableInstanceQueryImpl.java @@ -0,0 +1,267 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.io.Serializable; +import java.util.List; + +import org.camunda.bpm.engine.impl.cmd.CommandLogger; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity; +import org.camunda.bpm.engine.impl.util.CompareUtil; +import org.camunda.bpm.engine.impl.variable.serializer.AbstractTypedValueSerializer; +import org.camunda.bpm.engine.runtime.VariableInstance; +import org.camunda.bpm.engine.runtime.VariableInstanceQuery; + +/** + * @author roman.smirnov + */ +public class VariableInstanceQueryImpl extends AbstractVariableQueryImpl implements VariableInstanceQuery, Serializable { + + private final static CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; + + private static final long serialVersionUID = 1L; + + protected String variableId; + protected String variableName; + protected String[] variableNames; + protected String variableNameLike; + protected String[] executionIds; + protected String[] processInstanceIds; + protected String[] caseExecutionIds; + protected String[] caseInstanceIds; + protected String[] taskIds; + protected String[] batchIds; + protected String[] variableScopeIds; + protected String[] activityInstanceIds; + protected String[] tenantIds; + + protected boolean isByteArrayFetchingEnabled = true; + protected boolean isCustomObjectDeserializationEnabled = true; + + public VariableInstanceQueryImpl() { } + + public VariableInstanceQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public VariableInstanceQuery variableId(String id) { + ensureNotNull("id", id); + this.variableId = id; + return this; + } + + public VariableInstanceQuery variableName(String variableName) { + this.variableName = variableName; + return this; + } + + public VariableInstanceQuery variableNameIn(String... variableNames) { + this.variableNames = variableNames; + return this; + } + + public VariableInstanceQuery variableNameLike(String variableNameLike) { + this.variableNameLike = variableNameLike; + return this; + } + + public VariableInstanceQuery executionIdIn(String... executionIds) { + this.executionIds = executionIds; + return this; + } + + public VariableInstanceQuery processInstanceIdIn(String... processInstanceIds) { + this.processInstanceIds = processInstanceIds; + return this; + } + + public VariableInstanceQuery caseExecutionIdIn(String... caseExecutionIds) { + this.caseExecutionIds = caseExecutionIds; + return this; + } + + public VariableInstanceQuery caseInstanceIdIn(String... caseInstanceIds) { + this.caseInstanceIds = caseInstanceIds; + return this; + } + + public VariableInstanceQuery taskIdIn(String... taskIds) { + this.taskIds = taskIds; + return this; + } + + @Override + public VariableInstanceQuery batchIdIn(String... batchIds) { + this.batchIds = batchIds; + return this; + } + + public VariableInstanceQuery variableScopeIdIn(String... variableScopeIds) { + this.variableScopeIds = variableScopeIds; + return this; + } + + public VariableInstanceQuery activityInstanceIdIn(String... activityInstanceIds) { + this.activityInstanceIds = activityInstanceIds; + return this; + } + + public VariableInstanceQuery disableBinaryFetching() { + this.isByteArrayFetchingEnabled = false; + return this; + } + + public VariableInstanceQuery disableCustomObjectDeserialization() { + this.isCustomObjectDeserializationEnabled = false; + return this; + } + + public VariableInstanceQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + return this; + } + + // ordering //////////////////////////////////////////////////// + + public VariableInstanceQuery orderByVariableName() { + orderBy(VariableInstanceQueryProperty.VARIABLE_NAME); + return this; + } + + public VariableInstanceQuery orderByVariableType() { + orderBy(VariableInstanceQueryProperty.VARIABLE_TYPE); + return this; + } + + public VariableInstanceQuery orderByActivityInstanceId() { + orderBy(VariableInstanceQueryProperty.ACTIVITY_INSTANCE_ID); + return this; + } + + public VariableInstanceQuery orderByTenantId() { + orderBy(VariableInstanceQueryProperty.TENANT_ID); + return this; + } + + @Override + protected boolean hasExcludingConditions() { + return super.hasExcludingConditions() || CompareUtil.elementIsNotContainedInArray(variableName, variableNames); + } + + // results //////////////////////////////////////////////////// + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + ensureVariablesInitialized(); + return commandContext + .getVariableInstanceManager() + .findVariableInstanceCountByQueryCriteria(this); + } + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + ensureVariablesInitialized(); + List result = commandContext + .getVariableInstanceManager() + .findVariableInstanceByQueryCriteria(this, page); + + if (result == null) { + return result; + } + + // iterate over the result array to initialize the value and serialized value of the variable + for (VariableInstance variableInstance : result) { + VariableInstanceEntity variableInstanceEntity = (VariableInstanceEntity) variableInstance; + + if (shouldFetchValue(variableInstanceEntity)) { + try { + variableInstanceEntity.getTypedValue(isCustomObjectDeserializationEnabled); + + } catch(Exception t) { + // do not fail if one of the variables fails to load + LOG.exceptionWhileGettingValueForVariable(t); + } + } + + } + + return result; + } + + protected boolean shouldFetchValue(VariableInstanceEntity entity) { + // do not fetch values for byte arrays eagerly (unless requested by the user) + return isByteArrayFetchingEnabled + || !AbstractTypedValueSerializer.BINARY_VALUE_TYPES.contains(entity.getSerializer().getType().getName()); + } + + // getters //////////////////////////////////////////////////// + + public String getVariableId() { + return variableId; + } + + public String getVariableName() { + return variableName; + } + + public String[] getVariableNames() { + return variableNames; + } + + public String getVariableNameLike() { + return variableNameLike; + } + + public String[] getExecutionIds() { + return executionIds; + } + + public String[] getProcessInstanceIds() { + return processInstanceIds; + } + + public String[] getCaseExecutionIds() { + return caseExecutionIds; + } + + public String[] getCaseInstanceIds() { + return caseInstanceIds; + } + + public String[] getTaskIds() { + return taskIds; + } + + public String[] getBatchIds() { + return batchIds; + } + + public String[] getVariableScopeIds() { + return variableScopeIds; + } + + public String[] getActivityInstanceIds() { + return activityInstanceIds; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/VariableInstanceQueryProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/VariableInstanceQueryProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..ef9b6164c7fadded1fd76e3f3425fa9c89f94e09 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/VariableInstanceQueryProperty.java @@ -0,0 +1,40 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import org.camunda.bpm.engine.query.QueryProperty; + +/** + * @author roman.smirnov + */ +public interface VariableInstanceQueryProperty { + + public static final QueryProperty VARIABLE_NAME = new QueryPropertyImpl("NAME_"); + public static final QueryProperty VARIABLE_TYPE = new QueryPropertyImpl("TYPE_"); + public static final QueryProperty ACTIVITY_INSTANCE_ID = new QueryPropertyImpl("ACT_INST_ID_"); + public static final QueryProperty EXECUTION_ID = new QueryPropertyImpl("EXECUTION_ID_"); + public static final QueryProperty TASK_ID = new QueryPropertyImpl("TASK_ID_"); + public static final QueryProperty CASE_EXECUTION_ID = new QueryPropertyImpl("CASE_EXECUTION_ID_"); + public static final QueryProperty CASE_INSTANCE_ID = new QueryPropertyImpl("CASE_INST_ID_"); + public static final QueryProperty TENANT_ID = new QueryPropertyImpl("TENANT_ID_"); + + public static final QueryProperty TEXT = new QueryPropertyImpl("TEXT_"); + public static final QueryProperty TEXT_AS_LOWER = new QueryPropertyImpl("TEXT_", "LOWER"); + public static final QueryProperty DOUBLE = new QueryPropertyImpl("DOUBLE_"); + public static final QueryProperty LONG = new QueryPropertyImpl("LONG_"); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/VariableOrderProperty.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/VariableOrderProperty.java new file mode 100644 index 0000000000000000000000000000000000000000..f8e5f154a3d1b9e9911403f926c789202fa646d8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/VariableOrderProperty.java @@ -0,0 +1,105 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl; + +import java.util.ArrayList; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.query.QueryProperty; +import org.camunda.bpm.engine.variable.type.ValueType; + +/** + * @author Thorben Lindhauer + * + */ +public class VariableOrderProperty extends QueryOrderingProperty { + + private static final long serialVersionUID = 1L; + + public VariableOrderProperty(String name, ValueType valueType) { + super(QueryOrderingProperty.RELATION_VARIABLE, typeToQueryProperty(valueType)); + this.relationConditions = new ArrayList(); + relationConditions.add(new QueryEntityRelationCondition(VariableInstanceQueryProperty.VARIABLE_NAME, name)); + + // works only for primitive types + relationConditions.add(new QueryEntityRelationCondition(VariableInstanceQueryProperty.VARIABLE_TYPE, valueType.getName())); + } + + public VariableOrderProperty() { + } + + public static VariableOrderProperty forProcessInstanceVariable(String variableName, ValueType valueType) { + VariableOrderProperty orderingProperty = new VariableOrderProperty(variableName, valueType); + orderingProperty.relationConditions.add( + new QueryEntityRelationCondition(VariableInstanceQueryProperty.EXECUTION_ID, TaskQueryProperty.PROCESS_INSTANCE_ID)); + + return orderingProperty; + } + + public static VariableOrderProperty forExecutionVariable(String variableName, ValueType valueType) { + VariableOrderProperty orderingProperty = new VariableOrderProperty(variableName, valueType); + orderingProperty.relationConditions.add( + new QueryEntityRelationCondition(VariableInstanceQueryProperty.EXECUTION_ID, TaskQueryProperty.EXECUTION_ID)); + + return orderingProperty; + } + + public static VariableOrderProperty forTaskVariable(String variableName, ValueType valueType) { + VariableOrderProperty orderingProperty = new VariableOrderProperty(variableName, valueType); + orderingProperty.relationConditions.add( + new QueryEntityRelationCondition(VariableInstanceQueryProperty.TASK_ID, TaskQueryProperty.TASK_ID)); + + return orderingProperty; + } + + public static VariableOrderProperty forCaseInstanceVariable(String variableName, ValueType valueType) { + VariableOrderProperty orderingProperty = new VariableOrderProperty(variableName, valueType); + orderingProperty.relationConditions.add( + new QueryEntityRelationCondition(VariableInstanceQueryProperty.CASE_EXECUTION_ID, TaskQueryProperty.CASE_INSTANCE_ID)); + + return orderingProperty; + } + + public static VariableOrderProperty forCaseExecutionVariable(String variableName, ValueType valueType) { + VariableOrderProperty orderingProperty = new VariableOrderProperty(variableName, valueType); + orderingProperty.relationConditions.add( + new QueryEntityRelationCondition(VariableInstanceQueryProperty.CASE_EXECUTION_ID, TaskQueryProperty.CASE_EXECUTION_ID)); + + return orderingProperty; + } + + public static QueryProperty typeToQueryProperty(ValueType type) { + if (ValueType.STRING.equals(type)) { + return VariableInstanceQueryProperty.TEXT_AS_LOWER; + } else if (ValueType.INTEGER.equals(type)) { + return VariableInstanceQueryProperty.LONG; + } else if (ValueType.SHORT.equals(type)) { + return VariableInstanceQueryProperty.LONG; + } else if (ValueType.DATE.equals(type)) { + return VariableInstanceQueryProperty.LONG; + } else if (ValueType.BOOLEAN.equals(type)) { + return VariableInstanceQueryProperty.LONG; + } else if (ValueType.LONG.equals(type)) { + return VariableInstanceQueryProperty.LONG; + } else if (ValueType.DOUBLE.equals(type)) { + return VariableInstanceQueryProperty.DOUBLE; + } else { + throw new ProcessEngineException("Cannot order by variables of type " + type.getName()); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ant/DeployBarTask.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ant/DeployBarTask.java new file mode 100644 index 0000000000000000000000000000000000000000..25adbb1cb2575fc4138d9511048cdf6334c1bc27 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ant/DeployBarTask.java @@ -0,0 +1,164 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.ant; + +import java.io.File; +import java.io.FileInputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.zip.ZipInputStream; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Task; +import org.apache.tools.ant.types.FileSet; +import org.camunda.bpm.engine.ProcessEngine; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.ProcessEngineInfo; +import org.camunda.bpm.engine.ProcessEngines; +import org.camunda.bpm.engine.RepositoryService; +import org.camunda.bpm.engine.impl.util.IoUtil; +import org.camunda.bpm.engine.impl.util.LogUtil; + + +/** + * @author Tom Baeyens + */ +public class DeployBarTask extends Task { + + String processEngineName = ProcessEngines.NAME_DEFAULT; + File file; + List fileSets; + + public void execute() throws BuildException { + List files = new ArrayList(); + if (file!=null) { + files.add(file); + } + if (fileSets!=null) { + for (FileSet fileSet: fileSets) { + DirectoryScanner directoryScanner = fileSet.getDirectoryScanner(getProject()); + File baseDir = directoryScanner.getBasedir(); + String[] includedFiles = directoryScanner.getIncludedFiles(); + String[] excludedFiles = directoryScanner.getExcludedFiles(); + List excludedFilesList = Arrays.asList(excludedFiles); + for (String includedFile: includedFiles) { + if (!excludedFilesList.contains(includedFile)) { + files.add(new File(baseDir, includedFile)); + } + } + } + } + + Thread currentThread = Thread.currentThread(); + ClassLoader originalClassLoader = currentThread.getContextClassLoader(); + currentThread.setContextClassLoader(DeployBarTask.class.getClassLoader()); + + LogUtil.readJavaUtilLoggingConfigFromClasspath(); + + try { + log("Initializing process engine " + processEngineName); + ProcessEngines.init(); + ProcessEngine processEngine = ProcessEngines.getProcessEngine(processEngineName); + if (processEngine == null) { + List processEngineInfos = ProcessEngines.getProcessEngineInfos(); + if( processEngineInfos != null && processEngineInfos.size() > 0 ) + { + // Since no engine with the given name is found, we can't be 100% sure which ProcessEngineInfo + // is causing the error. We should show ALL errors and process engine names / resource URL's. + String message = getErrorMessage(processEngineInfos, processEngineName); + throw new ProcessEngineException(message); + } + else + throw new ProcessEngineException("Could not find a process engine with name '" + processEngineName + "', no engines found. " + + "Make sure an engine configuration is present on the classpath"); + } + RepositoryService repositoryService = processEngine.getRepositoryService(); + + log("Starting to deploy " + files.size() + " files"); + for (File file: files) { + String path = file.getAbsolutePath(); + log("Handling file " + path); + try { + FileInputStream inputStream = new FileInputStream(file); + try { + log("deploying bar "+path); + repositoryService + .createDeployment() + .name(file.getName()) + .addZipInputStream(new ZipInputStream(inputStream)) + .deploy(); + } finally { + IoUtil.closeSilently(inputStream); + } + } catch (Exception e) { + throw new BuildException("couldn't deploy bar "+path+": "+e.getMessage(), e); + } + } + + } finally { + currentThread.setContextClassLoader(originalClassLoader); + } + } + + private String getErrorMessage(List processEngineInfos, String name) { + StringBuilder builder = new StringBuilder("Could not find a process engine with name "); + builder.append(name).append(", engines loaded:\n"); + for (ProcessEngineInfo engineInfo : processEngineInfos) { + String engineName = (engineInfo.getName() != null) ? engineInfo.getName() : "unknown"; + builder.append("Process engine name: ").append(engineName); + builder.append(" - resource: ").append(engineInfo.getResourceUrl()); + builder.append(" - status: "); + + if (engineInfo.getException() != null) { + builder.append("Error while initializing engine. "); + if (engineInfo.getException().indexOf("driver on UnpooledDataSource") != -1) { + builder.append("Exception while initializing process engine! Database or database driver might not have been configured correctly.") + .append("Please consult the user guide for supported database environments or build.properties. Stacktrace: ") + .append(engineInfo.getException()); + } else { + builder.append("Stacktrace: ").append(engineInfo.getException()); + } + } else { + // Process engine initialised without exception + builder.append("Initialised"); + } + builder.append("\n"); + } + return builder.toString(); + } + + public String getProcessEngineName() { + return processEngineName; + } + public void setProcessEngineName(String processEngineName) { + this.processEngineName = processEngineName; + } + public File getFile() { + return file; + } + public void setFile(File file) { + this.file = file; + } + public List getFileSets() { + return fileSets; + } + public void setFileSets(List fileSets) { + this.fileSets = fileSets; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ant/LaunchTask.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ant/LaunchTask.java new file mode 100644 index 0000000000000000000000000000000000000000..19a1c53db636227decede536e7dd6d67559ed1da --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ant/LaunchTask.java @@ -0,0 +1,112 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.ant; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.StringTokenizer; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Task; + + +/** + * @author Tom Baeyens + */ +public class LaunchTask extends Task { + + private static final String FILESEPARATOR = System.getProperty("file.separator"); + + File dir; + String script; + String msg; + String args; + + public void execute() throws BuildException { + if (dir==null) { + throw new BuildException("dir attribute is required with the launch task"); + } + if (script==null) { + throw new BuildException("script attribute is required with the launch task"); + } + + String[] cmd = null; + String executable = getExecutable(); + if (args!=null) { + List pieces = new ArrayList(); + pieces.add(executable); + StringTokenizer tokenizer = new StringTokenizer("args", " "); + while (tokenizer.hasMoreTokens()) { + pieces.add(tokenizer.nextToken()); + } + cmd = pieces.toArray(new String[pieces.size()]); + + } else { + cmd = new String[]{executable}; + } + + LaunchThread.launch(this,cmd,dir,msg); + } + + public String getExecutable() { + String os = System.getProperty("os.name").toLowerCase(); + String dirPath = dir.getAbsolutePath(); + String base = dirPath+FILESEPARATOR+script; + if (exists(base)) { + return base; + } + + if (os.indexOf("windows")!=-1) { + if (exists(base+".exe")) { + return base+".exe"; + } + if (exists(base+".bat")) { + return base+".bat"; + } + } + + if (os.indexOf("linux")!=-1 || os.indexOf("mac")!=-1) { + if (exists(base+".sh")) { + return base+".sh"; + } + } + + throw new BuildException("couldn't find executable for script "+base); + } + + public boolean exists(String path) { + File file = new File(path); + return (file.exists()); + } + + public void setDir(File dir) { + this.dir = dir; + } + + public void setScript(String script) { + this.script = script; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public void setArgs(String args) { + this.args = args; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ant/LaunchThread.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ant/LaunchThread.java new file mode 100644 index 0000000000000000000000000000000000000000..97248cd703ad2ef2a53f798a502a47c4956769ec --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/ant/LaunchThread.java @@ -0,0 +1,103 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.ant; + +import java.io.BufferedReader; +import java.io.File; +import java.io.InputStream; +import java.io.InputStreamReader; + +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Task; +import org.camunda.bpm.engine.impl.util.IoUtil; + + +/** + * @author Tom Baeyens + */ +public class LaunchThread extends Thread { + + Task task; + String[] cmd; + File dir; + String msg; + + public LaunchThread(Task task, String[] cmd, File dir, String msg) { + this.task = task; + this.cmd = cmd; + this.dir = dir; + this.msg = msg; + } + + public static void launch(Task task, String[] cmd, File dir, String launchCompleteText) { + if (cmd==null) { + throw new BuildException("cmd is null"); + } + try { + LaunchThread launchThread = new LaunchThread(task, cmd, dir, launchCompleteText); + launchThread.start(); + launchThread.join(); + } catch (Exception e) { + throw new BuildException("couldn't launch cmd: "+cmdString(cmd), e); + } + } + + private static String cmdString(String[] cmd) { + StringBuilder cmdText = new StringBuilder(); + for(String cmdPart: cmd) { + cmdText.append(cmdPart); + cmdText.append(" "); + } + return cmdText.toString(); + } + + public void run() { + task.log("launching cmd '"+cmdString(cmd)+"' in dir '"+dir+"'"); + if (msg!=null) { + task.log("waiting for launch completion msg '"+msg+"'..."); + } else { + task.log("not waiting for a launch completion msg."); + } + ProcessBuilder processBuilder = new ProcessBuilder(cmd) + .redirectErrorStream(true) + .directory(dir); + + InputStream consoleStream = null; + try { + Process process = processBuilder.start(); + + consoleStream = process.getInputStream(); + BufferedReader consoleReader = new BufferedReader(new InputStreamReader(consoleStream)); + String consoleLine = ""; + while ( (consoleLine!=null) + && (msg==null || consoleLine.indexOf(msg)==-1) + ) { + consoleLine = consoleReader.readLine(); + + if (consoleLine!=null) { + task.log(" " + consoleLine); + } else { + task.log("launched process completed"); + } + } + } catch (Exception e) { + throw new BuildException("couldn't launch "+cmdString(cmd), e); + } finally { + IoUtil.closeSilently(consoleStream); + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/application/DefaultProcessApplicationRegistration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/application/DefaultProcessApplicationRegistration.java new file mode 100644 index 0000000000000000000000000000000000000000..621bf25798d0aed44f3bc00a27561d31b042a13f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/application/DefaultProcessApplicationRegistration.java @@ -0,0 +1,55 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.application; + +import java.util.Set; + +import org.camunda.bpm.application.ProcessApplicationReference; +import org.camunda.bpm.application.ProcessApplicationRegistration; + +/** + * @author Daniel Meyer + * + */ +public class DefaultProcessApplicationRegistration implements ProcessApplicationRegistration { + + protected Set deploymentIds; + protected String processEngineName; + protected ProcessApplicationReference reference; + + /** + * @param reference + */ + public DefaultProcessApplicationRegistration(ProcessApplicationReference reference, Set deploymentIds, String processEnginenName) { + this.reference = reference; + this.deploymentIds = deploymentIds; + this.processEngineName = processEnginenName; + } + + public Set getDeploymentIds() { + return deploymentIds; + } + + public String getProcessEngineName() { + return processEngineName; + } + + public ProcessApplicationReference getReference() { + return reference; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/application/ProcessApplicationManager.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/application/ProcessApplicationManager.java new file mode 100644 index 0000000000000000000000000000000000000000..f80c100c03311b26b83a0e7c8496bb21db618a6f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/application/ProcessApplicationManager.java @@ -0,0 +1,285 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.application; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import org.camunda.bpm.application.ProcessApplicationReference; +import org.camunda.bpm.application.ProcessApplicationRegistration; +import org.camunda.bpm.application.impl.ProcessApplicationLogger; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.cfg.TransactionState; +import org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionEntity; +import org.camunda.bpm.engine.impl.cmmn.entity.repository.CaseDefinitionManager; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.deploy.DeploymentFailListener; +import org.camunda.bpm.engine.impl.persistence.entity.DeploymentEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionManager; +import org.camunda.bpm.engine.repository.CaseDefinition; +import org.camunda.bpm.engine.repository.ProcessDefinition; + +/** + * @author Daniel Meyer + * + */ +public class ProcessApplicationManager { + + public final static ProcessApplicationLogger LOG = ProcessEngineLogger.PROCESS_APPLICATION_LOGGER; + + protected Map registrationsByDeploymentId = new HashMap(); + + public ProcessApplicationReference getProcessApplicationForDeployment(String deploymentId) { + DefaultProcessApplicationRegistration registration = registrationsByDeploymentId.get(deploymentId); + if (registration != null) { + return registration.getReference(); + } else { + return null; + } + } + + public synchronized ProcessApplicationRegistration registerProcessApplicationForDeployments(Set deploymentsToRegister, ProcessApplicationReference reference) { + // create process application registration + DefaultProcessApplicationRegistration registration = createProcessApplicationRegistration(deploymentsToRegister, reference); + // register with job executor + createJobExecutorRegistrations(deploymentsToRegister); + logRegistration(deploymentsToRegister, reference); + return registration; + } + + public synchronized void clearRegistrations() { + registrationsByDeploymentId.clear(); + } + + public synchronized void unregisterProcessApplicationForDeployments(Set deploymentIds, boolean removeProcessesFromCache) { + removeJobExecutorRegistrations(deploymentIds); + removeProcessApplicationRegistration(deploymentIds, removeProcessesFromCache); + } + + public boolean hasRegistrations() { + return !registrationsByDeploymentId.isEmpty(); + } + + protected DefaultProcessApplicationRegistration createProcessApplicationRegistration(Set deploymentsToRegister, ProcessApplicationReference reference) { + final String processEngineName = Context.getProcessEngineConfiguration().getProcessEngineName(); + + DefaultProcessApplicationRegistration registration = new DefaultProcessApplicationRegistration(reference, deploymentsToRegister, processEngineName); + // add to registration map + for (String deploymentId : deploymentsToRegister) { + registrationsByDeploymentId.put(deploymentId, registration); + } + return registration; + } + + protected void removeProcessApplicationRegistration(final Set deploymentIds, boolean removeProcessesFromCache) { + for (String deploymentId : deploymentIds) { + try { + if(removeProcessesFromCache) { + Context.getProcessEngineConfiguration() + .getDeploymentCache() + .removeDeployment(deploymentId); + } + } + catch (Throwable t) { + LOG.couldNotRemoveDefinitionsFromCache(t); + } + finally { + if(deploymentId != null) { + registrationsByDeploymentId.remove(deploymentId); + } + } + } + } + + protected void createJobExecutorRegistrations(Set deploymentIds) { + try { + final DeploymentFailListener deploymentFailListener = new DeploymentFailListener(deploymentIds, + Context.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew()); + Context.getCommandContext() + .getTransactionContext() + .addTransactionListener(TransactionState.ROLLED_BACK, deploymentFailListener); + + Set registeredDeployments = Context.getProcessEngineConfiguration().getRegisteredDeployments(); + registeredDeployments.addAll(deploymentIds); + + } + catch (Exception e) { + throw LOG.exceptionWhileRegisteringDeploymentsWithJobExecutor(e); + } + } + + protected void removeJobExecutorRegistrations(Set deploymentIds) { + try { + Set registeredDeployments = Context.getProcessEngineConfiguration().getRegisteredDeployments(); + registeredDeployments.removeAll(deploymentIds); + + } + catch (Exception e) { + LOG.exceptionWhileUnregisteringDeploymentsWithJobExecutor(e); + } + } + + // logger //////////////////////////////////////////////////////////////////////////// + + protected void logRegistration(Set deploymentIds, ProcessApplicationReference reference) { + + if (!LOG.isInfoEnabled()) { + // building the log message is expensive (db queries) so we avoid it if we can + return; + } + + try { + StringBuilder builder = new StringBuilder(); + builder.append("ProcessApplication '"); + builder.append(reference.getName()); + builder.append("' registered for DB deployments "); + builder.append(deploymentIds); + builder.append(". "); + + List processDefinitions = new ArrayList(); + List caseDefinitions = new ArrayList(); + + CommandContext commandContext = Context.getCommandContext(); + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + boolean cmmnEnabled = processEngineConfiguration.isCmmnEnabled(); + + for (String deploymentId : deploymentIds) { + + DeploymentEntity deployment = commandContext + .getDbEntityManager() + .selectById(DeploymentEntity.class, deploymentId); + + if(deployment != null) { + + processDefinitions.addAll(getDeployedProcessDefinitionArtifacts(deployment)); + + if (cmmnEnabled) { + caseDefinitions.addAll(getDeployedCaseDefinitionArtifacts(deployment)); + } + + } + } + + logProcessDefinitionRegistrations(builder, processDefinitions); + + if (cmmnEnabled) { + logCaseDefinitionRegistrations(builder, caseDefinitions); + } + + LOG.registrationSummary(builder.toString()); + + } + catch(Throwable e) { + LOG.exceptionWhileLoggingRegistrationSummary(e); + } + } + + protected List getDeployedProcessDefinitionArtifacts(DeploymentEntity deployment) { + CommandContext commandContext = Context.getCommandContext(); + + // in case deployment was created by this command + List entities = deployment.getDeployedProcessDefinitions(); + + if (entities == null) { + String deploymentId = deployment.getId(); + ProcessDefinitionManager manager = commandContext.getProcessDefinitionManager(); + return manager.findProcessDefinitionsByDeploymentId(deploymentId); + } + + return entities; + + } + + protected List getDeployedCaseDefinitionArtifacts(DeploymentEntity deployment) { + CommandContext commandContext = Context.getCommandContext(); + + // in case deployment was created by this command + List entities = deployment.getDeployedCaseDefinitions(); + + if (entities == null) { + String deploymentId = deployment.getId(); + CaseDefinitionManager caseDefinitionManager = commandContext.getCaseDefinitionManager(); + return caseDefinitionManager.findCaseDefinitionByDeploymentId(deploymentId); + } + + return entities; + + } + + protected void logProcessDefinitionRegistrations(StringBuilder builder, List processDefinitions) { + if(processDefinitions.isEmpty()) { + builder.append("Deployment does not provide any process definitions."); + + } else { + builder.append("Will execute process definitions "); + builder.append("\n"); + for (ProcessDefinition processDefinition : processDefinitions) { + builder.append("\n"); + builder.append(" "); + builder.append(processDefinition.getKey()); + builder.append("[version: "); + builder.append(processDefinition.getVersion()); + builder.append(", id: "); + builder.append(processDefinition.getId()); + builder.append("]"); + } + builder.append("\n"); + } + } + + protected void logCaseDefinitionRegistrations(StringBuilder builder, List caseDefinitions) { + if(caseDefinitions.isEmpty()) { + builder.append("Deployment does not provide any case definitions."); + + } else { + builder.append("\n"); + builder.append("Will execute case definitions "); + builder.append("\n"); + for (CaseDefinition caseDefinition : caseDefinitions) { + builder.append("\n"); + builder.append(" "); + builder.append(caseDefinition.getKey()); + builder.append("[version: "); + builder.append(caseDefinition.getVersion()); + builder.append(", id: "); + builder.append(caseDefinition.getId()); + builder.append("]"); + } + builder.append("\n"); + } + } + + public String getRegistrationSummary() { + StringBuilder builder = new StringBuilder(); + for (Entry entry : registrationsByDeploymentId.entrySet()) { + if(builder.length()>0) { + builder.append(", "); + } + builder.append(entry.getKey()); + builder.append("->"); + builder.append(entry.getValue().getReference().getName()); + } + return builder.toString(); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchConfigurationObjectConverter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchConfigurationObjectConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..5e211a9ff419e968bf8ddb79ca18f1a3bd2d7783 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchConfigurationObjectConverter.java @@ -0,0 +1,44 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import com.google.gson.JsonObject; +import org.camunda.bpm.engine.impl.json.JsonObjectConverter; +import org.camunda.bpm.engine.impl.util.JsonUtil; + +public abstract class AbstractBatchConfigurationObjectConverter extends JsonObjectConverter { + + protected static final String BATCH_ID = "batchId"; + + public abstract JsonObject writeConfiguration(T object); + + public abstract T readConfiguration(JsonObject jsonObject); + + @Override + public final JsonObject toJsonObject(T object) { + JsonObject json = writeConfiguration(object); + JsonUtil.addField(json, BATCH_ID, object.getBatchId()); + return json; + } + + @Override + public final T toObject(JsonObject jsonObject) { + T configuration = readConfiguration(jsonObject); + configuration.setBatchId(JsonUtil.getString(jsonObject, BATCH_ID)); + return configuration; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..1272ca59427af9d12fd45a6520e7b5fb903fbe81 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/AbstractBatchJobHandler.java @@ -0,0 +1,266 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import com.google.gson.JsonElement; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.DbEntity; +import org.camunda.bpm.engine.impl.db.entitymanager.OptimisticLockingListener; +import org.camunda.bpm.engine.impl.db.entitymanager.OptimisticLockingResult; +import org.camunda.bpm.engine.impl.db.entitymanager.operation.DbEntityOperation; +import org.camunda.bpm.engine.impl.db.entitymanager.operation.DbOperation; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ByteArrayManager; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; +import org.camunda.bpm.engine.impl.persistence.entity.JobManager; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; +import org.camunda.bpm.engine.impl.util.ClockUtil; +import org.camunda.bpm.engine.impl.util.JsonUtil; + +/** + * Common methods for batch job handlers based on list of ids, providing serialization, configuration instantiation, etc. + * + * @author Askar Akhmerov + */ +public abstract class AbstractBatchJobHandler implements BatchJobHandler, OptimisticLockingListener { + + @Override + public abstract JobDeclaration getJobDeclaration(); + + @Override + public boolean createJobs(BatchEntity batch) { + T configuration = readConfiguration(batch.getConfigurationBytes()); + String deploymentId = null; + + DeploymentMappings idMappings = configuration.getIdMappings(); + boolean deploymentAware = idMappings != null && !idMappings.isEmpty(); + + List ids = configuration.getIds(); + + if (deploymentAware) { + sanitizeMappings(idMappings, ids); + DeploymentMapping mappingToProcess = idMappings.get(0); + ids = mappingToProcess.getIds(ids); + deploymentId = mappingToProcess.getDeploymentId(); + } + + int batchJobsPerSeed = batch.getBatchJobsPerSeed(); + int invocationsPerBatchJob = batch.getInvocationsPerBatchJob(); + + int numberOfItemsToProcess = Math.min(invocationsPerBatchJob * batchJobsPerSeed, ids.size()); + + // view of process instances to process + List processIds = ids.subList(0, numberOfItemsToProcess); + createJobEntities(batch, configuration, deploymentId, processIds, invocationsPerBatchJob); + if (deploymentAware) { + if (ids.isEmpty()) { + // all ids of the deployment are handled + idMappings.remove(0); + } else { + idMappings.get(0).removeIds(numberOfItemsToProcess); + } + } + + // update batch configuration + batch.setConfigurationBytes(writeConfiguration(configuration)); + + return deploymentAware ? idMappings.isEmpty() : ids.isEmpty(); + } + + @Override + public final void execute(final BatchJobConfiguration configuration, + final ExecutionEntity execution, + final CommandContext commandContext, + final String tenantId) { + + // load handler config + String byteArrayId = configuration.getConfigurationByteArrayId(); + ByteArrayEntity byteArray = commandContext.getDbEntityManager().selectById(ByteArrayEntity.class, byteArrayId); + byte[] configurationByteArray = byteArray.getBytes(); + T batchConfiguration = readConfiguration(configurationByteArray); + + // load batch + String batchId = batchConfiguration.getBatchId(); + final BatchEntity batch = commandContext.getBatchManager().findBatchById(batchId); + + // set executionStartTime & fire historic update event + if (batch != null && batch.getExecutionStartTime() == null) { + // batches with multiple jobs could trigger an OptimisticLockingException, register listener to ignore that + commandContext.getDbEntityManager().registerOptimisticLockingListener(this); + + final Date executionStartTime = ClockUtil.now(); + batch.setExecutionStartTime(executionStartTime); + batch.fireHistoricUpdateEvent(); + } + + executeHandler(batchConfiguration, execution, commandContext, tenantId); + } + + protected abstract void executeHandler(final T configuration, + final ExecutionEntity execution, + final CommandContext commandContext, + final String tenantId); + + protected void sanitizeMappings(DeploymentMappings idMappings, List ids) { + // for mixed version SeedJob execution, there might be ids that have been processed + // without updating the mappings, this is corrected here, + // see https://jira.camunda.com/browse/CAM-11188 + int elementsToRemove = idMappings.getOverallIdCount() - ids.size(); + if (elementsToRemove > 0) { + for (Iterator iterator = idMappings.iterator(); iterator.hasNext();) { + DeploymentMapping deploymentMapping = iterator.next(); + if (deploymentMapping.getCount() <= elementsToRemove) { + iterator.remove(); + elementsToRemove -= deploymentMapping.getCount(); + if (elementsToRemove == 0) { + break; + } + } else { + deploymentMapping.removeIds(elementsToRemove); + break; + } + } + } + } + + protected void createJobEntities(BatchEntity batch, T configuration, String deploymentId, + List processIds, int invocationsPerBatchJob) { + + if (processIds == null || processIds.isEmpty()) { + return; + } + + CommandContext commandContext = Context.getCommandContext(); + ByteArrayManager byteArrayManager = commandContext.getByteArrayManager(); + JobManager jobManager = commandContext.getJobManager(); + + int createdJobs = 0; + while (!processIds.isEmpty()) { + int lastIdIndex = Math.min(invocationsPerBatchJob, processIds.size()); + // view of process instances for this job + List idsForJob = processIds.subList(0, lastIdIndex); + + T jobConfiguration = createJobConfiguration(configuration, idsForJob); + + jobConfiguration.setBatchId(batch.getId()); + + ByteArrayEntity configurationEntity = saveConfiguration(byteArrayManager, jobConfiguration); + + JobEntity job = createBatchJob(batch, configurationEntity); + job.setDeploymentId(deploymentId); + postProcessJob(configuration, job, jobConfiguration); + jobManager.insertAndHintJobExecutor(job); + + idsForJob.clear(); + createdJobs++; + } + + // update created jobs for batch + batch.setJobsCreated(batch.getJobsCreated() + createdJobs); + } + + protected abstract T createJobConfiguration(T configuration, List processIdsForJob); + + protected void postProcessJob(T configuration, JobEntity job, T jobConfiguration) { + // do nothing as default + } + + protected JobEntity createBatchJob(BatchEntity batch, ByteArrayEntity configuration) { + BatchJobContext creationContext = new BatchJobContext(batch, configuration); + return getJobDeclaration().createJobInstance(creationContext); + } + + @Override + public void deleteJobs(BatchEntity batch) { + List jobs = Context.getCommandContext() + .getJobManager() + .findJobsByJobDefinitionId(batch.getBatchJobDefinitionId()); + + for (JobEntity job : jobs) { + job.delete(); + } + } + + @Override + public BatchJobConfiguration newConfiguration(String canonicalString) { + return new BatchJobConfiguration(canonicalString); + } + + @Override + public void onDelete(BatchJobConfiguration configuration, JobEntity jobEntity) { + String byteArrayId = configuration.getConfigurationByteArrayId(); + if (byteArrayId != null) { + Context.getCommandContext().getByteArrayManager() + .deleteByteArrayById(byteArrayId); + } + } + + protected ByteArrayEntity saveConfiguration(ByteArrayManager byteArrayManager, T jobConfiguration) { + ByteArrayEntity configurationEntity = new ByteArrayEntity(); + configurationEntity.setBytes(writeConfiguration(jobConfiguration)); + byteArrayManager.insert(configurationEntity); + return configurationEntity; + } + + @Override + public byte[] writeConfiguration(T configuration) { + JsonElement jsonObject = getJsonConverterInstance().toJsonObject(configuration); + + return JsonUtil.asBytes(jsonObject); + } + + @Override + public T readConfiguration(byte[] serializedConfiguration) { + return getJsonConverterInstance().toObject(JsonUtil.asObject(serializedConfiguration)); + } + + protected abstract AbstractBatchConfigurationObjectConverter getJsonConverterInstance(); + + @Override + public Class getEntityType() { + return BatchEntity.class; + } + + @Override + public OptimisticLockingResult failedOperation(final DbOperation operation) { + if (operation instanceof DbEntityOperation) { + return OptimisticLockingResult.IGNORE; + } + return OptimisticLockingResult.THROW; + } + + @Override + public int calculateInvocationsPerBatchJob(String batchType, T configuration) { + ProcessEngineConfigurationImpl engineConfig = Context.getProcessEngineConfiguration(); + Map invocationsPerBatchJobByBatchType = engineConfig.getInvocationsPerBatchJobByBatchType(); + Integer invocationCount = invocationsPerBatchJobByBatchType.get(batchType); + if (invocationCount != null) { + return invocationCount; + } else { + return engineConfig.getInvocationsPerBatchJob(); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..7e91d7ed50ab1032357e0beed88f8a663af9cebb --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchConfiguration.java @@ -0,0 +1,85 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import java.util.List; + + +public class BatchConfiguration { + + protected List ids; + protected DeploymentMappings idMappings; + protected boolean failIfNotExists; + protected String batchId; + + public BatchConfiguration(List ids) { + this(ids, true); + } + + public BatchConfiguration(List ids, boolean failIfNotExists) { + this(ids, null, failIfNotExists); + } + + public BatchConfiguration(List ids, DeploymentMappings mappings) { + this(ids, mappings, true); + } + + public BatchConfiguration(List ids, DeploymentMappings mappings, boolean failIfNotExists) { + this.ids = ids; + this.idMappings = mappings; + this.failIfNotExists = failIfNotExists; + } + + public BatchConfiguration(List ids, DeploymentMappings mappings, String batchId) { + this.ids = ids; + this.idMappings = mappings; + this.batchId = batchId; + } + + public List getIds() { + return ids; + } + + public void setIds(List ids) { + this.ids = ids; + } + + public DeploymentMappings getIdMappings() { + return idMappings; + } + + public void setIdMappings(DeploymentMappings idMappings) { + this.idMappings = idMappings; + } + + public boolean isFailIfNotExists() { + return failIfNotExists; + } + + public void setFailIfNotExists(boolean failIfNotExists) { + this.failIfNotExists = failIfNotExists; + } + + public String getBatchId() { + return batchId; + } + + public void setBatchId(String batchId) { + this.batchId = batchId; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchElementConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchElementConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..9b2c8547b342cf77026e3468a0c7cbdf549fa0a5 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchElementConfiguration.java @@ -0,0 +1,128 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashSet; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; +import java.util.SortedMap; +import java.util.TreeMap; + +import org.camunda.bpm.engine.impl.util.ImmutablePair; + +/** + * Configuration information on the elements of a batch + */ +public class BatchElementConfiguration { + protected static final Comparator NULLS_LAST_STRING_COMPARATOR = Comparator.nullsLast(String::compareToIgnoreCase); + + protected SortedMap> collectedMappings = new TreeMap<>(NULLS_LAST_STRING_COMPARATOR); + + protected List ids; + protected DeploymentMappings mappings; + + /** + * Add mappings of deployment ids to resource ids to the overall element + * mapping list. + * + * @param mappings + * the mappings to add + */ + public void addDeploymentMappings(List> mappings) { + addDeploymentMappings(mappings, null); + } + + /** + * Add mappings of deployment ids to resource ids to the overall element + * mapping list. All elements from idList that are not part of + * the mappings will be added to the list of null deployment id + * mappings. + * + * @param mappingsList + * the mappings to add + * @param idList + * the list of ids to check for missing elements concerning the + * mappings to add + */ + public void addDeploymentMappings(List> mappingsList, Collection idList) { + if (ids != null) { + ids = null; + mappings = null; + } + Set missingIds = idList == null ? null : new HashSet<>(idList); + mappingsList.forEach(pair -> { + String deploymentId = pair.getLeft(); + Set idSet = collectedMappings.get(deploymentId); + if (idSet == null) { + idSet = new HashSet<>(); + collectedMappings.put(deploymentId, idSet); + } + idSet.add(pair.getRight()); + if (missingIds != null) { + missingIds.remove(pair.getRight()); + } + }); + // add missing ids to "null" deployment id + if (missingIds != null && !missingIds.isEmpty()) { + Set nullIds = collectedMappings.get(null); + if (nullIds == null) { + nullIds = new HashSet<>(); + collectedMappings.put(null, nullIds); + } + nullIds.addAll(missingIds); + } + } + + /** + * @return the list of ids that are mapped to deployment ids, ordered by + * deployment id + */ + public List getIds() { + if (ids == null) { + createDeploymentMappings(); + } + return ids; + } + + /** + * @return the list of {@link DeploymentMapping}s + */ + public DeploymentMappings getMappings() { + if (mappings == null) { + createDeploymentMappings(); + } + return mappings; + } + + public boolean isEmpty() { + return collectedMappings.isEmpty(); + } + + protected void createDeploymentMappings() { + ids = new ArrayList<>(); + mappings = new DeploymentMappings(); + + for (Entry> mapping : collectedMappings.entrySet()) { + ids.addAll(mapping.getValue()); + mappings.add(new DeploymentMapping(mapping.getKey(), mapping.getValue().size())); + } + } +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchEntity.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..825833ea98c65e87f0bbeec3b1b49630fc7c2f48 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchEntity.java @@ -0,0 +1,472 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.DbEntity; +import org.camunda.bpm.engine.impl.db.HasDbReferences; +import org.camunda.bpm.engine.impl.db.HasDbRevision; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentManager; +import org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogManager; +import org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.JobDefinitionManager; +import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; +import org.camunda.bpm.engine.impl.persistence.entity.Nameable; +import org.camunda.bpm.engine.impl.persistence.entity.SuspensionState; +import org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity; +import org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceManager; +import org.camunda.bpm.engine.impl.persistence.entity.util.ByteArrayField; +import org.camunda.bpm.engine.impl.util.ClockUtil; +import org.camunda.bpm.engine.repository.ResourceTypes; + +public class BatchEntity implements Batch, DbEntity, HasDbReferences, Nameable, HasDbRevision { + + public static final BatchSeedJobDeclaration BATCH_SEED_JOB_DECLARATION = new BatchSeedJobDeclaration(); + public static final BatchMonitorJobDeclaration BATCH_MONITOR_JOB_DECLARATION = new BatchMonitorJobDeclaration(); + + // persistent + protected String id; + protected String type; + + protected int totalJobs; + protected int jobsCreated; + protected int batchJobsPerSeed; + protected int invocationsPerBatchJob; + + protected String seedJobDefinitionId; + protected String monitorJobDefinitionId; + protected String batchJobDefinitionId; + + protected ByteArrayField configuration = new ByteArrayField(this, ResourceTypes.RUNTIME); + + protected String tenantId; + protected String createUserId; + + protected int suspensionState = SuspensionState.ACTIVE.getStateCode(); + + protected Date startTime; + protected Date executionStartTime; + + protected int revision; + + // transient + protected JobDefinitionEntity seedJobDefinition; + protected JobDefinitionEntity monitorJobDefinition; + protected JobDefinitionEntity batchJobDefinition; + + protected BatchJobHandler batchJobHandler; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return id; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public int getTotalJobs() { + return totalJobs; + } + + public void setTotalJobs(int totalJobs) { + this.totalJobs = totalJobs; + } + + public int getJobsCreated() { + return jobsCreated; + } + + public void setJobsCreated(int jobsCreated) { + this.jobsCreated = jobsCreated; + } + + public int getBatchJobsPerSeed() { + return batchJobsPerSeed; + } + + public void setBatchJobsPerSeed(int batchJobsPerSeed) { + this.batchJobsPerSeed = batchJobsPerSeed; + } + + public int getInvocationsPerBatchJob() { + return invocationsPerBatchJob; + } + + public void setInvocationsPerBatchJob(int invocationsPerBatchJob) { + this.invocationsPerBatchJob = invocationsPerBatchJob; + } + + public String getSeedJobDefinitionId() { + return seedJobDefinitionId; + } + + public void setSeedJobDefinitionId(String seedJobDefinitionId) { + this.seedJobDefinitionId = seedJobDefinitionId; + } + + public String getMonitorJobDefinitionId() { + return monitorJobDefinitionId; + } + + public void setMonitorJobDefinitionId(String monitorJobDefinitionId) { + this.monitorJobDefinitionId = monitorJobDefinitionId; + } + + public String getBatchJobDefinitionId() { + return batchJobDefinitionId; + } + + public void setBatchJobDefinitionId(String batchJobDefinitionId) { + this.batchJobDefinitionId = batchJobDefinitionId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getConfiguration() { + return configuration.getByteArrayId(); + } + + public void setConfiguration(String configuration) { + this.configuration.setByteArrayId(configuration); + } + + public void setSuspensionState(int state) { + this.suspensionState = state; + } + + public int getSuspensionState() { + return suspensionState; + } + + public boolean isSuspended() { + return suspensionState == SuspensionState.SUSPENDED.getStateCode(); + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(final Date startTime) { + this.startTime = startTime; + } + + public Date getExecutionStartTime() { + return executionStartTime; + } + + public void setExecutionStartTime(final Date executionStartTime) { + this.executionStartTime = executionStartTime; + } + + public void setRevision(int revision) { + this.revision = revision; + + } + + public int getRevision() { + return revision; + } + + public int getRevisionNext() { + return revision + 1; + } + + // transient + + public JobDefinitionEntity getSeedJobDefinition() { + if (seedJobDefinition == null && seedJobDefinitionId != null) { + seedJobDefinition = Context.getCommandContext().getJobDefinitionManager().findById(seedJobDefinitionId); + } + + return seedJobDefinition; + } + + public JobDefinitionEntity getMonitorJobDefinition() { + if (monitorJobDefinition == null && monitorJobDefinitionId != null) { + monitorJobDefinition = Context.getCommandContext().getJobDefinitionManager().findById(monitorJobDefinitionId); + } + + return monitorJobDefinition; + } + + public JobDefinitionEntity getBatchJobDefinition() { + if (batchJobDefinition == null && batchJobDefinitionId != null) { + batchJobDefinition = Context.getCommandContext().getJobDefinitionManager().findById(batchJobDefinitionId); + } + + return batchJobDefinition; + } + + public byte[] getConfigurationBytes() { + return this.configuration.getByteArrayValue(); + } + + public void setConfigurationBytes(byte[] configuration) { + this.configuration.setByteArrayValue(configuration); + } + + public BatchJobHandler getBatchJobHandler() { + if (batchJobHandler == null) { + batchJobHandler = Context.getCommandContext().getProcessEngineConfiguration().getBatchHandlers().get(type); + } + + return batchJobHandler; + } + + @Override + public Object getPersistentState() { + HashMap persistentState = new HashMap<>(); + persistentState.put("jobsCreated", jobsCreated); + persistentState.put("executionStartTime", executionStartTime); + return persistentState; + } + + public JobDefinitionEntity createSeedJobDefinition(String deploymentId) { + seedJobDefinition = new JobDefinitionEntity(BATCH_SEED_JOB_DECLARATION); + seedJobDefinition.setJobConfiguration(id); + seedJobDefinition.setTenantId(tenantId); + seedJobDefinition.setDeploymentId(deploymentId); + + Context.getCommandContext().getJobDefinitionManager().insert(seedJobDefinition); + + seedJobDefinitionId = seedJobDefinition.getId(); + + return seedJobDefinition; + } + + public JobDefinitionEntity createMonitorJobDefinition() { + monitorJobDefinition = new JobDefinitionEntity(BATCH_MONITOR_JOB_DECLARATION); + monitorJobDefinition.setJobConfiguration(id); + monitorJobDefinition.setTenantId(tenantId); + + Context.getCommandContext().getJobDefinitionManager().insert(monitorJobDefinition); + + monitorJobDefinitionId = monitorJobDefinition.getId(); + + return monitorJobDefinition; + } + + public JobDefinitionEntity createBatchJobDefinition() { + batchJobDefinition = new JobDefinitionEntity(getBatchJobHandler().getJobDeclaration()); + batchJobDefinition.setJobConfiguration(id); + batchJobDefinition.setTenantId(tenantId); + + Context.getCommandContext().getJobDefinitionManager().insert(batchJobDefinition); + + batchJobDefinitionId = batchJobDefinition.getId(); + + return batchJobDefinition; + } + + public JobEntity createSeedJob() { + JobEntity seedJob = BATCH_SEED_JOB_DECLARATION.createJobInstance(this); + + Context.getCommandContext().getJobManager().insertAndHintJobExecutor(seedJob); + + return seedJob; + } + + public void deleteSeedJob() { + List seedJobs = Context.getCommandContext() + .getJobManager() + .findJobsByJobDefinitionId(seedJobDefinitionId); + + for (JobEntity job : seedJobs) { + job.delete(); + } + } + + public JobEntity createMonitorJob(boolean setDueDate) { + // Maybe use an other job declaration + JobEntity monitorJob = BATCH_MONITOR_JOB_DECLARATION.createJobInstance(this); + if (setDueDate) { + monitorJob.setDuedate(calculateMonitorJobDueDate()); + } + + Context.getCommandContext() + .getJobManager().insertAndHintJobExecutor(monitorJob); + + return monitorJob; + } + + protected Date calculateMonitorJobDueDate() { + int pollTime = Context.getCommandContext() + .getProcessEngineConfiguration() + .getBatchPollTime(); + long dueTime = ClockUtil.getCurrentTime().getTime() + (pollTime * 1000); + return new Date(dueTime); + } + + public void deleteMonitorJob() { + List monitorJobs = Context.getCommandContext() + .getJobManager() + .findJobsByJobDefinitionId(monitorJobDefinitionId); + + for (JobEntity monitorJob : monitorJobs) { + monitorJob.delete(); + } + } + + public void delete(boolean cascadeToHistory, boolean deleteJobs) { + CommandContext commandContext = Context.getCommandContext(); + + if (Batch.TYPE_SET_VARIABLES.equals(type) || + Batch.TYPE_PROCESS_INSTANCE_MIGRATION.equals(type) || + Batch.TYPE_CORRELATE_MESSAGE.equals(type)) { + deleteVariables(commandContext); + } + + deleteSeedJob(); + deleteMonitorJob(); + if (deleteJobs) { + getBatchJobHandler().deleteJobs(this); + } + + JobDefinitionManager jobDefinitionManager = commandContext.getJobDefinitionManager(); + jobDefinitionManager.delete(getSeedJobDefinition()); + jobDefinitionManager.delete(getMonitorJobDefinition()); + jobDefinitionManager.delete(getBatchJobDefinition()); + + commandContext.getBatchManager().delete(this); + configuration.deleteByteArrayValue(); + + fireHistoricEndEvent(); + + if (cascadeToHistory) { + HistoricIncidentManager historicIncidentManager = commandContext.getHistoricIncidentManager(); + historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(seedJobDefinitionId); + historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(monitorJobDefinitionId); + historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(batchJobDefinitionId); + + HistoricJobLogManager historicJobLogManager = commandContext.getHistoricJobLogManager(); + historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(seedJobDefinitionId); + historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(monitorJobDefinitionId); + historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(batchJobDefinitionId); + + commandContext.getHistoricBatchManager().deleteHistoricBatchById(id); + } + } + + protected void deleteVariables(CommandContext commandContext) { + VariableInstanceManager variableInstanceManager = commandContext.getVariableInstanceManager(); + + List variableInstances = + variableInstanceManager.findVariableInstancesByBatchId(id); + + variableInstances.forEach(VariableInstanceEntity::delete); + } + + public void fireHistoricStartEvent() { + Context.getCommandContext() + .getHistoricBatchManager() + .createHistoricBatch(this); + } + + public void fireHistoricEndEvent() { + Context.getCommandContext() + .getHistoricBatchManager() + .completeHistoricBatch(this); + } + + public void fireHistoricUpdateEvent() { + Context.getCommandContext() + .getHistoricBatchManager() + .updateHistoricBatch(this); + } + + public boolean isCompleted() { + return Context.getCommandContext().getProcessEngineConfiguration() + .getManagementService() + .createJobQuery() + .jobDefinitionId(batchJobDefinitionId) + .count() == 0; + } + + public String toString() { + return "BatchEntity{" + + "batchHandler=" + batchJobHandler + + ", id='" + id + '\'' + + ", type='" + type + '\'' + + ", size=" + totalJobs + + ", jobCreated=" + jobsCreated + + ", batchJobsPerSeed=" + batchJobsPerSeed + + ", invocationsPerBatchJob=" + invocationsPerBatchJob + + ", seedJobDefinitionId='" + seedJobDefinitionId + '\'' + + ", monitorJobDefinitionId='" + seedJobDefinitionId + '\'' + + ", batchJobDefinitionId='" + batchJobDefinitionId + '\'' + + ", configurationId='" + configuration.getByteArrayId() + '\'' + + '}'; + } + + @Override + public Set getReferencedEntityIds() { + Set referencedEntityIds = new HashSet<>(); + return referencedEntityIds; + } + + @Override + public Map getReferencedEntitiesIdAndClass() { + Map referenceIdAndClass = new HashMap<>(); + + if (seedJobDefinitionId != null) { + referenceIdAndClass.put(seedJobDefinitionId, JobDefinitionEntity.class); + } + if (batchJobDefinitionId != null) { + referenceIdAndClass.put(batchJobDefinitionId, JobDefinitionEntity.class); + } + if (monitorJobDefinitionId != null) { + referenceIdAndClass.put(monitorJobDefinitionId, JobDefinitionEntity.class); + } + + return referenceIdAndClass; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..85c790e7777472eaee1a02054f4b10bdcb632304 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobConfiguration.java @@ -0,0 +1,42 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import org.camunda.bpm.engine.impl.jobexecutor.JobHandlerConfiguration; + +/** + * @author Thorben Lindhauer + * + */ +public class BatchJobConfiguration implements JobHandlerConfiguration { + + protected String configurationByteArrayId; + + public BatchJobConfiguration(String configurationByteArrayId) { + this.configurationByteArrayId = configurationByteArrayId; + } + + public String getConfigurationByteArrayId() { + return configurationByteArrayId; + } + + @Override + public String toCanonicalString() { + return configurationByteArrayId; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobContext.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobContext.java new file mode 100644 index 0000000000000000000000000000000000000000..7c2e6c2933ff10ce4de3629e8256da27c06684c2 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobContext.java @@ -0,0 +1,48 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity; + +/** + * @author Askar Akhmerov + */ +public class BatchJobContext { + public BatchJobContext(BatchEntity batchEntity, ByteArrayEntity configuration) { + this.batch = batchEntity; + this.configuration = configuration; + } + + protected BatchEntity batch; + protected ByteArrayEntity configuration; + + public BatchEntity getBatch() { + return batch; + } + + public void setBatch(BatchEntity batch) { + this.batch = batch; + } + + public ByteArrayEntity getConfiguration() { + return configuration; + } + + public void setConfiguration(ByteArrayEntity configuration) { + this.configuration = configuration; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobDeclaration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobDeclaration.java new file mode 100644 index 0000000000000000000000000000000000000000..0ed69084992097156fca87b6522635aad2eb83e6 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobDeclaration.java @@ -0,0 +1,67 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider; +import org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.jobexecutor.JobHandlerConfiguration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + + +public class BatchJobDeclaration extends JobDeclaration { + + public BatchJobDeclaration(String jobHandlerType) { + super(jobHandlerType); + } + + @Override + protected ExecutionEntity resolveExecution(BatchJobContext context) { + return null; + } + + @Override + protected MessageEntity newJobInstance(BatchJobContext context) { + return new MessageEntity(); + } + + @Override + protected JobHandlerConfiguration resolveJobHandlerConfiguration(BatchJobContext context) { + return new BatchJobConfiguration(context.getConfiguration().getId()); + } + + @Override + protected String resolveJobDefinitionId(BatchJobContext context) { + return context.getBatch().getBatchJobDefinitionId(); + } + + @Override + public ParameterValueProvider getJobPriorityProvider() { + long batchJobPriority = Context.getProcessEngineConfiguration() + .getBatchJobPriority(); + return new ConstantValueProvider(batchJobPriority); + } + + @Override + public MessageEntity reconfigure(BatchJobContext context, MessageEntity job) { + super.reconfigure(context, job); + job.setJobHandlerConfiguration(new BatchJobConfiguration(context.getConfiguration().getId())); + return job; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..ef59d4abdd0599818b231d0748efa765a39d30db --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchJobHandler.java @@ -0,0 +1,82 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.jobexecutor.JobHandler; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + +/** + * A batch job handler manages batch jobs based + * on the configuration {@link T}. + * + * Used by a seed job to manage lifecycle of execution jobs. + */ +public interface BatchJobHandler extends JobHandler { + + /** + * Converts the configuration of the batch to a byte array. + * + * @param configuration the configuration object + * @return the serialized configuration + */ + byte[] writeConfiguration(T configuration); + + /** + * Read the serialized configuration of the batch. + * + * @param serializedConfiguration the serialized configuration + * @return the deserialized configuration object + */ + T readConfiguration(byte[] serializedConfiguration); + + /** + * Get the job declaration for batch jobs. + * + * @return the batch job declaration + */ + JobDeclaration getJobDeclaration(); + + /** + * Creates batch jobs for a batch. + * + * @param batch the batch to create jobs for + * @return true of no more jobs have to be created for this batch, false otherwise + */ + boolean createJobs(BatchEntity batch); + + /** + * Delete all jobs for a batch. + * + * @param batch the batch to delete jobs for + */ + void deleteJobs(BatchEntity batch); + + /** + * Determine the number of invocations ber patch job. This can be defined by + * the related batch job handler specifically or otherwise taken from the + * engine configuration. + * + * @param batchType + * the batch's type to help determine any engine configuration + * related to it + * @param configuration + * the configuration object + * @return the number of invocations ber patch job + */ + int calculateInvocationsPerBatchJob(String batchType, T configuration); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchMonitorJobDeclaration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchMonitorJobDeclaration.java new file mode 100644 index 0000000000000000000000000000000000000000..593531101662bfdcece2b8bfe30404f143199d5f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchMonitorJobDeclaration.java @@ -0,0 +1,64 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import org.camunda.bpm.engine.impl.batch.BatchMonitorJobHandler.BatchMonitorJobConfiguration; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider; +import org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.jobexecutor.JobHandlerConfiguration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + +/** + * Job declaration for batch monitor jobs. The batch monitor job + * polls for the completion of the batch. + */ +public class BatchMonitorJobDeclaration extends JobDeclaration { + + private static final long serialVersionUID = 1L; + + public BatchMonitorJobDeclaration() { + super(BatchMonitorJobHandler.TYPE); + } + + protected ExecutionEntity resolveExecution(BatchEntity batch) { + return null; + } + + protected MessageEntity newJobInstance(BatchEntity batch) { + return new MessageEntity(); + } + + @Override + protected JobHandlerConfiguration resolveJobHandlerConfiguration(BatchEntity batch) { + return new BatchMonitorJobConfiguration(batch.getId()); + } + + @Override + protected String resolveJobDefinitionId(BatchEntity batch) { + return batch.getMonitorJobDefinitionId(); + } + + public ParameterValueProvider getJobPriorityProvider() { + long batchJobPriority = Context.getProcessEngineConfiguration() + .getBatchJobPriority(); + return new ConstantValueProvider(batchJobPriority); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchMonitorJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchMonitorJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..c2bb8edecd794ff7ba55e05a69c688c81e27ae38 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchMonitorJobHandler.java @@ -0,0 +1,82 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import org.camunda.bpm.engine.impl.batch.BatchMonitorJobHandler.BatchMonitorJobConfiguration; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobHandler; +import org.camunda.bpm.engine.impl.jobexecutor.JobHandlerConfiguration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; + +/** + * Job handler for batch monitor jobs. The batch monitor job + * polls for the completion of the batch. + */ +public class BatchMonitorJobHandler implements JobHandler { + + public static final String TYPE = "batch-monitor-job"; + + public String getType() { + return TYPE; + } + + public void execute(BatchMonitorJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) { + + String batchId = configuration.getBatchId(); + BatchEntity batch = commandContext.getBatchManager().findBatchById(configuration.getBatchId()); + ensureNotNull("Batch with id '" + batchId + "' cannot be found", "batch", batch); + + boolean completed = batch.isCompleted(); + + if (!completed) { + batch.createMonitorJob(true); + } + else { + batch.delete(false, false); + } + } + + @Override + public BatchMonitorJobConfiguration newConfiguration(String canonicalString) { + return new BatchMonitorJobConfiguration(canonicalString); + } + + public static class BatchMonitorJobConfiguration implements JobHandlerConfiguration { + protected String batchId; + + public BatchMonitorJobConfiguration(String batchId) { + this.batchId = batchId; + } + + public String getBatchId() { + return batchId; + } + + @Override + public String toCanonicalString() { + return batchId; + } + } + + public void onDelete(BatchMonitorJobConfiguration configuration, JobEntity jobEntity) { + // do nothing + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..70963467c171db1536688dc114850e1b61169a15 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchQueryImpl.java @@ -0,0 +1,122 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.List; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.batch.BatchQuery; +import org.camunda.bpm.engine.impl.AbstractQuery; +import org.camunda.bpm.engine.impl.BatchQueryProperty; +import org.camunda.bpm.engine.impl.Page; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.SuspensionState; + +public class BatchQueryImpl extends AbstractQuery implements BatchQuery { + + private static final long serialVersionUID = 1L; + + protected String batchId; + protected String type; + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + protected SuspensionState suspensionState; + + public BatchQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public BatchQuery batchId(String batchId) { + ensureNotNull("Batch id", batchId); + this.batchId = batchId; + return this; + } + + public String getBatchId() { + return batchId; + } + + public BatchQuery type(String type) { + ensureNotNull("Type", type); + this.type = type; + return this; + } + + public String getType() { + return type; + } + + public BatchQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public String[] getTenantIds() { + return tenantIds; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public BatchQuery withoutTenantId() { + this.tenantIds = null; + isTenantIdSet = true; + return this; + } + + public BatchQuery active() { + this.suspensionState = SuspensionState.ACTIVE; + return this; + } + + public BatchQuery suspended() { + this.suspensionState = SuspensionState.SUSPENDED; + return this; + } + + public SuspensionState getSuspensionState() { + return suspensionState; + } + + public BatchQuery orderById() { + return orderBy(BatchQueryProperty.ID); + } + + @Override + public BatchQuery orderByTenantId() { + return orderBy(BatchQueryProperty.TENANT_ID); + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext.getBatchManager() + .findBatchCountByQueryCriteria(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext.getBatchManager() + .findBatchesByQueryCriteria(this, page); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchSeedJobDeclaration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchSeedJobDeclaration.java new file mode 100644 index 0000000000000000000000000000000000000000..207b0786dc5a873c3aa20165ce26b0b8585daa52 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchSeedJobDeclaration.java @@ -0,0 +1,64 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import org.camunda.bpm.engine.impl.batch.BatchSeedJobHandler.BatchSeedJobConfiguration; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.core.variable.mapping.value.ConstantValueProvider; +import org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.jobexecutor.JobHandlerConfiguration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + +/** + * Job declaration for batch seed jobs. The batch seed job + * creates all batch jobs required to complete the batch. + */ +public class BatchSeedJobDeclaration extends JobDeclaration { + + private static final long serialVersionUID = 1L; + + public BatchSeedJobDeclaration() { + super(BatchSeedJobHandler.TYPE); + } + + protected ExecutionEntity resolveExecution(BatchEntity batch) { + return null; + } + + protected MessageEntity newJobInstance(BatchEntity batch) { + return new MessageEntity(); + } + + @Override + protected JobHandlerConfiguration resolveJobHandlerConfiguration(BatchEntity batch) { + return new BatchSeedJobConfiguration(batch.getId()); + } + + @Override + protected String resolveJobDefinitionId(BatchEntity batch) { + return batch.getSeedJobDefinitionId(); + } + + public ParameterValueProvider getJobPriorityProvider() { + long batchJobPriority = Context.getProcessEngineConfiguration() + .getBatchJobPriority(); + return new ConstantValueProvider(batchJobPriority); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchSeedJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchSeedJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..6bb4e372d62811fa4a35871099e10cf989d2c775 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchSeedJobHandler.java @@ -0,0 +1,93 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import org.camunda.bpm.engine.impl.batch.BatchSeedJobHandler.BatchSeedJobConfiguration; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobHandler; +import org.camunda.bpm.engine.impl.jobexecutor.JobHandlerConfiguration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; + +/** + * The batch seed job handler is responsible to + * create all jobs to be executed by the batch. + * + * If all jobs are created a seed monitor job is + * created to oversee the completion of the batch + * (see {@link BatchMonitorJobHandler}). + */ +public class BatchSeedJobHandler implements JobHandler { + + public static final String TYPE = "batch-seed-job"; + + public String getType() { + return TYPE; + } + + public void execute(BatchSeedJobConfiguration configuration, ExecutionEntity execution, CommandContext commandContext, String tenantId) { + + String batchId = configuration.getBatchId(); + BatchEntity batch = commandContext.getBatchManager().findBatchById(batchId); + ensureNotNull("Batch with id '" + batchId + "' cannot be found", "batch", batch); + + BatchJobHandler batchJobHandler = commandContext + .getProcessEngineConfiguration() + .getBatchHandlers() + .get(batch.getType()); + + boolean done = batchJobHandler.createJobs(batch); + + if (!done) { + batch.createSeedJob(); + } + else { + // create monitor job initially without due date to + // enable rapid completion of simple batches + batch.createMonitorJob(false); + } + } + + @Override + public BatchSeedJobConfiguration newConfiguration(String canonicalString) { + return new BatchSeedJobConfiguration(canonicalString); + } + + public static class BatchSeedJobConfiguration implements JobHandlerConfiguration { + protected String batchId; + + public BatchSeedJobConfiguration(String batchId) { + this.batchId = batchId; + } + + public String getBatchId() { + return batchId; + } + + @Override + public String toCanonicalString() { + return batchId; + } + } + + public void onDelete(BatchSeedJobConfiguration configuration, JobEntity jobEntity) { + // do nothing + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchStatisticsEntity.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchStatisticsEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..993231fb66dfe9466b55da5fb76c53fcd512ed18 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchStatisticsEntity.java @@ -0,0 +1,69 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import org.camunda.bpm.engine.batch.BatchStatistics; + +public class BatchStatisticsEntity extends BatchEntity implements BatchStatistics { + + protected int remainingJobs; + protected int failedJobs; + + public int getRemainingJobs() { + return remainingJobs + getJobsToCreate(); + } + + public void setRemainingJobs(int remainingJobs) { + this.remainingJobs = remainingJobs; + } + + public int getCompletedJobs() { + return totalJobs - getRemainingJobs(); + } + + public int getFailedJobs() { + return failedJobs; + } + + public void setFailedJobs(int failedJobs) { + this.failedJobs = failedJobs; + } + + public int getJobsToCreate() { + return totalJobs - jobsCreated; + } + + public String toString() { + return "BatchStatisticsEntity{" + + "batchHandler=" + batchJobHandler + + ", id='" + id + '\'' + + ", type='" + type + '\'' + + ", size=" + totalJobs + + ", jobCreated=" + jobsCreated + + ", remainingJobs=" + remainingJobs + + ", failedJobs=" + failedJobs + + ", batchJobsPerSeed=" + batchJobsPerSeed + + ", invocationsPerBatchJob=" + invocationsPerBatchJob + + ", seedJobDefinitionId='" + seedJobDefinitionId + '\'' + + ", monitorJobDefinitionId='" + seedJobDefinitionId + '\'' + + ", batchJobDefinitionId='" + batchJobDefinitionId + '\'' + + ", configurationId='" + configuration.getByteArrayId() + '\'' + + '}'; + } + + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchStatisticsQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchStatisticsQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..efae0b44f6ec71496a0ed6f3e5855465225c4e77 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/BatchStatisticsQueryImpl.java @@ -0,0 +1,164 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.batch.BatchStatistics; +import org.camunda.bpm.engine.batch.BatchStatisticsQuery; +import org.camunda.bpm.engine.impl.AbstractQuery; +import org.camunda.bpm.engine.impl.BatchQueryProperty; +import org.camunda.bpm.engine.impl.Page; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.SuspensionState; + +public class BatchStatisticsQueryImpl extends AbstractQuery implements BatchStatisticsQuery { + + protected static final long serialVersionUID = 1L; + + protected String batchId; + protected String type; + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + protected SuspensionState suspensionState; + protected String userId; + protected Date startedBefore; + protected Date startedAfter; + protected Boolean hasFailure; + + public BatchStatisticsQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public BatchStatisticsQuery batchId(String batchId) { + ensureNotNull("Batch id", batchId); + this.batchId = batchId; + return this; + } + + public String getBatchId() { + return batchId; + } + + public BatchStatisticsQuery type(String type) { + ensureNotNull("Type", type); + this.type = type; + return this; + } + + public String getType() { + return type; + } + + public BatchStatisticsQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public String[] getTenantIds() { + return tenantIds; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public BatchStatisticsQuery withoutTenantId() { + this.tenantIds = null; + isTenantIdSet = true; + return this; + } + + public BatchStatisticsQuery active() { + this.suspensionState = SuspensionState.ACTIVE; + return this; + } + + public BatchStatisticsQuery suspended() { + this.suspensionState = SuspensionState.SUSPENDED; + return this; + } + + @Override + public BatchStatisticsQuery createdBy(final String userId) { + this.userId = userId; + return this; + } + + @Override + public BatchStatisticsQuery startedBefore(final Date date) { + this.startedBefore = date; + return this; + } + + @Override + public BatchStatisticsQuery startedAfter(final Date date) { + this.startedAfter = date; + return this; + } + + @Override + public BatchStatisticsQuery withFailures() { + this.hasFailure = true; + return this; + } + + @Override + public BatchStatisticsQuery withoutFailures() { + this.hasFailure = false; + return this; + } + + public SuspensionState getSuspensionState() { + return suspensionState; + } + + public BatchStatisticsQuery orderById() { + return orderBy(BatchQueryProperty.ID); + } + + @Override + public BatchStatisticsQuery orderByTenantId() { + return orderBy(BatchQueryProperty.TENANT_ID); + } + + @Override + public BatchStatisticsQuery orderByStartTime() { + return orderBy(BatchQueryProperty.START_TIME); + } + + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getStatisticsManager() + .getStatisticsCountGroupedByBatch(this); + } + + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getStatisticsManager() + .getStatisticsGroupedByBatch(this, page); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeleteBatchCmd.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeleteBatchCmd.java new file mode 100644 index 0000000000000000000000000000000000000000..0c64e7fbf59d71a0a08078f2e2730fb7a3c666ae --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeleteBatchCmd.java @@ -0,0 +1,69 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.history.UserOperationLogEntry; +import org.camunda.bpm.engine.impl.cfg.CommandChecker; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.PropertyChange; + +/** + * @author Thorben Lindhauer + * + */ +public class DeleteBatchCmd implements Command { + + protected boolean cascadeToHistory; + protected String batchId; + + public DeleteBatchCmd(String batchId, boolean cascadeToHistory) { + this.batchId = batchId; + this.cascadeToHistory = cascadeToHistory; + } + + @Override + public Void execute(CommandContext commandContext) { + ensureNotNull(BadUserRequestException.class, "Batch id must not be null", "batch id", batchId); + + BatchEntity batchEntity = commandContext.getBatchManager().findBatchById(batchId); + ensureNotNull(BadUserRequestException.class, "Batch for id '" + batchId + "' cannot be found", "batch", batchEntity); + + checkAccess(commandContext, batchEntity); + writeUserOperationLog(commandContext, batchEntity.getTenantId()); + batchEntity.delete(cascadeToHistory, true); + + return null; + } + + protected void checkAccess(CommandContext commandContext, BatchEntity batch) { + for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { + checker.checkDeleteBatch(batch); + } + } + + protected void writeUserOperationLog(CommandContext commandContext, String tenantId) { + commandContext.getOperationLogManager() + .logBatchOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE, + batchId, + tenantId, + new PropertyChange("cascadeToHistory", null, cascadeToHistory)); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeploymentMapping.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeploymentMapping.java new file mode 100644 index 0000000000000000000000000000000000000000..33e8a82498878ed260f9392eef54282ec69689aa --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeploymentMapping.java @@ -0,0 +1,75 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import java.util.List; +import java.util.Objects; +import java.util.StringJoiner; + +/** + * Aggregated information on deployment ids and the number of related resources + */ +public class DeploymentMapping { + protected static String NULL_ID = "$NULL"; + + protected String deploymentId; + protected int count; + + public DeploymentMapping(String deploymentId, int count) { + this.deploymentId = deploymentId == null ? NULL_ID : deploymentId; + this.count = count; + } + + public String getDeploymentId() { + return NULL_ID.equals(deploymentId) ? null : deploymentId; + } + + public int getCount() { + return count; + } + + public List getIds(List ids) { + return ids.subList(0, count); + } + + public void removeIds(int numberOfIds) { + count -= numberOfIds; + } + + @Override + public String toString() { + return new StringJoiner(";").add(deploymentId).add(String.valueOf(count)).toString(); + } + + @Override + public int hashCode() { + return Objects.hash(count, deploymentId); + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DeploymentMapping)) { + return false; + } + DeploymentMapping other = (DeploymentMapping) obj; + return count == other.count && Objects.equals(deploymentId, other.deploymentId); + } + +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeploymentMappingJsonConverter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeploymentMappingJsonConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..6ee072291eb10ea2db80e6e2a7249461e391ed9b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeploymentMappingJsonConverter.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import org.camunda.bpm.engine.impl.json.JsonObjectConverter; +import org.camunda.bpm.engine.impl.util.JsonUtil; + +import com.google.gson.JsonObject; + +public class DeploymentMappingJsonConverter extends JsonObjectConverter { + + public static final DeploymentMappingJsonConverter INSTANCE = new DeploymentMappingJsonConverter(); + + protected static final String COUNT = "count"; + protected static final String DEPLOYMENT_ID = "deploymentId"; + + @Override + public JsonObject toJsonObject(DeploymentMapping mapping) { + JsonObject json = JsonUtil.createObject(); + json.addProperty(DEPLOYMENT_ID, mapping.getDeploymentId()); + json.addProperty(COUNT, mapping.getCount()); + return json; + } + + @Override + public DeploymentMapping toObject(JsonObject json) { + String deploymentId = JsonUtil.isNull(json, DEPLOYMENT_ID) ? null : JsonUtil.getString(json, DEPLOYMENT_ID); + int count = JsonUtil.getInt(json, COUNT); + return new DeploymentMapping(deploymentId, count); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeploymentMappings.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeploymentMappings.java new file mode 100644 index 0000000000000000000000000000000000000000..a059979d5338bbb4ae60f7834189faf257a9bcf3 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/DeploymentMappings.java @@ -0,0 +1,61 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import java.util.ArrayList; + +/** + * List of aggregated information on deployment ids and the number of related resources + */ +public class DeploymentMappings extends ArrayList { + + private static final long serialVersionUID = -868922966819588407L; + + protected int overallIdCount; + + public static DeploymentMappings of(DeploymentMapping mapping) { + DeploymentMappings mappings = new DeploymentMappings(); + mappings.add(mapping); + return mappings; + } + + @Override + public boolean add(DeploymentMapping mapping) { + overallIdCount += mapping.getCount(); + return super.add(mapping); + } + + @Override + public DeploymentMapping remove(int mappingIndex) { + overallIdCount -= get(mappingIndex).getCount(); + return super.remove(mappingIndex); + } + + @Override + public boolean remove(Object mapping) { + if (super.remove(mapping)) { + overallIdCount -= ((DeploymentMapping) mapping).getCount(); + return true; + } + return false; + } + + public int getOverallIdCount() { + return overallIdCount; + } + +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/RestartProcessInstancesBatchCmd.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/RestartProcessInstancesBatchCmd.java new file mode 100644 index 0000000000000000000000000000000000000000..13166011d0349b62de3fdd2bd1332ab0ff34a939 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/RestartProcessInstancesBatchCmd.java @@ -0,0 +1,104 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotContainsNull; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotEmpty; +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.authorization.BatchPermissions; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.RestartProcessInstanceBuilderImpl; +import org.camunda.bpm.engine.impl.RestartProcessInstancesBatchConfiguration; +import org.camunda.bpm.engine.impl.batch.builder.BatchBuilder; +import org.camunda.bpm.engine.impl.cmd.AbstractProcessInstanceModificationCommand; +import org.camunda.bpm.engine.impl.cmd.AbstractRestartProcessInstanceCmd; +import org.camunda.bpm.engine.impl.cmd.CommandLogger; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity; + +/** + * + * @author Anna Pazola + * + */ +public class RestartProcessInstancesBatchCmd extends AbstractRestartProcessInstanceCmd { + + private final CommandLogger LOG = ProcessEngineLogger.CMD_LOGGER; + + public RestartProcessInstancesBatchCmd(CommandExecutor commandExecutor, RestartProcessInstanceBuilderImpl builder) { + super(commandExecutor, builder); + } + + @Override + public Batch execute(CommandContext commandContext) { + Collection collectedInstanceIds = collectProcessInstanceIds(); + + List instructions = builder.getInstructions(); + ensureNotEmpty(BadUserRequestException.class, "Restart instructions cannot be empty", + "instructions", instructions); + ensureNotEmpty(BadUserRequestException.class, "Process instance ids cannot be empty", + "processInstanceIds", collectedInstanceIds); + ensureNotContainsNull(BadUserRequestException.class, "Process instance ids cannot be null", + "processInstanceIds", collectedInstanceIds); + + String processDefinitionId = builder.getProcessDefinitionId(); + ProcessDefinitionEntity processDefinition = + getProcessDefinition(commandContext, processDefinitionId); + + ensureNotNull(BadUserRequestException.class, + "Process definition cannot be null", processDefinition); + ensureTenantAuthorized(commandContext, processDefinition); + + String tenantId = processDefinition.getTenantId(); + + return new BatchBuilder(commandContext) + .type(Batch.TYPE_PROCESS_INSTANCE_RESTART) + .config(getConfiguration(collectedInstanceIds, processDefinition.getDeploymentId())) + .permission(BatchPermissions.CREATE_BATCH_RESTART_PROCESS_INSTANCES) + .tenantId(tenantId) + .operationLogHandler((ctx, instanceCount) -> + writeUserOperationLog(ctx, processDefinition, instanceCount, true)) + .build(); + } + + protected void ensureTenantAuthorized(CommandContext commandContext, ProcessDefinitionEntity processDefinition) { + if (!commandContext.getTenantManager().isAuthenticatedTenant(processDefinition.getTenantId())) { + throw LOG.exceptionCommandWithUnauthorizedTenant("restart process instances of process definition '" + processDefinition.getId() + "'"); + } + } + + public BatchConfiguration getConfiguration(Collection instanceIds, String deploymentId) { + return new RestartProcessInstancesBatchConfiguration( + new ArrayList<>(instanceIds), + DeploymentMappings.of(new DeploymentMapping(deploymentId, instanceIds.size())), + builder.getInstructions(), + builder.getProcessDefinitionId(), + builder.isInitialVariables(), + builder.isSkipCustomListeners(), + builder.isSkipIoMappings(), + builder.isWithoutBusinessKey()); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/SetJobRetriesBatchConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/SetJobRetriesBatchConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..ccb2cec877089367a2ef9215a573cce011e852f9 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/SetJobRetriesBatchConfiguration.java @@ -0,0 +1,50 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import java.util.Date; +import java.util.List; + +public class SetJobRetriesBatchConfiguration extends SetRetriesBatchConfiguration { + + protected Date dueDate; + protected boolean isDueDateSet; + + public SetJobRetriesBatchConfiguration(List ids, int retries, Date dueDate, boolean isDueDateSet) { + this(ids, null, retries, dueDate, isDueDateSet); + } + + public SetJobRetriesBatchConfiguration(List ids, DeploymentMappings mappings, int retries, Date dueDate, boolean isDueDateSet) { + super(ids, mappings, retries); + this.dueDate = dueDate; + this.isDueDateSet = isDueDateSet; + } + + public Date getDueDate() { + return dueDate; + } + + public void setDueDate(Date dueDate) { + isDueDateSet = true; + this.dueDate = dueDate; + } + + public boolean isDueDateSet() { + return isDueDateSet; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/SetRetriesBatchConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/SetRetriesBatchConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..83ca0a988a6f6d2925303476c1e32030a329fe38 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/SetRetriesBatchConfiguration.java @@ -0,0 +1,41 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch; + +import java.util.List; + +public class SetRetriesBatchConfiguration extends BatchConfiguration { + + protected int retries; + + public SetRetriesBatchConfiguration(List ids, int retries) { + this(ids, null, retries); + } + + public SetRetriesBatchConfiguration(List ids, DeploymentMappings mappings, int retries) { + super(ids, mappings); + this.retries = retries; + } + + public int getRetries() { + return retries; + } + + public void setRetries(int retries) { + this.retries = retries; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/BatchBuilder.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/BatchBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..3e6aaaee0757af621e4cb67045bc896524ce392e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/BatchBuilder.java @@ -0,0 +1,209 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.builder; + +import java.util.List; +import java.util.Map; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.authorization.Permission; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.BatchEntity; +import org.camunda.bpm.engine.impl.batch.BatchJobHandler; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobHandler; +import org.camunda.bpm.engine.impl.util.ClockUtil; + +public class BatchBuilder { + + protected CommandContext commandContext; + + protected BatchConfiguration config; + protected String tenantId; + protected String type; + + protected Integer totalJobsCount; + + protected Permission permission; + protected PermissionHandler permissionHandler; + + protected OperationLogInstanceCountHandler operationLogInstanceCountHandler; + protected OperationLogHandler operationLogHandler; + + public BatchBuilder(CommandContext commandContext) { + this.commandContext = commandContext; + } + + public BatchBuilder tenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + public BatchBuilder config(BatchConfiguration config) { + this.config = config; + return this; + } + + public BatchBuilder type(String batchType) { + this.type = batchType; + return this; + } + + public BatchBuilder totalJobs(int totalJobsCount) { + this.totalJobsCount = totalJobsCount; + return this; + } + + public BatchBuilder permission(Permission permission) { + this.permission = permission; + return this; + } + + public BatchBuilder permissionHandler(PermissionHandler permissionCheckHandler) { + this.permissionHandler = permissionCheckHandler; + return this; + } + + public BatchBuilder operationLogHandler(OperationLogInstanceCountHandler operationLogHandler) { + this.operationLogInstanceCountHandler = operationLogHandler; + return this; + } + + public BatchBuilder operationLogHandler(OperationLogHandler operationLogHandler) { + this.operationLogHandler = operationLogHandler; + return this; + } + + public Batch build() { + checkPermissions(); + + BatchEntity batch = new BatchEntity(); + configure(batch); + save(batch); + + writeOperationLog(); + + return batch; + } + + protected void checkPermissions() { + if (permission == null && permissionHandler == null) { + throw new ProcessEngineException("No permission check performed!"); + } + + if (permission != null) { + commandContext.getProcessEngineConfiguration() + .getCommandCheckers() + .forEach(checker -> checker.checkCreateBatch(permission)); + + } + + if (permissionHandler != null) { + permissionHandler.check(commandContext); + + } + } + + @SuppressWarnings(value = "unchecked") + protected BatchEntity configure(BatchEntity batch) { + ProcessEngineConfigurationImpl engineConfig = commandContext.getProcessEngineConfiguration(); + + Map jobHandlers = engineConfig.getJobHandlers(); + BatchJobHandler jobHandler = (BatchJobHandler) jobHandlers.get(type); + + String type = jobHandler.getType(); + batch.setType(type); + + int invocationPerBatchJobCount = jobHandler.calculateInvocationsPerBatchJob(type, config); + batch.setInvocationsPerBatchJob(invocationPerBatchJobCount); + + batch.setTenantId(tenantId); + batch.setStartTime(ClockUtil.getCurrentTime()); + + byte[] configAsBytes = jobHandler.writeConfiguration(config); + batch.setConfigurationBytes(configAsBytes); + + setTotalJobs(batch, invocationPerBatchJobCount); + + int jobCount = engineConfig.getBatchJobsPerSeed(); + batch.setBatchJobsPerSeed(jobCount); + + return batch; + } + + protected void setTotalJobs(BatchEntity batch, int invocationPerBatchJobCount) { + if (totalJobsCount != null) { + batch.setTotalJobs(totalJobsCount); + + } else { + List instanceIds = config.getIds(); + + int instanceCount = instanceIds.size(); + int totalJobsCount = calculateTotalJobs(instanceCount, invocationPerBatchJobCount); + + batch.setTotalJobs(totalJobsCount); + } + } + + protected void save(BatchEntity batch) { + commandContext.getBatchManager().insertBatch(batch); + + String seedDeploymentId = null; + if (config.getIdMappings() != null && !config.getIdMappings().isEmpty()) { + seedDeploymentId = config.getIdMappings().get(0).getDeploymentId(); + } + + batch.createSeedJobDefinition(seedDeploymentId); + batch.createMonitorJobDefinition(); + batch.createBatchJobDefinition(); + + batch.fireHistoricStartEvent(); + + batch.createSeedJob(); + } + + protected void writeOperationLog() { + if (operationLogInstanceCountHandler == null && operationLogHandler == null) { + throw new ProcessEngineException("No operation log handler specified!"); + } + + if (operationLogInstanceCountHandler != null) { + List instanceIds = config.getIds(); + + int instanceCount = instanceIds.size(); + operationLogInstanceCountHandler.write(commandContext, instanceCount); + + } else { + operationLogHandler.write(commandContext); + + } + } + + protected int calculateTotalJobs(int instanceCount, int invocationPerBatchJobCount) { + if (instanceCount == 0 || invocationPerBatchJobCount == 0) { + return 0; + } + + if (instanceCount % invocationPerBatchJobCount == 0) { + return instanceCount / invocationPerBatchJobCount; + } + + return (instanceCount / invocationPerBatchJobCount) + 1; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/OperationLogHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/OperationLogHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..17e2268f68637bbe1cf8741ee0fc7ea4a3c372d9 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/OperationLogHandler.java @@ -0,0 +1,32 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.builder; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; + +/** + * This is a functional interface to pass a callback that writes + * the Operation Log. + */ +public interface OperationLogHandler { + /** + * Callback to write the Operation Log. + * @param commandContext can be used when writing the Operation Log + */ + void write(CommandContext commandContext); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/OperationLogInstanceCountHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/OperationLogInstanceCountHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..5604ba8bb0a6baa753d243e1ba42958acd74d487 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/OperationLogInstanceCountHandler.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.builder; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; + +/** + * This is a functional interface to pass a callback that writes + * the Operation Log. + */ +public interface OperationLogInstanceCountHandler { + + /** + * Callback to write the Operation Log. + * @param commandContext can be used when writing the Operation Log + * @param instanceCount that can be logged + */ + void write(CommandContext commandContext, int instanceCount); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/PermissionHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/PermissionHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..4dac3c50127e43b5d073cae71aafe4cd8cb92e43 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/builder/PermissionHandler.java @@ -0,0 +1,33 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.builder; + +import org.camunda.bpm.engine.impl.interceptor.CommandContext; + +/** + * This is a functional interface to pass a callback that performs + * the permission check. + */ +public interface PermissionHandler { + + /** + * Callback that performs the permission check. + * @param commandContext can be used within the permission check + */ + void check(CommandContext commandContext); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteHistoricProcessInstanceBatchConfigurationJsonConverter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteHistoricProcessInstanceBatchConfigurationJsonConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..04b488dcbd7f49f57af8d065db9a03ea149a4945 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteHistoricProcessInstanceBatchConfigurationJsonConverter.java @@ -0,0 +1,64 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.deletion; + +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.AbstractBatchConfigurationObjectConverter; +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.DeploymentMappingJsonConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; +import org.camunda.bpm.engine.impl.util.JsonUtil; + +import com.google.gson.JsonObject; + +/** + * @author Askar Akhmerov + */ +public class DeleteHistoricProcessInstanceBatchConfigurationJsonConverter + extends AbstractBatchConfigurationObjectConverter { + + public static final DeleteHistoricProcessInstanceBatchConfigurationJsonConverter INSTANCE = new DeleteHistoricProcessInstanceBatchConfigurationJsonConverter(); + + public static final String HISTORIC_PROCESS_INSTANCE_IDS = "historicProcessInstanceIds"; + public static final String HISTORIC_PROCESS_INSTANCE_ID_MAPPINGS = "historicProcessInstanceIdMappings"; + public static final String FAIL_IF_NOT_EXISTS = "failIfNotExists"; + + @Override + public JsonObject writeConfiguration(BatchConfiguration configuration) { + JsonObject json = JsonUtil.createObject(); + JsonUtil.addListField(json, HISTORIC_PROCESS_INSTANCE_ID_MAPPINGS, DeploymentMappingJsonConverter.INSTANCE, configuration.getIdMappings()); + JsonUtil.addListField(json, HISTORIC_PROCESS_INSTANCE_IDS, configuration.getIds()); + JsonUtil.addField(json, FAIL_IF_NOT_EXISTS, configuration.isFailIfNotExists()); + return json; + } + + @Override + public BatchConfiguration readConfiguration(JsonObject json) { + BatchConfiguration configuration = new BatchConfiguration(readProcessInstanceIds(json), readIdMappings(json), + JsonUtil.getBoolean(json, FAIL_IF_NOT_EXISTS)); + return configuration; + } + + protected List readProcessInstanceIds(JsonObject jsonObject) { + return JsonUtil.asStringList(JsonUtil.getArray(jsonObject, HISTORIC_PROCESS_INSTANCE_IDS)); + } + + protected DeploymentMappings readIdMappings(JsonObject json) { + return JsonUtil.asList(JsonUtil.getArray(json, HISTORIC_PROCESS_INSTANCE_ID_MAPPINGS), DeploymentMappingJsonConverter.INSTANCE, DeploymentMappings::new); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteHistoricProcessInstancesJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteHistoricProcessInstancesJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..e7002b2278042a7369a8b775f4cd4dbb79549eb7 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteHistoricProcessInstancesJobHandler.java @@ -0,0 +1,70 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.deletion; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.cmd.DeleteHistoricProcessInstancesCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + +import java.util.List; + +/** + * @author Askar Akhmerov + */ +public class DeleteHistoricProcessInstancesJobHandler extends AbstractBatchJobHandler { + + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION); + + @Override + public String getType() { + return Batch.TYPE_HISTORIC_PROCESS_INSTANCE_DELETION; + } + + protected DeleteHistoricProcessInstanceBatchConfigurationJsonConverter getJsonConverterInstance() { + return DeleteHistoricProcessInstanceBatchConfigurationJsonConverter.INSTANCE; + } + + @Override + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + @Override + protected BatchConfiguration createJobConfiguration(BatchConfiguration configuration, List processIdsForJob) { + return new BatchConfiguration(processIdsForJob, configuration.isFailIfNotExists()); + } + + @Override + public void executeHandler(BatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + + commandContext.executeWithOperationLogPrevented( + new DeleteHistoricProcessInstancesCmd( + batchConfiguration.getIds(), + batchConfiguration.isFailIfNotExists())); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteProcessInstanceBatchConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteProcessInstanceBatchConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..423f5b65ae3bc1c6ce88a470a541f04a607119c6 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteProcessInstanceBatchConfiguration.java @@ -0,0 +1,86 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.deletion; + +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; + +/** + * Configuration object that is passed to the Job that will actually perform execution of + * deletion. + *

+ * This object will be serialized and persisted as run will be performed asynchronously. + * + * @author Askar Akhmerov + * @see org.camunda.bpm.engine.impl.batch.deletion.DeleteProcessInstanceBatchConfigurationJsonConverter + */ +public class DeleteProcessInstanceBatchConfiguration extends BatchConfiguration { + + protected String deleteReason; + protected boolean skipCustomListeners; + protected boolean skipSubprocesses; + protected boolean skipIoMappings; + + public DeleteProcessInstanceBatchConfiguration(List ids, DeploymentMappings mappings, boolean skipCustomListeners, boolean skipSubprocesses) { + this(ids, mappings, null, skipCustomListeners, skipSubprocesses, true, false); + } + + public DeleteProcessInstanceBatchConfiguration(List ids, DeploymentMappings mappings, String deleteReason, boolean skipCustomListeners) { + this(ids, mappings, deleteReason, skipCustomListeners, true, true, false); + } + + public DeleteProcessInstanceBatchConfiguration(List ids, DeploymentMappings mappings, String deleteReason, boolean skipCustomListeners, + boolean skipSubprocesses, boolean failIfNotExists, boolean skipIoMappings) { + super(ids, mappings); + this.deleteReason = deleteReason; + this.skipCustomListeners = skipCustomListeners; + this.skipSubprocesses = skipSubprocesses; + this.failIfNotExists = failIfNotExists; + this.skipIoMappings = skipIoMappings; + } + + public String getDeleteReason() { + return deleteReason; + } + + public void setDeleteReason(String deleteReason) { + this.deleteReason = deleteReason; + } + + public boolean isSkipCustomListeners() { + return skipCustomListeners; + } + + public boolean isSkipSubprocesses() { + return skipSubprocesses; + } + + public void setSkipSubprocesses(boolean skipSubprocesses) { + this.skipSubprocesses = skipSubprocesses; + } + + public boolean isSkipIoMappings() { + return skipIoMappings; + } + + public void setSkipIoMappings(boolean skipIoMappings) { + this.skipIoMappings = skipIoMappings; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteProcessInstanceBatchConfigurationJsonConverter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteProcessInstanceBatchConfigurationJsonConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..90fec0cca9e406e786d52b530b2b80ac80178e53 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteProcessInstanceBatchConfigurationJsonConverter.java @@ -0,0 +1,90 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.deletion; + +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.AbstractBatchConfigurationObjectConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappingJsonConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; +import org.camunda.bpm.engine.impl.util.JsonUtil; + +import com.google.gson.JsonObject; + +/** + * Perform serialization of DeleteProcessInstanceBatchConfiguration into JSON format. + * + * @author Askar Akhmerov + */ +public class DeleteProcessInstanceBatchConfigurationJsonConverter + extends AbstractBatchConfigurationObjectConverter { + + public static final DeleteProcessInstanceBatchConfigurationJsonConverter INSTANCE = new DeleteProcessInstanceBatchConfigurationJsonConverter(); + + public static final String DELETE_REASON = "deleteReason"; + public static final String PROCESS_INSTANCE_IDS = "processInstanceIds"; + public static final String PROCESS_INSTANCE_ID_MAPPINGS = "processInstanceIdMappings"; + public static final String SKIP_CUSTOM_LISTENERS = "skipCustomListeners"; + public static final String SKIP_SUBPROCESSES = "skipSubprocesses"; + public static final String SKIP_IO_MAPPINGS = "skipIoMappings"; + + public static final String FAIL_IF_NOT_EXISTS = "failIfNotExists"; + + @Override + public JsonObject writeConfiguration(DeleteProcessInstanceBatchConfiguration configuration) { + JsonObject json = JsonUtil.createObject(); + + JsonUtil.addField(json, DELETE_REASON, configuration.getDeleteReason()); + JsonUtil.addListField(json, PROCESS_INSTANCE_ID_MAPPINGS, DeploymentMappingJsonConverter.INSTANCE, configuration.getIdMappings()); + JsonUtil.addListField(json, PROCESS_INSTANCE_IDS, configuration.getIds()); + JsonUtil.addField(json, SKIP_CUSTOM_LISTENERS, configuration.isSkipCustomListeners()); + JsonUtil.addField(json, SKIP_SUBPROCESSES, configuration.isSkipSubprocesses()); + JsonUtil.addField(json, FAIL_IF_NOT_EXISTS, configuration.isFailIfNotExists()); + JsonUtil.addField(json, SKIP_IO_MAPPINGS, configuration.isSkipIoMappings()); + + return json; + } + + @Override + public DeleteProcessInstanceBatchConfiguration readConfiguration(JsonObject json) { + DeleteProcessInstanceBatchConfiguration configuration = new DeleteProcessInstanceBatchConfiguration( + readProcessInstanceIds(json), + readIdMappings(json), + null, + JsonUtil.getBoolean(json, SKIP_CUSTOM_LISTENERS), + JsonUtil.getBoolean(json, SKIP_SUBPROCESSES), + JsonUtil.getBoolean(json, FAIL_IF_NOT_EXISTS), + JsonUtil.getBoolean(json, SKIP_IO_MAPPINGS) + ); + + String deleteReason = JsonUtil.getString(json, DELETE_REASON); + + if (deleteReason != null && !deleteReason.isEmpty()) { + configuration.setDeleteReason(deleteReason); + } + + return configuration; + } + + protected List readProcessInstanceIds(JsonObject jsonObject) { + return JsonUtil.asStringList(JsonUtil.getArray(jsonObject, PROCESS_INSTANCE_IDS)); + } + + protected DeploymentMappings readIdMappings(JsonObject json) { + return JsonUtil.asList(JsonUtil.getArray(json, PROCESS_INSTANCE_ID_MAPPINGS), DeploymentMappingJsonConverter.INSTANCE, DeploymentMappings::new); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteProcessInstancesJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteProcessInstancesJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..5085b9a8c1229b40df989c68cd5128ce67c290a3 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/deletion/DeleteProcessInstancesJobHandler.java @@ -0,0 +1,103 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.deletion; + +import java.util.HashSet; +import java.util.List; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchElementConfiguration; +import org.camunda.bpm.engine.impl.batch.BatchEntity; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.cmd.DeleteProcessInstancesCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + +/** + * @author Askar Akhmerov + */ +public class DeleteProcessInstancesJobHandler extends AbstractBatchJobHandler { + + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_PROCESS_INSTANCE_DELETION); + + @Override + public String getType() { + return Batch.TYPE_PROCESS_INSTANCE_DELETION; + } + + protected DeleteProcessInstanceBatchConfigurationJsonConverter getJsonConverterInstance() { + return DeleteProcessInstanceBatchConfigurationJsonConverter.INSTANCE; + } + + @Override + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + @Override + protected DeleteProcessInstanceBatchConfiguration createJobConfiguration(DeleteProcessInstanceBatchConfiguration configuration, List processIdsForJob) { + return new DeleteProcessInstanceBatchConfiguration( + processIdsForJob, + null, + configuration.getDeleteReason(), + configuration.isSkipCustomListeners(), + configuration.isSkipSubprocesses(), + configuration.isFailIfNotExists(), + configuration.isSkipIoMappings() + ); + } + + @Override + public void executeHandler(DeleteProcessInstanceBatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + + commandContext.executeWithOperationLogPrevented( + new DeleteProcessInstancesCmd( + batchConfiguration.getIds(), + batchConfiguration.getDeleteReason(), + batchConfiguration.isSkipCustomListeners(), + true, + batchConfiguration.isSkipSubprocesses(), + batchConfiguration.isFailIfNotExists(), + batchConfiguration.isSkipIoMappings() + )); + } + + @Override + protected void createJobEntities(BatchEntity batch, DeleteProcessInstanceBatchConfiguration configuration, String deploymentId, List processIds, + int invocationsPerBatchJob) { + // handle legacy batch entities (no up-front deployment mapping has been done) + if (deploymentId == null && (configuration.getIdMappings() == null || configuration.getIdMappings().isEmpty())) { + // create deployment mappings for the ids to process + BatchElementConfiguration elementConfiguration = new BatchElementConfiguration(); + ProcessInstanceQueryImpl query = new ProcessInstanceQueryImpl(); + query.processInstanceIds(new HashSet<>(configuration.getIds())); + elementConfiguration.addDeploymentMappings(query.listDeploymentIdMappings(), configuration.getIds()); + // create jobs by deployment id + elementConfiguration.getMappings().forEach(mapping -> super.createJobEntities(batch, configuration, mapping.getDeploymentId(), + mapping.getIds(processIds), invocationsPerBatchJob)); + } else { + super.createJobEntities(batch, configuration, deploymentId, processIds, invocationsPerBatchJob); + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/externaltask/SetExternalTaskRetriesBatchConfigurationJsonConverter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/externaltask/SetExternalTaskRetriesBatchConfigurationJsonConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..0b985206fde8f4bc9766e973b90af431e2a53428 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/externaltask/SetExternalTaskRetriesBatchConfigurationJsonConverter.java @@ -0,0 +1,61 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.externaltask; + +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.AbstractBatchConfigurationObjectConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappingJsonConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; +import org.camunda.bpm.engine.impl.batch.SetRetriesBatchConfiguration; +import org.camunda.bpm.engine.impl.util.JsonUtil; + +import com.google.gson.JsonObject; + +public class SetExternalTaskRetriesBatchConfigurationJsonConverter + extends AbstractBatchConfigurationObjectConverter { + + public static final SetExternalTaskRetriesBatchConfigurationJsonConverter INSTANCE = new SetExternalTaskRetriesBatchConfigurationJsonConverter(); + + public static final String EXTERNAL_TASK_IDS = "externalTaskIds"; + public static final String EXTERNAL_TASK_ID_MAPPINGS = "externalTaskIdMappingss"; + public static final String RETRIES = "retries"; + + @Override + public JsonObject writeConfiguration(SetRetriesBatchConfiguration configuration) { + JsonObject json = JsonUtil.createObject(); + + JsonUtil.addListField(json, EXTERNAL_TASK_IDS, configuration.getIds()); + JsonUtil.addListField(json, EXTERNAL_TASK_ID_MAPPINGS, DeploymentMappingJsonConverter.INSTANCE, configuration.getIdMappings()); + JsonUtil.addField(json, RETRIES, configuration.getRetries()); + + return json; + } + + @Override + public SetRetriesBatchConfiguration readConfiguration(JsonObject json) { + return new SetRetriesBatchConfiguration(readExternalTaskIds(json), readIdMappings(json), JsonUtil.getInt(json, RETRIES)); + } + + protected List readExternalTaskIds(JsonObject json) { + return JsonUtil.asStringList(JsonUtil.getArray(json, EXTERNAL_TASK_IDS)); + } + + protected DeploymentMappings readIdMappings(JsonObject json) { + return JsonUtil.asList(JsonUtil.getArray(json, EXTERNAL_TASK_ID_MAPPINGS), DeploymentMappingJsonConverter.INSTANCE, DeploymentMappings::new); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/externaltask/SetExternalTaskRetriesJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/externaltask/SetExternalTaskRetriesJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..6f211d2a38be1a7cc1d681e0e7bb80aafbda3c09 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/externaltask/SetExternalTaskRetriesJobHandler.java @@ -0,0 +1,71 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.externaltask; + +import java.util.List; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.batch.SetRetriesBatchConfiguration; +import org.camunda.bpm.engine.impl.cmd.SetExternalTasksRetriesCmd; +import org.camunda.bpm.engine.impl.cmd.UpdateExternalTaskRetriesBuilderImpl; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + +public class SetExternalTaskRetriesJobHandler extends AbstractBatchJobHandler { + + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_SET_EXTERNAL_TASK_RETRIES); + + @Override + public String getType() { + return Batch.TYPE_SET_EXTERNAL_TASK_RETRIES; + } + + @Override + public void executeHandler(SetRetriesBatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + + commandContext.executeWithOperationLogPrevented( + new SetExternalTasksRetriesCmd( + new UpdateExternalTaskRetriesBuilderImpl( + batchConfiguration.getIds(), + batchConfiguration.getRetries()))); + } + + @Override + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + @Override + protected SetRetriesBatchConfiguration createJobConfiguration(SetRetriesBatchConfiguration configuration, + List processIdsForJob) { + return new SetRetriesBatchConfiguration(processIdsForJob, configuration.getRetries()); + } + + @Override + protected SetExternalTaskRetriesBatchConfigurationJsonConverter getJsonConverterInstance() { + return SetExternalTaskRetriesBatchConfigurationJsonConverter.INSTANCE; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/history/DeleteHistoricBatchCmd.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/history/DeleteHistoricBatchCmd.java new file mode 100644 index 0000000000000000000000000000000000000000..4c1149e977a324ab196b5fdcaf44241cffe03084 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/history/DeleteHistoricBatchCmd.java @@ -0,0 +1,61 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.history; + +import org.camunda.bpm.engine.BadUserRequestException; +import org.camunda.bpm.engine.history.UserOperationLogEntry; +import org.camunda.bpm.engine.impl.cfg.CommandChecker; +import org.camunda.bpm.engine.impl.interceptor.Command; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.PropertyChange; +import org.camunda.bpm.engine.impl.util.EnsureUtil; + +public class DeleteHistoricBatchCmd implements Command { + + protected String batchId; + + public DeleteHistoricBatchCmd(String batchId) { + this.batchId = batchId; + } + + public Object execute(CommandContext commandContext) { + EnsureUtil.ensureNotNull(BadUserRequestException.class, "Historic batch id must not be null", "historic batch id", batchId); + + HistoricBatchEntity historicBatch = commandContext.getHistoricBatchManager().findHistoricBatchById(batchId); + EnsureUtil.ensureNotNull(BadUserRequestException.class, "Historic batch for id '" + batchId + "' cannot be found", "historic batch", historicBatch); + + checkAccess(commandContext, historicBatch); + + writeUserOperationLog(commandContext, historicBatch.getTenantId()); + + historicBatch.delete(); + + return null; + } + + protected void checkAccess(CommandContext commandContext, HistoricBatchEntity batch) { + for(CommandChecker checker : commandContext.getProcessEngineConfiguration().getCommandCheckers()) { + checker.checkDeleteHistoricBatch(batch); + } + } + + protected void writeUserOperationLog(CommandContext commandContext, String tenantId) { + commandContext.getOperationLogManager() + .logBatchOperation(UserOperationLogEntry.OPERATION_TYPE_DELETE_HISTORY, batchId, tenantId, PropertyChange.EMPTY_CHANGE); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/history/HistoricBatchEntity.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/history/HistoricBatchEntity.java new file mode 100644 index 0000000000000000000000000000000000000000..120f6f62e37b9fd0a6b2352e6752eb632d6e5d62 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/history/HistoricBatchEntity.java @@ -0,0 +1,171 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.history; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +import org.camunda.bpm.engine.batch.history.HistoricBatch; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.db.DbEntity; +import org.camunda.bpm.engine.impl.history.event.HistoryEvent; +import org.camunda.bpm.engine.impl.persistence.entity.HistoricIncidentManager; +import org.camunda.bpm.engine.impl.persistence.entity.HistoricJobLogManager; + +public class HistoricBatchEntity extends HistoryEvent implements HistoricBatch, DbEntity { + + private static final long serialVersionUID = 1L; + + protected String id; + protected String type; + + protected int totalJobs; + protected int batchJobsPerSeed; + protected int invocationsPerBatchJob; + + protected String seedJobDefinitionId; + protected String monitorJobDefinitionId; + protected String batchJobDefinitionId; + + protected String tenantId; + protected String createUserId; + + protected Date startTime; + protected Date endTime; + protected Date executionStartTime; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public int getTotalJobs() { + return totalJobs; + } + + public void setTotalJobs(int totalJobs) { + this.totalJobs = totalJobs; + } + + public int getBatchJobsPerSeed() { + return batchJobsPerSeed; + } + + public void setBatchJobsPerSeed(int batchJobsPerSeed) { + this.batchJobsPerSeed = batchJobsPerSeed; + } + + public int getInvocationsPerBatchJob() { + return invocationsPerBatchJob; + } + + public void setInvocationsPerBatchJob(int invocationsPerBatchJob) { + this.invocationsPerBatchJob = invocationsPerBatchJob; + } + + public String getSeedJobDefinitionId() { + return seedJobDefinitionId; + } + + public void setSeedJobDefinitionId(String seedJobDefinitionId) { + this.seedJobDefinitionId = seedJobDefinitionId; + } + + public String getMonitorJobDefinitionId() { + return monitorJobDefinitionId; + } + + public void setMonitorJobDefinitionId(String monitorJobDefinitionId) { + this.monitorJobDefinitionId = monitorJobDefinitionId; + } + + public String getBatchJobDefinitionId() { + return batchJobDefinitionId; + } + + public void setBatchJobDefinitionId(String batchJobDefinitionId) { + this.batchJobDefinitionId = batchJobDefinitionId; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public Date getStartTime() { + return startTime; + } + + public void setStartTime(Date startTime) { + this.startTime = startTime; + } + + public Date getEndTime() { + return endTime; + } + + public void setEndTime(Date endTime) { + this.endTime = endTime; + } + + @Override + public Date getExecutionStartTime() { + return executionStartTime; + } + + public void setExecutionStartTime(final Date executionStartTime) { + this.executionStartTime = executionStartTime; + } + + @Override + public Object getPersistentState() { + Map persistentState = new HashMap(); + persistentState.put("endTime", endTime); + persistentState.put("executionStartTime", executionStartTime); + return persistentState; + } + + public void delete() { + HistoricIncidentManager historicIncidentManager = Context.getCommandContext().getHistoricIncidentManager(); + historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(seedJobDefinitionId); + historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(monitorJobDefinitionId); + historicIncidentManager.deleteHistoricIncidentsByJobDefinitionId(batchJobDefinitionId); + + HistoricJobLogManager historicJobLogManager = Context.getCommandContext().getHistoricJobLogManager(); + historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(seedJobDefinitionId); + historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(monitorJobDefinitionId); + historicJobLogManager.deleteHistoricJobLogsByJobDefinitionId(batchJobDefinitionId); + + Context.getCommandContext().getHistoricBatchManager().delete(this); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/history/HistoricBatchQueryImpl.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/history/HistoricBatchQueryImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ea54e221075aa20d1ab1b5cff54269244f2d3148 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/history/HistoricBatchQueryImpl.java @@ -0,0 +1,124 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.history; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.List; + +import org.camunda.bpm.engine.batch.history.HistoricBatch; +import org.camunda.bpm.engine.batch.history.HistoricBatchQuery; +import org.camunda.bpm.engine.impl.AbstractQuery; +import org.camunda.bpm.engine.impl.HistoricBatchQueryProperty; +import org.camunda.bpm.engine.impl.Page; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; + +public class HistoricBatchQueryImpl extends AbstractQuery implements HistoricBatchQuery { + + private static final long serialVersionUID = 1L; + + protected String batchId; + protected String type; + protected Boolean completed; + protected boolean isTenantIdSet = false; + protected String[] tenantIds; + + public HistoricBatchQueryImpl(CommandExecutor commandExecutor) { + super(commandExecutor); + } + + public HistoricBatchQuery batchId(String batchId) { + ensureNotNull("Batch id", batchId); + this.batchId = batchId; + return this; + } + + public String getBatchId() { + return batchId; + } + + public HistoricBatchQuery type(String type) { + ensureNotNull("Type", type); + this.type = type; + return this; + } + + public HistoricBatchQuery completed(boolean completed) { + this.completed = completed; + return this; + } + + public HistoricBatchQuery tenantIdIn(String... tenantIds) { + ensureNotNull("tenantIds", (Object[]) tenantIds); + this.tenantIds = tenantIds; + isTenantIdSet = true; + return this; + } + + public String[] getTenantIds() { + return tenantIds; + } + + public boolean isTenantIdSet() { + return isTenantIdSet; + } + + public HistoricBatchQuery withoutTenantId() { + this.tenantIds = null; + isTenantIdSet = true; + return this; + } + + public String getType() { + return type; + } + + public HistoricBatchQuery orderById() { + return orderBy(HistoricBatchQueryProperty.ID); + } + + public HistoricBatchQuery orderByStartTime() { + return orderBy(HistoricBatchQueryProperty.START_TIME); + } + + public HistoricBatchQuery orderByEndTime() { + return orderBy(HistoricBatchQueryProperty.END_TIME); + } + + @Override + public HistoricBatchQuery orderByTenantId() { + return orderBy(HistoricBatchQueryProperty.TENANT_ID); + } + + @Override + public long executeCount(CommandContext commandContext) { + checkQueryOk(); + return commandContext + .getHistoricBatchManager() + .findBatchCountByQueryCriteria(this); + } + + + @Override + public List executeList(CommandContext commandContext, Page page) { + checkQueryOk(); + return commandContext + .getHistoricBatchManager() + .findBatchesByQueryCriteria(this, page); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/job/SetJobRetriesBatchConfigurationJsonConverter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/job/SetJobRetriesBatchConfigurationJsonConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..0610823fae3a359b088fccc6d24e90cf0ac22c86 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/job/SetJobRetriesBatchConfigurationJsonConverter.java @@ -0,0 +1,82 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.job; + +import java.util.Date; +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.AbstractBatchConfigurationObjectConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappingJsonConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; +import org.camunda.bpm.engine.impl.batch.SetJobRetriesBatchConfiguration; +import org.camunda.bpm.engine.impl.util.JsonUtil; + +import com.google.gson.JsonObject; + +/** + * @author Askar Akhmerov + */ +public class SetJobRetriesBatchConfigurationJsonConverter + extends AbstractBatchConfigurationObjectConverter { + + public static final SetJobRetriesBatchConfigurationJsonConverter INSTANCE = new SetJobRetriesBatchConfigurationJsonConverter(); + + public static final String JOB_IDS = "jobIds"; + public static final String JOB_ID_MAPPINGS = "jobIdMappings"; + public static final String RETRIES = "retries"; + public static final String DUE_DATE = "dueDate"; + + @Override + public JsonObject writeConfiguration(SetJobRetriesBatchConfiguration configuration) { + JsonObject json = JsonUtil.createObject(); + + JsonUtil.addListField(json, JOB_IDS, configuration.getIds()); + JsonUtil.addListField(json, JOB_ID_MAPPINGS, DeploymentMappingJsonConverter.INSTANCE, configuration.getIdMappings()); + JsonUtil.addField(json, RETRIES, configuration.getRetries()); + if(configuration.isDueDateSet()) { + Date dueDate = configuration.getDueDate(); + if (dueDate == null) { + JsonUtil.addNullField(json, DUE_DATE); + } else { + JsonUtil.addDateField(json, DUE_DATE, dueDate); + } + } + return json; + } + + @Override + public SetJobRetriesBatchConfiguration readConfiguration(JsonObject json) { + boolean isDueDateSet = json.has(DUE_DATE); + Date dueDate = null; + if (isDueDateSet && !json.get(DUE_DATE).isJsonNull()) { + dueDate = new Date(JsonUtil.getLong(json, DUE_DATE)); + } + + SetJobRetriesBatchConfiguration configuration = new SetJobRetriesBatchConfiguration( + readJobIds(json), readIdMappings(json), JsonUtil.getInt(json, RETRIES), dueDate, isDueDateSet); + + return configuration; + } + + protected List readJobIds(JsonObject jsonObject) { + return JsonUtil.asStringList(JsonUtil.getArray(jsonObject, JOB_IDS)); + } + + protected DeploymentMappings readIdMappings(JsonObject jsonObject) { + return JsonUtil.asList(JsonUtil.getArray(jsonObject, JOB_ID_MAPPINGS), DeploymentMappingJsonConverter.INSTANCE, DeploymentMappings::new); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/job/SetJobRetriesJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/job/SetJobRetriesJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..8240ca7911ae8a0579322256f634c900c6777e54 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/job/SetJobRetriesJobHandler.java @@ -0,0 +1,68 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.job; + +import java.util.List; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.batch.SetJobRetriesBatchConfiguration; +import org.camunda.bpm.engine.impl.cmd.SetJobRetriesCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + + +/** + * @author Askar Akhmerov + */ +public class SetJobRetriesJobHandler extends AbstractBatchJobHandler { + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_SET_JOB_RETRIES); + + @Override + public String getType() { + return Batch.TYPE_SET_JOB_RETRIES; + } + + protected SetJobRetriesBatchConfigurationJsonConverter getJsonConverterInstance() { + return SetJobRetriesBatchConfigurationJsonConverter.INSTANCE; + } + + @Override + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + @Override + protected SetJobRetriesBatchConfiguration createJobConfiguration(SetJobRetriesBatchConfiguration configuration, List jobIds) { + return new SetJobRetriesBatchConfiguration(jobIds, configuration.getRetries(), configuration.getDueDate(), configuration.isDueDateSet()); + } + + @Override + public void executeHandler(SetJobRetriesBatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + + commandContext.executeWithOperationLogPrevented( + new SetJobRetriesCmd(batchConfiguration.getIds(), batchConfiguration.getRetries(), batchConfiguration.getDueDate(), batchConfiguration.isDueDateSet())); + + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/message/MessageCorrelationBatchConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/message/MessageCorrelationBatchConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..acaa3762a9c86a200430ee1e47dda1fcc17f6107 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/message/MessageCorrelationBatchConfiguration.java @@ -0,0 +1,57 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.message; + +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; + +public class MessageCorrelationBatchConfiguration extends BatchConfiguration { + + protected String messageName; + + public MessageCorrelationBatchConfiguration(List ids, + String messageName, + String batchId) { + this(ids, null, messageName, batchId); + } + + public MessageCorrelationBatchConfiguration(List ids, + DeploymentMappings mappings, + String messageName, + String batchId) { + super(ids, mappings); + this.messageName = messageName; + this.batchId = batchId; + } + + public MessageCorrelationBatchConfiguration(List ids, + DeploymentMappings mappings, + String messageName) { + this(ids, mappings, messageName, null); + } + + public String getMessageName() { + return messageName; + } + + public void setMessageName(String messageName) { + this.messageName = messageName;; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/message/MessageCorrelationBatchJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/message/MessageCorrelationBatchJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..32491d830b4eb267f082a7419abd2736b5371293 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/message/MessageCorrelationBatchJobHandler.java @@ -0,0 +1,103 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.message; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.MessageCorrelationBuilderImpl; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.cmd.CorrelateAllMessageCmd; +import org.camunda.bpm.engine.impl.core.variable.VariableUtil; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.json.MessageCorrelationBatchConfigurationJsonConverter; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; +import org.camunda.bpm.engine.runtime.MessageCorrelationBuilder; +import org.camunda.bpm.engine.variable.impl.VariableMapImpl; + +/** + * Job handler for message correlation jobs. The jobs correlate a message to a + * list of process instances. + */ +public class MessageCorrelationBatchJobHandler extends AbstractBatchJobHandler { + + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_CORRELATE_MESSAGE); + + public String getType() { + return Batch.TYPE_CORRELATE_MESSAGE; + } + + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + protected MessageCorrelationBatchConfigurationJsonConverter getJsonConverterInstance() { + return MessageCorrelationBatchConfigurationJsonConverter.INSTANCE; + } + + @Override + protected MessageCorrelationBatchConfiguration createJobConfiguration(MessageCorrelationBatchConfiguration configuration, List processIdsForJob) { + return new MessageCorrelationBatchConfiguration( + processIdsForJob, + configuration.getMessageName(), + configuration.getBatchId()); + } + + @Override + protected void postProcessJob(MessageCorrelationBatchConfiguration configuration, JobEntity job, MessageCorrelationBatchConfiguration jobConfiguration) { + // if there is only one process instance to adjust, set its ID to the job so exclusive scheduling is possible + if (jobConfiguration.getIds() != null && jobConfiguration.getIds().size() == 1) { + job.setProcessInstanceId(jobConfiguration.getIds().get(0)); + } + } + + @Override + public void executeHandler(MessageCorrelationBatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + String batchId = batchConfiguration.getBatchId(); + + MessageCorrelationBuilderImpl correlationBuilder = new MessageCorrelationBuilderImpl(commandContext, batchConfiguration.getMessageName()); + correlationBuilder.executionsOnly(); + setVariables(batchId, correlationBuilder, commandContext); + for (String id : batchConfiguration.getIds()) { + correlationBuilder.processInstanceId(id); + commandContext.executeWithOperationLogPrevented(new CorrelateAllMessageCmd(correlationBuilder, false, false)); + } + } + + protected void setVariables(String batchId, + MessageCorrelationBuilder correlationBuilder, + CommandContext commandContext) { + Map variables = null; + if (batchId != null) { + variables = VariableUtil.findBatchVariablesSerialized(batchId, commandContext); + if (variables != null) { + correlationBuilder.setVariables(new VariableMapImpl(new HashMap<>(variables))); + } + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/BatchSetRemovalTimeJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/BatchSetRemovalTimeJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..f76f0b8349351468e464eb7ea093b3fa70eb431d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/BatchSetRemovalTimeJobHandler.java @@ -0,0 +1,140 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.removaltime; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.batch.history.HistoricBatchEntity; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + +import java.util.Date; +import java.util.List; + +import static org.camunda.bpm.engine.ProcessEngineConfiguration.HISTORY_REMOVAL_TIME_STRATEGY_END; +import static org.camunda.bpm.engine.ProcessEngineConfiguration.HISTORY_REMOVAL_TIME_STRATEGY_START; + +/** + * @author Tassilo Weidner + */ +public class BatchSetRemovalTimeJobHandler extends AbstractBatchJobHandler { + + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_BATCH_SET_REMOVAL_TIME); + + public void executeHandler(SetRemovalTimeBatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + + for (String instanceId : batchConfiguration.getIds()) { + + HistoricBatchEntity instance = findBatchById(instanceId, commandContext); + + if (instance != null) { + Date removalTime = getOrCalculateRemovalTime(batchConfiguration, instance, commandContext); + + if (removalTime != instance.getRemovalTime()) { + addRemovalTime(instanceId, removalTime, commandContext); + + } + } + } + } + + protected Date getOrCalculateRemovalTime(SetRemovalTimeBatchConfiguration batchConfiguration, HistoricBatchEntity instance, CommandContext commandContext) { + if (batchConfiguration.hasRemovalTime()) { + return batchConfiguration.getRemovalTime(); + + } else if (hasBaseTime(instance, commandContext)) { + return calculateRemovalTime(instance, commandContext); + + } else { + return null; + + } + } + + protected void addRemovalTime(String instanceId, Date removalTime, CommandContext commandContext) { + commandContext.getHistoricBatchManager() + .addRemovalTimeById(instanceId, removalTime); + } + + protected boolean hasBaseTime(HistoricBatchEntity instance, CommandContext commandContext) { + return isStrategyStart(commandContext) || (isStrategyEnd(commandContext) && isEnded(instance)); + } + + protected boolean isEnded(HistoricBatchEntity instance) { + return instance.getEndTime() != null; + } + + protected boolean isStrategyStart(CommandContext commandContext) { + return HISTORY_REMOVAL_TIME_STRATEGY_START.equals(getHistoryRemovalTimeStrategy(commandContext)); + } + + protected boolean isStrategyEnd(CommandContext commandContext) { + return HISTORY_REMOVAL_TIME_STRATEGY_END.equals(getHistoryRemovalTimeStrategy(commandContext)); + } + + protected String getHistoryRemovalTimeStrategy(CommandContext commandContext) { + return commandContext.getProcessEngineConfiguration() + .getHistoryRemovalTimeStrategy(); + } + + protected boolean isDmnEnabled(CommandContext commandContext) { + return commandContext.getProcessEngineConfiguration().isDmnEnabled(); + } + + protected Date calculateRemovalTime(HistoricBatchEntity batch, CommandContext commandContext) { + return commandContext.getProcessEngineConfiguration() + .getHistoryRemovalTimeProvider() + .calculateRemovalTime(batch); + } + + protected ByteArrayEntity findByteArrayById(String byteArrayId, CommandContext commandContext) { + return commandContext.getDbEntityManager() + .selectById(ByteArrayEntity.class, byteArrayId); + } + + protected HistoricBatchEntity findBatchById(String instanceId, CommandContext commandContext) { + return commandContext.getHistoricBatchManager() + .findHistoricBatchById(instanceId); + } + + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + protected SetRemovalTimeBatchConfiguration createJobConfiguration(SetRemovalTimeBatchConfiguration configuration, List batchIds) { + return new SetRemovalTimeBatchConfiguration(batchIds) + .setRemovalTime(configuration.getRemovalTime()) + .setHasRemovalTime(configuration.hasRemovalTime()); + } + + protected SetRemovalTimeJsonConverter getJsonConverterInstance() { + return SetRemovalTimeJsonConverter.INSTANCE; + } + + public String getType() { + return Batch.TYPE_BATCH_SET_REMOVAL_TIME; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/DecisionSetRemovalTimeJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/DecisionSetRemovalTimeJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..363d315ae766187089a8e62a4c056e380a3a3a7c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/DecisionSetRemovalTimeJobHandler.java @@ -0,0 +1,170 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.removaltime; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.history.event.HistoricDecisionInstanceEntity; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; +import org.camunda.bpm.engine.repository.DecisionDefinition; + +import java.util.Date; +import java.util.List; + +import static org.camunda.bpm.engine.ProcessEngineConfiguration.HISTORY_REMOVAL_TIME_STRATEGY_END; +import static org.camunda.bpm.engine.ProcessEngineConfiguration.HISTORY_REMOVAL_TIME_STRATEGY_START; + +/** + * @author Tassilo Weidner + */ +public class DecisionSetRemovalTimeJobHandler extends AbstractBatchJobHandler { + + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_DECISION_SET_REMOVAL_TIME); + + public void executeHandler(SetRemovalTimeBatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + + if (isDmnEnabled(commandContext)) { + + for (String instanceId : batchConfiguration.getIds()) { + + HistoricDecisionInstanceEntity instance = findDecisionInstanceById(instanceId, commandContext); + + if (instance != null) { + if (batchConfiguration.isHierarchical()) { + + String rootDecisionInstanceId = getRootDecisionInstance(instance); + + HistoricDecisionInstanceEntity rootInstance = findDecisionInstanceById(rootDecisionInstanceId, commandContext); + + Date removalTime = getOrCalculateRemovalTime(batchConfiguration, rootInstance, commandContext); + + addRemovalTimeToHierarchy(rootDecisionInstanceId, removalTime, commandContext); + + } else { + Date removalTime = getOrCalculateRemovalTime(batchConfiguration, instance, commandContext); + + if (removalTime != instance.getRemovalTime()) { + addRemovalTime(instanceId, removalTime, commandContext); + + } + } + } + } + } + } + + protected String getRootDecisionInstance(HistoricDecisionInstanceEntity instance) { + return instance.getRootDecisionInstanceId() == null ? instance.getId() : instance.getRootDecisionInstanceId(); + } + + protected Date getOrCalculateRemovalTime(SetRemovalTimeBatchConfiguration batchConfiguration, HistoricDecisionInstanceEntity instance, CommandContext commandContext) { + if (batchConfiguration.hasRemovalTime()) { + return batchConfiguration.getRemovalTime(); + + } else if (hasBaseTime(commandContext)){ + return calculateRemovalTime(instance, commandContext); + + } else { + return null; + + } + } + + protected void addRemovalTimeToHierarchy(String instanceId, Date removalTime, CommandContext commandContext) { + commandContext.getHistoricDecisionInstanceManager() + .addRemovalTimeToDecisionsByRootDecisionInstanceId(instanceId, removalTime); + } + + protected void addRemovalTime(String instanceId, Date removalTime, CommandContext commandContext) { + commandContext.getHistoricDecisionInstanceManager() + .addRemovalTimeToDecisionsByDecisionInstanceId(instanceId, removalTime); + } + + protected boolean hasBaseTime(CommandContext commandContext) { + return isStrategyStart(commandContext) || isStrategyEnd(commandContext); + } + + protected boolean isStrategyStart(CommandContext commandContext) { + return HISTORY_REMOVAL_TIME_STRATEGY_START.equals(getHistoryRemovalTimeStrategy(commandContext)); + } + + protected boolean isStrategyEnd(CommandContext commandContext) { + return HISTORY_REMOVAL_TIME_STRATEGY_END.equals(getHistoryRemovalTimeStrategy(commandContext)); + } + + protected String getHistoryRemovalTimeStrategy(CommandContext commandContext) { + return commandContext.getProcessEngineConfiguration() + .getHistoryRemovalTimeStrategy(); + } + + protected DecisionDefinition findDecisionDefinitionById(String decisionDefinitionId, CommandContext commandContext) { + return commandContext.getProcessEngineConfiguration() + .getDeploymentCache() + .findDeployedDecisionDefinitionById(decisionDefinitionId); + } + + protected boolean isDmnEnabled(CommandContext commandContext) { + return commandContext.getProcessEngineConfiguration().isDmnEnabled(); + } + + protected Date calculateRemovalTime(HistoricDecisionInstanceEntity decisionInstance, CommandContext commandContext) { + DecisionDefinition decisionDefinition = findDecisionDefinitionById(decisionInstance.getDecisionDefinitionId(), commandContext); + + return commandContext.getProcessEngineConfiguration() + .getHistoryRemovalTimeProvider() + .calculateRemovalTime(decisionInstance, decisionDefinition); + } + + protected ByteArrayEntity findByteArrayById(String byteArrayId, CommandContext commandContext) { + return commandContext.getDbEntityManager() + .selectById(ByteArrayEntity.class, byteArrayId); + } + + protected HistoricDecisionInstanceEntity findDecisionInstanceById(String instanceId, CommandContext commandContext) { + return commandContext.getHistoricDecisionInstanceManager() + .findHistoricDecisionInstance(instanceId); + } + + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + protected SetRemovalTimeBatchConfiguration createJobConfiguration(SetRemovalTimeBatchConfiguration configuration, List decisionInstanceIds) { + return new SetRemovalTimeBatchConfiguration(decisionInstanceIds) + .setRemovalTime(configuration.getRemovalTime()) + .setHasRemovalTime(configuration.hasRemovalTime()) + .setHierarchical(configuration.isHierarchical()); + } + + protected SetRemovalTimeJsonConverter getJsonConverterInstance() { + return SetRemovalTimeJsonConverter.INSTANCE; + } + + public String getType() { + return Batch.TYPE_DECISION_SET_REMOVAL_TIME; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/ProcessSetRemovalTimeJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/ProcessSetRemovalTimeJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..4bdef7556abba13d694bd719cc4e3ab2a5e98989 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/ProcessSetRemovalTimeJobHandler.java @@ -0,0 +1,247 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.removaltime; + +import static org.camunda.bpm.engine.ProcessEngineConfiguration.HISTORY_REMOVAL_TIME_STRATEGY_END; +import static org.camunda.bpm.engine.ProcessEngineConfiguration.HISTORY_REMOVAL_TIME_STRATEGY_START; + +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.cfg.TransactionListener; +import org.camunda.bpm.engine.impl.cfg.TransactionState; +import org.camunda.bpm.engine.impl.db.DbEntity; +import org.camunda.bpm.engine.impl.db.entitymanager.operation.DbOperation; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.HistoricProcessInstanceEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; +import org.camunda.bpm.engine.repository.ProcessDefinition; + +/** + * @author Tassilo Weidner + */ +public class ProcessSetRemovalTimeJobHandler extends AbstractBatchJobHandler { + + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_PROCESS_SET_REMOVAL_TIME); + public static final int MAX_CHUNK_SIZE = 500; + + @Override + public void executeHandler(SetRemovalTimeBatchConfiguration configuration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + if (configuration.isUpdateInChunks()) { + // only one instance allowed if enabled, see #calculateInvocationsPerBatchJob + String instanceId = configuration.getIds().get(0); + Set entities = configuration.getEntities(); + Integer chunkSize = getUpdateChunkSize(configuration, commandContext); + Map, DbOperation> operations = addRemovalTimeToInstance(instanceId, configuration, + chunkSize, entities, commandContext); + MessageEntity currentJob = (MessageEntity) commandContext.getCurrentJob(); + registerTransactionHandler(configuration, operations, chunkSize, currentJob, commandContext); + currentJob.setRepeat("true"); + } else { + configuration.getIds().forEach(id -> + addRemovalTimeToInstance(id, configuration, null, Collections.emptySet(), commandContext)); + } + } + + protected Map, DbOperation> addRemovalTimeToInstance(String instanceId, + SetRemovalTimeBatchConfiguration configuration, + Integer batchSize, + Set entities, + CommandContext commandContext) { + HistoricProcessInstanceEntity instance = findProcessInstanceById(instanceId, commandContext); + if (instance != null) { + if (configuration.isHierarchical() && hasHierarchy(instance)) { + String rootProcessInstanceId = instance.getRootProcessInstanceId(); + HistoricProcessInstanceEntity rootInstance = findProcessInstanceById(rootProcessInstanceId, commandContext); + Date removalTime = getOrCalculateRemovalTime(configuration, rootInstance, commandContext); + return addRemovalTimeToHierarchy(rootProcessInstanceId, removalTime, batchSize, entities, commandContext); + } else { + Date removalTime = getOrCalculateRemovalTime(configuration, instance, commandContext); + if (removalTime != instance.getRemovalTime()) { + return addRemovalTime(instanceId, removalTime, batchSize, entities, commandContext); + } + } + } + return null; + } + + protected Date getOrCalculateRemovalTime(SetRemovalTimeBatchConfiguration configuration, + HistoricProcessInstanceEntity instance, + CommandContext commandContext) { + if (configuration.hasRemovalTime()) { + return configuration.getRemovalTime(); + } else if (hasBaseTime(instance, commandContext)) { + return calculateRemovalTime(instance, commandContext); + } else { + return null; + } + } + + protected Map, DbOperation> addRemovalTimeToHierarchy(String rootProcessInstanceId, + Date removalTime, + Integer batchSize, + Set entities, + CommandContext commandContext) { + Map, DbOperation> operations = commandContext.getHistoricProcessInstanceManager() + .addRemovalTimeToProcessInstancesByRootProcessInstanceId(rootProcessInstanceId, removalTime, batchSize, entities); + if (isDmnEnabled(commandContext)) { + operations.putAll(commandContext.getHistoricDecisionInstanceManager() + .addRemovalTimeToDecisionsByRootProcessInstanceId(rootProcessInstanceId, removalTime, batchSize, entities)); + } + return operations; + } + + protected Map, DbOperation> addRemovalTime(String instanceId, + Date removalTime, + Integer batchSize, + Set entities, + CommandContext commandContext) { + Map, DbOperation> operations = commandContext.getHistoricProcessInstanceManager() + .addRemovalTimeById(instanceId, removalTime, batchSize, entities); + if (isDmnEnabled(commandContext)) { + operations.putAll(commandContext.getHistoricDecisionInstanceManager() + .addRemovalTimeToDecisionsByProcessInstanceId(instanceId, removalTime, batchSize, entities)); + } + return operations; + } + + protected boolean hasBaseTime(HistoricProcessInstanceEntity instance, CommandContext commandContext) { + return isStrategyStart(commandContext) || (isStrategyEnd(commandContext) && isEnded(instance)); + } + + protected boolean isEnded(HistoricProcessInstanceEntity instance) { + return instance.getEndTime() != null; + } + + protected boolean isStrategyStart(CommandContext commandContext) { + return HISTORY_REMOVAL_TIME_STRATEGY_START.equals(getHistoryRemovalTimeStrategy(commandContext)); + } + + protected boolean isStrategyEnd(CommandContext commandContext) { + return HISTORY_REMOVAL_TIME_STRATEGY_END.equals(getHistoryRemovalTimeStrategy(commandContext)); + } + + protected boolean hasHierarchy(HistoricProcessInstanceEntity instance) { + return instance.getRootProcessInstanceId() != null; + } + + protected String getHistoryRemovalTimeStrategy(CommandContext commandContext) { + return commandContext.getProcessEngineConfiguration() + .getHistoryRemovalTimeStrategy(); + } + + protected ProcessDefinition findProcessDefinitionById(String processDefinitionId, CommandContext commandContext) { + return commandContext.getProcessEngineConfiguration() + .getDeploymentCache() + .findDeployedProcessDefinitionById(processDefinitionId); + } + + protected boolean isDmnEnabled(CommandContext commandContext) { + return commandContext.getProcessEngineConfiguration().isDmnEnabled(); + } + + protected Date calculateRemovalTime(HistoricProcessInstanceEntity processInstance, CommandContext commandContext) { + ProcessDefinition processDefinition = findProcessDefinitionById(processInstance.getProcessDefinitionId(), commandContext); + + return commandContext.getProcessEngineConfiguration() + .getHistoryRemovalTimeProvider() + .calculateRemovalTime(processInstance, processDefinition); + } + + protected ByteArrayEntity findByteArrayById(String byteArrayId, CommandContext commandContext) { + return commandContext.getDbEntityManager() + .selectById(ByteArrayEntity.class, byteArrayId); + } + + protected HistoricProcessInstanceEntity findProcessInstanceById(String instanceId, CommandContext commandContext) { + return commandContext.getHistoricProcessInstanceManager() + .findHistoricProcessInstance(instanceId); + } + + protected void registerTransactionHandler(SetRemovalTimeBatchConfiguration configuration, + Map, DbOperation> operations, + Integer chunkSize, + MessageEntity currentJob, + CommandContext commandContext) { + CommandExecutor newCommandExecutor = commandContext.getProcessEngineConfiguration().getCommandExecutorTxRequiresNew(); + TransactionListener transactionResulthandler = createTransactionHandler(configuration, operations, chunkSize, + currentJob, newCommandExecutor); + commandContext.getTransactionContext().addTransactionListener(TransactionState.COMMITTED, transactionResulthandler); + } + + protected int getUpdateChunkSize(SetRemovalTimeBatchConfiguration configuration, CommandContext commandContext) { + return configuration.getChunkSize() == null + ? commandContext.getProcessEngineConfiguration().getRemovalTimeUpdateChunkSize() + : configuration.getChunkSize(); + } + + protected TransactionListener createTransactionHandler(SetRemovalTimeBatchConfiguration configuration, + Map, DbOperation> operations, + Integer chunkSize, + MessageEntity currentJob, + CommandExecutor newCommandExecutor) { + return new ProcessSetRemovalTimeResultHandler(configuration, chunkSize, newCommandExecutor, this, + currentJob.getId(), operations); + } + + @Override + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + @Override + protected SetRemovalTimeBatchConfiguration createJobConfiguration(SetRemovalTimeBatchConfiguration configuration, + List processInstanceIds) { + return new SetRemovalTimeBatchConfiguration(processInstanceIds) + .setRemovalTime(configuration.getRemovalTime()) + .setHasRemovalTime(configuration.hasRemovalTime()) + .setHierarchical(configuration.isHierarchical()) + .setUpdateInChunks(configuration.isUpdateInChunks()) + .setChunkSize(configuration.getChunkSize()); + } + + @Override + protected SetRemovalTimeJsonConverter getJsonConverterInstance() { + return SetRemovalTimeJsonConverter.INSTANCE; + } + + @Override + public int calculateInvocationsPerBatchJob(String batchType, SetRemovalTimeBatchConfiguration configuration) { + if (configuration.isUpdateInChunks()) { + return 1; + } + return super.calculateInvocationsPerBatchJob(batchType, configuration); + } + + @Override + public String getType() { + return Batch.TYPE_PROCESS_SET_REMOVAL_TIME; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/ProcessSetRemovalTimeResultHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/ProcessSetRemovalTimeResultHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..7389584c5b417632f38f8ff321cf74b04f0a5c85 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/ProcessSetRemovalTimeResultHandler.java @@ -0,0 +1,97 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.removaltime; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.cfg.TransactionListener; +import org.camunda.bpm.engine.impl.db.DbEntity; +import org.camunda.bpm.engine.impl.db.entitymanager.operation.DbOperation; +import org.camunda.bpm.engine.impl.history.event.HistoricProcessInstanceEventEntity; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity; +import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; +import org.camunda.bpm.engine.impl.util.ClockUtil; + +public class ProcessSetRemovalTimeResultHandler implements TransactionListener { + + protected SetRemovalTimeBatchConfiguration batchJobConfiguration; + protected Integer chunkSize; + protected CommandExecutor commandExecutor; + protected ProcessSetRemovalTimeJobHandler jobHandler; + protected String jobId; + protected Map, DbOperation> operations; + + public ProcessSetRemovalTimeResultHandler(SetRemovalTimeBatchConfiguration batchJobConfiguration, + Integer chunkSize, + CommandExecutor commandExecutor, + ProcessSetRemovalTimeJobHandler jobHandler, + String jobId, + Map, DbOperation> operations) { + this.batchJobConfiguration = batchJobConfiguration; + this.chunkSize = chunkSize; + this.commandExecutor = commandExecutor; + this.jobHandler = jobHandler; + this.jobId = jobId; + this.operations = operations; + } + + @Override + public void execute(CommandContext commandContext) { + // use the new command executor since the command context might already have been closed/finished + commandExecutor.execute(context -> { + JobEntity job = context.getJobManager().findJobById(jobId); + Set entitiesToUpdate = getEntitiesToUpdate(operations, chunkSize); + if (entitiesToUpdate.isEmpty() && !operations.containsKey(HistoricProcessInstanceEventEntity.class)) { + // update the process instance last to avoid orphans + entitiesToUpdate = new HashSet<>(); + entitiesToUpdate.add(HistoricProcessInstanceEventEntity.class.getName()); + } + if (entitiesToUpdate.isEmpty()) { + job.delete(true); + } else { + // save batch job configuration + batchJobConfiguration.setEntities(entitiesToUpdate); + ByteArrayEntity newConfiguration = saveConfiguration(batchJobConfiguration, context); + BatchJobContext newBatchContext = new BatchJobContext(null, newConfiguration); + ProcessSetRemovalTimeJobHandler.JOB_DECLARATION.reconfigure(newBatchContext, (MessageEntity) job); + // reschedule job + context.getJobManager().reschedule(job, ClockUtil.getCurrentTime()); + } + return null; + }); + } + + protected ByteArrayEntity saveConfiguration(SetRemovalTimeBatchConfiguration configuration, CommandContext context) { + ByteArrayEntity configurationEntity = new ByteArrayEntity(); + configurationEntity.setBytes(jobHandler.writeConfiguration(configuration)); + context.getByteArrayManager().insert(configurationEntity); + return configurationEntity; + } + + protected static Set getEntitiesToUpdate(Map, DbOperation> operations, int chunkSize) { + return operations.entrySet().stream() + .filter(op -> op.getValue().getRowsAffected() == chunkSize) + .map(op -> op.getKey().getName()) + .collect(Collectors.toSet()); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/SetRemovalTimeBatchConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/SetRemovalTimeBatchConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..ea7ca7bad414e3e2de108ec8b890c3026d9835c5 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/SetRemovalTimeBatchConfiguration.java @@ -0,0 +1,99 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.removaltime; + +import java.util.Date; +import java.util.List; +import java.util.Set; +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; + +/** + * @author Tassilo Weidner + */ +public class SetRemovalTimeBatchConfiguration extends BatchConfiguration { + + protected Date removalTime; + protected boolean hasRemovalTime; + protected boolean isHierarchical; + protected boolean updateInChunks; + protected Integer chunkSize; + protected Set entities; + + public SetRemovalTimeBatchConfiguration(List ids) { + this(ids, null); + } + + public SetRemovalTimeBatchConfiguration(List ids, DeploymentMappings mappings) { + super(ids, mappings); + } + + public Date getRemovalTime() { + return removalTime; + } + + public SetRemovalTimeBatchConfiguration setRemovalTime(Date removalTime) { + this.removalTime = removalTime; + return this; + } + + public boolean hasRemovalTime() { + return hasRemovalTime; + } + + public SetRemovalTimeBatchConfiguration setHasRemovalTime(boolean hasRemovalTime) { + this.hasRemovalTime = hasRemovalTime; + return this; + } + + public boolean isHierarchical() { + return isHierarchical; + } + + public SetRemovalTimeBatchConfiguration setHierarchical(boolean hierarchical) { + isHierarchical = hierarchical; + return this; + } + + public boolean isUpdateInChunks() { + return updateInChunks; + } + + public SetRemovalTimeBatchConfiguration setUpdateInChunks(boolean updateInChunks) { + this.updateInChunks = updateInChunks; + return this; + } + + public Integer getChunkSize() { + return chunkSize; + } + + public SetRemovalTimeBatchConfiguration setChunkSize(Integer chunkSize) { + this.chunkSize = chunkSize; + return this; + } + + public Set getEntities() { + return entities; + } + + public SetRemovalTimeBatchConfiguration setEntities(Set entities) { + this.entities = entities; + return this; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/SetRemovalTimeJsonConverter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/SetRemovalTimeJsonConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..9665bfc3f27d0904007a43074c7cbde5c09a7c01 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/removaltime/SetRemovalTimeJsonConverter.java @@ -0,0 +1,98 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.removaltime; + +import com.google.gson.JsonObject; +import java.util.ArrayList; +import java.util.Date; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import org.camunda.bpm.engine.impl.batch.AbstractBatchConfigurationObjectConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappingJsonConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; +import org.camunda.bpm.engine.impl.util.JsonUtil; + +/** + * @author Tassilo Weidner + */ +public class SetRemovalTimeJsonConverter + extends AbstractBatchConfigurationObjectConverter { + + public static final SetRemovalTimeJsonConverter INSTANCE = new SetRemovalTimeJsonConverter(); + + protected static final String IDS = "ids"; + protected static final String ID_MAPPINGS = "idMappings"; + protected static final String REMOVAL_TIME = "removalTime"; + protected static final String HAS_REMOVAL_TIME = "hasRemovalTime"; + protected static final String IS_HIERARCHICAL = "isHierarchical"; + protected static final String UPDATE_IN_CHUNKS = "updateInChunks"; + protected static final String CHUNK_SIZE = "chunkSize"; + protected static final String ENTITIES = "entities"; + + @Override + public JsonObject writeConfiguration(SetRemovalTimeBatchConfiguration configuration) { + JsonObject json = JsonUtil.createObject(); + + JsonUtil.addListField(json, IDS, configuration.getIds()); + JsonUtil.addListField(json, ID_MAPPINGS, DeploymentMappingJsonConverter.INSTANCE, configuration.getIdMappings()); + JsonUtil.addDateField(json, REMOVAL_TIME, configuration.getRemovalTime()); + JsonUtil.addField(json, HAS_REMOVAL_TIME, configuration.hasRemovalTime()); + JsonUtil.addField(json, IS_HIERARCHICAL, configuration.isHierarchical()); + JsonUtil.addField(json, UPDATE_IN_CHUNKS, configuration.isUpdateInChunks()); + JsonUtil.addField(json, CHUNK_SIZE, configuration.getChunkSize()); + if (configuration.getEntities() != null) { + JsonUtil.addListField(json, ENTITIES, new ArrayList<>(configuration.getEntities())); + } + + return json; + } + + @Override + public SetRemovalTimeBatchConfiguration readConfiguration(JsonObject jsonObject) { + + long removalTimeMills = JsonUtil.getLong(jsonObject, REMOVAL_TIME); + Date removalTime = removalTimeMills > 0 ? new Date(removalTimeMills) : null; + + List instanceIds = JsonUtil.asStringList(JsonUtil.getArray(jsonObject, IDS)); + + DeploymentMappings mappings = JsonUtil.asList(JsonUtil.getArray(jsonObject, ID_MAPPINGS), + DeploymentMappingJsonConverter.INSTANCE, DeploymentMappings::new); + + boolean hasRemovalTime = JsonUtil.getBoolean(jsonObject, HAS_REMOVAL_TIME); + + boolean isHierarchical = JsonUtil.getBoolean(jsonObject, IS_HIERARCHICAL); + + boolean updateInChunks = JsonUtil.getBoolean(jsonObject, UPDATE_IN_CHUNKS); + + Integer chunkSize = jsonObject.has(CHUNK_SIZE)? JsonUtil.getInt(jsonObject, CHUNK_SIZE) : null; + + Set entities = null; + if (jsonObject.has(ENTITIES)) { + entities = new HashSet<>(JsonUtil.asStringList(JsonUtil.getArray(jsonObject, ENTITIES))); + } + + return new SetRemovalTimeBatchConfiguration(instanceIds, mappings) + .setRemovalTime(removalTime) + .setHasRemovalTime(hasRemovalTime) + .setHierarchical(isHierarchical) + .setUpdateInChunks(updateInChunks) + .setChunkSize(chunkSize) + .setEntities(entities); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/update/UpdateProcessInstancesSuspendStateBatchConfiguration.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/update/UpdateProcessInstancesSuspendStateBatchConfiguration.java new file mode 100644 index 0000000000000000000000000000000000000000..73bdd235d29fdd6f79bd8795236ddad4fc48a740 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/update/UpdateProcessInstancesSuspendStateBatchConfiguration.java @@ -0,0 +1,43 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.update; + +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; + +public class UpdateProcessInstancesSuspendStateBatchConfiguration extends BatchConfiguration { + + + protected final boolean suspended; + + public UpdateProcessInstancesSuspendStateBatchConfiguration(List ids, boolean suspended) { + this(ids, null, suspended); + } + + public UpdateProcessInstancesSuspendStateBatchConfiguration(List ids, + DeploymentMappings mappings, boolean suspended) { + super(ids, mappings); + this.suspended = suspended; + } + + boolean getSuspended(){ + return suspended; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/update/UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/update/UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..f0ee4e9b024b018d7a86cd9db53d27550b1b30c2 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/update/UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter.java @@ -0,0 +1,62 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.update; + +import java.util.List; + +import org.camunda.bpm.engine.impl.batch.AbstractBatchConfigurationObjectConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappingJsonConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; +import org.camunda.bpm.engine.impl.util.JsonUtil; +import com.google.gson.JsonObject; + +public class UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter + extends AbstractBatchConfigurationObjectConverter { + + public static final UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter INSTANCE = new UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter(); + + public static final String PROCESS_INSTANCE_IDS = "processInstanceIds"; + public static final String PROCESS_INSTANCE_ID_MAPPINGS = "processInstanceIdMappings"; + public static final String SUSPENDING = "suspended"; + + @Override + public JsonObject writeConfiguration(UpdateProcessInstancesSuspendStateBatchConfiguration configuration) { + JsonObject json = JsonUtil.createObject(); + + JsonUtil.addListField(json, PROCESS_INSTANCE_IDS, configuration.getIds()); + JsonUtil.addListField(json, PROCESS_INSTANCE_ID_MAPPINGS, DeploymentMappingJsonConverter.INSTANCE, configuration.getIdMappings()); + JsonUtil.addField(json, SUSPENDING, configuration.getSuspended()); + return json; + } + + @Override + public UpdateProcessInstancesSuspendStateBatchConfiguration readConfiguration(JsonObject json) { + UpdateProcessInstancesSuspendStateBatchConfiguration configuration = + new UpdateProcessInstancesSuspendStateBatchConfiguration(readProcessInstanceIds(json), readMappings(json), + JsonUtil.getBoolean(json, SUSPENDING)); + + return configuration; + } + + protected List readProcessInstanceIds(JsonObject jsonObject) { + return JsonUtil.asStringList(JsonUtil.getArray(jsonObject, PROCESS_INSTANCE_IDS)); + } + + protected DeploymentMappings readMappings(JsonObject jsonObject) { + return JsonUtil.asList(JsonUtil.getArray(jsonObject, PROCESS_INSTANCE_ID_MAPPINGS), DeploymentMappingJsonConverter.INSTANCE, DeploymentMappings::new); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/update/UpdateProcessInstancesSuspendStateJobHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/update/UpdateProcessInstancesSuspendStateJobHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..a4c255eb7a76756b746e5630b4ef4ae0c631b7e0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/update/UpdateProcessInstancesSuspendStateJobHandler.java @@ -0,0 +1,69 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.update; + +import java.util.List; +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.UpdateProcessInstancesSuspensionStateBuilderImpl; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.cmd.UpdateProcessInstancesSuspendStateCmd; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.interceptor.CommandExecutor; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + +public class UpdateProcessInstancesSuspendStateJobHandler extends AbstractBatchJobHandler { + + public static final BatchJobDeclaration JOB_DECLARATION = new BatchJobDeclaration(Batch.TYPE_PROCESS_INSTANCE_UPDATE_SUSPENSION_STATE); + + @Override + public String getType() { + return Batch.TYPE_PROCESS_INSTANCE_UPDATE_SUSPENSION_STATE; + } + + protected UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter getJsonConverterInstance() { + return UpdateProcessInstancesSuspendStateBatchConfigurationJsonConverter.INSTANCE; + } + + @Override + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + @Override + protected UpdateProcessInstancesSuspendStateBatchConfiguration createJobConfiguration(UpdateProcessInstancesSuspendStateBatchConfiguration configuration, List processIdsForJob) { + return new UpdateProcessInstancesSuspendStateBatchConfiguration(processIdsForJob, configuration.getSuspended()); + } + + @Override + public void executeHandler(UpdateProcessInstancesSuspendStateBatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + + CommandExecutor commandExecutor = commandContext.getProcessEngineConfiguration() + .getCommandExecutorTxRequired(); + commandContext.executeWithOperationLogPrevented(new UpdateProcessInstancesSuspendStateCmd( + commandExecutor, + new UpdateProcessInstancesSuspensionStateBuilderImpl(batchConfiguration.getIds()), + batchConfiguration.getSuspended())); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/variables/BatchSetVariablesHandler.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/variables/BatchSetVariablesHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..88485efc3fc0edebf311d93282f91daf0368a985 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/variables/BatchSetVariablesHandler.java @@ -0,0 +1,92 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.variables; + +import org.camunda.bpm.engine.batch.Batch; +import org.camunda.bpm.engine.impl.batch.AbstractBatchJobHandler; +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.BatchJobContext; +import org.camunda.bpm.engine.impl.batch.BatchJobDeclaration; +import org.camunda.bpm.engine.impl.cmd.SetExecutionVariablesCmd; +import org.camunda.bpm.engine.impl.core.variable.VariableUtil; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.jobexecutor.JobDeclaration; +import org.camunda.bpm.engine.impl.persistence.entity.ByteArrayEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.JobEntity; +import org.camunda.bpm.engine.impl.persistence.entity.MessageEntity; + +import java.util.List; +import java.util.Map; + +public class BatchSetVariablesHandler extends AbstractBatchJobHandler { + + public static final BatchJobDeclaration JOB_DECLARATION = + new BatchJobDeclaration(Batch.TYPE_SET_VARIABLES); + + @Override + public void executeHandler(BatchConfiguration batchConfiguration, + ExecutionEntity execution, + CommandContext commandContext, + String tenantId) { + + String batchId = batchConfiguration.getBatchId(); + Map variables = VariableUtil.findBatchVariablesSerialized(batchId, commandContext); + + List processInstanceIds = batchConfiguration.getIds(); + + for (String processInstanceId : processInstanceIds) { + commandContext.executeWithOperationLogPrevented( + new SetExecutionVariablesCmd(processInstanceId, variables, false, true, false)); + } + } + + @Override + public JobDeclaration getJobDeclaration() { + return JOB_DECLARATION; + } + + @Override + protected BatchConfiguration createJobConfiguration(BatchConfiguration configuration, + List processIdsForJob) { + return new BatchConfiguration(processIdsForJob); + } + + @Override + protected SetVariablesJsonConverter getJsonConverterInstance() { + return SetVariablesJsonConverter.INSTANCE; + } + + @Override + public String getType() { + return Batch.TYPE_SET_VARIABLES; + } + + @Override + protected void postProcessJob(BatchConfiguration configuration, JobEntity job, BatchConfiguration jobConfiguration) { + // if there is only one process instance to adjust, set its ID to the job so exclusive scheduling is possible + if (jobConfiguration.getIds() != null && jobConfiguration.getIds().size() == 1) { + job.setProcessInstanceId(jobConfiguration.getIds().get(0)); + } + } + + protected ByteArrayEntity findByteArrayById(String byteArrayId, CommandContext commandContext) { + return commandContext.getDbEntityManager() + .selectById(ByteArrayEntity.class, byteArrayId); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/variables/SetVariablesJsonConverter.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/variables/SetVariablesJsonConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..09b77c431abdb50d688ba9fec88af8f167a9eb2e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/batch/variables/SetVariablesJsonConverter.java @@ -0,0 +1,56 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.batch.variables; + +import com.google.gson.JsonObject; +import org.camunda.bpm.engine.impl.batch.AbstractBatchConfigurationObjectConverter; +import org.camunda.bpm.engine.impl.batch.BatchConfiguration; +import org.camunda.bpm.engine.impl.batch.DeploymentMappingJsonConverter; +import org.camunda.bpm.engine.impl.batch.DeploymentMappings; +import org.camunda.bpm.engine.impl.util.JsonUtil; + +import java.util.List; + +public class SetVariablesJsonConverter extends AbstractBatchConfigurationObjectConverter { + + public static final SetVariablesJsonConverter INSTANCE = new SetVariablesJsonConverter(); + + protected static final String IDS = "ids"; + protected static final String ID_MAPPINGS = "idMappings"; + + @Override + public JsonObject writeConfiguration(final BatchConfiguration configuration) { + JsonObject json = JsonUtil.createObject(); + + JsonUtil.addListField(json, IDS, configuration.getIds()); + JsonUtil.addListField(json, ID_MAPPINGS, DeploymentMappingJsonConverter.INSTANCE, + configuration.getIdMappings()); + + return json; + } + + @Override + public BatchConfiguration readConfiguration(final JsonObject jsonObject) { + List instanceIds = JsonUtil.asStringList(JsonUtil.getArray(jsonObject, IDS)); + + DeploymentMappings mappings = JsonUtil.asList(JsonUtil.getArray(jsonObject, ID_MAPPINGS), + DeploymentMappingJsonConverter.INSTANCE, DeploymentMappings::new); + + return new BatchConfiguration(instanceIds, mappings); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/AbstractBpmnActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/AbstractBpmnActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..d362f946e7d29979fc8a47bea6a6800b3a6c7139 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/AbstractBpmnActivityBehavior.java @@ -0,0 +1,138 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import static org.camunda.bpm.engine.impl.bpmn.helper.CompensationUtil.SIGNAL_COMPENSATION_DONE; + +import java.util.concurrent.Callable; + +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.bpmn.helper.BpmnExceptionHandler; +import org.camunda.bpm.engine.impl.bpmn.helper.ErrorPropagationException; +import org.camunda.bpm.engine.impl.event.EventType; +import org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.PvmActivity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl; + + +/** + * Denotes an 'activity' in the sense of BPMN 2.0: + * a parent class for all tasks, subprocess and callActivity. + * + * @author Joram Barrez + * @author Daniel Meyer + * @author Thorben Lindhauer + */ +public class AbstractBpmnActivityBehavior extends FlowNodeActivityBehavior { + + protected static final BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + /** + * Subclasses that call leave() will first pass through this method, before + * the regular {@link FlowNodeActivityBehavior#leave(ActivityExecution)} is + * called. + */ + @Override + public void doLeave(ActivityExecution execution) { + + PvmActivity currentActivity = execution.getActivity(); + ActivityImpl compensationHandler = ((ActivityImpl) currentActivity).findCompensationHandler(); + + // subscription for compensation event subprocess is already created + if(compensationHandler != null && !isCompensationEventSubprocess(compensationHandler)) { + createCompensateEventSubscription(execution, compensationHandler); + } + super.doLeave(execution); + } + + protected boolean isCompensationEventSubprocess(ActivityImpl activity) { + return activity.isCompensationHandler() && activity.isSubProcessScope() && activity.isTriggeredByEvent(); + } + + protected void createCompensateEventSubscription(ActivityExecution execution, ActivityImpl compensationHandler) { + // the compensate event subscription is created at subprocess or miBody of the the current activity + PvmActivity currentActivity = execution.getActivity(); + ActivityExecution scopeExecution = execution.findExecutionForFlowScope(currentActivity.getFlowScope()); + + EventSubscriptionEntity.createAndInsert((ExecutionEntity) scopeExecution, EventType.COMPENSATE, compensationHandler); + } + + /** + * Takes an {@link ActivityExecution} and an {@link Callable} and wraps + * the call to the Callable with the proper error propagation. This method + * also makes sure that exceptions not caught by following activities in the + * process will be thrown and not propagated. + * + * @param execution + * @param toExecute + * @throws Exception + */ + protected void executeWithErrorPropagation(ActivityExecution execution, Callable toExecute) throws Exception { + String activityInstanceId = execution.getActivityInstanceId(); + try { + toExecute.call(); + } catch (Exception ex) { + if (activityInstanceId.equals(execution.getActivityInstanceId())) { + + try { + BpmnExceptionHandler.propagateException(execution, ex); + } + catch (ErrorPropagationException e) { + // exception has been logged by thrower + // re-throw the original exception so that it is logged + // and set as cause of the failure + throw ex; + } + + } + else { + throw ex; + } + } + } + + @Override + public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception { + if(SIGNAL_COMPENSATION_DONE.equals(signalName)) { + signalCompensationDone(execution); + } else { + super.signal(execution, signalName, signalData); + } + } + + protected void signalCompensationDone(ActivityExecution execution) { + // default behavior is to join compensating executions and propagate the signal if all executions have compensated + + // only wait for non-event-scope executions cause a compensation event subprocess consume the compensation event and + // do not have to compensate embedded subprocesses (which are still non-event-scope executions) + + if(((PvmExecutionImpl) execution).getNonEventScopeExecutions().isEmpty()) { + if(execution.getParent() != null) { + ActivityExecution parent = execution.getParent(); + execution.remove(); + parent.signal(SIGNAL_COMPENSATION_DONE, null); + } + } else { + ((ExecutionEntity)execution).forceUpdate(); + } + + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BoundaryConditionalEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BoundaryConditionalEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..5605808a38cc6717ac28fe3beb61d197fdc6ea76 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BoundaryConditionalEventActivityBehavior.java @@ -0,0 +1,54 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.bpmn.parser.ConditionalEventDefinition; +import org.camunda.bpm.engine.impl.core.variable.event.VariableEvent; +import org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.runtime.ActivityInstanceState; +import org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl; + +/** + * + * @author Christopher Zell + */ +public class BoundaryConditionalEventActivityBehavior extends BoundaryEventActivityBehavior implements ConditionalEventBehavior { + + protected final ConditionalEventDefinition conditionalEvent; + + public BoundaryConditionalEventActivityBehavior(ConditionalEventDefinition conditionalEvent) { + this.conditionalEvent = conditionalEvent; + } + + @Override + public ConditionalEventDefinition getConditionalEventDefinition() { + return conditionalEvent; + } + + @Override + public void leaveOnSatisfiedCondition(final EventSubscriptionEntity eventSubscription, final VariableEvent variableEvent) { + final PvmExecutionImpl execution = eventSubscription.getExecution(); + + if (execution != null && !execution.isEnded() && execution.isScope() + && conditionalEvent.tryEvaluate(variableEvent, execution)) { + execution.executeEventHandlerActivity(eventSubscription.getActivity()); + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BoundaryEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BoundaryEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..9f5dfd987a31cb128e54255d84682df42ccb38f5 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BoundaryEventActivityBehavior.java @@ -0,0 +1,36 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.pvm.process.ActivityStartBehavior; + + +/** + *

The BPMN Boundary Event.

+ * + *

The behavior of the boundary event is defined via it's {@link ActivityStartBehavior}. It must be either + * {@value ActivityStartBehavior#CANCEL_EVENT_SCOPE} or {@value ActivityStartBehavior#CONCURRENT_IN_FLOW_SCOPE} meaning + * that it will either cancel the scope execution for the activity it is attached to (it's event scope) or will be executed concurrently + * in it's flow scope.

+ *

The boundary event does noting "special" in its inner behavior.

+ * + * @author Daniel Meyer + * @author Roman Smirnov + */ +public class BoundaryEventActivityBehavior extends FlowNodeActivityBehavior { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BpmnActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BpmnActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..49b55f016ac6ba6d9fb89d81bbc50c0838d1dd0e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BpmnActivityBehavior.java @@ -0,0 +1,143 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.impl.Condition; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse; +import org.camunda.bpm.engine.impl.pvm.PvmTransition; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.runtime.CompensationBehavior; +import org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl; + +/** + * Helper class for implementing BPMN 2.0 activities, offering convenience + * methods specific to BPMN 2.0. + * + * This class can be used by inheritance or aggregation. + * + * @author Joram Barrez + */ +public class BpmnActivityBehavior { + + protected static BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + /** + * Performs the default outgoing BPMN 2.0 behavior, which is having parallel + * paths of executions for the outgoing sequence flow. + * + * More precisely: every sequence flow that has a condition which evaluates to + * true (or which doesn't have a condition), is selected for continuation of + * the process instance. If multiple sequencer flow are selected, multiple, + * parallel paths of executions are created. + */ + public void performDefaultOutgoingBehavior(ActivityExecution activityExecution) { + performOutgoingBehavior(activityExecution, true); + } + + /** + * Performs the default outgoing BPMN 2.0 behavior (@see + * {@link #performDefaultOutgoingBehavior(ActivityExecution)}), but without + * checking the conditions on the outgoing sequence flow. + * + * This means that every outgoing sequence flow is selected for continuing the + * process instance, regardless of having a condition or not. In case of + * multiple outgoing sequence flow, multiple parallel paths of executions will + * be created. + */ + public void performIgnoreConditionsOutgoingBehavior(ActivityExecution activityExecution) { + performOutgoingBehavior(activityExecution, false); + } + + /** + * Actual implementation of leaving an activity. + * + * @param execution + * The current execution context + * @param checkConditions + * Whether or not to check conditions before determining whether or + * not to take a transition. + */ + protected void performOutgoingBehavior(ActivityExecution execution, + boolean checkConditions) { + + LOG.leavingActivity(execution.getActivity().getId()); + + String defaultSequenceFlow = (String) execution.getActivity().getProperty("default"); + List transitionsToTake = new ArrayList<>(); + + List outgoingTransitions = execution.getActivity().getOutgoingTransitions(); + for (PvmTransition outgoingTransition : outgoingTransitions) { + if (defaultSequenceFlow == null || !outgoingTransition.getId().equals(defaultSequenceFlow)) { + Condition condition = (Condition) outgoingTransition.getProperty(BpmnParse.PROPERTYNAME_CONDITION); + if (condition == null || !checkConditions || condition.evaluate(execution)) { + transitionsToTake.add(outgoingTransition); + } + } + } + + if (transitionsToTake.size() == 1) { + + execution.leaveActivityViaTransition(transitionsToTake.get(0)); + + } else if (transitionsToTake.size() >= 1) { + execution.leaveActivityViaTransitions(transitionsToTake, Arrays.asList(execution)); + } else { + + if (defaultSequenceFlow != null) { + PvmTransition defaultTransition = execution.getActivity().findOutgoingTransition(defaultSequenceFlow); + if (defaultTransition != null) { + execution.leaveActivityViaTransition(defaultTransition); + } else { + throw LOG.missingDefaultFlowException(execution.getActivity().getId(), defaultSequenceFlow); + } + + } else if (!outgoingTransitions.isEmpty()) { + throw LOG.missingConditionalFlowException(execution.getActivity().getId()); + + } else { + + if (((ActivityImpl) execution.getActivity()).isCompensationHandler() && isAncestorCompensationThrowing(execution)) { + + execution.endCompensation(); + + } else { + LOG.missingOutgoingSequenceFlow(execution.getActivity().getId()); + execution.end(true); + } + } + } + } + + protected boolean isAncestorCompensationThrowing(ActivityExecution execution) { + ActivityExecution parent = execution.getParent(); + while (parent != null) { + if (CompensationBehavior.isCompensationThrowing((PvmExecutionImpl) parent)) { + return true; + } + parent = parent.getParent(); + } + return false; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BpmnBehaviorLogger.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BpmnBehaviorLogger.java new file mode 100644 index 0000000000000000000000000000000000000000..40c0fe9c4d009953f673903170f52e717eb95680 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/BpmnBehaviorLogger.java @@ -0,0 +1,286 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity; +import org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl; + +/** + * @author Stefan Hentschel. + */ +public class BpmnBehaviorLogger extends ProcessEngineLogger { + + + public void missingBoundaryCatchEvent(String executionId, String errorCode, String errorMessage) { + logInfo( + "001", + "Execution with id '{}' throws an error event with errorCode '{}' and errorMessage '{}', but no catching boundary event was defined. " + + "Execution is ended (none end event semantics).", + executionId, + errorCode, + errorMessage + ); + } + + public void leavingActivity(String activityId) { + logDebug("002", "Leaving activity '{}'.", activityId); + } + + public void missingOutgoingSequenceFlow(String activityId) { + logDebug("003", "No outgoing sequence flow found for activity '{}'. Ending execution.", activityId); + } + + public ProcessEngineException stuckExecutionException(String activityId) { + return new ProcessEngineException(exceptionMessage( + "004", + "No outgoing sequence flow for the element with id '{}' could be selected for continuing the process.", + activityId + )); + } + + public ProcessEngineException missingDefaultFlowException(String activityId, String defaultSequenceFlow) { + return new ProcessEngineException( + exceptionMessage("005", "Default sequence flow '{}' for element with id '{}' could not be not found.", + defaultSequenceFlow, activityId) + ); + } + + public ProcessEngineException missingConditionalFlowException(String activityId) { + return new ProcessEngineException(exceptionMessage( + "006", + "No conditional sequence flow leaving the Flow Node '{}' could be selected for continuing the process.", + activityId + )); + } + + public ProcessEngineException incorrectlyUsedSignalException(String className) { + return new ProcessEngineException(exceptionMessage("007", "signal() can only be called on a '{}' instance.", className)); + } + + public ProcessEngineException missingDelegateParentClassException(String className, + String javaDelegate, String activityBehavior) { + + return new ProcessEngineException( + exceptionMessage("008", "Class '{}' doesn't implement '{}' nor '{}'.", className, javaDelegate, activityBehavior)); + } + + public void outgoingSequenceFlowSelected(String sequenceFlowId) { + logDebug("009", "Sequence flow with id '{}' was selected as outgoing sequence flow.", sequenceFlowId); + } + + public ProcessEngineException unsupportedSignalException(String activityId) { + return new ProcessEngineException(exceptionMessage("010", "The activity with id '{}' doesn't accept signals.", activityId)); + } + + public void activityActivation(String activityId) { + logDebug("011", "Element with id '{}' activates.", activityId); + } + + public void noActivityActivation(String activityId) { + logDebug("012", "Element with id '{}' does not activate.", activityId); + } + + public void ignoringEventSubscription(EventSubscriptionEntity eventSubscription, String processDefinitionId) { + logDebug( + "014", + "Found event subscription '{}' but process definition with id '{}' could not be found.", + eventSubscription.toString(), + processDefinitionId + ); + } + + public ProcessEngineException sendingEmailException(String recipient, Throwable cause) { + return new ProcessEngineException(exceptionMessage("015", "Unable to send email to recipient '{}'.", recipient), cause); + } + + public ProcessEngineException emailFormatException() { + return new ProcessEngineException( + exceptionMessage("016", "'html' or 'text' is required to be defined as mail format when using the mail activity.") + ); + } + + public ProcessEngineException emailCreationException(String format, Throwable cause) { + return new ProcessEngineException(exceptionMessage("017", "Unable to create a mail with format '{}'.", format), cause); + } + + public ProcessEngineException addRecipientException(String recipient, Throwable cause) { + return new ProcessEngineException(exceptionMessage("018", "Unable to add '{}' as recipient.", recipient), cause); + } + + public ProcessEngineException missingRecipientsException() { + return new ProcessEngineException(exceptionMessage("019", "No recipient could be found for sending email.")); + } + + public ProcessEngineException addSenderException(String sender, Throwable cause) { + return new ProcessEngineException(exceptionMessage("020", "Could not set '{}' as from address in email.", sender), cause); + } + + public ProcessEngineException addCcException(String cc, Throwable cause) { + return new ProcessEngineException(exceptionMessage("021", "Could not add '{}' as cc recipient.", cc), cause); + } + + public ProcessEngineException addBccException(String bcc, Throwable cause) { + return new ProcessEngineException(exceptionMessage("022", "Could not add '{}' as bcc recipient.", bcc), cause); + } + + public ProcessEngineException invalidAmountException(String type, int amount) { + return new ProcessEngineException(exceptionMessage( + "023", + "Invalid number of '{}': must be positive integer value or zero, but was '{}'.", + type, + amount + )); + } + + public ProcessEngineException unresolvableExpressionException(String expression, String type) { + return new ProcessEngineException( + exceptionMessage("024", "Expression '{}' didn't resolve to type '{}'.", expression, type) + ); + } + + public ProcessEngineException invalidVariableTypeException(String variable, String type) { + return new ProcessEngineException(exceptionMessage("025", "Variable '{}' is not of the expected type '{}'.", variable, type)); + } + + public ProcessEngineException resolveCollectionExpressionOrVariableReferenceException() { + return new ProcessEngineException(exceptionMessage("026", "Couldn't resolve collection expression nor variable reference")); + } + + public ProcessEngineException expressionNotANumberException(String type, String expression) { + return new ProcessEngineException(exceptionMessage( + "027", + "Could not resolve expression of type '{}'. Expression '{}' needs to be a number or number String.", + type, + expression + )); + } + + public ProcessEngineException expressionNotBooleanException(String type, String expression) { + return new ProcessEngineException(exceptionMessage( + "028", + "Could not resolve expression of type '{}'. Expression '{}' needs to evaluate to a boolean value.", + type, + expression + )); + } + + public void multiInstanceCompletionConditionState(Boolean state) { + logDebug("029", "Completion condition of multi-instance satisfied: '{}'", state); + } + + public void activityActivation(String activityId, int joinedExecutions, int availableExecution) { + logDebug( + "030", + "Element with id '{}' activates. Joined '{}' of '{}' available executions.", + activityId, + joinedExecutions, + availableExecution + ); + } + + public void noActivityActivation(String activityId, int joinedExecutions, int availableExecution) { + logDebug( + "031", + "Element with id '{}' does not activate. Joined '{}' of '{}' available executions.", + activityId, + joinedExecutions, + availableExecution + ); + } + + public ProcessEngineException unsupportedConcurrencyException(String scopeExecutionId, String className) { + return new ProcessEngineException(exceptionMessage( + "032", + "Execution '{}' with execution behavior of class '{}' cannot have concurrency.", + scopeExecutionId, + className + )); + } + + public ProcessEngineException resolveDelegateExpressionException(Expression expression, Class parentClass, Class javaDelegateClass) { + return new ProcessEngineException(exceptionMessage( + "033", + "Delegate Expression '{}' did neither resolve to an implementation of '{}' nor '{}'.", + expression, + parentClass, + javaDelegateClass + )); + } + + public ProcessEngineException shellExecutionException(Throwable cause) { + return new ProcessEngineException(exceptionMessage("034", "Could not execute shell command."), cause); + } + + public void errorPropagationException(String activityId, Throwable cause) { + logError("035", "Caught an exception while propagate error in activity with id '{}'", activityId, cause); + } + + public void debugConcurrentScopeIsPruned(PvmExecutionImpl execution) { + logDebug( + "036", "Concurrent scope is pruned {}", execution); + } + + public void debugCancelConcurrentScopeExecution(PvmExecutionImpl execution) { + logDebug( + "037", "Cancel concurrent scope execution {}", execution); + } + + public void destroyConcurrentScopeExecution(PvmExecutionImpl execution) { + logDebug( + "038", "Destroy concurrent scope execution", execution); + } + + public void completeNonScopeEventSubprocess() { + logDebug( + "039", "Destroy non-socpe event subprocess"); + } + + public void endConcurrentExecutionInEventSubprocess() { + logDebug( + "040", "End concurrent execution in event subprocess"); + } + + public ProcessEngineException missingDelegateVariableMappingParentClassException(String className, String delegateVarMapping) { + return new ProcessEngineException( + exceptionMessage("041", "Class '{}' doesn't implement '{}'.", className, delegateVarMapping)); + } + + public ProcessEngineException missingBoundaryCatchEventError(String executionId, String errorCode, String errorMessage) { + return new ProcessEngineException( + exceptionMessage( + "042", + "Execution with id '{}' throws an error event with errorCode '{}' and errorMessage '{}', but no error handler was defined. ", + executionId, + errorCode, + errorMessage)); + } + + + public ProcessEngineException missingBoundaryCatchEventEscalation(String executionId, String escalationCode) { + return new ProcessEngineException( + exceptionMessage( + "043", + "Execution with id '{}' throws an escalation event with escalationCode '{}', but no escalation handler was defined. ", + executionId, + escalationCode)); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CallActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CallActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..1de45c9ffc3bb3a680abb3f853cf19eadd177855 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CallActivityBehavior.java @@ -0,0 +1,86 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance; +import org.camunda.bpm.engine.impl.migration.instance.MigratingCalledProcessInstance; +import org.camunda.bpm.engine.impl.migration.instance.parser.MigratingInstanceParseContext; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.PvmProcessInstance; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.MigrationObserverBehavior; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.process.ProcessDefinitionImpl; +import org.camunda.bpm.engine.variable.VariableMap; + +import static org.camunda.bpm.engine.impl.util.CallableElementUtil.getProcessDefinitionToCall; + + +/** + * Implementation of the BPMN 2.0 call activity + * (limited currently to calling a subprocess and not (yet) a global task). + * + * @author Joram Barrez + * @author Roman Smirnov + */ +public class CallActivityBehavior extends CallableElementActivityBehavior implements MigrationObserverBehavior { + + public CallActivityBehavior() { + } + + public CallActivityBehavior(String className) { + super(className); + } + + public CallActivityBehavior(Expression expression) { + super(expression); + } + + @Override + protected void startInstance(ActivityExecution execution, VariableMap variables, String businessKey) { + ExecutionEntity executionEntity = (ExecutionEntity) execution; + + ProcessDefinitionImpl definition = getProcessDefinitionToCall( + executionEntity, + executionEntity.getProcessDefinitionTenantId(), + getCallableElement()); + PvmProcessInstance processInstance = execution.createSubProcessInstance(definition, businessKey); + processInstance.start(variables); + } + + @Override + public void migrateScope(ActivityExecution scopeExecution) { + } + + @Override + public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) { + ActivityImpl callActivity = (ActivityImpl) migratingInstance.getSourceScope(); + + // A call activity is typically scope and since we guarantee stability of scope executions during migration, + // the superExecution link does not have to be maintained during migration. + // There are some exceptions, though: A multi-instance call activity is not scope and therefore + // does not have a dedicated scope execution. In this case, the link to the super execution + // must be maintained throughout migration + if (!callActivity.isScope()) { + ExecutionEntity callActivityExecution = migratingInstance.resolveRepresentativeExecution(); + ExecutionEntity calledProcessInstance = callActivityExecution.getSubProcessInstance(); + migratingInstance.addMigratingDependentInstance(new MigratingCalledProcessInstance(calledProcessInstance)); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CallableElementActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CallableElementActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..77ac68f876b8291bd1ae497908c59ceb886b9580 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CallableElementActivityBehavior.java @@ -0,0 +1,225 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.concurrent.Callable; +import org.camunda.bpm.application.InvocationContext; +import org.camunda.bpm.application.ProcessApplicationReference; +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.delegate.DelegateVariableMapping; +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.delegate.VariableScope; + +import static org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.NUMBER_OF_ACTIVE_INSTANCES; +import static org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.NUMBER_OF_COMPLETED_INSTANCES; +import static org.camunda.bpm.engine.impl.bpmn.behavior.MultiInstanceActivityBehavior.NUMBER_OF_INSTANCES; + +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.context.ProcessApplicationContextUtil; +import org.camunda.bpm.engine.impl.core.model.BaseCallableElement.CallableElementBinding; +import org.camunda.bpm.engine.impl.core.model.CallableElement; +import org.camunda.bpm.engine.impl.delegate.DelegateInvocation; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.SubProcessActivityBehavior; +import org.camunda.bpm.engine.impl.util.ClassDelegateUtil; +import org.camunda.bpm.engine.variable.VariableMap; + +/** + * @author Roman Smirnov + * + */ +public abstract class CallableElementActivityBehavior extends AbstractBpmnActivityBehavior implements SubProcessActivityBehavior { + + protected String[] variablesFilter = { NUMBER_OF_INSTANCES, NUMBER_OF_ACTIVE_INSTANCES, NUMBER_OF_COMPLETED_INSTANCES }; + + protected CallableElement callableElement; + + /** + * The expression which identifies the delegation for the variable mapping. + */ + protected Expression expression; + + /** + * The class name of the delegated variable mapping, which should be used. + */ + protected String className; + + public CallableElementActivityBehavior() { + } + + public CallableElementActivityBehavior(String className) { + this.className = className; + } + + public CallableElementActivityBehavior(Expression expression) { + this.expression = expression; + } + + protected DelegateVariableMapping getDelegateVariableMapping(Object instance) { + if (instance instanceof DelegateVariableMapping) { + return (DelegateVariableMapping) instance; + } else { + throw LOG.missingDelegateVariableMappingParentClassException( + instance.getClass().getName(), + DelegateVariableMapping.class.getName()); + } + } + + protected DelegateVariableMapping resolveDelegation(ActivityExecution execution) { + Object delegate = resolveDelegateClass(execution); + return delegate != null ? getDelegateVariableMapping(delegate) : null; + } + + public Object resolveDelegateClass(final ActivityExecution execution) { + ProcessApplicationReference targetProcessApplication + = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution); + if (ProcessApplicationContextUtil.requiresContextSwitch(targetProcessApplication)) { + return Context.executeWithinProcessApplication(new Callable() { + + @Override + public Object call() throws Exception { + return resolveDelegateClass(execution); + } + }, targetProcessApplication, new InvocationContext(execution)); + } else { + return instantiateDelegateClass(execution); + } + } + + protected Object instantiateDelegateClass(ActivityExecution execution) { + Object delegate = null; + if (expression != null) { + delegate = expression.getValue(execution); + } else if (className != null) { + delegate = ClassDelegateUtil.instantiateDelegate(className, null); + } + return delegate; + } + + @Override + public void execute(final ActivityExecution execution) throws Exception { + final VariableMap variables = getInputVariables(execution); + + final DelegateVariableMapping varMapping = resolveDelegation(execution); + if (varMapping != null) { + invokeVarMappingDelegation(new DelegateInvocation(execution, null) { + @Override + protected void invoke() throws Exception { + varMapping.mapInputVariables(execution, variables); + } + }); + } + + String businessKey = getBusinessKey(execution); + startInstance(execution, variables, businessKey); + } + + @Override + public void passOutputVariables(final ActivityExecution execution, final VariableScope subInstance) { + // only data. no control flow available on this execution. + VariableMap variables = filterVariables(getOutputVariables(subInstance)); + VariableMap localVariables = getOutputVariablesLocal(subInstance); + + execution.setVariables(variables); + execution.setVariablesLocal(localVariables); + + final DelegateVariableMapping varMapping = resolveDelegation(execution); + if (varMapping != null) { + invokeVarMappingDelegation(new DelegateInvocation(execution, null) { + @Override + protected void invoke() throws Exception { + varMapping.mapOutputVariables(execution, subInstance); + } + }); + } + } + + protected void invokeVarMappingDelegation(DelegateInvocation delegation) { + try { + Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(delegation); + } catch (Exception ex) { + throw new ProcessEngineException(ex); + } + } + + protected VariableMap filterVariables(VariableMap variables) { + if (variables != null) { + for (String key : variablesFilter) { + variables.remove(key); + } + } + return variables; + } + + @Override + public void completed(ActivityExecution execution) throws Exception { + // only control flow. no sub instance data available + leave(execution); + } + + public CallableElement getCallableElement() { + return callableElement; + } + + public void setCallableElement(CallableElement callableElement) { + this.callableElement = callableElement; + } + + protected String getBusinessKey(ActivityExecution execution) { + return getCallableElement().getBusinessKey(execution); + } + + protected VariableMap getInputVariables(ActivityExecution callingExecution) { + return getCallableElement().getInputVariables(callingExecution); + } + + protected VariableMap getOutputVariables(VariableScope calledElementScope) { + return getCallableElement().getOutputVariables(calledElementScope); + } + + protected VariableMap getOutputVariablesLocal(VariableScope calledElementScope) { + return getCallableElement().getOutputVariablesLocal(calledElementScope); + } + + protected Integer getVersion(ActivityExecution execution) { + return getCallableElement().getVersion(execution); + } + + protected String getDeploymentId(ActivityExecution execution) { + return getCallableElement().getDeploymentId(); + } + + protected CallableElementBinding getBinding() { + return getCallableElement().getBinding(); + } + + protected boolean isLatestBinding() { + return getCallableElement().isLatestBinding(); + } + + protected boolean isDeploymentBinding() { + return getCallableElement().isDeploymentBinding(); + } + + protected boolean isVersionBinding() { + return getCallableElement().isVersionBinding(); + } + + protected abstract void startInstance(ActivityExecution execution, VariableMap variables, String businessKey); + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CancelBoundaryEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CancelBoundaryEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..d71033c4803e89e37ef504ce118df302351752e2 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CancelBoundaryEventActivityBehavior.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.runtime.LegacyBehavior; + +/** + * See CancelEndEventActivityBehavior: the cancel end event interrupts the scope and performs compensation. + * + * @author Daniel Meyer + */ +public class CancelBoundaryEventActivityBehavior extends BoundaryEventActivityBehavior { + + public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception { + + if (LegacyBehavior.signalCancelBoundaryEvent(signalName)) { + // join compensating executions + if (!execution.hasChildren()) { + leave(execution); + } + else { + ((ExecutionEntity)execution).forceUpdate(); + } + } + else { + super.signal(execution, signalName, signalData); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CancelEndEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CancelEndEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..b6fb213c9cd24a9cf4ef7ac1c9722fc2ed5ff386 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CancelEndEventActivityBehavior.java @@ -0,0 +1,82 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.List; + +import org.camunda.bpm.engine.impl.bpmn.helper.CompensationUtil; +import org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.PvmActivity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl; +import org.camunda.bpm.engine.impl.util.EnsureUtil; + + +/** + * @author Daniel Meyer + * @author Falko Menge + */ +public class CancelEndEventActivityBehavior extends AbstractBpmnActivityBehavior { + + protected PvmActivity cancelBoundaryEvent; + + @Override + public void execute(ActivityExecution execution) throws Exception { + + EnsureUtil + .ensureNotNull("Could not find cancel boundary event for cancel end event " + execution.getActivity(), "cancelBoundaryEvent", cancelBoundaryEvent); + + List compensateEventSubscriptions = + CompensationUtil.collectCompensateEventSubscriptionsForScope(execution); + + if(compensateEventSubscriptions.isEmpty()) { + leave(execution); + } + else { + CompensationUtil.throwCompensationEvent(compensateEventSubscriptions, execution, false); + } + + } + + public void doLeave(ActivityExecution execution) { + // continue via the appropriate cancel boundary event + ScopeImpl eventScope = (ScopeImpl) cancelBoundaryEvent.getEventScope(); + + ActivityExecution boundaryEventScopeExecution = execution.findExecutionForFlowScope(eventScope); + boundaryEventScopeExecution.executeActivity(cancelBoundaryEvent); + } + + public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception { + + // join compensating executions + if(!execution.hasChildren()) { + leave(execution); + } else { + ((ExecutionEntity)execution).forceUpdate(); + } + } + + public void setCancelBoundaryEvent(PvmActivity cancelBoundaryEvent) { + this.cancelBoundaryEvent = cancelBoundaryEvent; + } + + public PvmActivity getCancelBoundaryEvent() { + return cancelBoundaryEvent; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CaseCallActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CaseCallActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..5147f68d1c1a4d6210de53522baaa1d14e4c8241 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CaseCallActivityBehavior.java @@ -0,0 +1,72 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import static org.camunda.bpm.engine.impl.util.CallableElementUtil.getCaseDefinitionToCall; + +import org.camunda.bpm.engine.impl.cmmn.entity.runtime.CaseExecutionEntity; +import org.camunda.bpm.engine.impl.cmmn.execution.CmmnCaseInstance; +import org.camunda.bpm.engine.impl.cmmn.model.CmmnCaseDefinition; +import org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance; +import org.camunda.bpm.engine.impl.migration.instance.MigratingCalledCaseInstance; +import org.camunda.bpm.engine.impl.migration.instance.parser.MigratingInstanceParseContext; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.MigrationObserverBehavior; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.runtime.CaseInstance; +import org.camunda.bpm.engine.variable.VariableMap; + +/** + * Implementation to create a new {@link CaseInstance} using the BPMN 2.0 call activity + * + * @author Roman Smirnov + * + */ +public class CaseCallActivityBehavior extends CallableElementActivityBehavior implements MigrationObserverBehavior { + + protected void startInstance(ActivityExecution execution, VariableMap variables, String businessKey) { + ExecutionEntity executionEntity = (ExecutionEntity) execution; + + CmmnCaseDefinition definition = getCaseDefinitionToCall(executionEntity, + executionEntity.getProcessDefinitionTenantId(), + getCallableElement()); + CmmnCaseInstance caseInstance = execution.createSubCaseInstance(definition, businessKey); + caseInstance.create(variables); + } + + @Override + public void migrateScope(ActivityExecution scopeExecution) { + } + + @Override + public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) { + ActivityImpl callActivity = (ActivityImpl) migratingInstance.getSourceScope(); + + // A call activity is typically scope and since we guarantee stability of scope executions during migration, + // the superExecution link does not have to be maintained during migration. + // There are some exceptions, though: A multi-instance call activity is not scope and therefore + // does not have a dedicated scope execution. In this case, the link to the super execution + // must be maintained throughout migration + if (!callActivity.isScope()) { + ExecutionEntity callActivityExecution = migratingInstance.resolveRepresentativeExecution(); + CaseExecutionEntity calledCaseInstance = callActivityExecution.getSubCaseInstance(); + migratingInstance.addMigratingDependentInstance(new MigratingCalledCaseInstance(calledCaseInstance)); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ClassDelegateActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ClassDelegateActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..5d555f7691269ebbb236ea1fb22a0e45b858115d --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ClassDelegateActivityBehavior.java @@ -0,0 +1,127 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import static org.camunda.bpm.engine.impl.util.ClassDelegateUtil.instantiateDelegate; + +import java.util.List; +import java.util.concurrent.Callable; + +import org.camunda.bpm.application.InvocationContext; +import org.camunda.bpm.application.ProcessApplicationReference; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.context.ProcessApplicationContextUtil; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior; + + +/** + * Helper class for bpmn constructs that allow class delegation. + * + * This class will lazily instantiate the referenced classes when needed at runtime. + * + * @author Joram Barrez + * @author Falko Menge + * @author Roman Smirnov + */ +public class ClassDelegateActivityBehavior extends AbstractBpmnActivityBehavior { + + protected static final BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + protected String className; + protected List fieldDeclarations; + + public ClassDelegateActivityBehavior(String className, List fieldDeclarations) { + this.className = className; + this.fieldDeclarations = fieldDeclarations; + } + + public ClassDelegateActivityBehavior(Class clazz, List fieldDeclarations) { + this(clazz.getName(), fieldDeclarations); + } + + // Activity Behavior + @Override + public void execute(final ActivityExecution execution) throws Exception { + this.executeWithErrorPropagation(execution, new Callable() { + @Override + public Void call() throws Exception { + getActivityBehaviorInstance(execution).execute(execution); + return null; + } + }); + } + + // Signallable activity behavior + @Override + public void signal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception { + ProcessApplicationReference targetProcessApplication = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution); + if(ProcessApplicationContextUtil.requiresContextSwitch(targetProcessApplication)) { + Context.executeWithinProcessApplication(new Callable() { + public Void call() throws Exception { + signal(execution, signalName, signalData); + return null; + } + }, targetProcessApplication, new InvocationContext(execution)); + } + else { + doSignal(execution, signalName, signalData); + } + } + + protected void doSignal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception { + final ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution); + + if (activityBehaviorInstance instanceof CustomActivityBehavior) { + CustomActivityBehavior behavior = (CustomActivityBehavior) activityBehaviorInstance; + ActivityBehavior delegate = behavior.getDelegateActivityBehavior(); + + if (!(delegate instanceof SignallableActivityBehavior)) { + throw LOG.incorrectlyUsedSignalException(SignallableActivityBehavior.class.getName() ); + } + } + executeWithErrorPropagation(execution, new Callable() { + @Override + public Void call() throws Exception { + ((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData); + return null; + } + }); + } + + protected ActivityBehavior getActivityBehaviorInstance(ActivityExecution execution) { + Object delegateInstance = instantiateDelegate(className, fieldDeclarations); + + if (delegateInstance instanceof ActivityBehavior) { + return new CustomActivityBehavior((ActivityBehavior) delegateInstance); + } else if (delegateInstance instanceof JavaDelegate) { + return new ServiceTaskJavaDelegateActivityBehavior((JavaDelegate) delegateInstance); + } else { + throw LOG.missingDelegateParentClassException( + delegateInstance.getClass().getName(), + JavaDelegate.class.getName(), + ActivityBehavior.class.getName() + ); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CompensationEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CompensationEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..bd15f8b190cd07608fb028695f096b63f751e964 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CompensationEventActivityBehavior.java @@ -0,0 +1,78 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.List; + +import org.camunda.bpm.engine.impl.bpmn.helper.CompensationUtil; +import org.camunda.bpm.engine.impl.bpmn.parser.CompensateEventDefinition; +import org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl; + +/** + * Behavior for a compensation end event. + * + * @see IntermediateThrowCompensationEventActivityBehavior + * + * @author Philipp Ossler + * + */ +public class CompensationEventActivityBehavior extends FlowNodeActivityBehavior { + + protected final CompensateEventDefinition compensateEventDefinition; + + public CompensationEventActivityBehavior(CompensateEventDefinition compensateEventDefinition) { + this.compensateEventDefinition = compensateEventDefinition; + } + + @Override + public void execute(ActivityExecution execution) throws Exception { + + final List eventSubscriptions = collectEventSubscriptions(execution); + if (eventSubscriptions.isEmpty()) { + leave(execution); + } else { + // async (waitForCompletion=false in bpmn) is not supported + CompensationUtil.throwCompensationEvent(eventSubscriptions, execution, false); + } + } + + protected List collectEventSubscriptions(ActivityExecution execution) { + final String activityRef = compensateEventDefinition.getActivityRef(); + if (activityRef != null) { + return CompensationUtil.collectCompensateEventSubscriptionsForActivity(execution, activityRef); + } else { + return CompensationUtil.collectCompensateEventSubscriptionsForScope(execution); + } + } + + @Override + public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception { + // join compensating executions - + // only wait for non-event-scope executions cause a compensation event subprocess consume the compensation event and + // do not have to compensate embedded subprocesses (which are still non-event-scope executions) + + if (((PvmExecutionImpl) execution).getNonEventScopeExecutions().isEmpty()) { + leave(execution); + } else { + ((ExecutionEntity) execution).forceUpdate(); + } + } + +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ConditionalEventBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ConditionalEventBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..884be7aec73bda85cc2bbb2330ba55d543c07d36 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ConditionalEventBehavior.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.bpmn.parser.ConditionalEventDefinition; +import org.camunda.bpm.engine.impl.core.variable.event.VariableEvent; +import org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity; + +/** + * Represents an interface for the condition event behaviors. + * Makes it possible to leave the current activity if the condition of the + * conditional event is satisfied. + * + * @author Christopher Zell + */ +public interface ConditionalEventBehavior { + + /** + * Returns the current conditional event definition. + * + * @return the conditional event definition + */ + ConditionalEventDefinition getConditionalEventDefinition(); + + /** + * Checks the condition, on satisfaction the activity is leaved. + * + * @param eventSubscription the event subscription which contains all necessary informations + * @param variableEvent the variableEvent to evaluate the condition + */ + void leaveOnSatisfiedCondition(final EventSubscriptionEntity eventSubscription, final VariableEvent variableEvent); +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CustomActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CustomActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..07f7a3ad0797410eaa96d3d800ebbeb864e4ae83 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/CustomActivityBehavior.java @@ -0,0 +1,56 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.bpmn.delegate.ActivityBehaviorInvocation; +import org.camunda.bpm.engine.impl.bpmn.delegate.ActivityBehaviorSignalInvocation; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior; + +/** + * @author Roman Smirnov + * + */ +public class CustomActivityBehavior implements ActivityBehavior, SignallableActivityBehavior { + + protected ActivityBehavior delegateActivityBehavior; + + public CustomActivityBehavior(ActivityBehavior activityBehavior) { + this.delegateActivityBehavior = activityBehavior; + } + + public void execute(ActivityExecution execution) throws Exception { + Context + .getProcessEngineConfiguration() + .getDelegateInterceptor() + .handleInvocation(new ActivityBehaviorInvocation(delegateActivityBehavior, execution)); + } + + public void signal(ActivityExecution execution, String signalEvent, Object signalData) throws Exception { + Context + .getProcessEngineConfiguration() + .getDelegateInterceptor() + .handleInvocation(new ActivityBehaviorSignalInvocation((SignallableActivityBehavior) delegateActivityBehavior, execution, signalEvent, signalData)); + } + + public ActivityBehavior getDelegateActivityBehavior() { + return delegateActivityBehavior; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/DmnBusinessRuleTaskActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/DmnBusinessRuleTaskActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..3469216d06fbc3bfa684850d4af32785234522b5 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/DmnBusinessRuleTaskActivityBehavior.java @@ -0,0 +1,71 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import static org.camunda.bpm.engine.impl.util.DecisionEvaluationUtil.evaluateDecision; + +import java.util.concurrent.Callable; + +import org.camunda.bpm.engine.delegate.VariableScope; +import org.camunda.bpm.engine.impl.core.model.BaseCallableElement; +import org.camunda.bpm.engine.impl.core.variable.scope.AbstractVariableScope; +import org.camunda.bpm.engine.impl.dmn.result.DecisionResultMapper; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +/** + * Implementation of a Bpmn BusinessRuleTask executing a DMN Decision. + * + * The decision is resolved as a {@link BaseCallableElement}. + * + * The decision is executed in the context of the current {@link VariableScope}. + * + * @author Daniel Meyer + * + */ +public class DmnBusinessRuleTaskActivityBehavior extends AbstractBpmnActivityBehavior { + + protected final BaseCallableElement callableElement; + protected final String resultVariable; + protected final DecisionResultMapper decisionResultMapper; + + public DmnBusinessRuleTaskActivityBehavior(BaseCallableElement callableElement, String resultVariableName, DecisionResultMapper decisionResultMapper) { + this.callableElement = callableElement; + this.resultVariable = resultVariableName; + this.decisionResultMapper = decisionResultMapper; + } + + @Override + public void execute(final ActivityExecution execution) throws Exception { + executeWithErrorPropagation(execution, new Callable() { + + public Void call() throws Exception { + ExecutionEntity executionEntity = (ExecutionEntity) execution; + + evaluateDecision(executionEntity, + executionEntity.getProcessDefinitionTenantId(), + callableElement, + resultVariable, + decisionResultMapper); + leave(execution); + return null; + } + + }); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ErrorEndEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ErrorEndEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..3855d736ab501c7481ea34c515a46710800d5639 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ErrorEndEventActivityBehavior.java @@ -0,0 +1,57 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.bpmn.helper.BpmnExceptionHandler; +import org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + + +/** + * @author Joram Barrez + * @author Falko Menge + */ +public class ErrorEndEventActivityBehavior extends AbstractBpmnActivityBehavior { + + protected String errorCode; + private ParameterValueProvider errorMessageExpression; + + public ErrorEndEventActivityBehavior(String errorCode, ParameterValueProvider errorMessage) { + this.errorCode = errorCode; + this.errorMessageExpression = errorMessage; + } + + public void execute(ActivityExecution execution) throws Exception { + String errorMessageValue = errorMessageExpression != null ? (String) errorMessageExpression.getValue(execution) : null; + BpmnExceptionHandler.propagateError(errorCode, errorMessageValue, null, execution); + } + + public String getErrorCode() { + return errorCode; + } + public void setErrorCode(String errorCode) { + this.errorCode = errorCode; + } + + public ParameterValueProvider getErrorMessageExpression() { + return errorMessageExpression; + } + + public void setErrorMessageExpression(ParameterValueProvider errorMessage) { + this.errorMessageExpression = errorMessage; + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventBasedGatewayActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventBasedGatewayActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..78ed3596e98105541c92a36514a728db44253a79 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventBasedGatewayActivityBehavior.java @@ -0,0 +1,48 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.bpmn.parser.ConditionalEventDefinition; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; + +/** + * @author Daniel Meyer + */ +public class EventBasedGatewayActivityBehavior extends FlowNodeActivityBehavior { + + @Override + public void execute(ActivityExecution execution) throws Exception { + // If conditional events exist after the event based gateway they should be evaluated. + // If a condition is satisfied the event based gateway should be left, + // otherwise the event based gateway is a wait state + ActivityImpl eventBasedGateway = (ActivityImpl) execution.getActivity(); + for (ActivityImpl act : eventBasedGateway.getEventActivities()) { + ActivityBehavior activityBehavior = act.getActivityBehavior(); + if (activityBehavior instanceof ConditionalEventBehavior) { + ConditionalEventBehavior conditionalEventBehavior = (ConditionalEventBehavior) activityBehavior; + ConditionalEventDefinition conditionalEventDefinition = conditionalEventBehavior.getConditionalEventDefinition(); + if (conditionalEventDefinition.tryEvaluate(execution)) { + ((ExecutionEntity) execution).executeEventHandlerActivity(conditionalEventDefinition.getConditionalActivity()); + return; + } + } + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventSubProcessActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventSubProcessActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..6dbd47fbc181af2dbe270befb10a19c7d2f69ecc --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventSubProcessActivityBehavior.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.runtime.LegacyBehavior; + +/** + * @author Daniel Meyer + * + */ +public class EventSubProcessActivityBehavior extends SubProcessActivityBehavior { + + public void complete(ActivityExecution scopeExecution) { + // check whether legacy behavior needs to be performed. + if(!LegacyBehavior.eventSubprocessComplete(scopeExecution)) { + // in case legacy behavior is not performed, the event subprocess behaves in the same way as a regular subprocess. + super.complete(scopeExecution); + } + } + + public void concurrentChildExecutionEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution) { + // Check whether legacy behavior needs to be performed. + // Legacy behavior means that the event subprocess is not a scope and as a result does not + // join concurrent executions on it's own. Instead it delegates to the the subprocess activity behavior in which it is embedded. + if(!LegacyBehavior.eventSubprocessConcurrentChildExecutionEnded(scopeExecution, endedExecution)) { + // in case legacy behavior is not performed, the event subprocess behaves in the same way as a regular subprocess. + super.concurrentChildExecutionEnded(scopeExecution, endedExecution); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventSubProcessStartConditionalEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventSubProcessStartConditionalEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..5914b22a6775f17a381f64d28c7b9eca3bdca63f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventSubProcessStartConditionalEventActivityBehavior.java @@ -0,0 +1,55 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.bpmn.parser.ConditionalEventDefinition; +import org.camunda.bpm.engine.impl.core.variable.event.VariableEvent; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl; + +/** + * + * @author Christopher Zell + */ +public class EventSubProcessStartConditionalEventActivityBehavior extends EventSubProcessStartEventActivityBehavior implements ConditionalEventBehavior { + + protected final ConditionalEventDefinition conditionalEvent; + + public EventSubProcessStartConditionalEventActivityBehavior(ConditionalEventDefinition conditionalEvent) { + this.conditionalEvent = conditionalEvent; + } + + @Override + public ConditionalEventDefinition getConditionalEventDefinition() { + return conditionalEvent; + } + + @Override + public void leaveOnSatisfiedCondition(final EventSubscriptionEntity eventSubscription, final VariableEvent variableEvent) { + PvmExecutionImpl execution = eventSubscription.getExecution(); + + if (execution != null && !execution.isEnded() && execution.isScope() + && conditionalEvent.tryEvaluate(variableEvent, execution)) { + ActivityImpl activity = eventSubscription.getActivity(); + activity = (ActivityImpl) activity.getFlowScope(); + execution.executeEventHandlerActivity(activity); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventSubProcessStartEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventSubProcessStartEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..e7b8552f7f43166f997df3088e7afc8e2132138b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/EventSubProcessStartEventActivityBehavior.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.pvm.process.ActivityStartBehavior; + + +/** + *

Specialization of the Start Event for Event Sub-Processes.

+ * + *

The start event's behavior is realized by the start behavior of the event subprocess it is embedded in. + * The start behavior of the event subprocess must be either either {@link ActivityStartBehavior#INTERRUPT_EVENT_SCOPE} or + * {@link ActivityStartBehavior#CONCURRENT_IN_FLOW_SCOPE}

+ * + * @author Daniel Meyer + * @author Roman Smirnov + */ +public class EventSubProcessStartEventActivityBehavior extends NoneStartEventActivityBehavior { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ExclusiveGatewayActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ExclusiveGatewayActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..500bdd1696443e280d3e25b1fda799cf51664875 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ExclusiveGatewayActivityBehavior.java @@ -0,0 +1,89 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.Iterator; + +import org.camunda.bpm.engine.impl.Condition; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse; +import org.camunda.bpm.engine.impl.pvm.PvmTransition; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + + +/** + * implementation of the Exclusive Gateway/XOR gateway/exclusive data-based gateway + * as defined in the BPMN specification. + * + * @author Joram Barrez + */ +public class ExclusiveGatewayActivityBehavior extends GatewayActivityBehavior { + + protected static BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + /** + * The default behaviour of BPMN, taking every outgoing sequence flow + * (where the condition evaluates to true), is not valid for an exclusive + * gateway. + * + * Hence, this behaviour is overriden and replaced by the correct behavior: + * selecting the first sequence flow which condition evaluates to true + * (or which hasn't got a condition) and leaving the activity through that + * sequence flow. + * + * If no sequence flow is selected (ie all conditions evaluate to false), + * then the default sequence flow is taken (if defined). + */ + @Override + public void doLeave(ActivityExecution execution) { + + LOG.leavingActivity(execution.getActivity().getId()); + + PvmTransition outgoingSeqFlow = null; + String defaultSequenceFlow = (String) execution.getActivity().getProperty("default"); + Iterator transitionIterator = execution.getActivity().getOutgoingTransitions().iterator(); + while (outgoingSeqFlow == null && transitionIterator.hasNext()) { + PvmTransition seqFlow = transitionIterator.next(); + + Condition condition = (Condition) seqFlow.getProperty(BpmnParse.PROPERTYNAME_CONDITION); + if ( (condition == null && (defaultSequenceFlow == null || !defaultSequenceFlow.equals(seqFlow.getId())) ) + || (condition != null && condition.evaluate(execution)) ) { + + LOG.outgoingSequenceFlowSelected(seqFlow.getId()); + outgoingSeqFlow = seqFlow; + } + } + + if (outgoingSeqFlow != null) { + execution.leaveActivityViaTransition(outgoingSeqFlow); + } else { + + if (defaultSequenceFlow != null) { + PvmTransition defaultTransition = execution.getActivity().findOutgoingTransition(defaultSequenceFlow); + if (defaultTransition != null) { + execution.leaveActivityViaTransition(defaultTransition); + } else { + throw LOG.missingDefaultFlowException(execution.getActivity().getId(), defaultSequenceFlow); + } + } else { + //No sequence flow could be found, not even a default one + throw LOG.stuckExecutionException(execution.getActivity().getId()); + } + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ExternalTaskActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ExternalTaskActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..04c76cf2a960d563cad923de396f39d75d74de97 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ExternalTaskActivityBehavior.java @@ -0,0 +1,83 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.PriorityProvider; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.core.variable.mapping.value.ParameterValueProvider; +import org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance; +import org.camunda.bpm.engine.impl.migration.instance.MigratingExternalTaskInstance; +import org.camunda.bpm.engine.impl.migration.instance.parser.MigratingInstanceParseContext; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.ExternalTaskEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.MigrationObserverBehavior; + +/** + * Implements behavior of external task activities, i.e. all service-task-like + * activities that have camunda:type="external". + * + * @author Thorben Lindhauer + * @author Christopher Zell + */ +public class ExternalTaskActivityBehavior extends AbstractBpmnActivityBehavior implements MigrationObserverBehavior { + + protected ParameterValueProvider topicNameValueProvider; + protected ParameterValueProvider priorityValueProvider; + + public ExternalTaskActivityBehavior(ParameterValueProvider topicName, ParameterValueProvider paramValueProvider) { + this.topicNameValueProvider = topicName; + this.priorityValueProvider = paramValueProvider; + } + + @Override + public void execute(ActivityExecution execution) throws Exception { + ExecutionEntity executionEntity = (ExecutionEntity) execution; + PriorityProvider provider = Context.getProcessEngineConfiguration().getExternalTaskPriorityProvider(); + + long priority = provider.determinePriority(executionEntity, this, null); + String topic = (String) topicNameValueProvider.getValue(executionEntity); + + ExternalTaskEntity.createAndInsert(executionEntity, topic, priority); + + } + + @Override + public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception { + leave(execution); + } + + public ParameterValueProvider getPriorityValueProvider() { + return priorityValueProvider; + } + + @Override + public void migrateScope(ActivityExecution scopeExecution) { + } + + @Override + public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) { + ExecutionEntity execution = migratingInstance.resolveRepresentativeExecution(); + + for (ExternalTaskEntity task : execution.getExternalTasks()) { + MigratingExternalTaskInstance migratingTask = new MigratingExternalTaskInstance(task, migratingInstance); + migratingInstance.addMigratingDependentInstance(migratingTask); + parseContext.consume(task); + parseContext.submit(migratingTask); + } + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/FlowNodeActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/FlowNodeActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..27d02d8edd476dab6db3c1d0b73aeb850389407c --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/FlowNodeActivityBehavior.java @@ -0,0 +1,68 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior; +import org.camunda.bpm.engine.impl.pvm.runtime.operation.PvmAtomicOperation; + + +/** + * Superclass for all 'connectable' BPMN 2.0 process elements: tasks, gateways and events. + * This means that any subclass can be the source or target of a sequenceflow. + * + * Corresponds with the notion of the 'flownode' in BPMN 2.0. + * + * @author Joram Barrez + */ +public abstract class FlowNodeActivityBehavior implements SignallableActivityBehavior { + + protected static final BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + protected BpmnActivityBehavior bpmnActivityBehavior = new BpmnActivityBehavior(); + + /** + * Default behaviour: just leave the activity with no extra functionality. + */ + public void execute(ActivityExecution execution) throws Exception { + leave(execution); + } + + /** + * Default way of leaving a BPMN 2.0 activity: evaluate the conditions on the + * outgoing sequence flow and take those that evaluate to true. + */ + public void leave(ActivityExecution execution) { + ((ExecutionEntity) execution).dispatchDelayedEventsAndPerformOperation(PvmAtomicOperation.ACTIVITY_LEAVE); + } + + public void doLeave(ActivityExecution execution) { + bpmnActivityBehavior.performDefaultOutgoingBehavior(execution); + } + + protected void leaveIgnoreConditions(ActivityExecution activityContext) { + bpmnActivityBehavior.performIgnoreConditionsOutgoingBehavior(activityContext); + } + + public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception { + // concrete activity behaviors that do accept signals should override this method; + + throw LOG.unsupportedSignalException(execution.getActivity().getId()); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/GatewayActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/GatewayActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..b83dcd4f64023acc7b441aa6e2488ff0b1672c65 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/GatewayActivityBehavior.java @@ -0,0 +1,40 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + + +/** + * super class for all gateway activity implementations. + * + * @author Joram Barrez + */ +public abstract class GatewayActivityBehavior extends FlowNodeActivityBehavior { + + protected void lockConcurrentRoot(ActivityExecution execution) { + ActivityExecution concurrentRoot = null; + if (execution.isConcurrent()) { + concurrentRoot = execution.getParent(); + } else { + concurrentRoot = execution; + } + ((ExecutionEntity)concurrentRoot).forceUpdate(); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/InclusiveGatewayActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/InclusiveGatewayActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..eaa9bc3edb97fe650668748cbff7b827ef2b04fb --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/InclusiveGatewayActivityBehavior.java @@ -0,0 +1,202 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.camunda.bpm.engine.impl.Condition; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse; +import org.camunda.bpm.engine.impl.pvm.PvmActivity; +import org.camunda.bpm.engine.impl.pvm.PvmTransition; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.process.ScopeImpl; + +/** + * Implementation of the Inclusive Gateway/OR gateway/inclusive data-based + * gateway as defined in the BPMN specification. + * + * @author Tijs Rademakers + * @author Tom Van Buskirk + * @author Joram Barrez + */ +public class InclusiveGatewayActivityBehavior extends GatewayActivityBehavior { + + protected static BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + public void execute(ActivityExecution execution) throws Exception { + + execution.inactivate(); + lockConcurrentRoot(execution); + + PvmActivity activity = execution.getActivity(); + if (activatesGateway(execution, activity)) { + + LOG.activityActivation(activity.getId()); + + List joinedExecutions = execution.findInactiveConcurrentExecutions(activity); + String defaultSequenceFlow = (String) execution.getActivity().getProperty("default"); + List transitionsToTake = new ArrayList(); + + // find matching non-default sequence flows + for (PvmTransition outgoingTransition : execution.getActivity().getOutgoingTransitions()) { + if (defaultSequenceFlow == null || !outgoingTransition.getId().equals(defaultSequenceFlow)) { + Condition condition = (Condition) outgoingTransition.getProperty(BpmnParse.PROPERTYNAME_CONDITION); + if (condition == null || condition.evaluate(execution)) { + transitionsToTake.add(outgoingTransition); + } + } + } + + // if none found, add default flow + if (transitionsToTake.isEmpty()) { + if (defaultSequenceFlow != null) { + PvmTransition defaultTransition = execution.getActivity().findOutgoingTransition(defaultSequenceFlow); + if (defaultTransition == null) { + throw LOG.missingDefaultFlowException(execution.getActivity().getId(), defaultSequenceFlow); + } + + transitionsToTake.add(defaultTransition); + + } else { + // No sequence flow could be found, not even a default one + throw LOG.stuckExecutionException(execution.getActivity().getId()); + } + } + + // take the flows found + execution.leaveActivityViaTransitions(transitionsToTake, joinedExecutions); + } else { + LOG.noActivityActivation(activity.getId()); + } + } + + protected Collection getLeafExecutions(ActivityExecution parent) { + List executionlist = new ArrayList(); + List subExecutions = parent.getNonEventScopeExecutions(); + if (subExecutions.size() == 0) { + executionlist.add(parent); + } else { + for (ActivityExecution concurrentExecution : subExecutions) { + executionlist.addAll(getLeafExecutions(concurrentExecution)); + } + } + + return executionlist; + } + + protected boolean activatesGateway(ActivityExecution execution, PvmActivity gatewayActivity) { + int numExecutionsGuaranteedToActivate = gatewayActivity.getIncomingTransitions().size(); + ActivityExecution scopeExecution = execution.isScope() ? execution : execution.getParent(); + + List executionsAtGateway = execution.findInactiveConcurrentExecutions(gatewayActivity); + + if (executionsAtGateway.size() >= numExecutionsGuaranteedToActivate) { + return true; + } + else { + Collection executionsNotAtGateway = getLeafExecutions(scopeExecution); + executionsNotAtGateway.removeAll(executionsAtGateway); + + for (ActivityExecution executionNotAtGateway : executionsNotAtGateway) { + if (canReachActivity(executionNotAtGateway, gatewayActivity)) { + return false; + } + } + + // if no more token may arrive, then activate + return true; + } + + } + + protected boolean canReachActivity(ActivityExecution execution, PvmActivity activity) { + PvmTransition pvmTransition = execution.getTransition(); + if (pvmTransition != null) { + return isReachable(pvmTransition.getDestination(), activity, new HashSet()); + } else { + return isReachable(execution.getActivity(), activity, new HashSet()); + } + } + + protected boolean isReachable(PvmActivity srcActivity, PvmActivity targetActivity, Set visitedActivities) { + if (srcActivity.equals(targetActivity)) { + return true; + } + + if (visitedActivities.contains(srcActivity)) { + return false; + } + + // To avoid infinite looping, we must capture every node we visit and + // check before going further in the graph if we have already visited the node. + visitedActivities.add(srcActivity); + + List outgoingTransitions = srcActivity.getOutgoingTransitions(); + + if (outgoingTransitions.isEmpty()) { + + if (srcActivity.getActivityBehavior() instanceof EventBasedGatewayActivityBehavior) { + + ActivityImpl eventBasedGateway = (ActivityImpl) srcActivity; + Set eventActivities = eventBasedGateway.getEventActivities(); + + for (ActivityImpl eventActivity : eventActivities) { + boolean isReachable = isReachable(eventActivity, targetActivity, visitedActivities); + + if (isReachable) { + return true; + } + } + + } + else { + + ScopeImpl flowScope = srcActivity.getFlowScope(); + if (flowScope != null && flowScope instanceof PvmActivity) { + return isReachable((PvmActivity) flowScope, targetActivity, visitedActivities); + } + + } + + return false; + } + else { + for (PvmTransition pvmTransition : outgoingTransitions) { + PvmActivity destinationActivity = pvmTransition.getDestination(); + if (destinationActivity != null && !visitedActivities.contains(destinationActivity)) { + + boolean reachable = isReachable(destinationActivity, targetActivity, visitedActivities); + + // If false, we should investigate other paths, and not yet return the result + if (reachable) { + return true; + } + + } + } + } + + return false; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateCatchEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateCatchEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..446c943b992b86a4fb78a491e62deac1032368e0 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateCatchEventActivityBehavior.java @@ -0,0 +1,53 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +/** + * + * @author Daniel Meyer + * @author Roman Smirnov + * + */ +public class IntermediateCatchEventActivityBehavior extends AbstractBpmnActivityBehavior { + + protected boolean isAfterEventBasedGateway; + + public IntermediateCatchEventActivityBehavior(boolean isAfterEventBasedGateway) { + this.isAfterEventBasedGateway = isAfterEventBasedGateway; + } + + public void execute(ActivityExecution execution) throws Exception { + if (isAfterEventBasedGateway) { + leave(execution); + + } else { + // Do nothing: waitstate behavior + } + } + + public boolean isAfterEventBasedGateway() { + return isAfterEventBasedGateway; + } + + @Override + public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception { + leave(execution); + } +} + diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateCatchLinkEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateCatchLinkEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..4215473ad614f0f97adca84ae2e83f1290002b8f --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateCatchLinkEventActivityBehavior.java @@ -0,0 +1,34 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +/** + * + * @author Bernd Rücker + * + */ +public class IntermediateCatchLinkEventActivityBehavior extends AbstractBpmnActivityBehavior { + + @Override + public void execute(ActivityExecution execution) throws Exception { + // a link event does not behave as a wait state + leave(execution); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateConditionalEventBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateConditionalEventBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..80b47d83daf3608698e472de2af588ce6805dcd8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateConditionalEventBehavior.java @@ -0,0 +1,68 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.bpmn.parser.ConditionalEventDefinition; +import org.camunda.bpm.engine.impl.core.variable.event.VariableEvent; +import org.camunda.bpm.engine.impl.interceptor.CommandContext; +import org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl; + +/** + * + * @author Christopher Zell + */ +public class IntermediateConditionalEventBehavior extends IntermediateCatchEventActivityBehavior implements ConditionalEventBehavior { + + protected final ConditionalEventDefinition conditionalEvent; + + public IntermediateConditionalEventBehavior(ConditionalEventDefinition conditionalEvent, boolean isAfterEventBasedGateway) { + super(isAfterEventBasedGateway); + this.conditionalEvent = conditionalEvent; + } + + @Override + public ConditionalEventDefinition getConditionalEventDefinition() { + return conditionalEvent; + } + + @Override + public void execute(final ActivityExecution execution) throws Exception { + if (isAfterEventBasedGateway || conditionalEvent.tryEvaluate(execution)) { + leave(execution); + } + } + + @Override + public void leaveOnSatisfiedCondition(final EventSubscriptionEntity eventSubscription, final VariableEvent variableEvent) { + PvmExecutionImpl execution = eventSubscription.getExecution(); + + if (execution != null && !execution.isEnded() + && variableEvent != null + && conditionalEvent.tryEvaluate(variableEvent, execution) + && execution.isActive() && execution.isScope()) { + if (isAfterEventBasedGateway) { + final ActivityImpl activity = eventSubscription.getActivity(); + execution.executeEventHandlerActivity(activity); + } else { + leave(execution); + } + } + } +} \ No newline at end of file diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateThrowNoneEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateThrowNoneEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..9c812dd445b1796754073041f99034b51925d420 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/IntermediateThrowNoneEventActivityBehavior.java @@ -0,0 +1,21 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +public class IntermediateThrowNoneEventActivityBehavior extends FlowNodeActivityBehavior{ + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/MailActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/MailActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..c08862d53cf46a7b2c74d1df15b660698866a4b8 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/MailActivityBehavior.java @@ -0,0 +1,217 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import org.apache.commons.mail.Email; +import org.apache.commons.mail.EmailException; +import org.apache.commons.mail.HtmlEmail; +import org.apache.commons.mail.SimpleEmail; +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +/** + * @author Joram Barrez + * @author Frederik Heremans + */ +public class MailActivityBehavior extends AbstractBpmnActivityBehavior { + + protected static final BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + protected Expression to; + protected Expression from; + protected Expression cc; + protected Expression bcc; + protected Expression subject; + protected Expression text; + protected Expression html; + protected Expression charset; + + public void execute(ActivityExecution execution) { + String toStr = getStringFromField(to, execution); + String fromStr = getStringFromField(from, execution); + String ccStr = getStringFromField(cc, execution); + String bccStr = getStringFromField(bcc, execution); + String subjectStr = getStringFromField(subject, execution); + String textStr = getStringFromField(text, execution); + String htmlStr = getStringFromField(html, execution); + String charSetStr = getStringFromField(charset, execution); + + Email email = createEmail(textStr, htmlStr); + + addTo(email, toStr); + setFrom(email, fromStr); + addCc(email, ccStr); + addBcc(email, bccStr); + setSubject(email, subjectStr); + setMailServerProperties(email); + setCharset(email, charSetStr); + + try { + email.send(); + } catch (EmailException e) { + throw LOG.sendingEmailException(toStr, e); + } + leave(execution); + } + + protected Email createEmail(String text, String html) { + if (html != null) { + return createHtmlEmail(text, html); + } else if (text != null) { + return createTextOnlyEmail(text); + } else { + throw LOG.emailFormatException(); + } + } + + protected HtmlEmail createHtmlEmail(String text, String html) { + HtmlEmail email = new HtmlEmail(); + try { + email.setHtmlMsg(html); + if (text != null) { // for email clients that don't support html + email.setTextMsg(text); + } + return email; + } catch (EmailException e) { + throw LOG.emailCreationException("HTML", e); + } + } + + protected SimpleEmail createTextOnlyEmail(String text) { + SimpleEmail email = new SimpleEmail(); + try { + email.setMsg(text); + return email; + } catch (EmailException e) { + throw LOG.emailCreationException("text-only", e); + } + } + + protected void addTo(Email email, String to) { + String[] tos = splitAndTrim(to); + if (tos != null) { + for (String t : tos) { + try { + email.addTo(t); + } catch (EmailException e) { + throw LOG.addRecipientException(t, e); + } + } + } else { + throw LOG.missingRecipientsException(); + } + } + + protected void setFrom(Email email, String from) { + String fromAddress = null; + + if (from != null) { + fromAddress = from; + } else { // use default configured from address in process engine config + fromAddress = Context.getProcessEngineConfiguration().getMailServerDefaultFrom(); + } + + try { + email.setFrom(fromAddress); + } catch (EmailException e) { + throw LOG.addSenderException(from, e); + } + } + + protected void addCc(Email email, String cc) { + String[] ccs = splitAndTrim(cc); + if (ccs != null) { + for (String c : ccs) { + try { + email.addCc(c); + } catch (EmailException e) { + throw LOG.addCcException(c, e); + } + } + } + } + + protected void addBcc(Email email, String bcc) { + String[] bccs = splitAndTrim(bcc); + if (bccs != null) { + for (String b : bccs) { + try { + email.addBcc(b); + } catch (EmailException e) { + throw LOG.addBccException(b, e); + } + } + } + } + + protected void setSubject(Email email, String subject) { + email.setSubject(subject != null ? subject : ""); + } + + protected void setMailServerProperties(Email email) { + ProcessEngineConfigurationImpl processEngineConfiguration = Context.getProcessEngineConfiguration(); + + String host = processEngineConfiguration.getMailServerHost(); + ensureNotNull("Could not send email: no SMTP host is configured", "host", host); + email.setHostName(host); + + int port = processEngineConfiguration.getMailServerPort(); + email.setSmtpPort(port); + + email.setTLS(processEngineConfiguration.getMailServerUseTLS()); + + String user = processEngineConfiguration.getMailServerUsername(); + String password = processEngineConfiguration.getMailServerPassword(); + if (user != null && password != null) { + email.setAuthentication(user, password); + } + } + + protected void setCharset(Email email, String charSetStr) { + if (charset != null) { + email.setCharset(charSetStr); + } + } + + protected String[] splitAndTrim(String str) { + if (str != null) { + String[] splittedStrings = str.split(","); + for (int i = 0; i < splittedStrings.length; i++) { + splittedStrings[i] = splittedStrings[i].trim(); + } + return splittedStrings; + } + return null; + } + + protected String getStringFromField(Expression expression, DelegateExecution execution) { + if(expression != null) { + Object value = expression.getValue(execution); + if(value != null) { + return value.toString(); + } + } + return null; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ManualTaskActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ManualTaskActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..09ccdfa92f065ff8f0d351362c86e0450931b210 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ManualTaskActivityBehavior.java @@ -0,0 +1,30 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +/** + * Implementation of the BPMN 2.0 'manual task': a task that is external to the + * BPMS and to which there is no reference to IT systems whatsoever. + * + * Given this definition, this activity will behave simply as a pass-though step + * in the process. + * + * @author Joram Barrez + */ +public class ManualTaskActivityBehavior extends TaskActivityBehavior { + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..d677fa7e491e1066eda9a206a94f9f18c12113b7 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/MultiInstanceActivityBehavior.java @@ -0,0 +1,261 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import java.util.Collection; +import java.util.Iterator; + +import org.camunda.bpm.engine.ProcessEngineException; +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.bpmn.helper.CompensationUtil; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.PvmActivity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior; +import org.camunda.bpm.engine.impl.pvm.delegate.ModificationObserverBehavior; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.variable.value.IntegerValue; + + +/** + * Abstract Multi Instance Behavior: used for both parallel and sequential + * multi instance implementation. + * + * @author Daniel Meyer + * @author Thorben Lindhauer + */ +public abstract class MultiInstanceActivityBehavior extends AbstractBpmnActivityBehavior implements CompositeActivityBehavior, ModificationObserverBehavior { + + protected static final BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + // Variable names for mi-body scoped variables (as described in spec) + public static final String NUMBER_OF_INSTANCES = "nrOfInstances"; + public static final String NUMBER_OF_ACTIVE_INSTANCES = "nrOfActiveInstances"; + public static final String NUMBER_OF_COMPLETED_INSTANCES = "nrOfCompletedInstances"; + + // Variable names for mi-instance scoped variables (as described in the spec) + public static final String LOOP_COUNTER = "loopCounter"; + + protected Expression loopCardinalityExpression; + protected Expression completionConditionExpression; + protected Expression collectionExpression; + protected String collectionVariable; + protected String collectionElementVariable; + + @Override + public void execute(ActivityExecution execution) throws Exception { + int nrOfInstances = resolveNrOfInstances(execution); + if (nrOfInstances == 0) { + leave(execution); + } + else if (nrOfInstances < 0) { + throw LOG.invalidAmountException("instances", nrOfInstances); + } + else { + createInstances(execution, nrOfInstances); + } + } + + protected void performInstance(ActivityExecution execution, PvmActivity activity, int loopCounter, Collection collection) { + setLoopVariable(execution, LOOP_COUNTER, loopCounter); + evaluateCollectionVariable(execution, collection, loopCounter); + execution.setEnded(false); + execution.setActive(true); + execution.executeActivity(activity); + } + + protected void evaluateCollectionVariable(ActivityExecution execution, Collection collection, int loopCounter) { + if (usesCollection() && collectionElementVariable != null && collection != null) { + Object value = getElementAtIndex(loopCounter, collection); + setLoopVariable(execution, collectionElementVariable, value); + } + } + + protected Collection evaluateCollection(ActivityExecution execution) { + Collection collection = null; + if (usesCollection() && collectionElementVariable != null) { + if (collectionExpression != null) { + collection = (Collection) collectionExpression.getValue(execution); + } else if (collectionVariable != null) { + collection = (Collection) execution.getVariable(collectionVariable); + } + } + return collection; + } + + protected abstract void createInstances(ActivityExecution execution, int nrOfInstances) throws Exception; + + // Helpers ////////////////////////////////////////////////////////////////////// + + protected int resolveNrOfInstances(ActivityExecution execution) { + int nrOfInstances = -1; + if (loopCardinalityExpression != null) { + nrOfInstances = resolveLoopCardinality(execution); + } else if (collectionExpression != null) { + Object obj = collectionExpression.getValue(execution); + if (!(obj instanceof Collection)) { + throw LOG.unresolvableExpressionException(collectionExpression.getExpressionText(), "Collection"); + } + nrOfInstances = ((Collection) obj).size(); + } else if (collectionVariable != null) { + Object obj = execution.getVariable(collectionVariable); + if (!(obj instanceof Collection)) { + throw LOG.invalidVariableTypeException(collectionVariable, "Collection"); + } + nrOfInstances = ((Collection) obj).size(); + } else { + throw LOG.resolveCollectionExpressionOrVariableReferenceException(); + } + return nrOfInstances; + } + + protected Object getElementAtIndex(int i, Collection collection) { + Object value = null; + int index = 0; + Iterator it = collection.iterator(); + while (index <= i) { + value = it.next(); + index++; + } + return value; + } + + protected boolean usesCollection() { + return collectionExpression != null + || collectionVariable != null; + } + + protected int resolveLoopCardinality(ActivityExecution execution) { + // Using Number since expr can evaluate to eg. Long (which is also the default for Juel) + Object value = loopCardinalityExpression.getValue(execution); + if (value instanceof Number) { + return ((Number) value).intValue(); + } else if (value instanceof String) { + return Integer.parseInt((String) value); + } else { + throw LOG.expressionNotANumberException("loopCardinality", loopCardinalityExpression.getExpressionText()); + } + } + + protected boolean completionConditionSatisfied(ActivityExecution execution) { + if (completionConditionExpression != null) { + Object value = completionConditionExpression.getValue(execution); + if (! (value instanceof Boolean)) { + throw LOG.expressionNotBooleanException("completionCondition", completionConditionExpression.getExpressionText()); + } + Boolean booleanValue = (Boolean) value; + + LOG.multiInstanceCompletionConditionState(booleanValue); + return booleanValue; + } + return false; + } + + @Override + public void doLeave(ActivityExecution execution) { + CompensationUtil.createEventScopeExecution((ExecutionEntity) execution); + + super.doLeave(execution); + } + + /** + * Get the inner activity of the multi instance execution. + * + * @param execution + * of multi instance activity + * @return inner activity + */ + public ActivityImpl getInnerActivity(PvmActivity miBodyActivity) { + for (PvmActivity activity : miBodyActivity.getActivities()) { + ActivityImpl innerActivity = (ActivityImpl) activity; + // note that miBody can contains also a compensation handler + if (!innerActivity.isCompensationHandler()) { + return innerActivity; + } + } + throw new ProcessEngineException("inner activity of multi instance body activity '" + miBodyActivity.getId() + "' not found"); + } + + protected void setLoopVariable(ActivityExecution execution, String variableName, Object value) { + execution.setVariableLocal(variableName, value); + } + + protected Integer getLoopVariable(ActivityExecution execution, String variableName) { + IntegerValue value = execution.getVariableLocalTyped(variableName); + ensureNotNull("The variable \"" + variableName + "\" could not be found in execution with id " + execution.getId(), "value", value); + return value.getValue(); + } + + + protected Integer getLocalLoopVariable(ActivityExecution execution, String variableName) { + return (Integer) execution.getVariableLocal(variableName); + } + + public boolean hasLoopVariable(ActivityExecution execution, String variableName) { + return execution.hasVariableLocal(variableName); + } + + public void removeLoopVariable(ActivityExecution execution, String variableName) { + execution.removeVariableLocal(variableName); + } + + // Getters and Setters /////////////////////////////////////////////////////////// + + public Expression getLoopCardinalityExpression() { + return loopCardinalityExpression; + } + + public void setLoopCardinalityExpression(Expression loopCardinalityExpression) { + this.loopCardinalityExpression = loopCardinalityExpression; + } + + public Expression getCompletionConditionExpression() { + return completionConditionExpression; + } + + public void setCompletionConditionExpression(Expression completionConditionExpression) { + this.completionConditionExpression = completionConditionExpression; + } + + public Expression getCollectionExpression() { + return collectionExpression; + } + + public void setCollectionExpression(Expression collectionExpression) { + this.collectionExpression = collectionExpression; + } + + public String getCollectionVariable() { + return collectionVariable; + } + + public void setCollectionVariable(String collectionVariable) { + this.collectionVariable = collectionVariable; + } + + public String getCollectionElementVariable() { + return collectionElementVariable; + } + + public void setCollectionElementVariable(String collectionElementVariable) { + this.collectionElementVariable = collectionElementVariable; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/NoneEndEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/NoneEndEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..8e12432c4f2ba1aa1140f2fb490eed9d065aec4b --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/NoneEndEventActivityBehavior.java @@ -0,0 +1,31 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + + +/** + * @author Joram Barrez + */ +public class NoneEndEventActivityBehavior extends FlowNodeActivityBehavior { + + public void execute(ActivityExecution execution) throws Exception { + execution.end(true); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/NoneStartEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/NoneStartEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..cb74a796c874efd4a9b73db79afab0b94d67bdaf --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/NoneStartEventActivityBehavior.java @@ -0,0 +1,35 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + + + + +/** + * implementation of the 'none start event': a start event that has no + * specific trigger but the programmatic one (processService.startProcessInstanceXXX()). + * + * + * @author Joram Barrez + */ +public class NoneStartEventActivityBehavior extends FlowNodeActivityBehavior { + + // Nothing to see here. + // The default behaviour of the BpmnActivity is exactly what + // a none start event should be doing. + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ParallelGatewayActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ParallelGatewayActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..28a2dacf6371a1a85f891b4a784526958e32bbb1 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ParallelGatewayActivityBehavior.java @@ -0,0 +1,82 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.List; + +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.pvm.PvmActivity; +import org.camunda.bpm.engine.impl.pvm.PvmTransition; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +/** + * Implementation of the Parallel Gateway/AND gateway as definined in the BPMN + * 2.0 specification. + * + * The Parallel Gateway can be used for splitting a path of execution into + * multiple paths of executions (AND-split/fork behavior), one for every + * outgoing sequence flow. + * + * The Parallel Gateway can also be used for merging or joining paths of + * execution (AND-join). In this case, on every incoming sequence flow an + * execution needs to arrive, before leaving the Parallel Gateway (and + * potentially then doing the fork behavior in case of multiple outgoing + * sequence flow). + * + * Note that there is a slight difference to spec (p. 436): "The parallel + * gateway is activated if there is at least one Token on each incoming sequence + * flow." We only check the number of incoming tokens to the number of sequenceflow. + * So if two tokens would arrive through the same sequence flow, our implementation + * would activate the gateway. + * + * Note that a Parallel Gateway having one incoming and multiple ougoing + * sequence flow, is the same as having multiple outgoing sequence flow on a + * given activity. However, a parallel gateway does NOT check conditions on the + * outgoing sequence flow. + * + * @author Joram Barrez + * @author Tom Baeyens + */ +public class ParallelGatewayActivityBehavior extends GatewayActivityBehavior { + + protected static final BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + public void execute(ActivityExecution execution) throws Exception { + + // Join + PvmActivity activity = execution.getActivity(); + List outgoingTransitions = execution.getActivity().getOutgoingTransitions(); + + execution.inactivate(); + lockConcurrentRoot(execution); + + List joinedExecutions = execution.findInactiveConcurrentExecutions(activity); + int nbrOfExecutionsToJoin = execution.getActivity().getIncomingTransitions().size(); + int nbrOfExecutionsJoined = joinedExecutions.size(); + + if (nbrOfExecutionsJoined==nbrOfExecutionsToJoin) { + + // Fork + LOG.activityActivation(activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin); + execution.leaveActivityViaTransitions(outgoingTransitions, joinedExecutions); + + } else { + LOG.noActivityActivation(activity.getId(), nbrOfExecutionsJoined, nbrOfExecutionsToJoin); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ParallelMultiInstanceActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ParallelMultiInstanceActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..9e3b0ac7ce479033ab435e5ae07f6a573b554bac --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ParallelMultiInstanceActivityBehavior.java @@ -0,0 +1,202 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance; +import org.camunda.bpm.engine.impl.migration.instance.parser.MigratingInstanceParseContext; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity; +import org.camunda.bpm.engine.impl.pvm.PvmActivity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.MigrationObserverBehavior; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; +import org.camunda.bpm.engine.impl.pvm.runtime.Callback; +import org.camunda.bpm.engine.impl.pvm.runtime.PvmExecutionImpl; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +/** + * @author Daniel Meyer + * + */ +public class ParallelMultiInstanceActivityBehavior extends MultiInstanceActivityBehavior implements MigrationObserverBehavior { + + @Override + protected void createInstances(ActivityExecution execution, int nrOfInstances) throws Exception { + PvmActivity innerActivity = getInnerActivity(execution.getActivity()); + + // evaluate the collection to ensure the input of collectionExpression same as before + // also reduces the loop count of collectionExpression + Collection collection = evaluateCollection(execution); + // initialize the scope and create the desired number of child executions + prepareScopeExecution(execution, nrOfInstances); + + List concurrentExecutions = new ArrayList(); + for (int i = 0; i < nrOfInstances; i++) { + concurrentExecutions.add(createConcurrentExecution(execution)); + } + + // start the concurrent child executions + // start executions in reverse order (order will be reversed again in command context with the effect that they are + // actually be started in correct order :) ) + for (int i = (nrOfInstances - 1); i >= 0; i--) { + ActivityExecution activityExecution = concurrentExecutions.get(i); + performInstance(activityExecution, innerActivity, i, collection); + } + } + + protected void prepareScopeExecution(ActivityExecution scopeExecution, int nrOfInstances) { + // set the MI-body scoped variables + setLoopVariable(scopeExecution, NUMBER_OF_INSTANCES, nrOfInstances); + setLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES, 0); + setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, nrOfInstances); + scopeExecution.setActivity(null); + scopeExecution.inactivate(); + } + + protected ActivityExecution createConcurrentExecution(ActivityExecution scopeExecution) { + ActivityExecution concurrentChild = scopeExecution.createExecution(); + scopeExecution.forceUpdate(); + concurrentChild.setConcurrent(true); + concurrentChild.setScope(false); + return concurrentChild; + } + + @Override + public void concurrentChildExecutionEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution) { + + int nrOfCompletedInstances = getLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES) + 1; + setLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES, nrOfCompletedInstances); + int nrOfActiveInstances = getLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES) - 1; + setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, nrOfActiveInstances); + + // inactivate the concurrent execution + endedExecution.inactivate(); + endedExecution.setActivityInstanceId(null); + + // join + scopeExecution.forceUpdate(); + // TODO: should the completion condition be evaluated on the scopeExecution or on the endedExecution? + if(completionConditionSatisfied(endedExecution) || + allExecutionsEnded(scopeExecution, endedExecution)) { + + ArrayList childExecutions = new ArrayList(((PvmExecutionImpl) scopeExecution).getNonEventScopeExecutions()); + for (ActivityExecution childExecution : childExecutions) { + // delete all not-ended instances; these are either active (for non-scope tasks) or inactive but have no activity id (for subprocesses, etc.) + if (childExecution.isActive() || childExecution.getActivity() == null) { + ((PvmExecutionImpl)childExecution).deleteCascade("Multi instance completion condition satisfied."); + } + else { + childExecution.remove(); + } + } + + scopeExecution.setActivity((PvmActivity) endedExecution.getActivity().getFlowScope()); + scopeExecution.setActive(true); + leave(scopeExecution); + } else { + ((ExecutionEntity) scopeExecution).dispatchDelayedEventsAndPerformOperation((Callback) null); + } + } + + protected boolean allExecutionsEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution) { + int numberOfInactiveConcurrentExecutions = endedExecution.findInactiveConcurrentExecutions(endedExecution.getActivity()).size(); + int concurrentExecutions = scopeExecution.getExecutions().size(); + + // no active instances exist and all concurrent executions are inactive + return getLocalLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES) <= 0 && + numberOfInactiveConcurrentExecutions == concurrentExecutions; + } + + @Override + public void complete(ActivityExecution scopeExecution) { + // can't happen + } + + @Override + public List initializeScope(ActivityExecution scopeExecution, int numberOfInstances) { + + prepareScopeExecution(scopeExecution, numberOfInstances); + + List executions = new ArrayList(); + for (int i = 0; i < numberOfInstances; i++) { + ActivityExecution concurrentChild = createConcurrentExecution(scopeExecution); + setLoopVariable(concurrentChild, LOOP_COUNTER, i); + executions.add(concurrentChild); + } + + return executions; + } + + @Override + public ActivityExecution createInnerInstance(ActivityExecution scopeExecution) { + // even though there is only one instance, there is always a concurrent child + ActivityExecution concurrentChild = createConcurrentExecution(scopeExecution); + + int nrOfInstances = getLoopVariable(scopeExecution, NUMBER_OF_INSTANCES); + setLoopVariable(scopeExecution, NUMBER_OF_INSTANCES, nrOfInstances + 1); + int nrOfActiveInstances = getLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES); + setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, nrOfActiveInstances + 1); + + setLoopVariable(concurrentChild, LOOP_COUNTER, nrOfInstances); + + return concurrentChild; + } + + @Override + public void destroyInnerInstance(ActivityExecution concurrentExecution) { + + ActivityExecution scopeExecution = concurrentExecution.getParent(); + concurrentExecution.remove(); + scopeExecution.forceUpdate(); + + int nrOfActiveInstances = getLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES); + setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, nrOfActiveInstances - 1); + + } + + @Override + public void migrateScope(ActivityExecution scopeExecution) { + // migrate already completed instances + for (ActivityExecution child : scopeExecution.getExecutions()) { + if (!child.isActive()) { + ((PvmExecutionImpl) child).setProcessDefinition(((PvmExecutionImpl) scopeExecution).getProcessDefinition()); + } + } + } + + @Override + public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) { + ExecutionEntity scopeExecution = migratingInstance.resolveRepresentativeExecution(); + + List concurrentInActiveExecutions = + scopeExecution.findInactiveChildExecutions(getInnerActivity((ActivityImpl) migratingInstance.getSourceScope())); + + // variables on ended inner instance executions need not be migrated anywhere + // since they are also not represented in the tree of migrating instances, we remove + // them from the parse context here to avoid a validation exception + for (ActivityExecution execution : concurrentInActiveExecutions) { + for (VariableInstanceEntity variable : ((ExecutionEntity) execution).getVariablesInternal()) { + parseContext.consume(variable); + } + } + + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ReceiveTaskActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ReceiveTaskActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..21f5743926958c985c75721d77941337e2252008 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ReceiveTaskActivityBehavior.java @@ -0,0 +1,42 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.RuntimeService; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + + +/** + * A receive task is a wait state that waits for the receival of some message. + * + * Currently, the only message that is supported is the external trigger, + * given by calling the {@link RuntimeService#signal(String)} operation. + * + * @author Joram Barrez + */ +public class ReceiveTaskActivityBehavior extends TaskActivityBehavior { + + @Override + public void performExecution(ActivityExecution execution) throws Exception { + // Do nothing: waitstate behavior + } + + public void signal(ActivityExecution execution, String signalName, Object data) throws Exception { + leave(execution); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ScriptTaskActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ScriptTaskActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..95ed948f42b0f468353e128bcd1c7beff54d6557 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ScriptTaskActivityBehavior.java @@ -0,0 +1,88 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.concurrent.Callable; + +import org.camunda.bpm.engine.delegate.BpmnError; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.delegate.ScriptInvocation; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.scripting.ExecutableScript; + +/** + *

+ * {@link ActivityBehavior} implementation of the BPMN 2.0 script task. + *

+ * + * @author Joram Barrez + * @author Christian Stettler + * @author Falko Menge + * @author Daniel Meyer + * + */ +public class ScriptTaskActivityBehavior extends TaskActivityBehavior { + + protected ExecutableScript script; + protected String resultVariable; + + public ScriptTaskActivityBehavior(ExecutableScript script, String resultVariable) { + this.script = script; + this.resultVariable = resultVariable; + } + + @Override + public void performExecution(final ActivityExecution execution) throws Exception { + executeWithErrorPropagation(execution, new Callable() { + @Override + public Void call() throws Exception { + ScriptInvocation invocation = new ScriptInvocation(script, execution); + Context.getProcessEngineConfiguration().getDelegateInterceptor().handleInvocation(invocation); + Object result = invocation.getInvocationResult(); + if (result != null && resultVariable != null) { + execution.setVariable(resultVariable, result); + } + leave(execution); + return null; + } + }); + } + + /** + * Searches recursively through the exception to see if the exception itself + * or one of its causes is a {@link BpmnError}. + * + * @param e + * the exception to check + * @return the BpmnError that was the cause of this exception or null if no + * BpmnError was found + */ + protected BpmnError checkIfCauseOfExceptionIsBpmnError(Throwable e) { + if (e instanceof BpmnError) { + return (BpmnError) e; + } else if (e.getCause() == null) { + return null; + } + return checkIfCauseOfExceptionIsBpmnError(e.getCause()); + } + + public ExecutableScript getScript() { + return script; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/SequentialMultiInstanceActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/SequentialMultiInstanceActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..937f6363332b1f25f71327b12ec0c4ead45434a9 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/SequentialMultiInstanceActivityBehavior.java @@ -0,0 +1,115 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.pvm.PvmActivity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.process.ActivityImpl; + +/** + * + * @author Daniel Meyer + * @author Thorben Lindhauer + */ +public class SequentialMultiInstanceActivityBehavior extends MultiInstanceActivityBehavior { + + protected static final BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + @Override + protected void createInstances(ActivityExecution execution, int nrOfInstances) throws Exception { + Collection collection = evaluateCollection(execution); + prepareScope(execution, nrOfInstances); + setLoopVariable(execution, NUMBER_OF_ACTIVE_INSTANCES, 1); + + ActivityImpl innerActivity = getInnerActivity(execution.getActivity()); + performInstance(execution, innerActivity, 0, collection); + } + + public void complete(ActivityExecution scopeExecution) { + int loopCounter = getLoopVariable(scopeExecution, LOOP_COUNTER) + 1; + int nrOfInstances = getLoopVariable(scopeExecution, NUMBER_OF_INSTANCES); + int nrOfCompletedInstances = getLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES) + 1; + setLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES, nrOfCompletedInstances); + + if (loopCounter == nrOfInstances || completionConditionSatisfied(scopeExecution)) { + leave(scopeExecution); + } + else { + Collection collection = evaluateCollection(scopeExecution); + PvmActivity innerActivity = getInnerActivity(scopeExecution.getActivity()); + performInstance(scopeExecution, innerActivity, loopCounter, collection); + } + } + + public void concurrentChildExecutionEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution) { + // cannot happen + } + + protected void prepareScope(ActivityExecution scopeExecution, int totalNumberOfInstances) { + setLoopVariable(scopeExecution, NUMBER_OF_INSTANCES, totalNumberOfInstances); + setLoopVariable(scopeExecution, NUMBER_OF_COMPLETED_INSTANCES, 0); + } + + public List initializeScope(ActivityExecution scopeExecution, int nrOfInstances) { + if (nrOfInstances > 1) { + LOG.unsupportedConcurrencyException(scopeExecution.toString(), this.getClass().getSimpleName()); + } + + List executions = new ArrayList(); + + prepareScope(scopeExecution, nrOfInstances); + setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, nrOfInstances); + + if (nrOfInstances > 0) { + setLoopVariable(scopeExecution, LOOP_COUNTER, 0); + executions.add(scopeExecution); + } + + return executions; + } + + @Override + public ActivityExecution createInnerInstance(ActivityExecution scopeExecution) { + + if (hasLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES) && getLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES) > 0) { + throw LOG.unsupportedConcurrencyException(scopeExecution.toString(), this.getClass().getSimpleName()); + } + else { + int nrOfInstances = getLoopVariable(scopeExecution, NUMBER_OF_INSTANCES); + + setLoopVariable(scopeExecution, LOOP_COUNTER, nrOfInstances); + setLoopVariable(scopeExecution, NUMBER_OF_INSTANCES, nrOfInstances + 1); + setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, 1); + } + + return scopeExecution; + } + + @Override + public void destroyInnerInstance(ActivityExecution scopeExecution) { + removeLoopVariable(scopeExecution, LOOP_COUNTER); + + int nrOfActiveInstances = getLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES); + setLoopVariable(scopeExecution, NUMBER_OF_ACTIVE_INSTANCES, nrOfActiveInstances - 1); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ServiceTaskDelegateExpressionActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ServiceTaskDelegateExpressionActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..c46d04757dd92643f64600c010e5cf19ef4a1f25 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ServiceTaskDelegateExpressionActivityBehavior.java @@ -0,0 +1,142 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import static org.camunda.bpm.engine.impl.util.ClassDelegateUtil.applyFieldDeclaration; + +import java.util.List; +import java.util.concurrent.Callable; + +import org.camunda.bpm.application.InvocationContext; +import org.camunda.bpm.application.ProcessApplicationReference; +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.bpmn.delegate.ActivityBehaviorInvocation; +import org.camunda.bpm.engine.impl.bpmn.delegate.JavaDelegateInvocation; +import org.camunda.bpm.engine.impl.bpmn.parser.FieldDeclaration; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.context.ProcessApplicationContextUtil; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior; + + +/** + * {@link ActivityBehavior} used when 'delegateExpression' is used + * for a serviceTask. + * + * @author Joram Barrez + * @author Josh Long + * @author Slawomir Wojtasiak (Patch for ACT-1159) + * @author Falko Menge + */ +public class ServiceTaskDelegateExpressionActivityBehavior extends TaskActivityBehavior { + + protected static final BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + protected Expression expression; + private final List fieldDeclarations; + + public ServiceTaskDelegateExpressionActivityBehavior(Expression expression, List fieldDeclarations) { + this.expression = expression; + this.fieldDeclarations = fieldDeclarations; + } + + @Override + public void signal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception { + ProcessApplicationReference targetProcessApplication = ProcessApplicationContextUtil.getTargetProcessApplication((ExecutionEntity) execution); + if(ProcessApplicationContextUtil.requiresContextSwitch(targetProcessApplication)) { + Context.executeWithinProcessApplication(new Callable() { + public Void call() throws Exception { + signal(execution, signalName, signalData); + return null; + } + }, targetProcessApplication, new InvocationContext(execution)); + } + else { + doSignal(execution, signalName, signalData); + } + } + + public void doSignal(final ActivityExecution execution, final String signalName, final Object signalData) throws Exception { + Object delegate = expression.getValue(execution); + applyFieldDeclaration(fieldDeclarations, delegate); + final ActivityBehavior activityBehaviorInstance = getActivityBehaviorInstance(execution, delegate); + + if (activityBehaviorInstance instanceof CustomActivityBehavior) { + CustomActivityBehavior behavior = (CustomActivityBehavior) activityBehaviorInstance; + ActivityBehavior delegateActivityBehavior = behavior.getDelegateActivityBehavior(); + + if (!(delegateActivityBehavior instanceof SignallableActivityBehavior)) { + // legacy behavior: do nothing when it is not a signallable activity behavior + return; + } + } + executeWithErrorPropagation(execution, new Callable() { + @Override + public Void call() throws Exception { + ((SignallableActivityBehavior) activityBehaviorInstance).signal(execution, signalName, signalData); + return null; + } + }); + } + + @Override + public void performExecution(final ActivityExecution execution) throws Exception { + Callable callable = new Callable() { + @Override + public Void call() throws Exception { + // Note: we can't cache the result of the expression, because the + // execution can change: eg. delegateExpression='${mySpringBeanFactory.randomSpringBean()}' + Object delegate = expression.getValue(execution); + applyFieldDeclaration(fieldDeclarations, delegate); + + if (delegate instanceof ActivityBehavior) { + Context.getProcessEngineConfiguration() + .getDelegateInterceptor() + .handleInvocation(new ActivityBehaviorInvocation((ActivityBehavior) delegate, execution)); + + } else if (delegate instanceof JavaDelegate) { + Context.getProcessEngineConfiguration() + .getDelegateInterceptor() + .handleInvocation(new JavaDelegateInvocation((JavaDelegate) delegate, execution)); + leave(execution); + + } else { + throw LOG.resolveDelegateExpressionException(expression, ActivityBehavior.class, JavaDelegate.class); + } + return null; + } + }; + executeWithErrorPropagation(execution, callable); + } + + protected ActivityBehavior getActivityBehaviorInstance(ActivityExecution execution, Object delegateInstance) { + + if (delegateInstance instanceof ActivityBehavior) { + return new CustomActivityBehavior((ActivityBehavior) delegateInstance); + } else if (delegateInstance instanceof JavaDelegate) { + return new ServiceTaskJavaDelegateActivityBehavior((JavaDelegate) delegateInstance); + } else { + throw LOG.missingDelegateParentClassException(delegateInstance.getClass().getName(), + JavaDelegate.class.getName(), ActivityBehavior.class.getName()); + } + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ServiceTaskExpressionActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ServiceTaskExpressionActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..16295fa4c98b157f5bb3fffe69536c4970020946 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ServiceTaskExpressionActivityBehavior.java @@ -0,0 +1,60 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.concurrent.Callable; + +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +/** + * ActivityBehavior that evaluates an expression when executed. Optionally, it + * sets the result of the expression as a variable on the execution. + * + * @author Tom Baeyens + * @author Christian Stettler + * @author Frederik Heremans + * @author Slawomir Wojtasiak (Patch for ACT-1159) + * @author Falko Menge + */ +public class ServiceTaskExpressionActivityBehavior extends TaskActivityBehavior { + + protected Expression expression; + protected String resultVariable; + + public ServiceTaskExpressionActivityBehavior(Expression expression, String resultVariable) { + this.expression = expression; + this.resultVariable = resultVariable; + } + + @Override + public void performExecution(final ActivityExecution execution) throws Exception { + executeWithErrorPropagation(execution, new Callable() { + @Override + public Void call() throws Exception { + //getValue() can have side-effects, that's why we have to call it independently from the result variable + Object value = expression.getValue(execution); + if (resultVariable != null) { + execution.setVariable(resultVariable, value); + } + leave(execution); + return null; + } + }); + + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ServiceTaskJavaDelegateActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ServiceTaskJavaDelegateActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..75d24c6ab249b4b88ccdcbbb1b61938ead81f8ad --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ServiceTaskJavaDelegateActivityBehavior.java @@ -0,0 +1,57 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.ExecutionListener; +import org.camunda.bpm.engine.delegate.JavaDelegate; +import org.camunda.bpm.engine.impl.bpmn.delegate.JavaDelegateInvocation; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + + +/** + * @author Tom Baeyens + */ +public class ServiceTaskJavaDelegateActivityBehavior extends TaskActivityBehavior implements ActivityBehavior, ExecutionListener { + + protected JavaDelegate javaDelegate; + + protected ServiceTaskJavaDelegateActivityBehavior() { + } + + public ServiceTaskJavaDelegateActivityBehavior(JavaDelegate javaDelegate) { + this.javaDelegate = javaDelegate; + } + + @Override + public void performExecution(ActivityExecution execution) throws Exception { + execute((DelegateExecution) execution); + leave(execution); + } + + public void notify(DelegateExecution execution) throws Exception { + execute(execution); + } + + public void execute(DelegateExecution execution) throws Exception { + Context.getProcessEngineConfiguration() + .getDelegateInterceptor() + .handleInvocation(new JavaDelegateInvocation(javaDelegate, execution)); + } +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ShellActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ShellActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..7e9cefbf04ae06d4f7eaf24bb842a7a9f2063eb7 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ShellActivityBehavior.java @@ -0,0 +1,171 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.io.BufferedReader; +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.io.StringWriter; +import java.io.Writer; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +import org.camunda.bpm.engine.delegate.DelegateExecution; +import org.camunda.bpm.engine.delegate.Expression; +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +public class ShellActivityBehavior extends AbstractBpmnActivityBehavior { + + protected static final BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + protected Expression command; + protected Expression wait; + protected Expression arg1; + protected Expression arg2; + protected Expression arg3; + protected Expression arg4; + protected Expression arg5; + protected Expression outputVariable; + protected Expression errorCodeVariable; + protected Expression redirectError; + protected Expression cleanEnv; + protected Expression directory; + + String commandStr; + String arg1Str; + String arg2Str; + String arg3Str; + String arg4Str; + String arg5Str; + String waitStr; + String resultVariableStr; + String errorCodeVariableStr; + Boolean waitFlag; + Boolean redirectErrorFlag; + Boolean cleanEnvBoolan; + String directoryStr; + + private void readFields(ActivityExecution execution) { + commandStr = getStringFromField(command, execution); + arg1Str = getStringFromField(arg1, execution); + arg2Str = getStringFromField(arg2, execution); + arg3Str = getStringFromField(arg3, execution); + arg4Str = getStringFromField(arg4, execution); + arg5Str = getStringFromField(arg5, execution); + waitStr = getStringFromField(wait, execution); + resultVariableStr = getStringFromField(outputVariable, execution); + errorCodeVariableStr = getStringFromField(errorCodeVariable, execution); + + String redirectErrorStr = getStringFromField(redirectError, execution); + String cleanEnvStr = getStringFromField(cleanEnv, execution); + + waitFlag = waitStr == null || waitStr.equals("true"); + redirectErrorFlag = redirectErrorStr != null && redirectErrorStr.equals("true"); + cleanEnvBoolan = cleanEnvStr != null && cleanEnvStr.equals("true"); + directoryStr = getStringFromField(directory, execution); + + } + + public void execute(ActivityExecution execution) { + + readFields(execution); + + List argList = new ArrayList(); + argList.add(commandStr); + + if (arg1Str != null) + argList.add(arg1Str); + if (arg2Str != null) + argList.add(arg2Str); + if (arg3Str != null) + argList.add(arg3Str); + if (arg4Str != null) + argList.add(arg4Str); + if (arg5Str != null) + argList.add(arg5Str); + + ProcessBuilder processBuilder = new ProcessBuilder(argList); + + try { + processBuilder.redirectErrorStream(redirectErrorFlag); + if (cleanEnvBoolan) { + Map env = processBuilder.environment(); + env.clear(); + } + if (directoryStr != null && directoryStr.length() > 0) + processBuilder.directory(new File(directoryStr)); + + Process process = processBuilder.start(); + + if (waitFlag) { + int errorCode = process.waitFor(); + + if (resultVariableStr != null) { + String result = convertStreamToStr(process.getInputStream()); + execution.setVariable(resultVariableStr, result); + } + + if (errorCodeVariableStr != null) { + execution.setVariable(errorCodeVariableStr, Integer.toString(errorCode)); + + } + + } + } catch (Exception e) { + throw LOG.shellExecutionException(e); + } + + leave(execution); + } + + public static String convertStreamToStr(InputStream is) throws IOException { + + if (is != null) { + Writer writer = new StringWriter(); + + char[] buffer = new char[1024]; + try { + Reader reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); + int n; + while ((n = reader.read(buffer)) != -1) { + writer.write(buffer, 0, n); + } + } finally { + is.close(); + } + return writer.toString(); + } else { + return ""; + } + } + + protected String getStringFromField(Expression expression, DelegateExecution execution) { + if (expression != null) { + Object value = expression.getValue(execution); + if (value != null) { + return value.toString(); + } + } + return null; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..0fa673f1f06fe5a4887727d9c148250070d4419e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/SubProcessActivityBehavior.java @@ -0,0 +1,68 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import static org.camunda.bpm.engine.impl.util.EnsureUtil.ensureNotNull; + +import org.camunda.bpm.engine.impl.bpmn.helper.BpmnProperties; +import org.camunda.bpm.engine.impl.bpmn.helper.CompensationUtil; +import org.camunda.bpm.engine.impl.bpmn.parser.BpmnParse; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.PvmActivity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.CompositeActivityBehavior; + + +/** + * Implementation of the BPMN 2.0 subprocess (formally known as 'embedded' subprocess): + * a subprocess defined within another process definition. + * + * @author Joram Barrez + */ +public class SubProcessActivityBehavior extends AbstractBpmnActivityBehavior implements CompositeActivityBehavior { + + @Override + public void execute(ActivityExecution execution) throws Exception { + PvmActivity activity = execution.getActivity(); + PvmActivity initialActivity = activity.getProperties().get(BpmnProperties.INITIAL_ACTIVITY); + + ensureNotNull("No initial activity found for subprocess " + execution.getActivity().getId(), "initialActivity", initialActivity); + + execution.executeActivity(initialActivity); + } + + @Override + public void concurrentChildExecutionEnded(ActivityExecution scopeExecution, ActivityExecution endedExecution) { + // join + endedExecution.remove(); + scopeExecution.tryPruneLastConcurrentChild(); + scopeExecution.forceUpdate(); + } + + @Override + public void complete(ActivityExecution scopeExecution) { + leave(scopeExecution); + } + + @Override + public void doLeave(ActivityExecution execution) { + CompensationUtil.createEventScopeExecution((ExecutionEntity) execution); + + super.doLeave(execution); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/TaskActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/TaskActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..6d17b57a262f7b6703add8e607919778794a47ed --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/TaskActivityBehavior.java @@ -0,0 +1,74 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + + + +/** + * Parent class for all BPMN 2.0 task types such as ServiceTask, ScriptTask, UserTask, etc. + * + * When used on its own, it behaves just as a pass-through activity. + * + * @author Joram Barrez + */ +public class TaskActivityBehavior extends AbstractBpmnActivityBehavior { + + /** + * Activity instance id before execution. + */ + protected String activityInstanceId; + + /** + * The method which will be called before the execution is performed. + * + * @param execution the execution which is used during execution + * @throws Exception + */ + protected void preExecution(ActivityExecution execution) throws Exception { + activityInstanceId = execution.getActivityInstanceId(); + } + + /** + * The method which should be overridden by the sub classes to perform an execution. + * + * @param execution the execution which is used during performing the execution + * @throws Exception + */ + protected void performExecution(ActivityExecution execution) throws Exception { + leave(execution); + } + + /** + * The method which will be called after performing the execution. + * + * @param execution the execution + * @throws Exception + */ + protected void postExecution(ActivityExecution execution) throws Exception { + } + + @Override + public void execute(ActivityExecution execution) throws Exception { + performExecution(execution); + } + + + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/TerminateEndEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/TerminateEndEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..ceaf0765bf15eedb193c97070bbdbde2fbd26a55 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/TerminateEndEventActivityBehavior.java @@ -0,0 +1,40 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.process.ActivityStartBehavior; + +/** + *

The BPMN terminate End Event.

+ * + *

The start behavior of the terminate end event is {@link ActivityStartBehavior#INTERRUPT_FLOW_SCOPE}. + * as a result, the current scope will be interrupted (all concurrent executions cancelled) and this + * behavior is entered with the scope execution.

+ * + * + * @author Daniel Meyer + * @author Roman Smirnov + */ +public class TerminateEndEventActivityBehavior extends FlowNodeActivityBehavior { + + public void execute(ActivityExecution execution) throws Exception { + // we are the last execution inside this scope: calling end() ends this scope. + execution.end(true); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ThrowEscalationEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ThrowEscalationEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..aaf88ac681ed4afae6fbe0e4661deee51d5baacc --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ThrowEscalationEventActivityBehavior.java @@ -0,0 +1,60 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.bpmn.helper.EscalationHandler; +import org.camunda.bpm.engine.impl.bpmn.parser.Escalation; +import org.camunda.bpm.engine.impl.bpmn.parser.EscalationEventDefinition; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.PvmActivity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +/** + * The activity behavior for an intermediate throwing escalation event and an escalation end event. + * + * @author Philipp Ossler + * + */ +public class ThrowEscalationEventActivityBehavior extends AbstractBpmnActivityBehavior { + + protected final Escalation escalation; + + public ThrowEscalationEventActivityBehavior(Escalation escalation) { + this.escalation = escalation; + } + + @Override + public void execute(ActivityExecution execution) throws Exception { + final PvmActivity currentActivity = execution.getActivity(); + + EscalationEventDefinition escalationEventDefinition = EscalationHandler.executeEscalation(execution, escalation.getEscalationCode()); + + if (escalationEventDefinition == null || !escalationEventDefinition.isCancelActivity()) { + leaveExecution(execution, currentActivity, escalationEventDefinition); + } + } + + protected void leaveExecution(ActivityExecution execution, final PvmActivity currentActivity, EscalationEventDefinition escalationEventDefinition) { + + // execution tree could have been expanded by triggering a non-interrupting event + ExecutionEntity replacingExecution = ((ExecutionEntity) execution).getReplacedBy(); + + ExecutionEntity leavingExecution = (ExecutionEntity) (replacingExecution != null ? replacingExecution : execution); + leave(leavingExecution); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ThrowSignalEventActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ThrowSignalEventActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..36b0689b19252f0b56fe4d0dc899f20d2202cf4e --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/ThrowSignalEventActivityBehavior.java @@ -0,0 +1,91 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import org.camunda.bpm.engine.impl.ProcessEngineLogger; +import org.camunda.bpm.engine.impl.bpmn.parser.EventSubscriptionDeclaration; +import org.camunda.bpm.engine.impl.context.Context; +import org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.EventSubscriptionManager; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.variable.VariableMap; + +import java.util.List; + +/** + * Defines activity behavior for signal end event and intermediate throw signal event. + * + * @author Daniel Meyer + */ +public class ThrowSignalEventActivityBehavior extends AbstractBpmnActivityBehavior { + + protected final static BpmnBehaviorLogger LOG = ProcessEngineLogger.BPMN_BEHAVIOR_LOGGER; + + protected final EventSubscriptionDeclaration signalDefinition; + + public ThrowSignalEventActivityBehavior(EventSubscriptionDeclaration signalDefinition) { + this.signalDefinition = signalDefinition; + } + + @Override + public void execute(ActivityExecution execution) throws Exception { + + String businessKey = signalDefinition.getEventPayload().getBusinessKey(execution); + VariableMap variableMap = signalDefinition.getEventPayload().getInputVariables(execution); + + String eventName = signalDefinition.resolveExpressionOfEventName(execution); + // trigger all event subscriptions for the signal (start and intermediate) + List signalEventSubscriptions = + findSignalEventSubscriptions(eventName, execution.getTenantId()); + + for (EventSubscriptionEntity signalEventSubscription : signalEventSubscriptions) { + if (isActiveEventSubscription(signalEventSubscription)) { + signalEventSubscription.eventReceived(variableMap, null, null, businessKey, signalDefinition.isAsync()); + } + } + leave(execution); + } + + protected List findSignalEventSubscriptions(String signalName, String tenantId) { + EventSubscriptionManager eventSubscriptionManager = Context.getCommandContext().getEventSubscriptionManager(); + + if (tenantId != null) { + return eventSubscriptionManager + .findSignalEventSubscriptionsByEventNameAndTenantIdIncludeWithoutTenantId(signalName, tenantId); + + } else { + // find event subscriptions without tenant id + return eventSubscriptionManager.findSignalEventSubscriptionsByEventNameAndTenantId(signalName, null); + } + } + + protected boolean isActiveEventSubscription(EventSubscriptionEntity signalEventSubscriptionEntity) { + return isStartEventSubscription(signalEventSubscriptionEntity) + || isActiveIntermediateEventSubscription(signalEventSubscriptionEntity); + } + + protected boolean isStartEventSubscription(EventSubscriptionEntity signalEventSubscriptionEntity) { + return signalEventSubscriptionEntity.getExecutionId() == null; + } + + protected boolean isActiveIntermediateEventSubscription(EventSubscriptionEntity signalEventSubscriptionEntity) { + ExecutionEntity execution = signalEventSubscriptionEntity.getExecution(); + return execution != null && !execution.isEnded() && !execution.isCanceled(); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/UserTaskActivityBehavior.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/UserTaskActivityBehavior.java new file mode 100644 index 0000000000000000000000000000000000000000..29a9683d7ce454d28f933c49df09ffeb16c088dc --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/behavior/UserTaskActivityBehavior.java @@ -0,0 +1,110 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.behavior; + +import java.util.Collection; + +import org.camunda.bpm.engine.impl.el.ExpressionManager; +import org.camunda.bpm.engine.impl.migration.instance.MigratingActivityInstance; +import org.camunda.bpm.engine.impl.migration.instance.MigratingUserTaskInstance; +import org.camunda.bpm.engine.impl.migration.instance.parser.MigratingInstanceParseContext; +import org.camunda.bpm.engine.impl.persistence.entity.ExecutionEntity; +import org.camunda.bpm.engine.impl.persistence.entity.TaskEntity; +import org.camunda.bpm.engine.impl.persistence.entity.TaskEntity.TaskState; +import org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceEntity; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.MigrationObserverBehavior; +import org.camunda.bpm.engine.impl.task.TaskDecorator; +import org.camunda.bpm.engine.impl.task.TaskDefinition; + +/** + * activity implementation for the user task. + * + * @author Joram Barrez + * @author Roman Smirnov + */ +public class UserTaskActivityBehavior extends TaskActivityBehavior implements MigrationObserverBehavior { + + protected TaskDecorator taskDecorator; + + @Deprecated + public UserTaskActivityBehavior(ExpressionManager expressionManager, TaskDefinition taskDefinition) { + this.taskDecorator = new TaskDecorator(taskDefinition, expressionManager); + } + + public UserTaskActivityBehavior(TaskDecorator taskDecorator) { + this.taskDecorator = taskDecorator; + } + + @Override + public void performExecution(ActivityExecution execution) throws Exception { + TaskEntity task = new TaskEntity((ExecutionEntity) execution); + task.insert(); + + // initialize task properties + taskDecorator.decorate(task, execution); + + // fire lifecycle events after task is initialized + task.transitionTo(TaskState.STATE_CREATED); + } + + public void signal(ActivityExecution execution, String signalName, Object signalData) throws Exception { + leave(execution); + } + + // migration + + @Override + public void migrateScope(ActivityExecution scopeExecution) { + } + + @Override + public void onParseMigratingInstance(MigratingInstanceParseContext parseContext, MigratingActivityInstance migratingInstance) { + ExecutionEntity execution = migratingInstance.resolveRepresentativeExecution(); + + for (TaskEntity task : execution.getTasks()) { + migratingInstance.addMigratingDependentInstance(new MigratingUserTaskInstance(task, migratingInstance)); + parseContext.consume(task); + + Collection variables = task.getVariablesInternal(); + + if (variables != null) { + for (VariableInstanceEntity variable : variables) { + // we don't need to represent task variables in the migrating instance structure because + // they are migrated by the MigratingTaskInstance as well + parseContext.consume(variable); + } + } + } + + } + + // getters + + public TaskDefinition getTaskDefinition() { + return taskDecorator.getTaskDefinition(); + } + + public ExpressionManager getExpressionManager() { + return taskDecorator.getExpressionManager(); + } + + public TaskDecorator getTaskDecorator() { + return taskDecorator; + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/delegate/ActivityBehaviorInvocation.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/delegate/ActivityBehaviorInvocation.java new file mode 100644 index 0000000000000000000000000000000000000000..05614be335c891ae3e37e777741656447a1c88a3 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/delegate/ActivityBehaviorInvocation.java @@ -0,0 +1,43 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.delegate; + +import org.camunda.bpm.engine.impl.delegate.DelegateInvocation; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityBehavior; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; + +/** + * + * @author Daniel Meyer + */ +public class ActivityBehaviorInvocation extends DelegateInvocation { + + protected final ActivityBehavior behaviorInstance; + + protected final ActivityExecution execution; + + public ActivityBehaviorInvocation(ActivityBehavior behaviorInstance, ActivityExecution execution) { + super(execution, null); + this.behaviorInstance = behaviorInstance; + this.execution = execution; + } + + protected void invoke() throws Exception { + behaviorInstance.execute(execution); + } + +} diff --git a/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/delegate/ActivityBehaviorSignalInvocation.java b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/delegate/ActivityBehaviorSignalInvocation.java new file mode 100644 index 0000000000000000000000000000000000000000..cdb51b8606ff0ed246265d7811b1abcc64e165b2 --- /dev/null +++ b/source_data/pinned/camunda-dmn-examples/commit-ee4826e5e76c/engine/src/main/java/org/camunda/bpm/engine/impl/bpmn/delegate/ActivityBehaviorSignalInvocation.java @@ -0,0 +1,46 @@ +/* + * Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH + * under one or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information regarding copyright + * ownership. Camunda licenses this file to you under the Apache License, + * Version 2.0; you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.camunda.bpm.engine.impl.bpmn.delegate; + +import org.camunda.bpm.engine.impl.delegate.DelegateInvocation; +import org.camunda.bpm.engine.impl.pvm.delegate.ActivityExecution; +import org.camunda.bpm.engine.impl.pvm.delegate.SignallableActivityBehavior; + +/** + * @author Roman Smirnov + * + */ +public class ActivityBehaviorSignalInvocation extends DelegateInvocation { + + protected SignallableActivityBehavior behaviorInstance; + protected ActivityExecution execution; + protected String signalName; + protected Object signalData; + + public ActivityBehaviorSignalInvocation(SignallableActivityBehavior behaviorInstance, ActivityExecution execution, String signalName, Object signalData) { + super(execution, null); + this.behaviorInstance = behaviorInstance; + this.execution = execution; + this.signalName = signalName; + this.signalData = signalData; + } + + protected void invoke() throws Exception { + behaviorInstance.signal(execution, signalName, signalData); + } + +}