Source Code Cross Referenced for EJBQLParseTree.java in  » Database-ORM » toplink » oracle » toplink » essentials » internal » parsing » 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 » Database ORM » toplink » oracle.toplink.essentials.internal.parsing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         * 
004:         * // Copyright (c) 1998, 2007, Oracle. All rights reserved.
005:         * 
006:         *
007:         * The contents of this file are subject to the terms of either the GNU
008:         * General Public License Version 2 only ("GPL") or the Common Development
009:         * and Distribution License("CDDL") (collectively, the "License").  You
010:         * may not use this file except in compliance with the License. You can obtain
011:         * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
012:         * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
013:         * language governing permissions and limitations under the License.
014:         * 
015:         * When distributing the software, include this License Header Notice in each
016:         * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
017:         * Sun designates this particular file as subject to the "Classpath" exception
018:         * as provided by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code.  If applicable, add the following below the License
020:         * Header, with the fields enclosed by brackets [] replaced by your own
021:         * identifying information: "Portions Copyrighted [year]
022:         * [name of copyright owner]"
023:         * 
024:         * Contributor(s):
025:         * 
026:         * If you wish your version of this file to be governed by only the CDDL or
027:         * only the GPL Version 2, indicate your decision by adding "[Contributor]
028:         * elects to include this software in this distribution under the [CDDL or GPL
029:         * Version 2] license."  If you don't indicate a single choice of license, a
030:         * recipient has the option to distribute your version of this file under
031:         * either the CDDL, the GPL Version 2 or to extend the choice of license to
032:         * its licensees as provided above.  However, if you add GPL Version 2 code
033:         * and therefore, elected the GPL Version 2 license, then the option applies
034:         * only if the new code is made subject to such option by the copyright
035:         * holder.
036:         */
037:        package oracle.toplink.essentials.internal.parsing;
038:
039:        import oracle.toplink.essentials.queryframework.*;
040:        import oracle.toplink.essentials.internal.sessions.AbstractSession;
041:
042:        /**
043:         * INTERNAL
044:         * <p><b>Purpose</b>: This represents an EJBQL parse tre
045:         * <p><b>Responsibilities</b>:<ul>
046:         * <li> Maintain the context for the expression generation
047:         * <li> Build an initial expression
048:         * <li> Return a reference class for the expression
049:         * <li> Maintain the root node for the query
050:         * </ul>
051:         *    @author Jon Driscoll and Joel Lucuik
052:         *    @since TopLink 4.0
053:         */
054:        public class EJBQLParseTree extends ParseTree {
055:
056:            /**
057:             * EJBQLParseTree constructor comment.
058:             */
059:            public EJBQLParseTree() {
060:                super ();
061:            }
062:
063:            /**
064:             * INTERNAL
065:             * Build the context to be used when generating the expression from the parse tree
066:             */
067:            public GenerationContext buildContext(ReadQuery readQuery,
068:                    AbstractSession session) {
069:                GenerationContext contextForGeneration = super .buildContext(
070:                        readQuery, session);
071:
072:                contextForGeneration.setBaseQueryClass(readQuery
073:                        .getReferenceClass());
074:                return contextForGeneration;
075:            }
076:
077:            /**
078:             * INTERNAL
079:             * Build the context to be used when generating the expression from the
080:             * subquery parse tree.
081:             */
082:            private GenerationContext buildSubqueryContext(ReadQuery readQuery,
083:                    GenerationContext outer) {
084:                GenerationContext context = new SelectGenerationContext(outer,
085:                        this );
086:                context.setBaseQueryClass(readQuery.getReferenceClass());
087:                return context;
088:            }
089:
090:            /**
091:             * Add all of the relevant query settings from an EJBQLParseTree to the given
092:             * database query.
093:             * @param query The query to populate
094:             * @param outer the GenerationContext of the outer EJBQL query.
095:             * @return the GenerationContext for the subquery
096:             */
097:            public GenerationContext populateSubquery(
098:                    ObjectLevelReadQuery readQuery, GenerationContext outer) {
099:                GenerationContext innerContext = buildSubqueryContext(
100:                        readQuery, outer);
101:                populateReadQueryInternal(readQuery, innerContext);
102:                return innerContext;
103:            }
104:
105:            /**
106:             * Add all of the relevant query settings from an EJBQLParseTree to the given
107:             * database query.
108:             * @param query The query to populate
109:             * @param session The sessionto use to information such as descriptors.
110:             */
111:            public void populateQuery(DatabaseQuery query,
112:                    AbstractSession session) {
113:                if (query.isObjectLevelReadQuery()) {
114:                    ObjectLevelReadQuery objectQuery = (ObjectLevelReadQuery) query;
115:                    GenerationContext generationContext = buildContext(
116:                            objectQuery, session);
117:                    populateReadQueryInternal(objectQuery, generationContext);
118:                } else if (query.isUpdateAllQuery()) {
119:                    UpdateAllQuery updateQuery = (UpdateAllQuery) query;
120:                    GenerationContext generationContext = buildContext(
121:                            updateQuery, session);
122:                    populateModifyQueryInternal(updateQuery, generationContext);
123:                    addUpdatesToQuery(updateQuery, generationContext);
124:                } else if (query.isDeleteAllQuery()) {
125:                    DeleteAllQuery deleteQuery = (DeleteAllQuery) query;
126:                    GenerationContext generationContext = buildContext(
127:                            deleteQuery, session);
128:                    populateModifyQueryInternal(deleteQuery, generationContext);
129:                }
130:            }
131:
132:            private void populateReadQueryInternal(
133:                    ObjectLevelReadQuery objectQuery,
134:                    GenerationContext generationContext) {
135:                // Get the reference class if it does not exist.  This is done
136:                // for dynamic queries in EJBQL 3.0
137:                if (objectQuery.getReferenceClass() == null) {
138:                    // Adjust the reference class if necessary
139:                    adjustReferenceClassForQuery(objectQuery, generationContext);
140:                }
141:
142:                // Initialize the base expression in the generation context
143:                initBaseExpression(objectQuery, generationContext);
144:
145:                // Validate parse tree
146:                validate(generationContext.getSession(), getClassLoader());
147:
148:                // Apply the query node to the query (this will be a SelectNode for a read query)
149:                applyQueryNodeToQuery(objectQuery, generationContext);
150:
151:                // Verify the SELECT is valid (valid alias, etc)
152:                verifySelect(objectQuery, generationContext);
153:
154:                // This is what it's all about...
155:                setSelectionCriteriaForQuery(objectQuery, generationContext);
156:
157:                // Add any ordering
158:                addOrderingToQuery(objectQuery, generationContext);
159:
160:                // Add any grouping
161:                addGroupingToQuery(objectQuery, generationContext);
162:
163:                // Add having
164:                addHavingToQuery(objectQuery, generationContext);
165:
166:                // Add non fetch joined variables
167:                addNonFetchJoinAttributes(objectQuery, generationContext);
168:            }
169:
170:            private void populateModifyQueryInternal(ModifyAllQuery query,
171:                    GenerationContext generationContext) {
172:                if (query.getReferenceClass() == null) {
173:                    // Adjust the reference class if necessary
174:                    adjustReferenceClassForQuery(query, generationContext);
175:                }
176:                query.setSession(generationContext.getSession());
177:
178:                // Initialize the base expression in the generation context
179:                initBaseExpression(query, generationContext);
180:
181:                // Validate parse tree
182:                validate(generationContext.getSession(), getClassLoader());
183:
184:                // Apply the query node to the query
185:                applyQueryNodeToQuery(query, generationContext);
186:
187:                setSelectionCriteriaForQuery(query, generationContext);
188:            }
189:
190:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.