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"));
158 std::map<std::string, std::string> conninfo;
160 while(reader.
next() &&
184 conninfo[paramName] = paramValue;
196 ds->setConnInfo(conninfo);
214 boost::replace_all(schema_loc,
" ",
"%20");
216 schema_loc =
"file:///" + schema_loc;
224 writer.
writeAttribute(
"xmlns:xsd",
"http://www.w3.org/2001/XMLSchema-instance");
225 writer.
writeAttribute(
"xmlns:te_common",
"http://www.terralib.org/schemas/common");
226 writer.
writeAttribute(
"xmlns",
"http://www.terralib.org/schemas/dataaccess");
227 writer.
writeAttribute(
"xsd:schemaLocation",
"http://www.terralib.org/schemas/dataaccess " + schema_loc);
235 for(it=itBegin; it!=itEnd; ++it)
237 bool ogrDsrc = it->second->getAccessDriver() ==
"OGR";
243 writer.
writeAttribute(
"access_driver", it->second->getAccessDriver());
254 std::map<std::string, std::string> info = it->second->getConnInfo();
255 std::map<std::string, std::string>::iterator conIt;
257 for(conIt=info.begin(); conIt!=info.end(); ++conIt)
314 return catalog.release();
321 Save(catalog, *w.get());
330 writer.
writeAttribute(
"xmlns:xlink",
"http://www.w3.org/1999/xlink");
331 writer.
writeAttribute(
"xmlns:xsd",
"http://www.w3.org/2001/XMLSchema-instance");
332 writer.
writeAttribute(
"xmlns",
"http://www.terralib.org/schemas/da");
333 writer.
writeAttribute(
"xsd:schemaLocation",
"http://www.terralib.org/schemas/da C:/Users/gribeiro/Documents/terralib5/trunk/myschemas/terralib/da/catalog.xsd");
341 for(std::size_t i = 0; i < ndatasets; ++i)
355 std::string name = reader.
getAttr(
"name");
356 std::string title = reader.
getAttr(
"title");
367 std::auto_ptr<te::dt::Property> p(ReadProperty(reader));
368 dt->add(p.release());
385 const std::size_t nprops = dt->
size();
387 for(std::size_t i = 0; i < nprops; ++i)
395 if(accessPolicy ==
"NO_ACCESS")
397 else if (accessPolicy ==
"R_ACCESS")
399 else if(accessPolicy ==
"W_ACCESS")
401 else if(accessPolicy ==
"RW_ACCESS")
411 xmlReader->read(dialectFileName);
413 if(!xmlReader->next())
414 throw te::da::Exception((boost::format(
TE_TR(
"Could not read DataSourceCapabilities information in file: %1%.")) % dialectFileName).str());
417 throw te::da::Exception((boost::format(
TE_TR(
"Error reading the document %1%, the start element wasn't found.")) % dialectFileName).str());
419 if(xmlReader->getElementLocalName() !=
"DataSourceCapabilities")
420 throw te::da::Exception((boost::format(
TE_TR(
"The first tag in the document %1% is not 'DataSourceCapabilities'.")) % dialectFileName).str());
424 assert(xmlReader->getElementLocalName() ==
"DataTypeCapabilities");
428 while(xmlReader->next() &&
430 (xmlReader->getElementLocalName() ==
"DataType"))
447 assert(xmlReader->getElementLocalName() ==
"QueryCapabilities");
453 assert(xmlReader->getElementLocalName() ==
"SQLDialect");
463 assert(xmlReader->getElementLocalName() ==
"SpatialSQLDialect");
466 qc.setSupportSpatialSQLDialect(xmlReader->getElementValueAsBoolean());
473 assert(xmlReader->getElementLocalName() ==
"Insert");
477 qc.setSupportInsert(xmlReader->getElementValueAsBoolean());
484 assert(xmlReader->getElementLocalName() ==
"Update");
488 qc.setSupportUpdate(xmlReader->getElementValueAsBoolean());
495 assert(xmlReader->getElementLocalName() ==
"Delete");
499 qc.setSupportDelete(xmlReader->getElementValueAsBoolean());
506 assert(xmlReader->getElementLocalName() ==
"Create");
510 qc.setSupportCreate(xmlReader->getElementValueAsBoolean());
517 assert(xmlReader->getElementLocalName() ==
"Drop");
521 qc.setSupportDrop(xmlReader->getElementValueAsBoolean());
528 assert(xmlReader->getElementLocalName() ==
"Alter");
532 qc.setSupportAlter(xmlReader->getElementValueAsBoolean());
539 assert(xmlReader->getElementLocalName() ==
"Select");
543 qc.setSupportSelect(xmlReader->getElementValueAsBoolean());
550 assert(xmlReader->getElementLocalName() ==
"SelectInto");
554 qc.setSupportSelectInto(xmlReader->getElementValueAsBoolean());
563 assert(xmlReader->getElementLocalName() ==
"SpatialTopologicOperators");
565 while(xmlReader->next() &&
567 (xmlReader->getElementLocalName() ==
"Function"))
571 std::string fname = xmlReader->getAttr(
"name");
573 qc.addSpatialTopologicOperator(fname);
578 std::string encoderType = xmlReader->getElementLocalName();
580 if(encoderType ==
"FunctionEncoder")
582 std::string alias = xmlReader->getAttr(0);
585 else if(encoderType ==
"BinaryOpEncoder")
587 std::string alias = xmlReader->getAttr(0);
590 else if(encoderType ==
"UnaryOpEncoder")
592 std::string alias = xmlReader->getAttr(0);
595 else if(encoderType ==
"TemplateEncoder")
597 std::string alias = xmlReader->getAttr(0);
598 std::string temp = xmlReader->getAttr(1);
603 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
606 dialect.
insert(fname, sfe);
619 assert(xmlReader->getElementLocalName() ==
"SpatialMetricOperators");
621 while(xmlReader->next() &&
623 (xmlReader->getElementLocalName() ==
"Function"))
627 std::string fname = xmlReader->getAttr(
"name");
629 qc.addSpatialMetricOperator(fname);
634 std::string encoderType = xmlReader->getElementLocalName();
636 if(encoderType ==
"FunctionEncoder")
638 std::string alias = xmlReader->getAttr(0);
641 else if(encoderType ==
"BinaryOpEncoder")
643 std::string alias = xmlReader->getAttr(0);
646 else if(encoderType ==
"UnaryOpEncoder")
648 std::string alias = xmlReader->getAttr(0);
651 else if(encoderType ==
"TemplateEncoder")
653 std::string alias = xmlReader->getAttr(0);
654 std::string temp = xmlReader->getAttr(1);
659 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
662 dialect.
insert(fname, sfe);
675 assert(xmlReader->getElementLocalName() ==
"SpatialNewGeomOperators");
677 while(xmlReader->next() &&
679 (xmlReader->getElementLocalName() ==
"Function"))
683 std::string fname = xmlReader->getAttr(
"name");
685 qc.addSpatialNewGeomOperator(fname);
690 std::string encoderType = xmlReader->getElementLocalName();
692 if(encoderType ==
"FunctionEncoder")
694 std::string alias = xmlReader->getAttr(0);
697 else if(encoderType ==
"BinaryOpEncoder")
699 std::string alias = xmlReader->getAttr(0);
702 else if(encoderType ==
"UnaryOpEncoder")
704 std::string alias = xmlReader->getAttr(0);
707 else if(encoderType ==
"TemplateEncoder")
709 std::string alias = xmlReader->getAttr(0);
710 std::string temp = xmlReader->getAttr(1);
715 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
718 dialect.
insert(fname, sfe);
733 assert(xmlReader->getElementLocalName() ==
"SpatialOperators");
735 while(xmlReader->next() &&
737 (xmlReader->getElementLocalName() ==
"Function"))
741 std::string fname = xmlReader->getAttr(
"name");
743 qc.addSpatialOperator(fname);
748 std::string encoderType = xmlReader->getElementLocalName();
750 if(encoderType ==
"FunctionEncoder")
752 std::string alias = xmlReader->getAttr(0);
755 else if(encoderType ==
"BinaryOpEncoder")
757 std::string alias = xmlReader->getAttr(0);
760 else if(encoderType ==
"UnaryOpEncoder")
762 std::string alias = xmlReader->getAttr(0);
765 else if(encoderType ==
"TemplateEncoder")
767 std::string alias = xmlReader->getAttr(0);
768 std::string temp = xmlReader->getAttr(1);
773 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
776 dialect.
insert(fname, sfe);
789 assert(xmlReader->getElementLocalName() ==
"LogicalOperators");
791 while(xmlReader->next() &&
793 (xmlReader->getElementLocalName() ==
"Function"))
797 std::string fname = xmlReader->getAttr(
"name");
799 qc.addLogicalOperator(fname);
804 std::string encoderType = xmlReader->getElementLocalName();
806 if(encoderType ==
"FunctionEncoder")
808 std::string alias = xmlReader->getAttr(0);
811 else if(encoderType ==
"BinaryOpEncoder")
813 std::string alias = xmlReader->getAttr(0);
816 else if(encoderType ==
"UnaryOpEncoder")
818 std::string alias = xmlReader->getAttr(0);
821 else if(encoderType ==
"TemplateEncoder")
823 std::string alias = xmlReader->getAttr(0);
824 std::string temp = xmlReader->getAttr(1);
829 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
832 dialect.
insert(fname, sfe);
845 assert(xmlReader->getElementLocalName() ==
"ComparsionOperators");
847 while(xmlReader->next() &&
849 (xmlReader->getElementLocalName() ==
"Function"))
853 std::string fname = xmlReader->getAttr(
"name");
855 qc.addComparsionOperator(fname);
860 std::string encoderType = xmlReader->getElementLocalName();
862 if(encoderType ==
"FunctionEncoder")
864 std::string alias = xmlReader->getAttr(0);
867 else if(encoderType ==
"BinaryOpEncoder")
869 std::string alias = xmlReader->getAttr(0);
872 else if(encoderType ==
"UnaryOpEncoder")
874 std::string alias = xmlReader->getAttr(0);
877 else if(encoderType ==
"TemplateEncoder")
879 std::string alias = xmlReader->getAttr(0);
880 std::string temp = xmlReader->getAttr(1);
885 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
888 dialect.
insert(fname, sfe);
901 assert(xmlReader->getElementLocalName() ==
"ArithmeticOperators");
903 while(xmlReader->next() &&
905 (xmlReader->getElementLocalName() ==
"Function"))
909 std::string fname = xmlReader->getAttr(
"name");
911 qc.addArithmeticOperator(fname);
916 std::string encoderType = xmlReader->getElementLocalName();
918 if(encoderType ==
"FunctionEncoder")
920 std::string alias = xmlReader->getAttr(0);
923 else if(encoderType ==
"BinaryOpEncoder")
925 std::string alias = xmlReader->getAttr(0);
928 else if(encoderType ==
"UnaryOpEncoder")
930 std::string alias = xmlReader->getAttr(0);
933 else if(encoderType ==
"TemplateEncoder")
935 std::string alias = xmlReader->getAttr(0);
936 std::string temp = xmlReader->getAttr(1);
941 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
944 dialect.
insert(fname, sfe);
957 assert(xmlReader->getElementLocalName() ==
"Functions");
959 while(xmlReader->next() &&
961 (xmlReader->getElementLocalName() ==
"Function"))
965 std::string fname = xmlReader->getAttr(
"name");
967 qc.addFunction(fname);
972 std::string encoderType = xmlReader->getElementLocalName();
974 if(encoderType ==
"FunctionEncoder")
976 std::string alias = xmlReader->getAttr(0);
979 else if(encoderType ==
"BinaryOpEncoder")
981 std::string alias = xmlReader->getAttr(0);
984 else if(encoderType ==
"UnaryOpEncoder")
986 std::string alias = xmlReader->getAttr(0);
989 else if(encoderType ==
"TemplateEncoder")
991 std::string alias = xmlReader->getAttr(0);
992 std::string temp = xmlReader->getAttr(1);
997 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
1000 dialect.
insert(fname, sfe);
1013 assert(xmlReader->getElementLocalName() ==
"GeomOperands");
1015 while(xmlReader->next() &&
1017 (xmlReader->getElementLocalName() ==
"GeomType"))
1022 std::string geom = boost::to_upper_copy(xmlReader->getElementValue());
1041 assert(xmlReader->getElementLocalName() ==
"DataSetTypeCapabilities");
1047 assert(xmlReader->getElementLocalName() ==
"SupportPrimaryKey");
1059 assert(xmlReader->getElementLocalName() ==
"SupportUniqueKey");
1064 dstc.setSupportUniqueKey(xmlReader->getElementValueAsBoolean());
1071 assert(xmlReader->getElementLocalName() ==
"SupportForeignKey");
1076 dstc.setSupportForeingKey(xmlReader->getElementValueAsBoolean());
1083 assert(xmlReader->getElementLocalName() ==
"SupportSequence");
1088 dstc.setSupportSequence(xmlReader->getElementValueAsBoolean());
1095 assert(xmlReader->getElementLocalName() ==
"SupportCheckConstraints");
1100 dstc.setSupportCheckConstraints(xmlReader->getElementValueAsBoolean());
1107 assert(xmlReader->getElementLocalName() ==
"SupportIndex");
1112 dstc.setSupportIndex(xmlReader->getElementValueAsBoolean());
1119 assert(xmlReader->getElementLocalName() ==
"SupportRTreeIndex");
1124 dstc.setSupportRTreeIndex(xmlReader->getElementValueAsBoolean());
1131 assert(xmlReader->getElementLocalName() ==
"SupportBTreeIndex");
1136 dstc.setSupportBTreeIndex(xmlReader->getElementValueAsBoolean());
1143 assert(xmlReader->getElementLocalName() ==
"SupportHashIndex");
1148 dstc.setSupportHashIndex(xmlReader->getElementValueAsBoolean());
1155 assert(xmlReader->getElementLocalName() ==
"SupportQuadTreeIndex");
1160 dstc.setSupportQuadTreeIndex(xmlReader->getElementValueAsBoolean());
1172 assert(xmlReader->getElementLocalName() ==
"DataSetCapabilities");
1178 assert(xmlReader->getElementLocalName() ==
"Bidirectional");
1190 assert(xmlReader->getElementLocalName() ==
"Random");
1195 dsetc.setSupportRandomTraversing(xmlReader->getElementValueAsBoolean());
1202 assert(xmlReader->getElementLocalName() ==
"Indexed");
1207 dsetc.setSupportIndexedTraversing(xmlReader->getElementValueAsBoolean());
1214 assert(xmlReader->getElementLocalName() ==
"EfficientMovePrevious");
1219 dsetc.setSupportEfficientMovePrevious(xmlReader->getElementValueAsBoolean());
1226 assert(xmlReader->getElementLocalName() ==
"EfficientMoveBeforeFirst");
1231 dsetc.setSupportEfficientMoveBeforeFirst(xmlReader->getElementValueAsBoolean());
1238 assert(xmlReader->getElementLocalName() ==
"EfficientMoveLast");
1243 dsetc.setSupportEfficientMoveLast(xmlReader->getElementValueAsBoolean());
1250 assert(xmlReader->getElementLocalName() ==
"EfficientMoveAfterLast");
1255 dsetc.setSupportEfficientMoveAfterLast(xmlReader->getElementValueAsBoolean());
1262 assert(xmlReader->getElementLocalName() ==
"EfficientMove");
1267 dsetc.setSupportEfficientMove(xmlReader->getElementValueAsBoolean());
1274 assert(xmlReader->getElementLocalName() ==
"EfficientSize");
1279 dsetc.setSupportEfficientDataSetSize(xmlReader->getElementValueAsBoolean());
1291 assert(xmlReader->getElementLocalName() ==
"SpecificCapabilities");
1293 while(xmlReader->next() &&
1295 (xmlReader->getElementLocalName() ==
"Parameter"))
1299 assert(xmlReader->getElementLocalName() ==
"Name");
1304 std::string paramName = xmlReader->getElementValue();
1311 assert(xmlReader->getElementLocalName() ==
"Value");
1316 std::string paramValue = xmlReader->getElementValue();
1331 assert(xmlReader->getElementLocalName() ==
"AccessPolicyName");
1343 assert(xmlReader->getElementLocalName() ==
"SupportTransactions");
1355 assert(xmlReader->getElementLocalName() ==
"SupportDataSetPesistenceAPI");
1367 assert(xmlReader->getElementLocalName() ==
"SupportDataSetTypePesistenceAPI");
1379 assert(xmlReader->getElementLocalName() ==
"SupportPreparedQueryAPI");
1391 assert(xmlReader->getElementLocalName() ==
"SupportBatchExecutorAPI");
1410 xmlReader->read(dialectFileName);
1412 if(!xmlReader->next())
1413 throw te::da::Exception((boost::format(
TE_TR(
"Could not read query dialect information in file: %1%.")) % dialectFileName).str());
1416 throw te::da::Exception((boost::format(
TE_TR(
"Error reading the document %1%, the start element wasn't found.")) % dialectFileName).str());
1418 if(xmlReader->getElementLocalName() !=
"QueryDialect")
1419 throw te::da::Exception((boost::format(
TE_TR(
"The first tag in the document %1% is not 'QueryDialect'.")) % dialectFileName).str());
1423 assert(xmlReader->getElementLocalName() ==
"DriverName");
1432 assert(xmlReader->getElementLocalName() ==
"Functions");
1436 while(xmlReader->next() &&
1438 (xmlReader->getElementLocalName() ==
"Function"))
1440 std::string fname = xmlReader->getAttr(0);
1445 std::string encoderType = xmlReader->getElementLocalName();
1449 if(encoderType ==
"FunctionEncoder")
1451 std::string alias = xmlReader->getAttr(0);
1454 else if(encoderType ==
"BinaryOpEncoder")
1456 std::string alias = xmlReader->getAttr(0);
1459 else if(encoderType ==
"UnaryOpEncoder")
1461 std::string alias = xmlReader->getAttr(0);
1466 throw te::da::Exception(
TE_TR(
"Unsupported encoder type!"));
1472 mydialect->insert(fname, sfe);
1480 return mydialect.release();
1509 dist->push_back(exp);
1537 fields->push_back(f);
1542 fields->push_back(f);
1547 fields->push_back(f);
1599 else if (type ==
"INNER_JOIN")
1601 else if (type ==
"LEFT_JOIN")
1603 else if (type ==
"RIGHT_JOIN")
1605 else if (type ==
"FULL_OUTER_JOIN")
1607 else if ( type ==
"CROSS_JOIN")
1644 from->push_back(join);
1727 std::size_t countAux = 0;
1795 groupBy->push_back(groupByItem);
1895 throw te::da::Exception(
TE_TR(
"Data Type Undefined!"));
1946 orderBy->push_back(orderByItem);
1998 select->setFields(fields);
2004 select->setFrom(from);
2010 select->setWhere(wh);
2016 select->setGroupBy(gBy);
2022 select->setHaving(having);
2028 select->setOrderBy(oBy);
2034 select->setDistinct(distinct);
2041 select->setLimit(boost::lexical_cast<std::size_t>(reader.
getElementValue()));
2051 select->setOffset(boost::lexical_cast<std::size_t>(reader.
getElementValue()));
2099 for(std::size_t i = 0; i < distinct->size(); ++i)
2113 std::auto_ptr<te::da::Expression> exp(expression->
clone());
2121 Save(pName, writer);
2127 throw te::da::Exception(
TE_TR(
"Error: Expression Type Undefined!"));
2155 for(std::size_t i = 0; i < fields->size(); ++i)
2159 Save(&item, writer);
2169 for(std::size_t i = 0; i < from->size(); ++i)
2173 Save(&item, writer);
2210 std::string joinType;
2217 joinType =
"INNER_JOIN";
2220 joinType =
"LEFT_JOIN";
2223 joinType =
"RIGHT_JOIN";
2226 joinType =
"FULL_OUTER_JOIN";
2229 joinType =
"CROSS_JOIN";
2232 joinType =
"NATURAL_JOIN";
2254 for(std::size_t i = 0; i < joinUsing->
getNumFields(); ++i)
2273 std::string funcName = func->
getName();
2277 for(std::size_t i = 0; i < func->
getNumArgs(); i++)
2287 assert(groupByItem);
2299 for(std::size_t i = 0; i < groupBy->size(); ++i)
2303 Save(&item, writer);
2335 assert(orderByItem);
2352 for(std::size_t i = 0; i < orderBy->size(); ++i)
2356 Save(&item, writer);
2364 assert(propertyName);
2376 Save(fields, writer);
2388 Save(groupBy, writer);
2392 Save(having, writer);
2396 Save(orderBy, writer);
2400 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.
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.