Source Code Cross Referenced for SqlDataStoreFactory.java in  » GIS » GeoTools-2.4.1 » org » geotools » data » sql » 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 » GeoTools 2.4.1 » org.geotools.data.sql 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.geotools.data.sql;
002:
003:        import java.io.IOException;
004:        import java.util.Collections;
005:        import java.util.HashMap;
006:        import java.util.Map;
007:        import java.util.logging.Logger;
008:
009:        import org.geotools.data.DataSourceException;
010:        import org.geotools.data.DataStore;
011:        import org.geotools.data.DataStoreFactorySpi;
012:        import org.geotools.data.DataStoreFinder;
013:
014:        /**
015:         * A DataStoreFactory that produces any {@link org.geotools.data.sql.SqlDataStore}, whose
016:         * only purpose is to simplify the process of defining in-process views by
017:         * specifying them as plain SQL SELECT statements in the Map of parameters.
018:         * <p>
019:         * The only mandatory parameter to use this factory is <code>"wrapper.type"</code>, whose
020:         * value must be the fixed literal <code>"sql"</code>. Though a bunch of other parameters
021:         * will be needed to actually find the surrogate datastore, those parameters are
022:         * dependent on the parameters expected by the surrogate datastore factory.
023:         * To prevent parameter name clashes and the surrogate being found prior to this
024:         * factory in the lookup process, all surrogate datastre's parameters must be 
025:         * prepended by the literal <code>"surrogate."</code>, as in the following example:
026:         * <pre><code>
027:         *      wrapper.type=SQL
028:         *      surrogate.property1=...
029:         *      surrogate.property2=...
030:         *      surrogate.property3=...
031:         *      surrogate.property4=...
032:         *      
033:         *      sqlView.1.typeName = ViewType1
034:         *      sqlView.1.sqlQuery = select gid, the_geom, table2.someField \
035:         *                           from table1, table2 \
036:         *                           where table1.gid = table2.table1_id
037:         *     
038:         *      sqlView.2.typeName = ViewType2
039:         *      sqlView.2.sqlQuery = select ...
040:         * </code></pre>
041:         * </p>
042:         * <p>
043:         * As noted above, apart from the surrogate parameters you'll have to specify
044:         * which SQL queries to use as FeatureType "views". The process is quite simple:
045:         * prepend <code>"sqlView.N."</code> to <code>"typeName"</code> and <code>"sqlQuery"</code>
046:         * for each view you want to define.
047:         * </p>
048:         * 
049:         * @author Gabriel Roldan, Axios Engineering
050:         * @version $id$
051:         * @since 2.3.x
052:         * @source $URL: http://svn.geotools.org/geotools/tags/2.4.1/modules/unsupported/community-schemas/sql-datastore/src/org/geotools/data/sql/SqlDataStoreFactory.java $
053:         */
054:        public class SqlDataStoreFactory implements  DataStoreFactorySpi {
055:            private static final Logger LOGGER = org.geotools.util.logging.Logging
056:                    .getLogger(SqlDataStore.class.getPackage().getName());
057:
058:            private static final String WRAPPERTYPE_FIXED_VALUE = "sql";
059:
060:            private static Param WRAPPERTYPE = new Param("wrapper.type",
061:                    String.class,
062:                    "Needs to be the fixed value 'sql' to be recognized", true,
063:                    WRAPPERTYPE_FIXED_VALUE);
064:
065:            public DataStore createDataStore(Map params) throws IOException {
066:                if (!canProcess(params)) {
067:                    throw new DataSourceException("can't process " + params);
068:                }
069:                Map surrogateParams = ViewRegisteringFactoryHelper
070:                        .cleanUpSurrogateParams(params);
071:                DataStore surrogate = DataStoreFinder
072:                        .getDataStore(surrogateParams);
073:                if (surrogate == null) {
074:                    throw new DataSourceException(
075:                            "Can't locate surrogate datastore: "
076:                                    + surrogateParams);
077:                }
078:                if (!(surrogate instanceof  SqlDataStore)) {
079:                    throw new DataSourceException(
080:                            "Surrogate datastore is not a SqlDataStore: "
081:                                    + surrogate.getClass());
082:                }
083:
084:                SqlDataStore sqlDs = (SqlDataStore) surrogate;
085:                ViewRegisteringFactoryHelper.registerSqlViews(sqlDs, params);
086:
087:                return sqlDs;
088:            }
089:
090:            public DataStore createNewDataStore(Map params) throws IOException {
091:                throw new UnsupportedOperationException();
092:            }
093:
094:            public String getDisplayName() {
095:                return "SQL select based datastore";
096:            }
097:
098:            public String getDescription() {
099:                return "DataStore that adds in-process views to ahother one that implements SqlDataStore";
100:            }
101:
102:            public Param[] getParametersInfo() {
103:                return new Param[] { WRAPPERTYPE };
104:            }
105:
106:            /**
107:             * Checks only if the "wrapper.type" keywords is equal to the
108:             * fixed value "sql".
109:             */
110:            public boolean canProcess(Map params) {
111:                try {
112:                    return WRAPPERTYPE_FIXED_VALUE.equalsIgnoreCase(String
113:                            .valueOf(WRAPPERTYPE.lookUp(params)));
114:                } catch (Exception e) {
115:                    LOGGER.finer("lookup failed on parameter "
116:                            + WRAPPERTYPE.key);
117:                    return false;
118:                }
119:            }
120:
121:            /**
122:             * @return <code>true</code>
123:             * @REVISIT: checking surrogate's datastore availability
124:             * would be costly which goes against this method intentions.
125:             */
126:            public boolean isAvailable() {
127:                return true;
128:            }
129:
130:            /**
131:             * @return an empty Map. No implementation hints
132:             * defined for this datastore.
133:             */
134:            public Map getImplementationHints() {
135:                return Collections.EMPTY_MAP;
136:            }
137:
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.