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


001:        /*
002:         *    GeoTools - OpenSource mapping toolkit
003:         *    http://geotools.org
004:         *    (C) 2002-2006, GeoTools Project Managment Committee (PMC)
005:         * 
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         */
016:        package org.geotools.data.postgis;
017:
018:        import java.io.IOException;
019:        import java.util.Iterator;
020:        import java.util.Set;
021:        import java.util.logging.Level;
022:        import java.util.logging.Logger;
023:
024:        import org.geotools.data.postgis.fidmapper.VersionedFIDMapper;
025:        import org.geotools.feature.FeatureType;
026:        import org.geotools.filter.CompareFilter;
027:        import org.geotools.filter.FidFilter;
028:        import org.geotools.filter.Filter;
029:        import org.geotools.filter.FilterFactory;
030:        import org.geotools.filter.visitor.DuplicatorFilterVisitor;
031:
032:        /**
033:         * Takes a filter that eventually contains a fid filter and builds a new filter that does not have
034:         * it, and relies on attributes instead. This assumes pk attributes are part of the feature type.
035:         * <br>
036:         * This cloning is necessary because public FID do not contain the revision attribute, that will be
037:         * handled by including new filters.
038:         * 
039:         * @author aaime
040:         * @since 2.4
041:         * 
042:         */
043:        class FidTransformeVisitor extends DuplicatorFilterVisitor {
044:            /** The logger for the postgis module. */
045:            protected static final Logger LOGGER = org.geotools.util.logging.Logging
046:                    .getLogger("org.geotools.data.postgis");
047:
048:            private VersionedFIDMapper mapper;
049:
050:            private Object featureType;
051:
052:            public FidTransformeVisitor(FilterFactory factory,
053:                    FeatureType featureType, VersionedFIDMapper mapper) {
054:                super (factory);
055:                this .mapper = mapper;
056:                this .featureType = featureType;
057:            }
058:
059:            public void visit(FidFilter filter) {
060:                Set ids = filter.getIDs();
061:                if (ids.isEmpty()) {
062:                    throw new IllegalArgumentException(
063:                            "Invalid fid filter provides, has no fids inside");
064:                }
065:                Filter external = null;
066:                for (Iterator it = ids.iterator(); it.hasNext();) {
067:                    String id = (String) it.next();
068:                    Object[] attributes;
069:                    try {
070:                        attributes = mapper.getUnversionedPKAttributes(id);
071:                    } catch (IOException e) {
072:                        // assume the fid provided is not in the format the mapper can handle, so
073:                        // it's not really a real datastore fid but has been provided by the user.
074:                        // No harm dome, we just need to skip it
075:                        if (LOGGER.isLoggable(Level.FINE))
076:                            LOGGER.fine("Skipping fid " + id
077:                                    + " since it's not in the "
078:                                    + "proper format for this datastore"
079:                                    + e.getMessage());
080:                        continue;
081:                    }
082:                    Filter idf = null;
083:                    for (int i = 0, j = 0; i < attributes.length; j++) {
084:                        String colName = mapper.getColumnName(j);
085:                        if ("revision".equals(colName))
086:                            continue;
087:                        CompareFilter equal = ff
088:                                .createCompareFilter(Filter.COMPARE_EQUALS);
089:                        equal.addLeftValue(ff
090:                                .createAttributeExpression(colName));
091:                        equal.addRightValue(ff
092:                                .createLiteralExpression(attributes[i]));
093:                        if (idf == null)
094:                            idf = equal;
095:                        else
096:                            idf = idf.and(equal);
097:                        i++;
098:                    }
099:                    if (external == null)
100:                        external = idf;
101:                    else
102:                        external = external.or(idf);
103:                }
104:                // if all the fids are in an improper format, the fid filter is equivalent to
105:                // a Filter that excludes everything... Since I cannot use Filter.EXCLUDE (it breaks
106:                // the filter splitter with a class cast exception) I'm falling back on the old  
107:                // "1 = 0" filter (ugly, but works...)
108:                if (external == null) {
109:                    CompareFilter equal = ff
110:                            .createCompareFilter(Filter.COMPARE_EQUALS);
111:                    equal.addLeftValue(ff.createLiteralExpression(0));
112:                    equal.addRightValue(ff.createLiteralExpression(1));
113:                    pages.push(equal);
114:                } else
115:                    pages.push(external);
116:            }
117:
118:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.