001: /*
002: * $Id: Work.java 661 2006-03-10 22:47:16Z hengels $
003: * (c) Copyright 2004 con:cern development team.
004: *
005: * This file is part of con:cern (http://concern.sf.net).
006: *
007: * con:cern is free software; you can redistribute it and/or modify
008: * it under the terms of the GNU Lesser General Public License
009: * as published by the Free Software Foundation; either version 2.1
010: * of the License, or (at your option) any later version.
011: *
012: * Please see COPYING for the complete licence.
013: */
014: package org.concern;
015:
016: import java.sql.Timestamp;
017: import java.util.*;
018:
019: /**
020: * Work describes a unit of concern. It referes to a process, an activity and a subject.
021: */
022: public class Work {
023: protected String process;
024: protected String activity;
025: protected String subjectId;
026: protected String subjectLine;
027: protected int level;
028: protected String originator;
029: protected Timestamp due;
030: protected String lockedBy;
031: protected Timestamp lockedUntil;
032:
033: private Object subject;
034:
035: protected Work() {
036: }
037:
038: public Work(String process, String activity, String subjectId) {
039: this .process = process;
040: this .subjectId = subjectId;
041: this .activity = activity;
042: }
043:
044: public Work(String process, String activity, String subjectId,
045: String subjectLine, String originator, Timestamp due,
046: int level, String lockedBy, Timestamp lockedUntil) {
047: this .process = process;
048: this .activity = activity;
049: this .subjectId = subjectId;
050: this .subjectLine = subjectLine;
051: this .originator = originator;
052: this .due = due;
053: this .level = level;
054: this .lockedBy = lockedBy;
055: this .lockedUntil = lockedUntil;
056: }
057:
058: // hibernate bug .. won't locate the constructor with parameters of type timestamp
059: public Work(String process, String activity, String subjectId,
060: String subjectLine, String originator, long due, int level,
061: String lockedBy, Date lockedUntil) {
062: this .process = process;
063: this .activity = activity;
064: this .subjectId = subjectId;
065: this .subjectLine = subjectLine;
066: this .originator = originator;
067: if (due != Long.MAX_VALUE)
068: this .due = new Timestamp(due);
069: this .level = level;
070: this .lockedBy = lockedBy;
071: if (lockedUntil != null)
072: this .lockedUntil = new Timestamp(lockedUntil.getTime());
073: }
074:
075: /**
076: * @return identifies the subject
077: */
078: public String getSubjectId() {
079: return subjectId;
080: }
081:
082: /**
083: * The name of the process to which the activity belongs.
084: * @return the process name
085: */
086: public String getProcess() {
087: return process;
088: }
089:
090: /**
091: * The name of the activity that is to be executed.
092: * @return
093: */
094: public String getActivity() {
095: return activity;
096: }
097:
098: /**
099: * The task is due until ..
100: * @return
101: */
102: public Timestamp getDue() {
103: return due;
104: }
105:
106: /**
107: * The subject orginated from ..
108: * @return
109: */
110: public String getOriginator() {
111: return originator;
112: }
113:
114: /**
115: * The localized subject line
116: * @return
117: */
118: public String getSubjectLine() {
119: return subjectLine;
120: }
121:
122: public int getLevel() {
123: return level;
124: }
125:
126: public void setLevel(int level) {
127: this .level = level;
128: }
129:
130: /**
131: * Currently locked by ..
132: * @return
133: */
134: public String getLockedBy() {
135: return lockedBy;
136: }
137:
138: /**
139: * Supposably locked until ..
140: * @return
141: */
142: public Timestamp getLockedUntil() {
143: return lockedUntil;
144: }
145:
146: /**
147: * The subject itself as loaded by the Loader.
148: * @return the subject
149: */
150: public Object getSubject() {
151: return subject;
152: }
153:
154: /**
155: * The subject itself as loaded by the Loader.
156: * @param subject the subject
157: */
158: public void setSubject(Object subject) {
159: this .subject = subject;
160: }
161:
162: public boolean isOptional() {
163: return due == null;
164: }
165:
166: public boolean equals(Object o) {
167: if (this == o)
168: return true;
169: if (!(o instanceof Work))
170: return false;
171:
172: final Work work = (Work) o;
173:
174: if (!activity.equals(work.activity))
175: return false;
176: if (!process.equals(work.process))
177: return false;
178: if (!subjectId.equals(work.subjectId))
179: return false;
180:
181: return true;
182: }
183:
184: public int hashCode() {
185: int result;
186: result = subjectId.hashCode();
187: result = 29 * result + activity.hashCode();
188: result = 29 * result + process.hashCode();
189: return result;
190: }
191:
192: public String toString() {
193: return process + ":" + activity + ":" + subjectId;
194: }
195: }
|