9 #include <stdair/basic/BasConst_BomDisplay.hpp>
10 #include <stdair/bom/BomManager.hpp>
11 #include <stdair/bom/BomRoot.hpp>
12 #include <stdair/bom/Inventory.hpp>
13 #include <stdair/bom/FlightPeriod.hpp>
14 #include <stdair/bom/SegmentPeriod.hpp>
15 #include <stdair/bom/BookingRequestStruct.hpp>
16 #include <stdair/bom/TravelSolutionStruct.hpp>
17 #include <stdair/service/Logger.hpp>
28 void SegmentPathProvider::
29 buildSegmentPathList (stdair::TravelSolutionList_T& ioTravelSolutionList,
30 const stdair::BomRoot& iBomRoot,
31 const stdair::BookingRequestStruct& iBookingRequest) {
34 const stdair::AirportCode_T& lOrigin = iBookingRequest.getOrigin ();
35 const ReachableUniverse* lReachableUniverse_ptr =
36 stdair::BomManager::getObjectPtr<ReachableUniverse> (iBomRoot, lOrigin);
37 if (lReachableUniverse_ptr != NULL) {
38 buildSegmentPathList (ioTravelSolutionList, *lReachableUniverse_ptr,
44 void SegmentPathProvider::
45 buildSegmentPathList (stdair::TravelSolutionList_T& ioTravelSolutionList,
46 const ReachableUniverse& iReachableUniverse,
47 const stdair::BookingRequestStruct& iBookingRequest) {
50 const stdair::AirportCode_T& lDestination = iBookingRequest.getDestination();
51 const OriginDestinationSet* lOriginDestinationSet_ptr =
52 stdair::BomManager::getObjectPtr<OriginDestinationSet> (iReachableUniverse,
54 if (lOriginDestinationSet_ptr != NULL) {
55 buildSegmentPathList (ioTravelSolutionList, *lOriginDestinationSet_ptr,
61 void SegmentPathProvider::
62 buildSegmentPathList (stdair::TravelSolutionList_T& ioTravelSolutionList,
63 const OriginDestinationSet& iOriginDestinationSet,
64 const stdair::BookingRequestStruct& iBookingRequest) {
66 const stdair::Date_T& lPreferedDepartureDate =
67 iBookingRequest.getPreferedDepartureDate ();
72 stdair::BomManager::getList<SegmentPathPeriod> (iOriginDestinationSet);
73 for (SegmentPathPeriodList_T::const_iterator itSegmentPath =
74 lSegmentPathPeriodList.begin ();
75 itSegmentPath != lSegmentPathPeriodList.end (); ++itSegmentPath) {
76 const SegmentPathPeriod* lCurrentSegmentPath_ptr = *itSegmentPath;
77 assert (lCurrentSegmentPath_ptr != NULL);
78 if (lCurrentSegmentPath_ptr->isDepartureDateValid(lPreferedDepartureDate)){
79 const stdair::DateTime_T lRequestDateTime =
80 iBookingRequest.getRequestDateTime();
81 const stdair::Duration_T& lBoardingTime =
82 lCurrentSegmentPath_ptr->getBoardingTime();
83 const stdair::DateTime_T lDepartureDateTime (lPreferedDepartureDate,
85 const bool IsDepartureDateValid =
87 if (IsDepartureDateValid ==
false) {
90 buildSegmentPathList (ioTravelSolutionList, *lCurrentSegmentPath_ptr,
97 void SegmentPathProvider::
98 buildSegmentPathList (stdair::TravelSolutionList_T& ioTravelSolutionList,
99 const SegmentPathPeriod& iSegmentPathPeriod,
100 const stdair::BookingRequestStruct& iBookingRequest) {
102 stdair::TravelSolutionStruct lTravelSolution;
106 const stdair::Date_T& lPreferedDepartureDate =
107 iBookingRequest.getPreferedDepartureDate ();
108 const stdair::SegmentPeriodList_T& lSegmentPeriodList =
109 stdair::BomManager::getList<stdair::SegmentPeriod> (iSegmentPathPeriod);
111 iSegmentPathPeriod.getBoardingDateOffsetList ();
112 assert (lSegmentPeriodList.size() == lBoardingDateOffsetList.size());
113 DateOffsetList_T::const_iterator itOffset = lBoardingDateOffsetList.begin();
114 for (stdair::SegmentPeriodList_T::const_iterator itSegment =
115 lSegmentPeriodList.begin();
116 itSegment != lSegmentPeriodList.end(); ++itSegment) {
117 const stdair::SegmentPeriod* lSegmentPeriod_ptr = *itSegment;
118 assert (lSegmentPeriod_ptr != NULL);
119 const stdair::DateOffset_T& lBoardingDateOffset = *itOffset;
122 const stdair::DateOffset_T& lSegmentBoardingDateOffset =
123 lSegmentPeriod_ptr->getBoardingDateOffset();
124 const stdair::Date_T& lReferenceFlightDate = lPreferedDepartureDate
125 + lBoardingDateOffset - lSegmentBoardingDateOffset;
128 const stdair::FlightPeriod& lFlightPeriod =
129 stdair::BomManager::getParent<stdair::FlightPeriod>(*lSegmentPeriod_ptr);
130 const stdair::Inventory& lInventory =
131 stdair::BomManager::getParent<stdair::Inventory> (lFlightPeriod);
132 const stdair::Duration_T lBoardingTime = lSegmentPeriod_ptr->getBoardingTime();
133 std::ostringstream oStr;
134 oStr << lInventory.getAirlineCode()
135 << stdair::DEFAULT_KEY_FLD_DELIMITER
136 << lFlightPeriod.getFlightNumber()
137 << stdair::DEFAULT_KEY_SUB_FLD_DELIMITER
138 << boost::gregorian::to_simple_string (lReferenceFlightDate)
139 << stdair::DEFAULT_KEY_FLD_DELIMITER
140 << lSegmentPeriod_ptr->getBoardingPoint()
141 << stdair::DEFAULT_KEY_SUB_FLD_DELIMITER
142 << lSegmentPeriod_ptr->getOffPoint()
143 << stdair::DEFAULT_KEY_FLD_DELIMITER
146 lTravelSolution.addSegment (oStr.str());
150 ioTravelSolutionList.push_back (lTravelSolution);