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


001:        /*
002:         * Created on Jun 28, 2004
003:         *
004:         * TODO To change the template for this generated file go to
005:         * Window - Preferences - Java - Code Style - Code Templates
006:         */
007:        package org.vfny.geoserver.action.validation;
008:
009:        import com.vividsolutions.jts.geom.Envelope;
010:        import org.geotools.data.DataStore;
011:        import org.geotools.data.FeatureReader;
012:        import org.geotools.data.FeatureSource;
013:        import org.geotools.data.Repository;
014:        import org.geotools.feature.FeatureCollection;
015:        import org.geotools.validation.ValidationProcessor;
016:        import org.geotools.validation.ValidationResults;
017:        import org.geotools.validation.Validator;
018:        import org.vfny.geoserver.config.DataConfig;
019:        import org.vfny.geoserver.config.DataStoreConfig;
020:
021:        import java.util.ArrayList;
022:        import java.util.HashMap;
023:        import java.util.Iterator;
024:        import java.util.List;
025:        import java.util.Map;
026:        import java.util.logging.Logger;
027:        import javax.servlet.ServletContext;
028:        import javax.servlet.http.HttpServletRequest;
029:
030:        /**
031:         * @author rgould
032:         * @author bowens
033:         *
034:         * TODO To change the template for this generated type comment go to
035:         * Window - Preferences - Java - Code Style - Code Templates
036:         */
037:        public class ValidationRunnable implements  Runnable {
038:            /** Standard logging instance for class */
039:            private static final Logger LOGGER = org.geotools.util.logging.Logging
040:                    .getLogger("org.vfny.geoserver.responses");
041:            private Map testSuites;
042:            private Map plugins;
043:            private DataConfig dataConfig;
044:            private ServletContext context;
045:            private HttpServletRequest request;
046:            Validator validator;
047:            ValidationProcessor gv;
048:            public TestValidationResults results; // I get filled up with goodies
049:            Repository repository;
050:            public final static String KEY = "validationTestDoItThread.key";
051:
052:            //public ValidationRunnable(Map ts, Map plugins, DataConfig dataConfig, ServletContext context, HttpServletRequest request) throws Exception
053:            public ValidationRunnable(HttpServletRequest request) {
054:                //		this.testSuites = ts;		// what tests we are actually running
055:                //		this.plugins = plugins;		// every possible plugin
056:                //		this.dataConfig = dataConfig;
057:                //		this.context = context;
058:                this .request = request;
059:
060:                /*
061:                                LOGGER.finer("testSuites.size() = " + testSuites.size());
062:                                LOGGER.finer("plugins.size() = " + plugins.size());
063:                                LOGGER.finer("" + (TestSuiteDTO) testSuites.values().toArray()[0]);
064:
065:                                //DataConfig dataConfig = (DataConfig) getDataConfig();
066:                                Map dataStoreConfigs = dataConfig.getDataStores();
067:                                DefaultRepository dataRepository = new DefaultRepository();
068:                                Iterator it = dataStoreConfigs.keySet().iterator();
069:
070:                                // get all the data stores and build up our dataRepository
071:                                while (it.hasNext())
072:                                {
073:                                        String dsKey = it.next().toString();
074:                                        DataStoreConfig dsc = (DataStoreConfig) dataStoreConfigs.get(dsKey);
075:                                        DataStore ds = null;
076:                                        try {
077:                                                ds = dsc.findDataStore(context);
078:                                                dataRepository.register(dsKey, ds);
079:                                        }
080:                                        catch (Exception e) {
081:                                                e.printStackTrace();
082:                                        }
083:                                }
084:
085:                                validator = new Validator(dataRepository, gv);
086:                 */
087:            }
088:
089:            public void setup(TestValidationResults vr, Repository repo,
090:                    Map plugins, Map testSuites) throws Exception {
091:                gv = new ValidationProcessor();
092:                gv.load(plugins, testSuites);
093:                results = vr;
094:                repository = repo;
095:                validator = new Validator(repository, gv);
096:            }
097:
098:            /* (non-Javadoc)
099:             * @see java.lang.Runnable#run()
100:             */
101:            public void run() {
102:                //GeoValidator gv = new GeoValidator(testSuites,plugins);
103:                //Map dataStores = dataConfig.getDataStores();
104:                //TestValidationResults vr = runTransactions(dataStores,gv,context);
105:                request.getSession().setAttribute(
106:                        TestValidationResults.CURRENTLY_SELECTED_KEY, results);
107:
108:                Map dataStores = repository.getFeatureSources();
109:                Iterator it = dataStores.entrySet().iterator();
110:
111:                // Go through each data store and run the featureValidation test on
112:                //  each feature type
113:                while (it.hasNext()) {
114:                    Map.Entry entry = (Map.Entry) it.next();
115:                    String typeRef = (String) entry.getKey();
116:                    FeatureSource featureSource = (FeatureSource) entry
117:                            .getValue();
118:                    String dataStoreId = typeRef.split(":")[0];
119:
120:                    try {
121:                        LOGGER.finer(dataStoreId + ": feature validation, "
122:                                + featureSource);
123:
124:                        FeatureCollection features = featureSource
125:                                .getFeatures();
126:                        validator.featureValidation(dataStoreId, features,
127:                                results);
128:                    } catch (Exception e1) {
129:                        e1.printStackTrace();
130:                    }
131:                }
132:
133:                /** ------------------------------------------------------------------ */
134:
135:                /** run INTEGRITY validations */
136:
137:                // this is stupid
138:                Envelope env = new Envelope(Integer.MIN_VALUE,
139:                        Integer.MIN_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
140:
141:                // a map of typeref -> DataSource
142:                try {
143:                    Map featureSources = repository.getFeatureSources();
144:                    LOGGER.finer("integrity tests entry for "
145:                            + featureSources.size() + " dataSources.");
146:                    validator.integrityValidation(featureSources, env, results);
147:                } catch (Exception e) {
148:                    e.printStackTrace();
149:                }
150:
151:                results.run = true;
152:            }
153:
154:            private TestValidationResults runTransactions(Map dsm,
155:                    ValidationProcessor v, ServletContext sc) {
156:                if ((dsm == null) || (dsm.size() == 0)) {
157:                    System.out.println("No Datastores were defined.");
158:
159:                    return null;
160:                }
161:
162:                if (v == null) {
163:                    System.err
164:                            .println("An error occured: Cannot run without a ValidationProcessor.");
165:
166:                    return null;
167:                }
168:
169:                TestValidationResults vr = new TestValidationResults();
170:                Iterator i = dsm.keySet().iterator();
171:
172:                //TODO: we only get one datastore here when we may need more than that
173:                // do another pass through it and get those typesNames
174:                List dataStores = new ArrayList();
175:                try {
176:                    while (i.hasNext()) {
177:                        Map sources = new HashMap();
178:                        String key = i.next().toString();
179:                        DataStoreConfig dsc = (DataStoreConfig) dsm.get(key);
180:
181:                        try {
182:                            DataStore ds = dsc.findDataStore(sc);
183:                            dataStores.add(ds);
184:                            String[] ss = ds.getTypeNames();
185:
186:                            for (int j = 0; j < ss.length; j++) {
187:                                FeatureSource fs = ds.getFeatureSource(ss[j]);
188:                                sources.put(dsc.getId() + ":" + ss[j], fs);
189:
190:                                //v.runFeatureTests(dsc.getId(),fs.getSchema(),
191:                                //    fs.getFeatures().collection(), (ValidationResults) vr);
192:                                System.out.println("Feature Test Results for "
193:                                        + key + ":" + ss[j]);
194:                                System.out.println(vr.toString());
195:                            }
196:                        } catch (Exception e) {
197:                            e.printStackTrace();
198:                        }
199:
200:                        Envelope env = new Envelope(Integer.MIN_VALUE,
201:                                Integer.MIN_VALUE, Integer.MAX_VALUE,
202:                                Integer.MAX_VALUE);
203:
204:                        try {
205:                            v.runIntegrityTests(sources.keySet(), sources, env,
206:                                    (ValidationResults) vr);
207:                            System.out
208:                                    .println("Feature Integrety Test Results");
209:                            System.out.println(vr.toString());
210:                        } catch (Exception e) {
211:                            e.printStackTrace();
212:                        }
213:                    }
214:                } finally {
215:                    for (Iterator it = dataStores.iterator(); it.hasNext();) {
216:                        DataStore ds = (DataStore) it.next();
217:                        ds.dispose();
218:                    }
219:                }
220:
221:                return vr;
222:            }
223:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.