Source Code Cross Referenced for TurbineMapBuilder.java in  » Web-Framework » TURBINE » org » apache » turbine » util » db » map » 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 » Web Framework » TURBINE » org.apache.turbine.util.db.map 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.apache.turbine.util.db.map;
002:
003:        /*
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with 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,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:
022:        import java.util.Date;
023:        import java.util.Hashtable;
024:
025:        import org.apache.torque.Torque;
026:        import org.apache.torque.map.DatabaseMap;
027:        import org.apache.torque.map.MapBuilder;
028:        import org.apache.torque.map.TableMap;
029:
030:        /**
031:         * Default Builder for Database/Table/Column Maps within the Turbine
032:         * System.  If you decide to use your own table schema, then you
033:         * probably will want to implement this class on your own.  It is then
034:         * defined within the TurbineResources.properties file.
035:         *
036:         * @author <a href="mailto:john.mcnally@clearink.com">John D. McNally</a>
037:         * @author <a href="mailto:dlr@finemaltcoding.com">Daniel Rall</a>
038:         * @version $Id: TurbineMapBuilder.java 534527 2007-05-02 16:10:59Z tv $
039:         */
040:        public class TurbineMapBuilder implements  MapBuilder {
041:            /**
042:             * Get the User table.
043:             *
044:             * @return A String.
045:             */
046:            public String getTableUser() {
047:                return "TURBINE_USER";
048:            }
049:
050:            /**
051:             * Get the UserRole table.
052:             *
053:             * @return A String.
054:             */
055:            public String getTableRole() {
056:                return "TURBINE_ROLE";
057:            }
058:
059:            /**
060:             * Get the Permission table.
061:             *
062:             * @return A String.
063:             */
064:            public String getTablePermission() {
065:                return "TURBINE_PERMISSION";
066:            }
067:
068:            /**
069:             * Get the UserGroupRole table.
070:             *
071:             * @return A String.
072:             */
073:            public String getTableUserGroupRole() {
074:                return "TURBINE_USER_GROUP_ROLE";
075:            }
076:
077:            /**
078:             * Get the RolePermission table.
079:             *
080:             * @return A String.
081:             */
082:            public String getTableRolePermission() {
083:                return "TURBINE_ROLE_PERMISSION";
084:            }
085:
086:            /**
087:             * Get the Group table.
088:             *
089:             * @return A String.
090:             */
091:            public String getTableGroup() {
092:                return "TURBINE_GROUP";
093:            }
094:
095:            /**
096:             * Internal Unique key to the visitor table.  Override this if
097:             * using your custom table.
098:             *
099:             * @return A String.
100:             */
101:            public String getUserId() {
102:                return "USER_ID";
103:            }
104:
105:            /**
106:             * Fully qualified Unique key to the visitor table.  Shouldn't
107:             * need to override this as it uses the above methods.
108:             *
109:             * @return A String.
110:             */
111:            public String getUser_UserId() {
112:                return getTableUser() + '.' + getUserId();
113:            }
114:
115:            /**
116:             * Column used to record the last login time for visitor.
117:             * Override this if using your custom table.
118:             *
119:             * @return A String.
120:             */
121:            public String getLastLogin() {
122:                return "LAST_LOGIN";
123:            }
124:
125:            /**
126:             * Fully qualified column used to record the last login time for
127:             * visitor.  Shouldn't need to override this as it uses the above
128:             * methods.
129:             *
130:             * @return A String.
131:             */
132:            public String getUser_LastLogin() {
133:                return getTableUser() + '.' + getLastLogin();
134:            }
135:
136:            /**
137:             * Column used to record the users username.  Override this if
138:             * using your custom table.
139:             *
140:             * @return A String.
141:             */
142:            public String getUsername() {
143:                return "LOGIN_NAME";
144:            }
145:
146:            /**
147:             * Fully qualified column used to record the visitors username.
148:             * Shouldn't need to override this as it uses the above methods.
149:             *
150:             * @return A String.
151:             */
152:            public String getUser_Username() {
153:                return getTableUser() + '.' + getUsername();
154:            }
155:
156:            /**
157:             * Column used to record the users password.  Override this if
158:             * using your custom table.
159:             *
160:             * @return A String.
161:             */
162:            public String getPassword() {
163:                return "PASSWORD_VALUE";
164:            }
165:
166:            /**
167:             * Fully qualified column used to record the visitors password.
168:             * Shouldn't need to override this as it uses the above methods.
169:             *
170:             * @return A String.
171:             */
172:            public String getUser_Password() {
173:                return getTableUser() + '.' + getPassword();
174:            }
175:
176:            /**
177:             * Column used to record general visitor data from a hashmap.
178:             * Override this if using your custom table.
179:             *
180:             * @return A String.
181:             */
182:            public String getObjectData() {
183:                return "OBJECTDATA";
184:            }
185:
186:            /**
187:             * Fully qualified column used to record general visitor data from
188:             * a hashmap.  Shouldn't need to override this as it uses the
189:             * above methods.
190:             *
191:             * @return A String.
192:             */
193:            public String getUser_ObjectData() {
194:                return getTableUser() + '.' + getObjectData();
195:            }
196:
197:            /**
198:             * Column used to store the user's first name.
199:             * Override this if using your custom table.
200:             *
201:             * @return A String.
202:             */
203:            public String getFirstName() {
204:                return "FIRST_NAME";
205:            }
206:
207:            /**
208:             * Fully qualified column used to store the user's last name.
209:             * Shouldn't need to override this as it uses the above methods.
210:             *
211:             * @return A String.
212:             */
213:            public String getUser_FirstName() {
214:                return getTableUser() + '.' + getFirstName();
215:            }
216:
217:            /**
218:             * Column used to store the user's last name.
219:             * Override this if using your custom table.
220:             *
221:             * @return A String.
222:             */
223:            public String getLastName() {
224:                return "LAST_NAME";
225:            }
226:
227:            /**
228:             * Fully qualified column used to store the user's last name.
229:             * Shouldn't need to override this as it uses the above methods.
230:             *
231:             * @return A String.
232:             */
233:            public String getUser_LastName() {
234:                return getTableUser() + '.' + getLastName();
235:            }
236:
237:            /**
238:             * Column used to store the user's data modification time.
239:             * Override this if using your custom table.
240:             *
241:             * @return A String.
242:             */
243:            public String getModified() {
244:                return "MODIFIED";
245:            }
246:
247:            /**
248:             * Fully qualified column used to store the user's data modification time.
249:             * Shouldn't need to override this as it uses the above methods.
250:             *
251:             * @return A String.
252:             */
253:            public String getUser_Modified() {
254:                return getTableUser() + '.' + getModified();
255:            }
256:
257:            /**
258:             * Column used to store the user's record cration time.
259:             * Override this if using your custom table.
260:             *
261:             * @return A String.
262:             */
263:            public String getCreated() {
264:                return "CREATED";
265:            }
266:
267:            /**
268:             * Fully qualified column used to store the user's record cration time.
269:             * Shouldn't need to override this as it uses the above methods.
270:             *
271:             * @return A String.
272:             */
273:            public String getUser_Created() {
274:                return getTableUser() + '.' + getCreated();
275:            }
276:
277:            /**
278:             * Column used to store the user's email.
279:             * Override this if using your custom table.
280:             *
281:             * @return A String.
282:             */
283:            public String getEmail() {
284:                return "EMAIL";
285:            }
286:
287:            /**
288:             * Fully qualified column used to store the user's email.
289:             * Shouldn't need to override this as it uses the above methods.
290:             *
291:             * @return A String.
292:             */
293:            public String getUser_Email() {
294:                return getTableUser() + '.' + getEmail();
295:            }
296:
297:            /**
298:             * Column used to store the user's confirmation flag.
299:             * Override this if using your custom table.
300:             *
301:             * @return A String.
302:             */
303:            public String getConfirmValue() {
304:                return "CONFIRM_VALUE";
305:            }
306:
307:            /**
308:             * Fully qualified column used to store the user's confirmation flag.
309:             * Shouldn't need to override this as it uses the above methods.
310:             *
311:             * @return A String.
312:             */
313:            public String getUser_ConfirmValue() {
314:                return getTableUser() + '.' + getConfirmValue();
315:            }
316:
317:            /**
318:             * Column used for the unique id to a Role.  Override this if
319:             * using your custom table
320:             *
321:             * @return A String.
322:             */
323:            public String getRoleId() {
324:                return "ROLE_ID";
325:            }
326:
327:            /**
328:             * Fully qualified column name for Role unique key.  Shouldn't
329:             * need to override this as it uses the above methods.
330:             *
331:             * @return A String.
332:             */
333:            public String getRole_RoleId() {
334:                return getTableRole() + '.' + getRoleId();
335:            }
336:
337:            /**
338:             * Column used for the name of Role.  Override this if using
339:             * your custom table.
340:             *
341:             * @return A String.
342:             */
343:            public String getRoleName() {
344:                return "ROLE_NAME";
345:            }
346:
347:            /**
348:             * Fully qualified column name for Role name.  Shouldn't need
349:             * to override this as it uses the above methods.
350:             *
351:             * @return A String.
352:             */
353:            public String getRole_Name() {
354:                return getTableRole() + '.' + getRoleName();
355:            }
356:
357:            /**
358:             * Fully qualified column name for ObjectData column.  Shouldn't need
359:             * to override this as it uses the above methods.
360:             *
361:             * @return A String.
362:             */
363:            public String getRole_ObjectData() {
364:                return getTableRole() + '.' + getObjectData();
365:            }
366:
367:            /**
368:             * Column used for the id of the Permission table.  Override this
369:             * if using your custom table.
370:             *
371:             * @return A String.
372:             */
373:            public String getPermissionId() {
374:                return "PERMISSION_ID";
375:            }
376:
377:            /**
378:             * Fully qualified column name for Permission table unique key.
379:             * Shouldn't need to override this as it uses the above methods.
380:             *
381:             * @return A String.
382:             */
383:            public String getPermission_PermissionId() {
384:                return getTablePermission() + '.' + getPermissionId();
385:            }
386:
387:            /**
388:             * Column used for the name of a Permission.  Override this if
389:             * using your custom table.
390:             *
391:             * @return A String.
392:             */
393:            public String getPermissionName() {
394:                return "PERMISSION_NAME";
395:            }
396:
397:            /**
398:             * Fully qualified column name for Permission table name of the
399:             * permission.  Shouldn't need to override this as it uses the
400:             * above methods.
401:             *
402:             * @return A String.
403:             */
404:            public String getPermission_Name() {
405:                return getTablePermission() + '.' + getPermissionName();
406:            }
407:
408:            /**
409:             * Fully qualified column name for ObjectData column.  Shouldn't need
410:             * to override this as it uses the above methods.
411:             *
412:             * @return A String.
413:             */
414:            public String getPermission_ObjectData() {
415:                return getTablePermission() + '.' + getObjectData();
416:            }
417:
418:            /**
419:             * Fully qualified column name for UserGroupRole visitor id.
420:             * Shouldn't need to override this as it uses the above methods.
421:             *
422:             * @return A String.
423:             */
424:            public String getUserGroupRole_UserId() {
425:                return getTableUserGroupRole() + '.' + getUserId();
426:            }
427:
428:            /**
429:             * Fully qualified column name for UserGroupRole group id.  Shouldn't
430:             * need to override this as it uses the above methods.
431:             *
432:             * @return A String.
433:             */
434:            public String getUserGroupRole_GroupId() {
435:                return getTableUserGroupRole() + '.' + getGroupId();
436:            }
437:
438:            /**
439:             * Fully qualified column name for UserGroupRole role id.  Shouldn't
440:             * need to override this as it uses the above methods.
441:             *
442:             * @return A String.
443:             */
444:            public String getUserGroupRole_RoleId() {
445:                return getTableUserGroupRole() + '.' + getRoleId();
446:            }
447:
448:            /**
449:             * Fully qualified column name for RolePermission permission id.
450:             * Shouldn't need to override this as it uses the above methods.
451:             *
452:             * @return A String.
453:             */
454:            public String getRolePermission_PermissionId() {
455:                return getTableRolePermission() + '.' + getPermissionId();
456:            }
457:
458:            /**
459:             * Fully qualified column name for RolePermission role id.
460:             * Shouldn't need to override this as it uses the above methods.
461:             *
462:             * @return A String.
463:             */
464:            public String getRolePermission_RoleId() {
465:                return getTableRolePermission() + '.' + getRoleId();
466:            }
467:
468:            /**
469:             * Column used for the id of the Group table.  Override this
470:             * if using your custom table.
471:             *
472:             * @return A String.
473:             */
474:            public String getGroupId() {
475:                return "GROUP_ID";
476:            }
477:
478:            /**
479:             * Fully qualified column name for Group id.  Shouldn't
480:             * need to override this as it uses the above methods.
481:             *
482:             * @return A String.
483:             */
484:            public String getGroup_GroupId() {
485:                return getTableGroup() + '.' + getGroupId();
486:            }
487:
488:            /**
489:             * Column used for the name of a Group.  Override this if using
490:             * your custom table.
491:             *
492:             * @return A String.
493:             */
494:            public String getGroupName() {
495:                return "GROUP_NAME";
496:            }
497:
498:            /**
499:             * Fully qualified column name for Group name.  Shouldn't
500:             * need to override this as it uses the above methods.
501:             *
502:             * @return A String.
503:             */
504:            public String getGroup_Name() {
505:                return getTableGroup() + '.' + getGroupName();
506:            }
507:
508:            /**
509:             * Fully qualified column name for ObjectData column.  Shouldn't need
510:             * to override this as it uses the above methods.
511:             *
512:             * @return A String.
513:             */
514:            public String getGroup_ObjectData() {
515:                return getTableGroup() + '.' + getObjectData();
516:            }
517:
518:            /**
519:             * GROUP_SEQUENCE.
520:             *
521:             * @return A String.
522:             */
523:            public String getSequenceGroup() {
524:                return "GROUP_SEQUENCE";
525:            }
526:
527:            /**
528:             * PERMISSION_SEQUENCE.
529:             *
530:             * @return A String.
531:             */
532:            public String getSequencePermission() {
533:                return "PERMISSION_SEQUENCE";
534:            }
535:
536:            /**
537:             * ROLE_SEQUENCE.
538:             *
539:             * @return A String.
540:             */
541:            public String getSequenceRole() {
542:                return "ROLE_SEQUENCE";
543:            }
544:
545:            /**
546:             * USER_SEQUENCE.
547:             *
548:             * @return A String.
549:             */
550:            public String getSequenceUser() {
551:                return "USER_SEQUENCE";
552:            }
553:
554:            /** The database map. */
555:            protected DatabaseMap dbMap = null;
556:
557:            /**
558:             * Tells us if this DatabaseMapBuilder is built so that we don't
559:             * have to re-build it every time.
560:             *
561:             * @return True if DatabaseMapBuilder is built.
562:             */
563:            public boolean isBuilt() {
564:                return (dbMap != null);
565:            }
566:
567:            /**
568:             * Gets the databasemap this map builder built.
569:             *
570:             * @return A DatabaseMap.
571:             */
572:            public DatabaseMap getDatabaseMap() {
573:                return this .dbMap;
574:            }
575:
576:            /**
577:             * Build up the databasemapping.  It should probably be modified
578:             * to read a .xml file representation of the database to build
579:             * this.
580:             *
581:             * @exception Exception a generic exception.
582:             */
583:            public void doBuild() throws Exception {
584:                // Reusable TableMap
585:                TableMap tMap;
586:
587:                // Make some objects.
588:                String string = "";
589:                Integer integer = new Integer(0);
590:                java.util.Date date = new Date();
591:
592:                // Get default map.
593:                dbMap = Torque.getDatabaseMap();
594:
595:                // Add tables.
596:                dbMap.addTable(getTableUser());
597:                dbMap.addTable(getTableGroup());
598:                dbMap.addTable(getTableRole());
599:                dbMap.addTable(getTablePermission());
600:                dbMap.addTable(getTableUserGroupRole());
601:                dbMap.addTable(getTableRolePermission());
602:
603:                // Add User columns.
604:                tMap = dbMap.getTable(getTableUser());
605:                tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
606:                tMap.setPrimaryKeyMethodInfo(tMap.getName());
607:                tMap.addPrimaryKey(getUserId(), integer);
608:                tMap.addColumn(getUsername(), string);
609:                tMap.addColumn(getPassword(), string);
610:                tMap.addColumn(getFirstName(), string);
611:                tMap.addColumn(getLastName(), string);
612:                tMap.addColumn(getEmail(), string);
613:                tMap.addColumn(getConfirmValue(), string);
614:                tMap.addColumn(getCreated(), date);
615:                tMap.addColumn(getModified(), date);
616:                tMap.addColumn(getLastLogin(), date);
617:                tMap.addColumn(getObjectData(), new Hashtable(1));
618:
619:                // Add Group columns.
620:                tMap = dbMap.getTable(getTableGroup());
621:                tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
622:                tMap.setPrimaryKeyMethodInfo(tMap.getName());
623:                tMap.addPrimaryKey(getGroupId(), integer);
624:                tMap.addColumn(getGroupName(), string);
625:                tMap.addColumn(getObjectData(), new Hashtable(1));
626:
627:                // Add Role columns.
628:                tMap = dbMap.getTable(getTableRole());
629:                tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
630:                tMap.setPrimaryKeyMethodInfo(tMap.getName());
631:                tMap.addPrimaryKey(getRoleId(), integer);
632:                tMap.addColumn(getRoleName(), string);
633:                tMap.addColumn(getObjectData(), new Hashtable(1));
634:
635:                // Add Permission columns.
636:                tMap = dbMap.getTable(getTablePermission());
637:                tMap.setPrimaryKeyMethod(TableMap.ID_BROKER);
638:                tMap.setPrimaryKeyMethodInfo(tMap.getName());
639:                tMap.addPrimaryKey(getPermissionId(), integer);
640:                tMap.addColumn(getPermissionName(), string);
641:                tMap.addColumn(getObjectData(), new Hashtable(1));
642:
643:                // Add RolePermission columns.
644:                tMap = dbMap.getTable(getTableRolePermission());
645:                tMap.addForeignPrimaryKey(getPermissionId(), integer,
646:                        getTablePermission(), getPermissionId());
647:                tMap.addForeignPrimaryKey(getRoleId(), integer, getTableRole(),
648:                        getRoleId());
649:
650:                // Add UserGroupRole columns.
651:                tMap = dbMap.getTable(getTableUserGroupRole());
652:                tMap.addForeignPrimaryKey(getUserId(), integer, getTableUser(),
653:                        getUserId());
654:                tMap.addForeignPrimaryKey(getGroupId(), integer,
655:                        getTableGroup(), getGroupId());
656:                tMap.addForeignPrimaryKey(getRoleId(), integer, getTableRole(),
657:                        getRoleId());
658:            }
659:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.