org.activiti.bpmn.model.Process Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of activiti-bpmn-model Show documentation
Show all versions of activiti-bpmn-model Show documentation
workflow engine base on bboss and activiti.
The newest version!
/* 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.activiti.bpmn.model;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author Tijs Rademakers
*/
public class Process extends BaseElement implements FlowElementsContainer, HasExecutionListeners {
protected String name;
protected boolean executable = true;
protected String documentation;
protected IOSpecification ioSpecification;
protected List executionListeners = new ArrayList();
protected List lanes = new ArrayList();
protected List flowElementList = new ArrayList();
protected Map flowElementMap = new HashMap(); // The flow elements are twice stored. The map is used for performance when retrieving by id
protected List artifactList = new ArrayList();
protected List candidateStarterUsers = new ArrayList();
protected List candidateStarterGroups = new ArrayList();
public String getDocumentation() {
return documentation;
}
public void setDocumentation(String documentation) {
this.documentation = documentation;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isExecutable() {
return executable;
}
public void setExecutable(boolean executable) {
this.executable = executable;
}
public IOSpecification getIoSpecification() {
return ioSpecification;
}
public void setIoSpecification(IOSpecification ioSpecification) {
this.ioSpecification = ioSpecification;
}
public List getExecutionListeners() {
return executionListeners;
}
public void setExecutionListeners(List executionListeners) {
this.executionListeners = executionListeners;
}
public List getLanes() {
return lanes;
}
public void setLanes(List lanes) {
this.lanes = lanes;
}
public FlowElement getFlowElement(String flowElementId) {
FlowElement flowElement = flowElementMap.get(flowElementId);
// It could be the id has changed after insertion into the map,
// So if it is not found, we loop through the list
if (flowElement == null) {
flowElement = findFlowElementInList(flowElementId);
}
return flowElement;
}
protected FlowElement findFlowElementInList(String flowElementId) {
for (FlowElement f : flowElementList) {
if (f.getId() != null && f.getId().equals(flowElementId)) {
return f;
}
}
return null;
}
public Collection getFlowElements() {
return flowElementList;
}
public void addFlowElement(FlowElement element) {
flowElementList.add(element);
flowElementMap.put(element.getId(), element);
}
public void removeFlowElement(String elementId) {
FlowElement element = flowElementMap.get(elementId);
if (element == null) {
element = findFlowElementInList(elementId);
}
if (element != null) {
flowElementList.remove(element);
flowElementMap.remove(elementId);
}
}
public Artifact getArtifact(String id) {
Artifact foundArtifact = null;
for (Artifact artifact : artifactList) {
if (id.equals(artifact.getId())) {
foundArtifact = artifact;
break;
}
}
return foundArtifact;
}
public Collection getArtifacts() {
return artifactList;
}
public void addArtifact(Artifact artifact) {
artifactList.add(artifact);
}
public void removeArtifact(String artifactId) {
Artifact artifact = getArtifact(artifactId);
if (artifact != null) {
artifactList.remove(artifact);
}
}
public List getCandidateStarterUsers() {
return candidateStarterUsers;
}
public void setCandidateStarterUsers(List candidateStarterUsers) {
this.candidateStarterUsers = candidateStarterUsers;
}
public List getCandidateStarterGroups() {
return candidateStarterGroups;
}
public void setCandidateStarterGroups(List candidateStarterGroups) {
this.candidateStarterGroups = candidateStarterGroups;
}
@SuppressWarnings("unchecked")
public List findFlowElementsOfType(Class type) {
List flowElements = new ArrayList();
for (FlowElement flowElement : this.getFlowElements()) {
if (type.isInstance(flowElement)) {
flowElements.add((FlowElementType) flowElement);
}
}
return flowElements;
}
}