org.camunda.bpm.engine.impl.ProcessInstanceQueryImpl Maven / Gradle / Ivy
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, 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.List;
import java.util.Set;
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.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 executionId;
protected String businessKey;
protected String processDefinitionId;
protected Set processInstanceIds;
protected String processDefinitionKey;
protected String superProcessInstanceId;
protected String subProcessInstanceId;
protected SuspensionState suspensionState;
protected String incidentType;
protected String incidentId;
protected String incidentMessage;
protected String incidentMessageLike;
protected String caseInstanceId;
// Unused, see dynamic query
protected String activityId;
protected List eventSubscriptions;
public ProcessInstanceQueryImpl() {
}
public ProcessInstanceQueryImpl(CommandContext commandContext) {
super(commandContext);
}
public ProcessInstanceQueryImpl(CommandExecutor commandExecutor) {
super(commandExecutor);
}
public ProcessInstanceQueryImpl processInstanceId(String processInstanceId) {
ensureNotNull("Process instance id", processInstanceId);
this.executionId = processInstanceId;
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 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 superProcessInstanceId(String 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 orderByProcessInstanceId() {
this.orderProperty = ProcessInstanceQueryProperty.PROCESS_INSTANCE_ID;
return this;
}
public ProcessInstanceQuery orderByProcessDefinitionId() {
this.orderProperty = ProcessInstanceQueryProperty.PROCESS_DEFINITION_ID;
return this;
}
public ProcessInstanceQuery orderByProcessDefinitionKey() {
this.orderProperty = ProcessInstanceQueryProperty.PROCESS_DEFINITION_KEY;
return this;
}
public ProcessInstanceQuery active() {
this.suspensionState = SuspensionState.ACTIVE;
return this;
}
public ProcessInstanceQuery suspended() {
this.suspensionState = SuspensionState.SUSPENDED;
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;
}
//results /////////////////////////////////////////////////////////////////
public long executeCount(CommandContext commandContext) {
checkQueryOk();
ensureVariablesInitialized();
return commandContext
.getExecutionManager()
.findProcessInstanceCountByQueryCriteria(this);
}
public List executeList(CommandContext commandContext, Page page) {
checkQueryOk();
ensureVariablesInitialized();
return commandContext
.getExecutionManager()
.findProcessInstanceByQueryCriteria(this, page);
}
//getters /////////////////////////////////////////////////////////////////
public boolean getOnlyProcessInstances() {
return true; // See dynamic query in runtime.mapping.xml
}
public String getProcessInstanceId() {
return executionId;
}
public Set getProcessInstanceIds() {
return processInstanceIds;
}
public String getBusinessKey() {
return businessKey;
}
public String getProcessDefinitionId() {
return processDefinitionId;
}
public String getProcessDefinitionKey() {
return processDefinitionKey;
}
public String getActivityId() {
return null; // Unused, see dynamic query
}
public String getSuperProcessInstanceId() {
return superProcessInstanceId;
}
public String getSubProcessInstanceId() {
return subProcessInstanceId;
}
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;
}
public String getCaseInstanceId() {
return caseInstanceId;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy