Source Code Cross Referenced for BaseIssueVote.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:        import java.math.BigDecimal;
004:        import java.sql.Connection;
005:        import java.util.ArrayList;
006:        import java.util.Collections;
007:        import java.util.Date;
008:        import java.util.List;
009:
010:        import org.apache.commons.lang.ObjectUtils;
011:        import org.apache.fulcrum.intake.Retrievable;
012:        import org.apache.torque.TorqueException;
013:        import org.apache.torque.om.BaseObject;
014:        import org.apache.torque.om.ComboKey;
015:        import org.apache.torque.om.DateKey;
016:        import org.apache.torque.om.NumberKey;
017:        import org.apache.torque.om.ObjectKey;
018:        import org.apache.torque.om.SimpleKey;
019:        import org.apache.torque.om.StringKey;
020:        import org.apache.torque.om.Persistent;
021:        import org.apache.torque.util.Criteria;
022:        import org.apache.torque.util.Transaction;
023:
024:        /**
025:         * You should not use this class directly.  It should not even be
026:         * extended all references should be to IssueVote
027:         */
028:        public abstract class BaseIssueVote extends BaseObject implements 
029:                org.apache.fulcrum.intake.Retrievable {
030:            /** The Peer class */
031:            private static final IssueVotePeer peer = new IssueVotePeer();
032:
033:            /** The value for the issueId field */
034:            private Long issueId;
035:
036:            /** The value for the userId field */
037:            private Integer userId;
038:
039:            /** The value for the votes field */
040:            private int votes = 0;
041:
042:            /**
043:             * Get the IssueId
044:             *
045:             * @return Long
046:             */
047:            public Long getIssueId() {
048:                return issueId;
049:            }
050:
051:            /**
052:             * Set the value of IssueId
053:             *
054:             * @param v new value
055:             */
056:            public void setIssueId(Long v) throws TorqueException {
057:
058:                if (!ObjectUtils.equals(this .issueId, v)) {
059:                    this .issueId = v;
060:                    setModified(true);
061:                }
062:
063:                if (aIssue != null
064:                        && !ObjectUtils.equals(aIssue.getIssueId(), v)) {
065:                    aIssue = null;
066:                }
067:
068:            }
069:
070:            /**
071:             * Get the UserId
072:             *
073:             * @return Integer
074:             */
075:            public Integer getUserId() {
076:                return userId;
077:            }
078:
079:            /**
080:             * Set the value of UserId
081:             *
082:             * @param v new value
083:             */
084:            public void setUserId(Integer v) throws TorqueException {
085:
086:                if (!ObjectUtils.equals(this .userId, v)) {
087:                    this .userId = v;
088:                    setModified(true);
089:                }
090:
091:                if (aScarabUser != null
092:                        && !ObjectUtils.equals(aScarabUser.getUserId(), v)) {
093:                    aScarabUser = null;
094:                }
095:
096:            }
097:
098:            /**
099:             * Get the Votes
100:             *
101:             * @return int
102:             */
103:            public int getVotes() {
104:                return votes;
105:            }
106:
107:            /**
108:             * Set the value of Votes
109:             *
110:             * @param v new value
111:             */
112:            public void setVotes(int v) {
113:
114:                if (this .votes != v) {
115:                    this .votes = v;
116:                    setModified(true);
117:                }
118:
119:            }
120:
121:            private Issue aIssue;
122:
123:            /**
124:             * Declares an association between this object and a Issue object
125:             *
126:             * @param v Issue
127:             * @throws TorqueException
128:             */
129:            public void setIssue(Issue v) throws TorqueException {
130:                if (v == null) {
131:                    setIssueId((Long) null);
132:                } else {
133:                    setIssueId(v.getIssueId());
134:                }
135:                aIssue = v;
136:            }
137:
138:            /**
139:             * Returns the associated Issue object.
140:             * If it was not retrieved before, the object is retrieved from
141:             * the database
142:             *
143:             * @return the associated Issue object
144:             * @throws TorqueException
145:             */
146:            public Issue getIssue() throws TorqueException {
147:                if (aIssue == null && (!ObjectUtils.equals(this .issueId, null))) {
148:                    aIssue = IssueManager.getInstance(SimpleKey
149:                            .keyFor(this .issueId));
150:                }
151:                return aIssue;
152:            }
153:
154:            /**
155:             * Return the associated Issue object
156:             * If it was not retrieved before, the object is retrieved from
157:             * the database using the passed connection
158:             *
159:             * @param connection the connection used to retrieve the associated object
160:             *        from the database, if it was not retrieved before
161:             * @return the associated Issue object
162:             * @throws TorqueException
163:             */
164:            public Issue getIssue(Connection connection) throws TorqueException {
165:                if (aIssue == null && (!ObjectUtils.equals(this .issueId, null))) {
166:                    aIssue = IssueManager.getCachedInstance(SimpleKey
167:                            .keyFor(this .issueId));
168:                    if (aIssue == null) {
169:                        aIssue = IssuePeer.retrieveByPK(SimpleKey
170:                                .keyFor(this .issueId), connection);
171:                        IssueManager.putInstance(aIssue);
172:                    }
173:                }
174:                return aIssue;
175:            }
176:
177:            /**
178:             * Provides convenient way to set a relationship based on a
179:             * ObjectKey, for example
180:             * <code>bar.setFooKey(foo.getPrimaryKey())</code>
181:             *
182:             */
183:            public void setIssueKey(ObjectKey key) throws TorqueException {
184:
185:                setIssueId(new Long(((NumberKey) key).longValue()));
186:            }
187:
188:            private ScarabUser aScarabUser;
189:
190:            /**
191:             * Declares an association between this object and a ScarabUser object
192:             *
193:             * @param v ScarabUser
194:             * @throws TorqueException
195:             */
196:            public void setScarabUser(ScarabUser v) throws TorqueException {
197:                if (v == null) {
198:                    setUserId((Integer) null);
199:                } else {
200:                    setUserId(v.getUserId());
201:                }
202:                aScarabUser = v;
203:            }
204:
205:            /**
206:             * Returns the associated ScarabUser object.
207:             * If it was not retrieved before, the object is retrieved from
208:             * the database
209:             *
210:             * @return the associated ScarabUser object
211:             * @throws TorqueException
212:             */
213:            public ScarabUser getScarabUser() throws TorqueException {
214:                if (aScarabUser == null
215:                        && (!ObjectUtils.equals(this .userId, null))) {
216:                    aScarabUser = ScarabUserManager.getInstance(SimpleKey
217:                            .keyFor(this .userId));
218:                }
219:                return aScarabUser;
220:            }
221:
222:            /**
223:             * Return the associated ScarabUser object
224:             * If it was not retrieved before, the object is retrieved from
225:             * the database using the passed connection
226:             *
227:             * @param connection the connection used to retrieve the associated object
228:             *        from the database, if it was not retrieved before
229:             * @return the associated ScarabUser object
230:             * @throws TorqueException
231:             */
232:            public ScarabUser getScarabUser(Connection connection)
233:                    throws TorqueException {
234:                if (aScarabUser == null
235:                        && (!ObjectUtils.equals(this .userId, null))) {
236:                    aScarabUser = ScarabUserManager.getCachedInstance(SimpleKey
237:                            .keyFor(this .userId));
238:                    if (aScarabUser == null) {
239:                        aScarabUser = ScarabUserImplPeer
240:                                .retrieveScarabUserImplByPK(SimpleKey
241:                                        .keyFor(this .userId), connection);
242:                        ScarabUserManager.putInstance(aScarabUser);
243:                    }
244:                }
245:                return aScarabUser;
246:            }
247:
248:            /**
249:             * Provides convenient way to set a relationship based on a
250:             * ObjectKey, for example
251:             * <code>bar.setFooKey(foo.getPrimaryKey())</code>
252:             *
253:             */
254:            public void setScarabUserKey(ObjectKey key) throws TorqueException {
255:
256:                setUserId(new Integer(((NumberKey) key).intValue()));
257:            }
258:
259:            private static List fieldNames = null;
260:
261:            /**
262:             * Generate a list of field names.
263:             *
264:             * @return a list of field names
265:             */
266:            public static synchronized List getFieldNames() {
267:                if (fieldNames == null) {
268:                    fieldNames = new ArrayList();
269:                    fieldNames.add("IssueId");
270:                    fieldNames.add("UserId");
271:                    fieldNames.add("Votes");
272:                    fieldNames = Collections.unmodifiableList(fieldNames);
273:                }
274:                return fieldNames;
275:            }
276:
277:            /**
278:             * Retrieves a field from the object by name passed in as a String.
279:             *
280:             * @param name field name
281:             * @return value
282:             */
283:            public Object getByName(String name) {
284:                if (name.equals("IssueId")) {
285:                    return getIssueId();
286:                }
287:                if (name.equals("UserId")) {
288:                    return getUserId();
289:                }
290:                if (name.equals("Votes")) {
291:                    return new Integer(getVotes());
292:                }
293:                return null;
294:            }
295:
296:            /**
297:             * Retrieves a field from the object by name passed in
298:             * as a String.  The String must be one of the static
299:             * Strings defined in this Class' Peer.
300:             *
301:             * @param name peer name
302:             * @return value
303:             */
304:            public Object getByPeerName(String name) {
305:                if (name.equals(IssueVotePeer.ISSUE_ID)) {
306:                    return getIssueId();
307:                }
308:                if (name.equals(IssueVotePeer.USER_ID)) {
309:                    return getUserId();
310:                }
311:                if (name.equals(IssueVotePeer.VOTES)) {
312:                    return new Integer(getVotes());
313:                }
314:                return null;
315:            }
316:
317:            /**
318:             * Retrieves a field from the object by Position as specified
319:             * in the xml schema.  Zero-based.
320:             *
321:             * @param pos position in xml schema
322:             * @return value
323:             */
324:            public Object getByPosition(int pos) {
325:                if (pos == 0) {
326:                    return getIssueId();
327:                }
328:                if (pos == 1) {
329:                    return getUserId();
330:                }
331:                if (pos == 2) {
332:                    return new Integer(getVotes());
333:                }
334:                return null;
335:            }
336:
337:            /**
338:             * Stores the object in the database.  If the object is new,
339:             * it inserts it; otherwise an update is performed.
340:             *
341:             * @throws TorqueException
342:             */
343:            public void save() throws TorqueException {
344:                save(IssueVotePeer.getMapBuilder().getDatabaseMap().getName());
345:            }
346:
347:            /**
348:             * Stores the object in the database.  If the object is new,
349:             * it inserts it; otherwise an update is performed.
350:             * Note: this code is here because the method body is
351:             * auto-generated conditionally and therefore needs to be
352:             * in this file instead of in the super class, BaseObject.
353:             *
354:             * @param dbName
355:             * @throws TorqueException
356:             */
357:            public void save(String dbName) throws TorqueException {
358:                Connection con = null;
359:                try {
360:                    con = Transaction.begin(dbName);
361:                    save(con);
362:                    Transaction.commit(con);
363:                } catch (TorqueException e) {
364:                    Transaction.safeRollback(con);
365:                    throw e;
366:                }
367:            }
368:
369:            /** flag to prevent endless save loop, if this object is referenced
370:              by another object which falls in this transaction. */
371:            private boolean alreadyInSave = false;
372:
373:            /**
374:             * Stores the object in the database.  If the object is new,
375:             * it inserts it; otherwise an update is performed.  This method
376:             * is meant to be used as part of a transaction, otherwise use
377:             * the save() method and the connection details will be handled
378:             * internally
379:             *
380:             * @param con
381:             * @throws TorqueException
382:             */
383:            public void save(Connection con) throws TorqueException {
384:                if (!alreadyInSave) {
385:                    alreadyInSave = true;
386:
387:                    // If this object has been modified, then save it to the database.
388:                    if (isModified()) {
389:                        if (isNew()) {
390:                            IssueVotePeer.doInsert((IssueVote) this , con);
391:                            setNew(false);
392:                        } else {
393:                            IssueVotePeer.doUpdate((IssueVote) this , con);
394:                        }
395:
396:                        if (isCacheOnSave()) {
397:                            IssueVoteManager.putInstance(this );
398:                        }
399:                    }
400:
401:                    alreadyInSave = false;
402:                }
403:            }
404:
405:            /**
406:             * Specify whether to cache the object after saving to the db.
407:             * This method returns true
408:             */
409:            protected boolean isCacheOnSave() {
410:                return true;
411:            }
412:
413:            private final SimpleKey[] pks = new SimpleKey[2];
414:            private final ComboKey comboPK = new ComboKey(pks);
415:
416:            /**
417:             * Set the PrimaryKey with an ObjectKey
418:             *
419:             * @param key
420:             */
421:            public void setPrimaryKey(ObjectKey key) throws TorqueException {
422:                SimpleKey[] keys = (SimpleKey[]) key.getValue();
423:                SimpleKey tmpKey = null;
424:                setIssueId(new Long(((NumberKey) keys[0]).longValue()));
425:                setUserId(new Integer(((NumberKey) keys[1]).intValue()));
426:            }
427:
428:            /**
429:             * Set the PrimaryKey using SimpleKeys.
430:             *
431:             * @param issueId Long
432:             * @param userId Integer
433:             */
434:            public void setPrimaryKey(Long issueId, Integer userId)
435:                    throws TorqueException {
436:                setIssueId(issueId);
437:                setUserId(userId);
438:            }
439:
440:            /**
441:             * Set the PrimaryKey using a String.
442:             */
443:            public void setPrimaryKey(String key) throws TorqueException {
444:                setPrimaryKey(new ComboKey(key));
445:            }
446:
447:            /**
448:             * returns an id that differentiates this object from others
449:             * of its class.
450:             */
451:            public ObjectKey getPrimaryKey() {
452:                pks[0] = SimpleKey.keyFor(getIssueId());
453:                pks[1] = SimpleKey.keyFor(getUserId());
454:                return comboPK;
455:            }
456:
457:            /**
458:             * get an id that differentiates this object from others
459:             * of its class.
460:             */
461:            public String getQueryKey() {
462:                if (getPrimaryKey() == null) {
463:                    return "";
464:                } else {
465:                    return getPrimaryKey().toString();
466:                }
467:            }
468:
469:            /**
470:             * set an id that differentiates this object from others
471:             * of its class.
472:             */
473:            public void setQueryKey(String key) throws TorqueException {
474:                setPrimaryKey(key);
475:            }
476:
477:            /**
478:             * Makes a copy of this object.
479:             * It creates a new object filling in the simple attributes.
480:             * It then fills all the association collections and sets the
481:             * related objects to isNew=true.
482:             */
483:            public IssueVote copy() throws TorqueException {
484:                return copyInto(new IssueVote());
485:            }
486:
487:            protected IssueVote copyInto(IssueVote copyObj)
488:                    throws TorqueException {
489:                copyObj.setIssueId(issueId);
490:                copyObj.setUserId(userId);
491:                copyObj.setVotes(votes);
492:
493:                copyObj.setIssueId((Long) null);
494:                copyObj.setUserId((Integer) null);
495:
496:                return copyObj;
497:            }
498:
499:            /**
500:             * returns a peer instance associated with this om.  Since Peer classes
501:             * are not to have any instance attributes, this method returns the
502:             * same instance for all member of this class. The method could therefore
503:             * be static, but this would prevent one from overriding the behavior.
504:             */
505:            public IssueVotePeer getPeer() {
506:                return peer;
507:            }
508:
509:            public String toString() {
510:                StringBuffer str = new StringBuffer();
511:                str.append("IssueVote:\n");
512:                str.append("IssueId = ").append(getIssueId()).append("\n");
513:                str.append("UserId = ").append(getUserId()).append("\n");
514:                str.append("Votes = ").append(getVotes()).append("\n");
515:                return (str.toString());
516:            }
517:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.