27 #include "../../../common/BoostUtils.h"
28 #include "../../../datatype/AbstractData.h"
29 #include "../../../datatype/Enums.h"
30 #include "../../../datatype/serialization/xml/Serializer.h"
31 #include "../../../datatype/StringProperty.h"
32 #include "../../../datatype/Utils.h"
33 #include "../../../geometry/Geometry.h"
34 #include "../../../geometry/WKTReader.h"
35 #include "../../../xml/Reader.h"
36 #include "../../../xml/ReaderFactory.h"
37 #include "../../../xml/Writer.h"
38 #include "../../dataset/DataSetType.h"
39 #include "../../datasource/DataSourceCapabilities.h"
40 #include "../../datasource/DataSourceCatalog.h"
41 #include "../../datasource/DataSourceInfo.h"
42 #include "../../datasource/DataSourceInfoManager.h"
43 #include "../../query/BinaryFunction.h"
44 #include "../../query/BinaryOpEncoder.h"
45 #include "../../query/DataSetName.h"
46 #include "../../query/Distinct.h"
47 #include "../../query/Expression.h"
48 #include "../../query/Field.h"
49 #include "../../query/FromItem.h"
50 #include "../../query/Function.h"
51 #include "../../query/FunctionEncoder.h"
52 #include "../../query/GroupByItem.h"
53 #include "../../query/Having.h"
54 #include "../../query/Literal.h"
55 #include "../../query/LiteralDouble.h"
56 #include "../../query/LiteralGeom.h"
57 #include "../../query/LiteralInt16.h"
58 #include "../../query/LiteralInt32.h"
59 #include "../../query/LiteralInt64.h"
60 #include "../../query/LiteralString.h"
61 #include "../../query/OrderByItem.h"
62 #include "../../query/PropertyName.h"
63 #include "../../query/Select.h"
64 #include "../../query/SQLDialect.h"
65 #include "../../query/SQLFunctionEncoder.h"
66 #include "../../query/TemplateEncoder.h"
67 #include "../../query/UnaryOpEncoder.h"
68 #include "../../query/Where.h"
69 #include "../../Exception.h"
78 #include <boost/algorithm/string/case_conv.hpp>
79 #include <boost/format.hpp>
80 #include <boost/lexical_cast.hpp>
81 #include <boost/algorithm/string/replace.hpp>
87 xmlReader->read(datasourcesFileName);
89 if(!xmlReader->next())
90 throw te::da::Exception((boost::format(
TR_DATAACCESS(
"Could not read data source information in file: %1%.")) % datasourcesFileName).str());
93 throw te::da::Exception((boost::format(
TR_DATAACCESS(
"Error reading the document %1%, the start element wasn't found.")) % datasourcesFileName).str());
95 if(xmlReader->getElementLocalName() !=
"DataSourceList")
96 throw te::da::Exception((boost::format(
TR_DATAACCESS(
"The first tag in the document %1% is not 'DataSourceList'.")) % datasourcesFileName).str());
98 if(!xmlReader->next())
102 (xmlReader->getElementLocalName() ==
"DataSource"))
116 ds->setType(reader.
getAttr(1));
117 ds->setAccessDriver(reader.
getAttr(2));
148 std::map<std::string, std::string> conninfo;
150 while(reader.
next() &&
174 conninfo[paramName] = paramValue;
186 ds->setConnInfo(conninfo);
193 std::fstream ostr(fileName.c_str(), std::ios_base::out);
209 const char* te_env = getenv(
"TERRALIB_DIR");
212 throw te::da::Exception(
TR_DATAACCESS(
"Environment variable \"TERRALIB_DIR\" not found.\nTry to set it before run the application."));
214 std::string schema_loc(te_env);
215 schema_loc +=
"/schemas/terralib";
217 boost::replace_all(schema_loc,
" ",
"%20");
219 schema_loc =
"file:///" + schema_loc;
225 writer.
writeAttribute(
"xmlns:xsd",
"http://www.w3.org/2001/XMLSchema-instance");
226 writer.
writeAttribute(
"xmlns:te_common",
"http://www.terralib.org/schemas/common");
227 writer.
writeAttribute(
"xmlns:te_da",
"http://www.terralib.org/schemas/dataaccess");
228 writer.
writeAttribute(
"xmlns",
"http://www.terralib.org/schemas/dataaccess");
229 writer.
writeAttribute(
"xsd:schemaLocation",
"http://www.terralib.org/schemas/dataaccess " + schema_loc +
"/dataaccess/dataaccess.xsd");
237 for(it=itBegin; it!=itEnd; ++it)
239 bool ogrDsrc = it->second->getAccessDriver() ==
"OGR";
245 writer.
writeAttribute(
"access_driver", it->second->getAccessDriver());
256 std::map<std::string, std::string> info = it->second->getConnInfo();
257 std::map<std::string, std::string>::iterator conIt;
259 for(conIt=info.begin(); conIt!=info.end(); ++conIt)
314 return catalog.release();
319 std::fstream ostr(fileName.c_str(), std::ios_base::out);
339 writer.
writeAttribute(
"xmlns:xlink",
"http://www.w3.org/1999/xlink");
340 writer.
writeAttribute(
"xmlns:xsd",
"http://www.w3.org/2001/XMLSchema-instance");
341 writer.
writeAttribute(
"xmlns",
"http://www.terralib.org/schemas/da");
342 writer.
writeAttribute(
"xsd:schemaLocation",
"http://www.terralib.org/schemas/da C:/Users/gribeiro/Documents/terralib5/trunk/myschemas/terralib/da/catalog.xsd");
352 for(std::size_t i = 0; i < ndatasets; ++i)
366 std::string name = reader.
getAttr(1);
367 std::string title = reader.
getAttr(2);
378 std::auto_ptr<te::dt::Property> p(
ReadProperty(reader));
379 dt->add(p.release());
396 const std::size_t nprops = dt->
size();
398 for(std::size_t i = 0; i < nprops; ++i)
406 if(accessPolicy ==
"NO_ACCESS")
408 else if (accessPolicy ==
"R_ACCESS")
410 else if(accessPolicy ==
"W_ACCESS")
412 else if(accessPolicy ==
"RW_ACCESS")
422 xmlReader->read(dialectFileName);
424 if(!xmlReader->next())
425 throw te::da::Exception((boost::format(
TR_DATAACCESS(
"Could not read DataSourceCapabilities information in file: %1%.")) % dialectFileName).str());
428 throw te::da::Exception((boost::format(
TR_DATAACCESS(
"Error reading the document %1%, the start element wasn't found.")) % dialectFileName).str());
430 if(xmlReader->getElementLocalName() !=
"DataSourceCapabilities")
431 throw te::da::Exception((boost::format(
TR_DATAACCESS(
"The first tag in the document %1% is not 'DataSourceCapabilities'.")) % dialectFileName).str());
435 assert(xmlReader->getElementLocalName() ==
"DataTypeCapabilities");
439 while(xmlReader->next() &&
441 (xmlReader->getElementLocalName() ==
"DataType"))
458 assert(xmlReader->getElementLocalName() ==
"QueryCapabilities");
464 assert(xmlReader->getElementLocalName() ==
"SQLDialect");
474 assert(xmlReader->getElementLocalName() ==
"SpatialSQLDialect");
477 qc.setSupportSpatialSQLDialect(xmlReader->getElementValueAsBoolean());
484 assert(xmlReader->getElementLocalName() ==
"Insert");
488 qc.setSupportInsert(xmlReader->getElementValueAsBoolean());
495 assert(xmlReader->getElementLocalName() ==
"Update");
499 qc.setSupportUpdate(xmlReader->getElementValueAsBoolean());
506 assert(xmlReader->getElementLocalName() ==
"Delete");
510 qc.setSupportDelete(xmlReader->getElementValueAsBoolean());
517 assert(xmlReader->getElementLocalName() ==
"Create");
521 qc.setSupportCreate(xmlReader->getElementValueAsBoolean());
528 assert(xmlReader->getElementLocalName() ==
"Drop");
532 qc.setSupportDrop(xmlReader->getElementValueAsBoolean());
539 assert(xmlReader->getElementLocalName() ==
"Alter");
543 qc.setSupportAlter(xmlReader->getElementValueAsBoolean());
550 assert(xmlReader->getElementLocalName() ==
"Select");
554 qc.setSupportSelect(xmlReader->getElementValueAsBoolean());
561 assert(xmlReader->getElementLocalName() ==
"SelectInto");
565 qc.setSupportSelectInto(xmlReader->getElementValueAsBoolean());
574 assert(xmlReader->getElementLocalName() ==
"SpatialTopologicOperators");
576 while(xmlReader->next() &&
578 (xmlReader->getElementLocalName() ==
"Function"))
582 std::string fname = xmlReader->getAttr(
"name");
584 qc.addSpatialTopologicOperator(fname);
589 std::string encoderType = xmlReader->getElementLocalName();
591 if(encoderType ==
"FunctionEncoder")
593 std::string alias = xmlReader->getAttr(0);
596 else if(encoderType ==
"BinaryOpEncoder")
598 std::string alias = xmlReader->getAttr(0);
601 else if(encoderType ==
"UnaryOpEncoder")
603 std::string alias = xmlReader->getAttr(0);
606 else if(encoderType ==
"TemplateEncoder")
608 std::string alias = xmlReader->getAttr(0);
609 std::string temp = xmlReader->getAttr(1);
614 throw te::da::Exception(
TR_DATAACCESS(
"Unsupported encoder type!"));
617 dialect.
insert(fname, sfe);
630 assert(xmlReader->getElementLocalName() ==
"SpatialMetricOperators");
632 while(xmlReader->next() &&
634 (xmlReader->getElementLocalName() ==
"Function"))
638 std::string fname = xmlReader->getAttr(
"name");
640 qc.addSpatialMetricOperator(fname);
645 std::string encoderType = xmlReader->getElementLocalName();
647 if(encoderType ==
"FunctionEncoder")
649 std::string alias = xmlReader->getAttr(0);
652 else if(encoderType ==
"BinaryOpEncoder")
654 std::string alias = xmlReader->getAttr(0);
657 else if(encoderType ==
"UnaryOpEncoder")
659 std::string alias = xmlReader->getAttr(0);
662 else if(encoderType ==
"TemplateEncoder")
664 std::string alias = xmlReader->getAttr(0);
665 std::string temp = xmlReader->getAttr(1);
670 throw te::da::Exception(
TR_DATAACCESS(
"Unsupported encoder type!"));
673 dialect.
insert(fname, sfe);
686 assert(xmlReader->getElementLocalName() ==
"SpatialNewGeomOperators");
688 while(xmlReader->next() &&
690 (xmlReader->getElementLocalName() ==
"Function"))
694 std::string fname = xmlReader->getAttr(
"name");
696 qc.addSpatialNewGeomOperator(fname);
701 std::string encoderType = xmlReader->getElementLocalName();
703 if(encoderType ==
"FunctionEncoder")
705 std::string alias = xmlReader->getAttr(0);
708 else if(encoderType ==
"BinaryOpEncoder")
710 std::string alias = xmlReader->getAttr(0);
713 else if(encoderType ==
"UnaryOpEncoder")
715 std::string alias = xmlReader->getAttr(0);
718 else if(encoderType ==
"TemplateEncoder")
720 std::string alias = xmlReader->getAttr(0);
721 std::string temp = xmlReader->getAttr(1);
726 throw te::da::Exception(
TR_DATAACCESS(
"Unsupported encoder type!"));
729 dialect.
insert(fname, sfe);
744 assert(xmlReader->getElementLocalName() ==
"SpatialOperators");
746 while(xmlReader->next() &&
748 (xmlReader->getElementLocalName() ==
"Function"))
752 std::string fname = xmlReader->getAttr(
"name");
754 qc.addSpatialOperator(fname);
759 std::string encoderType = xmlReader->getElementLocalName();
761 if(encoderType ==
"FunctionEncoder")
763 std::string alias = xmlReader->getAttr(0);
766 else if(encoderType ==
"BinaryOpEncoder")
768 std::string alias = xmlReader->getAttr(0);
771 else if(encoderType ==
"UnaryOpEncoder")
773 std::string alias = xmlReader->getAttr(0);
776 else if(encoderType ==
"TemplateEncoder")
778 std::string alias = xmlReader->getAttr(0);
779 std::string temp = xmlReader->getAttr(1);
784 throw te::da::Exception(
TR_DATAACCESS(
"Unsupported encoder type!"));
787 dialect.
insert(fname, sfe);
800 assert(xmlReader->getElementLocalName() ==
"LogicalOperators");
802 while(xmlReader->next() &&
804 (xmlReader->getElementLocalName() ==
"Function"))
808 std::string fname = xmlReader->getAttr(
"name");
810 qc.addLogicalOperator(fname);
815 std::string encoderType = xmlReader->getElementLocalName();
817 if(encoderType ==
"FunctionEncoder")
819 std::string alias = xmlReader->getAttr(0);
822 else if(encoderType ==
"BinaryOpEncoder")
824 std::string alias = xmlReader->getAttr(0);
827 else if(encoderType ==
"UnaryOpEncoder")
829 std::string alias = xmlReader->getAttr(0);
832 else if(encoderType ==
"TemplateEncoder")
834 std::string alias = xmlReader->getAttr(0);
835 std::string temp = xmlReader->getAttr(1);
840 throw te::da::Exception(
TR_DATAACCESS(
"Unsupported encoder type!"));
843 dialect.
insert(fname, sfe);
856 assert(xmlReader->getElementLocalName() ==
"ComparsionOperators");
858 while(xmlReader->next() &&
860 (xmlReader->getElementLocalName() ==
"Function"))
864 std::string fname = xmlReader->getAttr(
"name");
866 qc.addComparsionOperator(fname);
871 std::string encoderType = xmlReader->getElementLocalName();
873 if(encoderType ==
"FunctionEncoder")
875 std::string alias = xmlReader->getAttr(0);
878 else if(encoderType ==
"BinaryOpEncoder")
880 std::string alias = xmlReader->getAttr(0);
883 else if(encoderType ==
"UnaryOpEncoder")
885 std::string alias = xmlReader->getAttr(0);
888 else if(encoderType ==
"TemplateEncoder")
890 std::string alias = xmlReader->getAttr(0);
891 std::string temp = xmlReader->getAttr(1);
896 throw te::da::Exception(
TR_DATAACCESS(
"Unsupported encoder type!"));
899 dialect.
insert(fname, sfe);
912 assert(xmlReader->getElementLocalName() ==
"ArithmeticOperators");
914 while(xmlReader->next() &&
916 (xmlReader->getElementLocalName() ==
"Function"))
920 std::string fname = xmlReader->getAttr(
"name");
922 qc.addArithmeticOperator(fname);
927 std::string encoderType = xmlReader->getElementLocalName();
929 if(encoderType ==
"FunctionEncoder")
931 std::string alias = xmlReader->getAttr(0);
934 else if(encoderType ==
"BinaryOpEncoder")
936 std::string alias = xmlReader->getAttr(0);
939 else if(encoderType ==
"UnaryOpEncoder")
941 std::string alias = xmlReader->getAttr(0);
944 else if(encoderType ==
"TemplateEncoder")
946 std::string alias = xmlReader->getAttr(0);
947 std::string temp = xmlReader->getAttr(1);
952 throw te::da::Exception(
TR_DATAACCESS(
"Unsupported encoder type!"));
955 dialect.
insert(fname, sfe);
968 assert(xmlReader->getElementLocalName() ==
"Functions");
970 while(xmlReader->next() &&
972 (xmlReader->getElementLocalName() ==
"Function"))
976 std::string fname = xmlReader->getAttr(
"name");
978 qc.addFunction(fname);
983 std::string encoderType = xmlReader->getElementLocalName();
985 if(encoderType ==
"FunctionEncoder")
987 std::string alias = xmlReader->getAttr(0);
990 else if(encoderType ==
"BinaryOpEncoder")
992 std::string alias = xmlReader->getAttr(0);
995 else if(encoderType ==
"UnaryOpEncoder")
997 std::string alias = xmlReader->getAttr(0);
1000 else if(encoderType ==
"TemplateEncoder")
1002 std::string alias = xmlReader->getAttr(0);
1003 std::string temp = xmlReader->getAttr(1);
1008 throw te::da::Exception(
TR_DATAACCESS(
"Unsupported encoder type!"));
1011 dialect.
insert(fname, sfe);
1024 assert(xmlReader->getElementLocalName() ==
"GeomOperands");
1026 while(xmlReader->next() &&
1028 (xmlReader->getElementLocalName() ==
"GeomType"))
1033 std::string geom = boost::to_upper_copy(xmlReader->getElementValue());
1052 assert(xmlReader->getElementLocalName() ==
"DataSetTypeCapabilities");
1058 assert(xmlReader->getElementLocalName() ==
"SupportPrimaryKey");
1070 assert(xmlReader->getElementLocalName() ==
"SupportUniqueKey");
1075 dstc.setSupportUniqueKey(xmlReader->getElementValueAsBoolean());
1082 assert(xmlReader->getElementLocalName() ==
"SupportForeignKey");
1087 dstc.setSupportForeingKey(xmlReader->getElementValueAsBoolean());
1094 assert(xmlReader->getElementLocalName() ==
"SupportSequence");
1099 dstc.setSupportSequence(xmlReader->getElementValueAsBoolean());
1106 assert(xmlReader->getElementLocalName() ==
"SupportCheckConstraints");
1111 dstc.setSupportCheckConstraints(xmlReader->getElementValueAsBoolean());
1118 assert(xmlReader->getElementLocalName() ==
"SupportIndex");
1123 dstc.setSupportIndex(xmlReader->getElementValueAsBoolean());
1130 assert(xmlReader->getElementLocalName() ==
"SupportRTreeIndex");
1135 dstc.setSupportRTreeIndex(xmlReader->getElementValueAsBoolean());
1142 assert(xmlReader->getElementLocalName() ==
"SupportBTreeIndex");
1147 dstc.setSupportBTreeIndex(xmlReader->getElementValueAsBoolean());
1154 assert(xmlReader->getElementLocalName() ==
"SupportHashIndex");
1159 dstc.setSupportHashIndex(xmlReader->getElementValueAsBoolean());
1166 assert(xmlReader->getElementLocalName() ==
"SupportQuadTreeIndex");
1171 dstc.setSupportQuadTreeIndex(xmlReader->getElementValueAsBoolean());
1183 assert(xmlReader->getElementLocalName() ==
"DataSetCapabilities");
1189 assert(xmlReader->getElementLocalName() ==
"Bidirectional");
1201 assert(xmlReader->getElementLocalName() ==
"Random");
1206 dsetc.setSupportRandomTraversing(xmlReader->getElementValueAsBoolean());
1213 assert(xmlReader->getElementLocalName() ==
"Indexed");
1218 dsetc.setSupportIndexedTraversing(xmlReader->getElementValueAsBoolean());
1225 assert(xmlReader->getElementLocalName() ==
"EfficientMovePrevious");
1230 dsetc.setSupportEfficientMovePrevious(xmlReader->getElementValueAsBoolean());
1237 assert(xmlReader->getElementLocalName() ==
"EfficientMoveBeforeFirst");
1242 dsetc.setSupportEfficientMoveBeforeFirst(xmlReader->getElementValueAsBoolean());
1249 assert(xmlReader->getElementLocalName() ==
"EfficientMoveLast");
1254 dsetc.setSupportEfficientMoveLast(xmlReader->getElementValueAsBoolean());
1261 assert(xmlReader->getElementLocalName() ==
"EfficientMoveAfterLast");
1266 dsetc.setSupportEfficientMoveAfterLast(xmlReader->getElementValueAsBoolean());
1273 assert(xmlReader->getElementLocalName() ==
"EfficientMove");
1278 dsetc.setSupportEfficientMove(xmlReader->getElementValueAsBoolean());
1285 assert(xmlReader->getElementLocalName() ==
"EfficientSize");
1290 dsetc.setSupportEfficientDataSetSize(xmlReader->getElementValueAsBoolean());
1302 assert(xmlReader->getElementLocalName() ==
"SpecificCapabilities");
1304 while(xmlReader->next() &&
1306 (xmlReader->getElementLocalName() ==
"Parameter"))
1310 assert(xmlReader->getElementLocalName() ==
"Name");
1315 std::string paramName = xmlReader->getElementValue();
1322 assert(xmlReader->getElementLocalName() ==
"Value");
1327 std::string paramValue = xmlReader->getElementValue();
1342 assert(xmlReader->getElementLocalName() ==
"AccessPolicyName");
1354 assert(xmlReader->getElementLocalName() ==
"SupportTransactions");
1366 assert(xmlReader->getElementLocalName() ==
"SupportDataSetPesistenceAPI");
1378 assert(xmlReader->getElementLocalName() ==
"SupportDataSetTypePesistenceAPI");
1390 assert(xmlReader->getElementLocalName() ==
"SupportPreparedQueryAPI");
1402 assert(xmlReader->getElementLocalName() ==
"SupportBatchExecutorAPI");
1421 xmlReader->read(dialectFileName);
1423 if(!xmlReader->next())
1424 throw te::da::Exception((boost::format(
TR_DATAACCESS(
"Could not read query dialect information in file: %1%.")) % dialectFileName).str());
1427 throw te::da::Exception((boost::format(
TR_DATAACCESS(
"Error reading the document %1%, the start element wasn't found.")) % dialectFileName).str());
1429 if(xmlReader->getElementLocalName() !=
"QueryDialect")
1430 throw te::da::Exception((boost::format(
TR_DATAACCESS(
"The first tag in the document %1% is not 'QueryDialect'.")) % dialectFileName).str());
1434 assert(xmlReader->getElementLocalName() ==
"DriverName");
1443 assert(xmlReader->getElementLocalName() ==
"Functions");
1447 while(xmlReader->next() &&
1449 (xmlReader->getElementLocalName() ==
"Function"))
1451 std::string fname = xmlReader->getAttr(0);
1456 std::string encoderType = xmlReader->getElementLocalName();
1460 if(encoderType ==
"FunctionEncoder")
1462 std::string alias = xmlReader->getAttr(0);
1465 else if(encoderType ==
"BinaryOpEncoder")
1467 std::string alias = xmlReader->getAttr(0);
1470 else if(encoderType ==
"UnaryOpEncoder")
1472 std::string alias = xmlReader->getAttr(0);
1477 throw te::da::Exception(
TR_DATAACCESS(
"Unsupported encoder type!"));
1483 mydialect->insert(fname, sfe);
1491 return mydialect.release();
1520 dist->push_back(exp);
1548 fields->push_back(f);
1553 fields->push_back(f);
1558 fields->push_back(f);
1618 from->push_back(fi);
1659 std::size_t countAux = 0;
1727 groupBy->push_back(groupByItem);
1827 throw te::da::Exception(
TR_DATAACCESS(
"Data Type Undefined!"));
1878 orderBy->push_back(orderByItem);
1930 select->setFields(fields);
1936 select->setFrom(from);
1942 select->setWhere(wh);
1948 select->setGroupBy(gBy);
1954 select->setHaving(having);
1960 select->setOrderBy(oBy);
1966 select->setDistinct(distinct);
1973 select->setLimit(boost::lexical_cast<std::size_t>(reader.
getElementValue()));
1983 select->setOffset(boost::lexical_cast<std::size_t>(reader.
getElementValue()));
2031 for(std::size_t i = 0; i < distinct->size(); ++i)
2045 std::auto_ptr<te::da::Expression> exp(expression->
clone());
2053 Save(pName, writer);
2059 throw te::da::Exception(
TR_DATAACCESS(
"Error: Expression Type Undefined!"));
2087 for(std::size_t i = 0; i < fields->size(); ++i)
2091 Save(&item, writer);
2101 for(std::size_t i = 0; i < from->size(); ++i)
2105 Save(&item, writer);
2138 else if(funcName ==
">")
2140 else if(funcName ==
"<>")
2141 return "<>";
2142 else if(funcName ==
"<=")
2144 else if(funcName ==
">=")
2155 std::string funcName = func->
getName();
2160 for(std::size_t i = 0; i < func->
getNumArgs(); i++)
2170 assert(groupByItem);
2182 for(std::size_t i = 0; i < groupBy->size(); ++i)
2186 Save(&item, writer);
2218 assert(orderByItem);
2235 for(std::size_t i = 0; i < orderBy->size(); ++i)
2239 Save(&item, writer);
2247 assert(propertyName);
2259 Save(fields, writer);
2271 Save(groupBy, writer);
2275 Save(having, writer);
2279 Save(orderBy, writer);
2283 Save(distinct, writer);
virtual void writeStartDocument(const std::string &encoding, const std::string &standalone)
te::da::SQLDialect * mydialect
TEDATAACCESSEXPORT te::da::Fields * ReadFields(te::xml::Reader &reader)
std::map< std::string, DataSourceInfoPtr >::iterator iterator
TEDATAACCESSEXPORT void Read(const std::string &dialectFileName, te::da::DataSourceCapabilities &capabilities, te::da::SQLDialect &dialect)
const std::string & getTitle() const
A human descriptive title for the DataSetType.
A query encoder for binary operations.
void insert(const std::string &funcName, SQLFunctionEncoder *encoder)
It adds a new encoder for a given function.
It represents the system catalog of a DataSource.
A class that models the name of a dataset used in a From clause.
TEDATATYPEEXPORT int Convert2Terralib(const std::string &dataType)
It convert a string to a DataType.
const Having * getHaving() const
It returns the list of expressions used to eliminate group row that doesn't satisfy the condition...
void setSupportDataSetTypePesistenceAPI(const bool &support)
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.
void setSupportPrimaryKey(const bool &support)
TEDATAACCESSEXPORT te::da::Select * ReadSelect(te::xml::Reader &reader)
Expression * getExpression() const
It returns the expression set for an output select query.
TECOMMONEXPORT std::string ConvertLatin1UTFString(const std::string &data, const bool &toUtf=true)
Converts a string from latin1 to utf8 and vice-versa.
TEDATAACCESSEXPORT void Save(const std::string &fileName)
void setAccessPolicy(const te::common::AccessPolicy &accessPolicy)
TEDATAACCESSEXPORT te::da::Where * ReadWhere(te::xml::Reader &reader)
virtual int getTypeCode() const =0
It returns the data type code associated to the data value.
TEDATAACCESSEXPORT te::da::OrderBy * ReadOrderBy(te::xml::Reader &reader)
void setSupportBatchExecutorAPI(const bool &support)
A Select models a query to be used when retrieving data from a DataSource.
A base class for encoders of SQL function expressions.
void setSupportSQLDialect(const bool &support)
void setSupportTransactions(const bool &support)
A class that represents a data source component.
This class models a XML reader object.
A base class for binary functions.
const std::string & getName() const
It returns the property name.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
std::size_t getNumberOfDataSets() const
It returns the number of datasets in the catalog.
virtual std::string toString() const =0
It returns the data value in a string notation.
This class models a string Literal value.
const std::string & getName() const
It returns the dataset name.
static te::xml::Reader * make()
It creates a new XML reader using the dafault implementation.
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
void setSupportDataSetPesistenceAPI(const bool &support)
virtual Expression * clone() const =0
It creates a new copy of this expression.
virtual bool next()=0
It gets the next event to be read.
const std::string & getName() const
It returns the property name.
std::size_t getLimit() const
It tells the maximum number of rows to return.
A class that can be used to model a filter expression that can be applied to a query.
A class that models the name of any property of an object.
const From * getFrom() const
It returns the list of source information to be used by the query.
std::size_t getOffset() const
It tells the number of rows to skip before starting to return rows.
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
TEDATAACCESSEXPORT te::da::PropertyName * ReadPropertyName(te::xml::Reader &reader)
A class that can be used in an ORDER BY clause to sort the items of a resulting query.
Expression * getExpression() const
It returns the exprsssion to be used to sort the result of a query.
void setSupport(const int &type, const bool &support)
A class that models a literal for Geometry values.
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
A class that informs what kind of constraint and index is supported by a given data source...
std::string Function2Ascii(std::string funcName)
AccessPolicy
Supported data access policies (can be used as bitfield).
void setQueryCapabilities(const QueryCapabilities &capabilities)
virtual void writeStartElement(const std::string &qName)
std::size_t getNumArgs() const
It returns the number of arguments informed to the function.
virtual void writeAttribute(const std::string &attName, const std::string &value)
const Distinct * getDistinct() const
It returns the Distinct modifier.
It represents the SQL query dialect accepted by a given data source.
virtual std::string getElementValue() const =0
It returns the element data value in the case of VALUE node.
virtual void writeEndElement(const std::string &qName)
A query encoder for binary operator expressions.
An abstract class that models a source of data in a query.
Expression * getArg(std::size_t i) const
It returns the i-th function argument.
TEDATAACCESSEXPORT te::da::From * ReadFrom(te::xml::Reader &reader)
TEDATAACCESSEXPORT te::da::GroupBy * ReadGroupBy(te::xml::Reader &reader)
virtual boost::uint32_t getAttrAsUInt32(std::size_t i) const
It returns the attribute value in the case of an element node with valid attributes.
const std::string & getAlias() const
It returns the alias associated to the source item.
TEDATAACCESSEXPORT te::da::Function * ReadFunction(te::xml::Reader &reader)
SortOrder getSortOrder() const
It returns the order of sorting: Asc or Desc.
A class that informs the query support of a given data source.
Expression * getExp() const
boost::ptr_vector< OrderByItem > OrderBy
A class that can be used to model an ORDER BY clause.
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
TEDATATYPEEXPORT std::auto_ptr< te::dt::Property > ReadProperty(te::xml::Reader &reader)
TEDATAACCESSEXPORT te::da::Distinct * ReadDistinct(te::xml::Reader &reader)
boost::ptr_vector< Expression > Distinct
A class that models a Distinct clause on a query.
void setDataSetTypeCapabilities(const DataSetTypeCapabilities &capabilities)
te::common::AccessPolicy Convert2Terralib(std::string accessPolicy)
A class that can be used in a GROUP BY clause.
#define TR_DATAACCESS(message)
It marks a string in order to get translated. This is a special mark used in the DataAccess module of...
virtual void writeElement(const std::string &qName, const std::string &value)
A base class for values that can be retrieved from the data access module.
TEDATAACCESSEXPORT te::da::SQLDialect * ReadDialect(const std::string &dialectFileName)
virtual void writeValue(const std::string &value)
boost::ptr_vector< GroupByItem > GroupBy
A class that can be used to model a GROUP BY clause.
This class models a literal value.
const GroupBy * getGroupBy() const
It returns the list of expressions used to condense the result set.
const std::string & getName() const
It returns the function name.
A class that models the description of a dataset.
void setSupportPreparedQueryAPI(const bool &support)
A class that informs what the dataset implementation of a given data source can perform.
TEDATAACCESSEXPORT te::da::DataSetType * ReadDataSetType(te::xml::Reader &reader)
Expression * getExp() const
boost::shared_ptr< DataSetType > DataSetTypePtr
static Geometry * read(const char *wkt)
It returns a valid Geometry from a given WKT.
This is an abstract class that models a query expression.
TEDATAACCESSEXPORT te::da::Literal * ReadLiteral(te::xml::Reader &reader)
const Fields * getFields() const
It returns the list of output expressions used to form the result set.
const OrderBy * getOrderBy() const
It returns the list of expressions used to sort the output result.
void setDataTypeCapabilities(const DataTypeCapabilities &capabilities)
Where * getWhere() const
It returns the filter condition.
std::string * getAlias() const
It returns the alias for the outout expression.
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
virtual NodeType getNodeType() const =0
It return the type of node read.
TEDATAACCESSEXPORT te::da::DataSourceCatalog * ReadDataSourceCatalog(te::xml::Reader &reader)
unsigned int getId() const
It returns the property identifier.
A class that models a Function expression.
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
A class that can be used to model a filter expression that can be applied to a query.
A class that represents the supported data types of a specific data source.
virtual std::string getElementLocalName() const =0
It returns the local part of the element name in the case of an element node.
A class that models a literal for double values.
A query encoder for unary operator expressions.
void addSpecificCapability(const std::string &key, const std::string &value)
virtual boost::int32_t getAttrAsInt32(const std::string &name) const
It returns the attribute value in the case of an element node with valid attributes.
An SQL encoder for general function expressions.
const DataSetTypePtr & getDataSetType(std::size_t i) const
It returns the i-th dataset schema.
void setSupportBidirectionalTraversing(const bool &support)
Expression * getExpression() const
It returns the exprsssion to be used to sort the result of a query.
te::da::DataSourceCapabilities capabilities
TEDATAACCESSEXPORT te::da::Having * ReadHaving(te::xml::Reader &reader)
te::dt::AbstractData * getValue() const
It returns the value associated to the literal.
SortOrder
Sort order type: asc or desc.
TEDATAACCESSEXPORT void ReadDataSourceInfo(const std::string &datasourcesFileName)
void setDataSetCapabilities(const DataSetCapabilities &capabilities)
virtual std::string getAttr(const std::string &name) const =0
It returns the attribute value in the case of an element node with valid attributes.
This class models a XML writer object.