7 #include <boost/make_shared.hpp> 
    9 #include <stdair/stdair_json.hpp> 
   10 #include <stdair/basic/BasChronometer.hpp> 
   11 #include <stdair/basic/JSonCommand.hpp> 
   12 #include <stdair/basic/PartnershipTechnique.hpp> 
   13 #include <stdair/basic/UnconstrainingMethod.hpp> 
   14 #include <stdair/basic/OptimisationMethod.hpp> 
   15 #include <stdair/bom/BomKeyManager.hpp>  
   16 #include <stdair/bom/BomManager.hpp> 
   17 #include <stdair/bom/BomRoot.hpp> 
   18 #include <stdair/bom/Inventory.hpp> 
   19 #include <stdair/bom/FlightDate.hpp> 
   20 #include <stdair/bom/SegmentCabin.hpp> 
   21 #include <stdair/bom/AirlineFeature.hpp> 
   22 #include <stdair/bom/RMEventStruct.hpp> 
   23 #include <stdair/bom/BomJSONImport.hpp> 
   24 #include <stdair/bom/BomJSONExport.hpp> 
   25 #include <stdair/factory/FacBomManager.hpp> 
   26 #include <stdair/service/Logger.hpp> 
   27 #include <stdair/STDAIR_Service.hpp> 
   29 #include <rmol/RMOL_Service.hpp> 
   31 #include <airrac/AIRRAC_Service.hpp> 
   33 #include <sevmgr/SEVMGR_Service.hpp> 
   49   AIRINV_Service::AIRINV_Service () : _airinvServiceContext (NULL) {
 
   54   AIRINV_Service::AIRINV_Service (
const AIRINV_Service& iService)
 
   55   : _airinvServiceContext (NULL) {
 
   60   AIRINV_Service::AIRINV_Service (
const stdair::BasLogParams& iLogParams)
 
   61     : _airinvServiceContext (NULL) {
 
   64     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
 
   65       initStdAirService (iLogParams);
 
   72     const bool ownStdairService = 
true;
 
   73     addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
 
   89   AIRINV_Service::AIRINV_Service (
const stdair::BasLogParams& iLogParams,
 
   90                                   const stdair::BasDBParams& iDBParams)
 
   91     : _airinvServiceContext (NULL) {
 
   94     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
 
   95       initStdAirService (iLogParams, iDBParams);
 
  102     const bool ownStdairService = 
true;
 
  103     addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
 
  120   AIRINV_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr)
 
  122     : _airinvServiceContext (NULL) {
 
  125     initServiceContext();
 
  129     const bool doesNotOwnStdairService = 
false;
 
  130     addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
 
  148   AIRINV_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
 
  149                   SEVMGR::SEVMGR_ServicePtr_T ioSEVMGR_Service_ptr)
 
  151     : _airinvServiceContext (NULL) {
 
  154     initServiceContext();
 
  158     const bool doesNotOwnStdairService = 
false;
 
  159     addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
 
  162     const bool doesNotOwnSEVMGRService = 
false;
 
  163     addSEVMGRService (ioSEVMGR_Service_ptr, doesNotOwnSEVMGRService);
 
  183   void AIRINV_Service::finalise() {
 
  184     assert (_airinvServiceContext != NULL);
 
  186     _airinvServiceContext->reset();
 
  190   void AIRINV_Service::initServiceContext() {
 
  192     AIRINV_ServiceContext& lAIRINV_ServiceContext = 
 
  194     _airinvServiceContext = &lAIRINV_ServiceContext;
 
  198   void AIRINV_Service::
 
  199   addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
 
  200                     const bool iOwnStdairService) {
 
  203     assert (_airinvServiceContext != NULL);
 
  204     AIRINV_ServiceContext& lAIRINV_ServiceContext = *_airinvServiceContext;
 
  207     lAIRINV_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
 
  212   void AIRINV_Service::
 
  213   addSEVMGRService (SEVMGR::SEVMGR_ServicePtr_T ioSEVMGR_Service_ptr,
 
  214                     const bool iOwnSEVMGRService) { 
 
  217     assert (_airinvServiceContext != NULL);
 
  218     AIRINV_ServiceContext& lAIRINV_ServiceContext = *_airinvServiceContext;
 
  221     lAIRINV_ServiceContext.setSEVMGR_Service (ioSEVMGR_Service_ptr, 
 
  226   stdair::STDAIR_ServicePtr_T AIRINV_Service::
 
  227   initStdAirService (
const stdair::BasLogParams& iLogParams,
 
  228                      const stdair::BasDBParams& iDBParams) {
 
  237     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 
 
  238       boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
 
  240     return lSTDAIR_Service_ptr;
 
  244   stdair::STDAIR_ServicePtr_T AIRINV_Service::
 
  245   initStdAirService (
const stdair::BasLogParams& iLogParams) {
 
  254     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr = 
 
  255       boost::make_shared<stdair::STDAIR_Service> (iLogParams);
 
  257     return lSTDAIR_Service_ptr;
 
  261   void AIRINV_Service::initRMOLService() {
 
  264     assert (_airinvServiceContext != NULL);
 
  265     AIRINV_ServiceContext& lAIRINV_ServiceContext = *_airinvServiceContext;
 
  268     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
 
  269       lAIRINV_ServiceContext.getSTDAIR_ServicePtr();
 
  278     RMOL::RMOL_ServicePtr_T lRMOL_Service_ptr = 
 
  279       boost::make_shared<RMOL::RMOL_Service> (lSTDAIR_Service_ptr);
 
  282     lAIRINV_ServiceContext.setRMOL_Service (lRMOL_Service_ptr);
 
  286   void AIRINV_Service::initAIRRACService() {
 
  289     assert (_airinvServiceContext != NULL);
 
  290     AIRINV_ServiceContext& lAIRINV_ServiceContext = *_airinvServiceContext;
 
  293     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
 
  294       lAIRINV_ServiceContext.getSTDAIR_ServicePtr();
 
  303     AIRRAC::AIRRAC_ServicePtr_T lAIRRAC_Service_ptr = 
 
  304       boost::make_shared<AIRRAC::AIRRAC_Service> (lSTDAIR_Service_ptr);
 
  307     lAIRINV_ServiceContext.setAIRRAC_Service (lAIRRAC_Service_ptr);
 
  311   void AIRINV_Service::initSEVMGRService() {
 
  314     assert (_airinvServiceContext != NULL);
 
  315     AIRINV_ServiceContext& lAIRINV_ServiceContext = 
 
  316       *_airinvServiceContext;
 
  319     stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
 
  320       lAIRINV_ServiceContext.getSTDAIR_ServicePtr();
 
  329     SEVMGR::SEVMGR_ServicePtr_T lSEVMGR_Service_ptr = 
 
  330       boost::make_shared<SEVMGR::SEVMGR_Service> (lSTDAIR_Service_ptr);
 
  333     const bool doesOwnSEVMGRService = 
true;
 
  334     lAIRINV_ServiceContext.setSEVMGR_Service (lSEVMGR_Service_ptr,
 
  335                                               doesOwnSEVMGRService);
 
  339   void AIRINV_Service::initAirinvService() {
 
  349     if (_airinvServiceContext == NULL) {
 
  350       throw stdair::NonInitialisedServiceException(
"The AirInv service has not " 
  353     assert (_airinvServiceContext != NULL);
 
  358     const bool doesOwnStdairService =
 
  359       lAIRINV_ServiceContext.getOwnStdairServiceFlag();
 
  362     stdair::STDAIR_Service& lSTDAIR_Service =
 
  363       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  366     stdair::BomRoot& lPersistentBomRoot = 
 
  367       lSTDAIR_Service.getPersistentBomRoot();
 
  378     InventoryBuilder::buildPartnerInventories (lPersistentBomRoot);
 
  383     lSTDAIR_Service.updateAirlineFeatures();  
 
  395     if (doesOwnStdairService == 
true) {
 
  405                 const stdair::ODFilePath& iODInputFilename,
 
  406                 const stdair::FRAT5FilePath& iFRAT5InputFilename,
 
  407                 const stdair::FFDisutilityFilePath& iFFDisutilityInputFilename,
 
  408                 const AIRRAC::YieldFilePath& iYieldFilename) {   
 
  411     if (_airinvServiceContext == NULL) {
 
  412       throw stdair::NonInitialisedServiceException(
"The AirInv service has not " 
  415     assert (_airinvServiceContext != NULL);
 
  420     const bool doesOwnStdairService =
 
  421       lAIRINV_ServiceContext.getOwnStdairServiceFlag();
 
  424     stdair::STDAIR_Service& lSTDAIR_Service =
 
  425       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  428     stdair::BomRoot& lPersistentBomRoot = 
 
  429       lSTDAIR_Service.getPersistentBomRoot();
 
  442     InventoryBuilder::buildPartnerInventories (lPersistentBomRoot); 
 
  447     lSTDAIR_Service.updateAirlineFeatures();
 
  463     AIRRAC::AIRRAC_Service& lAIRRAC_Service =
 
  464       lAIRINV_ServiceContext.getAIRRAC_Service();
 
  465     lAIRRAC_Service.parseAndLoad (iYieldFilename);
 
  473     lAIRRAC_Service.updateYields(lPersistentBomRoot); 
 
  479     if (doesOwnStdairService == 
true) {
 
  490     if (_airinvServiceContext == NULL) {
 
  491       throw stdair::NonInitialisedServiceException(
"The AirInv service has not " 
  494     assert (_airinvServiceContext != NULL);
 
  499     const bool doesOwnStdairService =
 
  500       lAIRINV_ServiceContext.getOwnStdairServiceFlag();
 
  503     stdair::STDAIR_Service& lSTDAIR_Service =
 
  504       lAIRINV_ServiceContext.getSTDAIR_Service(); 
 
  507     stdair::BomRoot& lPersistentBomRoot = 
 
  508       lSTDAIR_Service.getPersistentBomRoot();
 
  514     if (doesOwnStdairService == 
true) {
 
  516       lSTDAIR_Service.buildSampleBom();
 
  529     AIRRAC::AIRRAC_Service& lAIRRAC_Service =
 
  530       lAIRINV_ServiceContext.getAIRRAC_Service();
 
  531     lAIRRAC_Service.buildSampleBom();
 
  538     RMOL::RMOL_Service& lRMOL_Service = 
 
  539       lAIRINV_ServiceContext.getRMOL_Service();
 
  540     lRMOL_Service.buildSampleBom();
 
  545     InventoryBuilder::buildPartnerInventories (lPersistentBomRoot);
 
  556     lSTDAIR_Service.updateAirlineFeatures();
 
  562     if (doesOwnStdairService == 
true) {
 
  573     if (_airinvServiceContext == NULL) {
 
  574       throw stdair::NonInitialisedServiceException(
"The AirInv service has not " 
  577     assert (_airinvServiceContext != NULL);
 
  582     const bool doesOwnStdairService =
 
  583       lAIRINV_ServiceContext.getOwnStdairServiceFlag();
 
  586     stdair::STDAIR_Service& lSTDAIR_Service =
 
  587       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  593     if (doesOwnStdairService == 
true) {
 
  596       lSTDAIR_Service.clonePersistentBom ();
 
  602     stdair::BomRoot& lBomRoot = 
 
  603       lSTDAIR_Service.getBomRoot();
 
  651     stdair::JSonCommand::EN_JSonCommand lEN_JSonCommand;
 
  652     const bool hasCommandBeenRetrieved =
 
  653       stdair::BomJSONImport::jsonImportCommand (iJSONString,
 
  656     if (hasCommandBeenRetrieved == 
false) {
 
  658       std::ostringstream oErrorStream;
 
  659       oErrorStream << 
"{\"error\": \"Wrong JSON-ified string: " 
  660                    << 
"the command is not understood.\"}";
 
  661       return oErrorStream.str();
 
  663     assert (hasCommandBeenRetrieved == 
true);
 
  668     stdair::AirlineCode_T lAirlineCode;
 
  669     const bool hasKeyBeenRetrieved =
 
  670       stdair::BomJSONImport::jsonImportInventoryKey (iJSONString,
 
  673     if (hasKeyBeenRetrieved == 
false) {
 
  675       std::ostringstream oErrorStream;
 
  676       oErrorStream << 
"{\"error\": \"Wrong JSON-ified string: " 
  677                    << 
"the inventory key is not understood.\"}";
 
  678       return oErrorStream.str();
 
  680     assert (hasKeyBeenRetrieved == 
true);
 
  685     stdair::FlightNumber_T lFlightNumber;
 
  686     const bool hasFlightNumBeenRetrieved =
 
  687       stdair::BomJSONImport::jsonImportFlightNumber (iJSONString,
 
  690     if (hasFlightNumBeenRetrieved == 
false) {
 
  692       std::ostringstream oErrorStream;
 
  693       oErrorStream << 
"{\"error\": \"Wrong JSON-ified string: " 
  694                    << 
"the flight number is not understood.\"}";
 
  695       return oErrorStream.str();
 
  697     assert (hasFlightNumBeenRetrieved == 
true);
 
  699     switch (lEN_JSonCommand) {
 
  700     case stdair::JSonCommand::FLIGHT_DATE:{
 
  703       stdair::Date_T lDate;
 
  704       const bool hasDateBeenRetrieved =
 
  705         stdair::BomJSONImport::jsonImportFlightDate (iJSONString,
 
  708       if (hasDateBeenRetrieved == 
false) {
 
  710         std::ostringstream oErrorStream;
 
  711         oErrorStream << 
"{\"error\": \"Wrong JSON-ified string: " 
  712                      << 
"the flight date is not understood.\"}";
 
  713         return oErrorStream.str();
 
  717       STDAIR_LOG_DEBUG (
"=> airline code = '" << lAirlineCode
 
  718                         << 
"', flight number = " << lFlightNumber
 
  719                         << 
"', departure date = '" << lDate << 
"'");
 
  722       const std::string& lFlightDateDetailsCSVDump =
 
  723         csvDisplay (lAirlineCode, lFlightNumber, lDate);
 
  724       STDAIR_LOG_DEBUG (std::endl << lFlightDateDetailsCSVDump);
 
  727       const std::string& lFlightDateDetailsJSONDump =
 
  733       STDAIR_LOG_DEBUG (
"Send: '" << lFlightDateDetailsJSONDump << 
"'");
 
  735       return lFlightDateDetailsJSONDump;
 
  738     case stdair::JSonCommand::LIST:{
 
  741       STDAIR_LOG_DEBUG (
"=> airline code = '" << lAirlineCode
 
  742                         << 
"', flight number = " << lFlightNumber << 
"'");
 
  745       const std::string& lFlightDateListCSVDump =
 
  746         list (lAirlineCode, lFlightNumber);
 
  747       STDAIR_LOG_DEBUG (std::endl << lFlightDateListCSVDump);
 
  750       const std::string& lFlightDateListJSONDump =
 
  754       STDAIR_LOG_DEBUG (
"Send: '" << lFlightDateListCSVDump << 
"'");
 
  756       return lFlightDateListJSONDump;
 
  761       std::ostringstream lErrorCmdMessage;
 
  762       const std::string& lCommandStr =
 
  763         stdair::JSonCommand::getLabel(lEN_JSonCommand);
 
  764       lErrorCmdMessage << 
"{\"error\": \"The command '" << lCommandStr
 
  765                        << 
"' is not handled by the AirInv service.\"}";
 
  766       return lErrorCmdMessage.str();
 
  772     std::string lJSONDump (
"{\"error\": \"Wrong JSON-ified string\"}");
 
  779                             const stdair::FlightNumber_T& iFlightNumber)
 const {
 
  782     if (_airinvServiceContext == NULL) {
 
  783       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
  784                                                     "has not been initialised");
 
  786     assert (_airinvServiceContext != NULL);
 
  791     stdair::STDAIR_Service& lSTDAIR_Service =
 
  792       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  795     return lSTDAIR_Service.jsonExportFlightDateList (iAirlineCode, 
 
  802                                const stdair::FlightNumber_T& iFlightNumber,
 
  803                                const stdair::Date_T& iDepartureDate)
 const {
 
  806     if (_airinvServiceContext == NULL) {
 
  807       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
  808                                                     "has not been initialised");
 
  810     assert (_airinvServiceContext != NULL);
 
  815     stdair::STDAIR_Service& lSTDAIR_Service =
 
  816       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  819     return lSTDAIR_Service.jsonExportFlightDateObjects (iAirlineCode, 
 
  826   list (
const stdair::AirlineCode_T& iAirlineCode,
 
  827         const stdair::FlightNumber_T& iFlightNumber)
 const {
 
  828     std::ostringstream oFlightListStr;
 
  830     if (_airinvServiceContext == NULL) {
 
  831       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
  832                                                     "has not been initialised");
 
  834     assert (_airinvServiceContext != NULL);
 
  841     stdair::STDAIR_Service& lSTDAIR_Service =
 
  842       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  845     return lSTDAIR_Service.list (iAirlineCode, iFlightNumber);
 
  850   check (
const stdair::AirlineCode_T& iAirlineCode,
 
  851          const stdair::FlightNumber_T& iFlightNumber,
 
  852          const stdair::Date_T& iDepartureDate)
 const {
 
  853     std::ostringstream oFlightListStr;
 
  855     if (_airinvServiceContext == NULL) {
 
  856       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
  857                                                     "has not been initialised");
 
  859     assert (_airinvServiceContext != NULL);
 
  866     stdair::STDAIR_Service& lSTDAIR_Service =
 
  867       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  870     return lSTDAIR_Service.check (iAirlineCode, iFlightNumber, iDepartureDate);
 
  877     if (_airinvServiceContext == NULL) {
 
  878       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
  879                                                     "has not been initialised");
 
  881     assert (_airinvServiceContext != NULL);
 
  886     stdair::STDAIR_Service& lSTDAIR_Service =
 
  887       lAIRINV_ServiceContext.getSTDAIR_Service();  
 
  888     const stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
 
  891     return lSTDAIR_Service.csvDisplay(lBomRoot);
 
  897               const stdair::FlightNumber_T& iFlightNumber,
 
  898               const stdair::Date_T& iDepartureDate)
 const {
 
  901     if (_airinvServiceContext == NULL) {
 
  902       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
  903                                                     "has not been initialised");
 
  905     assert (_airinvServiceContext != NULL);
 
  910     stdair::STDAIR_Service& lSTDAIR_Service =
 
  911       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  914     return lSTDAIR_Service.csvDisplay (iAirlineCode, iFlightNumber,
 
  921                 const stdair::Date_T& iEndDate) {
 
  923     if (_airinvServiceContext == NULL) {
 
  924       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
  925                                                     "has not been initialised");
 
  927     assert (_airinvServiceContext != NULL);
 
  931     stdair::STDAIR_Service& lSTDAIR_Service =
 
  932       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  933     stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
 
  935     stdair::RMEventList_T oRMEventList;
 
  936     const stdair::InventoryList_T& lInventoryList =
 
  937       stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
 
  938     for (stdair::InventoryList_T::const_iterator itInv = lInventoryList.begin();
 
  939          itInv != lInventoryList.end(); ++itInv) {
 
  940       const stdair::Inventory* lInv_ptr = *itInv;
 
  941       assert (lInv_ptr != NULL);
 
  944                                       iStartDate, iEndDate); 
 
  954     if (_airinvServiceContext == NULL) {
 
  955       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
  956                                                     "has not been initialised");
 
  958     assert (_airinvServiceContext != NULL);
 
  962     stdair::STDAIR_Service& lSTDAIR_Service =
 
  963       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  964     stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
 
  967     stdair::BasChronometer lAvlChronometer;
 
  968     lAvlChronometer.start();
 
  979                              const stdair::ClassCode_T& iClassCode,
 
  980                              const stdair::PartySize_T& iPartySize) {
 
  981     bool isSellSuccessful = 
false;
 
  983     if (_airinvServiceContext == NULL) {
 
  984       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
  985                                                     "has not been initialised");
 
  987     assert (_airinvServiceContext != NULL);
 
  993     const stdair::InventoryKey& lInventoryKey =
 
  994       stdair::BomKeyManager::extractInventoryKey (iSegmentDateKey);
 
  997     stdair::STDAIR_Service& lSTDAIR_Service =
 
  998       lAIRINV_ServiceContext.getSTDAIR_Service();
 
  999     stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
 
 1002     stdair::Inventory& lInventory = stdair::BomManager::
 
 1003       getObject<stdair::Inventory> (lBomRoot, lInventoryKey.toString());
 
 1006     stdair::BasChronometer lSellChronometer; lSellChronometer.start();
 
 1008                                                iClassCode, iPartySize);
 
 1015     return isSellSuccessful;
 
 1020                              const stdair::PartySize_T& iPartySize) {
 
 1021     bool isSellSuccessful = 
false;
 
 1024     stdair::BasChronometer lSellChronometer; lSellChronometer.start();
 
 1032     return isSellSuccessful;
 
 1037                              const stdair::ClassCode_T& iClassCode,
 
 1038                              const stdair::PartySize_T& iPartySize) {
 
 1039     bool isCancellationSuccessful = 
false;
 
 1041     if (_airinvServiceContext == NULL) {
 
 1042       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
 1043                                                     "has not been initialised");
 
 1045     assert (_airinvServiceContext != NULL);
 
 1051     const stdair::InventoryKey& lInventoryKey =
 
 1052       stdair::BomKeyManager::extractInventoryKey (iSegmentDateKey);
 
 1055     stdair::STDAIR_Service& lSTDAIR_Service =
 
 1056       lAIRINV_ServiceContext.getSTDAIR_Service();
 
 1057     stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
 
 1060     stdair::Inventory& lInventory = stdair::BomManager::
 
 1061       getObject<stdair::Inventory> (lBomRoot, lInventoryKey.toString());
 
 1064     stdair::BasChronometer lCancellationChronometer;
 
 1065     lCancellationChronometer.start();
 
 1068                                                          iClassCode,iPartySize);
 
 1076     return isCancellationSuccessful;
 
 1081                              const stdair::PartySize_T& iPartySize) {
 
 1082     bool isCancelSuccessful = 
false;
 
 1085     stdair::BasChronometer lCancelChronometer; lCancelChronometer.start();
 
 1093     return isCancelSuccessful;
 
 1098                                       const stdair::DateTime_T& iSnapshotTime) {
 
 1100     if (_airinvServiceContext == NULL) {
 
 1101       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
 1102                                                     "has not been initialised");
 
 1104     assert (_airinvServiceContext != NULL);
 
 1108     stdair::STDAIR_Service& lSTDAIR_Service =
 
 1109       lAIRINV_ServiceContext.getSTDAIR_Service();
 
 1110     stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
 
 1112     const stdair::InventoryList_T lInventoryList =
 
 1113       stdair::BomManager::getList<stdair::Inventory> (lBomRoot);
 
 1114     for (stdair::InventoryList_T::const_iterator itInv = lInventoryList.begin();
 
 1115          itInv != lInventoryList.end(); ++itInv) {
 
 1116       const stdair::Inventory* lInv_ptr = *itInv;
 
 1117       assert (lInv_ptr != NULL);
 
 1125                                  const stdair::KeyDescription_T& iFDDescription,
 
 1126                                  const stdair::DateTime_T& iRMEventTime) {
 
 1128     if (_airinvServiceContext == NULL) {
 
 1129       throw stdair::NonInitialisedServiceException (
"The AirInv service " 
 1130                                                     "has not been initialised");
 
 1132     assert (_airinvServiceContext != NULL);
 
 1136     stdair::STDAIR_Service& lSTDAIR_Service =
 
 1137       lAIRINV_ServiceContext.getSTDAIR_Service();
 
 1138     stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
 
 1139     stdair::Inventory* lInventory_ptr =
 
 1140       stdair::BomManager::getObjectPtr<stdair::Inventory> (lBomRoot, iAirlineCode);
 
 1141     if (lInventory_ptr == NULL) {
 
 1142       std::ostringstream oErrorMessage;
 
 1143       oErrorMessage << 
"The Inventory '" << iAirlineCode
 
 1144                     << 
"', can not be retrieved.";
 
 1145       STDAIR_LOG_ERROR (oErrorMessage.str());
 
 1148     assert (lInventory_ptr != NULL);
 
 1149     stdair::FlightDate* lFlightDate_ptr =
 
 1150       stdair::BomManager::getObjectPtr<stdair::FlightDate> (*lInventory_ptr,
 
 1152     if (lFlightDate_ptr == NULL) {
 
 1153       std::ostringstream oErrorMessage;
 
 1154       oErrorMessage << 
"The flight date '" << iFDDescription
 
 1155                     << 
"', can not be retrieved in the '" 
 1156                     << iAirlineCode << 
"' inventory.";
 
 1157       STDAIR_LOG_ERROR (oErrorMessage.str());
 
 1160     assert (lFlightDate_ptr != NULL);
 
 1162     const stdair::UnconstrainingMethod& lUnconstrainingMethod =
 
 1163       lInventory_ptr->getUnconstrainingMethod();   
 
 1164     const stdair::ForecastingMethod& lForecastingMethod =
 
 1165       lInventory_ptr->getForecastingMethod(); 
 
 1166     const stdair::PreOptimisationMethod& lPreOptimisationMethod =
 
 1167       lInventory_ptr->getPreOptimisationMethod();
 
 1168     const stdair::OptimisationMethod& lOptimisationMethod =
 
 1169       lInventory_ptr->getOptimisationMethod();
 
 1170     const stdair::PartnershipTechnique& lPartnershipTechnique =
 
 1171       lInventory_ptr->getPartnershipTechnique();
 
 1174     RMOL::RMOL_Service& lRMOL_Service = lAIRINV_ServiceContext.getRMOL_Service();
 
 1177     bool isOptimised = lRMOL_Service.optimise (*lFlightDate_ptr, iRMEventTime,
 
 1178                                                lUnconstrainingMethod,
 
 1180                                                lPreOptimisationMethod,
 
 1181                                                lOptimisationMethod,
 
 1182                                                lPartnershipTechnique);
 
 1184     const stdair::OptimisationMethod::EN_OptimisationMethod& lENOptimisationMethod = lOptimisationMethod.getMethod();
 
 1185     const bool isEMSRb = 
 
 1186       (lENOptimisationMethod == stdair::OptimisationMethod::LEG_BASED_EMSR_B);
 
 1192     if (isOptimised == 
true && isEMSRb == 
false) {
 
 1193       InventoryManager::updateBookingControls (*lFlightDate_ptr);
 
 1194       InventoryManager::recalculateAvailability (*lFlightDate_ptr);