Source Code Cross Referenced for GetObservationRequest.java in  » GIS » deegree » org » deegree » ogcwebservices » sos » getobservation » 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.ogcwebservices.sos.getobservation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //$HeadURL: https://svn.wald.intevation.org/svn/deegree/base/trunk/src/org/deegree/ogcwebservices/sos/getobservation/GetObservationRequest.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:         Aennchenstraße 19  
030:         53177 Bonn
031:         Germany
032:         E-Mail: poth@lat-lon.de
033:
034:         Prof. Dr. Klaus Greve
035:         lat/lon GmbH
036:         Aennchenstraße 19
037:         53177 Bonn
038:         Germany
039:         E-Mail: greve@giub.uni-bonn.de
040:
041:         ---------------------------------------------------------------------------*/
042:        package org.deegree.ogcwebservices.sos.getobservation;
043:
044:        import java.util.ArrayList;
045:        import java.util.List;
046:        import java.util.Map;
047:
048:        import org.deegree.framework.log.ILogger;
049:        import org.deegree.framework.log.LoggerFactory;
050:        import org.deegree.framework.xml.NamespaceContext;
051:        import org.deegree.framework.xml.XMLParsingException;
052:        import org.deegree.framework.xml.XMLTools;
053:        import org.deegree.model.crs.UnknownCRSException;
054:        import org.deegree.model.filterencoding.ComplexFilter;
055:        import org.deegree.model.filterencoding.FilterConstructionException;
056:        import org.deegree.model.spatialschema.Envelope;
057:        import org.deegree.model.spatialschema.GMLGeometryAdapter;
058:        import org.deegree.ogcbase.CommonNamespaces;
059:        import org.deegree.ogcwebservices.AbstractOGCWebServiceRequest;
060:        import org.deegree.ogcwebservices.OGCWebServiceException;
061:        import org.w3c.dom.Document;
062:        import org.w3c.dom.Element;
063:        import org.w3c.dom.Node;
064:
065:        /**
066:         * represent a getObservation request
067:         * 
068:         * @author <a href="mailto:mkulbe@lat-lon.de">Matthias Kulbe </a>
069:         * 
070:         * @version 1.0
071:         */
072:
073:        public class GetObservationRequest extends AbstractOGCWebServiceRequest {
074:
075:            private static final NamespaceContext nsContext = CommonNamespaces
076:                    .getNamespaceContext();
077:
078:            private static final ILogger LOG = LoggerFactory
079:                    .getLogger(GetObservationRequest.class);
080:
081:            private Envelope envelope = null;
082:
083:            private Query query = null;
084:
085:            private Object[] time = null;
086:
087:            private String[] platforms = null;
088:
089:            private String[] sensors = null;
090:
091:            private String outputFormat;
092:
093:            /**
094:             * create a GetObservationRequest from KVP Map
095:             * 
096:             * @param map
097:             * @return
098:             * 
099:             */
100:            public static GetObservationRequest create(Map map) {
101:                throw new UnsupportedOperationException();
102:                /*
103:                 * // TODO implement this? String id = null; String version = null;
104:                 * 
105:                 * String outputFormat = null; Query query = null; Envelope boundingBox = null; Object[]
106:                 * time = null; String[] platformId = null; String[] sensorId = null;
107:                 * 
108:                 * return new GetObservationRequest( query, boundingBox, outputFormat, time, platformId,
109:                 * sensorId, version, id, null );
110:                 */
111:            }
112:
113:            /**
114:             * create from XML Document
115:             * 
116:             * @param id
117:             * @param doc
118:             * @return
119:             * @throws OGCWebServiceException
120:             * 
121:             */
122:            public static GetObservationRequest create(String id, Document doc)
123:                    throws OGCWebServiceException {
124:
125:                GetObservationRequest goReq = null;
126:                try {
127:                    // gets the version
128:                    String version = XMLTools.getNodeAsString(doc,
129:                            "sos:GetObservation/@version", nsContext, null);
130:
131:                    // gets the outputFormat
132:                    String outputFormat = XMLTools.getNodeAsString(doc,
133:                            "sos:GetObservation/@outputFormat", nsContext,
134:                            "SWEObservation");
135:
136:                    // optional, fixed to "SOS"
137:                    String service = XMLTools.getNodeAsString(doc,
138:                            "sos:GetObservation/@service", nsContext, null);
139:                    if ((service != null) && (!service.equals("SOS"))) {
140:                        throw new OGCWebServiceException(
141:                                "service must be 'SOS'");
142:                    }
143:
144:                    // gets Bounding Box
145:                    Node boxNode = XMLTools.getRequiredNode(doc,
146:                            "sos:GetObservation/sos:BoundingBox", nsContext);
147:                    Envelope env = GMLGeometryAdapter.wrapBox(
148:                            (Element) boxNode, null);
149:
150:                    Node queryNode = XMLTools.getNode(doc,
151:                            "sos:GetObservation/sos:Query", nsContext);
152:                    // gets Query
153:                    Query query = null;
154:                    if (queryNode != null) {
155:                        query = createQuery(queryNode);
156:                    }
157:
158:                    List timeList = XMLTools.getNodes(doc,
159:                            "sos:GetObservation/sos:time", nsContext);
160:
161:                    ArrayList time = getTimeList(timeList);
162:
163:                    // gets id's from the requested platforms
164:                    List platformIdList = XMLTools.getNodes(doc,
165:                            "sos:GetObservation/sos:platformID", nsContext);
166:                    ArrayList<String> platformId = new ArrayList<String>(
167:                            platformIdList.size());
168:                    for (int i = 0; i < platformIdList.size(); i++) {
169:                        platformId.add(XMLTools.getRequiredNodeAsString(
170:                                (Node) platformIdList.get(i), "text()",
171:                                nsContext));
172:                    }
173:
174:                    LOG.logDebug("Platforms=" + platformId.size());
175:
176:                    // gets id's from the requested sensors
177:                    List sensorIdList = XMLTools.getNodes(doc,
178:                            "sos:GetObservation/sos:sensorID", nsContext);
179:                    ArrayList<String> sensorId = new ArrayList<String>(
180:                            sensorIdList.size());
181:                    for (int i = 0; i < sensorIdList.size(); i++) {
182:                        sensorId.add(XMLTools
183:                                .getRequiredNodeAsString((Node) sensorIdList
184:                                        .get(i), "text()", nsContext));
185:                    }
186:                    LOG.logDebug("Sensors=" + sensorId.size());
187:
188:                    goReq = new GetObservationRequest(query, env, outputFormat,
189:                            time.toArray(), platformId
190:                                    .toArray(new String[platformId.size()]),
191:                            sensorId.toArray(new String[sensorId.size()]),
192:                            version, id, null);
193:
194:                } catch (XMLParsingException e) {
195:                    e.printStackTrace();
196:                    throw new OGCWebServiceException("scs webservice failure");
197:                } catch (UnknownCRSException e) {
198:                    e.printStackTrace();
199:                    throw new OGCWebServiceException("scs webservice failure");
200:                }
201:                return goReq;
202:            }
203:
204:            /**
205:             * @param nsContext
206:             * @param timeList
207:             * @return
208:             * @throws XMLParsingException
209:             * @throws OGCWebServiceException
210:             */
211:            private static ArrayList<Object> getTimeList(List timeList)
212:                    throws XMLParsingException, OGCWebServiceException {
213:
214:                ArrayList<Object> time = new ArrayList<Object>(timeList.size());
215:                for (int i = 0; i < timeList.size(); i++) {
216:
217:                    if ((XMLTools.getNode((Node) timeList.get(i),
218:                            "gml:TPeriod", nsContext)) != null) {
219:
220:                        String begin = XMLTools
221:                                .getNodeAsString(
222:                                        (Node) timeList.get(i),
223:                                        "gml:TPeriod/gml:begin/gml:TInstant/gml:tPosition/text()",
224:                                        nsContext, null);
225:                        if (begin == null) {
226:                            throw new OGCWebServiceException(
227:                                    "TPeriod must have a begin time Position");
228:                        }
229:
230:                        String end = XMLTools
231:                                .getNodeAsString(
232:                                        (Node) timeList.get(i),
233:                                        "gml:TPeriod/gml:end/gml:TInstant/gml:tPosition/text()",
234:                                        nsContext, null);
235:                        if (end == null) {
236:                            throw new OGCWebServiceException(
237:                                    "TPeriod must have a end time Position");
238:                        }
239:
240:                        LOG.logDebug("create TPeriod with begin=" + begin
241:                                + " end=" + end);
242:                        time.add(new TPeriod(begin, end));
243:                    } else if ((XMLTools.getNode((Node) timeList.get(i),
244:                            "gml:TInstant", nsContext)) != null) {
245:
246:                        String temp = XMLTools.getNodeAsString((Node) timeList
247:                                .get(i), "gml:TInstant/gml:tPosition/text()",
248:                                nsContext, null);
249:                        if (temp == null) {
250:                            throw new OGCWebServiceException(
251:                                    "TInstant must have a time Position");
252:                        }
253:
254:                        LOG.logDebug("create TInstant with time=" + temp);
255:                        time.add(new TInstant(temp));
256:                    } else {
257:                        throw new OGCWebServiceException(
258:                                "time must have a TPeriod or a TInstant");
259:                    }
260:                }
261:                return time;
262:            }
263:
264:            /**
265:             * @param nsContext
266:             * @param queryNode
267:             * @return
268:             * @throws XMLParsingException
269:             * @throws OGCWebServiceException
270:             */
271:            private static Query createQuery(Node queryNode)
272:                    throws XMLParsingException, OGCWebServiceException {
273:
274:                String feature = XMLTools.getRequiredNodeAsString(queryNode,
275:                        "@typeName", nsContext);
276:                Element filterElement = XMLTools.getChildElement(queryNode,
277:                        "ogc:Filter");
278:                ComplexFilter filter = null;
279:                if (filterElement != null) {
280:                    try {
281:                        filter = (ComplexFilter) ComplexFilter
282:                                .buildFromDOM(filterElement);
283:                    } catch (FilterConstructionException e) {
284:                        e.printStackTrace();
285:                        throw new OGCWebServiceException(
286:                                "sos:Query is not valid!");
287:                    }
288:                }
289:                return new Query(feature, filter);
290:            }
291:
292:            /**
293:             * @param id
294:             * @param version
295:             * @param sensorId
296:             * @param platformId
297:             * @param time
298:             * @param boundingBox
299:             * @param query
300:             * @param outputFormat
301:             * 
302:             */
303:            public static void create(String id, String version,
304:                    String[] sensorId, String[] platformId, Object[] time,
305:                    Envelope boundingBox, Query query, String outputFormat) {
306:                throw new UnsupportedOperationException();
307:            }
308:
309:            /**
310:             * @param query
311:             * @param boundingBox
312:             * @param outputFormat
313:             * @param time
314:             * @param platformId
315:             * @param sensorId
316:             * @param version
317:             * @param id
318:             * 
319:             */
320:            private GetObservationRequest(Query query, Envelope envelope,
321:                    String outputFormat, Object[] time, String[] platformId,
322:                    String[] sensorId, String version, String id,
323:                    Map<String, String> vendorSpecificParameter) {
324:
325:                super (version, id, vendorSpecificParameter);
326:
327:                this .envelope = envelope;
328:                this .query = query;
329:                this .time = time;
330:                this .platforms = platformId;
331:                this .sensors = sensorId;
332:                this .outputFormat = outputFormat;
333:            }
334:
335:            /**
336:             * fixed 'SOS'
337:             * 
338:             * @return the String "SOS".
339:             */
340:            public String getServiceName() {
341:                return "SOS";
342:            }
343:
344:            /**
345:             * @return
346:             */
347:            public Envelope getBBox() {
348:                return envelope;
349:            }
350:
351:            /**
352:             * @return platforms
353:             */
354:            public String[] getPlatforms() {
355:                return platforms;
356:            }
357:
358:            /**
359:             * @return query
360:             */
361:            public Query getQuery() {
362:                return query;
363:            }
364:
365:            /**
366:             * @return sensors
367:             */
368:            public String[] getSensors() {
369:                return sensors;
370:            }
371:
372:            /**
373:             * @return time
374:             */
375:            public Object[] getTime() {
376:                return time;
377:            }
378:
379:            /**
380:             * @return outputFormat
381:             */
382:            public String getOutputFormat() {
383:                return outputFormat;
384:            }
385:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.