KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > nl > hippo > cms > workflow > conditions > IsWorkflowInStep


1 /*
2  * Copyright 2004 Hippo Webworks.
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 package nl.hippo.cms.workflow.conditions;
17
18 import com.opensymphony.module.propertyset.PropertySet;
19 import com.opensymphony.workflow.Condition;
20 import com.opensymphony.workflow.WorkflowException;
21 import com.opensymphony.workflow.spi.Step;
22 import com.opensymphony.workflow.spi.WorkflowEntry;
23 import com.opensymphony.workflow.spi.WorkflowStore;
24 import java.util.Iterator JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Map JavaDoc;
27 import org.apache.avalon.framework.logger.AbstractLogEnabled;
28 import org.apache.avalon.framework.thread.ThreadSafe;
29
30 /**
31  * @author Johan Stuyts
32  */

33 public class IsWorkflowInStep extends AbstractLogEnabled
34 implements Condition, ThreadSafe {
35     
36     public IsWorkflowInStep() {
37         super();
38     }
39
40     public boolean passesCondition(Map JavaDoc transientVars, Map JavaDoc args, PropertySet ps)
41     throws WorkflowException {
42
43         final WorkflowStore store = (WorkflowStore) transientVars.get("store");
44         final WorkflowEntry entry = (WorkflowEntry) transientVars.get("entry");
45         final int stepId = Integer.parseInt((String JavaDoc) args.get("stepId"));
46
47         final List JavaDoc currentSteps = store.findCurrentSteps(entry.getId());
48         final Iterator JavaDoc currentStepsIterator = currentSteps.iterator();
49
50         while (currentStepsIterator.hasNext()) {
51             final Step currentStep = (Step) currentStepsIterator.next();
52             if (currentStep.getStepId() == stepId) {
53                 return true;
54             }
55         }
56
57         return false;
58     }
59
60 }
61
Popular Tags