01: package org.enhydra.shark.ejb;
02:
03: import org.enhydra.shark.api.client.wfbase.*;
04: import org.enhydra.shark.api.client.wfmodel.*;
05: import org.enhydra.shark.api.client.wfmodel.WfResource;
06:
07: /**
08: * WfResourceHelper - Helper class to be able to implement method
09: * WfAssignment.set_assignee(). Only required method to be implemented
10: * is resource_key().
11: * @author Sasa Bojanic
12: */
13: public class WfResourceHelper implements WfResource {
14: private String username;
15:
16: /**
17: * Creates a new WfResource
18: * @param username - Uniquely identifies the resource
19: */
20: protected WfResourceHelper(String username) {
21: this .username = username;
22: }
23:
24: /**
25: * Gets the number of work items currently assigned to this resource.
26: */
27: public int how_many_work_item() throws Exception {
28: throw new BaseException("Not implemented");
29: }
30:
31: /**
32: * Gets an iterator of work items.
33: */
34: public WfAssignmentIterator get_iterator_work_item()
35: throws Exception {
36: throw new BaseException("Not implemented");
37: }
38:
39: /**
40: * Gets the work items.
41: * @return List of WfAssignment objects.
42: */
43: public WfAssignment[] get_sequence_work_item(int max_number)
44: throws Exception {
45: throw new BaseException("Not implemented");
46: }
47:
48: /**
49: * Checks if an assignment object is associated with this resource
50: * @return true if assignment is part of the work list for this resource.
51: */
52: public boolean is_member_of_work_items(WfAssignment member)
53: throws Exception {
54: throw new BaseException("Not implemented");
55: }
56:
57: /**
58: * Gets the resource username.
59: */
60: public String resource_key() throws Exception {
61: return username;
62: }
63:
64: /**
65: * Gets the resource name.
66: */
67: public String resource_name() throws Exception {
68: throw new BaseException("Not implemented");
69: }
70:
71: /**
72: * Release the resouce from the assignment.
73: */
74: public void release(WfAssignment from_assigment, String release_info)
75: throws Exception, NotAssigned {
76: throw new BaseException("Not implemented");
77: }
78:
79: public String toString() {
80: return "[Id=" + username + "]";
81: }
82:
83: /**
84: * It is assumed that there can't be two or more
85: * resources having the same resource key.
86: */
87: public boolean equals(Object obj) {
88: if (!(obj instanceof WfResource))
89: return false;
90: WfResource res = (WfResource) obj;
91: try {
92: return res.resource_key().equals(username);
93: } catch (Exception ex) {
94: return false;
95: }
96: }
97:
98: }
|