Source Code Cross Referenced for GenericSQLShapeImporter.java in  » GIS » deegree » org » deegree » tools » shape » 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 » GIS » deegree » org.deegree.tools.shape 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/tools/shape/GenericSQLShapeImporter.java $
002:        /*----------------    FILE HEADER  ------------------------------------------
003:
004:         This file is part of deegree.
005:         Copyright (C) 2001-2008 by:
006:         EXSE, Department of Geography, University of Bonn
007:         http://www.giub.uni-bonn.de/deegree/
008:         lat/lon GmbH
009:         http://www.lat-lon.de
010:
011:         This library is free software; you can redistribute it and/or
012:         modify it under the terms of the GNU Lesser General Public
013:         License as published by the Free Software Foundation; either
014:         version 2.1 of the License, or (at your option) any later version.
015:
016:         This library is distributed in the hope that it will be useful,
017:         but WITHOUT ANY WARRANTY; without even the implied warranty of
018:         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
019:         Lesser General Public License for more details.
020:
021:         You should have received a copy of the GNU Lesser General Public
022:         License along with this library; if not, write to the Free Software
023:         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
024:
025:         Contact:
026:
027:         Andreas Poth
028:         lat/lon GmbH
029:         Aennchenstr. 19
030:         53177 Bonn
031:         Germany
032:         E-Mail: poth@lat-lon.de
033:
034:         Prof. Dr. Klaus Greve
035:         Department of Geography
036:         University of Bonn
037:         Meckenheimer Allee 166
038:         53115 Bonn
039:         Germany
040:         E-Mail: greve@giub.uni-bonn.de
041:
042:         ---------------------------------------------------------------------------*/
043:        package org.deegree.tools.shape;
044:
045:        import java.io.IOException;
046:        import java.nio.charset.Charset;
047:        import java.security.InvalidParameterException;
048:        import java.sql.Types;
049:        import java.util.Properties;
050:
051:        import org.deegree.framework.log.ILogger;
052:        import org.deegree.framework.log.LoggerFactory;
053:        import org.deegree.i18n.Messages;
054:        import org.deegree.io.dbaseapi.DBaseException;
055:        import org.deegree.io.quadtree.DBQuadtreeManager;
056:        import org.deegree.io.quadtree.IndexException;
057:        import org.deegree.io.shpapi.HasNoDBaseFileException;
058:
059:        /**
060:         * 
061:         * 
062:         * 
063:         * @version August 13th 2007
064:         * @author <a href="mailto:poth@lat-lon.de">Andreas Poth</a>
065:         * @author last edited by: $Author: apoth $
066:         * 
067:         * @version August 13th 2007
068:         * 
069:         * @since 2.0
070:         */
071:        public class GenericSQLShapeImporter {
072:            private static ILogger LOG = LoggerFactory
073:                    .getLogger(GenericSQLShapeImporter.class);
074:
075:            private void validate(Properties map) {
076:                if (null == map.get("-driver") || "".equals(map.get("-driver"))) {
077:                    throw new InvalidParameterException("-driver must be set");
078:                }
079:
080:                if (null == map.get("-url") || "".equals(map.get("-url"))) {
081:                    throw new InvalidParameterException("-url must be set");
082:                }
083:
084:                if (null == map.get("-user") || "".equals(map.get("-user"))) {
085:                    throw new InvalidParameterException("-user must be set");
086:                }
087:
088:                if (null == map.get("-password")
089:                        || "".equals(map.get("-password"))) {
090:                    LOG.logInfo("You supplied no password, is this correct?");
091:                }
092:
093:                if (null == map.get("-indexName")
094:                        || "".equals(map.get("-indexName"))) {
095:                    throw new InvalidParameterException(
096:                            "-indexName must be set");
097:                }
098:
099:                if (null == map.get("-table") || "".equals(map.get("-table"))) {
100:                    throw new InvalidParameterException("-table must be set");
101:                }
102:
103:                if (null == map.get("-shapeFile")
104:                        || "".equals(map.get("-shapeFile"))) {
105:                    throw new InvalidParameterException(
106:                            "-shapeFile must be set");
107:                }
108:
109:                if (null == map.get("-maxTreeDepth")
110:                        || "".equals(map.get("-maxTreeDepth"))) {
111:                    map.put("-maxTreeDepth", new Integer(6));
112:                }
113:
114:            }
115:
116:            private void printHelp() {
117:                System.out
118:                        .println(Messages
119:                                .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP_DRIVER"));
120:                System.out
121:                        .println(Messages
122:                                .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP_URL"));
123:                System.out
124:                        .println(Messages
125:                                .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP_USER"));
126:                System.out
127:                        .println(Messages
128:                                .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP_PASSWORD"));
129:                System.out
130:                        .println(Messages
131:                                .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP_INDEXNAME"));
132:                System.out
133:                        .println(Messages
134:                                .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP_TABLE"));
135:                System.out
136:                        .println(Messages
137:                                .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP_OWNER"));
138:                System.out
139:                        .println(Messages
140:                                .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP_SHAPEFILE"));
141:                System.out
142:                        .println(Messages
143:                                .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP_MAXTREEDEPTH"));
144:                System.out
145:                        .println(Messages
146:                                .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP_IDTYPE"));
147:                System.out.println(Messages
148:                        .getMessage("DATASTORE_GENERICSQLSHAPEIMPORTER.HELP"));
149:                System.exit(1);
150:            }
151:
152:            /**
153:             * @param args
154:             */
155:            public static void main(String[] args) {
156:
157:                Properties map = new Properties();
158:                for (int i = 0; i < args.length;) {
159:                    String first = args[i++];
160:                    if (first != null && !"".equals(first.trim())
161:                            && first.startsWith("-")) {
162:                        //do we have no argument left
163:                        if (i + 1 >= args.length) {
164:                            if (first != null && !"".equals(first.trim())) {
165:                                if (first.trim().startsWith("-")) {
166:                                    map.put(first, "");
167:                                } else {
168:                                    System.out
169:                                            .println("The last commandline parameter doesn't start with a '-' sign, I'm confused, please check for previous errors (e.g. unescaped characters like spaces etc.) please quote all commandline arguments with spaces in them.");
170:                                    System.exit(1);
171:                                }
172:                            }
173:                        } else {
174:                            StringBuilder tmp = new StringBuilder(args[i]);
175:                            while (i++ < args.length
176:                                    && !args[i].startsWith("-")) {
177:                                tmp.append(" ");
178:                                tmp.append(args[i]);
179:                            }
180:                            String second = tmp.toString();
181:                            map.put(first, second);
182:                        }
183:                    } else {
184:                        i++;
185:                    }
186:                }
187:
188:                LOG.logInfo("You supplied following command line values: "
189:                        + map);
190:
191:                GenericSQLShapeImporter gs = new GenericSQLShapeImporter();
192:                if (map.get("-?") != null || map.get("-h") != null) {
193:                    gs.printHelp();
194:                }
195:
196:                try {
197:                    gs.validate(map);
198:                } catch (InvalidParameterException ipe) {
199:                    LOG.logError(ipe.getMessage() + "\n");
200:                    gs.printHelp();
201:                }
202:
203:                int depth = Integer.parseInt(map.getProperty("-maxTreeDepth"));
204:                DBQuadtreeManager qtm = null;
205:                if ("INTEGER".equalsIgnoreCase((String) map.get("-idType"))) {
206:                    LOG.logInfo("Using Integer as id type");
207:                    qtm = new DBQuadtreeManager<Integer>(map
208:                            .getProperty("-driver"), map.getProperty("-url"),
209:                            map.getProperty("-user"), map
210:                                    .getProperty("-password"), Charset
211:                                    .defaultCharset().name(), map
212:                                    .getProperty("-indexName"), map
213:                                    .getProperty("-table"), "geometry", map
214:                                    .getProperty("-owner"), depth,
215:                            Types.INTEGER);
216:                } else {
217:                    LOG.logInfo("Using VARCHAR as id type");
218:                    qtm = new DBQuadtreeManager<String>(map
219:                            .getProperty("-driver"), map.getProperty("-url"),
220:                            map.getProperty("-user"), map
221:                                    .getProperty("-password"), Charset
222:                                    .defaultCharset().name(), map
223:                                    .getProperty("-indexName"), map
224:                                    .getProperty("-table"), "geometry", map
225:                                    .getProperty("-owner"), depth,
226:                            Types.VARCHAR);
227:                }
228:
229:                try {
230:                    qtm.importShape(map.getProperty("-shapeFile"));
231:                } catch (IOException e) {
232:                    LOG.logError(e.getMessage());
233:                    e.printStackTrace();
234:                } catch (IndexException e) {
235:                    LOG.logError(e.getMessage());
236:                    e.printStackTrace();
237:                } catch (HasNoDBaseFileException e) {
238:                    LOG.logError(e.getMessage());
239:                    e.printStackTrace();
240:                } catch (DBaseException e) {
241:                    LOG.logError(e.getMessage());
242:                    e.printStackTrace();
243:                }
244:                System.exit(0);
245:
246:            }
247:
248:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.