Source Code Cross Referenced for GeomGeOxygene2Oracle.java in  » GIS » GeOxygene-1.3 » fr » ign » cogit » geoxygene » datatools » oracle » 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 » GeOxygene 1.3 » fr.ign.cogit.geoxygene.datatools.oracle 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * This file is part of the GeOxygene project source files. 
003:         * 
004:         * GeOxygene aims at providing an open framework which implements OGC/ISO specifications for 
005:         * the development and deployment of geographic (GIS) applications. It is a open source 
006:         * contribution of the COGIT laboratory at the Institut Géographique National (the French 
007:         * National Mapping Agency).
008:         * 
009:         * See: http://oxygene-project.sourceforge.net 
010:         *  
011:         * Copyright (C) 2005 Institut Géographique National
012:         *
013:         * This library is free software; you can redistribute it and/or modify it under the terms
014:         * of the GNU Lesser General Public License as published by the Free Software Foundation; 
015:         * either version 2.1 of the License, or any later version.
016:         *
017:         * This library is distributed in the hope that it will be useful, but WITHOUT ANY 
018:         * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
019:         * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
020:         *
021:         * You should have received a copy of the GNU Lesser General Public License along with 
022:         * this library (see file LICENSE if present); if not, write to the Free Software 
023:         * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
024:         *  
025:         */
026:
027:        package fr.ign.cogit.geoxygene.datatools.oracle;
028:
029:        import java.sql.Connection;
030:
031:        import oracle.jdbc.driver.OracleConnection;
032:        import oracle.sdoapi.adapter.SDOGeometry;
033:        import oracle.sdoapi.adapter.SDOTemplateFactory;
034:        import oracle.sdoapi.adapter.SDOTemplateFactoryImpl;
035:        import oracle.sdoapi.geom.Geometry;
036:        import oracle.sdoapi.geom.GeometryFactory;
037:        import oracle.sdoapi.sref.SRManager;
038:        import oracle.sql.STRUCT;
039:
040:        import org.apache.ojb.broker.util.batch.BatchConnection;
041:
042:        import fr.ign.cogit.geoxygene.spatial.geomroot.GM_Object;
043:
044:        /**
045:         * Conversion dans les 2 sens entre une SDO_GEOMETRY (format sql.STRUCT) et un GM_Object.
046:         * Ceci est utilise par OJB.
047:         * 
048:         * @author Thierry Badard & Arnaud Braun
049:         * @version 1.1  
050:         *
051:         */
052:
053:        public class GeomGeOxygene2Oracle {
054:
055:            // Initialise au demarrage de la Geodatabase Oracle comme un singleton
056:            public static Connection CONNECTION;
057:            public static SRManager SRM;
058:            public static GeometryFactory GF;
059:
060:            public static Object sqlToJava(Object object) {
061:                try {
062:                    Geometry sdoGeom = SDOGeometry.STRUCTtoGeometry(
063:                            (STRUCT) object, GF, SRM);
064:                    GM_Object isoGeom = IsoAndSdo.sdoapi2iso(sdoGeom);
065:                    return isoGeom;
066:                } catch (Exception e) {
067:                    e.printStackTrace();
068:                    return null;
069:                }
070:            }
071:
072:            /** Methode utilisee si on n'utilise PAS les classes maison "OxygenePresistenceBroker" et "GeOxygeneStatementManager".
073:             * Ceci est a definir dans OJB.properties.
074:             * Inconvenient : on utilise une variable connection statique, 
075:             * donc impossible de se connecter a plusieurs bases Oracle simultanement.
076:             * De plus il y a un bug avec OJB : impossible d'ecrire des geometries nulles.
077:             */
078:            public static Object javaToSql(Object object) {
079:                try {
080:                    Geometry sdoGeom = IsoAndSdo.iso2sdoapi(GF,
081:                            (GM_Object) object);
082:                    SDOTemplateFactory sdoTF;
083:                    if (CONNECTION instanceof  BatchConnection) {// ceci est pour OJB
084:                        OracleConnection oConn = (OracleConnection) ((BatchConnection) CONNECTION)
085:                                .getDelegate();
086:                        sdoTF = new SDOTemplateFactoryImpl(oConn);
087:                    } else
088:                        sdoTF = new SDOTemplateFactoryImpl(
089:                                (OracleConnection) CONNECTION);
090:
091:                    STRUCT str = SDOGeometry.geometryToSTRUCT(sdoGeom, sdoTF);
092:                    return str;
093:                } catch (Exception e) {
094:                    e.printStackTrace();
095:                    return null;
096:                }
097:            }
098:
099:            /** Methode utilisee si on utilise les classes maison "GeOxygenePresistenceBroker" et "GeOxygeneStatementManager".
100:             * Ceci est a definir dans OJB.properties.
101:             * Ceci corrige les deux defauts de la methode qui ne passe pas de connection en parametre.
102:             */
103:            public static Object javaToSql(Object object, Connection conn) {
104:                try {
105:                    Geometry sdoGeom = IsoAndSdo.iso2sdoapi(GF,
106:                            (GM_Object) object);
107:                    SDOTemplateFactory sdoTF;
108:                    if (conn instanceof  BatchConnection) {// ceci est pour OJB
109:                        OracleConnection oConn = (OracleConnection) ((BatchConnection) conn)
110:                                .getDelegate();
111:                        sdoTF = new SDOTemplateFactoryImpl(oConn);
112:                    } else
113:                        sdoTF = new SDOTemplateFactoryImpl(
114:                                (OracleConnection) conn);
115:
116:                    STRUCT str = SDOGeometry.geometryToSTRUCT(sdoGeom, sdoTF);
117:                    return str;
118:                } catch (Exception e) {
119:                    e.printStackTrace();
120:                    return null;
121:                }
122:            }
123:
124:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.