Source Code Cross Referenced for DataFeatureTypesNewAction.java in  » GIS » GeoServer » org » vfny » geoserver » action » data » 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 » GeoServer » org.vfny.geoserver.action.data 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org.  All rights reserved.
002:         * This code is licensed under the GPL 2.0 license, availible at the root
003:         * application directory.
004:         */
005:        package org.vfny.geoserver.action.data;
006:
007:        import org.apache.struts.action.ActionError;
008:        import org.apache.struts.action.ActionErrors;
009:        import org.apache.struts.action.ActionForm;
010:        import org.apache.struts.action.ActionForward;
011:        import org.apache.struts.action.ActionMapping;
012:        import org.geotools.data.DataStore;
013:        import org.geotools.data.FeatureSource;
014:        import org.geotools.feature.FeatureType;
015:        import org.opengis.metadata.Identifier;
016:        import org.opengis.referencing.crs.CoordinateReferenceSystem;
017:        import org.vfny.geoserver.action.ConfigAction;
018:        import org.vfny.geoserver.config.DataConfig;
019:        import org.vfny.geoserver.config.DataStoreConfig;
020:        import org.vfny.geoserver.config.FeatureTypeConfig;
021:        import org.vfny.geoserver.form.data.DataFeatureTypesNewForm;
022:        import org.vfny.geoserver.global.UserContainer;
023:        import java.io.FileNotFoundException;
024:        import java.io.IOException;
025:        import java.util.Iterator;
026:        import java.util.Set;
027:        import javax.servlet.http.HttpServletRequest;
028:        import javax.servlet.http.HttpServletResponse;
029:
030:        /**
031:         * DataFeatureTypesNewAction purpose.
032:         *
033:         * <p>
034:         * Description of DataFeatureTypesNewAction ...
035:         * </p>
036:         *
037:         * <p>
038:         * Capabilities:
039:         * </p>
040:         *
041:         * <ul>
042:         * <li>
043:         * Feature: description
044:         * </li>
045:         * </ul>
046:         *
047:         * <p>
048:         * Example Use:
049:         * </p>
050:         * <pre><code>
051:         * DataFeatureTypesNewAction x = new DataFeatureTypesNewAction(...);
052:         * </code></pre>
053:         *
054:         * @author rgould, Refractions Research, Inc.
055:         * @author $Author: cholmesny $ (last modification)
056:         * @version $Id: DataFeatureTypesNewAction.java 7693 2007-11-01 09:31:11Z aaime $
057:         */
058:        public class DataFeatureTypesNewAction extends ConfigAction {
059:            public final static String NEW_FEATURE_TYPE_KEY = "newFeatureType";
060:
061:            public ActionForward execute(ActionMapping mapping,
062:                    ActionForm incomingForm, UserContainer user,
063:                    HttpServletRequest request, HttpServletResponse response)
064:                    throws IOException {
065:                DataFeatureTypesNewForm form = (DataFeatureTypesNewForm) incomingForm;
066:                String selectedNewFeatureType = form
067:                        .getSelectedNewFeatureType();
068:
069:                DataConfig dataConfig = (DataConfig) request.getSession()
070:                        .getServletContext()
071:                        .getAttribute(DataConfig.CONFIG_KEY);
072:                int index = selectedNewFeatureType
073:                        .indexOf(DataConfig.SEPARATOR);
074:                String dataStoreID = selectedNewFeatureType.substring(0, index);
075:                String featureTypeName = selectedNewFeatureType.substring(index
076:                        + DataConfig.SEPARATOR.length());
077:
078:                DataStoreConfig dsConfig = dataConfig.getDataStore(dataStoreID);
079:                DataStore dataStore = null;
080:
081:                FeatureTypeConfig ftConfig;
082:
083:                //JD: GEOS-399, wrap rest of method in try catch block in order to 
084:                // report back nicely to app
085:                try {
086:                    dataStore = dsConfig.findDataStore(request.getSession()
087:                            .getServletContext());
088:                    FeatureType featureType = dataStore
089:                            .getSchema(featureTypeName);
090:
091:                    ftConfig = new FeatureTypeConfig(dataStoreID, featureType,
092:                            false);
093:
094:                    // DJB: this comment looks old - SRS support is much better now.  
095:                    //     TODO: delete this comment (but wait a bit)
096:                    // What is the Spatial Reference System for this FeatureType?
097:                    // 
098:                    // getDefaultGeometry().getCoordinateSystem() should help but is null
099:                    // getDefaultGeometry().getGeometryFactory() could help, with getSRID(), but it is null
100:                    // 
101:                    // So we will use 0 which means Cartisian Coordinates aka don't know
102:                    //
103:                    // Only other thing we could do is ask for a geometry and see what it's
104:                    // SRID number is?
105:                    //
106:                    //            ftConfig.setSRS(0);
107:
108:                    // attempt to get a better SRS
109:                    try {
110:                        CoordinateReferenceSystem crs = featureType
111:                                .getDefaultGeometry().getCoordinateSystem();
112:
113:                        if (crs != null) {
114:                            Set idents = crs.getIdentifiers();
115:                            Iterator it = idents.iterator();
116:
117:                            while (it.hasNext()) {
118:                                Identifier id = (Identifier) it.next();
119:
120:                                if (id.toString().indexOf("EPSG:") != -1) // this should probably use the Citation, but this is easier!
121:                                {
122:                                    //we have an EPSG #, so lets use it!
123:                                    String str_num = id.toString().substring(
124:                                            id.toString().indexOf(':') + 1);
125:                                    int num = Integer.parseInt(str_num);
126:                                    ftConfig.setSRS(num);
127:
128:                                    break; // take the first EPSG
129:                                }
130:                            }
131:                        }
132:                    } catch (Exception e) {
133:                        e.printStackTrace(); // not a big deal - we'll default to 0.
134:                    }
135:
136:                    FeatureSource fs = dataStore.getFeatureSource(featureType
137:                            .getTypeName());
138:
139:                    // TODO translate to lat long, pending
140:                    //This should not be done by default, as it is an expensive operation.
141:                    //especially for very large tables.  User may know it, if not he
142:                    //can hit the generate button (which is why it's there).
143:                    //ftConfig.setLatLongBBox(DataStoreUtils.getBoundingBoxEnvelope(fs));
144:
145:                    //Extent ex = featureType.getDefaultGeometry().getCoordinateSystem().getValidArea();
146:                    //ftConfig.setLatLongBBox(ex);
147:                } catch (IOException e) {
148:                    e.printStackTrace();
149:
150:                    if (e instanceof  FileNotFoundException) {
151:                        ActionErrors errors = new ActionErrors();
152:                        errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
153:                                "error.exception", "File not found: "
154:                                        + e.getMessage()));
155:                        saveErrors(request, errors);
156:
157:                        return mapping.findForward("config.data.type.new");
158:                    }
159:
160:                    ActionErrors errors = new ActionErrors();
161:                    errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(
162:                            "error.exception", e.getMessage()));
163:
164:                    saveErrors(request, errors);
165:
166:                    return mapping.findForward("config.data.type.new");
167:                } finally {
168:                    if (dataStore != null)
169:                        dataStore.dispose();
170:                }
171:
172:                request.getSession().setAttribute(
173:                        DataConfig.SELECTED_FEATURE_TYPE, ftConfig);
174:                request.getSession().removeAttribute(
175:                        DataConfig.SELECTED_ATTRIBUTE_TYPE);
176:
177:                user.setFeatureTypeConfig(ftConfig);
178:
179:                return mapping.findForward("config.data.type.editor");
180:            }
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.