org.camunda.bpm.engine.impl.persistence.entity.VariableInstanceManager Maven / Gradle / Ivy
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.camunda.bpm.engine.impl.persistence.entity;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.camunda.bpm.engine.impl.Page;
import org.camunda.bpm.engine.impl.VariableInstanceQueryImpl;
import org.camunda.bpm.engine.impl.persistence.AbstractManager;
import org.camunda.bpm.engine.runtime.VariableInstance;
/**
* @author Tom Baeyens
*/
public class VariableInstanceManager extends AbstractManager {
public List findVariableInstancesByTaskId(String taskId) {
return findVariableInstancesByTaskIdAndVariableNames(taskId, null);
}
@SuppressWarnings("unchecked")
public List findVariableInstancesByTaskIdAndVariableNames(String taskId, Collection variableNames) {
Map parameter = new HashMap();
parameter.put("taskId", taskId);
parameter.put("variableNames", variableNames);
return getDbEntityManager().selectList("selectVariablesByTaskId", parameter);
}
public List findVariableInstancesByExecutionId(String executionId) {
return findVariableInstancesByExecutionIdAndVariableNames(executionId, null);
}
@SuppressWarnings("unchecked")
public List findVariableInstancesByExecutionIdAndVariableNames(String executionId, Collection variableNames) {
Map parameter = new HashMap();
parameter.put("executionId", executionId);
parameter.put("variableNames", variableNames);
return getDbEntityManager().selectList("selectVariablesByExecutionId", parameter);
}
@SuppressWarnings("unchecked")
public List findVariableInstancesByProcessInstanceId(String processInstanceId) {
return getDbEntityManager().selectList("selectVariablesByProcessInstanceId", processInstanceId);
}
public List findVariableInstancesByCaseExecutionId(String caseExecutionId) {
return findVariableInstancesByCaseExecutionIdAndVariableNames(caseExecutionId, null);
}
@SuppressWarnings("unchecked")
public List findVariableInstancesByCaseExecutionIdAndVariableNames(String caseExecutionId, Collection variableNames) {
Map parameter = new HashMap();
parameter.put("caseExecutionId", caseExecutionId);
parameter.put("variableNames", variableNames);
return getDbEntityManager().selectList("selectVariablesByCaseExecutionId", parameter);
}
public void deleteVariableInstanceByTask(TaskEntity task) {
List variableInstances = task.variableStore.getVariables();
for (VariableInstanceEntity variableInstance: variableInstances) {
variableInstance.delete();
}
}
public long findVariableInstanceCountByQueryCriteria(VariableInstanceQueryImpl variableInstanceQuery) {
configureQuery(variableInstanceQuery);
return (Long) getDbEntityManager().selectOne("selectVariableInstanceCountByQueryCriteria", variableInstanceQuery);
}
@SuppressWarnings("unchecked")
public List findVariableInstanceByQueryCriteria(VariableInstanceQueryImpl variableInstanceQuery, Page page) {
configureQuery(variableInstanceQuery);
return getDbEntityManager().selectList("selectVariableInstanceByQueryCriteria", variableInstanceQuery, page);
}
protected void configureQuery(VariableInstanceQueryImpl query) {
getAuthorizationManager().configureVariableInstanceQuery(query);
getTenantManager().configureQuery(query);
}
@SuppressWarnings("unchecked")
public List findVariableInstancesByBatchId(String batchId) {
Map parameters = Collections.singletonMap("batchId", batchId);
return getDbEntityManager().selectList("selectVariableInstancesByBatchId", parameters);
}
}