本文整理汇总了C++中TeDatabasePortal类的典型用法代码示例。如果您正苦于以下问题:C++ TeDatabasePortal类的具体用法?C++ TeDatabasePortal怎么用?C++ TeDatabasePortal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TeDatabasePortal类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: needUpdateDB
bool needUpdateDB(TeDatabase* db, string& DBversion)
{
TeDatabasePortal* portal = db->getPortal();
if(!portal)
return false;
string sql = " SELECT db_version FROM te_database ";
//The database does not have the te_database connection
if(!portal->query(sql))
{
DBversion = "";
delete portal;
return false;
}
if(!portal->fetchRow())
{
DBversion = "";
delete portal;
return true;
}
DBversion = portal->getData(0);
if(DBversion==TeDBVERSION)
{
delete portal;
return false;
}
delete portal;
return true;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:32,代码来源:TeUpdateDBVersion.cpp
示例2: insertRelationInfo
bool TeSQLite::insertRelationInfo(const int tableId, const string& tField, const string& rTable, const string& rField, int& relId)
{
if(tableId < 0)
{
return false;
}
// check if relation already exists
TeDatabasePortal* portal = this->getPortal();
if(!portal)
return false;
relId = -1;
string sel = "SELECT relation_id FROM te_tables_relation WHERE";
sel += " related_table_id = " + Te2String(tableId);
sel += " AND related_attr = '" + tField + "'";
sel += " AND external_table_name = '" + rTable + "'";
sel += " AND external_attr = '" + rField + "'";
if(!portal->query(sel))
{
delete portal;
return false;
}
if(portal->fetchRow())
{
relId = atoi(portal->getData("relation_id"));
delete portal;
return true;
}
delete portal;
string sql = "INSERT INTO te_tables_relation (related_table_id, related_attr, external_table_name, external_attr) VALUES(";
sql += Te2String(tableId);
sql += ", '";
sql += tField;
sql += "', '";
sql += rTable;
sql += "', '";
sql += rField;
sql += "')";
if(this->execute(sql))
{
//int newId = getMaxValue(this, "te_tables_relation", "relation_id");
int newId = getLastInsertedSerial();
if(newId >= 0)
{
relId = newId;
}
}
else
return false;
return true;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:59,代码来源:TeSQLite.cpp
示例3: getObjects
vector<string> getObjects(TeTheme* theme, vector<string>& itens)
{
vector<string> svec;
if(!theme)
return svec;
TeDatabase* db = 0;
if(theme->getProductId() == TeEXTERNALTHEME)
db = static_cast<TeExternalTheme*>(theme)->getSourceDatabase();
else if(theme->getProductId() == TeTHEME)
db = static_cast<TeTheme*>(theme)->layer()->database();
if(db == 0)
return svec;
TeDatabasePortal* portal = db->getPortal();
string C = theme->collectionTable();
string CA = theme->collectionAuxTable();
string query = "SELECT " + C + ".c_object_id FROM " + C + " LEFT JOIN " + CA;
query += " ON " + C + ".c_object_id = " + CA + ".object_id";
query += " WHERE " + CA + ".unique_id IN ";
set<string> idSet;
vector< string >::iterator it_begin = itens.begin();
vector< string >::iterator it_end = itens.end();
vector<string> inVec = generateInClauses(it_begin, it_end, db, false);
vector<string>::iterator it;
for(it=inVec.begin(); it!=inVec.end(); ++it)
{
if((*it).empty() == false)
{
string sel = query + *it;
if (portal->query(sel) == false)
{
delete portal;
return svec;
}
while (portal->fetchRow())
idSet.insert(portal->getData(0));
portal->freeResult();
}
}
delete portal;
set<string>::iterator sit;
for(sit=idSet.begin(); sit!=idSet.end(); ++sit)
svec.push_back(*sit);
return svec;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:52,代码来源:TeThemeFunctions.cpp
示例4: updateDB30To301
bool updateDB30To301(TeDatabase* db, string& errorMessage)
{
TeAttribute fattr;
TeDatabasePortal* portal = db->getPortal();
if(!portal)
return false;
// ----- collection_table
string sql = " SELECT collection_table FROM te_theme ";
if(!portal->query(sql))
{
delete portal;
return false;
}
while(portal->fetchRow())
{
string collName = portal->getData(0);
if( (db->tableExist(collName)) &&
(!db->columnExist(collName, "c_object_status", fattr)))
{
TeAttributeRep atRep;
atRep.type_ = TeINT;
atRep.name_ = "c_object_status";
if(db->addColumn(collName, atRep) == false)
{
errorMessage = "The column c_object_status could not be appended!\n";
errorMessage += db->errorMessage();
delete portal;
return false;
}
string upd = " UPDATE "+collName+" t1, "+collName+" t2 ";
upd += " SET t1.c_object_status = t2.c_legend_result ";
upd += " WHERE t1.c_object_id = t2.c_object_id ";
if(!db->execute (upd))
{
errorMessage = db->errorMessage();
delete portal;
return false;
}
db->deleteColumn(collName, "c_legend_result");
}
}
delete portal;
return true;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:52,代码来源:TeUpdateDBVersion.cpp
示例5: getItems
vector<string> getItems(TeTheme* theme, int sel)
{
vector<string> svec;
if(!theme)
return svec;
TeDatabase* db = 0;
if(theme->getProductId() == TeEXTERNALTHEME)
db = static_cast<TeExternalTheme*>(theme)->getSourceDatabase();
else if(theme->getProductId() == TeTHEME)
db = static_cast<TeTheme*>(theme)->layer()->database();
if(db == 0)
return svec;
string C = theme->collectionTable();
string CA = theme->collectionAuxTable();
string input;
if(sel == TeSelectedByPointing)
input += " WHERE " + CA + ".grid_status = 1 OR " + CA + ".grid_status = 3";
else if(sel == TeNotSelectedByPointing)
input += " WHERE " + CA + ".grid_status = 0 OR " + CA + ".grid_status = 2";
else if(sel == TeSelectedByQuery)
input += " WHERE " + CA + ".grid_status = 2 OR " + CA + ".grid_status = 3";
else if(sel == TeNotSelectedByQuery)
input += " WHERE " + CA + ".grid_status = 0 OR " + CA + ".grid_status = 1";
else if(sel == TeSelectedByPointingAndQuery)
input += " WHERE " + CA + ".grid_status = 3";
else if(sel == TeSelectedByPointingOrQuery)
input += " WHERE " + CA + ".grid_status <> 0";
else if(sel == TeGrouped)
input += " WHERE " + C + ".c_legend_id <> 0";
else if(sel == TeNotGrouped)
input += " WHERE " + C + ".c_legend_id = 0";
string query = "SELECT " + CA + ".unique_id FROM " + C + " LEFT JOIN " + CA;
query += " ON " + C + ".c_object_id = " + CA + ".object_id" + input;
TeDatabasePortal* portal = db->getPortal();
if (portal->query(query) == false)
{
delete portal;
return svec;
}
while (portal->fetchRow())
svec.push_back(portal->getData(0));
delete portal;
return svec;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:51,代码来源:TeThemeFunctions.cpp
示例6: deleteLayerTableName
/// UTILIITARY FUNCTION - Deletes a table from a TerraLib geographical database.
/// \param db is a pointer to a TerraLib database
/// \param tableName is the name of the table being removed
/// \return Return true in case of sucess, otherwise it returns false.
bool deleteLayerTableName ( TeDatabase *db, std::string &tableName )
{
TeDatabasePortal* portal = db->getPortal();
if( !portal )
return false;
string query = "SELECT attr_table, table_id FROM te_layer_table WHERE attr_table = '" + tableName + "'";
if( !portal->query( query ) )
{
delete portal;
return false;
}
vector<int> tableIds;
string attrTable;
string tableId;
string drop;
while ( portal->fetchRow() )
{
attrTable = portal->getData(0);
tableId = portal->getData(1);
//drop = "DROP TABLE " + attrTable;
if( db->tableExist( attrTable ) )
{
if( !db->deleteTable( attrTable ) ) //if( !db->execute( drop ) )
{
cout << "Error: fail to delete table \"" << attrTable
<< db->errorMessage() << endl;
db->close();
delete portal;
return false;
}
}
tableIds.push_back( atoi ( tableId.c_str() ) );
string del = "DELETE FROM te_layer_table WHERE table_id = "+ tableId;
db->execute(del);
}
delete portal;
string del;
del = "DELETE FROM te_layer_table WHERE attr_table = '" + tableName + "'";
if ( !db->execute ( del ) )
return false;
return true;
}
开发者ID:saraiva3,项目名称:terrame,代码行数:52,代码来源:luaUtils.cpp
示例7: getMaxValue
int getMaxValue(TeDatabase* database, const std::string& tableName, const std::string& intColumnName)
{
TeDatabasePortal* portal = database->getPortal();
std::string sql = "SELECT MAX(" + intColumnName + ") FROM " + tableName;
int maxVal = 0;
if(portal->query(sql) && portal->fetchRow())
{
maxVal = portal->getInt(0);
}
delete portal;
return maxVal;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:16,代码来源:TeSQLite.cpp
示例8: getAttributeList
bool TeSQLite::getAttributeList(const string& tableName,TeAttributeList& attList)
{
if(!tableExist(tableName))
{
return false;
}
TeDatabasePortal* portal = this->getPortal();
if (!portal)
return false;
string sql = "PRAGMA table_info(" + tableName + ")";
if (!portal->query(sql))
{
delete portal;
return false;
}
while(portal->fetchRow())
{
TeAttribute attr;
attr.rep_.name_ = portal->getData("name");
attr.rep_.isPrimaryKey_ = portal->getBool("pk");
attr.rep_.null_ = !portal->getBool("notnull");
attr.rep_.defaultValue_ = portal->getData("dflt_value");
std::string type = portal->getData("type");
if(type == "TEXT")
{
attr.rep_.type_ = TeSTRING;
}
else if(type == "INTEGER")
{
attr.rep_.type_ = TeINT;
}
else if(type == "REAL")
{
attr.rep_.type_ = TeREAL;
}
else if(type == "BLOB")
{
attr.rep_.type_ = TeBLOB;
}
else
{
attr.rep_.type_ = TeSTRING;
}
attList.push_back(attr);
}
delete portal;
return true;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:55,代码来源:TeSQLite.cpp
示例9: upper
bool TeSQLite::tableExist(const string& table)
{
std::string sql = "SELECT tbl_name FROM sqlite_master";
sql += " WHERE upper(tbl_name) = upper('" + table + "')";
sql += " AND type = 'table'";
bool exists = false;
TeDatabasePortal* portal = getPortal();
if(portal->query(sql) && portal->fetchRow())
{
exists = true;
}
delete portal;
return exists;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:18,代码来源:TeSQLite.cpp
示例10: getPortal
bool TeSQLite::getIndexesFromTable(const string& tableName, std::vector<TeDatabaseIndex>& vecIndexes)
{
TeDatabasePortal* portal = getPortal();
std::string sqlIndexes = "PRAGMA index_list(" + tableName + ");";
if(portal->query(sqlIndexes) == false)
{
delete portal;
return false;
}
while(portal->fetchRow())
{
TeDatabaseIndex dbIndex;
dbIndex.setIndexName(portal->getData("name"));
vecIndexes.push_back(dbIndex);
}
portal->freeResult();
for(unsigned int i = 0; i < vecIndexes.size(); ++i)
{
std::string sqlIndex = "PRAGMA index_info(" + vecIndexes[i].getIndexName() + ");";
if(portal->query(sqlIndex) == false)
{
delete portal;
return false;
}
std::vector<std::string> vecColumns;
while(portal->fetchRow())
{
vecColumns.push_back(portal->getData("name"));
}
portal->freeResult();
vecIndexes[i].setColumns(vecColumns);
}
delete portal;
return true;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:45,代码来源:TeSQLite.cpp
示例11: PrintSilent
aRTconn::aRTconn(string user, string pass, unsigned port, string host, string dbms)
{
PrintSilent("Trying to connect ... ");
User = user;
Password = pass;
Port = port;
Host = host;
if (dbms == "mysql") { Type = aRTmySQL; if(!port) Port=3306; }
else if(dbms == "postgre") { Type = aRTpostgres; if(!port) Port=5432; }
else if(dbms == "postgis") { Type = aRTpostgis; if(!port) Port=5432; }
//else error("Invalid database type: %s\n", dbms.c_str());
TeDatabase* database = NewTeDatabase();
// vector<string> db_names;
bool Valid = database->connect(Host, User, Password, "", Port);
if (!Valid)
{
PrintSilentNo;
string error_msg = database -> errorMessage();
delete database;
error(error_msg.c_str());
}
PrintSilentYes;
string query = "SELECT VERSION()";
TeDatabasePortal* portal = database->getPortal();
portal->query(query);
portal->fetchRow();
PrintSilent("Connected to %s version %s\n", dbms.c_str(), portal->getData(0));
delete database;
}
开发者ID:pedro-andrade-inpe,项目名称:aRT-old,代码行数:38,代码来源:aRTconn.cpp
示例12: updateDB331To400
bool updateDB331To400(TeDatabase* db, string& errorMessage)
{
TeDatabasePortal* portal = db->getPortal();
if(!portal)
return false;
string sql = " SELECT geom_table FROM te_representation WHERE geom_type = 512 ";
//The database does not have the te_database connection
if(!portal->query(sql))
{
delete portal;
return false;
}
while(portal->fetchRow())
{
std::string rasterTableName = portal->getData(0);
TeDatabasePortal* portalRaster = db->getPortal();
if(!portalRaster)
{
delete portal;
return false;
}
if(db->tableExist(rasterTableName) == false)
continue;
string sql = " SELECT lut_table FROM " + rasterTableName;
//The database does not have the te_database connection
if(!portalRaster->query(sql))
{
delete portal;
delete portalRaster;
return false;
}
while(portalRaster->fetchRow())
{
TeAttribute attr;
// ----- raster_metadata
std::string rasterMetadaTable = rasterTableName + "_metadata";
if(db->columnExist(rasterMetadaTable, "band_name", attr) == false)
{
TeAttributeRep attRep;
attRep.name_ = "band_name";
attRep.type_ = TeSTRING;
attRep.numChar_ = 255;
if(db->addColumn(rasterMetadaTable, attRep) == false)
{
errorMessage = "The column band_name could not be appended!\n";
errorMessage += db->errorMessage();
delete portal;
delete portalRaster;
return false;
}
}
// ----- raster_lut
std::string rasterLutTable = portalRaster->getData(0);
if(db->tableExist(rasterLutTable))
{
if(db->columnExist(rasterLutTable, "class_name", attr) == false)
{
TeAttributeRep attRep;
attRep.name_ = "class_name";
attRep.type_ = TeSTRING;
attRep.numChar_ = 255;
if(db->addColumn(rasterLutTable, attRep) == false)
{
errorMessage = "The column class_name could not be appended!\n";
errorMessage += db->errorMessage();
delete portal;
delete portalRaster;
return false;
}
}
}
}
delete portalRaster;
}
delete portal;
return true;
}
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:95,代码来源:TeUpdateDBVersion.cpp
示例13: GET_STRING_ELEMENT
SEXP aRTconn::GetPermissions(SEXP data)
{
SEXP result;
SEXP *each_column;
SEXP colnames;
SEXP rownames;
string query;
string user = GET_STRING_ELEMENT(data, "user" );
bool global = GET_BOOL_ELEMENT (data, "global");
TeDatabase* db = NewTeDatabase();
if( !db -> connect(Host, User, Password, "", Port))
error("Could not connect\n");
TeDatabasePortal* portal = db->getPortal();
if(global)
query = "select Host,User,Password,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv from mysql.user";
else
query = "select Host,User,Db,Select_priv,Insert_priv,Update_priv,Delete_priv,Create_priv from mysql.db";
if(user != "")
{
query += " where user= \"";
query += user;
query += "\";";
}
else
{
query += ";";
}
portal->query(query);
each_column = new SEXP[8];
colnames = PROTECT(allocVector( STRSXP, 8 ));
result = PROTECT(allocVector( VECSXP, 8 ));
rownames = PROTECT(allocVector( STRSXP, portal->numRows() ));
for(int i = 0; i < 8; i++)
each_column[i] = PROTECT(allocVector( STRSXP, portal->numRows() ));
SET_STRING_ELT(colnames, 0, mkChar("host" ));
SET_STRING_ELT(colnames, 1, mkChar("user" ));
SET_STRING_ELT(colnames, 2, mkChar(global? "password": "db"));
SET_STRING_ELT(colnames, 3, mkChar("select" ));
SET_STRING_ELT(colnames, 4, mkChar("insert" ));
SET_STRING_ELT(colnames, 5, mkChar("update" ));
SET_STRING_ELT(colnames, 6, mkChar("delete" ));
SET_STRING_ELT(colnames, 7, mkChar("create" ));
for(int i = 0; i != portal->numRows(); i++)
{
portal->fetchRow();
string host = portal->getData(0);
if(host == "%") host = "<any>";
SET_STRING_ELT( each_column[0], i, mkChar(host.c_str()) );
// user
SET_STRING_ELT( each_column[1], i, mkChar(portal->getData(1)) );
if(global)
{
string password = portal->getData(2);
password = password == ""? "No" : "Yes";
SET_STRING_ELT( each_column[2], i, mkChar(password.c_str()) );
}
else
{
string db = portal->getData(2);
SET_STRING_ELT( each_column[2], i, mkChar(db.c_str()) );
}
for(unsigned j = 3; j != 8; j++)
{
string value = portal->getData(j);
if(value == "Y") value = "Yes";
if(value == "N") value = "No";
SET_STRING_ELT( each_column[j], i, mkChar(value.c_str()) );
}
stringstream str;
str << i+1; // rownames must start from 1
SET_STRING_ELT(rownames, i, mkChar(str.str().c_str()));
}
setAttrib(result, R_NamesSymbol, colnames);
for(unsigned j = 0; j != 8; j++)
SET_VECTOR_ELT(result, j, each_column[j]);
result = AsDataFrame(result, rownames);
UNPROTECT(11);
delete[] each_column;
delete db;
//.........这里部分代码省略.........
开发者ID:pedro-andrade-inpe,项目名称:aRT-old,代码行数:101,代码来源:aRTconn.cpp
示例14: updateDB302To310
//.........这里部分代码省略.........
if(!PostgreSQLUpdateDB302To310(db, TeLINES, geomTableName))
{
db->execute("ROLLBACK TRANSACTION");
return false;
}
}
// update polygon geometry table
rep = itLayer->second->getRepresentation(TePOLYGONS);
if(rep)
{
string geomTableName = rep->tableName_;
if(!PostgreSQLUpdateDB302To310(db, TePOLYGONS, geomTableName))
{
db->execute("ROLLBACK TRANSACTION");
return false;
}
}
// update raster geometry table
rep = itLayer->second->getRepresentation(TeRASTER);
if(rep)
{
string rasterGeomTableName = rep->tableName_;
string sql = "SELECT raster_table FROM " + rasterGeomTableName;
TeDatabasePortal* p = db->getPortal();
if(!p)
{
db->execute("ROLLBACK TRANSACTION");
return false;
}
if(!p->query(sql))
{
delete p;
db->execute("ROLLBACK TRANSACTION");
return false;
}
while(p->fetchRow())
{
string geomTableName = p->getData(0);
if(!PostgreSQLUpdateDB302To310(db, TeRASTER, geomTableName))
{
delete p;
db->execute("ROLLBACK TRANSACTION");
return false;
}
}
delete p;
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:67,代码来源:TeUpdateDBVersion.cpp
示例15: PostgreSQLUpdateDB302To310
bool PostgreSQLUpdateDB302To310(TeDatabase* db, TeGeomRep rep, const string& geomTableName)
{
string geomColumnName = "spatial_box";
if(rep & TeRASTER)
geomColumnName = "block_box";
TeAttribute attr;
// verifies if table already has a box column
if(db->columnExist(geomTableName, geomColumnName, attr))
return true;
// add box column
string sql = "ALTER TABLE " + geomTableName;
sql += " ADD COLUMN " + geomColumnName + " BOX";
if(!db->execute(sql))
return false;
// make sure box column exist
if(!db->columnExist(geomTableName, geomColumnName, attr))
return false;
// populate column with values from older one
sql = "UPDATE " + geomTableName;
if(rep & TePOINTS)
sql += " SET " + geomColumnName + " = box(point(x, y), point(x, y))";
else
sql += " SET " + geomColumnName + " = box(point(upper_x, upper_y), point(lower_x, lower_y))";
if(!db->execute(sql))
return false;
// check if there is no null values
sql = "SELECT * FROM " + geomTableName;
sql += " WHERE " + geomColumnName + " IS NULL";
TeDatabasePortal* p = db->getPortal();
if(!p)
return false;
if(!p->query(sql))
{
delete p;
return false;
}
if(p->fetchRow())
{
delete p;
return false;
}
delete p;
// add not null for box column
sql = "ALTER TABLE " + geomTableName;
sql += " ALTER COLUMN " + geomColumnName + " SET NOT NULL";
if(!db->execute(sql))
return false;
// create GiST index
if(!db->createSpatialIndex(geomTableName, geomColumnName))
return false;
// for points is enough
if(rep & TePOINTS)
return true;
// drop older B-Tree index
sql = "DROP INDEX " + geomTableName + "_idx_box";
if(!db->execute(sql))
return false;
// drop older box column
sql = "ALTER TABLE " + geomTableName;
sql += " DROP COLUMN lower_x";
if(!db->execute(sql))
return false;
sql = "ALTER TABLE " + geomTableName;
sql += " DROP COLUMN lower_y";
if(!db->execute(sql))
return false;
sql = "ALTER TABLE " + geomTableName;
sql += " DROP COLUMN upper_x";
if(!db->execute(sql))
return false;
//.........这里部分代码省略.........
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:101,代码来源:TeUpdateDBVersion.cpp
示例16: updateDB301To302
bool updateDB301To302(TeDatabase* db, string& errorMessage)
{
TeDatabasePortal* portal = db->getPortal();
if(!portal)
return false;
// ----- valid attribute table
TeAttrTableVector attrTableVec;
if(db->getAttrTables(attrTableVec))
{
for(unsigned int i=0; i<attrTableVec.size(); ++i)
{
TeTable fromTable = attrTableVec[i];
bool flag = false;
if(fromTable.tableType()==TeAttrMedia)
continue;
//verify if there is another table with the same name
for(unsigned int j=0; j<i; ++j)
{
if(TeConvertToUpperCase(attrTableVec[j].name())==TeConvertToUpperCase(fromTable.name()))
{
flag = true;
break;
}
}
if(flag)
continue;
if(db->validTable(fromTable)) //fromTable was modified
{
TeAttributeList newAttrList = fromTable.attributeList();
TeAttributeList oldAttrList = attrTableVec[i].attributeList();
TeAttributeList::iterator newAttIt = newAttrList.begin();
TeAttributeList::iterator oldAttIt = oldAttrList.begin();
bool change = false;
while(newAttIt!=newAttrList.end())
{
if(((*oldAttIt).rep_.name_) != ((*newAttIt).rep_.name_))
{
TeAttributeRep rep = (*newAttIt).rep_;
if(db->alterTable(fromTable.name(), rep, (*oldAttIt).rep_.name_))
change = true;
}
++newAttIt;
++oldAttIt;
}
if(change)
{
// update te_layer_table
string upd = " UPDATE te_layer_table ";
upd += " SET unique_id = '"+ fromTable.uniqueName() +"'";
upd += ", attr_link = '"+ fromTable.linkName() +"'";
upd += " WHERE attr_table = '"+ fromTable.name() +"'";
if(!db->execute (upd))
{
delete portal;
errorMessage = "Error updating te_layer_table!\n";
errorMessage += db->errorMessage();
return false;
}
}
}//if
}//for
portal->freeResult();
}
// ----- te_grouping table
string sel = " SELECT theme_id, grouping_attr, grouping_attr_type FROM te_grouping ";
if(!portal->query(sel))
{
delete portal;
return false;
}
while(portal->fetchRow())
{
string themeId, gAttr;
themeId = portal->getData(0);
gAttr = portal->getData(1);
int gTypr = portal->getInt(2);
if(((gAttr.empty()) || (gAttr=="NONE")) && (gTypr==0))
{
string del = " DELETE FROM te_grouping WHERE theme_id = "+ themeId;
db->execute(del);
}
}
// ----- te_grouping table
//.........这里部分代码省略.........
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:101,代码来源:TeUpdateDBVersion.cpp
示例17: updateDB20To30
//.........这里部分代码省略.........
//te_visual
db->allowEmptyString ("te_visual", "lib_name");
db->allowEmptyString ("te_visual", "contour_lib_name");
db->allowEmptyString ("te_visual", "family");
//te_legend
db->allowEmptyString ("te_legend", "lower_value");
db->allowEmptyString ("te_legend", "upper_value");
db->allowEmptyString ("te_legend", "label");
//te_theme
db->allowEmptyString ("te_theme", "generate_attribute_where");
db->allowEmptyString ("te_theme", "generate_spatial_where");
db->allowEmptyString ("te_theme", "generate_temporal_where");
db->allowEmptyString ("te_theme", "collection_table");
//te_grouping
db->allowEmptyString ("te_grouping", "grouping_attr");
db->allowEmptyString ("te_grouping", "grouping_norm_attr");
db->allowEmptyString ("te_grouping", "grouping_function");
//te_theme_application
db->allowEmptyString ("te_theme_application", "refine_attribute_where");
db->allowEmptyString ("te_theme_application", "refine_spatial_where");
db->allowEmptyString ("te_theme_application", "refine_temporal_where");
db->allowEmptyString ("te_theme_application", "grouping_color");
db->allowEmptyString ("te_theme_application", "pie_dimension_attr");
db->allowEmptyString ("te_theme_application", "text_table");
db->allowEmptyString ("te_theme_application", "chart_function");
}
//------------ auxiliary collection
TeDatabasePortal* portal = db->getPortal();
if(!portal)
return false;
string sql = " SELECT theme_id, visible_rep FROM te_theme ";
if(!portal->query(sql))
{
delete portal;
return true;
}
while(portal->fetchRow ())
{
string themeId = portal->getData(0);
int visRep = atoi(portal->getData(1));
string collExtTable = "te_collection_"+ themeId +"_aux";
if ((db->tableExist("te_collection_"+ themeId)) &&
((visRep & TeRASTER) != TeRASTER) &&
(!db->tableExist(collExtTable)))
{
TeTheme* theme = new TeTheme();
theme->id(atoi(themeId.c_str()));
if(!db->loadTheme (theme))
{
delete portal;
return false;
}
string up = "UPDATE " + theme->collectionTable() + " SET c_object_status = 0";
up += " WHERE c_object_status <> " + Te2String(theme->pointingLegend().id());
up += " AND c_object_status <> " + Te2String(theme->queryLegend().id());
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:67,代码来源:TeUpdateDBVersion.cpp
示例18: updateDB400To412
bool updateDB400To412(TeDatabase* db, string& errorMessage)
{
// ----- create the datum table
if(!db->createDatumTable())
{
errorMessage = "Error creating the datum table.\n";
errorMessage += db->errorMessage();
return false;
}
// ----- create the SRS table
if(!db->createSRSTable())
{
errorMessage = "Error creating the SRS table.\n";
errorMessage += db->errorMessage();
return false;
}
// ----- populate the datum table with pre-defined datums and ellipsoids
db->populateDatumTable();
// ----- change te_projection table: removed the columns associated with datum
if(!db->deleteColumn("te_projection", "radius"))
{
errorMessage = "Error removing the column radius from te_projection table.\n";
errorMessage += db->errorMessage();
return false;
}
if(!db->deleteColumn("te_projection", "flattening"))
{
errorMessage = "Error removing the column flattening from te_projection table.\n";
errorMessage += db->errorMessage();
return false;
}
if(!db->deleteColumn("te_projection", "dx"))
{
errorMessage = "Error removing the column dx from te_projection table.\n";
errorMessage += db->errorMessage();
return false;
}
if(!db->deleteColumn("te_projection", "dy"))
{
errorMessage = "Error removing the column dy from te_projection table.\n";
errorMessage += db->errorMessage();
return false;
}
if(!db->deleteColumn("te_projection", "dz"))
{
errorMessage = "Error removing the column dz from te_projection table.\n";
errorMessage += db->errorMessage();
return false;
}
// ----- END: change te_projection table: removed the columns associated with datum
// ----- relations
if(!db->createRelation("fk_proj_datum_name", "te_projection", "datum", "te_datum", "name", false))
{
errorMessage = "Error creating foreign key in the projection table.\n";
errorMessage += db->errorMessage();
return false;
}
if(!db->createRelation("fk_srs_proj_id", "te_srs", "projection_id", "te_projection", "projection_id", true))
{
errorMessage = "Error creating foreign key in the srs table.\n";
errorMessage += db->errorMessage();
return false;
}
// ----- populate te_srs table
TeDatabasePortal* portal = db->getPortal();
if(!portal)
{
errorMessage = "Error getting the database portal";
return false;
}
std::string sql = "SELECT te_projection.*, te_datum.radius, te_datum.flattening, te_datum.dx, te_datum.dy, te_datum.dz ";
sql += "FROM te_projection LEFT JOIN te_datum ON te_projection.datum = te_datum.name ";
if (!portal->query(sql))
return false;
while(portal->fetchRow())
{
TeProjection* proj = 0;
portal->getProjection(&proj);
if(proj)
db->insertSRSId(proj, proj->epsgCode());
delete proj;
}
portal->freeResult();
delete portal;
return true;
//.........这里部分代码省略.........
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:101,代码来源:TeUpdateDBVersion.cpp
示例19: updateDB320To3201
//.........这里部分代码省略.........
{
//delete portal;
errorMessage = "The view box could not be appended!\n";
errorMessage += db->errorMessage();
return false;
}
}
atRep.type_ = TeINT;
atRep.name_ = "current_theme";
atRep.decimals_ = 0;
attr.rep_.name_ = "current_theme";
if(!db->columnExist("te_view", attr.rep_.name_,attr))
{
if(db->addColumn("te_view", atRep) == false)
{
//delete portal;
errorMessage = "The view current theme could not be appended!\n";
errorMessage += db->errorMessage();
return false;
}
//create foreign key
if (!db->createRelation("fk_view_current_theme", "te_view", "current_theme", "te_theme", "theme_id", false))
{
//delete portal;
errorMessage = "Error creating foreign key in the view table!\n";
errorMessage += db->errorMessage();
return false;
}
}
//fill the box theme
string sql = "SELECT te_theme.name, te_view.user_name ";
sql += " FROM te_theme INNER JOIN te_view ON te_theme.view_id = te_view.view_id ";
TeDatabasePortal* portal = db->getPortal();
if(!portal)
return false;
if(!portal->query(sql))
{
delete portal;
return false;
}
string originalUser = db->user();
while(portal->fetchRow())
{
string themeName = string(portal->getData(0));
string userName = string(portal->getData(1));
db->user(userName);
TeTheme theme(themeName);
if(!db->loadTheme(&theme))
{
delete portal;
errorMessage = "Error updating theme box!";
return false;
}
if(theme.type()==TeTREE)
continue;
//select the theme box
TeBox bb;
if (theme.layer()->hasGeometry(TeRASTER))
bb = theme.layer()->box();
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:66,代码来源:TeUpdateDBVersion.cpp
示例20: updateDB310To311
bool updateDB310To311(TeDatabase* db, string& errorMessage)
{
string sql = " SELECT collection_table FROM te_theme ";
TeDatabasePortal* portal = db->getPortal();
if(!portal)
return false;
if(!portal->query(sql))
{
delete portal;
return false;
}
while(portal->fetchRow())
{
string tableName = portal->getData(0);
if(!db->tableExist(tableName+"_aux"))
continue;
TeDatabasePortal* portal2 = db->getPortal();
if(!portal2)
{
delete portal;
return false;
}
sql = " SELECT * FROM "+ tableName+"_aux WHERE 1=2";
if(!portal2->query(sql))
{
delete portal;
delete portal2;
return false;
}
TeAttributeList attrList;
for(int i=0; i<portal2->numFields(); ++i)
{
TeAttribute attr = portal2->getAttribute(i);
attr.rep_.isPrimaryKey_= false;
if(TeConvertToUpperCase(portal2->getAttribute(i).rep_.name_) != "UNIQUE_ID" )
attrList.push_back(attr);
}
delete portal2;
//add new autonumber column
TeAttribute attr;
attr.rep_.name_= "unique_id" ;
attr.rep_.type_= TeINT;
attr.rep_.isAutoNumber_ = true;
attr.rep_.isPrimaryKey_ = true;
attrList.push_back(attr);
//create new table
if(!db->createTable(tableName+"_aux2", attrList))
{
errorMessage = "Error creating table "+ tableName+"_aux2 !\n";
errorMessage += db->errorMessage();
delete portal;
return false;
}
//insert records
string ins = " INSERT INTO "+ tableName +"_aux2 ( ";
string ins2 ="";
for(unsigned int j=0; j<(attrList.size()-1); ++j)
{
if(j>0)
ins2 += ",";
ins2 += attrList[j].rep_.name_;
}
ins += ins2 +" ) SELECT "+ ins2;
ins += " FROM "+ tableName+"_aux";
if(!db->execute(ins))
{
errorMessage = "Error inserting table "+ tableName+"_aux2 !\n";
errorMessage += db->errorMessage();
delete portal;
return false;
}
sql = " DROP TABLE "+ tableName+"_aux";
if(db->tableExist(tableName+"_aux"))
{
if(!db->execute(sql))
{
errorMessage = "Error dropping table "+ tableName+"_aux2 !\n";
errorMessage += db->errorMessage();
delete portal;
return false;
}
}
if(!db->alterTable(tableName+"_aux2", tableName+"_aux"))
{
errorMessage = "Error renaming table "+ tableName+"_aux2 !\n";
errorMessage += db->errorMessage();
delete portal;
return false;
}
//.........这里部分代码省略.........
开发者ID:Universefei,项目名称:Terralib-analysis,代码行数:101,代码来源:TeUpdateDBVersion.cpp
注:本文中的TeDatabasePortal类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论