27 #include "../common/Translator.h"
28 #include "../dataaccess/dataset/CheckConstraint.h"
29 #include "../dataaccess/dataset/DataSet.h"
30 #include "../dataaccess/dataset/ForeignKey.h"
31 #include "../dataaccess/dataset/Index.h"
32 #include "../dataaccess/dataset/ObjectIdSet.h"
33 #include "../dataaccess/dataset/PrimaryKey.h"
34 #include "../dataaccess/dataset/Sequence.h"
35 #include "../dataaccess/dataset/UniqueKey.h"
36 #include "../dataaccess/datasource/DataSourceCatalog.h"
37 #include "../dataaccess/datasource/ScopedTransaction.h"
38 #include "../dataaccess/query/Select.h"
39 #include "../dataaccess/query/SQLDialect.h"
40 #include "../dataaccess/utils/Utils.h"
41 #include "../datatype/Array.h"
42 #include "../datatype/Date.h"
43 #include "../datatype/DateTimeProperty.h"
44 #include "../datatype/Property.h"
45 #include "../datatype/SimpleData.h"
46 #include "../datatype/StringProperty.h"
47 #include "../geometry/Envelope.h"
48 #include "../geometry/GeometryProperty.h"
49 #include "../geometry/Utils.h"
50 #include "../geometry/Geometry.h"
51 #include "../memory/DataSet.h"
67 #include <boost/format.hpp>
68 #include <boost/lexical_cast.hpp>
71 #import "msado15.dll" \
72 no_namespace rename(
"EOF",
"EndOfFile")
84 m_isInTransaction(false)
105 m_conn->getConn()->BeginTrans();
106 m_isInTransaction =
true;
110 throw Exception(
TR_ADO(e.Description()));
118 m_conn->getConn()->CommitTrans();
119 m_isInTransaction =
false;
123 throw Exception(
TR_ADO(e.Description()));
131 m_conn->getConn()->RollbackTrans();
132 m_isInTransaction =
false;
136 throw Exception(
TR_ADO(e.Description()));
142 return m_isInTransaction;
150 std::string sql(
"SELECT * FROM ");
153 return query(sql, travType, connected, accessPolicy);
157 const std::string& propertyName,
165 throw Exception(
TR_ADO(
"The envelope is missing!"));
167 std::string lowerX =
"lower_x";
168 std::string upperX =
"upper_x";
169 std::string lowerY =
"lower_y";
170 std::string upperY =
"upper_y";
172 std::string q(
"SELECT * FROM " + name +
" WHERE ");
174 q +=
"NOT("+ lowerX +
" > " + boost::lexical_cast<std::string>(e->
m_urx) +
" OR ";
175 q += upperX +
" < " + boost::lexical_cast<std::string>(e->
m_llx) +
" OR ";
176 q += lowerY +
" > " + boost::lexical_cast<std::string>(e->
m_ury) +
" OR ";
177 q += upperY +
" < " + boost::lexical_cast<std::string>(e->
m_lly) +
")";
179 return query(q, travType, connected, accessPolicy);
190 throw Exception(
TR_ADO(
"Method getDataSet by geometry filter: not implemented yet!"));
199 throw Exception(
TR_ADO(
"Method getDataSet by oids: not implemented yet!"));
209 SQLVisitor visitor(*(m_ds->getDialect()), sql, m_conn->getConn());
213 return query(sql, travType);
221 _RecordsetPtr result = m_conn->query(query, connected);
223 long i = result->GetRecordCount();
225 std::auto_ptr<te::da::DataSet> dset(
new DataSet(
this, result));
243 SQLVisitor visitor(*(m_ds->getDialect()), sql, m_conn->getConn());
252 m_conn->execute(command);
257 throw Exception(
TR_ADO(
"Method getPrepared: not implemented yet!"));
262 throw Exception(
TR_ADO(
"Method getBatchExecutor: not implemented yet!"));
271 throw Exception(
TR_ADO(
"Method getLastGeneratedId: not implemented yet!"));
291 std::vector<std::string> datasets;
293 ADOX::_CatalogPtr pCatalog = 0;
295 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
299 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
301 ADOX::TablesPtr tables = pCatalog->GetTables();
303 for(
long i = 0; i < tables->GetCount(); ++i)
305 ADOX::_TablePtr table = tables->GetItem(i);
306 std::string tableName = table->GetName();
308 std::string tabletype = table->GetType();
310 if(table->GetType() == _bstr_t(
"ACCESS TABLE") ||
311 table->GetType() == _bstr_t(
"LINK") ||
312 table->GetType() == _bstr_t(
"PASS-THROUGH") ||
313 table->GetType() == _bstr_t(
"SYSTEM TABLE") ||
314 table->GetType() == _bstr_t(
"VIEW") ||
315 tableName ==
"geometry_columns")
318 datasets.push_back(std::string(table->GetName()));
323 throw Exception(
TR_ADO(e.ErrorMessage()));
331 return getDataSetNames().size();
340 getProperties(dt.get());
342 getPrimaryKey(dt.get());
344 getUniqueKeys(dt.get());
346 getIndexes(dt.get());
348 getCheckConstraints(dt.get());
355 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
357 std::vector<te::dt::Property*> dtProperties = dt->getProperties();
359 boost::ptr_vector<te::dt::Property> properties;
361 for(std::size_t i = 0; i < dtProperties.size(); ++i)
362 properties.push_back(dtProperties[i]->clone());
369 if(!propertyExists(datasetName, name))
370 throw Exception((boost::format(
TR_ADO(
"The dataset \"%1%\" has no property with this name \"%2%\"!")) % datasetName % name).str());
372 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
374 return std::auto_ptr<te::dt::Property>(dt->getProperty(name)->clone());
379 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
381 assert(propertyPos < dt->size());
383 return std::auto_ptr<te::dt::Property>(dt->getProperty(propertyPos)->clone());
388 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
390 std::vector<std::string> pNames;
392 std::size_t numProperties = dt->size();
394 for(std::size_t i = 0; i < numProperties; ++i)
395 pNames.push_back(dt->getProperty(i)->getName());
402 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
409 std::vector<std::string> datasets;
411 ADOX::_CatalogPtr pCatalog = 0;
413 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
417 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
419 ADOX::TablesPtr tables = pCatalog->GetTables();
421 ADOX::_TablePtr table;
423 for(
long i = 0; i < tables->GetCount(); ++i)
426 table = tables->GetItem(i);
427 std::string tableName = table->GetName();
429 if(tableName == datasetName)
437 ADOX::ColumnsPtr cols = table->GetColumns();
439 for(
int i = 0; i < cols->Count; ++i)
441 ADOX::_ColumnPtr col = cols->GetItem((
long)i);
443 if(((LPCSTR)(_bstr_t)col->GetName()) == name)
453 throw Exception(
TR_ADO(e.ErrorMessage()));
459 const std::string& propertyName = p->
getName();
461 if(propertyExists(datasetName, propertyName))
462 throw Exception((boost::format(
TR_ADO(
"The dataset already \"%1%\" has a property with this name \"%2%\"!")) % datasetName % propertyName).str());
464 ADOX::_CatalogPtr pCatalog = 0;
466 ADOX::_TablePtr pTable = 0;
468 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
472 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
474 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
476 ADOX::_ColumnPtr newColumn = 0;
478 TESTHR(newColumn.CreateInstance(__uuidof(ADOX::Column)));
480 newColumn->PutName(propertyName.c_str());
504 newColumn->PutAttributes(ADOX::adColNullable);
506 pTable->Columns->Append(_variant_t ((IDispatch*)newColumn), ado_type, 0);
520 newColumn->DefinedSize = ssize;
523 newColumn->PutAttributes(ADOX::adColNullable);
525 pTable->Columns->Append(_variant_t ((IDispatch*)newColumn), ado_type, ssize);
535 newColumn->PutAttributes(ADOX::adColNullable);
537 pTable->Columns->Append(_variant_t ((IDispatch*)newColumn), ado_type, 0);
545 addProperty(datasetName, lowerX.get());
546 addProperty(datasetName, lowerY.get());
547 addProperty(datasetName, upperX.get());
548 addProperty(datasetName, upperY.get());
550 insertIntoGeometryColumns(datasetName, static_cast<te::gm::GeometryProperty*>(p));
556 throw te::ado::Exception(
TR_ADO(
"The informed type could not be mapped to ADO type system!"));
562 throw Exception(
TR_ADO(e.Description()));
568 if(!propertyExists(datasetName, name))
569 throw Exception((boost::format(
TR_ADO(
"The dataset \"%1%\" has no property with this name \"%2%\"!")) % datasetName % name).str());
571 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
575 ADOX::_CatalogPtr pCatalog = 0;
577 ADOX::_TablePtr pTable = 0;
579 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
583 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
591 std::string sql =
"delete from geometry_columns where f_geometry_column = '";
593 sql +=
"' AND f_table_name = '";
597 m_conn->execute(sql);
602 throw Exception(
TR_ADO(e.Description()));
607 const std::string& propertyName,
608 const std::string& newPropertyName)
610 ADOX::_CatalogPtr pCatalog = 0;
612 ADOX::_TablePtr pTable = 0;
614 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
618 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
620 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
622 ADOX::_ColumnPtr col = pTable->GetColumns()->GetItem(propertyName.c_str());
624 col->PutName(newPropertyName.c_str());
626 pCatalog->GetTables()->Refresh();
630 throw Exception(
TR_ADO(e.Description()));
636 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
638 return std::auto_ptr<te::da::PrimaryKey>(
static_cast<te::da::PrimaryKey*
>(dt->getPrimaryKey()->clone()));
643 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
645 if(dt->getPrimaryKey()->getName() == name)
653 _variant_t vOptional;
654 vOptional.vt = VT_ERROR;
655 vOptional.scode = DISP_E_PARAMNOTFOUND;
657 ADOX::_KeyPtr pKey = 0;
658 ADOX::_TablePtr pTable = 0;
659 ADOX::_CatalogPtr pCatalog = 0;
661 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
662 TESTHR(pKey.CreateInstance(__uuidof(ADOX::Key)));
666 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
668 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
670 pKey->Name = pTable->Name +
"_pk";
671 pKey->Type = ADOX::adKeyPrimary;
680 TESTHR(pTable->Keys->Append(_variant_t((IDispatch *)pKey),ADOX::adKeyPrimary,vOptional,
L"",
L""));
681 pCatalog->Tables->Refresh();
685 throw Exception(
TR_ADO(e.Description()));
691 ADOX::_KeyPtr pKey = 0;
692 ADOX::_TablePtr pTable = 0;
693 ADOX::_CatalogPtr pCatalog = 0;
695 std::auto_ptr<te::da::PrimaryKey> pk(getPrimaryKey(datasetName));
699 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
701 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
703 pKey = pTable->Keys->GetItem(pk->getName().c_str());
705 TESTHR(pTable->GetKeys()->Delete(_variant_t((IDispatch *)pKey)));
709 throw Exception(
TR_ADO(e.Description()));
715 if(!foreignKeyExists(datasetName, name))
716 throw Exception((boost::format(
TR_ADO(
"The dataset \"%1%\" has no foreign key with this name \"%2%\"!")) % datasetName % name).str());
718 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
720 return std::auto_ptr<te::da::ForeignKey>(
static_cast<te::da::ForeignKey*
>(dt->getForeignKey(name)->clone()));
725 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
727 std::vector<std::string> fkNames;
729 std::size_t numFK = dt->getNumberOfForeignKeys();
731 for(std::size_t i = 0; i < numFK; ++i)
732 fkNames.push_back(dt->getForeignKey(i)->getName());
739 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
741 std::vector<std::string> fkNames = getForeignKeyNames(datasetName);
743 if(std::find(fkNames.begin(), fkNames.end(), name) != fkNames.end())
751 _variant_t vOptional;
752 vOptional.vt = VT_ERROR;
753 vOptional.scode = DISP_E_PARAMNOTFOUND;
755 ADOX::_KeyPtr pKey = 0;
756 ADOX::_TablePtr pTable = 0;
757 ADOX::_CatalogPtr pCatalog = 0;
761 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
763 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
765 TESTHR(pKey.CreateInstance(__uuidof(ADOX::Key)));
767 pKey->Name = pTable->Name +
"_fk";
768 pKey->Type = ADOX::adKeyForeign;
781 TESTHR(pTable->Keys->Append(_variant_t((IDispatch *)pKey),ADOX::adKeyPrimary,vOptional,
L"",
L""));
783 pCatalog->Tables->Refresh();
787 throw Exception(
TR_ADO(e.Description()));
793 ADOX::_KeyPtr pKey = 0;
794 ADOX::_TablePtr pTable = 0;
795 ADOX::_CatalogPtr pCatalog = 0;
800 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
802 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
804 pKey = pTable->Keys->GetItem(fkName.c_str());
806 TESTHR(pTable->GetKeys()->Delete(_variant_t((IDispatch *)pKey)));
810 throw Exception(
TR_ADO(e.Description()));
816 if(!uniqueKeyExists(datasetName, name))
817 throw Exception((boost::format(
TR_ADO(
"The dataset \"%1%\" has no unique key with this name \"%2%\"!")) % datasetName % name).str());
819 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
821 return std::auto_ptr<te::da::UniqueKey>(
static_cast<te::da::UniqueKey*
>(dt->getUniqueKey(name)->clone()));
826 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
828 std::vector<std::string> ukNames;
830 std::size_t numUKs = dt->getNumberOfUniqueKeys();
832 for(std::size_t i = 0; i < numUKs; ++i)
833 ukNames.push_back(dt->getUniqueKey(i)->getName());
840 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
842 std::vector<std::string> ukNames = getUniqueKeyNames(datasetName);
844 if(std::find(ukNames.begin(), ukNames.end(), name) != ukNames.end())
852 _variant_t vOptional;
853 vOptional.vt = VT_ERROR;
854 vOptional.scode = DISP_E_PARAMNOTFOUND;
856 ADOX::_KeyPtr pKey = 0;
857 ADOX::_TablePtr pTable = 0;
858 ADOX::_CatalogPtr pCatalog = 0;
860 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
861 TESTHR(pKey.CreateInstance(__uuidof(ADOX::Key)));
865 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
867 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
869 pKey->Name = pTable->Name +
"_uk";
870 pKey->Type = ADOX::adKeyUnique;
879 TESTHR(pTable->Keys->Append(_variant_t((IDispatch *)pKey),ADOX::adKeyUnique,vOptional,
L"",
L""));
881 pCatalog->Tables->Refresh();
885 throw Exception(
TR_ADO(e.Description()));
891 ADOX::_KeyPtr pKey = 0;
892 ADOX::_TablePtr pTable = 0;
893 ADOX::_CatalogPtr pCatalog = 0;
897 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
899 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
901 pKey = pTable->Keys->GetItem(name.c_str());
903 TESTHR(pTable->GetKeys()->Delete(_variant_t((IDispatch *)pKey)));
907 throw Exception(
TR_ADO(e.Description()));
913 if(!checkConstraintExists(datasetName, name))
914 throw Exception((boost::format(
TR_ADO(
"The dataset \"%1%\" has no check constraint with this name \"%2%\"!")) % datasetName % name).str());
916 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
918 return std::auto_ptr<te::da::CheckConstraint>(
static_cast<te::da::CheckConstraint*
>(dt->getCheckConstraint(name)->clone()));
923 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
925 std::vector<std::string> ccNames;
927 std::size_t numCCs = dt->getNumberOfCheckConstraints();
929 for(std::size_t i = 0; i < numCCs; ++i)
930 ccNames.push_back(dt->getCheckConstraint(i)->getName());
937 std::vector<std::string> ccNames = getCheckConstraintNames(datasetName);
939 if(std::find(ccNames.begin(), ccNames.end(), name) != ccNames.end())
947 throw Exception(
TR_ADO(
"Method addCheckConstraint: not implemented yet!"));
952 throw Exception(
TR_ADO(
"Method dropCheckConstraint: not implemented yet!"));
957 if(!indexExists(datasetName, name))
958 throw Exception((boost::format(
TR_ADO(
"The dataset \"%1%\" has no index with this name \"%2%\"!")) % datasetName % name).str());
960 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
962 return std::auto_ptr<te::da::Index>(dt->getIndex(name)->clone());
967 std::vector<std::string> idxNames;
969 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
971 std::size_t numIdxs = dt->getNumberOfIndexes();
973 for(std::size_t i = 0; i < numIdxs; ++i)
974 idxNames.push_back(dt->getIndex(i)->getName());
981 std::vector<std::string> idxNames = getIndexNames(datasetName);
983 if(std::find(idxNames.begin(), idxNames.end(), name) != idxNames.end())
990 const std::map<std::string, std::string>& options)
992 ADOX::_IndexPtr pIndex = 0;
993 ADOX::_TablePtr pTable = 0;
994 ADOX::_CatalogPtr pCatalog = 0;
996 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
997 TESTHR(pIndex.CreateInstance(__uuidof(ADOX::Index)));
1001 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
1003 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
1005 pIndex->Name = idx->
getName().c_str();
1007 std::vector<te::dt::Property*> idxProps = idx->
getProperties();
1008 for(
size_t i = 0; i < idxProps.size(); i++)
1017 TESTHR(pTable->Indexes->Append(_variant_t((IDispatch *)pIndex)));
1019 catch(_com_error& e)
1021 throw Exception(
TR_ADO(e.Description()));
1027 if(!indexExists(datasetName, idxName))
1028 throw Exception((boost::format(
TR_ADO(
"The dataset \"%1%\" has no index with this name: \"%2%\"!")) % datasetName % idxName).str());
1030 std::string sql(
"DROP INDEX ");
1035 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
1044 throw Exception(
TR_ADO(
"Method getSequence: not implemented yet!"));
1049 throw Exception(
TR_ADO(
"Method getSequenceNames: not implemented yet!"));
1054 throw Exception(
TR_ADO(
"Method sequenceExists: not implemented yet!"));
1059 throw Exception(
TR_ADO(
"Method addSequence: not implemented yet!"));
1064 throw Exception(
TR_ADO(
"Method dropSequence: not implemented yet!"));
1068 const std::string& )
1070 if(!dataSetExists(datasetName))
1071 throw Exception(
TR_ADO(
"The Data Set Type does not exist!"));
1073 std::string sql =
"SELECT MIN(lower_x), MIN(lower_y), MAX(upper_x), MAX(upper_y) from " + datasetName;
1075 std::auto_ptr<te::da::DataSet> resultBox(query(sql));
1081 resultBox->moveFirst();
1082 env->m_llx = resultBox->getDouble(0);
1083 env->m_lly = resultBox->getDouble(1);
1084 env->m_urx = resultBox->getDouble(2);
1085 env->m_ury = resultBox->getDouble(3);
1089 throw Exception(
TR_ADO(
"Error when calculating the envelope!"));
1098 return getExtent(datasetName, 0);
1103 std::auto_ptr<te::da::DataSet> result(getDataSet(datasetName));
1105 return result->size();
1110 std::vector<std::string> datasetNames = getDataSetNames();
1112 if(datasetNames.empty())
1120 std::vector<std::string> datasetNames = getDataSetNames();
1122 if(std::find(datasetNames.begin(), datasetNames.end(), name) != datasetNames.end())
1130 ADOX::_TablePtr pTable = 0;
1131 ADOX::_CatalogPtr pCatalog = 0;
1133 TESTHR(pTable.CreateInstance(__uuidof (ADOX::Table)));
1134 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1138 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
1140 pTable->Name = dt->
getName().c_str();
1142 TESTHR(pCatalog->Tables->Append(_variant_t((IDispatch*)pTable)));
1145 catch(_com_error &e)
1147 throw Exception(
TR_ADO(e.ErrorMessage()));
1150 std::size_t ncols = dt->
size();
1152 for(std::size_t i = 0; i < ncols; ++i)
1160 const std::string& ,
1161 const std::map<std::string, std::string>& )
1163 throw Exception(
TR_ADO(
"Method cloneDataSet: not implemented yet!"));
1168 ADOX::_CatalogPtr pCatalog = 0;
1170 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1174 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
1176 TESTHR(pCatalog->Tables->Delete(name.c_str()));
1178 catch(_com_error& e)
1180 throw Exception(
TR_ADO(e.Description()));
1186 ADOX::_CatalogPtr pCatalog = 0;
1188 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1192 pCatalog->Tables->GetItem(name.c_str())->PutName(newName.c_str());
1194 catch(_com_error& e)
1196 throw Exception(
TR_ADO(e.Description()));
1202 const std::map<std::string, std::string>& options,
1205 _RecordsetPtr recset;
1206 TESTHR(recset.CreateInstance(__uuidof(Recordset)));
1210 TESTHR(recset->Open(_bstr_t(datasetName.c_str()),
1211 _variant_t((IDispatch*)m_conn->getConn(),
true), adOpenKeyset, adLockOptimistic, adCmdTable));
1215 TESTHR(recset->AddNew());
1235 recset->GetFields()->GetItem(pname.c_str())->Value = (_bstr_t)d->
getChar(pname.c_str());
1239 recset->GetFields()->GetItem(pname.c_str())->Value = (_bstr_t)d->
getUChar(pname.c_str());
1243 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getInt16(pname.c_str());
1247 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getInt32(pname.c_str());
1251 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getInt64(pname.c_str());
1260 double dval = boost::lexical_cast<
double>(sval);
1261 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)(dval);
1267 std::auto_ptr<te::dt::DateTime> dtm(d->
getDateTime(i));
1271 recset->GetFields()->GetItem(pname.c_str())->Value = (_bstr_t)dtt.c_str();
1277 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getFloat(pname.c_str());
1281 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getDouble(pname.c_str());
1285 recset->GetFields()->GetItem(pname.c_str())->Value = (_bstr_t)d->
getString(pname.c_str()).c_str();
1289 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getBool(pname.c_str());
1307 std::auto_ptr<te::gm::Geometry> geometry(d->
getGeometry(pname));
1310 recset->GetFields()->GetItem(
"lower_x")->Value = (_variant_t)env->
m_llx;
1311 recset->GetFields()->GetItem(
"lower_y")->Value = (_variant_t)env->m_lly;
1312 recset->GetFields()->GetItem(
"upper_x")->Value = (_variant_t)env->m_urx;
1313 recset->GetFields()->GetItem(
"upper_y")->Value = (_variant_t)env->m_ury;
1318 recset->Fields->GetItem(pname.c_str())->AppendChunk (var);
1324 throw te::ado::Exception(
TR_ADO(
"The informed type could not be mapped to ADO type system!"));
1329 TESTHR(recset->Update());
1333 catch(_com_error& e)
1335 throw Exception(
TR_ADO(e.Description()));
1341 ADOX::_CatalogPtr pCatalog = 0;
1343 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1347 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
1349 TESTHR(pCatalog->Tables->Delete(datasetName.c_str()));
1351 catch(_com_error& e)
1353 throw Exception(
TR_ADO(e.Description()));
1359 const std::vector<std::size_t>& properties,
1361 const std::map<std::string, std::string>& options,
1374 _ConnectionPtr adoConn = m_conn->getConn();
1376 ADOX::_CatalogPtr pCatalog = 0;
1378 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1382 pCatalog->PutActiveConnection(variant_t((IDispatch *)adoConn));
1384 catch(_com_error& e)
1386 throw Exception(
TR_ADO(e.Description()));
1388 ADOX::TablesPtr tables = pCatalog->GetTables();
1390 ADOX::_TablePtr t = tables->GetItem(dt->
getName().c_str());
1392 ADOX::KeysPtr keys = t->GetKeys();
1394 ADOX::_KeyPtr pk = 0;
1396 for(
long i = 0; i < keys->Count; i++)
1398 if(keys->GetItem(i)->GetType() == ADOX::adKeyPrimary)
1399 pk = keys->GetItem(i);
1408 ADOX::ColumnsPtr cols = pk->GetColumns();
1412 for(
long i = 0; i < cols->GetCount(); i++)
1413 tlPk->
add(dt->
getProperty(std::string(cols->GetItem(i)->GetName())));
1418 std::string dsName = dt->
getName();
1421 ADOX::DataTypeEnum colType;
1422 std::map<int, std::string> colNamesMap;
1423 std::map<int, ADOX::DataTypeEnum> colTypesMap;
1424 std::map<int, int> charLengthMap;
1425 std::map<int, bool> isRequiredMap;
1426 std::map<int, bool> hasDefaultMap;
1427 std::map<int, std::string> defaultValueMap;
1429 _ConnectionPtr conn = 0;
1435 conn = m_conn->getConn();
1437 _RecordsetPtr rs = NULL;
1439 TESTHR(rs.CreateInstance(__uuidof(Recordset)));
1443 SAFEARRAY FAR* psa = NULL;
1444 SAFEARRAYBOUND rgsabound;
1448 rgsabound.lLbound = 0;
1449 rgsabound.cElements = 3;
1450 psa = SafeArrayCreate(VT_VARIANT, 1, &rgsabound);
1452 var[0].vt = VT_EMPTY;
1453 var[1].vt = VT_EMPTY;
1454 var[2] = dsName.c_str();
1457 for(LONG i = 0; i < 3; ++i)
1458 hr = SafeArrayPutElement(psa, &i, &var[i]);
1460 Array.vt = VT_ARRAY | VT_VARIANT;
1463 rs = conn->OpenSchema(adSchemaColumns, &Array, vtMissing);
1466 while (!(rs->EndOfFile))
1469 _bstr_t columnName = rs->Fields->GetItem(
"COLUMN_NAME")->Value;
1470 pos = rs->Fields->GetItem(
"ORDINAL_POSITION")->Value;
1472 colNamesMap[pos] = (LPCSTR)columnName;
1475 colType = ADOX::DataTypeEnum(
int(rs->Fields->GetItem(
"DATA_TYPE")->Value));
1476 colTypesMap[pos] = colType;
1479 _variant_t length = rs->Fields->GetItem(
"CHARACTER_MAXIMUM_LENGTH")->Value;
1481 if(length.vt != VT_NULL)
1482 charLength = (int)length.dblVal;
1483 charLengthMap[pos] = charLength;
1486 bool nullVal = rs->Fields->GetItem(
"IS_NULLABLE")->Value;
1487 isRequiredMap[pos] = !nullVal;
1490 bool hasDefault = rs->Fields->GetItem(
"COLUMN_HASDEFAULT")->Value;
1491 hasDefaultMap[pos] = !hasDefault;
1494 std::string defaultStr;
1497 _bstr_t defaultValue = rs->Fields->GetItem(
"COLUMN_DEFAULT")->Value;
1498 defaultStr = (LPSTR)defaultValue;
1501 defaultValueMap[pos] = defaultStr;
1507 catch (_com_error& e)
1509 std::cout <<
"Error = " << (
char*) e.ErrorMessage() << std::endl;
1513 for(
int i = 0; i < numCols; ++i)
1516 ADOX::DataTypeEnum colType = colTypesMap[i];
1517 std::string colName = colNamesMap[i];
1533 case ::adLongVarChar:
1534 case ::adLongVarWChar:
1542 sp->
setSize(charLengthMap[i]);
1547 case ADOX::adTinyInt:
1548 case ADOX::adSmallInt:
1549 case ADOX::adInteger:
1550 case ADOX::adBigInt:
1551 case ADOX::adSingle:
1552 case ADOX::adDouble:
1553 case ADOX::adDecimal:
1554 case ::adUnsignedBigInt:
1555 case ::adUnsignedInt:
1556 case ::adUnsignedSmallInt:
1557 case ::adUnsignedTinyInt:
1566 case ADOX::adBinary:
1567 case ADOX::adLongVarBinary:
1570 std::map<std::string, std::string> geomColumns = m_ds->getGeomColumns();
1571 std::map<std::string, std::string>::iterator it = geomColumns.find(dsName);
1573 if(it != geomColumns.end())
1575 if(it->second == colName)
1589 case ADOX::adDBDate:
1590 case ADOX::adDBTime:
1591 case ADOX::adDBTimeStamp:
1606 _ConnectionPtr adoConn = m_conn->getConn();
1608 ADOX::_CatalogPtr pCatalog = 0;
1610 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1614 pCatalog->PutActiveConnection(variant_t((IDispatch *)adoConn));
1616 catch(_com_error& e)
1618 throw Exception(
TR_ADO(e.Description()));
1621 ADOX::TablesPtr tables = pCatalog->GetTables();
1623 ADOX::_TablePtr t = tables->GetItem(dt->
getName().c_str());
1625 ADOX::KeysPtr keys = t->GetKeys();
1627 for(
long i = 0; i < keys->Count; i++)
1629 if(keys->GetItem(i)->GetType() == ADOX::adKeyUnique)
1631 ADOX::_KeyPtr uk = keys->GetItem(i);
1635 ADOX::ColumnsPtr cols = uk->GetColumns();
1637 for(
long j = 0; j < cols->Count; j++)
1638 tlUk->
add(dt->
getProperty(std::string(cols->GetItem(i)->GetName())));
1645 _ConnectionPtr adoConn = m_conn->getConn();
1647 ADOX::_CatalogPtr pCatalog = 0;
1649 TESTHR((pCatalog.CreateInstance(__uuidof(ADOX::Catalog))));
1653 pCatalog->PutActiveConnection(variant_t((IDispatch *)adoConn));
1655 catch(_com_error& e)
1657 throw Exception(
TR_ADO(e.Description()));
1660 ADOX::TablesPtr tables = pCatalog->GetTables();
1662 ADOX::_TablePtr t = tables->GetItem(dt->
getName().c_str());
1664 ADOX::IndexesPtr idxs = t->GetIndexes();
1666 for(
long i = 0; i < idxs->GetCount(); i++)
1668 ADOX::_IndexPtr idx = idxs->GetItem(i);
1671 tlIdx->
setName(std::string(idx->GetName()));
1673 std::vector<te::dt::Property*> props;
1675 ADOX::ColumnsPtr cols = idx->GetColumns();
1676 for(
long i = 0; i < cols->GetCount(); i++)
1677 props.push_back(dt->
getProperty(std::string(cols->GetItem(i)->GetName())));
1687 _RecordsetPtr rs = NULL;
1689 std::string dtName = dt->
getName();
1691 std::string str =
"[" + dtName +
"]";
1697 _ConnectionPtr adoConn = m_conn->getConn();
1699 TESTHR(rs.CreateInstance(__uuidof(Recordset)));
1701 rs = adoConn->OpenSchema(adSchemaCheckConstraints);
1703 while (!(rs->EndOfFile))
1705 std::string constraintName = (LPCSTR)(bstr_t)(rs->Fields->GetItem(
"CONSTRAINT_NAME")->GetValue());
1707 if(constraintName.find(str) != std::string::npos)
1710 std::string checkClause = (LPCSTR)(bstr_t)(rs->Fields->GetItem(
"CHECK_CLAUSE")->GetValue());
1717 catch(_com_error& e)
1719 throw Exception(
TR_ADO(e.Description()));
1723 if(rs && rs->State == adStateOpen)
1730 _ConnectionPtr adoConn = m_conn->getConn();
1732 int coord_dimension = 2;
1735 coord_dimension = 3;
1737 _RecordsetPtr recset;
1738 TESTHR(recset.CreateInstance(__uuidof(Recordset)));
1742 TESTHR(recset->Open(_bstr_t(
"geometry_columns"),
1743 _variant_t((IDispatch*)adoConn,
true), adOpenKeyset, adLockOptimistic, adCmdTable));
1745 TESTHR(recset->AddNew());
1747 recset->GetFields()->GetItem(
"f_table_catalog")->Value = (_bstr_t)std::string(
"''").c_str();
1748 recset->GetFields()->GetItem(
"f_table_schema")->Value = (_bstr_t)std::string(
"public").c_str();
1749 recset->GetFields()->GetItem(
"f_table_name")->Value = (_bstr_t)datasetName.c_str();
1750 recset->GetFields()->GetItem(
"f_geometry_column")->Value = (_bstr_t)geomProp->
getName().c_str();
1751 recset->GetFields()->GetItem(
"coord_dimension")->Value = (_variant_t)coord_dimension;
1752 recset->GetFields()->GetItem(
"srid")->Value = (_variant_t)geomProp->
getSRID();
1757 catch(_com_error& e)
1759 throw Exception(
TR_ADO(e.Description()));
1762 m_ds->registerGeometryColumn(datasetName, geomProp->
getName());
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value.
int Convert2Terralib(ADOX::DataTypeEnum adoType)
Bind ADOX Type to TerraLib Type.
void setRequired(bool r)
It tells if the property is required or not.
bool checkConstraintExists(const std::string &datasetName, const std::string &name)
It checks if a check-constraint with the given name exists in the data source.
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
Utility functions for ADO.
bool isRequired() const
It returns true if the attribute is required, otherwise it returns false.
It describes an index associated to a DataSetType.
void addIndex(const std::string &datasetName, te::da::Index *idx, const std::map< std::string, std::string > &options)
It adds an index to the dataset.
te::da::DataSource * getDataSource() const
It returns the parent data source of the transactor.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
void cloneDataSet(const std::string &name, const std::string &cloneName, const std::map< std::string, std::string > &options)
It clones the dataset in the data source.
te::gm::GeomType GetType(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
Read the geometry_columns table end return a geometry type.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
void add(te::dt::Property *p)
It adds the property to the list of properties that participates in the unique key.
Transactor(DataSource *ds)
void createDataSet(te::da::DataSetType *dt, const std::map< std::string, std::string > &options)
It creates the dataset schema definition in the target data source.
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
An atomic property like an integer or double.
Property * getProperty(std::size_t i) const
It returns the i-th property.
std::size_t size() const
It returns the number of properties of the CompositeProperty.
DataSet class implementation for Microsoft Access driver.
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
void getUniqueKeys(te::da::DataSetType *dt)
It update the DataSetType about the Unique Keys.
virtual float getFloat(std::size_t i) const =0
Method for retrieving a float attribute value.
The type for date and time types: date, date period, date duration, time duration, time instant, time period, time instant with time zone or time period with time zone.
A Select models a query to be used when retrieving data from a DataSource.
virtual bool getBool(std::size_t i) const =0
Method for retrieving a boolean attribute value.
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
void setName(const std::string &name)
It sets the index name.
void setExpression(const std::string &e)
It sets the check constraint expression.
void commit()
It commits the transaction.
virtual std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const =0
Method for retrieving a date and time attribute value.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source.
std::string GetFormattedDateTime(te::dt::DateTime *dateTime)
It gets a formatted DateTime string for ADO.
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long).
void setProperties(const std::vector< te::dt::Property * > &properties)
It sets the properties that take part of the index.
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
virtual unsigned char getUChar(std::size_t i) const =0
Method for retrieving an unsigned character attribute value (1 byte long).
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
void addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
It describes a primary key (pk) constraint.
bool hasDataSets()
It checks if the data source has any dataset.
const std::string & getName() const
It returns the property name.
void add(Constraint *c)
It adds a new constraint.
std::auto_ptr< te::da::DataSet > query(const te::da::Select &q, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It executes a query that may return some data using a generic query. A dataset can be connected or di...
virtual std::string getNumeric(std::size_t i) const =0
Method for retrieving a numeric attribute value.
void setSize(std::size_t s)
It sets the maximum number of characters for a varying string, or the number of characters for a fixe...
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
It describes a sequence (a number generator).
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the index.
ADOX::DataTypeEnum Convert2Ado(int terralib)
Bind TerraLib Type to ADO Type.
std::auto_ptr< te::da::CheckConstraint > getCheckConstraint(const std::string &datasetName, const std::string &name)
It gets the check constraint of the dataset with the given name.
SpatialRelation
Spatial relations between geometric objects.
It models a foreign key constraint for a DataSetType.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the primary key.
void add(const std::string &datasetName, te::da::DataSet *d, const std::map< std::string, std::string > &options, std::size_t limit=0)
It adds data items to the dataset in the data source.
bool indexExists(const std::string &datasetName, const std::string &name)
It checks if an index with the given name exists in the dataset.
A class that implements a connection to a ADO database.
std::auto_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
Implementation of a dataset for the ADO driver.
AccessPolicy
Supported data access policies (can be used as bitfield).
std::auto_ptr< te::da::Index > getIndex(const std::string &datasetName, const std::string &name)
It gets the index with the given name from the dataset.
void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
bool isDataSetNameValid(const std::string &datasetName)
It returns true if the given string is a valid dataset name.
std::auto_ptr< te::da::PreparedQuery > getPrepared(const std::string &qName=std::string(""))
It creates a prepared query object that may be used for query commands (select, insert, update and delete) that are used repeatedly.
void addPrimaryKey(const std::string &datasetName, te::da::PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
DataSourceTransactor class implementation for Microsoft Access driver.
void setPrimaryKey(PrimaryKey *pk)
It sets the primary key constraint.
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long).
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
A visitor for building an SQL statement using ADO dialect.
int GetSRID(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
Read the geometry_columns table end return a SRID.
double m_lly
Lower left corner y-coordinate.
void addSequence(te::da::Sequence *sequence)
It creates a new sequence in the data source.
void cancel()
It requests that the data source stop the processing of the current command.
A Query is independent from the data source language/dialect.
void execute(const te::da::Query &command)
It executes the specified command using a generic query representation.
void getCheckConstraints(te::da::DataSetType *dt)
It update the DataSetType about the Check Constraints.
double m_ury
Upper right corner y-coordinate.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
Implementation of the data source class for the ADO driver.
Property * getParent() const
It returns the parent of this property, or NULL, if it doesn't have one.
std::string MakeConnectionStr(const std::map< std::string, std::string > &dsInfo)
Create a connection string based on a map.
A visitor for building an SQL statement using ADO dialect.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
const std::string & getName() const
It returns the index name.
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
It describes a unique key (uk) constraint.
std::auto_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
void getIndexes(te::da::DataSetType *dt)
It update the DataSetType about the Indexes.
virtual char getChar(std::size_t i) const =0
Method for retrieving a signed character attribute value (1 byte long).
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
void update(const std::string &datasetName, te::da::DataSet *dataset, const std::vector< std::size_t > &properties, const te::da::ObjectIdSet *oids, const std::map< std::string, std::string > &options, std::size_t limit=0)
It updates the contents of a dataset for the set of data items.
double m_urx
Upper right corner x-coordinate.
virtual boost::int64_t getInt64(std::size_t i) const =0
Method for retrieving a 64-bit integer attribute value (8 bytes long).
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
std::auto_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
void dropSequence(const std::string &name)
It removes the sequence from the data source.
std::auto_ptr< te::da::UniqueKey > getUniqueKey(const std::string &datasetName, const std::string &name)
It gets the unique key in the dataset with the given name.
std::auto_ptr< te::dt::Property > getProperty(const std::string &datasetName, const std::string &name)
It retrieves the property with the given name from the dataset.
TraverseType
A dataset can be traversed in two ways:
std::size_t size() const
It returns the maximum number of characters for a varying string, or the number of characters for a f...
bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the foreign key constraint.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
A class that models the description of a dataset.
StringType
The subtype of string property.
void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
void insertIntoGeometryColumns(const std::string &datasetName, te::gm::GeometryProperty *geomProp)
It insert a geometry property in the geometry_clumns (SFS Schema).
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
std::auto_ptr< te::gm::Envelope > getExtent(const std::string &datasetName, const std::string &propertyName)
It retrieves the bounding rectangle of the spatial property for the given dataset.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
It models a property definition.
An static class with global definitions.
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
void optimize(const std::map< std::string, std::string > &opInfo)
For some data access drivers, this method will perform some operations to optimize the data storage...
double m_llx
Lower left corner x-coordinate.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
bool foreignKeyExists(const std::string &datasetName, const std::string &name)
It checks if a foreign key with the given name exists in the data source.
bool IsZProperty(te::gm::GeomType type)
Verifies whether Z property.
Connection * m_conn
The connection used by this transactor.
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
int getType() const
It returns the property data type.
std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
std::auto_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
bool isPropertyNameValid(const std::string &propertyName)
It checks if the given property name is valid.
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.
const std::vector< te::dt::Property * > & getReferencedProperties() const
It returns the referenced properties (on the referenced DataSetType) of this foreign key constraint...
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
PrimaryKey * getPrimaryKey() const
It returns the primary key associated to the dataset type.
A class that describes a check constraint.
An Envelope defines a 2D rectangular region.
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema.
DataSetType * getReferencedDataSetType() const
It returns the referenced DataSetType of this foreign key constraint.
void begin()
It starts a new transaction.
std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
An exception class for ADO.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that form the unique key.
const std::string & GetGeometryName(te::gm::GeomType t)
It returns the geometry OGC names.
A dataset is the unit of information manipulated by the data access module of TerraLib.
const std::map< std::string, std::string > & getConnectionInfo() const
It returns the set of parameters used to set up the access channel to the underlying repository...
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
A class that implements a connection to a ADO database.
std::auto_ptr< te::da::DataSet > getDataSet(const std::string &name, te::common::TraverseType travType=te::common::FORWARDONLY, bool connected=false, const te::common::AccessPolicy accessPolicy=te::common::RAccess)
It gets the dataset identified by the given name. A dataset can be connected or disconnected. A connected dataset, after its creation through the data source transactor, continues to depend on the connection given by its associated data source. Differently, a disconnected dataset, after its creation, no more depends of the connection given by the data source, and it continues to live after the connection has been released to the data source.
#define TR_ADO(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...