GOFIGURE2  0.9.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
QueryBuilderHelper.cxx File Reference
#include "QueryBuilderHelper.h"
#include "ConvertToStringHelper.h"
#include <sstream>
Include dependency graph for QueryBuilderHelper.cxx:

Go to the source code of this file.

Functions

std::string AddDistinctToWhat (const std::string &iWhat)
 DISTINCT iWhat. More...
 
std::string AddOrderBy (const std::string &iAttribute, std::string iAscDesc)
 ORDER BY iAttributes iAscDesc. More...
 
std::string GetConditions (const std::vector< FieldWithValue > &iConditions, std::string iConditionConnector)
 
std::string GetConditions (const std::string &iField, const std::string &iValue, std::string iConnector)
 
std::string GetGroupBy (const std::string &iColumn, unsigned int iNumberDoublons)
 
std::string GetLeftJoinThreeTables (const std::string &iTable, const std::string &iTableTwo, const std::string &iTableThree, const FieldWithValue &iOnConditionOne, const FieldWithValue &iOnConditionTwo)
 (iTable LEFT JOIN iTableTwo ON iTable.iOnCondition/Field = iTableTwo.iOnCondition/Value) LEFT JOIN iTableThree ON iTable.iOnCondition/Field = iTableThree.iOnCondition/Value) More...
 
std::string GetLeftJoinTwoTables (const std::string &iTableOne, const std::string &iTableTwo, const FieldWithValue &iOnCondition, bool NonNULLRows)
 iTableOne LEFT JOIN iTableTwo ON iTableOne.iOnCondition/Field = iTableTwo.iOnCondition/Value More...
 
std::string GetSelectedAttributes (const std::vector< std::string > &iListAttributes)
 iListAttributes[i], iListAttributes[i+1]... More...
 
std::vector< std::string > ListUnsgIntToVectorString (const std::list< unsigned int > &iList)
 
std::string SelectForTracesInfo (const std::vector< std::string > &iSelectedAttributes, const std::string &iTableOne, const std::string &iTableTwo, const std::string &iTableThree, const FieldWithValue &iJoinConditionOne, const FieldWithValue &iJoinConditionTwo, const std::string &iFieldOne, unsigned int iValueFieldOne, const std::string &iIDFieldName, const std::list< unsigned int > &iListIDs)
 SELECT iSelectedAttributes[0], iSelectedAttributes[1]...FROM (iTableOne left join iTableTwo on iJoinConditionOne) left join tableThree on iJoinConditionTwo where (iFieldOne = iValueFieldOne) AND (IDFieldName = iListIDs[0] OR IDFieldName = iListIDs[1] OR....);. More...
 
std::string SelectGeneralQuery (const std::string &iWhat, const std::string &iWhere, std::string iOrderByQuery)
 SELECT iWhat FROM iWhere iOrderByQuery. More...
 
std::string SelectGeneralQueryConditions (const std::string &iWhat, const std::string &iWhere, const std::string &iConditions)
 SELECT iWhat FROM iWhere WHERE iConditions. More...
 
std::string SelectQueryStream (const std::string &iTable, const std::string &iColumn, std::string iOrderByColumnName, std::string iAscDesc)
 SELECT iColumn FROM iTable ORDER BY iOrderByColumnName iAscDesc;. More...
 
std::string SelectQueryStream (const std::string &iTable, const std::vector< std::string > &iListAttributes, std::string iOrderByColumnName, std::string iAscDesc)
 SELECT iColumn[i],iColumn[i=1]... FROM iTable ORDER BY iOrderByColumnName iAscDesc;. More...
 
std::string SelectQueryStreamCondition (const std::string &iTable, const std::string &iColumn, const std::string &iConditions, bool Distinct, std::string iOrderByColumnName, std::string iAscDesc)
 SELECT (Distinct) iColumn FROM iTable WHERE iConditions (ORDER BY irderByColumnName iAscDesc);. More...
 
std::string SelectQueryStreamCondition (const std::string &iTable, const std::string &iColumn, const std::string &iField, const std::string &iValue, std::string iOrderByColumnName, std::string iAscDesc, bool Distinct)
 
std::string SelectQueryStreamCondition (const std::string &iTable, const std::vector< std::string > &iListAttributes, const std::string &iField, const std::string &iValue, std::string iOrderByColumnName, std::string iAscDesc)
 
std::string SelectQueryStreamListConditions (const std::string &iTable, const std::string &iColumn, const std::string &iField, const std::vector< std::string > &iListValues, bool Distinct, std::string iConditionConnector)
 SELECT (Distinct) iColumn FROM iTable WHERE iField = iValue Or/And... More...
 
std::string SelectQueryStreamListConditions (const std::string &iTable, const std::vector< std::string > &iListAttributes, const std::string &iField, const std::vector< std::string > &iListValues, std::string iConditionConnector, bool Distinct)
 
std::string SelectQueryStreamListConditions (const std::string &iTable, const std::string &iColumn, const std::vector< FieldWithValue > &iConditions, std::string iConditionConnector, bool Distinct)
 
std::string SelectQueryStreamListConditions (const std::string &iTable, const std::vector< std::string > &iListAttributes, const std::vector< FieldWithValue > &iConditions, std::string iConditionConnector, bool Distinct, std::string iOrderByColumnName)
 
std::list< unsigned int > VectorStringToUnsgInt (const std::vector< std::string > &iVector)
 
std::vector< std::string > VectorUnsgIntToVectorString (const std::vector< unsigned int > &iVector)
 

Function Documentation

std::string AddDistinctToWhat ( const std::string &  iWhat)

DISTINCT iWhat.

Parameters
[in]iWhatattributes
Returns
part of the query to make iWhat distinct

Definition at line 248 of file QueryBuilderHelper.cxx.

std::string AddOrderBy ( const std::string &  iAttribute,
std::string  iAscDesc = "ASC" 
)

ORDER BY iAttributes iAscDesc.

Parameters
[in]iAttributeattribute to be sorted
[in]iAscDescascendent or descendent sorting
Returns
the string corresponding to the query part

Definition at line 259 of file QueryBuilderHelper.cxx.

std::string GetConditions ( const std::vector< FieldWithValue > &  iConditions,
std::string  iConditionConnector 
)

Definition at line 273 of file QueryBuilderHelper.cxx.

std::string GetConditions ( const std::string &  iField,
const std::string &  iValue,
std::string  iConnector 
)

Definition at line 304 of file QueryBuilderHelper.cxx.

std::string GetGroupBy ( const std::string &  iColumn,
unsigned int  iNumberDoublons 
)

Definition at line 437 of file QueryBuilderHelper.cxx.

std::string GetLeftJoinThreeTables ( const std::string &  iTable,
const std::string &  iTableTwo,
const std::string &  iTableThree,
const FieldWithValue iOnConditionOne,
const FieldWithValue iOnConditionTwo 
)

(iTable LEFT JOIN iTableTwo ON iTable.iOnCondition/Field = iTableTwo.iOnCondition/Value) LEFT JOIN iTableThree ON iTable.iOnCondition/Field = iTableThree.iOnCondition/Value)

Parameters
[in]iTabletable to be joined
[in]iTableTwotable to be joined to the 1rst one
[in]iTableThreetable to be joined ot the 1rst one
[in]iOnConditionOnejoin on which condition between table and tableTwo
[in]iOnConditionTwojoin on which condition between table and tableThree
Returns
the string corresponding to the query part

Definition at line 417 of file QueryBuilderHelper.cxx.

std::string GetLeftJoinTwoTables ( const std::string &  iTableOne,
const std::string &  iTableTwo,
const FieldWithValue iOnCondition,
bool  NonNULLRows = false 
)

iTableOne LEFT JOIN iTableTwo ON iTableOne.iOnCondition/Field = iTableTwo.iOnCondition/Value

Parameters
[in]iTableOnetable to be joined
[in]iTableTwotable to be joined to
[in]iOnConditionjoin on which condition
[in]NonNULLRowsif the connection is not found for 2 tables, there won't be a result
Returns
the string corresponding to the query part

Definition at line 384 of file QueryBuilderHelper.cxx.

std::string GetSelectedAttributes ( const std::vector< std::string > &  iListAttributes)

iListAttributes[i], iListAttributes[i+1]...

Parameters
[in]iListAttributeslist of the attributes to be selected
Returns
the string corresponding to the query part

Definition at line 318 of file QueryBuilderHelper.cxx.

std::vector< std::string > ListUnsgIntToVectorString ( const std::list< unsigned int > &  iList)

Definition at line 335 of file QueryBuilderHelper.cxx.

std::string SelectForTracesInfo ( const std::vector< std::string > &  iSelectedAttributes,
const std::string &  iTableOne,
const std::string &  iTableTwo,
const std::string &  iTableThree,
const FieldWithValue iJoinConditionOne,
const FieldWithValue iJoinConditionTwo,
const std::string &  iFieldOne,
unsigned int  iValueFieldOne,
const std::string &  iIDFieldName,
const std::list< unsigned int > &  iListIDs 
)

SELECT iSelectedAttributes[0], iSelectedAttributes[1]...FROM (iTableOne left join iTableTwo on iJoinConditionOne) left join tableThree on iJoinConditionTwo where (iFieldOne = iValueFieldOne) AND (IDFieldName = iListIDs[0] OR IDFieldName = iListIDs[1] OR....);.

Parameters
[in]iSelectedAttributesvector of all the attributes to be fetched from the db
[in]iTableOnemain table involved (usually the table for the trace)
[in]iTableTwotable attached to the main table
[in]iTableThreetable attached to the main table
[in]iJoinConditionOnedescribes how the tabletwo is attached to the main table
[in]iJoinConditionTwodescribes how the tablethree is attached to the main table
[in]iFieldOnefirst condition
[in]iValueFieldOnevalue for the first condition
[in]iIDFieldNamefield for the IDName where there is a condition
[in]iListIDsvalues for the iIDFieldname
Returns
the string corresponding to the query part

Definition at line 456 of file QueryBuilderHelper.cxx.

std::string SelectGeneralQuery ( const std::string &  iWhat,
const std::string &  iWhere,
std::string  iOrderByQuery = "" 
)

SELECT iWhat FROM iWhere iOrderByQuery.

Parameters
[in]iWhatlist of attributes separated by commas
[in]iWherelist of tables, included joined tables
[in]iOrderByQuerypart of the query to order by
Returns
the string corresponding to the query part

Definition at line 58 of file QueryBuilderHelper.cxx.

std::string SelectGeneralQueryConditions ( const std::string &  iWhat,
const std::string &  iWhere,
const std::string &  iConditions 
)

SELECT iWhat FROM iWhere WHERE iConditions.

Parameters
[in]iWhatlist of attributes separated by commas
[in]iWherelist of tables, included joined tables
[in]iConditionslist of conditions
Returns
the string corresponding to the query part

Definition at line 39 of file QueryBuilderHelper.cxx.

std::string SelectQueryStream ( const std::string &  iTable,
const std::string &  iColumn,
std::string  iOrderByColumnName = "",
std::string  iAscDesc = "ASC" 
)

SELECT iColumn FROM iTable ORDER BY iOrderByColumnName iAscDesc;.

Parameters
[in]iTablename of the database table
[in]iColumnname of the attribute to select
[in]iOrderByColumnNamename of the column by which the results will be sorted, if empty, no sorting
[in]iAscDescorder to sort the results, ascendent by default
Returns
the string corresponding to the query part

Definition at line 79 of file QueryBuilderHelper.cxx.

std::string SelectQueryStream ( const std::string &  iTable,
const std::vector< std::string > &  iListAttributes,
std::string  iOrderByColumnName = "",
std::string  iAscDesc = "ASC" 
)

SELECT iColumn[i],iColumn[i=1]... FROM iTable ORDER BY iOrderByColumnName iAscDesc;.

Parameters
[in]iTablename of the database table
[in]iListAttributesname of the attributes to select
[in]iOrderByColumnNamename of the column by which the results will be sorted, if empty, no sorting
[in]iAscDescorder to sort the results, ascendent by default
Returns
the string corresponding to the query part

Definition at line 97 of file QueryBuilderHelper.cxx.

std::string SelectQueryStreamCondition ( const std::string &  iTable,
const std::string &  iColumn,
const std::string &  iConditions,
bool  Distinct = false,
std::string  iOrderByColumnName = "",
std::string  iAscDesc = "ASC" 
)

SELECT (Distinct) iColumn FROM iTable WHERE iConditions (ORDER BY irderByColumnName iAscDesc);.

Parameters
[in]iTablename of the database table
[in]iColumnname of the attribute to select
[in]iOrderByColumnNamename of the column by which the results will be sorted, if empty, no sorting
[in]iAscDescorder to sort the results, ascendent by default
[in]iConditionsname of the columns separated by comma that are part of the 'where'
[in]Distincttrue if no doublon allowed
Returns
the string corresponding to the query part

Definition at line 111 of file QueryBuilderHelper.cxx.

std::string SelectQueryStreamCondition ( const std::string &  iTable,
const std::string &  iColumn,
const std::string &  iField,
const std::string &  iValue,
std::string  iOrderByColumnName = "",
std::string  iAscDesc = "ASC",
bool  Distinct = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 136 of file QueryBuilderHelper.cxx.

std::string SelectQueryStreamCondition ( const std::string &  iTable,
const std::vector< std::string > &  iListAttributes,
const std::string &  iField,
const std::string &  iValue,
std::string  iOrderByColumnName = "",
std::string  iAscDesc = "ASC" 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 157 of file QueryBuilderHelper.cxx.

std::string SelectQueryStreamListConditions ( const std::string &  iTable,
const std::string &  iColumn,
const std::string &  iField,
const std::vector< std::string > &  iListValues,
bool  Distinct = false,
std::string  iConditionConnector = "OR" 
)

SELECT (Distinct) iColumn FROM iTable WHERE iField = iValue Or/And...

Parameters
[in]iTablename of the database table
[in]iColumnname of the attribute to select
[in]iFieldname of the condition
[in]iListValuesvalues of the condition
[in]Distinctif set to true no doublon allowed
[in]iConditionConnectoror/and
Returns
the string corresponding to the query part

Definition at line 173 of file QueryBuilderHelper.cxx.

std::string SelectQueryStreamListConditions ( const std::string &  iTable,
const std::vector< std::string > &  iListAttributes,
const std::string &  iField,
const std::vector< std::string > &  iListValues,
std::string  iConditionConnector,
bool  Distinct 
)

Definition at line 189 of file QueryBuilderHelper.cxx.

std::string SelectQueryStreamListConditions ( const std::string &  iTable,
const std::string &  iColumn,
const std::vector< FieldWithValue > &  iConditions,
std::string  iConditionConnector = "OR",
bool  Distinct = false 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 206 of file QueryBuilderHelper.cxx.

std::string SelectQueryStreamListConditions ( const std::string &  iTable,
const std::vector< std::string > &  iListAttributes,
const std::vector< FieldWithValue > &  iConditions,
std::string  iConditionConnector = "OR",
bool  Distinct = false,
std::string  iOrderByColumnName = "" 
)

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 226 of file QueryBuilderHelper.cxx.

std::list< unsigned int > VectorStringToUnsgInt ( const std::vector< std::string > &  iVector)

Definition at line 352 of file QueryBuilderHelper.cxx.

std::vector< std::string > VectorUnsgIntToVectorString ( const std::vector< unsigned int > &  iVector)

Definition at line 368 of file QueryBuilderHelper.cxx.