Source Code Cross Referenced for Configuration.java in  » Portal » uPortal_rel-2-6-1-GA » org » jasig » portal » tools » dbloader » 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 » Portal » uPortal_rel 2 6 1 GA » org.jasig.portal.tools.dbloader 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright 2004 The JA-SIG Collaborative.  All rights reserved.
002:         *  See license distributed with this file and
003:         *  available online at http://www.uportal.org/license.html
004:         */
005:
006:        package org.jasig.portal.tools.dbloader;
007:
008:        import java.io.PrintWriter;
009:        import java.net.URL;
010:        import java.sql.Connection;
011:        import java.util.ArrayList;
012:        import java.util.Hashtable;
013:        import java.util.Iterator;
014:        import java.util.Map;
015:
016:        import org.apache.oro.text.perl.Perl5Util;
017:
018:        import org.jasig.portal.properties.PropertiesManager;
019:        import org.w3c.dom.Document;
020:
021:        /**
022:         * Holds all configuration values used in DbLoader as part of loading a database.
023:         *
024:         * @author Ken Weiner, kweiner@unicon.net
025:         * @author Mark Boyd  {@link <a href="mailto:mark.boyd@engineer.com">mark.boyd@engineer.com</a>}
026:         * @version $Revision: 36690 $
027:         */
028:        public class Configuration {
029:            ///////// config values needed during the DB loading process /////////
030:
031:            private Connection con;
032:            private PrintWriter scriptWriter;
033:            private PrintWriter log;
034:            private Document genericTablesDoc;
035:            private Document tablesDoc;
036:
037:            private URL propertiesURL;
038:            private URL tablesURL;
039:            private URL dataURL;
040:
041:            private boolean dropTables;
042:            private boolean createTables;
043:            private boolean populateTables;
044:            private boolean createScript;
045:
046:            private String upgradeVersion;
047:            private int upgradeMajor;
048:            private int upgradeMinor;
049:
050:            private String adminLocale;
051:            private boolean localeAware;
052:
053:            private String tablesUri;
054:            private String tablesXslUri;
055:            private String dataUri;
056:            private String dataXslUri;
057:
058:            private String scriptFileName;
059:            private String statementTerminator;
060:            private ArrayList dbTypeMappings = new ArrayList();
061:            private Map localDbMetaTypeMap = null;
062:            private Map tableColumnTypes = new Hashtable(300);
063:
064:            ///////// Accessor Methods /////////
065:
066:            public void setLocaleAware(boolean localeAware) {
067:                this .localeAware = localeAware;
068:            }
069:
070:            public void setAdminLocale(String adminLocale) {
071:                this .adminLocale = adminLocale;
072:            }
073:
074:            public void setUpgradeVersion(String v) {
075:                this .upgradeVersion = v;
076:            }
077:
078:            public String getUpgradeVersion() {
079:                return this .upgradeVersion;
080:            }
081:
082:            public void setUpgradeMajor(int m) {
083:                this .upgradeMajor = m;
084:            }
085:
086:            public int getUpgradeMajor() {
087:                return this .upgradeMajor;
088:            }
089:
090:            public void setUpgradeMinor(int m) {
091:                this .upgradeMinor = m;
092:            }
093:
094:            public int getUpgradeMinor() {
095:                return this .upgradeMinor;
096:            }
097:
098:            public URL getPropertiesURL() {
099:                return propertiesURL;
100:            }
101:
102:            public URL getTablesURL() {
103:                return tablesURL;
104:            }
105:
106:            public URL getDataURL() {
107:                return dataURL;
108:            }
109:
110:            public void setTablesURL(URL tablesURL) {
111:                this .tablesURL = tablesURL;
112:            }
113:
114:            public void setDataURL(URL dataURL) {
115:                this .dataURL = dataURL;
116:            }
117:
118:            public void setPropertiesURL(URL u) {
119:                this .propertiesURL = u;
120:            }
121:
122:            public Document getGenericTablesDoc() {
123:                return this .genericTablesDoc;
124:            }
125:
126:            public void setGenericTablesDoc(Document d) {
127:                this .genericTablesDoc = d;
128:            }
129:
130:            public Document getTablesDoc() {
131:                return this .tablesDoc;
132:            }
133:
134:            public void setTablesDoc(Document d) {
135:                this .tablesDoc = d;
136:            }
137:
138:            public Connection getConnection() {
139:                return con;
140:            }
141:
142:            public PrintWriter getScriptWriter() {
143:                return scriptWriter;
144:            }
145:
146:            public PrintWriter getLog() {
147:                return log;
148:            }
149:
150:            public void setScriptWriter(PrintWriter w) {
151:                this .scriptWriter = w;
152:            }
153:
154:            public void setConnection(Connection c) {
155:                this .con = c;
156:            }
157:
158:            public void setLog(PrintWriter w) {
159:                this .log = w;
160:            }
161:
162:            public boolean getDropTables() {
163:                return dropTables;
164:            }
165:
166:            public boolean getCreateTables() {
167:                return createTables;
168:            }
169:
170:            public boolean getCreateScript() {
171:                return createScript;
172:            }
173:
174:            public boolean getPopulateTables() {
175:                return populateTables;
176:            }
177:
178:            public String getTablesUri() {
179:                return tablesUri;
180:            }
181:
182:            public String getTablesXslUri() {
183:                return tablesXslUri;
184:            }
185:
186:            public String getDataUri() {
187:                String ret = dataUri;
188:                if (localeAware == true && adminLocale != null) {
189:                    // Switch to replaceAll when we can rely on JDK 1.4
190:                    // ret = ret.replaceAll("\\.xml", "_" + admin_locale + ".xml");
191:                    Perl5Util perl5Util = new Perl5Util();
192:                    ret = perl5Util.substitute("s/\\.xml/_" + adminLocale
193:                            + ".xml" + "/g", ret);
194:                }
195:                return ret;
196:            }
197:
198:            public String getDataXslUri() {
199:                return dataXslUri;
200:            }
201:
202:            public String getScriptFileName() {
203:                return scriptFileName;
204:            }
205:
206:            public String getStatementTerminator() {
207:                return statementTerminator;
208:            }
209:
210:            public ArrayList getDbTypeMappings() {
211:                return dbTypeMappings;
212:            }
213:
214:            public void setDropTables(String dropTables) {
215:                this .setDropTables(toBoolean(dropTables));
216:            }
217:
218:            public void setDropTables(boolean dropTables) {
219:                this .dropTables = dropTables;
220:            }
221:
222:            public void setCreateTables(String createTables) {
223:                this .setCreateTables(toBoolean(createTables));
224:            }
225:
226:            public void setCreateTables(boolean createTables) {
227:                this .createTables = createTables;
228:            }
229:
230:            // CP Mod
231:            public void setPopulateTables(String populateTables) {
232:                this .setPopulateTables(toBoolean(populateTables));
233:            }
234:
235:            public void setPopulateTables(boolean populateTables) {
236:                this .populateTables = populateTables;
237:            }
238:
239:            public void setTablesUri(String tablesUri) {
240:                this .tablesUri = tablesUri;
241:            }
242:
243:            public void setTablesXslUri(String tablesXslUri) {
244:                this .tablesXslUri = tablesXslUri;
245:            }
246:
247:            public void setDataUri(String dataUri) {
248:                this .dataUri = dataUri;
249:            }
250:
251:            public void setDataXslUri(String dataXslUri) {
252:                this .dataXslUri = dataXslUri;
253:            }
254:
255:            public void setCreateScript(String createScript) {
256:                this .setCreateScript(toBoolean(createScript));
257:            }
258:
259:            public void setCreateScript(boolean createScript) {
260:                this .createScript = createScript;
261:            }
262:
263:            public void setScriptFileName(String scriptFileName) {
264:                this .scriptFileName = scriptFileName;
265:            }
266:
267:            public void setStatementTerminator(String statementTerminator) {
268:                this .statementTerminator = statementTerminator;
269:            }
270:
271:            public void addDbTypeMapping(DbTypeMapping dbTypeMapping) {
272:                dbTypeMappings.add(dbTypeMapping);
273:            }
274:
275:            public void setLocalTypeMap(Map m) {
276:                this .localDbMetaTypeMap = m;
277:            }
278:
279:            public Map getLocalTypeMap() {
280:                return this .localDbMetaTypeMap;
281:            }
282:
283:            public Map getTableColumnTypes() {
284:                return this .tableColumnTypes;
285:            }
286:
287:            public Configuration() {
288:                System.setProperty("org.xml.sax.driver", PropertiesManager
289:                        .getProperty("org.xml.sax.driver"));
290:                this .setLog(new PrintWriter(System.out, true));
291:            }
292:
293:            /**
294:             * Utility method for converting boolean strings to boolean values.
295:             * @param booleanString 
296:             * @return boolean
297:             */
298:            static boolean toBoolean(String booleanString) {
299:                return Boolean.valueOf(booleanString).booleanValue();
300:            }
301:
302:            public String getMappedDataTypeName(String dbName,
303:                    String dbVersion, String driverName, String driverVersion,
304:                    String genericDataTypeName) {
305:                String mappedDataTypeName = null;
306:                Iterator iterator = dbTypeMappings.iterator();
307:
308:                while (iterator.hasNext()) {
309:                    DbTypeMapping dbTypeMapping = (DbTypeMapping) iterator
310:                            .next();
311:                    String dbNameProp = dbTypeMapping.getDbName();
312:                    String dbVersionProp = dbTypeMapping.getDbVersion();
313:                    String driverNameProp = dbTypeMapping.getDriverName();
314:                    String driverVersionProp = dbTypeMapping.getDriverVersion();
315:
316:                    if (dbNameProp.equalsIgnoreCase(dbName)
317:                            && dbVersionProp.equalsIgnoreCase(dbVersion)
318:                            && driverNameProp.equalsIgnoreCase(driverName)
319:                            && (driverVersionProp
320:                                    .equalsIgnoreCase(driverVersion) || driverVersion == null)) {
321:                        // Found a matching database/driver combination
322:                        mappedDataTypeName = dbTypeMapping
323:                                .getMappedDataTypeName(genericDataTypeName);
324:                    }
325:                }
326:                return mappedDataTypeName;
327:            }
328:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.