KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > shark > instance > Activity


1 /*
2  * $Id: Activity.java 5462 2005-08-05 18:35:48Z jonesde $
3  *
4  * Copyright (c) 2004 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  */

25 package org.ofbiz.shark.instance;
26
27 import org.ofbiz.entity.GenericDelegator;
28 import org.ofbiz.entity.GenericValue;
29 import org.ofbiz.entity.GenericEntityException;
30 import org.ofbiz.base.util.UtilMisc;
31 import org.ofbiz.base.util.Debug;
32 import org.ofbiz.base.util.UtilDateTime;
33 import org.ofbiz.shark.container.SharkContainer;
34
35 import org.enhydra.shark.api.internal.instancepersistence.*;
36
37 /**
38  * Persistance Object
39  *
40  * @author <a HREF="mailto:jaz@ofbiz.org">Andy Zeneski</a>
41  * @version $Rev: 5462 $
42  * @since 3.1
43  */

44 public class Activity extends InstanceEntityObject implements ActivityPersistenceInterface {
45
46     public static final String JavaDoc module = Activity.class.getName();
47
48     protected GenericValue activity = null;
49     protected boolean newValue = false;
50
51     protected Activity(EntityPersistentMgr mgr, GenericDelegator delegator, String JavaDoc activityId) throws PersistenceException {
52         super(mgr, delegator);
53         this.delegator = delegator;
54         if (this.delegator != null) {
55             try {
56                 this.activity = delegator.findByPrimaryKey("WfActivity", UtilMisc.toMap("activityId", activityId));
57             } catch (GenericEntityException e) {
58                 throw new PersistenceException(e);
59             }
60         } else {
61             Debug.logError("Invalid delegator object passed", module);
62         }
63     }
64
65     protected Activity(EntityPersistentMgr mgr, GenericValue activity) {
66         super(mgr, activity.getDelegator());
67         this.activity = activity;
68     }
69
70     public Activity(EntityPersistentMgr mgr, GenericDelegator delegator) {
71         super(mgr, delegator);
72         this.newValue = true;
73         this.activity = delegator.makeValue("WfActivity", null);
74     }
75
76     public static Activity getInstance(EntityPersistentMgr mgr, GenericValue activity) {
77         Activity act = new Activity(mgr, activity);
78         if (act.isLoaded()) {
79             return act;
80         }
81         return null;
82     }
83
84     public static Activity getInstance(EntityPersistentMgr mgr, String JavaDoc activityId) throws PersistenceException {
85         Activity act = new Activity(mgr, SharkContainer.getDelegator(), activityId);
86         if (act.isLoaded()) {
87             return act;
88         }
89         return null;
90     }
91
92     public boolean isLoaded() {
93         if (activity == null) {
94             return false;
95         }
96         return true;
97     }
98
99     public void setId(String JavaDoc s) {
100         activity.set("activityId", s);
101     }
102
103     public String JavaDoc getId() {
104         return activity.getString("activityId");
105     }
106
107     public void setActivitySetDefinitionId(String JavaDoc asdId) {
108         activity.set("setDefinitionId", asdId);
109     }
110
111     public String JavaDoc getActivitySetDefinitionId() {
112         return activity.getString("setDefinitionId");
113     }
114
115     public void setActivityDefinitionId(String JavaDoc s) {
116         activity.set("definitionId", s);
117     }
118
119     public String JavaDoc getActivityDefinitionId() {
120        return activity.getString("definitionId");
121     }
122
123     public void setProcessId(String JavaDoc s) {
124         activity.set("processId", s);
125     }
126
127     public String JavaDoc getProcessId() {
128         return activity.getString("processId");
129     }
130
131     public void setSubflowProcessId(String JavaDoc s) {
132         activity.set("subFlowId", s);
133     }
134
135     public String JavaDoc getSubflowProcessId() {
136         return activity.getString("subFlowId");
137     }
138
139     public void setSubflowAsynchronous(boolean b) {
140         activity.set("isSubAsync", (b ? "Y" : "N"));
141     }
142
143     public boolean isSubflowAsynchronous() {
144         String JavaDoc isAsync = activity.getString("isSubAsync");
145         return isAsync != null && isAsync.equals("Y") ? true : false;
146     }
147
148     public void setResourceUsername(String JavaDoc s) {
149         activity.set("resourceUser", s);
150     }
151
152     public String JavaDoc getResourceUsername() {
153         return activity.getString("resourceUser");
154     }
155
156     public void setState(String JavaDoc s) {
157         activity.set("currentState", s);
158     }
159
160     public String JavaDoc getState() {
161         return activity.getString("currentState");
162     }
163
164     public void setBlockActivityId(String JavaDoc s) {
165         activity.set("blockId", s);
166     }
167
168     public String JavaDoc getBlockActivityId() {
169         return activity.getString("blockId");
170     }
171
172     public String JavaDoc getName() {
173         return activity.getString("activityName");
174     }
175
176     public void setName(String JavaDoc s) {
177         activity.set("activityName", s);
178     }
179
180     public String JavaDoc getDescription() {
181         return activity.getString("description");
182     }
183
184     public void setDescription(String JavaDoc s) {
185         activity.set("description", s);
186     }
187
188     public int getPriority() {
189         return activity.getLong("priority").intValue();
190     }
191
192     public void setPriority(int i) {
193         activity.set("priority", new Long JavaDoc(i));
194     }
195
196     public long getLastStateTime() {
197         return activity.get("lastStateTime") != null ? activity.getTimestamp("lastStateTime").getTime() : 0;
198     }
199
200     public void setLastStateTime(long timestamp) {
201         activity.set("lastStateTime", UtilDateTime.getTimestamp(timestamp));
202     }
203
204     public long getAcceptedTime() {
205         return activity.get("acceptedTime") != null ? activity.getTimestamp("acceptedTime").getTime() : 0;
206     }
207
208     public void setAcceptedTime(long timestamp) {
209         activity.set("acceptedTime", UtilDateTime.getTimestamp(timestamp));
210     }
211
212     public long getActivatedTime() {
213         return activity.get("activatedTime") != null ? activity.getTimestamp("activatedTime").getTime() : 0;
214     }
215
216     public void setActivatedTime(long timestamp) {
217         activity.set("activatedTime", UtilDateTime.getTimestamp(timestamp));
218     }
219
220     public void store() throws GenericEntityException {
221         if (newValue) {
222             delegator.createOrStore(activity);
223             newValue = false;
224         } else {
225             delegator.store(activity);
226         }
227     }
228
229     public void reload() throws GenericEntityException {
230         if (!newValue) {
231             activity.refresh();
232         }
233     }
234
235     public void remove() throws GenericEntityException {
236         if (!newValue) {
237             delegator.removeValue(activity);
238             Debug.log("**** REMOVED : " + this, module);
239         }
240     }
241 }
Popular Tags