| 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/utils/TeDatabaseUtils.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 *************************************************************************************/
    00026 #ifndef __TERRALIB_INTERNAL_DATABASEUTILS_H
    00027 #define __TERRALIB_INTERNAL_DATABASEUTILS_H
    00028
    00029
    00030 #include "../kernel/TeDatabase.h"
    00031 #include "../kernel/TeExternalTheme.h"
    00032 #include <string>
    00033 #include <vector>
    00034
    00035 #include "TeUtilsDefines.h"
    00036
    00037 using std::string;
    00038 using std::vector;
    00039
    00040
    00050 TLUTILS_DLL bool TeCopyDatabase(TeDatabase* dbFrom, TeDatabase* dbTo);
    00051
    00052
    00056 TLUTILS_DLL bool isTerralibModel(TeDatabase* db);
    00057
    00058 TLUTILS_DLL vector<string> generateItemsInClauseVec(TeTheme* theme, string& where);
    00059
    00060 TLUTILS_DLL map<string, vector<string> > getObject2ItemsMap(TeTheme* theme, vector<string>& itens);
    00061
    00062 template <typename Iterator>
    00063 vector<string>
    00064 generateItemsInClauses(Iterator& begin, Iterator& end, TeTheme* theme)
    00065 {
    00066            vector<string> itenVec;
    00067            Iterator temp = begin;
    00068            while (temp != end)
    00069            {
    00070                       itenVec.push_back(*temp);
    00071                       temp++;
    00072            }
    00073
    00074            map<string, vector<string> > objMap = getObject2ItemsMap(theme, itenVec);
    00075            map<string, vector<string> >::iterator mit;
    00076            vector<string>::iterator it;
    00077
    00078            int i, chunkSize = 200;
    00079            string inClause;
    00080            vector<string> inClauseVector;
    00081
    00082            i = 0;
    00083            bool chunk = true;
    00084            for(mit=objMap.begin(); mit!=objMap.end(); ++mit)
    00085            {
    00086                       if (chunk == true)
    00087                       {
    00088                                  chunk = false;
    00089                                  if (!inClause.empty())
    00090                                  {
    00091                                             inClause[inClause.size() - 1] = ')';
    00092                                             inClauseVector.push_back(inClause);
    00093                                             inClause.clear();
    00094                                  }
    00095                                  inClause = "(";
    00096                       }
    00097                       for(it=mit->second.begin(); it!=mit->second.end(); ++it)
    00098                       {
    00099                                  inClause += *it + ",";
    00100                                  i++;
    00101                                  if (i%chunkSize == 0)
    00102                                             chunk = true;
    00103                       }
    00104            }
    00105            if (!inClause.empty())
    00106            {
    00107                       inClause[inClause.size() - 1] = ')';
    00108                       inClauseVector.push_back(inClause);
    00109            }
    00110            return inClauseVector;
    00111 }
    00112
    00113 TLUTILS_DLL bool loadViewSetAndThemeGroups(TeDatabase* db, const std::string& userName);
    00114
    00115 TLUTILS_DLL bool TeCopyView(TeView* view, TeDatabase* inputDatabase, const std::string& newViewName, const std::string& newViewUser, const std::set<int>& setThemeIds, TeDatabase* outputDatabase, std::vector<bool>& vecResult);
    00116
    00117 TLUTILS_DLL TeViewNode* TeCopyViewNode(TeViewNode* node, TeDatabase* inputDatabase, TeDatabase* outputDatabase, TeView* newView);
    00118
    00119 TLUTILS_DLL bool TeCopyTable(TeDatabase* inputDatabase, const std::string& inputTable, TeDatabase* outputDatabase, const std::string& outputTable);
    00120
    00122
    00123 #endif
    00124

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines