001: /*
002: * Copyright (c) 2002-2003 by OpenSymphony
003: * All rights reserved.
004: */
005: package com.opensymphony.workflow.spi.hibernate;
006:
007: import com.opensymphony.workflow.spi.Step;
008:
009: import java.util.Date;
010: import java.util.Iterator;
011: import java.util.List;
012:
013: /**
014: * This abstract class provides all the implementation of the step interface
015: * It is abstract because the current and historical steps are stored in seperate tables.
016: * To split the history and current steps into two tables in hibernate, the easiest approach is to use
017: * two separate classes.
018: */
019: public abstract class HibernateStep implements Step {
020: //~ Instance fields ////////////////////////////////////////////////////////
021:
022: Date dueDate;
023: Date finishDate;
024: Date startDate;
025: HibernateWorkflowEntry entry;
026: List previousSteps;
027: String caller;
028: String owner;
029: String status;
030: int actionId;
031: int stepId;
032: long id = -1;
033:
034: //~ Constructors ///////////////////////////////////////////////////////////
035:
036: public HibernateStep() {
037: }
038:
039: public HibernateStep(HibernateStep step) {
040: this .actionId = step.getActionId();
041: this .caller = step.getCaller();
042: this .finishDate = step.getFinishDate();
043: this .dueDate = step.getDueDate();
044: this .startDate = step.getStartDate();
045:
046: //do not copy this value, it's for unsaved-value
047: //this.id = step.getId();
048: this .owner = step.getOwner();
049: this .status = step.getStatus();
050: this .stepId = step.getStepId();
051: this .previousSteps = step.getPreviousSteps();
052: this .entry = step.entry;
053: }
054:
055: //~ Methods ////////////////////////////////////////////////////////////////
056:
057: public void setActionId(int actionId) {
058: this .actionId = actionId;
059: }
060:
061: public int getActionId() {
062: return actionId;
063: }
064:
065: public void setCaller(String caller) {
066: this .caller = caller;
067: }
068:
069: public String getCaller() {
070: return caller;
071: }
072:
073: public void setDueDate(Date dueDate) {
074: this .dueDate = dueDate;
075: }
076:
077: public Date getDueDate() {
078: return dueDate;
079: }
080:
081: public void setEntry(HibernateWorkflowEntry entry) {
082: this .entry = entry;
083: }
084:
085: public HibernateWorkflowEntry getEntry() {
086: return entry;
087: }
088:
089: public long getEntryId() {
090: return entry.getId();
091: }
092:
093: public void setFinishDate(Date finishDate) {
094: this .finishDate = finishDate;
095: }
096:
097: public Date getFinishDate() {
098: return finishDate;
099: }
100:
101: public void setId(long id) {
102: this .id = id;
103: }
104:
105: public long getId() {
106: return id;
107: }
108:
109: public void setOwner(String owner) {
110: this .owner = owner;
111: }
112:
113: public String getOwner() {
114: return owner;
115: }
116:
117: public long[] getPreviousStepIds() {
118: if (previousSteps == null) {
119: return new long[0];
120: }
121:
122: long[] previousStepIds = new long[previousSteps.size()];
123: int i = 0;
124:
125: for (Iterator iterator = previousSteps.iterator(); iterator
126: .hasNext();) {
127: HibernateStep hibernateStep = (HibernateStep) iterator
128: .next();
129: previousStepIds[i] = hibernateStep.getId();
130: i++;
131: }
132:
133: return previousStepIds;
134: }
135:
136: public void setPreviousSteps(List previousSteps) {
137: this .previousSteps = previousSteps;
138: }
139:
140: public List getPreviousSteps() {
141: return previousSteps;
142: }
143:
144: public void setStartDate(Date startDate) {
145: this .startDate = startDate;
146: }
147:
148: public Date getStartDate() {
149: return startDate;
150: }
151:
152: public void setStatus(String status) {
153: this .status = status;
154: }
155:
156: public String 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: }
|