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(
TE_TR(e.Description()));
118 m_conn->getConn()->CommitTrans();
119 m_isInTransaction =
false;
123 throw Exception(
TE_TR(e.Description()));
131 m_conn->getConn()->RollbackTrans();
132 m_isInTransaction =
false;
136 throw Exception(
TE_TR(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(
TE_TR(
"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(
TE_TR(
"Method getDataSet by geometry filter: not implemented yet!"));
199 throw Exception(
TE_TR(
"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(
TE_TR(
"Method getPrepared: not implemented yet!"));
262 throw Exception(
TE_TR(
"Method getBatchExecutor: not implemented yet!"));
271 throw Exception(
TE_TR(
"Method getLastGeneratedId: not implemented yet!"));
281 std::vector<std::string> datasets;
283 ADOX::_CatalogPtr pCatalog = 0;
285 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
289 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
291 ADOX::TablesPtr tables = pCatalog->GetTables();
293 for(
long i = 0; i < tables->GetCount(); ++i)
295 ADOX::_TablePtr table = tables->GetItem(i);
296 std::string tableName = table->GetName();
298 std::string tabletype = table->GetType();
300 if(table->GetType() == _bstr_t(
"ACCESS TABLE") ||
301 table->GetType() == _bstr_t(
"LINK") ||
302 table->GetType() == _bstr_t(
"PASS-THROUGH") ||
303 table->GetType() == _bstr_t(
"SYSTEM TABLE") ||
304 table->GetType() == _bstr_t(
"VIEW") ||
305 table->GetType() == _bstr_t(
"GLOBAL TEMPORARY") ||
306 tableName ==
"geometry_columns")
309 datasets.push_back(std::string(table->GetName()));
314 throw Exception(
TE_TR(e.ErrorMessage()));
322 return getDataSetNames().size();
331 getProperties(dt.get());
333 getPrimaryKey(dt.get());
335 getUniqueKeys(dt.get());
337 getIndexes(dt.get());
339 getCheckConstraints(dt.get());
346 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
348 std::vector<te::dt::Property*> dtProperties = dt->getProperties();
350 boost::ptr_vector<te::dt::Property> properties;
352 for(std::size_t i = 0; i < dtProperties.size(); ++i)
353 properties.push_back(dtProperties[i]->clone());
360 if(!propertyExists(datasetName, name))
361 throw Exception((boost::format(
TE_TR(
"The dataset \"%1%\" has no property with this name \"%2%\"!")) % datasetName % name).str());
363 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
365 return std::auto_ptr<te::dt::Property>(dt->getProperty(name)->clone());
370 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
372 assert(propertyPos < dt->size());
374 return std::auto_ptr<te::dt::Property>(dt->getProperty(propertyPos)->clone());
379 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
381 std::vector<std::string> pNames;
383 std::size_t numProperties = dt->size();
385 for(std::size_t i = 0; i < numProperties; ++i)
386 pNames.push_back(dt->getProperty(i)->getName());
393 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
400 std::vector<std::string> datasets;
402 ADOX::_CatalogPtr pCatalog = 0;
404 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
408 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
410 ADOX::TablesPtr tables = pCatalog->GetTables();
412 ADOX::_TablePtr table;
414 for(
long i = 0; i < tables->GetCount(); ++i)
417 table = tables->GetItem(i);
418 std::string tableName = table->GetName();
420 if(tableName == datasetName)
428 ADOX::ColumnsPtr cols = table->GetColumns();
430 for(
int i = 0; i < cols->Count; ++i)
432 ADOX::_ColumnPtr col = cols->GetItem((
long)i);
434 if(((LPCSTR)(_bstr_t)col->GetName()) == name)
444 throw Exception(
TE_TR(e.ErrorMessage()));
450 const std::string& propertyName = p->
getName();
452 if(propertyExists(datasetName, propertyName))
453 throw Exception((boost::format(
TE_TR(
"The dataset already \"%1%\" has a property with this name \"%2%\"!")) % datasetName % propertyName).str());
455 ADOX::_CatalogPtr pCatalog = 0;
457 ADOX::_TablePtr pTable = 0;
459 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
463 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
465 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
467 ADOX::_ColumnPtr newColumn = 0;
469 TESTHR(newColumn.CreateInstance(__uuidof(ADOX::Column)));
471 newColumn->PutName(propertyName.c_str());
495 newColumn->PutAttributes(ADOX::adColNullable);
497 pTable->Columns->Append(_variant_t ((IDispatch*)newColumn), ado_type, 0);
511 newColumn->DefinedSize = ssize;
514 newColumn->PutAttributes(ADOX::adColNullable);
516 pTable->Columns->Append(_variant_t ((IDispatch*)newColumn), ado_type, ssize);
526 newColumn->PutAttributes(ADOX::adColNullable);
528 pTable->Columns->Append(_variant_t ((IDispatch*)newColumn), ado_type, 0);
536 addProperty(datasetName, lowerX.get());
537 addProperty(datasetName, lowerY.get());
538 addProperty(datasetName, upperX.get());
539 addProperty(datasetName, upperY.get());
541 insertIntoGeometryColumns(datasetName, static_cast<te::gm::GeometryProperty*>(p));
547 throw te::ado::Exception(
TE_TR(
"The informed type could not be mapped to ADO type system!"));
553 throw Exception(
TE_TR(e.Description()));
559 if(!propertyExists(datasetName, name))
560 throw Exception((boost::format(
TE_TR(
"The dataset \"%1%\" has no property with this name \"%2%\"!")) % datasetName % name).str());
562 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
566 ADOX::_CatalogPtr pCatalog = 0;
568 ADOX::_TablePtr pTable = 0;
570 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
574 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
582 std::string sql =
"delete from geometry_columns where f_geometry_column = '";
584 sql +=
"' AND f_table_name = '";
588 m_conn->execute(sql);
593 throw Exception(
TE_TR(e.Description()));
598 const std::string& propertyName,
599 const std::string& newPropertyName)
601 ADOX::_CatalogPtr pCatalog = 0;
603 ADOX::_TablePtr pTable = 0;
605 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
609 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
611 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
613 ADOX::_ColumnPtr col = pTable->GetColumns()->GetItem(propertyName.c_str());
615 col->PutName(newPropertyName.c_str());
617 pCatalog->GetTables()->Refresh();
621 throw Exception(
TE_TR(e.Description()));
627 std::auto_ptr<te::dt::Property> prp(newProp);
630 std::string sql(
"ALTER TABLE ");
631 sql += datasetName +
" ALTER COLUMN " + propName +
" " + type;
638 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
640 return std::auto_ptr<te::da::PrimaryKey>(
static_cast<te::da::PrimaryKey*
>(dt->getPrimaryKey()->clone()));
645 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
647 if(dt->getPrimaryKey()->getName() == name)
655 _variant_t vOptional;
656 vOptional.vt = VT_ERROR;
657 vOptional.scode = DISP_E_PARAMNOTFOUND;
659 ADOX::_KeyPtr pKey = 0;
660 ADOX::_TablePtr pTable = 0;
661 ADOX::_CatalogPtr pCatalog = 0;
663 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
664 TESTHR(pKey.CreateInstance(__uuidof(ADOX::Key)));
668 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
670 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
672 pKey->Name = pTable->Name +
"_pk";
673 pKey->Type = ADOX::adKeyPrimary;
682 TESTHR(pTable->Keys->Append(_variant_t((IDispatch *)pKey),ADOX::adKeyPrimary,vOptional,
L"",
L""));
683 pCatalog->Tables->Refresh();
687 throw Exception(
TE_TR(e.Description()));
693 ADOX::_KeyPtr pKey = 0;
694 ADOX::_TablePtr pTable = 0;
695 ADOX::_CatalogPtr pCatalog = 0;
697 std::auto_ptr<te::da::PrimaryKey> pk(getPrimaryKey(datasetName));
701 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
703 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
705 pKey = pTable->Keys->GetItem(pk->getName().c_str());
707 TESTHR(pTable->GetKeys()->Delete(_variant_t((IDispatch *)pKey)));
711 throw Exception(
TE_TR(e.Description()));
717 if(!foreignKeyExists(datasetName, name))
718 throw Exception((boost::format(
TE_TR(
"The dataset \"%1%\" has no foreign key with this name \"%2%\"!")) % datasetName % name).str());
720 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
722 return std::auto_ptr<te::da::ForeignKey>(
static_cast<te::da::ForeignKey*
>(dt->getForeignKey(name)->clone()));
727 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
729 std::vector<std::string> fkNames;
731 std::size_t numFK = dt->getNumberOfForeignKeys();
733 for(std::size_t i = 0; i < numFK; ++i)
734 fkNames.push_back(dt->getForeignKey(i)->getName());
741 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
743 std::vector<std::string> fkNames = getForeignKeyNames(datasetName);
745 if(std::find(fkNames.begin(), fkNames.end(), name) != fkNames.end())
753 _variant_t vOptional;
754 vOptional.vt = VT_ERROR;
755 vOptional.scode = DISP_E_PARAMNOTFOUND;
757 ADOX::_KeyPtr pKey = 0;
758 ADOX::_TablePtr pTable = 0;
759 ADOX::_CatalogPtr pCatalog = 0;
763 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
765 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
767 TESTHR(pKey.CreateInstance(__uuidof(ADOX::Key)));
769 pKey->Name = pTable->Name +
"_fk";
770 pKey->Type = ADOX::adKeyForeign;
783 TESTHR(pTable->Keys->Append(_variant_t((IDispatch *)pKey),ADOX::adKeyPrimary,vOptional,
L"",
L""));
785 pCatalog->Tables->Refresh();
789 throw Exception(
TE_TR(e.Description()));
795 ADOX::_KeyPtr pKey = 0;
796 ADOX::_TablePtr pTable = 0;
797 ADOX::_CatalogPtr pCatalog = 0;
802 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
804 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
806 pKey = pTable->Keys->GetItem(fkName.c_str());
808 TESTHR(pTable->GetKeys()->Delete(_variant_t((IDispatch *)pKey)));
812 throw Exception(
TE_TR(e.Description()));
818 if(!uniqueKeyExists(datasetName, name))
819 throw Exception((boost::format(
TE_TR(
"The dataset \"%1%\" has no unique key with this name \"%2%\"!")) % datasetName % name).str());
821 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
823 return std::auto_ptr<te::da::UniqueKey>(
static_cast<te::da::UniqueKey*
>(dt->getUniqueKey(name)->clone()));
828 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
830 std::vector<std::string> ukNames;
832 std::size_t numUKs = dt->getNumberOfUniqueKeys();
834 for(std::size_t i = 0; i < numUKs; ++i)
835 ukNames.push_back(dt->getUniqueKey(i)->getName());
842 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
844 std::vector<std::string> ukNames = getUniqueKeyNames(datasetName);
846 if(std::find(ukNames.begin(), ukNames.end(), name) != ukNames.end())
854 _variant_t vOptional;
855 vOptional.vt = VT_ERROR;
856 vOptional.scode = DISP_E_PARAMNOTFOUND;
858 ADOX::_KeyPtr pKey = 0;
859 ADOX::_TablePtr pTable = 0;
860 ADOX::_CatalogPtr pCatalog = 0;
862 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
863 TESTHR(pKey.CreateInstance(__uuidof(ADOX::Key)));
867 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
869 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
871 pKey->Name = pTable->Name +
"_uk";
872 pKey->Type = ADOX::adKeyUnique;
881 TESTHR(pTable->Keys->Append(_variant_t((IDispatch *)pKey),ADOX::adKeyUnique,vOptional,
L"",
L""));
883 pCatalog->Tables->Refresh();
887 throw Exception(
TE_TR(e.Description()));
893 ADOX::_KeyPtr pKey = 0;
894 ADOX::_TablePtr pTable = 0;
895 ADOX::_CatalogPtr pCatalog = 0;
899 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
901 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
903 pKey = pTable->Keys->GetItem(name.c_str());
905 TESTHR(pTable->GetKeys()->Delete(_variant_t((IDispatch *)pKey)));
909 throw Exception(
TE_TR(e.Description()));
915 if(!checkConstraintExists(datasetName, name))
916 throw Exception((boost::format(
TE_TR(
"The dataset \"%1%\" has no check constraint with this name \"%2%\"!")) % datasetName % name).str());
918 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
920 return std::auto_ptr<te::da::CheckConstraint>(
static_cast<te::da::CheckConstraint*
>(dt->getCheckConstraint(name)->clone()));
925 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
927 std::vector<std::string> ccNames;
929 std::size_t numCCs = dt->getNumberOfCheckConstraints();
931 for(std::size_t i = 0; i < numCCs; ++i)
932 ccNames.push_back(dt->getCheckConstraint(i)->getName());
939 std::vector<std::string> ccNames = getCheckConstraintNames(datasetName);
941 if(std::find(ccNames.begin(), ccNames.end(), name) != ccNames.end())
949 throw Exception(
TE_TR(
"Method addCheckConstraint: not implemented yet!"));
954 throw Exception(
TE_TR(
"Method dropCheckConstraint: not implemented yet!"));
959 if(!indexExists(datasetName, name))
960 throw Exception((boost::format(
TE_TR(
"The dataset \"%1%\" has no index with this name \"%2%\"!")) % datasetName % name).str());
962 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
964 return std::auto_ptr<te::da::Index>(dt->getIndex(name)->clone());
969 std::vector<std::string> idxNames;
971 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
973 std::size_t numIdxs = dt->getNumberOfIndexes();
975 for(std::size_t i = 0; i < numIdxs; ++i)
976 idxNames.push_back(dt->getIndex(i)->getName());
983 std::vector<std::string> idxNames = getIndexNames(datasetName);
985 if(std::find(idxNames.begin(), idxNames.end(), name) != idxNames.end())
992 const std::map<std::string, std::string>& options)
994 ADOX::_IndexPtr pIndex = 0;
995 ADOX::_TablePtr pTable = 0;
996 ADOX::_CatalogPtr pCatalog = 0;
998 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
999 TESTHR(pIndex.CreateInstance(__uuidof(ADOX::Index)));
1003 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
1005 pTable = pCatalog->Tables->GetItem(datasetName.c_str());
1007 pIndex->Name = idx->
getName().c_str();
1009 std::vector<te::dt::Property*> idxProps = idx->
getProperties();
1010 for(
size_t i = 0; i < idxProps.size(); i++)
1019 TESTHR(pTable->Indexes->Append(_variant_t((IDispatch *)pIndex)));
1021 catch(_com_error& e)
1023 throw Exception(
TE_TR(e.Description()));
1029 if(!indexExists(datasetName, idxName))
1030 throw Exception((boost::format(
TE_TR(
"The dataset \"%1%\" has no index with this name: \"%2%\"!")) % datasetName % idxName).str());
1032 std::string sql(
"DROP INDEX ");
1037 std::auto_ptr<te::da::DataSetType> dt(getDataSetType(datasetName));
1046 throw Exception(
TE_TR(
"Method getSequence: not implemented yet!"));
1051 throw Exception(
TE_TR(
"Method getSequenceNames: not implemented yet!"));
1056 throw Exception(
TE_TR(
"Method sequenceExists: not implemented yet!"));
1061 throw Exception(
TE_TR(
"Method addSequence: not implemented yet!"));
1066 throw Exception(
TE_TR(
"Method dropSequence: not implemented yet!"));
1070 const std::string& )
1072 if(!dataSetExists(datasetName))
1073 throw Exception(
TE_TR(
"The Data Set Type does not exist!"));
1075 std::string sql =
"SELECT MIN(lower_x), MIN(lower_y), MAX(upper_x), MAX(upper_y) from " + datasetName;
1077 std::auto_ptr<te::da::DataSet> resultBox(query(sql));
1083 resultBox->moveFirst();
1084 env->m_llx = resultBox->getDouble(0);
1085 env->m_lly = resultBox->getDouble(1);
1086 env->m_urx = resultBox->getDouble(2);
1087 env->m_ury = resultBox->getDouble(3);
1091 throw Exception(
TE_TR(
"Error when calculating the envelope!"));
1100 return getExtent(datasetName, 0);
1105 std::auto_ptr<te::da::DataSet> result(getDataSet(datasetName));
1107 return result->size();
1112 std::vector<std::string> datasetNames = getDataSetNames();
1114 if(datasetNames.empty())
1122 std::vector<std::string> datasetNames = getDataSetNames();
1124 if(std::find(datasetNames.begin(), datasetNames.end(), name) != datasetNames.end())
1132 ADOX::_TablePtr pTable = 0;
1133 ADOX::_CatalogPtr pCatalog = 0;
1135 TESTHR(pTable.CreateInstance(__uuidof (ADOX::Table)));
1136 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1140 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
1142 pTable->Name = dt->
getName().c_str();
1144 TESTHR(pCatalog->Tables->Append(_variant_t((IDispatch*)pTable)));
1147 catch(_com_error &e)
1149 throw Exception(
TE_TR(e.ErrorMessage()));
1152 std::size_t ncols = dt->
size();
1154 for(std::size_t i = 0; i < ncols; ++i)
1162 const std::string& ,
1163 const std::map<std::string, std::string>& )
1165 throw Exception(
TE_TR(
"Method cloneDataSet: not implemented yet!"));
1170 ADOX::_CatalogPtr pCatalog = 0;
1172 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1176 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
1178 TESTHR(pCatalog->Tables->Delete(name.c_str()));
1180 catch(_com_error& e)
1182 throw Exception(
TE_TR(e.Description()));
1188 ADOX::_CatalogPtr pCatalog = 0;
1190 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1194 pCatalog->Tables->GetItem(name.c_str())->PutName(newName.c_str());
1196 catch(_com_error& e)
1198 throw Exception(
TE_TR(e.Description()));
1204 const std::map<std::string, std::string>& options,
1207 _RecordsetPtr recset;
1208 TESTHR(recset.CreateInstance(__uuidof(Recordset)));
1212 TESTHR(recset->Open(_bstr_t(datasetName.c_str()),
1213 _variant_t((IDispatch*)m_conn->getConn(),
true), adOpenKeyset, adLockOptimistic, adCmdTable));
1217 TESTHR(recset->AddNew());
1237 recset->GetFields()->GetItem(pname.c_str())->Value = (_bstr_t)d->
getChar(pname.c_str());
1241 recset->GetFields()->GetItem(pname.c_str())->Value = (_bstr_t)d->
getUChar(pname.c_str());
1245 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getInt16(pname.c_str());
1249 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getInt32(pname.c_str());
1253 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getInt64(pname.c_str());
1262 double dval = boost::lexical_cast<
double>(sval);
1263 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)(dval);
1269 std::auto_ptr<te::dt::DateTime> dtm(d->
getDateTime(i));
1273 recset->GetFields()->GetItem(pname.c_str())->Value = (_bstr_t)dtt.c_str();
1279 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getFloat(pname.c_str());
1283 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getDouble(pname.c_str());
1287 recset->GetFields()->GetItem(pname.c_str())->Value = (_bstr_t)d->
getString(pname.c_str()).c_str();
1291 recset->GetFields()->GetItem(pname.c_str())->Value = (_variant_t)d->
getBool(pname.c_str());
1309 std::auto_ptr<te::gm::Geometry> geometry(d->
getGeometry(pname));
1312 recset->GetFields()->GetItem(
"lower_x")->Value = (_variant_t)env->
m_llx;
1313 recset->GetFields()->GetItem(
"lower_y")->Value = (_variant_t)env->m_lly;
1314 recset->GetFields()->GetItem(
"upper_x")->Value = (_variant_t)env->m_urx;
1315 recset->GetFields()->GetItem(
"upper_y")->Value = (_variant_t)env->m_ury;
1320 recset->Fields->GetItem(pname.c_str())->AppendChunk (var);
1326 throw te::ado::Exception(
TE_TR(
"The informed type could not be mapped to ADO type system!"));
1331 TESTHR(recset->Update());
1335 catch(_com_error& e)
1337 throw Exception(
TE_TR(e.Description()));
1343 ADOX::_CatalogPtr pCatalog = 0;
1345 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1349 pCatalog->PutActiveConnection(variant_t((IDispatch *)m_conn->getConn()));
1351 TESTHR(pCatalog->Tables->Delete(datasetName.c_str()));
1353 catch(_com_error& e)
1355 throw Exception(
TE_TR(e.Description()));
1361 const std::vector<std::size_t>& properties,
1363 const std::map<std::string, std::string>& options,
1371 const std::vector< std::set<int> >& properties,
1372 const std::vector<size_t>& ids)
1378 std::set<int>::iterator it;
1386 std::string sql =
"UPDATE " + datasetName +
" SET ";
1387 plst = properties[i];
1392 for(it = plst.begin(); it != plst.end(); ++it)
1400 pName +=
"=\"" + dataset->
getAsString(*it) +
"\"";
1407 for(
size_t j=0; j<ids.size(); ++j)
1420 sql += pName +
" WHERE " + id;
1429 catch(te::ado::Exception& e)
1444 _ConnectionPtr adoConn = m_conn->getConn();
1446 ADOX::_CatalogPtr pCatalog = 0;
1448 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1452 pCatalog->PutActiveConnection(variant_t((IDispatch *)adoConn));
1454 catch(_com_error& e)
1456 throw Exception(
TE_TR(e.Description()));
1458 ADOX::TablesPtr tables = pCatalog->GetTables();
1460 ADOX::_TablePtr t = tables->GetItem(dt->
getName().c_str());
1462 ADOX::KeysPtr keys = t->GetKeys();
1464 ADOX::_KeyPtr pk = 0;
1466 for(
long i = 0; i < keys->Count; i++)
1468 if(keys->GetItem(i)->GetType() == ADOX::adKeyPrimary)
1469 pk = keys->GetItem(i);
1478 ADOX::ColumnsPtr cols = pk->GetColumns();
1482 for(
long i = 0; i < cols->GetCount(); i++)
1483 tlPk->
add(dt->
getProperty(std::string(cols->GetItem(i)->GetName())));
1488 std::string dsName = dt->
getName();
1491 ADOX::DataTypeEnum colType;
1492 std::map<int, std::string> colNamesMap;
1493 std::map<int, ADOX::DataTypeEnum> colTypesMap;
1494 std::map<int, int> charLengthMap;
1495 std::map<int, bool> isRequiredMap;
1496 std::map<int, bool> hasDefaultMap;
1497 std::map<int, std::string> defaultValueMap;
1499 _ConnectionPtr conn = 0;
1505 conn = m_conn->getConn();
1507 _RecordsetPtr rs = NULL;
1509 TESTHR(rs.CreateInstance(__uuidof(Recordset)));
1513 SAFEARRAY FAR* psa = NULL;
1514 SAFEARRAYBOUND rgsabound;
1518 rgsabound.lLbound = 0;
1519 rgsabound.cElements = 3;
1520 psa = SafeArrayCreate(VT_VARIANT, 1, &rgsabound);
1522 var[0].vt = VT_EMPTY;
1523 var[1].vt = VT_EMPTY;
1524 var[2] = dsName.c_str();
1527 for(LONG i = 0; i < 3; ++i)
1528 hr = SafeArrayPutElement(psa, &i, &var[i]);
1530 Array.vt = VT_ARRAY | VT_VARIANT;
1533 rs = conn->OpenSchema(adSchemaColumns, &Array, vtMissing);
1536 while (!(rs->EndOfFile))
1539 _bstr_t columnName = rs->Fields->GetItem(
"COLUMN_NAME")->Value;
1540 pos = rs->Fields->GetItem(
"ORDINAL_POSITION")->Value;
1542 colNamesMap[pos] = (LPCSTR)columnName;
1545 colType = ADOX::DataTypeEnum(
int(rs->Fields->GetItem(
"DATA_TYPE")->Value));
1546 colTypesMap[pos] = colType;
1549 _variant_t length = rs->Fields->GetItem(
"CHARACTER_MAXIMUM_LENGTH")->Value;
1551 if(length.vt != VT_NULL)
1552 charLength = (int)length.dblVal;
1553 charLengthMap[pos] = charLength;
1556 bool nullVal = rs->Fields->GetItem(
"IS_NULLABLE")->Value;
1557 isRequiredMap[pos] = !nullVal;
1560 bool hasDefault = rs->Fields->GetItem(
"COLUMN_HASDEFAULT")->Value;
1561 hasDefaultMap[pos] = !hasDefault;
1564 std::string defaultStr;
1567 _bstr_t defaultValue = rs->Fields->GetItem(
"COLUMN_DEFAULT")->Value;
1568 defaultStr = (LPSTR)defaultValue;
1571 defaultValueMap[pos] = defaultStr;
1577 catch (_com_error& e)
1579 std::cout <<
"Error = " << (
char*) e.ErrorMessage() << std::endl;
1583 for(
int i = 0; i < numCols; ++i)
1586 ADOX::DataTypeEnum colType = colTypesMap[i];
1587 std::string colName = colNamesMap[i];
1603 case ::adLongVarChar:
1604 case ::adLongVarWChar:
1612 sp->
setSize(charLengthMap[i]);
1617 case ADOX::adTinyInt:
1618 case ADOX::adSmallInt:
1619 case ADOX::adInteger:
1620 case ADOX::adBigInt:
1621 case ADOX::adSingle:
1622 case ADOX::adDouble:
1623 case ADOX::adDecimal:
1624 case ::adUnsignedBigInt:
1625 case ::adUnsignedInt:
1626 case ::adUnsignedSmallInt:
1627 case ::adUnsignedTinyInt:
1636 case ADOX::adBinary:
1637 case ADOX::adLongVarBinary:
1640 std::map<std::string, std::string> geomColumns = m_ds->getGeomColumns();
1641 std::map<std::string, std::string>::iterator it = geomColumns.find(dsName);
1643 if(it != geomColumns.end())
1645 if(it->second == colName)
1659 case ADOX::adDBDate:
1660 case ADOX::adDBTime:
1661 case ADOX::adDBTimeStamp:
1676 _ConnectionPtr adoConn = m_conn->getConn();
1678 ADOX::_CatalogPtr pCatalog = 0;
1680 TESTHR(pCatalog.CreateInstance(__uuidof(ADOX::Catalog)));
1684 pCatalog->PutActiveConnection(variant_t((IDispatch *)adoConn));
1686 catch(_com_error& e)
1688 throw Exception(
TE_TR(e.Description()));
1691 ADOX::TablesPtr tables = pCatalog->GetTables();
1693 ADOX::_TablePtr t = tables->GetItem(dt->
getName().c_str());
1695 ADOX::KeysPtr keys = t->GetKeys();
1697 for(
long i = 0; i < keys->Count; i++)
1699 if(keys->GetItem(i)->GetType() == ADOX::adKeyUnique)
1701 ADOX::_KeyPtr uk = keys->GetItem(i);
1705 ADOX::ColumnsPtr cols = uk->GetColumns();
1707 for(
long j = 0; j < cols->Count; j++)
1708 tlUk->
add(dt->
getProperty(std::string(cols->GetItem(i)->GetName())));
1715 _ConnectionPtr adoConn = m_conn->getConn();
1717 ADOX::_CatalogPtr pCatalog = 0;
1719 TESTHR((pCatalog.CreateInstance(__uuidof(ADOX::Catalog))));
1723 pCatalog->PutActiveConnection(variant_t((IDispatch *)adoConn));
1725 catch(_com_error& e)
1727 throw Exception(
TE_TR(e.Description()));
1730 ADOX::TablesPtr tables = pCatalog->GetTables();
1732 ADOX::_TablePtr t = tables->GetItem(dt->
getName().c_str());
1734 ADOX::IndexesPtr idxs = t->GetIndexes();
1736 for(
long i = 0; i < idxs->GetCount(); i++)
1738 ADOX::_IndexPtr idx = idxs->GetItem(i);
1741 tlIdx->
setName(std::string(idx->GetName()));
1743 std::vector<te::dt::Property*> props;
1745 ADOX::ColumnsPtr cols = idx->GetColumns();
1746 for(
long i = 0; i < cols->GetCount(); i++)
1747 props.push_back(dt->
getProperty(std::string(cols->GetItem(i)->GetName())));
1757 _RecordsetPtr rs = NULL;
1759 std::string dtName = dt->
getName();
1761 std::string str =
"[" + dtName +
"]";
1767 _ConnectionPtr adoConn = m_conn->getConn();
1769 TESTHR(rs.CreateInstance(__uuidof(Recordset)));
1771 rs = adoConn->OpenSchema(adSchemaCheckConstraints);
1773 while (!(rs->EndOfFile))
1775 std::string constraintName = (LPCSTR)(bstr_t)(rs->Fields->GetItem(
"CONSTRAINT_NAME")->GetValue());
1777 if(constraintName.find(str) != std::string::npos)
1780 std::string checkClause = (LPCSTR)(bstr_t)(rs->Fields->GetItem(
"CHECK_CLAUSE")->GetValue());
1787 catch(_com_error& e)
1789 throw Exception(
TE_TR(e.Description()));
1793 if(rs && rs->State == adStateOpen)
1800 _ConnectionPtr adoConn = m_conn->getConn();
1802 int coord_dimension = 2;
1805 coord_dimension = 3;
1807 _RecordsetPtr recset;
1808 TESTHR(recset.CreateInstance(__uuidof(Recordset)));
1812 TESTHR(recset->Open(_bstr_t(
"geometry_columns"),
1813 _variant_t((IDispatch*)adoConn,
true), adOpenKeyset, adLockOptimistic, adCmdTable));
1815 TESTHR(recset->AddNew());
1817 recset->GetFields()->GetItem(
"f_table_catalog")->Value = (_bstr_t)std::string(
"''").c_str();
1818 recset->GetFields()->GetItem(
"f_table_schema")->Value = (_bstr_t)std::string(
"public").c_str();
1819 recset->GetFields()->GetItem(
"f_table_name")->Value = (_bstr_t)datasetName.c_str();
1820 recset->GetFields()->GetItem(
"f_geometry_column")->Value = (_bstr_t)geomProp->
getName().c_str();
1821 recset->GetFields()->GetItem(
"coord_dimension")->Value = (_variant_t)coord_dimension;
1822 recset->GetFields()->GetItem(
"srid")->Value = (_variant_t)geomProp->
getSRID();
1827 catch(_com_error& e)
1829 throw Exception(
TE_TR(e.Description()));
1832 m_ds->registerGeometryColumn(datasetName, geomProp->
getName());
Property * getProperty(std::size_t i) const
It returns the i-th property.
void add(te::dt::Property *p)
It adds the property to the list of properties that participates in the unique key.
StringType
The subtype of string property.
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.
std::auto_ptr< te::da::BatchExecutor > getBatchExecutor()
It creates a batch command executor.
virtual std::auto_ptr< te::dt::DateTime > getDateTime(std::size_t i) const =0
Method for retrieving a date and time attribute value.
virtual boost::int16_t getInt16(std::size_t i) const =0
Method for retrieving a 16-bit integer attribute value (2 bytes long).
std::vector< std::string > getForeignKeyNames(const std::string &datasetName)
It gets the foreign key names of the given dataset.
void add(te::dt::Property *p)
It adds a property to the list of properties of the primary key.
DataSet class implementation for Microsoft Access driver.
void dropCheckConstraint(const std::string &datasetName, const std::string &name)
It removes the check constraint from the dataset.
std::vector< std::string > getCheckConstraintNames(const std::string &datasetName)
It gets the check constraint names of the given dataset.
void renameDataSet(const std::string &name, const std::string &newName)
It renames a dataset.
int GetSRID(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
Read the geometry_columns table end return a SRID.
virtual boost::int32_t getInt32(std::size_t i) const =0
Method for retrieving a 32-bit integer attribute value (4 bytes long).
std::vector< std::string > getSequenceNames()
It gets the sequence names available in the data source.
void remove(const std::string &datasetName, const te::da::ObjectIdSet *oids=0)
It removes all the informed items from the dataset.
void getIndexes(te::da::DataSetType *dt)
It update the DataSetType about the Indexes.
An atomic property like an integer or double.
CharEncoding
Supported charsets (character encoding).
std::size_t getNumberOfItems(const std::string &datasetName)
It retrieves the number of items of the given dataset.
void getUniqueKeys(te::da::DataSetType *dt)
It update the DataSetType about the Unique Keys.
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.
const std::string & GetGeometryName(te::gm::GeomType t)
It returns the geometry OGC names.
te::gm::GeomType GetType(_ConnectionPtr adoConn, std::string tableName, std::string geomPropName)
Read the geometry_columns table end return a geometry type.
virtual char getChar(std::size_t i) const =0
Method for retrieving a signed character attribute value (1 byte long).
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.
virtual bool getBool(std::size_t i) const =0
Method for retrieving a boolean attribute value.
A class that models the description of a dataset.
int Convert2Terralib(ADOX::DataTypeEnum adoType)
Bind ADOX Type to TerraLib Type.
bool isInTransaction() const
It returns true if a transaction is in progress, otherwise, it returns false.
boost::int64_t getLastGeneratedId()
It returns the last id generated by an insertion command.
std::auto_ptr< te::da::ForeignKey > getForeignKey(const std::string &datasetName, const std::string &name)
It retrieves the foreign key from the given dataset.
virtual boost::int64_t getInt64(std::size_t i) const =0
Method for retrieving a 64-bit integer attribute value (8 bytes long).
void addForeignKey(const std::string &datasetName, te::da::ForeignKey *fk)
It adds a foreign key constraint to a dataset.
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...
std::vector< std::string > getIndexNames(const std::string &datasetName)
It gets the index names of the given dataset.
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.
double m_urx
Upper right corner x-coordinate.
PrimaryKey * getPrimaryKey() const
It returns the primary key associated to the dataset type.
SpatialRelation
Spatial relations between geometric objects.
bool hasDataSets()
It checks if the data source has any dataset.
It describes a sequence (a number generator).
A visitor for building an SQL statement using ADO dialect.
A class that describes a check constraint.
An abstract class for data providers like a DBMS, Web Services or a regular file. ...
std::string MakeConnectionStr(const std::map< std::string, std::string > &dsInfo)
Create a connection string based on a map.
void addProperty(const std::string &datasetName, te::dt::Property *p)
It adds a new property to the dataset schema.
virtual std::string getNumeric(std::size_t i) const =0
Method for retrieving a numeric attribute value.
#define TE_TR(message)
It marks a string in order to get translated.
An exception class for ADO.
std::string GetFormattedDateTime(te::dt::DateTime *dateTime)
It gets a formatted DateTime string for ADO.
A class that implements a connection to a ADO database.
std::size_t size() const
It returns the maximum number of characters for a varying string, or the number of characters for a f...
It models a property definition.
virtual double getDouble(std::size_t i) const =0
Method for retrieving a double attribute value.
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.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the primary key.
void addSequence(te::da::Sequence *sequence)
It creates a new sequence 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.
std::vector< std::string > getUniqueKeyNames(const std::string &datasetName)
It gets the unique key names of the given dataset.
virtual bool moveNext()=0
It moves the internal pointer to the next item of the collection.
AccessPolicy
Supported data access policies (can be used as bitfield).
TraverseType
A dataset can be traversed in two ways:
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.
Implementation of a random-access dataset class for the TerraLib In-Memory Data Access driver...
Implementation of a dataset for the ADO driver.
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.
std::string GetAdoStringType(const int &terralib)
Bind TerraLib type to an ADO valid fiel type name.
double m_llx
Lower left corner x-coordinate.
bool primaryKeyExists(const std::string &datasetName, const std::string &name)
It checks if a primary key exists in the dataset.
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...
bool sequenceExists(const std::string &name)
It checks if a sequence with the given name exists in the data source.
void begin()
It starts a new transaction.
int getSRID() const
It returns the spatial reference system identifier associated to this property.
void changePropertyDefinition(const std::string &datasetName, const std::string &propName, te::dt::Property *newProp)
virtual float getFloat(std::size_t i) const =0
Method for retrieving a float attribute value.
An Envelope defines a 2D rectangular region.
void addCheckConstraint(const std::string &datasetName, te::da::CheckConstraint *cc)
It adds a check constraint to the dataset.
This class represents a set of unique ids created in the same context. i.e. from the same data set...
virtual std::string getPropertyName(std::size_t i) const =0
It returns the property name at position pos.
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.
virtual bool isNull(std::size_t i) const =0
It checks if the attribute value is NULL.
void dropProperty(const std::string &datasetName, const std::string &name)
It removes a property from the given dataset.
void insertIntoGeometryColumns(const std::string &datasetName, te::gm::GeometryProperty *geomProp)
It insert a geometry property in the geometry_clumns (SFS Schema).
std::string escape(const std::string &value)
It escapes a string for using in commands and queries.
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.
GeomType getGeometryType() const
It returns the geometry subtype allowed for the property.
std::vector< std::string > getDataSetNames()
It It gets the dataset names available in the data source.
void addUniqueKey(const std::string &datasetName, te::da::UniqueKey *uk)
It adds a unique key constraint to the dataset.
void addPrimaryKey(const std::string &datasetName, te::da::PrimaryKey *pk)
It adds a primary key constraint to the dataset schema.
DataSetType * getReferencedDataSetType() const
It returns the referenced DataSetType of this foreign key constraint.
bool propertyExists(const std::string &datasetName, const std::string &name)
It checks if a property with the given name exists in the dataset.
void dropIndex(const std::string &datasetName, const std::string &idxName)
It removes the index from the dataset schema.
It models a foreign key constraint for a DataSetType.
virtual std::string getAsString(std::size_t i, int precision=0) const
Method for retrieving a data value as a string plain representation.
bool isRequired() const
It returns true if the attribute is required, otherwise it returns false.
The type for string types: FIXED_STRING, VAR_STRING or STRING.
It describes a unique key (uk) constraint.
void setProperties(const std::vector< te::dt::Property * > &properties)
It sets the properties that take part of the index.
Property * getParent() const
It returns the parent of this property, or NULL, if it doesn't have one.
std::size_t size() const
It returns the number of properties of the CompositeProperty.
void rollBack()
It aborts the transaction. Any changes will be rolled-back.
A visitor for building an SQL statement using ADO dialect.
std::auto_ptr< te::da::PrimaryKey > getPrimaryKey(const std::string &datasetName)
It retrieves the primary key of the dataset.
virtual std::size_t getNumProperties() const =0
It returns the number of properties that composes an item of the dataset.
Geometry is the root class of the geometries hierarchy, it follows OGC and ISO standards.
void dropDataSet(const std::string &name)
It removes the dataset schema from the data source.
void renameProperty(const std::string &datasetName, const std::string &propertyName, const std::string &newPropertyName)
It renames a property of the given dataset.
A Select models a query to be used when retrieving data from a DataSource.
virtual std::auto_ptr< te::gm::Geometry > getGeometry(std::size_t i) const =0
Method for retrieving a geometric attribute value.
void getCheckConstraints(te::da::DataSetType *dt)
It update the DataSetType about the Check Constraints.
Connection * m_conn
The connection used by this transactor.
double m_lly
Lower left corner y-coordinate.
Implementation of the data source class for the ADO driver.
void commit()
It commits the transaction.
void dropPrimaryKey(const std::string &datasetName)
It removes the primary key constraint from the dataset schema.
DataSourceTransactor class implementation for Microsoft Access driver.
int getType() const
It returns the property data type.
void add(Constraint *c)
It adds a new constraint.
std::size_t getNumberOfDataSets()
It retrieves the number of data sets available in the data source.
A dataset is the unit of information manipulated by the data access module of TerraLib.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that form the unique key.
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.
te::common::CharEncoding getEncoding()
It return the DataSource current encoding.
Utility functions for ADO.
double m_ury
Upper right corner y-coordinate.
virtual ReturnType accept(VisitorType &guest) const =0
It call the visit method from the guest object.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the index.
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.
It describes a primary key (pk) constraint.
void dropForeignKey(const std::string &datasetName, const std::string &fkName)
It removes the foreign key constraint from the dataset schema.
void setExpression(const std::string &e)
It sets the check constraint expression.
ADOX::DataTypeEnum Convert2Ado(int terralib)
Bind TerraLib Type to ADO Type.
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.
void setRequired(bool r)
It tells if the property is required or not.
void dropUniqueKey(const std::string &datasetName, const std::string &name)
It removes the unique key constraint from the dataset.
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...
A class that implements a connection to a ADO database.
bool IsZProperty(te::gm::GeomType type)
Verifies whether Z property.
void setName(const std::string &name)
It sets the index name.
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...
virtual std::string getString(std::size_t i) const =0
Method for retrieving a string value attribute.
te::da::DataSource * getDataSource() const
It returns the parent data source of the transactor.
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.
Transactor(DataSource *ds)
virtual unsigned char getUChar(std::size_t i) const =0
Method for retrieving an unsigned character attribute value (1 byte long).
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.
std::vector< std::string > getPropertyNames(const std::string &datasetName)
It gets the property names of the given dataset.
std::size_t getNumberOfProperties(const std::string &datasetName)
It gets the number of properties of the given dataset.
virtual int getPropertyDataType(std::size_t i) const =0
It returns the underlying data type of the property at position pos.
const std::vector< te::dt::Property * > & getProperties() const
It returns the properties that take part of the foreign key constraint.
boost::ptr_vector< te::dt::Property > getProperties(const std::string &datasetName)
It retrieves the properties of the dataset.
virtual bool moveFirst()=0
It moves the internal pointer to the first item in the collection.
std::auto_ptr< te::da::Sequence > getSequence(const std::string &name)
It gets the sequence with the given name in the data source.
const std::vector< te::dt::Property * > & getReferencedProperties() const
It returns the referenced properties (on the referenced DataSetType) of this foreign key constraint...
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 execute(const te::da::Query &command)
It executes the specified command using a generic query representation.
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.
It describes an index associated to a DataSetType.
An static class with global definitions.
std::auto_ptr< te::da::DataSetType > getDataSetType(const std::string &name)
It gets information about the given dataset.
void setPrimaryKey(PrimaryKey *pk)
It sets the primary key constraint.
bool uniqueKeyExists(const std::string &datasetName, const std::string &name)
It checks if a unique key with the given name exists in the dataset.
void dropSequence(const std::string &name)
It removes the sequence from the data source.
const std::string & getName() const
It returns the property name.
bool dataSetExists(const std::string &name)
It checks if a dataset with the given name exists in the data source.
const std::string & getName() const
It returns the index name.