Source Code Cross Referenced for ROptionOption.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:        // Turbine classes
050:        import org.apache.fulcrum.cache.CachedObject;
051:        import org.apache.fulcrum.cache.GlobalCacheService;
052:        import org.apache.fulcrum.cache.ObjectExpiredException;
053:        import org.apache.torque.TorqueException;
054:        import org.apache.torque.om.Persistent;
055:        import org.apache.torque.util.Criteria;
056:        import org.tigris.scarab.services.ServiceManager;
057:        import org.tigris.scarab.tools.localization.L10NKeySet;
058:        import org.tigris.scarab.util.ScarabException;
059:        import org.tigris.scarab.util.ScarabRuntimeException;
060:
061:        /** 
062:         * This class represents the SCARAB_R_OPTION_OPTION table.
063:         *
064:         * @author <a href="mailto:jon@collab.net">Jon S. Stevens</a>
065:         * @version $Id: ROptionOption.java 10193 2006-06-30 12:49:42Z dabbous $
066:         */
067:        public class ROptionOption extends BaseROptionOption implements 
068:                Persistent {
069:            private int level;
070:
071:            /** the name of this class */
072:            private static final String CLASS_NAME = "ROptionOption";
073:
074:            /**
075:             * Must call getInstance()
076:             */
077:            protected ROptionOption() {
078:            }
079:
080:            /**
081:             * Creates a key for use in caching AttributeOptions
082:             */
083:            static String getCacheKey(Integer option1, Integer option2) {
084:                String keyStringA = option1.toString();
085:                String keyStringB = option2.toString();
086:                return new StringBuffer(CLASS_NAME.length()
087:                        + keyStringA.length() + keyStringB.length()).append(
088:                        CLASS_NAME).append(keyStringA).append(keyStringB)
089:                        .toString();
090:            }
091:
092:            /**
093:             * Gets an instance of a new ROptionOption
094:             */
095:            public static ROptionOption getInstance() {
096:                return new ROptionOption();
097:            }
098:
099:            /**
100:             * Gets an instance of a new ROptionOption
101:             */
102:            public static ROptionOption getInstance(final Integer parent,
103:                    final Integer child) throws TorqueException,
104:                    ScarabException {
105:                final GlobalCacheService tgcs = getGlobalCacheService();
106:
107:                final String key = getCacheKey(parent, child);
108:                ROptionOption option = null;
109:                try {
110:                    option = (ROptionOption) tgcs.getObject(key).getContents();
111:                } catch (ObjectExpiredException oee) {
112:                    try {
113:                        final Criteria crit = new Criteria();
114:                        crit.add(ROptionOptionPeer.OPTION1_ID, parent);
115:                        crit.add(ROptionOptionPeer.OPTION2_ID, child);
116:                        option = (ROptionOption) (ROptionOptionPeer
117:                                .doSelect(crit)).get(0);
118:                    } catch (Exception e) {
119:                        throw new ScarabException(
120:                                L10NKeySet.ExceptionOptionNotFound, parent
121:                                        .toString(), child.toString());
122:                    }
123:                    tgcs.addObject(key, new CachedObject(option));
124:                }
125:                return option;
126:            }
127:
128:            /**
129:             * This will also remove the ROptionOption from the internal cache
130:             * as well as from the database.
131:             */
132:            public static void doRemove(ROptionOption roo)
133:                    throws TorqueException {
134:                // using Criteria because there is a bug in Torque
135:                // where doDelete(roo) doesn't work because it has
136:                // multple primary keys
137:                Criteria crit = new Criteria();
138:                crit.add(ROptionOptionPeer.OPTION1_ID, roo.getOption1Id());
139:                crit.add(ROptionOptionPeer.OPTION2_ID, roo.getOption2Id());
140:
141:                ROptionOptionPeer.doDelete(crit);
142:
143:                GlobalCacheService tgcs = getGlobalCacheService();
144:
145:                String key = getCacheKey(roo.getOption1Id(), roo.getOption2Id());
146:                tgcs.removeObject(key);
147:            }
148:
149:            /**
150:             * This will also remove the ROptionOption from the internal cache
151:             * as well as from the database.
152:             */
153:            public static void doRemove(Integer parent, Integer child)
154:                    throws TorqueException {
155:                ROptionOption roo = getInstance();
156:                roo.setOption1Id(parent);
157:                roo.setOption2Id(child);
158:                ROptionOption.doRemove(roo);
159:            }
160:
161:            /**
162:             * Gets the AttributeOption assigned to the Option1Id
163:             */
164:            public AttributeOption getOption1Option() throws TorqueException {
165:                return AttributeOptionManager.getInstance(getOption1Id());
166:            }
167:
168:            /**
169:             * Gets the AttributeOption assigned to the Option2Id
170:             */
171:            public AttributeOption getOption2Option() throws TorqueException {
172:                return AttributeOptionManager.getInstance(getOption2Id());
173:            }
174:
175:            /**
176:             * Get the level in the option parent-child tree.
177:             * Note: Not currently used.
178:             * @return value of level.
179:             */
180:            public int getLevel() {
181:                return level;
182:            }
183:
184:            /**
185:             * Get the level in the option parent-child tree.
186:             * Note: Not currently used.
187:             * @param v  Value to assign to level.
188:             */
189:            public void setLevel(int v) {
190:                this .level = v;
191:            }
192:
193:            /**
194:             * Will return true if this ROptionOption is the parent
195:             * of the given AttributeOption. In other words, the value of
196:             * this.OPTION2_ID == option.getOptionId()
197:            public boolean isParentOf(AttributeOption option)
198:            {
199:                return option.getOptionId().equals(this.getOption2Id());
200:            }
201:             */
202:
203:            /**
204:             * Will return true if this ROptionOption is the child
205:             * of the given AttributeOption. In other words, the value of
206:             * this.OPTION1_ID == option.getOptionId()
207:            public boolean isChildOf(AttributeOption option)
208:            {
209:                return option.getOptionId().equals(this.getOption1Id());
210:            }
211:             */
212:
213:            /**
214:             * A String representation of this object.
215:             */
216:            public String toString() {
217:                return "Parent: " + getOption1Id() + " Child: "
218:                        + getOption2Id() + " : Order: " + getPreferredOrder();
219:            }
220:
221:            /**
222:             * Gets the <code>GlobalCacheService</code> implementation.
223:             *
224:             * @return the GlobalCacheService implementation.
225:             */
226:            protected static final GlobalCacheService getGlobalCacheService() {
227:                try {
228:                    ServiceManager sm = ServiceManager.getInstance();
229:                    return (GlobalCacheService) sm
230:                            .lookup(GlobalCacheService.class);
231:                } catch (Exception e) {
232:                    throw new ScarabRuntimeException(
233:                            L10NKeySet.ExceptionLookupGlobalCache, e);
234:                }
235:            }
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.