KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > workflow > spi > hibernate > HibernateStep


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.workflow.spi.hibernate;
6
7 import com.opensymphony.workflow.spi.Step;
8
9 import java.util.Date JavaDoc;
10 import java.util.Iterator JavaDoc;
11 import java.util.List JavaDoc;
12
13
14 /**
15  * This abstract class provides all the implementation of the step interface
16  * It is abstract because the current and historical steps are stored in seperate tables.
17  * To split the history and current steps into two tables in hibernate, the easiest approach is to use
18  * two separate classes.
19  * @version $Revision: 1.5 $
20  */

21 public abstract class HibernateStep implements Step {
22     //~ Instance fields ////////////////////////////////////////////////////////
23

24     Date JavaDoc dueDate;
25     Date JavaDoc finishDate;
26     Date JavaDoc startDate;
27     HibernateWorkflowEntry entry;
28     List JavaDoc previousSteps;
29     String JavaDoc caller;
30     String JavaDoc owner;
31     String JavaDoc status;
32     int actionId;
33     int stepId;
34     long id = -1;
35
36     //~ Constructors ///////////////////////////////////////////////////////////
37

38     public HibernateStep() {
39     }
40
41     public HibernateStep(HibernateStep step) {
42         this.actionId = step.getActionId();
43         this.caller = step.getCaller();
44         this.finishDate = step.getFinishDate();
45         this.dueDate = step.getDueDate();
46         this.startDate = step.getStartDate();
47
48         //do not copy this value, it's for unsaved-value
49
//this.id = step.getId();
50
this.owner = step.getOwner();
51         this.status = step.getStatus();
52         this.stepId = step.getStepId();
53         this.previousSteps = step.getPreviousSteps();
54         this.entry = step.entry;
55     }
56
57     //~ Methods ////////////////////////////////////////////////////////////////
58

59     public void setActionId(int actionId) {
60         this.actionId = actionId;
61     }
62
63     public int getActionId() {
64         return actionId;
65     }
66
67     public void setCaller(String JavaDoc caller) {
68         this.caller = caller;
69     }
70
71     public String JavaDoc getCaller() {
72         return caller;
73     }
74
75     public void setDueDate(Date JavaDoc dueDate) {
76         this.dueDate = dueDate;
77     }
78
79     public Date JavaDoc getDueDate() {
80         return dueDate;
81     }
82
83     public void setEntry(HibernateWorkflowEntry entry) {
84         this.entry = entry;
85     }
86
87     public HibernateWorkflowEntry getEntry() {
88         return entry;
89     }
90
91     public long getEntryId() {
92         return entry.getId();
93     }
94
95     public void setFinishDate(Date JavaDoc finishDate) {
96         this.finishDate = finishDate;
97     }
98
99     public Date JavaDoc getFinishDate() {
100         return finishDate;
101     }
102
103     public void setId(long id) {
104         this.id = id;
105     }
106
107     public long getId() {
108         return id;
109     }
110
111     public void setOwner(String JavaDoc owner) {
112         this.owner = owner;
113     }
114
115     public String JavaDoc getOwner() {
116         return owner;
117     }
118
119     public long[] getPreviousStepIds() {
120         if (previousSteps == null) {
121             return new long[0];
122         }
123
124         long[] previousStepIds = new long[previousSteps.size()];
125         int i = 0;
126
127         for (Iterator JavaDoc iterator = previousSteps.iterator(); iterator.hasNext();) {
128             HibernateStep hibernateStep = (HibernateStep) iterator.next();
129             previousStepIds[i] = hibernateStep.getId();
130             i++;
131         }
132
133         return previousStepIds;
134     }
135
136     public void setPreviousSteps(List JavaDoc previousSteps) {
137         this.previousSteps = previousSteps;
138     }
139
140     public List JavaDoc getPreviousSteps() {
141         return previousSteps;
142     }
143
144     public void setStartDate(Date JavaDoc startDate) {
145         this.startDate = startDate;
146     }
147
148     public Date JavaDoc getStartDate() {
149         return startDate;
150     }
151
152     public void setStatus(String JavaDoc status) {
153         this.status = status;
154     }
155
156     public String JavaDoc getStatus() {
157         return status;
158     }
159
160     public void setStepId(int stepId) {
161         this.stepId = stepId;
162     }
163
164     public int getStepId() {
165         return stepId;
166     }
167 }
168
Popular Tags