Source code: org/apache/lenya/workflow/Condition.java
1 /*
2 * Copyright 1999-2004 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18 /* $Id: Condition.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.workflow;
21
22 /**
23 * <p>A condition can prevent a transition from firing,
24 * based on the current situation. Examples:</p>
25 * <ul>
26 * <li>Does the current user have a certain role on the current URL?</li>
27 * <li>Does a certain state variable have a certain value (e.g., is the document published)? (BooleanVariableCondition)<li>
28 * <li>Is the sun shining? (e.g., if the weather report may only be published on sunny days)</li>
29 * </ul>
30 */
31 public interface Condition {
32
33 /**
34 * Returns if the condition is complied in a certain situation.
35 * @param situation The situation to check.
36 * @param instance The workflow instance to check the condition on.
37 * @return if the condition is complied.
38 * @throws WorkflowException when the expression could not be evaluated.
39 */
40 boolean isComplied(Situation situation, WorkflowInstance instance) throws WorkflowException;
41
42 /** Sets the expression for this condition.
43 * @param expression The expression.
44 * @throws WorkflowException when the expression is not valid.
45 */
46 void setExpression(String expression) throws WorkflowException;
47 }