| TerraLib 4.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files
- Examples

- File List
- File Members

E:/Projetos_Primeiro_Semestre_2012/TerraView/terralib/src/terralib/drivers/Oracle/TeOCIOracle.h
Go to the documentation of this file.

    00001 /************************************************************************************
    00002 TerraLib - a library for developing GIS applications.
    00003 Copyright ? 2001-2007 INPE and Tecgraf/PUC-Rio.
    00004
    00005 This code is part of the TerraLib library.
    00006 This library is free software; you can redistribute it and/or
    00007 modify it under the terms of the GNU Lesser General Public
    00008 License as published by the Free Software Foundation; either
    00009 version 2.1 of the License, or (at your option) any later version.
    00010
    00011 You should have received a copy of the GNU Lesser General Public
    00012 License along with this library.
    00013
    00014 The authors reassure the license terms regarding the warranties.
    00015 They specifically disclaim any warranties, including, but not limited to,
    00016 the implied warranties of merchantability and fitness for a particular purpose.
    00017 The library provided hereunder is on an "as is" basis, and the authors have no
    00018 obligation to provide maintenance, support, updates, enhancements, or modifications.
    00019 In no event shall INPE and Tecgraf / PUC-Rio be held liable to any party for direct,
    00020 indirect, special, incidental, or consequential damages arising out of the use
    00021 of this library and its documentation.
    00022 *************************************************************************************/
    00027 #ifndef  __TERRALIB_INTERNAL_ORACLEOCI_H
    00028 #define  __TERRALIB_INTERNAL_ORACLEOCI_H
    00029
    00030 //#include "TeOCIConnect.h"
    00031 //#include "TeOCICursor.h"
    00032 #include <TeDatabase.h>
    00033 #include <TeDatabaseFactory.h>
    00034
    00035 #include <TeDatabaseIndex.h>
    00036
    00037 #include "TeOracleDefines.h"
    00038
    00039
    00040 class TeOCIConnect;
    00041 class TeOCICursor;
    00042 class TeOCIConnection;
    00043
    00044 #ifdef AFX_DLL
    00045 #define EXPORT_WIN __declspec( dllexport )
    00046 #else
    00047 #define EXPORT_WIN
    00048 #endif
    00049
    00061 class TLORACLE_DLL TeOCIOracle : public TeDatabase
    00062 {
    00063
    00064 friend class TeOCIOraclePortal;
    00065
    00066 protected:
    00067
    00068            TeOCIConnection*      connection_;
    00069            long                                        sequenceCont_;
    00070            string                                      sequenceName_;
    00071
    00073            bool       createSequence(const string &seqName);
    00074
    00076            bool       createAutoIncrementTrigger(const string &tableName, const string &fieldName);
    00077
    00079            string     getNameSequence(const string &tableName);
    00080
    00082            string  getNameTrigger(const string &tableName);
    00083
    00084 public:
    00085
    00087            TeOCIOracle();
    00088
    00090            ~TeOCIOracle();
    00091
    00093            string  escapeSequence(const string& from);
    00094
    00096            bool beginTransaction();
    00097
    00099            bool commitTransaction();
    00100
    00102            bool rollbackTransaction();
    00103
    00105            virtual bool newDatabase(const string& database, const string& user, const string& password, const string& host, const int& port=0, bool terralibModel=true, const std::string& characterSet = "");
    00106
    00108            virtual bool connect (const string& host, const string& user, const string& password, const string& database, int port = 0);
    00109
    00111            bool listTables(vector<string>& tableList);
    00112
    00114            void  close();
    00115
    00117            bool tableExist(const string& table);
    00118
    00120            bool viewExist(const string& view);
    00121
    00123            bool columnExist(const string& table, const string& column, TeAttribute& attr);
    00124
    00126            virtual bool createTable (const string& table, TeAttributeList &attr);
    00127
    00129            bool addColumn (const string& table,TeAttributeRep &rep);
    00130
    00132            bool deleteTable (const string& table);
    00133
    00135            bool execute (const string &sql);
    00136
    00138            virtual TeDatabasePortal* getPortal();
    00139
    00141            TeDBRelationType existRelation(const string& tableName, const string& relName);
    00142
    00144            bool createRelation (const string& name, const string& table, const string& fieldName, const string& relatedTable, const string& relatedField, bool cascadeDeletion);
    00145
    00147            virtual bool getIndexesFromTable(const string& tableName, std::vector<TeDatabaseIndex>& vecIndexes);
    00148
    00149
    00153            bool insertTableInfo (int layerId, TeTable &table, const string& user="");
    00154            bool insertRelationInfo(const int tableId, const string& tField, const string& rName, const string& rField, int& relId);
    00155            bool alterTable (const string& table, TeAttributeRep &rep, const string& oldColName);
    00156            bool alterTable (const string& oldTableName, const string& newTablename);
    00157            bool insertTable      (TeTable &table);
    00158            bool updateTable      (TeTable &table);
    00159            bool insertProjection (TeProjection *proj);
    00160            bool insertRepresentation (int layerId, TeRepresentation& rep);
    00161            bool insertLegend     (TeLegendEntry *legend);
    00162            bool insertView                  (TeView *view);
    00163            bool insertViewTree (TeViewTree *tree);
    00164            bool insertTheme                 (TeAbstractTheme *theme);
    00165            bool insertThemeTable (int themeId, int tableId, int relationId, int tableOrder);
    00166            bool insertThemeGroup (TeViewTree* tree);
    00167            bool insertLayer      (TeLayer *layer);
    00168            bool insertProject    (TeProject *project);
    00169            bool deleteLayer      (int layerId);
    00171
    00173            virtual bool generateLabelPositions         (TeTheme *theme, const std::string& objectId = "");
    00174
    00178            bool getValueSequence(const string& table);
    00179            virtual bool insertPolygonSet(const string& table, TePolygonSet &ps);
    00180            virtual bool insertPolygon                  (const string& table, TePolygon &p);
    00181            virtual bool updatePolygon                  (const string& table, TePolygon &p);
    00182            virtual bool insertLineSet(const string& table, TeLineSet &ls);
    00183            virtual bool insertLine (const string& table, TeLine2D &l);
    00184            virtual bool updateLine                     (const string& table, TeLine2D &l);
    00185            virtual bool insertPoint         (const string& table, TePoint &p);
    00186            virtual bool insertText                     (const string& table, TeText &t);
    00187            virtual bool insertArc           (const string& table,TeArc &arc);
    00188            virtual bool insertNode                     (const string& table, TeNode &node);
    00189            virtual bool insertCell                     (const string& table, TeCell &c);
    00190            virtual bool insertRasterBlock(const string& table, const string& blockId, const TeCoord2D& ll, const TeCoord2D& ur, unsigned char *buf,unsigned long size, int band=0, unsigned int res=1, unsigned int subband=0);
    00192
    00196            bool insertBlob (const string& tableName, const string& columnBlob, const string& whereClause, unsigned char* data, int size);
    00198
    00202            string getSQLStatistics (TeGroupingAttr& attrs);
    00203            string  getSQLAutoNumber(const string& table);
    00204            string  getSQLTime(const TeTime& time) const;
    00205            string toUpper(const string& value);
    00207
    00209            string concatValues(vector<string>& values, const string& unionString);
    00210
    00212            virtual bool getAttributeList(const string& tableName,TeAttributeList& attList);
    00213 };
    00214
    00215
    00227 class TLORACLE_DLL TeOCIOraclePortal : public TeDatabasePortal
    00228 {
    00229 protected:
    00230            TeOCICursor                      *cursor_;
    00231            long                             curRow_;
    00232
    00234            bool isConnected();
    00235
    00237            bool isEOF();
    00238
    00240            bool getLinearRing (TeLine2D& line);
    00242            bool getLinearRing (TeLine2D& line, const unsigned int& i);
    00243
    00244 public:
    00245
    00247            TeOCIOraclePortal(TeOCIOracle *pDatabase);
    00248
    00250            virtual ~TeOCIOraclePortal();
    00251
    00253            TeOCICursor* getCursor() { return cursor_; }
    00254
    00256            bool moveFirst();
    00257
    00259     bool moveNext();
    00260
    00262            bool query ( const string &q,TeCursorLocation l = TeSERVERSIDE, TeCursorType t = TeUNIDIRECTIONAL, TeCursorEditType e = TeREADONLY, TeCursorDataType dt = TeTEXTCURSOR );
    00263
    00265            bool fetchRow ();
    00266
    00268            bool fetchRow (int i);
    00269
    00271            void freeResult();
    00272
    00276            char* getData (int i);
    00277            char* getData (const string& s);
    00278            double getDouble (int i);
    00279            double getDouble (const string& s);
    00280            int        getInt (int i);
    00281            int        getInt (const string& s);
    00282            bool getBool (const string& s);
    00283            bool getBool (int i);
    00284            bool getBlob(const string& s, unsigned char* &data, long& size);
    00285            TeTime getDate (int i);
    00286            TeTime getDate (const string& s);
    00287            string getDateAsString(int i);
    00288            string getDateAsString(const string& s);
    00290
    00294            virtual bool fetchGeometry (TePolygon& poly);
    00295            virtual bool fetchGeometry (TeLine2D& line);
    00296            virtual bool fetchGeometry (TePoint& p);
    00297     virtual bool fetchGeometry (TeNode& n);
    00298            virtual bool fetchGeometry (TePolygon& poly, const unsigned int& initIndex);
    00299            virtual bool fetchGeometry (TeLine2D& line, const unsigned int& initIndex);
    00300            virtual bool fetchGeometry (TePoint& p, const unsigned int& initIndex);
    00301     virtual bool fetchGeometry (TeNode& n, const unsigned int& initIndex);
    00303
    00305            bool getRasterBlock(unsigned long& size, unsigned char*);
    00306 };
    00307
    00308
    00314 class TLORACLE_DLL TeOCIOracleFactory : public TeDatabaseFactory
    00315 {
    00316   public :
    00317
    00321     TeOCIOracleFactory() : TeDatabaseFactory( std::string( "OracleOCI" ) ) {};
    00322
    00326     ~TeOCIOracleFactory() {};
    00327
    00328   protected :
    00329
    00337     TeDatabase* build( const TeDatabaseFactoryParams& arg )
    00338     {
    00339       TeOCIOracle* instance_ptr = new TeOCIOracle();
    00340
    00341       if( arg.host_ != "" ) {
    00342         instance_ptr->connect( arg.host_, arg.user_, arg.password_,
    00343           arg.database_, arg.port_ );
    00344       }
    00345
    00346       return (TeDatabase*)instance_ptr;
    00347     }
    00348 };
    00349
    00350 namespace {
    00351   static TeOCIOracleFactory TeOCIOracleFactory_instance;
    00352 };
    00353
    00354 #endif
    00355
    00356
    00357

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines