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


001:        /*
002:
003:           Derby - Class org.apache.derby.impl.sql.catalog.SYSCONGLOMERATESRowFactory
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.catalog;
023:
024:        import org.apache.derby.iapi.services.sanity.SanityManager;
025:
026:        import org.apache.derby.iapi.types.TypeId;
027:        import org.apache.derby.iapi.sql.dictionary.SystemColumn;
028:        import org.apache.derby.catalog.TypeDescriptor;
029:
030:        import org.apache.derby.iapi.types.DataValueDescriptor;
031:
032:        import org.apache.derby.iapi.types.DataValueFactory;
033:
034:        import org.apache.derby.iapi.sql.dictionary.CatalogRowFactory;
035:        import org.apache.derby.iapi.sql.dictionary.ConglomerateDescriptor;
036:        import org.apache.derby.iapi.sql.dictionary.DataDescriptorGenerator;
037:        import org.apache.derby.iapi.sql.dictionary.DataDictionary;
038:        import org.apache.derby.iapi.sql.dictionary.IndexRowGenerator;
039:        import org.apache.derby.iapi.sql.dictionary.SchemaDescriptor;
040:        import org.apache.derby.iapi.sql.dictionary.TupleDescriptor;
041:
042:        import org.apache.derby.iapi.types.RowLocation;
043:
044:        import org.apache.derby.iapi.sql.execute.ExecIndexRow;
045:        import org.apache.derby.iapi.sql.execute.ExecRow;
046:        import org.apache.derby.iapi.sql.execute.ExecutionContext;
047:        import org.apache.derby.iapi.sql.execute.ExecutionFactory;
048:
049:        import org.apache.derby.iapi.error.StandardException;
050:
051:        import org.apache.derby.iapi.services.uuid.UUIDFactory;
052:        import org.apache.derby.catalog.UUID;
053:
054:        import org.apache.derby.catalog.IndexDescriptor;
055:
056:        import java.util.Properties;
057:
058:        /**
059:         * Factory for creating a SYSCONGLOMERATES row.
060:         *
061:         * @author ames
062:         */
063:
064:        public class SYSCONGLOMERATESRowFactory extends CatalogRowFactory {
065:            private static final String TABLENAME_STRING = "SYSCONGLOMERATES";
066:
067:            protected static final int SYSCONGLOMERATES_COLUMN_COUNT = 8;
068:            protected static final int SYSCONGLOMERATES_SCHEMAID = 1;
069:            protected static final int SYSCONGLOMERATES_TABLEID = 2;
070:            protected static final int SYSCONGLOMERATES_CONGLOMERATENUMBER = 3;
071:            protected static final int SYSCONGLOMERATES_CONGLOMERATENAME = 4;
072:            protected static final int SYSCONGLOMERATES_ISINDEX = 5;
073:            protected static final int SYSCONGLOMERATES_DESCRIPTOR = 6;
074:            protected static final int SYSCONGLOMERATES_ISCONSTRAINT = 7;
075:            protected static final int SYSCONGLOMERATES_CONGLOMERATEID = 8;
076:
077:            protected static final int SYSCONGLOMERATES_INDEX1_ID = 0;
078:            protected static final int SYSCONGLOMERATES_INDEX2_ID = 1;
079:            protected static final int SYSCONGLOMERATES_INDEX3_ID = 2;
080:
081:            private static final boolean[] uniqueness = { false, true, false };
082:
083:            private static final int[][] indexColumnPositions = {
084:                    { SYSCONGLOMERATES_CONGLOMERATEID },
085:                    { SYSCONGLOMERATES_CONGLOMERATENAME,
086:                            SYSCONGLOMERATES_SCHEMAID },
087:                    { SYSCONGLOMERATES_TABLEID } };
088:
089:            private static final String[] uuids = {
090:                    "80000010-00d0-fd77-3ed8-000a0a0b1900" // catalog UUID
091:                    , "80000027-00d0-fd77-3ed8-000a0a0b1900" // heap UUID
092:                    , "80000012-00d0-fd77-3ed8-000a0a0b1900" // SYSCONGLOMERATES_INDEX1
093:                    , "80000014-00d0-fd77-3ed8-000a0a0b1900" // SYSCONGLOMERATES_INDEX2
094:                    , "80000016-00d0-fd77-3ed8-000a0a0b1900" // SYSCONGLOMERATES_INDEX3
095:            };
096:
097:            SYSCONGLOMERATESRowFactory(UUIDFactory uuidf, ExecutionFactory ef,
098:                    DataValueFactory dvf, boolean convertIdToLower) {
099:                super (uuidf, ef, dvf, convertIdToLower);
100:                initInfo(SYSCONGLOMERATES_COLUMN_COUNT, TABLENAME_STRING,
101:                        indexColumnPositions, uniqueness, uuids);
102:            }
103:
104:            /**
105:             * Make a SYSCONGLOMERATES row
106:             *
107:             * @return	Row suitable for inserting into SYSCONGLOMERATES.
108:             *
109:             * @exception   StandardException thrown on failure
110:             */
111:            public ExecRow makeRow(TupleDescriptor td, TupleDescriptor parent)
112:                    throws StandardException {
113:                ExecRow row;
114:                DataValueDescriptor col;
115:                String tabID = null;
116:                Long conglomNumber = null;
117:                String conglomName = null;
118:                Boolean supportsIndex = null;
119:                IndexRowGenerator indexRowGenerator = null;
120:                Boolean supportsConstraint = null;
121:                String conglomUUIDString = null;
122:                String schemaID = null;
123:                ConglomerateDescriptor conglomerate = (ConglomerateDescriptor) td;
124:
125:                /* Insert info into sysconglomerates */
126:
127:                if (td != null) {
128:                    /* Sometimes the SchemaDescriptor is non-null and sometimes it
129:                     * is null.  (We can't just rely on getting the schema id from 
130:                     * the ConglomerateDescriptor because it can be null when
131:                     * we are creating a new conglomerate.
132:                     */
133:                    if (parent != null) {
134:                        SchemaDescriptor sd = (SchemaDescriptor) parent;
135:                        schemaID = sd.getUUID().toString();
136:                    } else {
137:                        schemaID = conglomerate.getSchemaID().toString();
138:                    }
139:                    tabID = conglomerate.getTableID().toString();
140:                    conglomNumber = new Long(conglomerate
141:                            .getConglomerateNumber());
142:                    conglomName = conglomerate.getConglomerateName();
143:                    conglomUUIDString = conglomerate.getUUID().toString();
144:
145:                    supportsIndex = new Boolean(conglomerate.isIndex());
146:                    indexRowGenerator = conglomerate.getIndexDescriptor();
147:                    supportsConstraint = new Boolean(conglomerate
148:                            .isConstraint());
149:                }
150:
151:                /* RESOLVE - It would be nice to require less knowledge about sysconglomerates
152:                 * and have this be more table driven.
153:                 */
154:
155:                /* Build the row to insert */
156:                row = getExecutionFactory().getValueRow(
157:                        SYSCONGLOMERATES_COLUMN_COUNT);
158:
159:                /* 1st column is SCHEMAID (UUID - char(36)) */
160:                row.setColumn(1, dvf.getCharDataValue(schemaID));
161:
162:                /* 2nd column is TABLEID (UUID - char(36)) */
163:                row.setColumn(2, dvf.getCharDataValue(tabID));
164:
165:                /* 3rd column is CONGLOMERATENUMBER (long) */
166:                row.setColumn(3, dvf.getDataValue(conglomNumber));
167:
168:                /* 4th column is CONGLOMERATENAME (varchar(128)) 
169:                 ** If null, use the tableid so we always
170:                 ** have a unique column
171:                 */
172:                row.setColumn(4, (conglomName == null) ? dvf
173:                        .getVarcharDataValue(tabID) : dvf
174:                        .getVarcharDataValue(conglomName));
175:
176:                /* 5th  column is ISINDEX (boolean) */
177:                row.setColumn(5, dvf.getDataValue(supportsIndex));
178:
179:                /* 6th column is DESCRIPTOR
180:                 *  (user type org.apache.derby.catalog.IndexDescriptor)
181:                 */
182:                row
183:                        .setColumn(
184:                                6,
185:                                dvf
186:                                        .getDataValue((indexRowGenerator == null ? (IndexDescriptor) null
187:                                                : indexRowGenerator
188:                                                        .getIndexDescriptor())));
189:
190:                /* 7th column is ISCONSTRAINT (boolean) */
191:                row.setColumn(7, dvf.getDataValue(supportsConstraint));
192:
193:                /* 8th column is CONGLOMERATEID (UUID - char(36)) */
194:                row.setColumn(8, dvf.getCharDataValue(conglomUUIDString));
195:
196:                return row;
197:            }
198:
199:            public ExecRow makeEmptyRow() throws StandardException {
200:                return makeRow(null, null);
201:            }
202:
203:            /**
204:             * Get the Properties associated with creating the heap.
205:             *
206:             * @return The Properties associated with creating the heap.
207:             */
208:            public Properties getCreateHeapProperties() {
209:                Properties properties = new Properties();
210:                // keep page size at 4K since its a big table
211:                properties.put("derby.storage.pageSize", "4096");
212:                // default properties for system tables:
213:                properties.put("derby.storage.pageReservedSpace", "0");
214:                properties.put("derby.storage.minimumRecordSize", "1");
215:                return properties;
216:            }
217:
218:            /**
219:             * Get the Properties associated with creating the specified index.
220:             *
221:             * @param indexNumber	The specified index number.
222:             *
223:             * @return The Properties associated with creating the specified index.
224:             */
225:            public Properties getCreateIndexProperties(int indexNumber) {
226:                Properties properties = new Properties();
227:                // keep page size for all indexes at 4K since its a big table
228:                properties.put("derby.storage.pageSize", "4096");
229:                return properties;
230:            }
231:
232:            ///////////////////////////////////////////////////////////////////////////
233:            //
234:            //	ABSTRACT METHODS TO BE IMPLEMENTED BY CHILDREN OF CatalogRowFactory
235:            //
236:            ///////////////////////////////////////////////////////////////////////////
237:
238:            /**
239:             *
240:             * @param row a SYSCOLUMNS row
241:             * @param parentTupleDescriptor	Null for this kind of descriptor.
242:             * @param dd dataDictionary
243:             *
244:             * @return	a conglomerate descriptor equivalent to a SYSCONGOMERATES row
245:             *
246:             * @exception   StandardException thrown on failure
247:             */
248:
249:            public TupleDescriptor buildDescriptor(ExecRow row,
250:                    TupleDescriptor parentTupleDescriptor, DataDictionary dd)
251:                    throws StandardException {
252:                if (SanityManager.DEBUG)
253:                    SanityManager
254:                            .ASSERT(
255:                                    row.nColumns() == SYSCONGLOMERATES_COLUMN_COUNT,
256:                                    "Wrong number of columns for a SYSCONGLOMERATES row");
257:
258:                DataDescriptorGenerator ddg = dd.getDataDescriptorGenerator();
259:                long conglomerateNumber;
260:                String name;
261:                boolean isConstraint;
262:                boolean isIndex;
263:                IndexRowGenerator indexRowGenerator;
264:                DataValueDescriptor col;
265:                ConglomerateDescriptor conglomerateDesc;
266:                String conglomUUIDString;
267:                UUID conglomUUID;
268:                String schemaUUIDString;
269:                UUID schemaUUID;
270:                String tableUUIDString;
271:                UUID tableUUID;
272:
273:                /* 1st column is SCHEMAID (UUID - char(36)) */
274:                col = row.getColumn(1);
275:                schemaUUIDString = col.getString();
276:                schemaUUID = getUUIDFactory().recreateUUID(schemaUUIDString);
277:
278:                /* 2nd column is TABLEID (UUID - char(36)) */
279:                col = row.getColumn(2);
280:                tableUUIDString = col.getString();
281:                tableUUID = getUUIDFactory().recreateUUID(tableUUIDString);
282:
283:                /* 3nd column is CONGLOMERATENUMBER (long) */
284:                col = row.getColumn(3);
285:                conglomerateNumber = col.getLong();
286:
287:                /* 4rd column is CONGLOMERATENAME (varchar(128)) */
288:                col = row.getColumn(4);
289:                name = col.getString();
290:
291:                /* 5th column is ISINDEX (boolean) */
292:                col = row.getColumn(5);
293:                isIndex = col.getBoolean();
294:
295:                /* 6th column is DESCRIPTOR */
296:                col = row.getColumn(6);
297:                indexRowGenerator = new IndexRowGenerator((IndexDescriptor) col
298:                        .getObject());
299:
300:                /* 7th column is ISCONSTRAINT (boolean) */
301:                col = row.getColumn(7);
302:                isConstraint = col.getBoolean();
303:
304:                /* 8th column is CONGLOMERATEID (UUID - char(36)) */
305:                col = row.getColumn(8);
306:                conglomUUIDString = col.getString();
307:                conglomUUID = getUUIDFactory().recreateUUID(conglomUUIDString);
308:
309:                /* now build and return the descriptor */
310:                conglomerateDesc = ddg.newConglomerateDescriptor(
311:                        conglomerateNumber, name, isIndex, indexRowGenerator,
312:                        isConstraint, conglomUUID, tableUUID, schemaUUID);
313:                return conglomerateDesc;
314:            }
315:
316:            /**
317:             * Get the conglomerate's UUID of the row.
318:             * 
319:             * @param row	The row from sysconglomerates
320:             *
321:             * @return UUID	The conglomerates UUID
322:             *
323:             * @exception   StandardException thrown on failure
324:             */
325:            protected UUID getConglomerateUUID(ExecRow row)
326:                    throws StandardException {
327:                DataValueDescriptor col;
328:                String conglomerateUUIDString;
329:
330:                /* 8th column is CONGLOMERATEID (UUID - char(36)) */
331:                col = row.getColumn(SYSCONGLOMERATES_CONGLOMERATEID);
332:                conglomerateUUIDString = col.getString();
333:                return getUUIDFactory().recreateUUID(conglomerateUUIDString);
334:            }
335:
336:            /**
337:             * Get the table's UUID from the row.
338:             * 
339:             * @param row	The row from sysconglomerates
340:             *
341:             * @return UUID	The table's UUID
342:             *
343:             * @exception   StandardException thrown on failure
344:             */
345:            protected UUID getTableUUID(ExecRow row) throws StandardException {
346:                DataValueDescriptor col;
347:                String tableUUIDString;
348:
349:                /* 2nd column is TABLEID (UUID - char(36)) */
350:                col = row.getColumn(SYSCONGLOMERATES_TABLEID);
351:                tableUUIDString = col.getString();
352:                return getUUIDFactory().recreateUUID(tableUUIDString);
353:            }
354:
355:            /**
356:             * Get the schema's UUID from the row.
357:             * 
358:             * @param row	The row from sysconglomerates
359:             *
360:             * @return UUID	The schema's UUID
361:             *
362:             * @exception   StandardException thrown on failure
363:             */
364:            protected UUID getSchemaUUID(ExecRow row) throws StandardException {
365:                DataValueDescriptor col;
366:                String schemaUUIDString;
367:
368:                /* 1st column is SCHEMAID (UUID - char(36)) */
369:                col = row.getColumn(SYSCONGLOMERATES_SCHEMAID);
370:                schemaUUIDString = col.getString();
371:                return getUUIDFactory().recreateUUID(schemaUUIDString);
372:            }
373:
374:            /**
375:             * Get the conglomerate's name of the row.
376:             * 
377:             * @param row	The row from sysconglomerates
378:             *
379:             * @return String	The conglomerates name
380:             *
381:             * @exception   StandardException thrown on failure
382:             */
383:            protected String getConglomerateName(ExecRow row)
384:                    throws StandardException {
385:                DataValueDescriptor col;
386:
387:                /* 4th column is CONGLOMERATENAME (varchar(128)) */
388:                col = row.getColumn(SYSCONGLOMERATES_CONGLOMERATENAME);
389:                return col.getString();
390:            }
391:
392:            /**
393:             * Builds a list of columns suitable for creating this Catalog.
394:             *
395:             *
396:             * @return array of SystemColumn suitable for making this catalog.
397:             */
398:            public SystemColumn[] buildColumnList() {
399:                int index = 0;
400:                SystemColumn[] columnList = new SystemColumn[SYSCONGLOMERATES_COLUMN_COUNT];
401:
402:                // describe columns
403:
404:                columnList[index++] = new SystemColumnImpl(
405:                        convertIdCase("SCHEMAID"), // column name
406:                        SYSCONGLOMERATES_SCHEMAID, // column number
407:                        0, // precision
408:                        0, // scale
409:                        false, // nullability
410:                        "CHAR", // dataType
411:                        true, // built-in type
412:                        36 // maxLength
413:                );
414:
415:                columnList[index++] = new SystemColumnImpl(
416:                        convertIdCase("TABLEID"), // column name
417:                        SYSCONGLOMERATES_TABLEID, // column number
418:                        0, // precision
419:                        0, // scale
420:                        false, // nullability
421:                        "CHAR", // dataType
422:                        true, // built-in type
423:                        36 // maxLength
424:                );
425:                columnList[index++] = new SystemColumnImpl(
426:                        convertIdCase("CONGLOMERATENUMBER"), // column name
427:                        SYSCONGLOMERATES_CONGLOMERATENUMBER, // column number
428:                        0, // precision
429:                        0, // scale
430:                        false, // nullability
431:                        "BIGINT", // dataType
432:                        true, // built-in type
433:                        TypeId.LONGINT_MAXWIDTH // maxLength
434:                );
435:
436:                columnList[index++] = new SystemColumnImpl( // SQL IDENTIFIER
437:                        convertIdCase("CONGLOMERATENAME"), // column name
438:                        SYSCONGLOMERATES_CONGLOMERATENAME, true // nullability
439:                );
440:
441:                columnList[index++] = new SystemColumnImpl(
442:                        convertIdCase("ISINDEX"), // column name
443:                        SYSCONGLOMERATES_ISINDEX, // column number
444:                        0, // precision
445:                        0, // scale
446:                        false, // nullability
447:                        "BOOLEAN", // dataType
448:                        true, // built-in type
449:                        1 // maxLength
450:                );
451:
452:                columnList[index++] = new SystemColumnImpl(
453:                        convertIdCase("DESCRIPTOR"), // column name
454:                        SYSCONGLOMERATES_DESCRIPTOR, 0, // precision
455:                        0, // scale
456:                        true, // nullability
457:                        "org.apache.derby.catalog.IndexDescriptor", // datatype
458:                        false, // built-in type
459:                        TypeDescriptor.MAXIMUM_WIDTH_UNKNOWN
460:                // maxLength
461:                );
462:
463:                columnList[index++] = new SystemColumnImpl(
464:                        convertIdCase("ISCONSTRAINT"), // column name
465:                        SYSCONGLOMERATES_ISCONSTRAINT, 0, // precision
466:                        0, // scale
467:                        true, // nullability
468:                        "BOOLEAN", // datatype
469:                        true, // built-in type
470:                        1 // maxLength
471:                );
472:
473:                columnList[index++] = new SystemColumnImpl(
474:                        convertIdCase("CONGLOMERATEID"), // column name
475:                        SYSCONGLOMERATES_CONGLOMERATEID, 0, // precision
476:                        0, // scale
477:                        false, // nullability
478:                        "CHAR", // datatype
479:                        true, // built-in type
480:                        36 // maxLength
481:                );
482:
483:                return columnList;
484:
485:            }
486:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.