$treeview $search $mathjax
StdAir Logo  1.00.2
$projectbrief
$projectbrief
$searchbox

stdair/bom/BomRetriever.cpp

Go to the documentation of this file.
00001 // //////////////////////////////////////////////////////////////////////
00002 // Import section
00003 // //////////////////////////////////////////////////////////////////////
00004 // STL
00005 #include <cassert>
00006 #include <sstream>
00007 // StdAir
00008 #include <stdair/basic/BasConst_Inventory.hpp>
00009 #include <stdair/basic/BasConst_BomDisplay.hpp>
00010 #include <stdair/bom/BomKeyManager.hpp>
00011 #include <stdair/bom/BomManager.hpp>
00012 #include <stdair/bom/BomRoot.hpp>
00013 #include <stdair/bom/Inventory.hpp>
00014 #include <stdair/bom/AirlineFeature.hpp>
00015 #include <stdair/bom/FlightDate.hpp>
00016 #include <stdair/bom/LegDate.hpp>
00017 #include <stdair/bom/SegmentDate.hpp>
00018 #include <stdair/bom/LegCabin.hpp>
00019 #include <stdair/bom/SegmentCabin.hpp>
00020 #include <stdair/bom/FareFamily.hpp>
00021 #include <stdair/bom/BookingClass.hpp>
00022 #include <stdair/bom/BomRetriever.hpp>
00023 #include <stdair/bom/ParsedKey.hpp>
00024 #include <stdair/bom/AirportPair.hpp>
00025 #include <stdair/service/Logger.hpp>
00026 
00027 namespace stdair {
00028 
00029   // ////////////////////////////////////////////////////////////////////
00030   Inventory* BomRetriever::
00031   retrieveInventoryFromLongKey (const BomRoot& iBomRoot,
00032                                 const std::string& iFullKeyStr) {
00033     Inventory* oInventory_ptr = NULL;
00034 
00035     // Extract the inventory key (i.e., airline code)
00036     const InventoryKey& lInventoryKey =
00037       BomKeyManager::extractInventoryKey (iFullKeyStr);
00038 
00039     oInventory_ptr = iBomRoot.getInventory (lInventoryKey);
00040 
00041     return oInventory_ptr;
00042   }
00043 
00044   // ////////////////////////////////////////////////////////////////////
00045   Inventory* BomRetriever::
00046   retrieveInventoryFromLongKey (const Inventory& iInventory,
00047                                 const std::string& iFullKeyStr) {
00048     Inventory* oInventory_ptr = NULL;
00049     
00050     // Extract the inventory key (i.e., airline code)
00051     const InventoryKey& lInventoryKey =
00052       BomKeyManager::extractInventoryKey (iFullKeyStr);
00053     const stdair::AirlineCode_T lAirlineCode = 
00054       lInventoryKey.getAirlineCode();
00055 
00056     oInventory_ptr =
00057       BomManager::getObjectPtr<Inventory> (iInventory,
00058                                            lAirlineCode);
00059     return oInventory_ptr;
00060   }
00061 
00062   // ////////////////////////////////////////////////////////////////////
00063   Inventory* BomRetriever::retrieveInventoryFromKey (const BomRoot& iBomRoot,
00064                                                      const InventoryKey& iKey) {
00065     Inventory* oInventory_ptr = NULL;
00066 
00067     //
00068     oInventory_ptr = iBomRoot.getInventory (iKey);
00069 
00070     return oInventory_ptr;
00071   }
00072 
00073   // ////////////////////////////////////////////////////////////////////
00074   Inventory* BomRetriever::
00075   retrieveInventoryFromKey (const BomRoot& iBomRoot,
00076                             const AirlineCode_T& iAirlineCode) {
00077     Inventory* oInventory_ptr = NULL;
00078 
00079     //
00080     const InventoryKey lKey (iAirlineCode);
00081     oInventory_ptr = iBomRoot.getInventory (lKey);
00082 
00083     return oInventory_ptr;
00084   } 
00085 
00086   // ////////////////////////////////////////////////////////////////////
00087   AirlineFeature* BomRetriever::
00088   retrieveAirlineFeatureFromKey (const BomRoot& iBomRoot,
00089                                  const AirlineCode_T& iAirlineCode) {
00090     Inventory* oInventory_ptr = NULL;
00091     AirlineFeature* oAirlineFeature_ptr = NULL;
00092 
00093     //
00094     oInventory_ptr = retrieveInventoryFromKey (iBomRoot, iAirlineCode);
00095     if (oInventory_ptr == NULL) {
00096       return oAirlineFeature_ptr;
00097     }
00098     assert (oInventory_ptr != NULL);
00099 
00100     oAirlineFeature_ptr = 
00101       BomManager::getObjectPtr<AirlineFeature,Inventory> (*oInventory_ptr,
00102                                                           iAirlineCode);
00103 
00104     return oAirlineFeature_ptr;
00105   }
00106 
00107   // ////////////////////////////////////////////////////////////////////
00108   FlightDate* BomRetriever::
00109   retrieveFlightDateFromLongKey (const BomRoot& iBomRoot,
00110                                  const std::string& iFullKeyStr) {
00111     FlightDate* oFlightDate_ptr = NULL;
00112 
00113     // Retrieve the inventory
00114     Inventory* oInventory_ptr =
00115       BomRetriever::retrieveInventoryFromLongKey (iBomRoot, iFullKeyStr);
00116     if (oInventory_ptr == NULL) {
00117       return oFlightDate_ptr;
00118     }
00119     assert (oInventory_ptr != NULL);
00120 
00121     // Extract the flight-date key (i.e., flight number and date)
00122     const FlightDateKey& lFlightDateKey =
00123       BomKeyManager::extractFlightDateKey (iFullKeyStr);
00124 
00125     oFlightDate_ptr = oInventory_ptr->getFlightDate (lFlightDateKey);
00126 
00127     return oFlightDate_ptr;
00128   }
00129 
00130   // ////////////////////////////////////////////////////////////////////
00131   FlightDate* BomRetriever::
00132   retrieveFlightDateFromKeySet (const BomRoot& iBomRoot,
00133                                 const AirlineCode_T& iAirlineCode,
00134                                 const FlightNumber_T& iFlightNumber,
00135                                 const Date_T& iFlightDateDate) {
00136     FlightDate* oFlightDate_ptr = NULL;
00137 
00138     // Retrieve the inventory
00139     Inventory* oInventory_ptr =
00140       BomRetriever::retrieveInventoryFromKey (iBomRoot, iAirlineCode);
00141     if (oInventory_ptr == NULL) {
00142       return oFlightDate_ptr;
00143     }
00144     assert (oInventory_ptr != NULL);
00145 
00146     //
00147     oFlightDate_ptr = retrieveFlightDateFromKey (*oInventory_ptr,
00148                                                  iFlightNumber, iFlightDateDate);
00149 
00150     return oFlightDate_ptr;
00151   }
00152 
00153   // ////////////////////////////////////////////////////////////////////
00154   FlightDate* BomRetriever::
00155   retrieveFlightDateFromLongKey (const Inventory& iInventory,
00156                                  const std::string& iFullKeyStr) {
00157     FlightDate* oFlightDate_ptr = NULL;
00158 
00159     // Extract the flight-date key (i.e., flight number and date)
00160     const FlightDateKey& lFlightDateKey =
00161       BomKeyManager::extractFlightDateKey (iFullKeyStr);
00162 
00163     oFlightDate_ptr = iInventory.getFlightDate (lFlightDateKey);
00164 
00165     return oFlightDate_ptr;
00166   }
00167 
00168   // ////////////////////////////////////////////////////////////////////
00169   FlightDate* BomRetriever::
00170   retrieveFlightDateFromKey (const Inventory& iInventory,
00171                              const FlightDateKey& iKey) {
00172     FlightDate* oFlightDate_ptr = NULL;
00173 
00174     //
00175     oFlightDate_ptr = iInventory.getFlightDate (iKey);
00176 
00177     return oFlightDate_ptr;
00178   }
00179 
00180   // ////////////////////////////////////////////////////////////////////
00181   FlightDate* BomRetriever::
00182   retrieveFlightDateFromKey (const Inventory& iInventory,
00183                              const FlightNumber_T& iFlightNumber,
00184                              const Date_T& iFlightDateDate) {
00185     FlightDate* oFlightDate_ptr = NULL;
00186 
00187     //
00188     const FlightDateKey lKey (iFlightNumber, iFlightDateDate);
00189     oFlightDate_ptr = iInventory.getFlightDate (lKey);
00190 
00191     return oFlightDate_ptr;
00192   }
00193 
00194   // ////////////////////////////////////////////////////////////////////
00195   SegmentDate* BomRetriever::
00196   retrieveSegmentDateFromLongKey (const BomRoot& iBomRoot,
00197                                   const std::string& iFullKeyStr) {
00198     SegmentDate* oSegmentDate_ptr = NULL;
00199 
00200     // Retrieve the flight-date
00201     FlightDate* oFlightDate_ptr =
00202       BomRetriever::retrieveFlightDateFromLongKey (iBomRoot, iFullKeyStr);
00203     if (oFlightDate_ptr == NULL) {
00204       return oSegmentDate_ptr;
00205     }
00206     assert (oFlightDate_ptr != NULL);
00207 
00208     // Extract the segment-date key (i.e., origin and destination)
00209     const SegmentDateKey& lSegmentDateKey =
00210       BomKeyManager::extractSegmentDateKey (iFullKeyStr);
00211 
00212     oSegmentDate_ptr = oFlightDate_ptr->getSegmentDate (lSegmentDateKey);
00213 
00214     return oSegmentDate_ptr;
00215   }
00216 
00217   // ////////////////////////////////////////////////////////////////////
00218   SegmentDate* BomRetriever::
00219   retrieveSegmentDateFromLongKey (const Inventory& iInventory,
00220                                   const std::string& iFullKeyStr) {
00221     SegmentDate* oSegmentDate_ptr = NULL;
00222 
00223     ParsedKey lParsedKey = BomKeyManager::extractKeys (iFullKeyStr);
00224 
00225     if (iInventory.getAirlineCode() != lParsedKey._airlineCode) {
00226       STDAIR_LOG_DEBUG ("Airline code: " << lParsedKey._airlineCode);
00227       return oSegmentDate_ptr;
00228     }
00229 
00230     FlightDate* lFlightDate_ptr =
00231       retrieveFlightDateFromKey (iInventory, lParsedKey.getFlightDateKey());
00232     if (lFlightDate_ptr == NULL) {
00233       STDAIR_LOG_DEBUG ("Flight-date key: "
00234                         << lParsedKey.getFlightDateKey().toString());
00235       return oSegmentDate_ptr;
00236     }
00237 
00238     oSegmentDate_ptr =
00239       retrieveSegmentDateFromKey (*lFlightDate_ptr, lParsedKey.getSegmentKey());
00240     if (oSegmentDate_ptr == NULL) {
00241       STDAIR_LOG_DEBUG ("Segment-date key: "
00242                         << lParsedKey.getSegmentKey().toString());
00243       return oSegmentDate_ptr;
00244     }
00245     
00246     return oSegmentDate_ptr;
00247   }
00248 
00249   // ////////////////////////////////////////////////////////////////////
00250   SegmentDate* BomRetriever::
00251   retrieveSegmentDateFromLongKey (const FlightDate& iFlightDate,
00252                                   const std::string& iFullKeyStr) {
00253     SegmentDate* oSegmentDate_ptr = NULL;
00254 
00255     // Extract the segment-date key (i.e., origin and destination)
00256     const SegmentDateKey& lSegmentDateKey =
00257       BomKeyManager::extractSegmentDateKey (iFullKeyStr);
00258 
00259     oSegmentDate_ptr = iFlightDate.getSegmentDate (lSegmentDateKey);
00260 
00261     return oSegmentDate_ptr;
00262   } 
00263 
00264   // ////////////////////////////////////////////////////////////////////
00265   LegDate* BomRetriever::
00266   retrieveOperatingLegDateFromLongKey (const FlightDate& iFlightDate,
00267                                        const std::string& iFullKeyStr) {
00268     LegDate* oLegDate_ptr = NULL;
00269 
00270     // Extract the segment-date key (i.e., origin and destination)
00271     const LegDateKey& lLegDateKey =
00272       BomKeyManager::extractLegDateKey (iFullKeyStr);
00273 
00274     oLegDate_ptr = iFlightDate.getLegDate (lLegDateKey);
00275 
00276     return oLegDate_ptr;
00277   }
00278 
00279   // ////////////////////////////////////////////////////////////////////
00280   SegmentDate* BomRetriever::
00281   retrievePartnerSegmentDateFromLongKey (const Inventory& iInventory,
00282                                          const std::string& iFullKeyStr) {
00283     SegmentDate* oSegmentDate_ptr = NULL;
00284     Inventory* oInventory_ptr = NULL;
00285 
00286     // Extract the inventory key (i.e., airline code)
00287     const InventoryKey& lInventoryKey =
00288       BomKeyManager::extractInventoryKey (iFullKeyStr);
00289     const stdair::AirlineCode_T lAirlineCode = 
00290       lInventoryKey.getAirlineCode();
00291 
00292     // Retrieve the inventory
00293     oInventory_ptr =
00294       retrieveInventoryFromLongKey (iInventory, lAirlineCode);
00295 
00296     if (oInventory_ptr != NULL) { 
00297       oSegmentDate_ptr =
00298         retrieveSegmentDateFromLongKey (*oInventory_ptr, iFullKeyStr);
00299     }
00300 
00301     return oSegmentDate_ptr;
00302 
00303   }
00304 
00305   // ////////////////////////////////////////////////////////////////////
00306   SegmentDate* BomRetriever::
00307   retrieveSegmentDateFromKey (const FlightDate& iFlightDate,
00308                               const SegmentDateKey& iKey) {
00309     SegmentDate* oSegmentDate_ptr = NULL;
00310 
00311     //
00312     oSegmentDate_ptr = iFlightDate.getSegmentDate (iKey);
00313 
00314     return oSegmentDate_ptr;
00315   }
00316 
00317   // ////////////////////////////////////////////////////////////////////
00318   SegmentDate* BomRetriever::
00319   retrieveSegmentDateFromKey (const FlightDate& iFlightDate,
00320                               const AirportCode_T& iOrigin,
00321                               const AirportCode_T& iDestination) {
00322     SegmentDate* oSegmentDate_ptr = NULL;
00323 
00324     //
00325     const SegmentDateKey lKey (iOrigin, iDestination);
00326     oSegmentDate_ptr = iFlightDate.getSegmentDate (lKey);
00327 
00328     return oSegmentDate_ptr;
00329   }
00330 
00331   // ////////////////////////////////////////////////////////////////////
00332   BookingClass* BomRetriever::
00333   retrieveBookingClassFromLongKey (const Inventory& iInventory,
00334                                    const std::string& iFullKeyStr,
00335                                    const ClassCode_T& iClassCode) {
00336     BookingClass* oBookingClass_ptr = NULL;
00337 
00338     SegmentDate* lSegmentDate_ptr = retrieveSegmentDateFromLongKey (iInventory,
00339                                                                     iFullKeyStr);
00340 
00341     if (lSegmentDate_ptr == NULL) {
00342       return oBookingClass_ptr;
00343     }
00344     assert (lSegmentDate_ptr != NULL);
00345 
00346     // 
00347     oBookingClass_ptr =
00348       BomManager::getObjectPtr<BookingClass> (*lSegmentDate_ptr, iClassCode);
00349 
00350     return oBookingClass_ptr;
00351   }
00352 
00353   // ////////////////////////////////////////////////////////////////////
00354   AirportPair* BomRetriever::
00355   retrieveAirportPairFromKeySet (const BomRoot& iBomRoot,
00356                                  const stdair::AirportCode_T& iOrigin,
00357                                  const stdair::AirportCode_T& iDestination) {
00358 
00359     // Get the Airport pair stream of the segment path.
00360     const AirportPairKey lAirportPairKey (iOrigin, iDestination);
00361     
00362     // Search for the fare rules having the same origin and
00363     // destination airport as the travel solution
00364     AirportPair* oAirportPair_ptr = BomManager::
00365       getObjectPtr<AirportPair> (iBomRoot, lAirportPairKey.toString());  
00366 
00367     return oAirportPair_ptr;
00368    
00369   }
00370 
00371   // ////////////////////////////////////////////////////////////////////
00372   void BomRetriever::
00373   retrieveDatePeriodListFromKey (const AirportPair& iAirportPair,
00374                                  const stdair::Date_T& iDepartureDate,
00375                                  stdair::DatePeriodList_T& ioDatePeriodList) {
00376 
00377     // Get the list of date-period
00378     const DatePeriodList_T& lFareDatePeriodList =
00379       BomManager::getList<DatePeriod> (iAirportPair);
00380 
00381     // Browse the date-period list
00382     for (DatePeriodList_T::const_iterator itDateRange =
00383            lFareDatePeriodList.begin();
00384          itDateRange != lFareDatePeriodList.end(); ++itDateRange) {
00385 
00386       DatePeriod* lCurrentFareDatePeriod_ptr = *itDateRange ;
00387       assert (lCurrentFareDatePeriod_ptr != NULL);
00388 
00389       // Select the date-period objects having a corresponding date range
00390       const bool isDepartureDateValid =
00391         lCurrentFareDatePeriod_ptr->isDepartureDateValid (iDepartureDate);
00392       
00393       // Add the date-period objects having a corresponding date range
00394       // to the list to display
00395       if (isDepartureDateValid == true) {
00396         ioDatePeriodList.push_back(lCurrentFareDatePeriod_ptr);
00397       }
00398     }
00399 
00400   }
00401 
00402   // ////////////////////////////////////////////////////////////////////
00403   void BomRetriever::
00404   retrieveDatePeriodListFromKeySet (const BomRoot& iBomRoot,
00405                                     const stdair::AirportCode_T& iOrigin,
00406                                     const stdair::AirportCode_T& iDestination,
00407                                     const stdair::Date_T& iDepartureDate,
00408                                     stdair::DatePeriodList_T& ioDatePeriodList) {
00409 
00410     // Retrieve the airport-pair
00411     AirportPair* oAirportPair_ptr =
00412       BomRetriever::retrieveAirportPairFromKeySet(iBomRoot, iOrigin,
00413                                                  iDestination);
00414     if (oAirportPair_ptr == NULL) {
00415       return;
00416     }
00417     assert (oAirportPair_ptr != NULL);
00418 
00419     // Retrieve the flight date
00420     BomRetriever::retrieveDatePeriodListFromKey (*oAirportPair_ptr, iDepartureDate,
00421                                                  ioDatePeriodList);
00422    
00423   }
00424   
00425   // ////////////////////////////////////////////////////////////////////
00426   LegCabin& BomRetriever::
00427   retrieveDummyLegCabin (stdair::BomRoot& iBomRoot,
00428                          const bool isForFareFamilies) {
00429 
00430     LegCabin* oLegCabin_ptr = NULL;
00431 
00432     // Retrieve the Inventory
00433     const Inventory* lInventory_ptr = BomRetriever::
00434       retrieveInventoryFromKey (iBomRoot, DEFAULT_AIRLINE_CODE);
00435 
00436     if (lInventory_ptr == NULL) {
00437       std::ostringstream oStr;
00438       oStr << "The inventory corresponding to the '"
00439            << DEFAULT_AIRLINE_CODE << "' airline can not be found";
00440       throw ObjectNotFoundException (oStr.str());
00441     }
00442     
00443     // Retrieve the FlightDate
00444     FlightDate* lFlightDate_ptr = NULL;
00445     if (isForFareFamilies == true) {
00446       lFlightDate_ptr = BomRetriever::
00447         retrieveFlightDateFromKey (*lInventory_ptr, DEFAULT_FLIGHT_NUMBER_FF,
00448                                    DEFAULT_DEPARTURE_DATE);
00449       
00450       if (lFlightDate_ptr == NULL) {
00451         std::ostringstream oStr;
00452         oStr << "The flight-date corresponding to ("
00453              << DEFAULT_FLIGHT_NUMBER_FF << ", "
00454              << DEFAULT_DEPARTURE_DATE << ") can not be found";
00455         throw ObjectNotFoundException (oStr.str());
00456       }
00457     } else {
00458       lFlightDate_ptr = BomRetriever::
00459         retrieveFlightDateFromKey (*lInventory_ptr, DEFAULT_FLIGHT_NUMBER,
00460                                    DEFAULT_DEPARTURE_DATE);
00461       
00462       if (lFlightDate_ptr == NULL) {
00463         std::ostringstream oStr;
00464         oStr << "The flight-date corresponding to ("
00465              << DEFAULT_FLIGHT_NUMBER << ", "
00466              << DEFAULT_DEPARTURE_DATE << ") can not be found";
00467         throw ObjectNotFoundException (oStr.str());
00468       }
00469     }
00470     assert(lFlightDate_ptr != NULL);
00471 
00472     // Retrieve the LegDate
00473     const LegDateKey lLegDateKey (DEFAULT_ORIGIN);
00474     const LegDate* lLegDate_ptr =
00475       lFlightDate_ptr->getLegDate (lLegDateKey);
00476 
00477     if (lLegDate_ptr == NULL) {
00478       std::ostringstream oStr;
00479       oStr << "The leg-date corresponding to the '"
00480            << DEFAULT_ORIGIN << "' origin can not be found";
00481       throw ObjectNotFoundException (oStr.str());
00482     }
00483     
00484     // Retrieve the LegCabin
00485     const LegCabinKey lLegCabinKey (DEFAULT_CABIN_CODE);
00486     oLegCabin_ptr = lLegDate_ptr->getLegCabin (lLegCabinKey);
00487 
00488     if (oLegCabin_ptr == NULL) {
00489       std::ostringstream oStr;
00490       oStr << "The leg-cabin corresponding to the '"
00491            << DEFAULT_CABIN_CODE << "' cabin code can not be found";
00492       throw ObjectNotFoundException (oStr.str());
00493     }
00494     
00495     assert (oLegCabin_ptr != NULL);
00496     return *oLegCabin_ptr;
00497 
00498   }
00499 
00500   // ////////////////////////////////////////////////////////////////////
00501   SegmentCabin& BomRetriever::
00502   retrieveDummySegmentCabin (stdair::BomRoot& iBomRoot,
00503                              const bool isForFareFamilies) {
00504 
00505     SegmentCabin* oSegmentCabin_ptr = NULL;
00506 
00507     // Retrieve the Inventory
00508     const Inventory* lInventory_ptr = BomRetriever::
00509       retrieveInventoryFromKey (iBomRoot, DEFAULT_AIRLINE_CODE);
00510 
00511     if (lInventory_ptr == NULL) {
00512       std::ostringstream oStr;
00513       oStr << "The inventory corresponding to the '"
00514            << DEFAULT_AIRLINE_CODE << "' airline can not be found";
00515       throw ObjectNotFoundException (oStr.str());
00516     }
00517 
00518     // Retrieve the FlightDate
00519     FlightDate* lFlightDate_ptr = NULL;
00520     if (isForFareFamilies == true) {
00521       lFlightDate_ptr = BomRetriever::
00522         retrieveFlightDateFromKey (*lInventory_ptr, DEFAULT_FLIGHT_NUMBER_FF,
00523                                    DEFAULT_DEPARTURE_DATE);
00524       
00525       if (lFlightDate_ptr == NULL) {
00526         std::ostringstream oStr;
00527         oStr << "The flight-date corresponding to ("
00528              << DEFAULT_FLIGHT_NUMBER_FF << ", "
00529              << DEFAULT_DEPARTURE_DATE << ") can not be found";
00530         throw ObjectNotFoundException (oStr.str());
00531       }
00532     } else {
00533       lFlightDate_ptr = BomRetriever::
00534         retrieveFlightDateFromKey (*lInventory_ptr, DEFAULT_FLIGHT_NUMBER,
00535                                    DEFAULT_DEPARTURE_DATE);
00536       
00537       if (lFlightDate_ptr == NULL) {
00538         std::ostringstream oStr;
00539         oStr << "The flight-date corresponding to ("
00540              << DEFAULT_FLIGHT_NUMBER << ", "
00541              << DEFAULT_DEPARTURE_DATE << ") can not be found";
00542         throw ObjectNotFoundException (oStr.str());
00543       }
00544     }
00545     assert(lFlightDate_ptr != NULL);
00546 
00547     // Retrieve the SegmentDate
00548     const SegmentDateKey lSegmentDateKey (DEFAULT_ORIGIN, DEFAULT_DESTINATION);
00549     const SegmentDate* lSegmentDate_ptr =
00550       lFlightDate_ptr->getSegmentDate (lSegmentDateKey);
00551 
00552     if (lSegmentDate_ptr == NULL) {
00553       std::ostringstream oStr;
00554       oStr << "The segment-date corresponding to the '"
00555            << DEFAULT_ORIGIN << "' origin and '"
00556            << DEFAULT_DESTINATION << "' destination can not be found";
00557       throw ObjectNotFoundException (oStr.str());
00558     }
00559     
00560     // Retrieve the SegmentCabin
00561     const SegmentCabinKey lSegmentCabinKey (DEFAULT_CABIN_CODE);
00562     oSegmentCabin_ptr =
00563       BomManager::getObjectPtr<SegmentCabin> (*lSegmentDate_ptr, lSegmentCabinKey.toString());
00564 
00565     if (oSegmentCabin_ptr == NULL) {
00566       std::ostringstream oStr;
00567       oStr << "The segment-cabin corresponding to the '"
00568            << DEFAULT_CABIN_CODE << "' cabin code can not be found";
00569       throw ObjectNotFoundException (oStr.str());
00570     }
00571 
00572     assert (oSegmentCabin_ptr != NULL);
00573     return *oSegmentCabin_ptr;
00574   } 
00575 
00576   // ////////////////////////////////////////////////////////////////////
00577   std::string BomRetriever::
00578   retrieveFullKeyFromSegmentDate (const SegmentDate& iSegmentdate) { 
00579 
00580     std::ostringstream lFullKeyStr;
00581  
00582     // Get the parent flight date
00583     FlightDate* lFlightDate_ptr = 
00584       BomManager::getParentPtr<FlightDate>(iSegmentdate);
00585     if (lFlightDate_ptr == NULL) { 
00586       return lFullKeyStr.str();
00587     }
00588     assert (lFlightDate_ptr != NULL);
00589 
00590     // Get the parent inventory
00591     Inventory* lInventory_ptr = 
00592       BomManager::getParentPtr<Inventory> (*lFlightDate_ptr);  
00593     if (lInventory_ptr == NULL) { 
00594       return lFullKeyStr.str();
00595     }
00596     assert (lInventory_ptr != NULL);
00597     
00598     lFullKeyStr << lInventory_ptr->describeKey() 
00599                 << DEFAULT_KEY_SUB_FLD_DELIMITER;       
00600     lFullKeyStr << lFlightDate_ptr->describeKey() 
00601                 << DEFAULT_KEY_SUB_FLD_DELIMITER;
00602     lFullKeyStr << iSegmentdate.describeKey();
00603         
00604     return lFullKeyStr.str();
00605 
00606   }
00607 
00608 }