1
2 package org.galagosearch.tupleflow.execution;
3
4 import java.io.Serializable;
5 import java.util.ArrayList;
6 import java.util.HashMap;
7
8 /***
9 * This is a stage description for a TupleFlow job.
10 *
11 * @author trevor
12 */
13 public class Stage extends Locatable implements Serializable, Cloneable {
14 public HashMap<String, StageConnectionPoint> connections = new HashMap<String, StageConnectionPoint>();
15 public ArrayList<Step> steps = new ArrayList<Step>();
16 public String name;
17
18 public Stage() {
19 super(null);
20 }
21
22 public Stage(String name) {
23 super(null);
24 this.name = name;
25 }
26
27 public Stage(FileLocation location) {
28 super(location);
29 }
30
31 public ArrayList<Step> getSteps() {
32 return steps;
33 }
34
35 public boolean containsInput(String name) {
36 return connections.containsKey(name) &&
37 connections.get(name).type == ConnectionPointType.Input;
38 }
39
40 public boolean containsOutput(String name) {
41 return connections.containsKey(name) &&
42 connections.get(name).type == ConnectionPointType.Output;
43 }
44
45 public HashMap<String, StageConnectionPoint> getConnections() {
46 return connections;
47 }
48
49 public StageConnectionPoint getConnection(String pointName) {
50 return connections.get(pointName);
51 }
52
53 @Override
54 public Stage clone() {
55 Stage result = null;
56
57 try {
58 result = (Stage) super.clone();
59 result.name = name;
60 result.steps = new ArrayList<Step>(steps);
61 result.connections = new HashMap<String, StageConnectionPoint>(connections);
62 } catch (CloneNotSupportedException e) {
63 throw new RuntimeException("Didn't expect clone to not be supported in superclass", e);
64 }
65
66 return result;
67 }
68
69 public void add(StageConnectionPoint point) {
70 connections.put(point.getExternalName(), point);
71 }
72
73 public void add(Step step) {
74 steps.add(step);
75 }
76 }
77