7 #if BOOST_VERSION >= 104100
9 #include <boost/property_tree/ptree.hpp>
10 #include <boost/property_tree/json_parser.hpp>
11 #endif // BOOST_VERSION >= 104100
34 #if BOOST_VERSION >= 104100
35 namespace bpt = boost::property_tree;
36 #else // BOOST_VERSION >= 104100
40 #endif // BOOST_VERSION >= 104100
56 : _stdairServiceContext (NULL) {
62 : _stdairServiceContext (NULL) {
77 : _stdairServiceContext (NULL) {
99 void STDAIR_Service::initServiceContext() {
105 _stdairServiceContext = &lSTDAIR_ServiceContext;
109 void STDAIR_Service::logInit (
const BasLogParams& iLogParams) {
110 Logger::init (iLogParams);
114 void STDAIR_Service::dbInit (
const BasDBParams& iDBParams) {
115 DBSessionManager::init (iDBParams);
118 assert (_stdairServiceContext != NULL);
119 STDAIR_ServiceContext& lSTDAIR_ServiceContext = *_stdairServiceContext;
120 lSTDAIR_ServiceContext.setDBParams (iDBParams);
124 void STDAIR_Service::init() {
130 assert (_stdairServiceContext != NULL);
132 *_stdairServiceContext;
134 return lSTDAIR_ServiceContext.getCloneBomRoot();
140 assert (_stdairServiceContext != NULL);
142 *_stdairServiceContext;
144 return lSTDAIR_ServiceContext.getPersistentBomRoot();
149 return Logger::getLogParams();
155 assert (_stdairServiceContext != NULL);
157 *_stdairServiceContext;
158 return lSTDAIR_ServiceContext.getDBParams();
165 assert (_stdairServiceContext != NULL);
167 *_stdairServiceContext;
168 return lSTDAIR_ServiceContext.getServiceInitialisationType();
174 assert (_stdairServiceContext != NULL);
176 *_stdairServiceContext;
179 BomRoot& lPersistentBomRoot = lSTDAIR_ServiceContext.getPersistentBomRoot();
182 CmdBomManager::buildSampleBom (lPersistentBomRoot);
189 assert (_stdairServiceContext != NULL);
191 *_stdairServiceContext;
194 BomRoot& lPersistentBomRoot = lSTDAIR_ServiceContext.getPersistentBomRoot();
197 CmdBomManager::buildDummyInventory (lPersistentBomRoot, iCabinCapacity);
198 CmdBomManager::buildCompleteDummyInventoryForFareFamilies (lPersistentBomRoot);
206 assert (_stdairServiceContext != NULL);
209 CmdBomManager::buildDummyLegSegmentAccesses (iBomRoot);
217 CmdBomManager::buildSampleTravelSolutionForPricing (ioTravelSolutionList);
224 CmdBomManager::buildSampleTravelSolutions (ioTravelSolutionList);
232 if (isForCRS ==
true) {
233 return CmdBomManager::buildSampleBookingRequestForCRS();
236 return CmdBomManager::buildSampleBookingRequest();
244 std::ostringstream oStr;
247 assert (_stdairServiceContext != NULL);
249 *_stdairServiceContext;
252 const BomRoot& lCloneBomRoot = lSTDAIR_ServiceContext.getCloneBomRoot();
255 iAirlineCode, iFlightNumber);
265 std::ostringstream oStr;
268 assert (_stdairServiceContext != NULL);
270 *_stdairServiceContext;
273 const BomRoot& lCloneBomRoot = lSTDAIR_ServiceContext.getCloneBomRoot();
282 if (lFlightDate_ptr != NULL) {
286 #if BOOST_VERSION >= 104100
292 std::ostringstream oNoFlightDateStream;
293 oNoFlightDateStream <<
"No flight-date found for the given key: '"
294 << iAirlineCode << iFlightNumber
295 <<
" - " << iDepartureDate <<
"'";
296 const std::string oNoFlightDateString (oNoFlightDateStream.str());
300 lPropertyTree.put (
"error", oNoFlightDateString.c_str());
303 write_json (oStr, lPropertyTree);
304 #endif // BOOST_VERSION >= 104100
314 std::ostringstream oStr;
319 switch (lEventType) {
345 assert (_stdairServiceContext != NULL);
347 *_stdairServiceContext;
351 lSTDAIR_ServiceContext.getConfigHolder();
362 assert (_stdairServiceContext != NULL);
364 *_stdairServiceContext;
368 lSTDAIR_ServiceContext.getConfigHolder();
378 assert (_stdairServiceContext != NULL);
380 *_stdairServiceContext;
384 lSTDAIR_ServiceContext.getConfigHolder();
392 const std::string& iPath) {
395 assert (_stdairServiceContext != NULL);
397 *_stdairServiceContext;
401 lSTDAIR_ServiceContext.getConfigHolder();
404 lConfigHolder.
addValue (iValue, iPath);
411 assert (_stdairServiceContext != NULL);
413 *_stdairServiceContext;
417 lSTDAIR_ServiceContext.getConfigHolder();
421 lSTDAIR_ServiceContext.getPersistentBomRoot();
430 std::ostringstream oStr;
433 assert (_stdairServiceContext != NULL);
437 const BomRoot& lCloneBomRoot = lSTDAIR_ServiceContext.getCloneBomRoot();
447 std::ostringstream oStr;
450 assert (_stdairServiceContext != NULL);
454 const BomRoot& lCloneBomRoot = lSTDAIR_ServiceContext.getCloneBomRoot();
466 std::ostringstream oStr;
469 assert (_stdairServiceContext != NULL);
473 const BomRoot& lCloneBomRoot = lSTDAIR_ServiceContext.getCloneBomRoot();
481 return (lFlightDate_ptr != NULL);
488 std::ostringstream oStr;
491 assert (_stdairServiceContext != NULL);
495 const BomRoot& lCloneBomRoot = lSTDAIR_ServiceContext.getCloneBomRoot();
504 return (lDatePeriodList.size() != 0);
511 assert (_stdairServiceContext != NULL);
513 *_stdairServiceContext;
517 lSTDAIR_ServiceContext.getConfigHolder();
528 assert (_stdairServiceContext != NULL);
530 *_stdairServiceContext;
533 const BomRoot& lPersistentBomRoot =
534 lSTDAIR_ServiceContext.getPersistentBomRoot();
542 std::ostringstream oStr;
545 assert (_stdairServiceContext != NULL);
558 std::ostringstream oStr;
561 assert (_stdairServiceContext != NULL);
565 const BomRoot& lCloneBomRoot = lSTDAIR_ServiceContext.getCloneBomRoot();
574 if (lFlightDate_ptr != NULL) {
578 oStr <<
" No flight-date found for the given key: '"
579 << iAirlineCode << iFlightNumber <<
" - " << iDepartureDate <<
"'";
590 std::ostringstream oStr;
601 std::ostringstream oStr;
604 assert (_stdairServiceContext != NULL);
608 const BomRoot& lCloneBomRoot = lSTDAIR_ServiceContext.getCloneBomRoot();
618 if (lDatePeriodList.empty()) {
619 oStr <<
" No fare-rule found for the given key: '"
620 << iOrigin <<
"-" << iDestination <<
" - " << iDepartureDate <<
"'";
629 void STDAIR_Service::finalise() {
638 assert (_stdairServiceContext != NULL);
645 lSTDAIR_ServiceContext.initCloneBomRoot();
648 const BomRoot& lPersistentBomRoot =
649 lSTDAIR_ServiceContext.getPersistentBomRoot();
650 BomRoot& lCloneBomRoot = lSTDAIR_ServiceContext.getCloneBomRoot();
653 CmdCloneBomManager::cloneBomRoot (lPersistentBomRoot, lCloneBomRoot);
bool check(const AirlineCode_T &, const FlightNumber_T &, const Date_T &iDepartureDate) const
void cleanCloneBomLayer()
LocationCode_T AirportCode_T
void importINIConfig(const ConfigINIFile &)
Import the configuration INI input file (format cfg).
const BasDBParams & getDBParams() const
static void jsonExportBreakPointObject(std::ostream &, const EventStruct &)
unsigned short FlightNumber_T
Structure holding the parameters for connection to a database.
Handle on the StdAir library context.
bool addValue(const std::string &iValue, const std::string &iPath)
STDAIR_Service()
Default constructor.
std::list< DatePeriod * > DatePeriodList_T
void buildSampleTravelSolutions(TravelSolutionList_T &)
void updateAirlineFeatures()
Update the airline features objects thanks to the configuration holder.
const EventType::EN_EventType & getEventType() const
STDAIR_ServiceContext & create()
void buildSampleTravelSolutionForPricing(TravelSolutionList_T &)
std::string AirlineCode_T
std::string jsonExportFlightDateObjects(const AirlineCode_T &, const FlightNumber_T &, const Date_T &iDepartureDate) const
Enumeration of service initialisation types.
BomRoot & getBomRoot() const
Get a reference on the BomRoot object.
std::string jsonExportConfiguration() const
BomRoot & getPersistentBomRoot() const
Get a reference on the BomRoot object.
std::string jsonExportFlightDateList(const AirlineCode_T &iAirlineCode="all", const FlightNumber_T &iFlightNumber=0) const
static void jsonExportFlightDateList(std::ostream &, const BomRoot &, const AirlineCode_T &iAirlineCode="all", const FlightNumber_T &iFlightNumber=0)
Structure holding parameters for logging.
std::string jsonExportEventObject(const EventStruct &) const
static FacSupervisor & instance()
void buildDummyLegSegmentAccesses(BomRoot &)
BasLogParams getLogParams() const
static void listAirportPairDateRange(std::ostream &, const BomRoot &)
static void jsonExportBookingRequestObject(std::ostream &, const EventStruct &)
std::list< TravelSolutionStruct > TravelSolutionList_T
static void list(std::ostream &, const BomRoot &, const AirlineCode_T &iAirlineCode="all", const FlightNumber_T &iFlightNumber=0)
static FlightDate * retrieveFlightDateFromKeySet(const BomRoot &, const AirlineCode_T &, const FlightNumber_T &, const Date_T &iFlightDateDate)
static void jsonExportFlightDateObjects(std::ostream &, const FlightDate &)
const std::string describe() const
Class holding the context of the Stdair services.
void updateAirlineFeatures(BomRoot &)
static FacSTDAIRServiceContext & instance()
std::string configDisplay() const
static void importINIConfig(ConfigHolderStruct &, const ConfigINIFile &)
std::string csvDisplay() const
void clonePersistentBom()
Clone the persistent Bom.
static void retrieveDatePeriodListFromKeySet(const BomRoot &, const stdair::AirportCode_T &, const stdair::AirportCode_T &, const stdair::Date_T &, stdair::DatePeriodList_T &)
boost::gregorian::date Date_T
static bool jsonImportConfig(const JSONString &, ConfigHolderStruct &)
std::string list(const AirlineCode_T &iAirlineCode="all", const FlightNumber_T &iFlightNumber=0) const
void buildDummyInventory(const CabinCapacity_T &iCabinCapacity)
Class representing the actual attributes for the Bom root.
static void csvDisplay(std::ostream &, const BomRoot &)
std::string listAirportPairDateRange() const
const ServiceInitialisationType & getServiceInitialisationType() const
const std::string jsonExport() const
Class representing the actual attributes for an airline flight-date.
Structure holding the elements of a booking request.
BookingRequestStruct buildSampleBookingRequest(const bool isForCRS=false)
bool jsonImportConfiguration(const JSONString &) const
Interface for the STDAIR Services.
~STDAIR_Service()
Destructor.
void importConfigValue(const std::string &iValue, const std::string &iPath)