Interface for the OPENTREP Services. More...
#include <opentrep/OPENTREP_Service.hpp>
Public Types | |
typedef std::pair< const TravelDBFilePath_T, const SQLDBConnectionString_T > | DBFilePathPair_T |
typedef std::pair< const PORFilePath_T, const DBFilePathPair_T > | FilePathSet_T |
Interface for the OPENTREP Services.
Definition at line 25 of file OPENTREP_Service.hpp.
typedef std::pair<const TravelDBFilePath_T, const SQLDBConnectionString_T> OPENTREP::OPENTREP_Service::DBFilePathPair_T |
Get the file-paths of the Xapian database/index and of the OPTD-maintained POR (points of reference).
Definition at line 74 of file OPENTREP_Service.hpp.
typedef std::pair<const PORFilePath_T, const DBFilePathPair_T> OPENTREP::OPENTREP_Service::FilePathSet_T |
Definition at line 75 of file OPENTREP_Service.hpp.
OPENTREP::OPENTREP_Service::OPENTREP_Service | ( | std::ostream & | ioLogStream, |
const TravelDBFilePath_T & | iTravelDBFilePath, | ||
const DBType & | iSQLDBType, | ||
const SQLDBConnectionString_T & | iSQLDBConnStr, | ||
const DeploymentNumber_T & | iDeploymentNumber ) |
Constructor for search-/query-related services.
std::ostream& | Output log stream (for instance, std::cout). |
const | TravelDBFilePath_T& File-path of the Xapian index/database. |
const | DBType& SQL database type (can be no database at all). |
const | SQLDBConnectionString_T& SQL DB connection string. |
const | DeploymentNumber_T& Deployment number/version. |
Definition at line 48 of file OPENTREP_Service.cpp.
OPENTREP::OPENTREP_Service::OPENTREP_Service | ( | std::ostream & | ioLogStream, |
const PORFilePath_T & | iPORFilepath, | ||
const TravelDBFilePath_T & | iTravelDBFilePath, | ||
const DBType & | iSQLDBType, | ||
const SQLDBConnectionString_T & | iSQLDBConnStr, | ||
const DeploymentNumber_T & | iDeploymentNumber, | ||
const shouldIndexNonIATAPOR_T & | iShouldIndexNonIATAPOR, | ||
const shouldIndexPORInXapian_T & | iShouldIndexPORInXapian, | ||
const shouldAddPORInSQLDB_T & | iShouldAddPORInSQLDB ) |
Constructor for indexing-related services.
std::ostream& | Output log stream (for instance, std::cout). |
const | PORFilePath_T& File-path of the file of POR (points of reference). |
const | TravelDBFilePath_T& File-path of the Xapian index/database. |
const | DBType& SQL database type (can be no database at all). |
const | SQLDBConnectionString_T& SQL DB connection string. |
const | DeploymentNumber_T& Deployment number/version. |
const | shouldIndexNonIATAPOR_T& Whether to include non-IATA POR. |
const | shouldIndexPORInXapian_T& Whether to index POR in Xapian. |
const | shouldAddPORInSQLDB_T& Whether to add POR in SQL database. |
Definition at line 32 of file OPENTREP_Service.cpp.
OPENTREP::OPENTREP_Service::~OPENTREP_Service | ( | ) |
Destructor.
Definition at line 70 of file OPENTREP_Service.cpp.
NbOfDBEntries_T OPENTREP::OPENTREP_Service::getIndexSize | ( | ) |
Get the number of documents within the Xapian database (index).
Definition at line 210 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::OPENTREP_ServiceContext::getTravelDBFilePath(), OPENTREP_LOG_DEBUG, and OPENTREP::BasChronometer::start().
Referenced by main().
NbOfMatches_T OPENTREP::OPENTREP_Service::drawRandomLocations | ( | const NbOfMatches_T & | iNbOfDraws, |
LocationList_T & | ioLocationList ) |
Return a given number of locations, all randomly draw from the Xapian database (index).
LocationList_T& | List of (geographical) locations randomly picked up from the Xapian database. |
Definition at line 238 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::OPENTREP_ServiceContext::getTravelDBFilePath(), OPENTREP_LOG_DEBUG, and OPENTREP::BasChronometer::start().
NbOfMatches_T OPENTREP::OPENTREP_Service::interpretTravelRequest | ( | const std::string & | iTravelQuery, |
LocationList_T & | ioLocationList, | ||
WordList_T & | ioWordList ) |
Match the given string, thanks to a full-text search on the underlying Xapian index (named "database").
const | std::string& (Travel-related) query string (e.g., "sna francicso rio de janero lso angles reykyavki nce iev mow"). |
LocationList_T& | List of (geographical) locations, if any, matching the given query string. |
WordList_T& | List of non-matched words of the query string. |
Definition at line 960 of file OPENTREP_Service.cpp.
References checkXapianDBOnFileSystem(), OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::OPENTREP_ServiceContext::getTransliterator(), OPENTREP::OPENTREP_ServiceContext::getTravelDBFilePath(), OPENTREP_LOG_DEBUG, OPENTREP_LOG_ERROR, and OPENTREP::BasChronometer::start().
Referenced by parseQuery().
OPENTREP_Service::FilePathSet_T OPENTREP::OPENTREP_Service::getFilePaths | ( | ) | const |
Definition at line 176 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::getPORFilePath(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), and OPENTREP::OPENTREP_ServiceContext::getTravelDBFilePath().
Referenced by main().
const DeploymentNumber_T & OPENTREP::OPENTREP_Service::getDeploymentNumber | ( | ) | const |
Get the deployment number.
Definition at line 160 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::getDeploymentNumber().
bool OPENTREP::OPENTREP_Service::checkXapianDBOnFileSystem | ( | const TravelDBFilePath_T & | iTravelDBFilePath | ) | const |
Check that the directory hosting the Xapian database/index exists and is accessible.
Definition at line 202 of file OPENTREP_Service.cpp.
References OPENTREP::FileManager::checkXapianDBOnFileSystem().
Referenced by interpretTravelRequest(), and main().
bool OPENTREP::OPENTREP_Service::createSQLDBUser | ( | ) |
Create the SQL database user ('trep' on MySQL) and database ('trep_trep' on MySQL). That method has no effect on other database types (e.g., nosql, sqlite).
Definition at line 270 of file OPENTREP_Service.cpp.
References OPENTREP::DBManager::createSQLDBUser(), OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::OPENTREP_ServiceContext::getDeploymentNumber(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::DBType::NODB, OPENTREP_LOG_DEBUG, and OPENTREP::BasChronometer::start().
Referenced by main().
void OPENTREP::OPENTREP_Service::setSQLDBConnectString | ( | const SQLDBConnectionString_T & | iSQLDBConnectionString | ) |
Update the connection string.
trep
user: db=trep_trep user=trep password=trep
db=mysql user=root password=admin_user_passwd
const | SQLDBConnectionString_T& Connection string. |
Definition at line 321 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP_LOG_DEBUG, and OPENTREP::OPENTREP_ServiceContext::setSQLDBConnectionString().
Referenced by main().
void OPENTREP::OPENTREP_Service::createSQLDBTables | ( | ) |
Create the SQL database tables and leave them empty.
The SQL database may be one of SQLite3, MySQL, PostgreSQL. That latter is not yet supported (patches are welcome on http://github.com/trep/opentrep/issues).
Definition at line 339 of file OPENTREP_Service.cpp.
References OPENTREP::DBManager::createSQLDBTables(), OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::DBManager::initSQLDBSession(), OPENTREP::DBType::NODB, OPENTREP_LOG_DEBUG, OPENTREP::BasChronometer::start(), and OPENTREP::DBManager::terminateSQLDBSession().
Referenced by main().
void OPENTREP::OPENTREP_Service::createSQLDBIndexes | ( | ) |
Create the SQL database indexes.
Definition at line 389 of file OPENTREP_Service.cpp.
References OPENTREP::DBManager::createSQLDBIndexes(), OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::DBManager::initSQLDBSession(), OPENTREP::DBType::NODB, OPENTREP_LOG_DEBUG, OPENTREP::BasChronometer::start(), and OPENTREP::DBManager::terminateSQLDBSession().
Referenced by main().
OPENTREP::DeploymentNumber_T OPENTREP::OPENTREP_Service::toggleDeploymentNumber | ( | ) |
Toggle the deployment number/version.
Definition at line 440 of file OPENTREP_Service.cpp.
References OPENTREP::DEFAULT_OPENTREP_DEPLOYMENT_NUMBER, OPENTREP::DEFAULT_OPENTREP_DEPLOYMENT_NUMBER_SIZE, OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::OPENTREP_ServiceContext::getDeploymentNumber(), OPENTREP_LOG_DEBUG, and OPENTREP::OPENTREP_ServiceContext::setDeploymentNumber().
Referenced by main().
OPENTREP::shouldIndexNonIATAPOR_T OPENTREP::OPENTREP_Service::toggleShouldIncludeAllPORFlag | ( | ) |
Toggle the flag stating whether to index non-IATA-referenced POR
Definition at line 471 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::OPENTREP_ServiceContext::getShouldIncludeAllPORFlag(), OPENTREP_LOG_DEBUG, and OPENTREP::OPENTREP_ServiceContext::setShouldIncludeAllPORFlag().
Referenced by main().
OPENTREP::shouldIndexPORInXapian_T OPENTREP::OPENTREP_Service::toggleShouldIndexPORInXapianFlag | ( | ) |
Toggle the flag stating whether to add the POR in the Xapian index
Definition at line 501 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::OPENTREP_ServiceContext::getShouldIndexPORInXapianFlag(), and OPENTREP_LOG_DEBUG.
Referenced by main().
OPENTREP::shouldAddPORInSQLDB_T OPENTREP::OPENTREP_Service::toggleShouldAddPORInSQLDBFlag | ( | ) |
Toggle the flag stating whether to add the POR in the SQL database
Definition at line 532 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::OPENTREP_ServiceContext::getShouldAddPORInSQLDB(), OPENTREP_LOG_DEBUG, and OPENTREP::OPENTREP_ServiceContext::setShouldAddPORInSQLDB().
Referenced by main().
NbOfDBEntries_T OPENTREP::OPENTREP_Service::insertIntoDBAndXapian | ( | ) |
From the file of OPTD-maintained POR (points of reference):
The relevant POR are by default only the IATA-referenced ones. If the corresponding flag is set, then all the POR are relevant. All the above-mentioned flags are specified in the underlying OPENTREP_ServiceContext object.
Definition at line 897 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::OPENTREP_ServiceContext::getPORFilePath(), OPENTREP::OPENTREP_ServiceContext::getShouldAddPORInSQLDB(), OPENTREP::OPENTREP_ServiceContext::getShouldIncludeAllPORFlag(), OPENTREP::OPENTREP_ServiceContext::getShouldIndexPORInXapianFlag(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::OPENTREP_ServiceContext::getTransliterator(), OPENTREP::OPENTREP_ServiceContext::getTravelDBFilePath(), OPENTREP_LOG_DEBUG, and OPENTREP::BasChronometer::start().
Referenced by main().
NbOfDBEntries_T OPENTREP::OPENTREP_Service::getNbOfPORFromDB | ( | ) |
Retrieve the number of POR (points of reference) within the SQL database.
Definition at line 562 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::DBManager::displayCount(), OPENTREP::BasChronometer::elapsed(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::DBManager::initSQLDBSession(), OPENTREP_LOG_DEBUG, OPENTREP::BasChronometer::start(), and OPENTREP::DBManager::terminateSQLDBSession().
Referenced by main().
NbOfMatches_T OPENTREP::OPENTREP_Service::listByIataCode | ( | const IATACode_T & | iIataCode, |
LocationList_T & | ioLocationList ) |
List all the POR (points of reference) corresponding to the given IATA code.
const | IATACode_T& The given IATA code (key). |
LocationList_T& | List of (geographical) locations, if any, matching the given key. |
Definition at line 607 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::DBManager::getPORByIATACode(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::DBManager::initSQLDBSession(), OPENTREP_LOG_DEBUG, OPENTREP::BasChronometer::start(), and OPENTREP::DBManager::terminateSQLDBSession().
Referenced by main().
NbOfMatches_T OPENTREP::OPENTREP_Service::listByIcaoCode | ( | const ICAOCode_T & | iIcaoCode, |
LocationList_T & | ioLocationList ) |
List all the POR (points of reference) corresponding to the given ICAO code.
const | ICAOCode_T& The given ICAO code (key). |
LocationList_T& | List of (geographical) locations, if any, matching the given key. |
Definition at line 656 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::DBManager::getPORByICAOCode(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::DBManager::initSQLDBSession(), OPENTREP_LOG_DEBUG, OPENTREP::BasChronometer::start(), and OPENTREP::DBManager::terminateSQLDBSession().
Referenced by main().
NbOfMatches_T OPENTREP::OPENTREP_Service::listByFaaCode | ( | const FAACode_T & | iFaaCode, |
LocationList_T & | ioLocationList ) |
List all the POR (points of reference) corresponding to the given FAA code.
const | FAACode_T& The given FAA code (key). |
LocationList_T& | List of (geographical) locations, if any, matching the given key. |
Definition at line 704 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::DBManager::getPORByFAACode(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::DBManager::initSQLDBSession(), OPENTREP_LOG_DEBUG, OPENTREP::BasChronometer::start(), and OPENTREP::DBManager::terminateSQLDBSession().
Referenced by main().
NbOfMatches_T OPENTREP::OPENTREP_Service::listByUNLOCode | ( | const UNLOCode_T & | iUNLOCode, |
LocationList_T & | ioLocationList ) |
List all the POR (points of reference) corresponding to the given UN/LOCODE code.
const | UNLOCode_T& The given UN/LOCODE code (key). |
LocationList_T& | List of (geographical) locations, if any, matching the given key. |
Definition at line 752 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::DBManager::getPORByUNLOCode(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::DBManager::initSQLDBSession(), OPENTREP_LOG_DEBUG, OPENTREP::BasChronometer::start(), and OPENTREP::DBManager::terminateSQLDBSession().
Referenced by main().
NbOfMatches_T OPENTREP::OPENTREP_Service::listByUICCode | ( | const UICCode_T & | iUICCode, |
LocationList_T & | ioLocationList ) |
List all the POR (points of reference) corresponding to the given UIC code.
const | UICCode_T& The given UIC code (key). |
LocationList_T& | List of (geographical) locations, if any, matching the given key. |
Definition at line 802 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::DBManager::getPORByUICCode(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::DBManager::initSQLDBSession(), OPENTREP_LOG_DEBUG, OPENTREP::BasChronometer::start(), and OPENTREP::DBManager::terminateSQLDBSession().
Referenced by main().
NbOfMatches_T OPENTREP::OPENTREP_Service::listByGeonameID | ( | const GeonamesID_T & | iGeonameID, |
LocationList_T & | ioLocationList ) |
List all the POR (points of reference) corresponding to the given Geoname ID.
const | GeonamesID_T& The given Geoname ID (key). |
LocationList_T& | List of (geographical) locations, if any, matching the given key. |
Definition at line 849 of file OPENTREP_Service.cpp.
References OPENTREP::OPENTREP_ServiceContext::display(), OPENTREP::BasChronometer::elapsed(), OPENTREP::DBManager::getPORByGeonameID(), OPENTREP::OPENTREP_ServiceContext::getSQLDBConnectionString(), OPENTREP::OPENTREP_ServiceContext::getSQLDBType(), OPENTREP::DBManager::initSQLDBSession(), OPENTREP_LOG_DEBUG, OPENTREP::BasChronometer::start(), and OPENTREP::DBManager::terminateSQLDBSession().
Referenced by main().