7 #if BOOST_VERSION >= 103400
9 #include <boost/foreach.hpp>
10 #endif // BOOST_VERSION >= 103400
41 if (BomManager::hasList<Inventory> (iBomRoot) ==
false) {
45 #if BOOST_VERSION >= 104100
53 BomManager::getList<Inventory> (iBomRoot);
54 for (InventoryList_T::const_iterator itInv = lInventoryList.begin();
55 itInv != lInventoryList.end(); ++itInv) {
57 assert (lInv_ptr != NULL);
63 if (iAirlineCode ==
"all" || iAirlineCode == lAirlineCode) {
71 if (BomManager::hasMap<FlightDate> (*lInv_ptr) ==
false) {
77 BomManager::getMap<FlightDate> (*lInv_ptr);
78 for (FlightDateMap_T::const_iterator itFD = lFlightDateList.begin();
79 itFD != lFlightDateList.end(); ++itFD) {
81 assert (lFD_ptr != NULL);
88 if (iFlightNumber == 0 || iFlightNumber == lFlightNumber) {
91 ptFD.put (
"airline_code", lAirlineCode);
93 ptFD.put (
"number", lFlightNumber);
95 ptFD.put (
"date", lFlightDateDate);
98 ptInventoryList.push_back(std::make_pair(
"", ptFD));
107 pt.add_child (
"inventories", ptInventoryList);
110 write_json (oStream, pt);
111 #endif // BOOST_VERSION >= 104100
115 void BomJSONExport::jsonExportFlightDate (
bpt::ptree& ioFDPropertyTree,
120 if (BomManager::hasMap<FlightDate> (iInventory) ==
false) {
124 #if BOOST_VERSION >= 104100
131 BomManager::getMap<FlightDate> (iInventory);
132 for (FlightDateMap_T::const_iterator itFD = lFlightDateList.begin();
133 itFD != lFlightDateList.end(); ++itFD) {
134 const FlightDate* lFD_ptr = itFD->second;
135 assert (lFD_ptr != NULL);
139 const Date_T& lFlightDateDate = lFD_ptr->getDepartureDate();
142 if (iFlightNumber == 0 || iFlightNumber == lFlightNumber) {
148 lCurrFDTree.put (
"number", lFlightNumber);
150 lCurrFDTree.put (
"date", lFlightDateDate);
153 ioFDPropertyTree.push_back(std::make_pair(
"", lCurrFDTree));
157 #endif // BOOST_VERSION >= 104100
166 #if BOOST_VERSION >= 104100
176 pt.put (
"flight_date.airline_code", lAirlineCode);
180 pt.put (
"flight_date.flight_number", lFlightNumber);
184 const std::string& lDepartureDateStr =
185 boost::gregorian::to_simple_string (lFlightDateDate);
186 pt.put (
"flight_date.departure_date", lDepartureDateStr);
195 jsonExportLegDate (ptLegs, iFlightDate);
198 pt.add_child (
"flight_date.legs", ptLegs);
207 jsonExportSegmentDate (ptSegments, iFlightDate);
210 pt.add_child (
"flight_date.segments", ptSegments);
213 write_json (oStream, pt);
215 #endif // BOOST_VERSION >= 104100
219 void BomJSONExport::jsonExportLegDate (
bpt::ptree& ioLegDateListTree,
223 if (BomManager::hasList<LegDate> (iFlightDate) ==
false) {
229 BomManager::getList<LegDate> (iFlightDate);
230 for (LegDateList_T::const_iterator itLD = lLegDateList.begin();
231 itLD != lLegDateList.end(); ++itLD) {
232 const LegDate* lLD_ptr = *itLD;
233 assert (lLD_ptr != NULL);
235 #if BOOST_VERSION >= 104100
241 const AirportCode_T& lBoardingPoint = lLD_ptr->getBoardingPoint();
242 lCurrLDTree.put (
"board_point", lBoardingPoint);
245 lCurrLDTree.put (
"off_point", lOffPoint);
247 const Date_T& lBoardingDate = lLD_ptr->getBoardingDate();
248 lCurrLDTree.put (
"board_date", lBoardingDate);
250 const Date_T& lOffDate = lLD_ptr->getOffDate();
251 lCurrLDTree.put (
"off_dDate", lOffDate);
253 const Duration_T& lBoardingTime = lLD_ptr->getBoardingTime();
254 lCurrLDTree.put (
"board_time", lBoardingTime);
256 const Duration_T& lOffTime = lLD_ptr->getOffTime();
257 lCurrLDTree.put (
"off_time", lOffTime);
259 const Duration_T& lElapsedTime = lLD_ptr->getElapsedTime();
260 lCurrLDTree.put (
"elapsed_time", lElapsedTime);
262 const DateOffset_T& lDateOffset = lLD_ptr->getDateOffset();
263 lCurrLDTree.put (
"date_offset", lDateOffset);
265 const Duration_T& lTimeOffset = lLD_ptr->getTimeOffset();
266 lCurrLDTree.put (
"time_offset", lTimeOffset);
268 const Distance_T& lDistance = lLD_ptr->getDistance();
269 lCurrLDTree.put (
"distance", lDistance);
272 lCurrLDTree.put (
"capacity", lCapacity);
279 jsonExportLegCabin (lLegCabinArray, *lLD_ptr);
282 lCurrLDTree.add_child (
"cabins", lLegCabinArray);
285 ioLegDateListTree.push_back(std::make_pair(
"", lCurrLDTree));
287 #endif // BOOST_VERSION >= 104100
292 void BomJSONExport::jsonExportLegCabin (
bpt::ptree& ioLegCabinListTree,
293 const LegDate& iLegDate) {
296 if (BomManager::hasList<LegCabin> (iLegDate) ==
false) {
302 BomManager::getList<LegCabin> (iLegDate);
303 for (LegCabinList_T::const_iterator itLC = lLegCabinList.begin();
304 itLC != lLegCabinList.end(); ++itLC) {
305 const LegCabin* lLC_ptr = *itLC;
306 assert (lLC_ptr != NULL);
308 #if BOOST_VERSION >= 104100
315 const CabinCode_T& lCabinCode = lLC_ptr->getCabinCode();
316 lCurrLCTree.put (
"code", lCabinCode);
318 const CabinCapacity_T& lOfferedCapacity = lLC_ptr->getOfferedCapacity();
319 lCurrLCTree.put (
"offed_cap", lOfferedCapacity);
321 const CabinCapacity_T& lPhysicalCapacity = lLC_ptr->getPhysicalCapacity();
322 lCurrLCTree.put (
"phy_cap", lPhysicalCapacity);
325 lCurrLCTree.put (
"rgd_adj", lRegradeAdjustment);
328 lCurrLCTree.put (
"au", lAuthorizationLevel);
330 const UPR_T& lUPR = lLC_ptr->getUPR();
331 lCurrLCTree.put (
"upr", lUPR);
333 const NbOfSeats_T& lNbOfSoldSeats = lLC_ptr->getSoldSeat();
334 lCurrLCTree.put (
"ss", lNbOfSoldSeats);
336 const NbOfSeats_T& lStaffNbOfSeats = lLC_ptr->getStaffNbOfSeats();
337 lCurrLCTree.put (
"staff", lStaffNbOfSeats);
339 const NbOfSeats_T& lWLNbOfSeats = lLC_ptr->getWLNbOfSeats();
340 lCurrLCTree.put (
"wl", lWLNbOfSeats);
342 const NbOfSeats_T& lGroupNbOfSeats = lLC_ptr->getGroupNbOfSeats();
343 lCurrLCTree.put (
"group", lGroupNbOfSeats);
346 lCurrLCTree.put (
"comm_space", lCommittedSpace);
348 const Availability_T& lAvailabilityPool = lLC_ptr->getAvailabilityPool();
349 lCurrLCTree.put (
"av_pool", lAvailabilityPool);
352 lCurrLCTree.put (
"avl", lAvailability);
354 const Availability_T& lNetAvailability = lLC_ptr->getNetAvailability();
355 lCurrLCTree.put (
"nav", lNetAvailability);
357 const Availability_T& lGrossAvailability = lLC_ptr->getGrossAvailability();
358 lCurrLCTree.put (
"gav", lGrossAvailability);
361 lLC_ptr->getAvgCancellationPercentage();
362 lCurrLCTree.put (
"acp", lAvgCancellationPercentage);
364 const NbOfSeats_T& lExpectedToBoard = lLC_ptr->getETB();
365 lCurrLCTree.put (
"etb", lExpectedToBoard );
367 const BidPrice_T& lCurrentBidPrice = lLC_ptr->getCurrentBidPrice();
368 lCurrLCTree.put (
"bid_price", lCurrentBidPrice);
371 lLC_ptr->getBidPriceVector();
372 std::ostringstream ostr;
373 BidPriceVector_T::const_iterator itBP = lCurrentBidPriceVector.begin();
374 while (itBP != lCurrentBidPriceVector.end()) {
377 if (itBP != lCurrentBidPriceVector.end()) {
381 lCurrLCTree.put (
"BPV", ostr.str());
388 jsonExportBucket (lBucketTree, *lLC_ptr);
391 lCurrLCTree.add_child (
"buckets", lBucketTree);
394 ioLegCabinListTree.push_back(std::make_pair(
"", lCurrLCTree));
396 #endif // BOOST_VERSION >= 104100
401 void BomJSONExport::jsonExportBucket (
bpt::ptree& ioBucketListTree,
402 const LegCabin& iLegCabin) {
409 if (BomManager::hasList<Bucket> (iLegCabin) ==
false) {
414 const BucketList_T& lBucketList = BomManager::getList<Bucket> (iLegCabin);
415 for (BucketList_T::const_iterator itBuck = lBucketList.begin();
416 itBuck != lBucketList.end(); ++itBuck) {
417 const Bucket* lBucket_ptr = *itBuck;
418 assert (lBucket_ptr != NULL);
420 #if BOOST_VERSION >= 104100
426 const Yield_T& lYieldRangeUpperValue =
427 lBucket_ptr->getYieldRangeUpperValue();
428 lCurrBucketTree.put (
"yield", lYieldRangeUpperValue);
430 const SeatIndex_T& lSeatIndex = lBucket_ptr->getSeatIndex();
431 lCurrBucketTree.put (
"si", lSeatIndex);
433 const NbOfSeats_T& lSoldSeats = lBucket_ptr->getSoldSeats();
434 lCurrBucketTree.put (
"ss", lSoldSeats);
437 lCurrBucketTree.put (
"av", lAvailability);
440 ioBucketListTree.push_back(std::make_pair(
"", lCurrBucketTree));
442 #endif // BOOST_VERSION >= 104100
447 void BomJSONExport::jsonExportSegmentDate (
bpt::ptree& ioSegmentDateTree,
448 const FlightDate& iFlightDate) {
451 if (BomManager::hasList<SegmentDate> (iFlightDate) ==
false) {
457 BomManager::getList<SegmentDate> (iFlightDate);
458 for (SegmentDateList_T::const_iterator itSD = lSegmentDateList.begin();
459 itSD != lSegmentDateList.end(); ++itSD) {
460 const SegmentDate* lSD_ptr = *itSD;
461 assert (lSD_ptr != NULL);
463 #if BOOST_VERSION >= 104100
469 lCurrSDTree.put (
"segment", lSD_ptr->toString());
476 jsonExportSegmentCabin (lSegmentCabinTree, *lSD_ptr);
479 lCurrSDTree.add_child (
"sub_classes", lSegmentCabinTree);
482 ioSegmentDateTree.push_back(std::make_pair(
"", lCurrSDTree));
484 #endif // BOOST_VERSION >= 104100
489 void BomJSONExport::jsonExportSegmentCabin (
bpt::ptree& ioPropertyTree,
490 const SegmentDate& iSegmentDate) {
493 if (BomManager::hasList<SegmentCabin> (iSegmentDate) ==
false) {
499 BomManager::getList<SegmentCabin> (iSegmentDate);
500 for (SegmentCabinList_T::const_iterator itSC = lSegmentCabinList.begin();
501 itSC != lSegmentCabinList.end(); ++itSC) {
502 const SegmentCabin* lSC_ptr = *itSC;
503 assert (lSC_ptr != NULL);
505 #if BOOST_VERSION >= 104100
511 lSCArray.put (
"cabin_code",lSC_ptr->toString());
514 jsonExportFareFamily (ioPropertyTree, lSCArray, *lSC_ptr);
516 #endif // BOOST_VERSION >= 104100
522 void BomJSONExport::jsonExportFareFamily (
bpt::ptree& ioPropertyTree,
524 const SegmentCabin& iSegmentCabin) {
527 if (BomManager::hasList<FareFamily> (iSegmentCabin) ==
true) {
531 BomManager::getList<FareFamily> (iSegmentCabin);
532 for (FareFamilyList_T::const_iterator itFF = lFareFamilyList.begin();
533 itFF != lFareFamilyList.end(); ++itFF) {
534 const FareFamily* lFF_ptr = *itFF;
535 assert (lFF_ptr != NULL);
539 BomManager::getList<BookingClass> (*lFF_ptr);
540 for (BookingClassList_T::const_iterator itBC =
541 lBookingClassList.begin();
542 itBC != lBookingClassList.end(); ++itBC) {
543 const BookingClass* lBC_ptr = *itBC;
544 assert (lBC_ptr != NULL);
546 #if BOOST_VERSION >= 104100
549 const FamilyCode_T& lFamilyCode = lFF_ptr->getFamilyCode();
550 ioSCTree.put (
"family_code", lFamilyCode);
553 jsonExportBookingClass (ioPropertyTree, ioSCTree, *lBC_ptr);
555 #endif // BOOST_VERSION >= 104100
567 BomManager::getList<BookingClass> (iSegmentCabin);
568 for (BookingClassList_T::const_iterator itBC =
569 lBookingClassList.begin();
570 itBC != lBookingClassList.end(); ++itBC) {
571 const BookingClass* lBC_ptr = *itBC;
572 assert (lBC_ptr != NULL);
574 #if BOOST_VERSION >= 104100
577 ioSCTree.put (
"family_code", lDefaultFamilyCode);
580 jsonExportBookingClass (ioPropertyTree, ioSCTree, *lBC_ptr);
582 #endif // BOOST_VERSION >= 104100
588 void BomJSONExport::jsonExportBookingClass (
bpt::ptree& ioPropertyTree,
590 const BookingClass& iBookingClass) {
597 #if BOOST_VERSION >= 104100
600 ioSCTree.put (
"class_code", iBookingClass.toString());
602 std::ostringstream oAUBlStr;
603 oAUBlStr << iBookingClass.getAuthorizationLevel();
606 ioSCTree.put (
"au", oAUBlStr.str());
609 iBookingClass.getNegotiatedSpace();
610 ioSCTree.put (
"nego", lNegotiatedSpace);
613 iBookingClass.getNoShowPercentage();
614 ioSCTree.put (
"ns%", lNoShowPercentage);
617 iBookingClass.getCancellationPercentage();
618 ioSCTree.put (
"ob%", lCancellationPercentage);
621 iBookingClass.getNbOfBookings();
622 ioSCTree.put (
"bkgs", lNbOfBookings);
625 iBookingClass.getNbOfGroupBookings();
626 ioSCTree.put (
"grp_bks (pdg)", lNbOfGroupBookings);
629 iBookingClass.getNbOfStaffBookings();
630 ioSCTree.put (
"stf_bkgs", lNbOfStaffBookings);
633 iBookingClass.getNbOfWLBookings();
634 ioSCTree.put (
"wl_bkgs", lNbOfWLBookings);
637 ioSCTree.put (
"etb", lETB);
640 iBookingClass.getNetClassAvailability();
641 ioSCTree.put (
"class_avl", lNetClassAvailability);
644 iBookingClass.getSegmentAvailability();
645 ioSCTree.put (
"seg_avl", lSegmentAvailability);
648 iBookingClass.getNetRevenueAvailability();
649 ioSCTree.put (
"rev_avl", lNetRevenueAvailability);
653 ioPropertyTree.push_back(std::make_pair(
"", ioSCTree));
655 #endif // BOOST_VERSION >= 104100
672 #if BOOST_VERSION >= 104100
680 ptBookingRequest.put (
"time_stamp", lRequestDateTime);
685 ptBookingRequest.put (
"org", lOrigin);
688 ptBookingRequest.put (
"des", lDestination);
691 ptBookingRequest.put (
"cab", lCabinCode);
694 ptBookingRequest.put (
"pax", lNbOfSeats);
697 ptBookingRequest.put (
"pos", lPOS);
701 ptBookingRequest.put (
"cha", lChannelLabel);
704 ptBookingRequest.put (
"wtp", lWTP);
706 const Date_T& lRequestDate =
707 lRequestDateTime.boost::posix_time::ptime::date();
708 ptBookingRequest.put (
"bkg_date", lRequestDate);
710 const Date_T& lPreferedDepartureDate =
712 ptBookingRequest.put (
"dep_date", lPreferedDepartureDate);
714 assert (lPreferedDepartureDate >= lRequestDate);
716 lPreferedDepartureDate - lRequestDate;
717 ptBookingRequest.put (
"adv_purchase", lAdvancePurchase);
721 ptBookingRequest.put (
"stay_duration", lStayDuration);
724 const Date_T& lReturnDate =
725 lPreferedDepartureDate + lDayDuration;
726 ptBookingRequest.put (
"return_date", lReturnDate);
729 ptBookingRequest.put (
"cancel_date",
"xxxx-xx-xx");
733 ptBookingRequest.put (
"dep_time", lPreferredDepartureTime);
736 ptBookingRequest.put (
"return_time",
"xxPM");
739 ptBookingRequest.put (
"pref_carriers",
"XX");
742 write_json (oStream, ptBookingRequest);
744 #endif // BOOST_VERSION >= 104100
761 #if BOOST_VERSION >= 104100
769 ptBreakPoint.put (
"time_stamp", lRequestDateTime);
774 write_json (oStream, ptBreakPoint);
777 #endif // BOOST_VERSION >= 104100