Source Code Cross Referenced for ActivityManager.java in  » Issue-Tracking » scarab-0.21 » org » tigris » scarab » om » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Issue Tracking » scarab 0.21 » org.tigris.scarab.om 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.tigris.scarab.om;
002:
003:        /* ================================================================
004:         * Copyright (c) 2000-2005 CollabNet.  All rights reserved.
005:         * 
006:         * Redistribution and use in source and binary forms, with or without
007:         * modification, are permitted provided that the following conditions are
008:         * met:
009:         * 
010:         * 1. Redistributions of source code must retain the above copyright
011:         * notice, this list of conditions and the following disclaimer.
012:         * 
013:         * 2. Redistributions in binary form must reproduce the above copyright
014:         * notice, this list of conditions and the following disclaimer in the
015:         * documentation and/or other materials provided with the distribution.
016:         * 
017:         * 3. The end-user documentation included with the redistribution, if
018:         * any, must include the following acknowlegement: "This product includes
019:         * software developed by Collab.Net <http://www.Collab.Net/>."
020:         * Alternately, this acknowlegement may appear in the software itself, if
021:         * and wherever such third-party acknowlegements normally appear.
022:         * 
023:         * 4. The hosted project names must not be used to endorse or promote
024:         * products derived from this software without prior written
025:         * permission. For written permission, please contact info@collab.net.
026:         * 
027:         * 5. Products derived from this software may not use the "Tigris" or 
028:         * "Scarab" names nor may "Tigris" or "Scarab" appear in their names without 
029:         * prior written permission of Collab.Net.
030:         * 
031:         * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
032:         * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
033:         * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
034:         * IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
035:         * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
036:         * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
037:         * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
038:         * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
039:         * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
040:         * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
041:         * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
042:         *
043:         * ====================================================================
044:         * 
045:         * This software consists of voluntary contributions made by many
046:         * individuals on behalf of Collab.Net.
047:         */
048:
049:        import java.sql.Connection;
050:        import java.util.List;
051:        import java.util.HashMap;
052:
053:        import org.apache.torque.TorqueException;
054:        import org.apache.torque.om.Persistent;
055:        import org.tigris.scarab.notification.ActivityType;
056:        import org.tigris.scarab.util.ScarabConstants;
057:
058:        /** 
059:         * This class manages Activity objects.  
060:         *
061:         * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
062:         * @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
063:         * @version $Id: ActivityManager.java 10020 2006-03-16 16:19:13Z jorgeuriarte $
064:         */
065:        public class ActivityManager extends BaseActivityManager {
066:            /**
067:             * Creates a new <code>ActivityManager</code> instance.
068:             *
069:             * @exception TorqueException if an error occurs
070:             */
071:            public ActivityManager() throws TorqueException {
072:                super ();
073:                validFields = new HashMap();
074:                validFields.put(ActivityPeer.ISSUE_ID, null);
075:            }
076:
077:            protected Persistent putInstanceImpl(Persistent om)
078:                    throws TorqueException {
079:                Persistent oldOm = super .putInstanceImpl(om);
080:                List listeners = (List) listenersMap.get(ActivityPeer.ISSUE_ID);
081:                notifyListeners(listeners, oldOm, om);
082:                return oldOm;
083:            }
084:
085:            /**
086:             * Convenience method for getting an Activity instance
087:             * with a String primary key (which gets converted to a Integer).
088:             */
089:            public static Activity getInstance(String id)
090:                    throws TorqueException {
091:                return getInstance(new Long(id));
092:            }
093:
094:            public static Activity createNumericActivity(Issue issue,
095:                    Attribute attribute, ActivitySet activitySet,
096:                    Attachment attachment, Integer oldNumericValue,
097:                    Integer newNumericValue) throws TorqueException {
098:                return create(issue, attribute, activitySet,
099:                        ActivityType.ATTRIBUTE_CHANGED, null, attachment,
100:                        oldNumericValue, newNumericValue, null, null, null,
101:                        null, null, null);
102:            }
103:
104:            public static Activity createUserActivity(Issue issue,
105:                    Attribute attribute, ActivitySet activitySet,
106:                    Attachment attachment, Integer oldUserId, Integer newUserId)
107:                    throws TorqueException {
108:                String oldUsername = null;
109:                String newUsername = null;
110:                if (oldUserId != null) {
111:                    oldUsername = ScarabUserManager.getInstance(oldUserId)
112:                            .getUserName();
113:                }
114:                if (newUserId != null) {
115:                    newUsername = ScarabUserManager.getInstance(newUserId)
116:                            .getUserName();
117:                }
118:                return create(issue, attribute, activitySet,
119:                        ActivityType.USER_ATTRIBUTE_CHANGED, null, attachment,
120:                        null, null, oldUserId, newUserId, null, null,
121:                        oldUsername, newUsername);
122:            }
123:
124:            public static Activity createAddDependencyActivity(Issue issue,
125:                    ActivitySet activitySet, Depend depend)
126:                    throws TorqueException {
127:                return create(issue, null, activitySet,
128:                        ActivityType.DEPENDENCY_CREATED, null, null, depend,
129:                        null, null, null, null, null, null, null, depend
130:                                .getDependType().getName(), null);
131:            }
132:
133:            public static Activity createChangeDependencyActivity(Issue issue,
134:                    ActivitySet activitySet, Depend depend,
135:                    String oldTextValue, String newTextValue)
136:                    throws TorqueException {
137:                return create(issue, null, activitySet,
138:                        ActivityType.DEPENDENCY_CHANGED, null, null, depend,
139:                        null, null, null, null, null, null, oldTextValue,
140:                        newTextValue, null);
141:            }
142:
143:            public static Activity createDeleteDependencyActivity(Issue issue,
144:                    ActivitySet activitySet, Depend depend)
145:                    throws TorqueException {
146:                return create(issue, null, activitySet,
147:                        ActivityType.DEPENDENCY_DELETED, null, null, depend,
148:                        null, null, null, null, null, null, depend
149:                                .getDependType().getName(), null, null);
150:            }
151:
152:            public static Activity createTextActivity(Issue issue,
153:                    ActivitySet activitySet, ActivityType type,
154:                    String newTextValue) throws TorqueException {
155:                return create(issue, null, activitySet, type, null, null, null,
156:                        null, null, null, null, null, null, newTextValue);
157:            }
158:
159:            public static Activity createTextActivity(Issue issue,
160:                    ActivitySet activitySet, ActivityType type,
161:                    Attachment attachment) throws TorqueException {
162:                return create(issue, null, activitySet, type, null, attachment,
163:                        null, null, null, null, null, null, null, null);
164:            }
165:
166:            public static Activity createTextActivity(Issue issue,
167:                    Attribute attribute, ActivitySet activitySet,
168:                    ActivityType type, String oldTextValue, String newTextValue)
169:                    throws TorqueException {
170:                return create(issue, attribute, activitySet, type, null, null,
171:                        null, null, null, null, null, null, oldTextValue,
172:                        newTextValue);
173:            }
174:
175:            public static Activity createTextActivity(Issue issue,
176:                    ActivitySet activitySet, ActivityType type,
177:                    Attachment attachment, String oldTextValue,
178:                    String newTextValue) throws TorqueException {
179:                return create(issue, null, activitySet, type, null, attachment,
180:                        null, null, null, null, null, null, oldTextValue,
181:                        newTextValue);
182:            }
183:
184:            public static Activity createTextActivity(Issue issue,
185:                    Attribute attribute, ActivitySet activitySet,
186:                    ActivityType type, String description,
187:                    Attachment attachment, String oldTextValue,
188:                    String newTextValue) throws TorqueException {
189:                return create(issue, attribute, activitySet, type, description,
190:                        attachment, null, null, null, null, null, null,
191:                        oldTextValue, newTextValue);
192:            }
193:
194:            /**
195:             * Populates a new Activity object for initial issue creation.
196:             */
197:            public static Activity createReportIssueActivity(Issue issue,
198:                    ActivitySet activitySet, String message)
199:                    throws TorqueException {
200:                return create(issue, AttributeManager
201:                        .getInstance(ScarabConstants.INTEGER_0), activitySet,
202:                        ActivityType.ISSUE_CREATED, null, null, null, null,
203:                        null, null, null, null, null, null);
204:            }
205:
206:            /**
207:             * Populates a new Activity for issue deletion
208:             * 
209:             * @param issue
210:             * @param activitySet
211:             * @return
212:             * @throws TorqueException
213:             */
214:            public static Activity createDeleteIssueActivity(Issue issue,
215:                    ActivitySet activitySet) throws TorqueException {
216:                return create(issue, AttributeManager
217:                        .getInstance(ScarabConstants.INTEGER_0), activitySet,
218:                        ActivityType.ISSUE_DELETED, null, null, null, null,
219:                        null, null, null, null, null, null);
220:            }
221:
222:            /**
223:             * Populates a new Activity object.
224:             */
225:            public static Activity create(Issue issue, Attribute attribute,
226:                    ActivitySet activitySet, ActivityType type,
227:                    String description, Attachment attachment,
228:                    Integer oldNumericValue, Integer newNumericValue,
229:                    Integer oldUserId, Integer newUserId, Integer oldOptionId,
230:                    Integer newOptionId, String oldTextValue,
231:                    String newTextValue) throws TorqueException {
232:                return create(issue, attribute, activitySet, type, description,
233:                        attachment, null, oldNumericValue, newNumericValue,
234:                        oldUserId, newUserId, oldOptionId, newOptionId,
235:                        oldTextValue, newTextValue, null);
236:            }
237:
238:            /**
239:             * Populates a new Activity object.
240:             */
241:            public static Activity create(Issue issue, Attribute attribute,
242:                    ActivitySet activitySet, ActivityType type,
243:                    String description, Attachment attachment,
244:                    Integer oldNumericValue, Integer newNumericValue,
245:                    Integer oldUserId, Integer newUserId, Integer oldOptionId,
246:                    Integer newOptionId, String oldTextValue,
247:                    String newTextValue, Connection dbCon)
248:                    throws TorqueException {
249:                return create(issue, attribute, activitySet, type, description,
250:                        attachment, null, oldNumericValue, newNumericValue,
251:                        oldUserId, newUserId, oldOptionId, newOptionId,
252:                        oldTextValue, newTextValue, dbCon);
253:            }
254:
255:            /**
256:             * Populates a new Activity object.
257:             */
258:            public static Activity create(Issue issue, Attribute attribute,
259:                    ActivitySet activitySet, ActivityType type,
260:                    String description, Attachment attachment, Depend depend,
261:                    Integer oldNumericValue, Integer newNumericValue,
262:                    Integer oldUserId, Integer newUserId, Integer oldOptionId,
263:                    Integer newOptionId, String oldTextValue,
264:                    String newTextValue, Connection dbCon)
265:                    throws TorqueException {
266:                Activity activity = ActivityManager.getInstance();
267:                activity.setIssue(issue);
268:                if (attribute == null) {
269:                    attribute = Attribute.getInstance(0);
270:                }
271:                activity.setAttribute(attribute);
272:                activity.setActivitySet(activitySet);
273:                activity.setOldNumericValue(oldNumericValue);
274:                activity.setNewNumericValue(newNumericValue);
275:                activity.setOldUserId(oldUserId);
276:                activity.setNewUserId(newUserId);
277:                activity.setOldOptionId(oldOptionId);
278:                activity.setNewOptionId(newOptionId);
279:                activity.setOldValue(oldTextValue);
280:                activity.setNewValue(newTextValue);
281:                activity.setDepend(depend);
282:                activity.setDescription(description);
283:                activity.setActivityType(type != null ? type.getCode() : null);
284:                if (attachment != null) {
285:                    activity.setAttachment(attachment);
286:                }
287:                if (dbCon == null) {
288:                    try {
289:                        activity.save();
290:                    } catch (Exception e) {
291:                        if (e instanceof  TorqueException) {
292:                            throw (TorqueException) e; //EXCEPTION
293:                        } else {
294:                            throw new TorqueException(e); //EXCEPTION
295:                        }
296:                    }
297:                } else {
298:                    activity.save(dbCon);
299:                }
300:                // Make sure new activity is added to activity cache
301:                try {
302:                    issue.addActivity(activity);
303:                } catch (Exception e) {
304:                    throw new TorqueException(e); //EXCEPTION
305:                }
306:                return activity;
307:            }
308:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.