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 45 STDAIR_Service::STDAIR_Service() : _stdairServiceContext (NULL) {
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);
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);
void updateAirlineFeatures(BomRoot &)
BasLogParams getLogParams() const
const std::string describe() const
Interface for the STDAIR Services.
STDAIR_ServiceContext & create()
LocationCode_T AirportCode_T
static void importINIConfig(ConfigHolderStruct &, const ConfigINIFile &)
void importConfigValue(const std::string &iValue, const std::string &iPath)
bool jsonImportConfiguration(const JSONString &) const
Structure holding the parameters for connection to a database.
Class holding the context of the Stdair services.
BomRoot & getPersistentBomRoot() const
Get a reference on the BomRoot object.
const std::string jsonExport() const
static FlightDate * retrieveFlightDateFromKeySet(const BomRoot &, const AirlineCode_T &, const FlightNumber_T &, const Date_T &iFlightDateDate)
std::string AirlineCode_T
BomRoot & getBomRoot() const
Get a reference on the BomRoot object.
void importINIConfig(const ConfigINIFile &)
Import the configuration INI input file (format cfg).
Structure holding parameters for logging.
boost::gregorian::date Date_T
Enumeration of service initialisation types.
std::list< TravelSolutionStruct > TravelSolutionList_T
std::string jsonExportFlightDateObjects(const AirlineCode_T &, const FlightNumber_T &, const Date_T &iDepartureDate) const
std::string csvDisplay() const
std::string listAirportPairDateRange() const
static bool jsonImportConfig(const JSONString &, ConfigHolderStruct &)
static void jsonExportFlightDateObjects(std::ostream &, const FlightDate &)
bool check(const AirlineCode_T &, const FlightNumber_T &, const Date_T &iDepartureDate) const
void buildSampleTravelSolutionForPricing(TravelSolutionList_T &)
std::string jsonExportConfiguration() const
BookingRequestStruct buildSampleBookingRequest(const bool isForCRS=false)
void cleanCloneBomLayer()
Class representing the actual attributes for an airline flight-date.
static FacSupervisor & instance()
const EventType::EN_EventType & getEventType() const
void buildDummyInventory(const CabinCapacity_T &iCabinCapacity)
const ServiceInitialisationType & getServiceInitialisationType() const
std::string jsonExportEventObject(const EventStruct &) const
unsigned short FlightNumber_T
std::string jsonExportFlightDateList(const AirlineCode_T &iAirlineCode="all", const FlightNumber_T &iFlightNumber=0) const
std::string configDisplay() const
static void list(std::ostream &, const BomRoot &, const AirlineCode_T &iAirlineCode="all", const FlightNumber_T &iFlightNumber=0)
static void jsonExportFlightDateList(std::ostream &, const BomRoot &, const AirlineCode_T &iAirlineCode="all", const FlightNumber_T &iFlightNumber=0)
void buildDummyLegSegmentAccesses(BomRoot &)
std::list< DatePeriod * > DatePeriodList_T
Class representing the actual attributes for the Bom root.
Handle on the StdAir library context.
STDAIR_Service()
Default constructor.
static void jsonExportBookingRequestObject(std::ostream &, const EventStruct &)
static void retrieveDatePeriodListFromKeySet(const BomRoot &, const stdair::AirportCode_T &, const stdair::AirportCode_T &, const stdair::Date_T &, stdair::DatePeriodList_T &)
std::string list(const AirlineCode_T &iAirlineCode="all", const FlightNumber_T &iFlightNumber=0) const
static void jsonExportBreakPointObject(std::ostream &, const EventStruct &)
static void csvDisplay(std::ostream &, const BomRoot &)
~STDAIR_Service()
Destructor.
Structure holding the elements of a booking request.
static void listAirportPairDateRange(std::ostream &, const BomRoot &)
void updateAirlineFeatures()
Update the airline features objects thanks to the configuration holder.
static FacSTDAIRServiceContext & instance()
void clonePersistentBom()
Clone the persistent Bom.
void buildSampleTravelSolutions(TravelSolutionList_T &)
const BasDBParams & getDBParams() const
bool addValue(const std::string &iValue, const std::string &iPath)