1 /*
2 * Licensed to The Apereo Foundation under one or more contributor license
3 * agreements. See the NOTICE file distributed with this work for additional
4 * information regarding copyright ownership.
5 *
6 *
7 * The Apereo Foundation licenses this file to you under the Educational
8 * Community License, Version 2.0 (the "License"); you may not use this file
9 * except in compliance with the License. You may obtain a copy of the License
10 * at:
11 *
12 * http://opensource.org/licenses/ecl2.txt
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17 * License for the specific language governing permissions and limitations under
18 * the License.
19 *
20 */
21
22 package org.opencastproject.workflow.api;
23
24 import java.util.Collection;
25 import java.util.List;
26 import java.util.Set;
27
28 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
29
30 /**
31 * A workflow definition.
32 */
33 @XmlJavaTypeAdapter(WorkflowDefinitionImpl.Adapter.class)
34 public interface WorkflowDefinition extends Comparable<WorkflowDefinition> {
35
36 /**
37 * The variable in a workflow definition that is to be replaced by the reason for an operation's failure.
38 */
39 String FAILURE_KEY = "failure.message";
40
41 /**
42 * The short title of this workflow definition
43 */
44 String getId();
45
46 /**
47 * Sets the identifier
48 *
49 * @param id
50 * the workflow definition identifier
51 */
52 void setId(String id);
53
54 /**
55 * The title for this workflow definition
56 */
57 String getTitle();
58
59 /**
60 * Sets the title
61 *
62 * @param title
63 * the workflow definition title
64 */
65 void setTitle(String title);
66
67 /**
68 * A longer description of this workflow definition
69 */
70 String getDescription();
71
72 /**
73 * Sets the description
74 *
75 * @param description
76 * the workflow definition description
77 */
78 void setDescription(String description);
79
80 /**
81 * A XML String describing the configuration parameter/panel for this WorkflowDefinition.
82 */
83 String getConfigurationPanel();
84
85 /**
86 * A JSON String describing the configuration parameter/panel for this WorkflowDefinition.
87 */
88 String getConfigurationPanelJson();
89
90 /**
91 * An integer describing the display order for this workflow definition. The display order is supposed to define the
92 * order workflow lists as displayed to users.
93 * Default is 0.
94 */
95 int getDisplayOrder();
96
97 /**
98 * Set the display order
99 *
100 * @param displayOrder
101 * the workflow definition display order
102 */
103 void setDisplayOrder(int displayOrder);
104
105 /**
106 * The operations, listed in order, that this workflow definition includes.
107 */
108 List<WorkflowOperationDefinition> getOperations();
109
110 /**
111 * The custom state mappings to use for this workflow.
112 */
113 Set<WorkflowStateMapping> getStateMappings();
114
115 /**
116 * Tags the workflow definition with the given tag.
117 *
118 * @param tag
119 * the tag
120 */
121 void addTag(String tag);
122
123 /**
124 * Removes the tag from the workflow definition.
125 *
126 * @param tag
127 * the tag
128 */
129 void removeTag(String tag);
130
131 /**
132 * Returns <code>true</code> if the workflow definition contains the given tag.
133 *
134 * @param tag
135 * the tag
136 * @return <code>true</code> if the element is tagged
137 */
138 boolean containsTag(String tag);
139
140 /**
141 * Returns <code>true</code> if the workflow definition contains at least one of the given tags. If there are no tags
142 * contained in the set, then the definition is considered to match as well.
143 *
144 * @param tags
145 * the set of tag
146 * @return <code>true</code> if the element is tagged accordingly
147 */
148 boolean containsTag(Collection<String> tags);
149
150 /**
151 * Returns the tags for this workflow definition or an empty array if there are no tags.
152 *
153 * @return the tags
154 */
155 String[] getTags();
156
157 /**
158 * Returns the roles for this workflow definition
159 *
160 * @return the tags
161 */
162 Collection<String> getRoles();
163
164 /**
165 * Removes all tags associated with this workflow definition
166 */
167 void clearTags();
168
169 /**
170 * Gets the organization associated with this workflow (or <code>null</code>, if it's global)
171 * @return the organization
172 */
173 String getOrganization();
174
175 /**
176 * Appends the operation to the workflow definition.
177 *
178 * @param operation
179 * the operation
180 */
181 void add(WorkflowOperationDefinition operation);
182
183 /**
184 * Inserts the operation at the given position into the workflow definition.
185 *
186 * @param operation
187 * the operation
188 * @param position
189 * the position to add the workflow operation to
190 * @throws IndexOutOfBoundsException
191 * if <code>position</code> is larger than the number of operations + 1
192 */
193 void add(WorkflowOperationDefinition operation, int position);
194
195 /**
196 * Returns the operation at the given position.
197 *
198 * @param position
199 * the operation's position
200 * @throws IndexOutOfBoundsException
201 * if <code>position</code> is larger than the number of operations
202 */
203 WorkflowOperationDefinition get(int position);
204
205 /**
206 * Removes the workflow operation at the indicated position and returns it.
207 *
208 * @param position
209 * the operation's position
210 * @return the removed workflow operation
211 * @throws IndexOutOfBoundsException
212 * if <code>position</code> is larger than the number of operations
213 */
214 WorkflowOperationDefinition remove(int position) throws IndexOutOfBoundsException;
215
216 }