27 #include "../../../Version.h"
28 #include "../../../common/BoostUtils.h"
29 #include "../../../common/PlatformUtils.h"
30 #include "../../../datatype/AbstractData.h"
31 #include "../../../datatype/Enums.h"
32 #include "../../../datatype/serialization/xml/Serializer.h"
33 #include "../../../datatype/StringProperty.h"
34 #include "../../../datatype/Utils.h"
35 #include "../../../geometry/Geometry.h"
36 #include "../../../geometry/WKTReader.h"
37 #include "../../../xml/AbstractWriter.h"
38 #include "../../../xml/AbstractWriterFactory.h"
39 #include "../../../xml/Reader.h"
40 #include "../../../xml/ReaderFactory.h"
41 #include "../../dataset/DataSetType.h"
42 #include "../../datasource/DataSourceCapabilities.h"
43 #include "../../datasource/DataSourceCatalog.h"
44 #include "../../datasource/DataSourceInfo.h"
45 #include "../../datasource/DataSourceInfoManager.h"
46 #include "../../query/BinaryFunction.h"
47 #include "../../query/BinaryOpEncoder.h"
48 #include "../../query/DataSetName.h"
49 #include "../../query/Distinct.h"
50 #include "../../query/Expression.h"
51 #include "../../query/Field.h"
52 #include "../../query/FromItem.h"
53 #include "../../query/Function.h"
54 #include "../../query/FunctionEncoder.h"
55 #include "../../query/GroupByItem.h"
56 #include "../../query/Having.h"
57 #include "../../query/Join.h"
58 #include "../../query/JoinConditionOn.h"
59 #include "../../query/JoinConditionUsing.h"
60 #include "../../query/Literal.h"
61 #include "../../query/LiteralDouble.h"
62 #include "../../query/LiteralGeom.h"
63 #include "../../query/LiteralInt16.h"
64 #include "../../query/LiteralInt32.h"
65 #include "../../query/LiteralInt64.h"
66 #include "../../query/LiteralString.h"
67 #include "../../query/OrderByItem.h"
68 #include "../../query/PropertyName.h"
69 #include "../../query/Select.h"
70 #include "../../query/SQLDialect.h"
71 #include "../../query/SQLFunctionEncoder.h"
72 #include "../../query/TemplateEncoder.h"
73 #include "../../query/UnaryOpEncoder.h"
74 #include "../../query/Where.h"
75 #include "../../Exception.h"
84 #include <boost/algorithm/string/case_conv.hpp>
85 #include <boost/format.hpp>
86 #include <boost/lexical_cast.hpp>
87 #include <boost/algorithm/string/replace.hpp>
88 #include <boost/filesystem.hpp>
92 if(!boost::filesystem::is_regular_file(datasourcesFileName))
97 xmlReader->read(datasourcesFileName);
99 if(!xmlReader->next())
100 throw te::da::Exception((boost::format(
TE_TR(
"Could not read data source information in file: %1%.")) % datasourcesFileName).str());
103 throw te::da::Exception((boost::format(
TE_TR(
"Error reading the document %1%, the start element wasn't found.")) % datasourcesFileName).str());
105 if(xmlReader->getElementLocalName() !=
"DataSourceList")
106 throw te::da::Exception((boost::format(
TE_TR(
"The first tag in the document %1% is not 'DataSourceList'.")) % datasourcesFileName).str());
108 if(!xmlReader->next())
112 (xmlReader->getElementLocalName() ==
"DataSource"))
125 ds->setId(reader.
getAttr(
"id"));
126 ds->setType(reader.
getAttr(
"type"));
127 ds->setAccessDriver(reader.
getAttr(
"access_driver"));
162 std::map<std::string, std::string> conninfo;
164 while(reader.
next() &&
188 conninfo[paramName] = paramValue;
200 ds->setConnInfo(conninfo);
218 boost::replace_all(schema_loc,
" ",
"%20");
220 schema_loc =
"file:///" + schema_loc;
228 writer.
writeAttribute(
"xmlns:xsd",
"http://www.w3.org/2001/XMLSchema-instance");
229 writer.
writeAttribute(
"xmlns:te_common",
"http://www.terralib.org/schemas/common");
230 writer.
writeAttribute(
"xmlns",
"http://www.terralib.org/schemas/dataaccess");
231 writer.
writeAttribute(
"xsd:schemaLocation",
"http://www.terralib.org/schemas/dataaccess " + schema_loc);
239 for(it=itBegin; it!=itEnd; ++it)
241 bool ogrDsrc = it->second->getAccessDriver() ==
"OGR";
247 writer.
writeAttribute(
"access_driver", it->second->getAccessDriver());
258 std::map<std::string, std::string> info = it->second->getConnInfo();
259 std::map<std::string, std::string>::iterator conIt;
261 for(conIt=info.begin(); conIt!=info.end(); ++conIt)
318 return catalog.release();
325 Save(catalog, *w.get());
334 writer.
writeAttribute(
"xmlns:xlink",
"http://www.w3.org/1999/xlink");
335 writer.
writeAttribute(
"xmlns:xsd",
"http://www.w3.org/2001/XMLSchema-instance");
336 writer.
writeAttribute(
"xmlns",
"http://www.terralib.org/schemas/da");
337 writer.
writeAttribute(
"xsd:schemaLocation",
"http://www.terralib.org/schemas/da C:/Users/gribeiro/Documents/terralib5/trunk/myschemas/terralib/da/catalog.xsd");
345 for(std::size_t i = 0; i < ndatasets; ++i)
359 std::string name = reader.
getAttr(
"name");
360 std::string title = reader.
getAttr(
"title");
371 std::auto_ptr<te::dt::Property> p(ReadProperty(reader));
372 dt->add(p.release());
389 const std::size_t nprops = dt->
size();
391 for(std::size_t i = 0; i < nprops; ++i)
399 if(accessPolicy ==
"NO_ACCESS")
401 else if (accessPolicy ==
"R_ACCESS")
403 else if(accessPolicy ==
"W_ACCESS")
405 else if(accessPolicy ==
"RW_ACCESS")
415 xmlReader->read(dialectFileName);
417 if(!xmlReader->next())
418 throw te::da::Exception((boost::format(
TE_TR(
"Could not read DataSourceCapabilities information in file: %1%.")) % dialectFileName).str());
421 throw te::da::Exception((boost::format(
TE_TR(
"Error reading the document %1%, the start element wasn't found.")) % dialectFileName).str());
423 if(xmlReader->getElementLocalName() !=
"DataSourceCapabilities")
424 throw te::da::Exception((boost::format(
TE_TR(
"The first tag in the document %1% is not 'DataSourceCapabilities'.")) % dialectFileName).str());
428 assert(xmlReader->getElementLocalName() ==
"DataTypeCapabilities");
432 while(xmlReader->next() &&
434 (xmlReader->getElementLocalName() ==
"DataType"))
451 assert(xmlReader->getElementLocalName() ==
"QueryCapabilities");
457 assert(xmlReader->getElementLocalName() ==
"SQLDialect");
467 assert(xmlReader->getElementLocalName() ==
"SpatialSQLDialect");
470 qc.setSupportSpatialSQLDialect(xmlReader->getElementValueAsBoolean());
477 assert(xmlReader->getElementLocalName() ==
"Insert");
481 qc.setSupportInsert(xmlReader->getElementValueAsBoolean());
488 assert(xmlReader->getElementLocalName() ==
"Update");
492 qc.setSupportUpdate(xmlReader->getElementValueAsBoolean());
499 assert(xmlReader->getElementLocalName() ==
"Delete");
503 qc.setSupportDelete(xmlReader->getElementValueAsBoolean());
510 assert(xmlReader->getElementLocalName() ==
"Create");
514 qc.setSupportCreate(xmlReader->getElementValueAsBoolean());
521 assert(xmlReader->getElementLocalName() ==
"Drop");
525 qc.setSupportDrop(xmlReader->getElementValueAsBoolean());
532 assert(xmlReader->getElementLocalName() ==
"Alter");
536 qc.setSupportAlter(xmlReader->getElementValueAsBoolean());
543 assert(xmlReader->getElementLocalName() ==
"Select");
547 qc.setSupportSelect(xmlReader->getElementValueAsBoolean());
554 assert(xmlReader->getElementLocalName() ==
"SelectInto");
558 qc.setSupportSelectInto(xmlReader->getElementValueAsBoolean());
567 assert(xmlReader->getElementLocalName() ==
"SpatialTopologicOperators");
569 while(xmlReader->next() &&
571 (xmlReader->getElementLocalName() ==
"Function"))
575 std::string fname = xmlReader->getAttr(
"name");
577 qc.addSpatialTopologicOperator(fname);
582 std::string encoderType = xmlReader->getElementLocalName();
584 if(encoderType ==
"FunctionEncoder")
586 std::string alias = xmlReader->getAttr(0);
589 else if(encoderType ==
"BinaryOpEncoder")
591 std::string alias = xmlReader->getAttr(0);
594 else if(encoderType ==
"UnaryOpEncoder")
596 std::string alias = xmlReader->getAttr(0);
599 else if(encoderType ==
"TemplateEncoder")
601 std::string alias = xmlReader->getAttr(0);
602 std::string temp = xmlReader->getAttr(1);
607 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
610 dialect.
insert(fname, sfe);
623 assert(xmlReader->getElementLocalName() ==
"SpatialMetricOperators");
625 while(xmlReader->next() &&
627 (xmlReader->getElementLocalName() ==
"Function"))
631 std::string fname = xmlReader->getAttr(
"name");
633 qc.addSpatialMetricOperator(fname);
638 std::string encoderType = xmlReader->getElementLocalName();
640 if(encoderType ==
"FunctionEncoder")
642 std::string alias = xmlReader->getAttr(0);
645 else if(encoderType ==
"BinaryOpEncoder")
647 std::string alias = xmlReader->getAttr(0);
650 else if(encoderType ==
"UnaryOpEncoder")
652 std::string alias = xmlReader->getAttr(0);
655 else if(encoderType ==
"TemplateEncoder")
657 std::string alias = xmlReader->getAttr(0);
658 std::string temp = xmlReader->getAttr(1);
663 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
666 dialect.
insert(fname, sfe);
679 assert(xmlReader->getElementLocalName() ==
"SpatialNewGeomOperators");
681 while(xmlReader->next() &&
683 (xmlReader->getElementLocalName() ==
"Function"))
687 std::string fname = xmlReader->getAttr(
"name");
689 qc.addSpatialNewGeomOperator(fname);
694 std::string encoderType = xmlReader->getElementLocalName();
696 if(encoderType ==
"FunctionEncoder")
698 std::string alias = xmlReader->getAttr(0);
701 else if(encoderType ==
"BinaryOpEncoder")
703 std::string alias = xmlReader->getAttr(0);
706 else if(encoderType ==
"UnaryOpEncoder")
708 std::string alias = xmlReader->getAttr(0);
711 else if(encoderType ==
"TemplateEncoder")
713 std::string alias = xmlReader->getAttr(0);
714 std::string temp = xmlReader->getAttr(1);
719 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
722 dialect.
insert(fname, sfe);
737 assert(xmlReader->getElementLocalName() ==
"SpatialOperators");
739 while(xmlReader->next() &&
741 (xmlReader->getElementLocalName() ==
"Function"))
745 std::string fname = xmlReader->getAttr(
"name");
747 qc.addSpatialOperator(fname);
752 std::string encoderType = xmlReader->getElementLocalName();
754 if(encoderType ==
"FunctionEncoder")
756 std::string alias = xmlReader->getAttr(0);
759 else if(encoderType ==
"BinaryOpEncoder")
761 std::string alias = xmlReader->getAttr(0);
764 else if(encoderType ==
"UnaryOpEncoder")
766 std::string alias = xmlReader->getAttr(0);
769 else if(encoderType ==
"TemplateEncoder")
771 std::string alias = xmlReader->getAttr(0);
772 std::string temp = xmlReader->getAttr(1);
777 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
780 dialect.
insert(fname, sfe);
793 assert(xmlReader->getElementLocalName() ==
"LogicalOperators");
795 while(xmlReader->next() &&
797 (xmlReader->getElementLocalName() ==
"Function"))
801 std::string fname = xmlReader->getAttr(
"name");
803 qc.addLogicalOperator(fname);
808 std::string encoderType = xmlReader->getElementLocalName();
810 if(encoderType ==
"FunctionEncoder")
812 std::string alias = xmlReader->getAttr(0);
815 else if(encoderType ==
"BinaryOpEncoder")
817 std::string alias = xmlReader->getAttr(0);
820 else if(encoderType ==
"UnaryOpEncoder")
822 std::string alias = xmlReader->getAttr(0);
825 else if(encoderType ==
"TemplateEncoder")
827 std::string alias = xmlReader->getAttr(0);
828 std::string temp = xmlReader->getAttr(1);
833 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
836 dialect.
insert(fname, sfe);
849 assert(xmlReader->getElementLocalName() ==
"ComparsionOperators");
851 while(xmlReader->next() &&
853 (xmlReader->getElementLocalName() ==
"Function"))
857 std::string fname = xmlReader->getAttr(
"name");
859 qc.addComparsionOperator(fname);
864 std::string encoderType = xmlReader->getElementLocalName();
866 if(encoderType ==
"FunctionEncoder")
868 std::string alias = xmlReader->getAttr(0);
871 else if(encoderType ==
"BinaryOpEncoder")
873 std::string alias = xmlReader->getAttr(0);
876 else if(encoderType ==
"UnaryOpEncoder")
878 std::string alias = xmlReader->getAttr(0);
881 else if(encoderType ==
"TemplateEncoder")
883 std::string alias = xmlReader->getAttr(0);
884 std::string temp = xmlReader->getAttr(1);
889 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
892 dialect.
insert(fname, sfe);
905 assert(xmlReader->getElementLocalName() ==
"ArithmeticOperators");
907 while(xmlReader->next() &&
909 (xmlReader->getElementLocalName() ==
"Function"))
913 std::string fname = xmlReader->getAttr(
"name");
915 qc.addArithmeticOperator(fname);
920 std::string encoderType = xmlReader->getElementLocalName();
922 if(encoderType ==
"FunctionEncoder")
924 std::string alias = xmlReader->getAttr(0);
927 else if(encoderType ==
"BinaryOpEncoder")
929 std::string alias = xmlReader->getAttr(0);
932 else if(encoderType ==
"UnaryOpEncoder")
934 std::string alias = xmlReader->getAttr(0);
937 else if(encoderType ==
"TemplateEncoder")
939 std::string alias = xmlReader->getAttr(0);
940 std::string temp = xmlReader->getAttr(1);
945 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
948 dialect.
insert(fname, sfe);
961 assert(xmlReader->getElementLocalName() ==
"Functions");
963 while(xmlReader->next() &&
965 (xmlReader->getElementLocalName() ==
"Function"))
969 std::string fname = xmlReader->getAttr(
"name");
971 qc.addFunction(fname);
976 std::string encoderType = xmlReader->getElementLocalName();
978 if(encoderType ==
"FunctionEncoder")
980 std::string alias = xmlReader->getAttr(0);
983 else if(encoderType ==
"BinaryOpEncoder")
985 std::string alias = xmlReader->getAttr(0);
988 else if(encoderType ==
"UnaryOpEncoder")
990 std::string alias = xmlReader->getAttr(0);
993 else if(encoderType ==
"TemplateEncoder")
995 std::string alias = xmlReader->getAttr(0);
996 std::string temp = xmlReader->getAttr(1);
1001 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
1004 dialect.
insert(fname, sfe);
1017 assert(xmlReader->getElementLocalName() ==
"GeomOperands");
1019 while(xmlReader->next() &&
1021 (xmlReader->getElementLocalName() ==
"GeomType"))
1026 std::string geom = boost::to_upper_copy(xmlReader->getElementValue());
1045 assert(xmlReader->getElementLocalName() ==
"DataSetTypeCapabilities");
1051 assert(xmlReader->getElementLocalName() ==
"SupportPrimaryKey");
1063 assert(xmlReader->getElementLocalName() ==
"SupportUniqueKey");
1068 dstc.setSupportUniqueKey(xmlReader->getElementValueAsBoolean());
1075 assert(xmlReader->getElementLocalName() ==
"SupportForeignKey");
1080 dstc.setSupportForeingKey(xmlReader->getElementValueAsBoolean());
1087 assert(xmlReader->getElementLocalName() ==
"SupportSequence");
1092 dstc.setSupportSequence(xmlReader->getElementValueAsBoolean());
1099 assert(xmlReader->getElementLocalName() ==
"SupportCheckConstraints");
1104 dstc.setSupportCheckConstraints(xmlReader->getElementValueAsBoolean());
1111 assert(xmlReader->getElementLocalName() ==
"SupportIndex");
1116 dstc.setSupportIndex(xmlReader->getElementValueAsBoolean());
1123 assert(xmlReader->getElementLocalName() ==
"SupportRTreeIndex");
1128 dstc.setSupportRTreeIndex(xmlReader->getElementValueAsBoolean());
1135 assert(xmlReader->getElementLocalName() ==
"SupportBTreeIndex");
1140 dstc.setSupportBTreeIndex(xmlReader->getElementValueAsBoolean());
1147 assert(xmlReader->getElementLocalName() ==
"SupportHashIndex");
1152 dstc.setSupportHashIndex(xmlReader->getElementValueAsBoolean());
1159 assert(xmlReader->getElementLocalName() ==
"SupportQuadTreeIndex");
1164 dstc.setSupportQuadTreeIndex(xmlReader->getElementValueAsBoolean());
1176 assert(xmlReader->getElementLocalName() ==
"DataSetCapabilities");
1182 assert(xmlReader->getElementLocalName() ==
"Bidirectional");
1194 assert(xmlReader->getElementLocalName() ==
"Random");
1199 dsetc.setSupportRandomTraversing(xmlReader->getElementValueAsBoolean());
1206 assert(xmlReader->getElementLocalName() ==
"Indexed");
1211 dsetc.setSupportIndexedTraversing(xmlReader->getElementValueAsBoolean());
1218 assert(xmlReader->getElementLocalName() ==
"EfficientMovePrevious");
1223 dsetc.setSupportEfficientMovePrevious(xmlReader->getElementValueAsBoolean());
1230 assert(xmlReader->getElementLocalName() ==
"EfficientMoveBeforeFirst");
1235 dsetc.setSupportEfficientMoveBeforeFirst(xmlReader->getElementValueAsBoolean());
1242 assert(xmlReader->getElementLocalName() ==
"EfficientMoveLast");
1247 dsetc.setSupportEfficientMoveLast(xmlReader->getElementValueAsBoolean());
1254 assert(xmlReader->getElementLocalName() ==
"EfficientMoveAfterLast");
1259 dsetc.setSupportEfficientMoveAfterLast(xmlReader->getElementValueAsBoolean());
1266 assert(xmlReader->getElementLocalName() ==
"EfficientMove");
1271 dsetc.setSupportEfficientMove(xmlReader->getElementValueAsBoolean());
1278 assert(xmlReader->getElementLocalName() ==
"EfficientSize");
1283 dsetc.setSupportEfficientDataSetSize(xmlReader->getElementValueAsBoolean());
1295 assert(xmlReader->getElementLocalName() ==
"SpecificCapabilities");
1297 while(xmlReader->next() &&
1299 (xmlReader->getElementLocalName() ==
"Parameter"))
1303 assert(xmlReader->getElementLocalName() ==
"Name");
1308 std::string paramName = xmlReader->getElementValue();
1315 assert(xmlReader->getElementLocalName() ==
"Value");
1320 std::string paramValue = xmlReader->getElementValue();
1335 assert(xmlReader->getElementLocalName() ==
"AccessPolicyName");
1347 assert(xmlReader->getElementLocalName() ==
"SupportTransactions");
1359 assert(xmlReader->getElementLocalName() ==
"SupportDataSetPesistenceAPI");
1371 assert(xmlReader->getElementLocalName() ==
"SupportDataSetTypePesistenceAPI");
1383 assert(xmlReader->getElementLocalName() ==
"SupportPreparedQueryAPI");
1395 assert(xmlReader->getElementLocalName() ==
"SupportBatchExecutorAPI");
1414 xmlReader->read(dialectFileName);
1416 if(!xmlReader->next())
1417 throw te::da::Exception((boost::format(
TE_TR(
"Could not read query dialect information in file: %1%.")) % dialectFileName).str());
1420 throw te::da::Exception((boost::format(
TE_TR(
"Error reading the document %1%, the start element wasn't found.")) % dialectFileName).str());
1422 if(xmlReader->getElementLocalName() !=
"QueryDialect")
1423 throw te::da::Exception((boost::format(
TE_TR(
"The first tag in the document %1% is not 'QueryDialect'.")) % dialectFileName).str());
1427 assert(xmlReader->getElementLocalName() ==
"DriverName");
1436 assert(xmlReader->getElementLocalName() ==
"Functions");
1440 while(xmlReader->next() &&
1442 (xmlReader->getElementLocalName() ==
"Function"))
1444 std::string fname = xmlReader->getAttr(0);
1449 std::string encoderType = xmlReader->getElementLocalName();
1453 if(encoderType ==
"FunctionEncoder")
1455 std::string alias = xmlReader->getAttr(0);
1458 else if(encoderType ==
"BinaryOpEncoder")
1460 std::string alias = xmlReader->getAttr(0);
1463 else if(encoderType ==
"UnaryOpEncoder")
1465 std::string alias = xmlReader->getAttr(0);
1470 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
1476 mydialect->insert(fname, sfe);
1484 return mydialect.release();
1513 dist->push_back(exp);
1542 fields->push_back(f);
1548 fields->push_back(f);
1553 fields->push_back(f);
1620 else if (type ==
"INNER_JOIN")
1622 else if (type ==
"LEFT_JOIN")
1624 else if (type ==
"RIGHT_JOIN")
1626 else if (type ==
"FULL_OUTER_JOIN")
1628 else if ( type ==
"CROSS_JOIN")
1665 from->push_back(join);
1748 std::size_t countAux = 0;
1816 groupBy->push_back(groupByItem);
1916 throw te::da::Exception(
TE_TR(
"Data Type Undefined!"));
1967 orderBy->push_back(orderByItem);
2019 select->setFields(fields);
2025 select->setFrom(from);
2031 select->setWhere(wh);
2037 select->setGroupBy(gBy);
2043 select->setHaving(having);
2049 select->setOrderBy(oBy);
2055 select->setDistinct(distinct);
2062 select->setLimit(boost::lexical_cast<std::size_t>(reader.
getElementValue()));
2072 select->setOffset(boost::lexical_cast<std::size_t>(reader.
getElementValue()));
2120 for(std::size_t i = 0; i < distinct->size(); ++i)
2134 std::auto_ptr<te::da::Expression> exp(expression->
clone());
2142 Save(pName, writer);
2148 throw te::da::Exception(
TE_TR(
"Error: Expression Type Undefined!"));
2176 for(std::size_t i = 0; i < fields->size(); ++i)
2180 Save(&item, writer);
2190 for(std::size_t i = 0; i < from->size(); ++i)
2194 Save(&item, writer);
2231 std::string joinType;
2238 joinType =
"INNER_JOIN";
2241 joinType =
"LEFT_JOIN";
2244 joinType =
"RIGHT_JOIN";
2247 joinType =
"FULL_OUTER_JOIN";
2250 joinType =
"CROSS_JOIN";
2253 joinType =
"NATURAL_JOIN";
2275 for(std::size_t i = 0; i < joinUsing->
getNumFields(); ++i)
2294 std::string funcName = func->
getName();
2298 for(std::size_t i = 0; i < func->
getNumArgs(); i++)
2308 assert(groupByItem);
2320 for(std::size_t i = 0; i < groupBy->size(); ++i)
2324 Save(&item, writer);
2356 assert(orderByItem);
2373 for(std::size_t i = 0; i < orderBy->size(); ++i)
2377 Save(&item, writer);
2385 assert(propertyName);
2397 Save(fields, writer);
2409 Save(groupBy, writer);
2413 Save(having, writer);
2417 Save(orderBy, writer);
2421 Save(distinct, writer);
A class that can be used to model a filter expression that can be applied to a query.
Expression * getArg(std::size_t i) const
It returns the i-th function argument.
TECOMMONEXPORT std::string ConvertLatin1UTFString(const std::string &data, const bool &toUtf=true)
Converts a string from latin1 to utf8 and vice-versa.
const Distinct * getDistinct() const
It returns the Distinct modifier.
Property * getProperty(std::size_t i) const
It returns the i-th property.
std::map< std::string, DataSourceInfoPtr >::iterator iterator
const std::string & getName() const
It returns the property name.
boost::ptr_vector< GroupByItem > GroupBy
A class that can be used to model a GROUP BY clause.
te::da::SQLDialect * dialect
A class that informs what kind of constraint and index is supported by a given data source...
const OrderBy * getOrderBy() const
It returns the list of expressions used to sort the output result.
A class that can be used in a GROUP BY clause.
An abstract class that models a source of data in a query.
The Field class can be used to model an expression that takes part of the output items of a SELECT...
boost::shared_ptr< DataSetType > DataSetTypePtr
This class models a XML reader object.
A class that models the name of a dataset used in a From clause.
An SQL encoder for general function expressions.
TEDATAACCESSEXPORT te::da::DataSetType * ReadDataSetType(te::xml::Reader &reader)
const GroupBy * getGroupBy() const
It returns the list of expressions used to condense the result set.
virtual void writeStartElement(const std::string &qName)=0
It represents the system catalog of a DataSource.
boost::ptr_vector< Expression > Distinct
A class that models a Distinct clause on a query.
A base class for encoders of SQL function expressions.
TECOMMONEXPORT std::string FindInTerraLibPath(const std::string &p)
Returns the path relative to a directory or file in the context of TerraLib.
A class that models the name of any property of an object.
void setDataSetTypeCapabilities(const DataSetTypeCapabilities &capabilities)
A class that models the description of a dataset.
void addSpecificCapability(const std::string &key, const std::string &value)
virtual void writeValue(const std::string &value)=0
Expression * getExpression() const
It returns the expression set for an output select query.
Expression * getExpression() const
It returns the exprsssion to be used to sort the result of a query.
virtual int getTypeCode() const =0
It returns the data type code associated to the data value.
static te::xml::AbstractWriter * make()
It creates a new XML writer using the dafault implementation.
It represents the SQL query dialect accepted by a given data source.
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.
Expression * getCondition() const
It returns a pointer to a join condition.
boost::ptr_vector< OrderByItem > OrderBy
A class that can be used to model an ORDER BY clause.
virtual std::string toString() const =0
It returns the data value in a string notation.
A class that represents the known capabilities of a specific data source, i.e. this class informs all...
std::size_t getNumberOfDataSets() const
It returns the number of datasets in the catalog.
void setAccessPolicy(const te::common::AccessPolicy &accessPolicy)
JoinType getType() const
It returns the join type.
static te::xml::Reader * make()
It creates a new XML reader using the dafault implementation.
A class that informs what the dataset implementation of a given data source can perform.
void setRootNamespaceURI(const std::string &uri)
This class models a XML writer object.
TEDATAACCESSEXPORT te::da::Having * ReadHaving(te::xml::Reader &reader)
#define TE_TR(message)
It marks a string in order to get translated.
void setSupport(const int &type, const bool &support)
TEDATAACCESSEXPORT void Read(const std::string &dialectFileName, te::da::DataSourceCapabilities &capabilities, te::da::SQLDialect &dialect)
void setSupportDataSetTypePesistenceAPI(const bool &support)
void setQueryCapabilities(const QueryCapabilities &capabilities)
void insert(const std::string &funcName, SQLFunctionEncoder *encoder)
It adds a new encoder for a given function.
TEDATAACCESSEXPORT te::da::Function * ReadFunction(te::xml::Reader &reader)
virtual std::string getElementLocalName() const =0
It returns the local part of the element name in the case of an element node.
const DataSetTypePtr & getDataSetType(std::size_t i) const
It returns the i-th dataset schema.
const From * getFrom() const
It returns the list of source information to be used by the query.
This is an abstract class that models a query expression.
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.
A query encoder for binary operations.
SortOrder getSortOrder() const
It returns the order of sorting: Asc or Desc.
void setSupportTransactions(const bool &support)
te::da::SQLDialect * mydialect
A class that represents the supported data types of a specific data source.
AccessPolicy
Supported data access policies (can be used as bitfield).
void setSupportPreparedQueryAPI(const bool &support)
virtual void writeElement(const std::string &qName, const std::string &value)=0
TEDATAACCESSEXPORT te::da::Where * ReadWhere(te::xml::Reader &reader)
A class that informs the query support of a given data source.
void setSupportDataSetPesistenceAPI(const bool &support)
static DataSourceInfoManager & getInstance()
It returns a reference to the singleton instance.
virtual void writeToFile()=0
const std::string & getAlias() const
It returns the alias associated to the source item.
This class models a literal value.
te::da::DataSourceCapabilities capabilities
A condition to be used in a Join clause.
TEDATAACCESSEXPORT void Save(const std::string &fileName)
boost::ptr_vector< Field > Fields
Fields is just a boost::ptr_vector of Field pointers.
JoinType
The type of join in a query.
TEDATAACCESSEXPORT te::da::From * ReadFrom(te::xml::Reader &reader)
A class that can be used to model a filter expression that can be applied to a query.
std::string * getAlias() const
It returns the alias for the outout expression.
TEDATAACCESSEXPORT te::da::Distinct * ReadDistinct(te::xml::Reader &reader)
A base class for values that can be retrieved from the data access module.
std::size_t getOffset() const
It tells the number of rows to skip before starting to return rows.
Expression * getExp() const
A class that models a Function expression.
const Fields * getFields() const
It returns the list of output expressions used to form the result set.
A Join clause combines two FromItems.
Expression * getExp() const
void setDataSetCapabilities(const DataSetCapabilities &capabilities)
A class that models a literal for double values.
TEDATAACCESSEXPORT te::da::FromItem * ReadFromItem(te::xml::Reader &reader)
std::size_t size() const
It returns the number of properties of the CompositeProperty.
te::common::AccessPolicy Convert2Terralib(std::string accessPolicy)
SortOrder
Sort order type: asc or desc.
void setAlias(std::string *alias)
As you know, sometimes is better to give an alias to an output expression.
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.
std::size_t getNumFields() const
It returns the number of fields in this join condition.
const std::string & getName() const
It returns the function name.
GeomType getGeomTypeId() const
It returns the geometry subclass type identifier.
void setSupportSQLDialect(const bool &support)
TEDATAACCESSEXPORT te::da::OrderBy * ReadOrderBy(te::xml::Reader &reader)
TEDATAACCESSEXPORT te::da::GroupBy * ReadGroupBy(te::xml::Reader &reader)
A Select models a query to be used when retrieving data from a DataSource.
void setSupportBidirectionalTraversing(const bool &support)
boost::ptr_vector< FromItem > From
It models the FROM clause for a query.
A query encoder for binary operator expressions.
void setSupportBatchExecutorAPI(const bool &support)
FromItem * getSecond() const
It returns the second item involved in the join.
TEDATAACCESSEXPORT te::da::DataSourceCatalog * ReadDataSourceCatalog(te::xml::Reader &reader)
Where * getWhere() const
It returns the filter condition.
TEDATAACCESSEXPORT te::da::SQLDialect * ReadDialect(const std::string &dialectFileName)
JoinCondition * getCondition() const
It returns the join condition.
virtual void writeAttribute(const std::string &attName, const std::string &value)=0
JoinConditionUsing class can be used to model a USING clause in a Join.
A query encoder for unary operator expressions.
TEDATAACCESSEXPORT te::da::Select * ReadSelect(te::xml::Reader &reader)
void setDataTypeCapabilities(const DataTypeCapabilities &capabilities)
const Having * getHaving() const
It returns the list of expressions used to eliminate group row that doesn't satisfy the condition...
virtual NodeType getNodeType() const =0
It return the type of node read.
void setSupportPrimaryKey(const bool &support)
std::size_t getLimit() const
It tells the maximum number of rows to return.
virtual std::string getElementValue() const =0
It returns the element data value in the case of VALUE node.
const std::string & getName() const
It returns the dataset name.
TEDATAACCESSEXPORT te::da::Fields * ReadFields(te::xml::Reader &reader)
virtual void writeEndElement(const std::string &qName)=0
A class that represents a data source component.
virtual void writeStartDocument(const std::string &encoding, const std::string &standalone)=0
JoinConditionOn is a boolean expression and it specifies which items in a join are considered to matc...
virtual Expression * clone() const =0
It creates a new copy of this expression.
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.
virtual bool next()=0
It gets the next event to be read.
te::dt::AbstractData * getValue() const
It returns the value associated to the literal.
A base class for binary functions.
std::size_t getNumArgs() const
It returns the number of arguments informed to the function.
TEDATAACCESSEXPORT te::da::PropertyName * ReadPropertyName(te::xml::Reader &reader)
unsigned int getId() const
It returns the property identifier.
TEDATATYPEEXPORT int Convert2Terralib(const std::string &dataType)
It convert a string to a DataType.
TEDATAACCESSEXPORT te::da::Literal * ReadLiteral(te::xml::Reader &reader)
FromItem * getFirst() const
It returns the first from item involved in the join.
boost::shared_ptr< DataSourceInfo > DataSourceInfoPtr
TEDATAACCESSEXPORT void ReadDataSourceInfo(const std::string &datasourcesFileName)
const std::string & getTitle() const
A human descriptive title for the DataSetType.
A class that models a literal for Geometry values.
This class models a string Literal value.
const std::string & getName() const
It returns the property name.
static Geometry * read(const char *wkt)
It returns a valid Geometry from a given WKT.