Source Code Cross Referenced for SchemaToolTask.java in  » Database-ORM » JPOX » org » jpox » 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 » JPOX » org.jpox 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**********************************************************************
002:        Copyright (c) 2004 Andy Jefferson and others. All rights reserved.
003:        Licensed under the Apache License, Version 2.0 (the "License");
004:        you may not use this file except in compliance with the License.
005:        You may obtain a copy of the License at
006:
007:            http://www.apache.org/licenses/LICENSE-2.0
008:
009:        Unless required by applicable law or agreed to in writing, software
010:        distributed under the License is distributed on an "AS IS" BASIS,
011:        WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
012:        See the License for the specific language governing permissions and
013:        limitations under the License.
014:
015:        Contributors:
016:        2004 Andy Jefferson - added sysproperty and classpath input options
017:        2004 Andy Jefferson - changed to be derived from Java taskdef
018:        2004 Andy Jefferson - removed redundant methods. Changed to se fork=true always
019:            ...
020:         **********************************************************************/package org.jpox;
021:
022:        import java.io.File;
023:        import java.util.Vector;
024:        import org.apache.tools.ant.BuildException;
025:        import org.apache.tools.ant.DirectoryScanner;
026:        import org.apache.tools.ant.Project;
027:        import org.apache.tools.ant.taskdefs.Java;
028:        import org.apache.tools.ant.types.FileSet;
029:        import org.jpox.util.Localiser;
030:
031:        /**
032:         * SchemaTool Ant Task. Accepts the following parameters
033:         * <UL>
034:         * <LI><B>mode</B> Mode of operation (<B>"create"</B>, "delete", "validate", "dbinfo", "schemainfo").</LI>
035:         * <LI><B>verbose</B> Verbose output.</LI>
036:         * <LI><B>props</B> Name of a properties file for use in SchemaTool (PMF properties)</LI>
037:         * <LI><B>ddlFile</B> Name of a file to output the DDL into</LI>
038:         * <LI><B>completeDdl</B> Whether to output complete DDL (otherwise just the missing tables/constraints)</LI>
039:         * <LI><B>persistenceUnit</B> Name of a persistence-unit to manage the schema for</LI>
040:         * </UL>
041:         *
042:         * @version $Revision: 1.13 $
043:         */
044:        public class SchemaToolTask extends Java {
045:            /** Localiser for messages. */
046:            private static final Localiser LOCALISER = Localiser
047:                    .getInstance("org.jpox.Localisation");
048:
049:            /** Operating mode */
050:            private int runMode = SchemaTool.SCHEMATOOL_CREATE_MODE;
051:
052:            /** Filesets of JDO files to be used in generating the schema. */
053:            Vector filesets = new Vector();
054:
055:            /**
056:             * Constructor.
057:             */
058:            public SchemaToolTask() {
059:                setClassname("org.jpox.SchemaTool");
060:                setFork(true);
061:            }
062:
063:            /**
064:             * Execute method, to execute the task.
065:             * @throws BuildException if any error happens while running the task
066:             **/
067:            public void execute() throws BuildException {
068:                if (runMode == SchemaTool.SCHEMATOOL_CREATE_MODE) {
069:                    createArg().setValue("-create");
070:                } else if (runMode == SchemaTool.SCHEMATOOL_DELETE_MODE) {
071:                    createArg().setValue("-delete");
072:                } else if (runMode == SchemaTool.SCHEMATOOL_VALIDATE_MODE) {
073:                    createArg().setValue("-validate");
074:                } else if (runMode == SchemaTool.SCHEMATOOL_DATABASE_INFO_MODE) {
075:                    createArg().setValue("-dbinfo");
076:                } else if (runMode == SchemaTool.SCHEMATOOL_SCHEMA_INFO_MODE) {
077:                    createArg().setValue("-schemainfo");
078:                }
079:
080:                File[] files = getFiles();
081:                for (int i = 0; i < files.length; i++) {
082:                    createArg().setFile(files[i]);
083:                }
084:
085:                setFork(true);
086:
087:                super .execute();
088:            }
089:
090:            /**
091:             * Add a fileset. @see ant manual
092:             * @param fs the FileSet
093:             */
094:            public void addFileSet(FileSet fs) {
095:                filesets.addElement(fs);
096:            }
097:
098:            protected File[] getFiles() {
099:                Vector v = new Vector();
100:                final int size = filesets.size();
101:                for (int i = 0; i < size; i++) {
102:                    FileSet fs = (FileSet) filesets.elementAt(i);
103:                    DirectoryScanner ds = fs.getDirectoryScanner(getProject());
104:                    ds.scan();
105:                    String[] f = ds.getIncludedFiles();
106:                    for (int j = 0; j < f.length; j++) {
107:                        String pathname = f[j];
108:                        File file = new File(ds.getBasedir(), pathname);
109:                        file = getProject().resolveFile(file.getPath());
110:                        v.addElement(file);
111:                    }
112:                }
113:                File[] files = new File[v.size()];
114:                v.copyInto(files);
115:                return files;
116:            }
117:
118:            /**
119:             * set verbose
120:             * @param verbose Whether to give verbose output
121:             */
122:            public void setVerbose(boolean verbose) {
123:                if (verbose) {
124:                    createArg().setValue("-v");
125:                    log("JPOX SchemaTool verbose: " + verbose,
126:                            Project.MSG_VERBOSE);
127:                }
128:            }
129:
130:            /**
131:             * Get properties for the PMF from a file
132:             * @param propsFileName Name of props file
133:             */
134:            public void setProps(String propsFileName) {
135:                if (propsFileName != null && propsFileName.length() > 0) {
136:                    createArg().setLine("-props " + propsFileName);
137:                    log("JPOX SchemaTool props: " + propsFileName,
138:                            Project.MSG_VERBOSE);
139:                }
140:            }
141:
142:            /**
143:             * Set the file to output DDL to
144:             * @param file Name of DDL file
145:             */
146:            public void setDdlFile(String file) {
147:                if (file != null && file.length() > 0) {
148:                    createArg().setLine("-ddlFile " + file);
149:                    log("JPOX SchemaTool ddlFile: " + file, Project.MSG_VERBOSE);
150:                }
151:            }
152:
153:            /**
154:             * set complete DDL
155:             * @param complete Whether to give complete DDL
156:             */
157:            public void setCompleteDdl(boolean complete) {
158:                if (complete) {
159:                    createArg().setValue("-completeDdl");
160:                    log("JPOX SchemaTool completeDdl: " + complete,
161:                            Project.MSG_VERBOSE);
162:                }
163:            }
164:
165:            /**
166:             * Set the name of the persistence unit to manage
167:             * @param unitName Name of persistence-unit
168:             */
169:            public void setPersistenceUnit(String unitName) {
170:                if (unitName != null && unitName.length() > 0) {
171:                    createArg().setLine("-persistenceUnit " + unitName);
172:                    log("JPOX SchemaTool persistenceUnit: " + unitName,
173:                            Project.MSG_VERBOSE);
174:                }
175:            }
176:
177:            /**
178:             * Set the API Adapter
179:             * @param api API Adapter
180:             */
181:            public void setApi(String api) {
182:                if (api != null && api.length() > 0) {
183:                    createArg().setValue("-api");
184:                    createArg().setValue(api);
185:                    log("JPOX SchemaTool api: " + api, Project.MSG_VERBOSE);
186:                }
187:            }
188:
189:            /**
190:             * Sets the mode of operation.
191:             * @param mode The mode of operation ("create", "delete", "validate", "dbinfo", "schemainfo")
192:             */
193:            public void setMode(String mode) {
194:                if (mode == null) {
195:                    return;
196:                }
197:                if (mode.equalsIgnoreCase("create")) {
198:                    this .runMode = SchemaTool.SCHEMATOOL_CREATE_MODE;
199:                } else if (mode.equalsIgnoreCase("delete")) {
200:                    this .runMode = SchemaTool.SCHEMATOOL_DELETE_MODE;
201:                } else if (mode.equalsIgnoreCase("validate")) {
202:                    this .runMode = SchemaTool.SCHEMATOOL_VALIDATE_MODE;
203:                } else if (mode.equalsIgnoreCase("dbinfo")) {
204:                    this .runMode = SchemaTool.SCHEMATOOL_DATABASE_INFO_MODE;
205:                } else if (mode.equalsIgnoreCase("schemainfo")) {
206:                    this .runMode = SchemaTool.SCHEMATOOL_SCHEMA_INFO_MODE;
207:                } else {
208:                    System.err.println(LOCALISER.msg("014036"));
209:                }
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.