KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > savant > ant > types > WorkflowType


1 /*
2  * Copyright (c) 2003-2004, Inversoft, All Rights Reserved
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.savant.ant.types;
8
9
10 import java.io.File JavaDoc;
11
12 import org.apache.tools.ant.BuildException;
13 import org.apache.tools.ant.Project;
14 import org.apache.tools.ant.types.DataType;
15
16 import com.inversoft.savant.Artifact;
17 import com.inversoft.savant.LocalCacheStore;
18 import com.inversoft.savant.Process;
19 import com.inversoft.savant.SavantException;
20 import com.inversoft.savant.Workflow;
21
22
23 /**
24  * <p>
25  * This class is the workflow that is used when attemping to
26  * fetch artifacts.
27  * </p>
28  *
29  * @author Brian Pontarelli
30  */

31 public class WorkflowType extends DataType {
32
33     private Workflow proxy = new Workflow();
34
35
36     /**
37      * Constructs a new <code>WorkflowType</code>.
38      */

39     public WorkflowType() {
40     }
41
42
43     /**
44      * Returns the Workflow object that this object is a proxy to.
45      */

46     public Workflow getProxy() {
47         return proxy;
48     }
49
50     /**
51      * Add a new process to the list of processes that compose this workflow.
52      *
53      * @param process The new process
54      */

55     public void add(DataType process) {
56         Process JavaDoc p;
57         if (process instanceof ProcessType) {
58             p = ((ProcessType) process).getProxy();
59         } else if (process instanceof Process JavaDoc) {
60             p = (Process JavaDoc) process;
61         } else {
62             throw new BuildException("WorkflowType only supports nested tasks that " +
63                 "implement com.inversoft.savant.Process");
64         }
65
66         proxy.addProcess(p);
67         log("Added process to workflow [" + process.getClass().getName() + "]",
68             Project.MSG_DEBUG);
69     }
70
71     /**
72      * Loops over all the processes until the artifact is found or not.
73      *
74      * @param artifact The artifact to locate
75      * @param localCache The local cache where the artifact is cached
76      * @return The artifact if found or null
77      */

78     public File JavaDoc findArtifact(Artifact artifact, LocalCacheStore localCache)
79     throws SavantException {
80         log("Looking for artifact [" + artifact + "]", Project.MSG_DEBUG);
81         return proxy.findArtifact(artifact, localCache);
82     }
83 }
Popular Tags