Source Code Cross Referenced for VersionedFeaturePropertyExtractor.java in  » GIS » GeoServer » org » geoserver » wfsv » xml » v1_1_0 » 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.geoserver.wfsv.xml.v1_1_0 
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.geoserver.wfsv.xml.v1_1_0;
006:
007:        import java.util.ArrayList;
008:        import java.util.List;
009:        import java.util.logging.Level;
010:        import java.util.logging.Logger;
011:
012:        import org.eclipse.xsd.XSDElementDeclaration;
013:        import org.eclipse.xsd.XSDFactory;
014:        import org.eclipse.xsd.XSDParticle;
015:        import org.eclipse.xsd.XSDSchema;
016:        import org.eclipse.xsd.XSDTypeDefinition;
017:        import org.geotools.data.VersioningFeatureSource;
018:        import org.geotools.feature.Feature;
019:        import org.geotools.feature.FeatureCollection;
020:        import org.geotools.util.logging.Logging;
021:        import org.geotools.xml.PropertyExtractor;
022:        import org.geotools.xs.XSConfiguration;
023:        import org.vfny.geoserver.global.Data;
024:        import org.vfny.geoserver.global.FeatureTypeInfo;
025:
026:        /**
027:         * Extracts the extra four properties out of a versioned data type. To be used
028:         * for encoding GetVersionedFeature output
029:         * @author Andrea Aime
030:         *
031:         */
032:        public class VersionedFeaturePropertyExtractor implements 
033:                PropertyExtractor {
034:            private static final String XSD_SCHEMA = "http://www.w3.org/2001/XMLSchema";
035:
036:            private static final Logger LOGGER = Logging
037:                    .getLogger("org.geoserver.wfsv.xml.v1_1_0");
038:
039:            private static final XSDParticle CR_VERSION;
040:
041:            private static final XSDParticle CR_AUTHOR;
042:
043:            private static final XSDParticle CR_DATE;
044:
045:            private static final XSDParticle CR_MESSAGE;
046:
047:            private static final XSDParticle LU_VERSION;
048:
049:            private static final XSDParticle LU_AUTHOR;
050:
051:            private static final XSDParticle LU_DATE;
052:
053:            private static final XSDParticle LU_MESSAGE;
054:
055:            static {
056:                XSDSchema schema = new XSConfiguration().schema();
057:                CR_VERSION = particle(schema, "creationVersion", XSD_SCHEMA,
058:                        "string", true, 0, 1);
059:                CR_AUTHOR = particle(schema, "createdBy", XSD_SCHEMA, "string",
060:                        true, 0, 1);
061:                CR_DATE = particle(schema, "creationDate", XSD_SCHEMA,
062:                        "dateTime", true, 0, 1);
063:                CR_MESSAGE = particle(schema, "creationMessage", XSD_SCHEMA,
064:                        "string", true, 0, 1);
065:                LU_VERSION = particle(schema, "lastUpdateVersion", XSD_SCHEMA,
066:                        "string", true, 0, 1);
067:                LU_AUTHOR = particle(schema, "lastUpdatedBy", XSD_SCHEMA,
068:                        "string", true, 0, 1);
069:                LU_DATE = particle(schema, "lastUpdateDate", XSD_SCHEMA,
070:                        "dateTime", true, 0, 1);
071:                LU_MESSAGE = particle(schema, "lastUpdateMessage", XSD_SCHEMA,
072:                        "string", true, 0, 1);
073:            }
074:
075:            static XSDParticle particle(XSDSchema schema, String elementName,
076:                    String typeNS, String typeName, boolean nillable,
077:                    int minOccurs, int maxOccurs) {
078:                XSDFactory factory = XSDFactory.eINSTANCE;
079:                XSDElementDeclaration element = factory
080:                        .createXSDElementDeclaration();
081:                element.setName(elementName);
082:                element.setNillable(nillable);
083:
084:                XSDTypeDefinition type = schema.resolveTypeDefinition(typeNS,
085:                        typeName);
086:                element.setTypeDefinition(type);
087:
088:                XSDParticle particle = factory.createXSDParticle();
089:                particle.setMinOccurs(minOccurs);
090:                particle.setMaxOccurs(maxOccurs);
091:                particle.setContent(element);
092:                return particle;
093:            }
094:
095:            Data catalog;
096:
097:            public VersionedFeaturePropertyExtractor(Data catalog) {
098:                this .catalog = catalog;
099:            }
100:
101:            public boolean canHandle(Object object) {
102:                try {
103:                    if (!(object instanceof  Feature)
104:                            || object instanceof  FeatureCollection)
105:                        return false;
106:
107:                    Feature f = (Feature) object;
108:                    FeatureTypeInfo info = catalog.getFeatureTypeInfo(f
109:                            .getFeatureType().getTypeName(), f.getFeatureType()
110:                            .getNamespace().toString());
111:                    return info != null
112:                            && info.getFeatureSource() instanceof  VersioningFeatureSource;
113:                } catch (Exception e) {
114:                    LOGGER
115:                            .log(
116:                                    Level.FINE,
117:                                    "Error occurred trying to determine versioning status of a feature type",
118:                                    e);
119:                    return false;
120:                }
121:            }
122:
123:            public List properties(Object object, XSDElementDeclaration elem) {
124:                Feature f = (Feature) object;
125:                List particles = new ArrayList();
126:                particles.add(particleValue(f, CR_VERSION));
127:                particles.add(particleValue(f, CR_AUTHOR));
128:                particles.add(particleValue(f, CR_DATE));
129:                particles.add(particleValue(f, CR_MESSAGE));
130:                particles.add(particleValue(f, LU_VERSION));
131:                particles.add(particleValue(f, LU_AUTHOR));
132:                particles.add(particleValue(f, LU_DATE));
133:                particles.add(particleValue(f, LU_MESSAGE));
134:                return particles;
135:            }
136:
137:            private Object[] particleValue(Feature f, XSDParticle particle) {
138:                return new Object[] {
139:                        particle,
140:                        f.getAttribute(((XSDElementDeclaration) particle
141:                                .getContent()).getName()) };
142:            }
143:
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.