Source Code Cross Referenced for CreateViewConstantAction.java in  » Database-DBMS » db-derby-10.2 » org » apache » derby » impl » sql » execute » 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 DBMS » db derby 10.2 » org.apache.derby.impl.sql.execute 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.execute.CreateViewConstantAction
004:
005:           Licensed to the Apache Software Foundation (ASF) under one or more
006:           contributor license agreements.  See the NOTICE file distributed with
007:           this work for additional information regarding copyright ownership.
008:           The ASF licenses this file to you under the Apache License, Version 2.0
009:           (the "License"); you may not use this file except in compliance with
010:           the License.  You may obtain a copy of the License at
011:
012:              http://www.apache.org/licenses/LICENSE-2.0
013:
014:           Unless required by applicable law or agreed to in writing, software
015:           distributed under the License is distributed on an "AS IS" BASIS,
016:           WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017:           See the License for the specific language governing permissions and
018:           limitations under the License.
019:
020:         */
021:
022:        package org.apache.derby.impl.sql.execute;
023:
024:        import org.apache.derby.iapi.sql.execute.ConstantAction;
025:
026:        import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator;
027:        import org.apache.derby.iapi.sql.dictionary.DataDictionary;
028:        import org.apache.derby.iapi.sql.dictionary.ColumnDescriptor;
029:        import org.apache.derby.iapi.sql.dictionary.ColumnDescriptorList;
030:        import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
031:        import org.apache.derby.iapi.sql.dictionary.TableDescriptor;
032:        import org.apache.derby.iapi.sql.dictionary.ViewDescriptor;
033:        import org.apache.derby.iapi.sql.depend.DependencyManager;
034:        import org.apache.derby.iapi.store.access.TransactionController;
035:
036:        import org.apache.derby.iapi.sql.conn.LanguageConnectionContext;
037:
038:        import org.apache.derby.iapi.sql.depend.Provider;
039:        import org.apache.derby.iapi.sql.depend.ProviderInfo;
040:
041:        import org.apache.derby.iapi.reference.SQLState;
042:
043:        import org.apache.derby.iapi.sql.Activation;
044:
045:        import org.apache.derby.iapi.error.StandardException;
046:
047:        import org.apache.derby.iapi.services.sanity.SanityManager;
048:
049:        import org.apache.derby.catalog.UUID;
050:
051:        /**
052:         *	This class  describes actions that are ALWAYS performed for a
053:         *	CREATE VIEW Statement at Execution time.
054:         *
055:         *	@author Jerry Brenner.
056:         */
057:
058:        class CreateViewConstantAction extends DDLConstantAction {
059:
060:            private final String tableName;
061:            private final String schemaName;
062:            private final String viewText;
063:            private final int tableType;
064:            private final int checkOption;
065:            private final ColumnInfo[] columnInfo;
066:            private final ProviderInfo[] providerInfo;
067:            private final UUID compSchemaId;
068:
069:            // CONSTRUCTORS
070:            /**
071:             *	Make the ConstantAction for a CREATE VIEW statement.
072:             *
073:             *  @param schemaName			name for the schema that view lives in.
074:             *  @param tableName	Name of table.
075:             *  @param tableType	Type of table (e.g., BASE).
076:             *	@param viewText		Text of query expression for view definition
077:             *  @param checkOption	Check option type
078:             *  @param columnInfo	Information on all the columns in the table.
079:             *  @param providerInfo Information on all the Providers
080:             *  @param compSchemaId 	Compilation Schema Id
081:             *		 (REMIND tableDescriptor ignored)
082:             */
083:            CreateViewConstantAction(String schemaName, String tableName,
084:                    int tableType, String viewText, int checkOption,
085:                    ColumnInfo[] columnInfo, ProviderInfo[] providerInfo,
086:                    UUID compSchemaId) {
087:                this .schemaName = schemaName;
088:                this .tableName = tableName;
089:                this .tableType = tableType;
090:                this .viewText = viewText;
091:                this .checkOption = checkOption;
092:                this .columnInfo = columnInfo;
093:                this .providerInfo = providerInfo;
094:                this .compSchemaId = compSchemaId;
095:
096:                if (SanityManager.DEBUG) {
097:                    SanityManager.ASSERT(schemaName != null,
098:                            "Schema name is null");
099:                }
100:            }
101:
102:            // OBJECT METHODS
103:
104:            public String toString() {
105:                return constructToString("CREATE VIEW ", tableName);
106:            }
107:
108:            // INTERFACE METHODS
109:
110:            /**
111:             *	This is the guts of the Execution-time logic for CREATE TABLE.
112:             *
113:             *	@see ConstantAction#executeConstantAction
114:             *
115:             * @exception StandardException		Thrown on failure
116:             */
117:            public void executeConstantAction(Activation activation)
118:                    throws StandardException {
119:                TableDescriptor td;
120:                UUID toid;
121:                SchemaDescriptor schemaDescriptor;
122:                ColumnDescriptor columnDescriptor;
123:                ViewDescriptor vd;
124:
125:                LanguageConnectionContext lcc = activation
126:                        .getLanguageConnectionContext();
127:                DataDictionary dd = lcc.getDataDictionary();
128:                DependencyManager dm = dd.getDependencyManager();
129:                TransactionController tc = lcc.getTransactionExecute();
130:
131:                /*
132:                 ** Inform the data dictionary that we are about to write to it.
133:                 ** There are several calls to data dictionary "get" methods here
134:                 ** that might be done in "read" mode in the data dictionary, but
135:                 ** it seemed safer to do this whole operation in "write" mode.
136:                 **
137:                 ** We tell the data dictionary we're done writing at the end of
138:                 ** the transaction.
139:                 */
140:                dd.startWriting(lcc);
141:
142:                SchemaDescriptor sd = DDLConstantAction
143:                        .getSchemaDescriptorForCreate(dd, activation,
144:                                schemaName);
145:
146:                /* Create a new table descriptor.
147:                 * (Pass in row locking, even though meaningless for views.)
148:                 */
149:                DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
150:                td = ddg.newTableDescriptor(tableName, sd, tableType,
151:                        TableDescriptor.ROW_LOCK_GRANULARITY);
152:
153:                dd.addDescriptor(td, sd, DataDictionary.SYSTABLES_CATALOG_NUM,
154:                        false, tc);
155:                toid = td.getUUID();
156:
157:                // for each column, stuff system.column
158:                ColumnDescriptor[] cdlArray = new ColumnDescriptor[columnInfo.length];
159:                int index = 1;
160:                for (int ix = 0; ix < columnInfo.length; ix++) {
161:                    columnDescriptor = new ColumnDescriptor(
162:                            columnInfo[ix].name, index++,
163:                            columnInfo[ix].dataType,
164:                            columnInfo[ix].defaultValue,
165:                            columnInfo[ix].defaultInfo, td, (UUID) null,
166:                            columnInfo[ix].autoincStart,
167:                            columnInfo[ix].autoincInc);
168:                    cdlArray[ix] = columnDescriptor;
169:                }
170:
171:                dd.addDescriptorArray(cdlArray, td,
172:                        DataDictionary.SYSCOLUMNS_CATALOG_NUM, false, tc);
173:
174:                // add columns to the column descriptor list.
175:                ColumnDescriptorList cdl = td.getColumnDescriptorList();
176:                for (int i = 0; i < cdlArray.length; i++)
177:                    cdl.add(cdlArray[i]);
178:
179:                /* Get and add a view descriptor */
180:                vd = ddg.newViewDescriptor(toid, tableName, viewText,
181:                        checkOption, (compSchemaId == null) ? lcc
182:                                .getDefaultSchema().getUUID() : compSchemaId);
183:
184:                for (int ix = 0; ix < providerInfo.length; ix++) {
185:                    /* We should always be able to find the Provider */
186:                    try {
187:                        Provider provider = (Provider) providerInfo[ix]
188:                                .getDependableFinder().getDependable(
189:                                        providerInfo[ix].getObjectId());
190:                        if (provider == null) //see beetle 4444
191:                        {
192:                            throw StandardException.newException(
193:                                    SQLState.LANG_OBJECT_NOT_FOUND, "OBJECT",
194:                                    providerInfo[ix].getObjectId());
195:                        }
196:                        dm.addDependency(vd, provider, lcc.getContextManager());
197:                    } catch (java.sql.SQLException te) {
198:                        // we should allow timeout to be thrown
199:                        throw StandardException.plainWrapException(te);
200:                    }
201:                }
202:                //store view's dependency on various privileges in the dependeny system
203:                storeViewTriggerDependenciesOnPrivileges(activation, vd);
204:
205:                dd.addDescriptor(vd, sd, DataDictionary.SYSVIEWS_CATALOG_NUM,
206:                        true, tc);
207:            }
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.