StdAir Logo  1.00.16
C++ Standard Airline IT Object Library
Loading...
Searching...
No Matches
BomJSONExport.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <cassert>
6#include <ostream>
7#if BOOST_VERSION_MACRO >= 103400
8// Boost ForEach
9#include <boost/foreach.hpp>
10#endif // BOOST_VERSION_MACRO >= 103400
11// StdAir
24#include <stdair/bom/Bucket.hpp>
30
31namespace stdair {
32
33 // ////////////////////////////////////////////////////////////////////
35 jsonExportFlightDateList (std::ostream& oStream,
36 const BomRoot& iBomRoot,
37 const AirlineCode_T& iAirlineCode,
38 const FlightNumber_T& iFlightNumber) {
39
40 // Check whether there are Inventory objects
41 if (BomManager::hasList<Inventory> (iBomRoot) == false) {
42 return;
43 }
44
45#if BOOST_VERSION_MACRO >= 104100
46
47 // Create empty property tree objects
48 bpt::ptree pt;
49 bpt::ptree ptInventoryList;
50
51 // Browse the inventories
52 const InventoryList_T& lInventoryList =
54 for (InventoryList_T::const_iterator itInv = lInventoryList.begin();
55 itInv != lInventoryList.end(); ++itInv) {
56 const Inventory* lInv_ptr = *itInv;
57 assert (lInv_ptr != NULL);
58
59 // Retrieve the inventory key (airline code)
60 const AirlineCode_T& lAirlineCode = lInv_ptr->getAirlineCode();
61
62 // Display only the requested inventories
63 if (iAirlineCode == "all" || iAirlineCode == lAirlineCode) {
64
65 // Flight date tree
66 bpt::ptree ptFD;
67 // Create an empty flight-dates array
68 bpt::ptree lFDDatePropertyTree;
69
70 // Check whether there are FlightDate objects
71 if (BomManager::hasMap<FlightDate> (*lInv_ptr) == false) {
72 return;
73 }
74
75 // Browse the flight-dates
76 const FlightDateMap_T& lFlightDateList =
78 for (FlightDateMap_T::const_iterator itFD = lFlightDateList.begin();
79 itFD != lFlightDateList.end(); ++itFD) {
80 const FlightDate* lFD_ptr = itFD->second;
81 assert (lFD_ptr != NULL);
82
83 // Retrieve the key of the flight-date
84 const FlightNumber_T& lFlightNumber = lFD_ptr->getFlightNumber();
85 const Date_T& lFlightDateDate = lFD_ptr->getDepartureDate();
86
87 // Display only the requested flight number
88 if (iFlightNumber == 0 || iFlightNumber == lFlightNumber) {
89
90 // Add the airline code to the inventory tree
91 ptFD.put ("airline_code", lAirlineCode);
92 // Put flight number in property tree
93 ptFD.put ("number", lFlightNumber);
94 // Put flight date date in property tree
95 ptFD.put ("date", lFlightDateDate);
96
97 // Put the current flight date tree in the array
98 ptInventoryList.push_back(std::make_pair("", ptFD));
99
100 }
101 }
102
103 }
104 }
105
106 // Store the inventory(ies) array tree into the global tree
107 pt.add_child ("inventories", ptInventoryList);
108
109 // Write the property tree into the JSON stream.
110 write_json (oStream, pt);
111#endif // BOOST_VERSION_MACRO >= 104100
112 }
113
114 // ////////////////////////////////////////////////////////////////////
115 void BomJSONExport::jsonExportFlightDate (bpt::ptree& ioFDPropertyTree,
116 const Inventory& iInventory,
117 const FlightNumber_T& iFlightNumber) {
118
119 // Check whether there are FlightDate objects
120 if (BomManager::hasMap<FlightDate> (iInventory) == false) {
121 return;
122 }
123
124#if BOOST_VERSION_MACRO >= 104100
125
126 // Create an empty flight-dates array
127 bpt::ptree lFDDatePropertyTree;
128
129 // Browse the flight-dates
130 const FlightDateMap_T& lFlightDateList =
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);
136
137 // Retrieve the key of the flight-date
138 const FlightNumber_T& lFlightNumber = lFD_ptr->getFlightNumber();
139 const Date_T& lFlightDateDate = lFD_ptr->getDepartureDate();
140
141 // Display only the requested flight number
142 if (iFlightNumber == 0 || iFlightNumber == lFlightNumber) {
143
144 // Create an empty property tree object for the current flight date
145 bpt::ptree lCurrFDTree;
146
147 // Put flight number in property tree
148 lCurrFDTree.put ("number", lFlightNumber);
149 // Put flight date date in property tree
150 lCurrFDTree.put ("date", lFlightDateDate);
151
152 // Put the current flight date tree in the flight date array
153 ioFDPropertyTree.push_back(std::make_pair("", lCurrFDTree));
154
155 }
156 }
157#endif // BOOST_VERSION_MACRO >= 104100
158
159 }
160
161 // ////////////////////////////////////////////////////////////////////
163 jsonExportFlightDateObjects (std::ostream& oStream,
164 const FlightDate& iFlightDate) {
165
166#if BOOST_VERSION_MACRO >= 104100
167
171 // Create an empty property tree object
172 bpt::ptree pt;
173
174 // Put the airline code in property tree
175 const AirlineCode_T& lAirlineCode = iFlightDate.getAirlineCode();
176 pt.put ("flight_date.airline_code", lAirlineCode);
177
178 // Put the flight number in property tree
179 const FlightNumber_T& lFlightNumber = iFlightDate.getFlightNumber();
180 pt.put ("flight_date.flight_number", lFlightNumber);
181
182 // Put the flight departure date in property tree
183 const Date_T& lFlightDateDate = iFlightDate.getDepartureDate();
184 const std::string& lDepartureDateStr =
185 boost::gregorian::to_simple_string (lFlightDateDate);
186 pt.put ("flight_date.departure_date", lDepartureDateStr);
187
191 // Create an empty legs array
192 bpt::ptree ptLegs;
193
194 // Recursively construct the legs array
195 jsonExportLegDate (ptLegs, iFlightDate);
196
197 // Add legs tree to the global property tree
198 pt.add_child ("flight_date.legs", ptLegs);
199
203 // Create an empty segments array
204 bpt::ptree ptSegments;
205
206 // Recursively construct the segments array
207 jsonExportSegmentDate (ptSegments, iFlightDate);
208
209 // Add segments tree to the global property tree
210 pt.add_child ("flight_date.segments", ptSegments);
211
212 // Write the property tree into the JSON stream.
213 write_json (oStream, pt);
214
215#endif // BOOST_VERSION_MACRO >= 104100
216 }
217
218 // ////////////////////////////////////////////////////////////////////
219 void BomJSONExport::jsonExportLegDate (bpt::ptree& ioLegDateListTree,
220 const FlightDate& iFlightDate) {
221
222 // Check whether there are LegDate objects
223 if (BomManager::hasList<LegDate> (iFlightDate) == false) {
224 return;
225 }
226
227 // Browse the leg-dates
228 const LegDateList_T& lLegDateList =
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);
234
235#if BOOST_VERSION_MACRO >= 104100
236
237 // Create an empty property tree object for the current leg date
238 bpt::ptree lCurrLDTree;
239
240 // Put boarding point in property tree
241 const AirportCode_T& lBoardingPoint = lLD_ptr->getBoardingPoint();
242 lCurrLDTree.put ("board_point", lBoardingPoint);
243 // Put off point in property tree
244 const AirportCode_T& lOffPoint = lLD_ptr->getOffPoint();
245 lCurrLDTree.put ("off_point", lOffPoint);
246 // Put boarding date in property tree
247 const Date_T& lBoardingDate = lLD_ptr->getBoardingDate();
248 lCurrLDTree.put ("board_date", lBoardingDate);
249 // Put off date in property tree
250 const Date_T& lOffDate = lLD_ptr->getOffDate();
251 lCurrLDTree.put ("off_dDate", lOffDate);
252 // Put boarding time in property tree
253 const Duration_T& lBoardingTime = lLD_ptr->getBoardingTime();
254 lCurrLDTree.put ("board_time", lBoardingTime);
255 // Put off time in property tree
256 const Duration_T& lOffTime = lLD_ptr->getOffTime();
257 lCurrLDTree.put ("off_time", lOffTime);
258 // Put elapsed time in property tree
259 const Duration_T& lElapsedTime = lLD_ptr->getElapsedTime();
260 lCurrLDTree.put ("elapsed_time", lElapsedTime);
261 // Put date offset in property tree
262 const DateOffset_T& lDateOffset = lLD_ptr->getDateOffset();
263 lCurrLDTree.put ("date_offset", lDateOffset);
264 // Put time offset in property tree
265 const Duration_T& lTimeOffset = lLD_ptr->getTimeOffset();
266 lCurrLDTree.put ("time_offset", lTimeOffset);
267 // Put distance in property tree
268 const Distance_T& lDistance = lLD_ptr->getDistance();
269 lCurrLDTree.put ("distance", lDistance);
270 // Put capacity in property tree
271 const CabinCapacity_T& lCapacity = lLD_ptr->getCapacity();
272 lCurrLDTree.put ("capacity", lCapacity);
273
274 // Create an empty property tree object for the leg cabins array
275 // corresponding to the current leg date.
276 bpt::ptree lLegCabinArray;
277
278 // Recursively construct the leg cabins array
279 jsonExportLegCabin (lLegCabinArray, *lLD_ptr);
280
281 // Add the leg cabins array to the leg date tree
282 lCurrLDTree.add_child ("cabins", lLegCabinArray);
283
284 // Put the current leg date tree in the leg date list tree
285 ioLegDateListTree.push_back(std::make_pair("", lCurrLDTree));
286
287#endif // BOOST_VERSION_MACRO >= 104100
288 }
289 }
290
291 // ////////////////////////////////////////////////////////////////////
292 void BomJSONExport::jsonExportLegCabin (bpt::ptree& ioLegCabinListTree,
293 const LegDate& iLegDate) {
294
295 // Check whether there are LegCabin objects
296 if (BomManager::hasList<LegCabin> (iLegDate) == false) {
297 return;
298 }
299
300 // Browse the leg-cabins
301 const LegCabinList_T& lLegCabinList =
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);
307
308#if BOOST_VERSION_MACRO >= 104100
309
310 // Create an empty property tree object for the current leg cabin
311 bpt::ptree lCurrLCTree;
312 bpt::ptree lCurrLCBPV;
313
314 // Put the cabin code in property tree
315 const CabinCode_T& lCabinCode = lLC_ptr->getCabinCode();
316 lCurrLCTree.put ("code", lCabinCode);
317 // Put the offered capacity in property tree
318 const CabinCapacity_T& lOfferedCapacity = lLC_ptr->getOfferedCapacity();
319 lCurrLCTree.put ("offed_cap", lOfferedCapacity);
320 // Put the physical capacity in property tree
321 const CabinCapacity_T& lPhysicalCapacity = lLC_ptr->getPhysicalCapacity();
322 lCurrLCTree.put ("phy_cap", lPhysicalCapacity);
323 // Put regrade adjustment in property tree
324 const CapacityAdjustment_T& lRegradeAdjustment = lLC_ptr->getRegradeAdjustment();
325 lCurrLCTree.put ("rgd_adj", lRegradeAdjustment);
326 // Put authorization level in property tree
327 const AuthorizationLevel_T& lAuthorizationLevel = lLC_ptr->getAuthorizationLevel();
328 lCurrLCTree.put ("au", lAuthorizationLevel);
329 // Put UPR in property tree
330 const UPR_T& lUPR = lLC_ptr->getUPR();
331 lCurrLCTree.put ("upr", lUPR);
332 // Put sold seats in property tree
333 const NbOfSeats_T& lNbOfSoldSeats = lLC_ptr->getSoldSeat();
334 lCurrLCTree.put ("ss", lNbOfSoldSeats);
335 // Put staff nb of seats in property tree
336 const NbOfSeats_T& lStaffNbOfSeats = lLC_ptr->getStaffNbOfSeats();
337 lCurrLCTree.put ("staff", lStaffNbOfSeats);
338 // Put waiting list nb of seats in property tree
339 const NbOfSeats_T& lWLNbOfSeats = lLC_ptr->getWLNbOfSeats();
340 lCurrLCTree.put ("wl", lWLNbOfSeats);
341 // Put group nb of seats in property tree
342 const NbOfSeats_T& lGroupNbOfSeats = lLC_ptr->getGroupNbOfSeats();
343 lCurrLCTree.put ("group", lGroupNbOfSeats);
344 // Put committed space in property tree
345 const CommittedSpace_T& lCommittedSpace = lLC_ptr->getCommittedSpace();
346 lCurrLCTree.put ("comm_space", lCommittedSpace);
347 // Put availability pool in property tree
348 const Availability_T& lAvailabilityPool = lLC_ptr->getAvailabilityPool();
349 lCurrLCTree.put ("av_pool", lAvailabilityPool);
350 // Put availability in property tree
351 const Availability_T& lAvailability = lLC_ptr->getAvailability();
352 lCurrLCTree.put ("avl", lAvailability);
353 // Put net availability in property tree
354 const Availability_T& lNetAvailability = lLC_ptr->getNetAvailability();
355 lCurrLCTree.put ("nav", lNetAvailability);
356 // Put gross availability in property tree
357 const Availability_T& lGrossAvailability = lLC_ptr->getGrossAvailability();
358 lCurrLCTree.put ("gav", lGrossAvailability);
359 // Put avg cancellation percentage in property tree
360 const OverbookingRate_T& lAvgCancellationPercentage =
361 lLC_ptr->getAvgCancellationPercentage();
362 lCurrLCTree.put ("acp", lAvgCancellationPercentage);
363 // Put ETB in property tree
364 const NbOfSeats_T& lExpectedToBoard = lLC_ptr->getETB();
365 lCurrLCTree.put ("etb", lExpectedToBoard );
366 // Put current bid price in property tree
367 const BidPrice_T& lCurrentBidPrice = lLC_ptr->getCurrentBidPrice();
368 lCurrLCTree.put ("bid_price", lCurrentBidPrice);
369 // Put current bid price vector in property tree
370 const BidPriceVector_T& lCurrentBidPriceVector =
371 lLC_ptr->getBidPriceVector();
372 std::ostringstream ostr;
373 BidPriceVector_T::const_iterator itBP = lCurrentBidPriceVector.begin();
374 while (itBP != lCurrentBidPriceVector.end()) {
375 ostr << *itBP;
376 ++itBP;
377 if (itBP != lCurrentBidPriceVector.end()) {
378 ostr << ",";
379 }
380 }
381 lCurrLCTree.put ("BPV", ostr.str());
382
383 // Create an empty property tree object for the buckets array
384 // corresponding to the current leg cabin.
385 bpt::ptree lBucketTree;
386
387 // Recursively construct the buckets array
388 jsonExportBucket (lBucketTree, *lLC_ptr);
389
390 // Add the buckets array to the leg cabin tree
391 lCurrLCTree.add_child ("buckets", lBucketTree);
392
393 // Put the current leg cabin tree in the leg cabin list tree
394 ioLegCabinListTree.push_back(std::make_pair("", lCurrLCTree));
395
396#endif // BOOST_VERSION_MACRO >= 104100
397 }
398 }
399
400 // ////////////////////////////////////////////////////////////////////
401 void BomJSONExport::jsonExportBucket (bpt::ptree& ioBucketListTree,
402 const LegCabin& iLegCabin) {
403
408 // Check whether there are Bucket objects
409 if (BomManager::hasList<Bucket> (iLegCabin) == false) {
410 return;
411 }
412
413 // Browse the buckets
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);
419
420#if BOOST_VERSION_MACRO >= 104100
421
422 // Create an empty property tree object for the current bucket
423 bpt::ptree lCurrBucketTree;
424
425 // Put yield in property tree
426 const Yield_T& lYieldRangeUpperValue =
427 lBucket_ptr->getYieldRangeUpperValue();
428 lCurrBucketTree.put ("yield", lYieldRangeUpperValue);
429 // Put seat_index in property tree
430 const SeatIndex_T& lSeatIndex = lBucket_ptr->getSeatIndex();
431 lCurrBucketTree.put ("si", lSeatIndex);
432 // Put sold_seats in property tree
433 const NbOfSeats_T& lSoldSeats = lBucket_ptr->getSoldSeats();
434 lCurrBucketTree.put ("ss", lSoldSeats);
435 // Put avaibility in property tree
436 const CabinCapacity_T& lAvailability = lBucket_ptr->getAvailability();
437 lCurrBucketTree.put ("av", lAvailability);
438
439 // Put the current bucket tree in the bucket list tree
440 ioBucketListTree.push_back(std::make_pair("", lCurrBucketTree));
441
442#endif // BOOST_VERSION_MACRO >= 104100
443 }
444 }
445
446 // ////////////////////////////////////////////////////////////////////
447 void BomJSONExport::jsonExportSegmentDate (bpt::ptree& ioSegmentDateTree,
448 const FlightDate& iFlightDate) {
449
450 // Check whether there are SegmentDate objects
451 if (BomManager::hasList<SegmentDate> (iFlightDate) == false) {
452 return;
453 }
454
455 // Browse the segment-dates
456 const SegmentDateList_T& lSegmentDateList =
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);
462
463#if BOOST_VERSION_MACRO >= 104100
464
465 // Create an empty property tree object for the current segment date
466 bpt::ptree lCurrSDTree;
467
468 // Put segment key in property tree
469 lCurrSDTree.put ("segment", lSD_ptr->toString());
470
471 // Create an empty property tree object for the segment cabin array
472 // corresponding to the current segment date
473 bpt::ptree lSegmentCabinTree;
474
475 // Recursively construct the segment cabin array
476 jsonExportSegmentCabin (lSegmentCabinTree, *lSD_ptr);
477
478 // Add the segment cabin array to the tree of the current segment date
479 lCurrSDTree.add_child ("sub_classes", lSegmentCabinTree);
480
481 // Put segment date array in property tree
482 ioSegmentDateTree.push_back(std::make_pair("", lCurrSDTree));
483
484#endif // BOOST_VERSION_MACRO >= 104100
485 }
486 }
487
488 // ////////////////////////////////////////////////////////////////////
489 void BomJSONExport::jsonExportSegmentCabin (bpt::ptree& ioPropertyTree,
490 const SegmentDate& iSegmentDate) {
491
492 // Check whether there are SegmentCabin objects
493 if (BomManager::hasList<SegmentCabin> (iSegmentDate) == false) {
494 return;
495 }
496
497 // Browse the segment-cabins
498 const SegmentCabinList_T& lSegmentCabinList =
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);
504
505#if BOOST_VERSION_MACRO >= 104100
506 // Create an empty property tree object for the current segment cabin
507 bpt::ptree lSCArray;
508
509 // Put cabin in property tree
510
511 lSCArray.put ("cabin_code",lSC_ptr->toString());
512
513 // Export the cabin tree to add fare-families and sub-classes details
514 jsonExportFareFamily (ioPropertyTree, lSCArray, *lSC_ptr);
515
516#endif // BOOST_VERSION_MACRO >= 104100
517
518 }
519 }
520
521 // ////////////////////////////////////////////////////////////////////
522 void BomJSONExport::jsonExportFareFamily (bpt::ptree& ioPropertyTree,
523 bpt::ptree& ioSCTree,
524 const SegmentCabin& iSegmentCabin) {
525
526 // Check whether there are FareFamily objects
527 if (BomManager::hasList<FareFamily> (iSegmentCabin) == true) {
528
529 // Browse the fare-families
530 const FareFamilyList_T& lFareFamilyList =
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);
536
537 // Browse the booking-classes
538 const BookingClassList_T& lBookingClassList =
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);
545
546#if BOOST_VERSION_MACRO >= 104100
547
548 // Put family code in property tree
549 const FamilyCode_T& lFamilyCode = lFF_ptr->getFamilyCode();
550 ioSCTree.put ("family_code", lFamilyCode);
551
552 // Export the cabin tree to add sub-classes details
553 jsonExportBookingClass (ioPropertyTree, ioSCTree, *lBC_ptr);
554
555#endif // BOOST_VERSION_MACRO >= 104100
556
557 }
558 }
559 } else {
560
561 // The fare family code is a fake one ('NoFF'), and therefore
562 // does not vary
563 const FamilyCode_T lDefaultFamilyCode ("NoFF");
564
565 // Browse the booking-classes, directly from the segment-cabin object
566 const BookingClassList_T& lBookingClassList =
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);
573
574#if BOOST_VERSION_MACRO >= 104100
575
576 // Put family code in property tree
577 ioSCTree.put ("family_code", lDefaultFamilyCode);
578
579 // Export the cabin tree to add sub-classes details
580 jsonExportBookingClass (ioPropertyTree, ioSCTree, *lBC_ptr);
581
582#endif // BOOST_VERSION_MACRO >= 104100
583 }
584 }
585 }
586
587 // ////////////////////////////////////////////////////////////////////
588 void BomJSONExport::jsonExportBookingClass (bpt::ptree& ioPropertyTree,
589 bpt::ptree& ioSCTree,
590 const BookingClass& iBookingClass) {
591
597#if BOOST_VERSION_MACRO >= 104100
598
599 // Put sub class in property tree
600 ioSCTree.put ("class_code", iBookingClass.toString());
601 // Put authorization level in property tree
602 std::ostringstream oAUBlStr;
603 oAUBlStr << iBookingClass.getAuthorizationLevel();
604 //<< " (" << iBookingClass.getCumulatedBookingLimit()
605 //<< ") ";
606 ioSCTree.put ("au", oAUBlStr.str());
607 // Put negotiated space in property tree
608 const NbOfSeats_T& lNegotiatedSpace =
609 iBookingClass.getNegotiatedSpace();
610 ioSCTree.put ("nego", lNegotiatedSpace);
611 // Put no show percentage in property tree
612 const OverbookingRate_T& lNoShowPercentage =
613 iBookingClass.getNoShowPercentage();
614 ioSCTree.put ("ns%", lNoShowPercentage);
615 // Put cancellation percentage in property tree
616 const OverbookingRate_T& lCancellationPercentage =
617 iBookingClass.getCancellationPercentage();
618 ioSCTree.put ("ob%", lCancellationPercentage);
619 // Put sub nb of bookings in property tree
620 const NbOfBookings_T lNbOfBookings =
621 iBookingClass.getNbOfBookings();
622 ioSCTree.put ("bkgs", lNbOfBookings);
623 // Put nb of group bookings in property tree
624 const NbOfBookings_T& lNbOfGroupBookings =
625 iBookingClass.getNbOfGroupBookings();
626 ioSCTree.put ("grp_bks (pdg)", lNbOfGroupBookings);
627 // Put nb of staff bookings in property tree
628 const NbOfBookings_T& lNbOfStaffBookings =
629 iBookingClass.getNbOfStaffBookings();
630 ioSCTree.put ("stf_bkgs", lNbOfStaffBookings);
631 // Put nb of WL bookings in property tree
632 const NbOfBookings_T& lNbOfWLBookings =
633 iBookingClass.getNbOfWLBookings();
634 ioSCTree.put ("wl_bkgs", lNbOfWLBookings);
635 // Put ETB in property tree
636 const NbOfBookings_T& lETB = iBookingClass.getETB();
637 ioSCTree.put ("etb", lETB);
638 // Put net class availability in property tree
639 const Availability_T& lNetClassAvailability =
640 iBookingClass.getNetClassAvailability();
641 ioSCTree.put ("class_avl", lNetClassAvailability);
642 // Put segment availability in property tree
643 const Availability_T& lSegmentAvailability =
644 iBookingClass.getSegmentAvailability();
645 ioSCTree.put ("seg_avl", lSegmentAvailability);
646 // Put net revenue availability in property tree
647 const Availability_T& lNetRevenueAvailability =
648 iBookingClass.getNetRevenueAvailability();
649 ioSCTree.put ("rev_avl", lNetRevenueAvailability);
650
651 // Add the sub-classe (containing cabin and fare-families information)
652 // to the global tree
653 ioPropertyTree.push_back(std::make_pair("", ioSCTree));
654
655#endif // BOOST_VERSION_MACRO >= 104100
656 }
657
658 // ////////////////////////////////////////////////////////////////////
660 jsonExportBookingRequestObject (std::ostream& oStream,
661 const EventStruct& iEventStruct) {
662
663 // Get the current event type: it should be booking request
664 const EventType::EN_EventType& lEventType =
665 iEventStruct.getEventType();
666 assert (lEventType == EventType::BKG_REQ);
667
668 // Get the booking request (the current event type is booking request)
669 const BookingRequestStruct& lBookingRequest =
670 iEventStruct.getBookingRequest();
671
672#if BOOST_VERSION_MACRO >= 104100
673
674 // Create an empty property tree object for the current booking request
675 bpt::ptree ptBookingRequest;
676
677 // Put request date time in property tree
678 const DateTime_T& lRequestDateTime =
679 lBookingRequest.getRequestDateTime();
680 ptBookingRequest.put ("time_stamp", lRequestDateTime);
681 // Put event type in property tree
682 ptBookingRequest.put ("event_type", EventType::getLabel(lEventType));
683 // Put origin in property tree
684 const AirportCode_T& lOrigin = lBookingRequest.getOrigin();
685 ptBookingRequest.put ("org", lOrigin);
686 // Put destination in property tree
687 const AirportCode_T& lDestination = lBookingRequest.getDestination();
688 ptBookingRequest.put ("des", lDestination);
689 // Put preferred cabin in property tree
690 const CabinCode_T& lCabinCode = lBookingRequest.getPreferredCabin();
691 ptBookingRequest.put ("cab", lCabinCode);
692 // Put party size in property tree
693 const NbOfSeats_T& lNbOfSeats = lBookingRequest.getPartySize();
694 ptBookingRequest.put ("pax", lNbOfSeats);
695 // Put point-of-sale in property tree
696 const AirportCode_T& lPOS = lBookingRequest.getPOS();
697 ptBookingRequest.put ("pos", lPOS);
698 // Put channel in property tree
699 const ChannelLabel_T& lChannelLabel =
700 lBookingRequest.getBookingChannel();
701 ptBookingRequest.put ("cha", lChannelLabel);
702 // Put WTP in property tree
703 const WTP_T& lWTP = lBookingRequest.getWTP();
704 ptBookingRequest.put ("wtp", lWTP);
705 // Put request date in property tree
706 const Date_T& lRequestDate =
707 lRequestDateTime.boost::posix_time::ptime::date();
708 ptBookingRequest.put ("bkg_date", lRequestDate);
709 // Put departure date in property tree
710 const Date_T& lPreferedDepartureDate =
711 lBookingRequest.getPreferedDepartureDate();
712 ptBookingRequest.put ("dep_date", lPreferedDepartureDate);
713 // Put advance purchase in property tree
714 assert (lPreferedDepartureDate >= lRequestDate);
715 const DateOffset_T& lAdvancePurchase =
716 lPreferedDepartureDate - lRequestDate;
717 ptBookingRequest.put ("adv_purchase", lAdvancePurchase);
718 // Put stay duration in property tree
719 const DayDuration_T& lStayDuration =
720 lBookingRequest.getStayDuration();
721 ptBookingRequest.put ("stay_duration", lStayDuration);
722 // Put return date in property tree
723 const DateOffset_T lDayDuration (lStayDuration);
724 const Date_T& lReturnDate =
725 lPreferedDepartureDate + lDayDuration;
726 ptBookingRequest.put ("return_date", lReturnDate);
727 // Put cancellation date in property tree
728 // TODO: cancellation date
729 ptBookingRequest.put ("cancel_date", "xxxx-xx-xx");
730 // Put preferred departure time in property tree
731 const Duration_T& lPreferredDepartureTime =
732 lBookingRequest.getPreferredDepartureTime();
733 ptBookingRequest.put ("dep_time", lPreferredDepartureTime);
734 // Put preferred return time in property tree
735 // TODO: preferred return time
736 ptBookingRequest.put ("return_time", "xxPM");
737 // Put preferred carriers in property tree
738 // TODO: preferred carriers
739 ptBookingRequest.put ("pref_carriers", "XX");
740
741 // Write the property tree into the JSON stream.
742 write_json (oStream, ptBookingRequest);
743
744#endif // BOOST_VERSION_MACRO >= 104100
745 }
746
747 // ////////////////////////////////////////////////////////////////////
749 jsonExportBreakPointObject (std::ostream& oStream,
750 const EventStruct& iEventStruct) {
751
752 // Get the current event type: it should be break point
753 const EventType::EN_EventType& lEventType =
754 iEventStruct.getEventType();
755 assert (lEventType == EventType::BRK_PT);
756
757 // Get the break point (the current event type is break point)
758 const BreakPointStruct& lBreakPoint =
759 iEventStruct.getBreakPoint();
760
761#if BOOST_VERSION_MACRO >= 104100
762
763 // Create an empty property tree object for the current break point
764 bpt::ptree ptBreakPoint;
765
766 // Put break point date time in property tree
767 const DateTime_T& lRequestDateTime =
768 lBreakPoint.getBreakPointTime();
769 ptBreakPoint.put ("time_stamp", lRequestDateTime);
770 // Put event type in property tree
771 ptBreakPoint.put ("event_type", EventType::getLabel(lEventType));
772
773 // Write the property tree into the JSON stream.
774 write_json (oStream, ptBreakPoint);
775
776
777#endif // BOOST_VERSION_MACRO >= 104100
778 }
779
780}
781
Handle on the StdAir library context.
boost::gregorian::date Date_T
boost::posix_time::ptime DateTime_T
std::map< const MapKey_T, FlightDate * > FlightDateMap_T
boost::gregorian::date_duration DateOffset_T
unsigned long int Distance_T
std::list< SegmentDate * > SegmentDateList_T
std::string ChannelLabel_T
std::list< FareFamily * > FareFamilyList_T
NbOfRequests_T NbOfBookings_T
std::list< BookingClass * > BookingClassList_T
unsigned int SeatIndex_T
std::list< SegmentCabin * > SegmentCabinList_T
double AuthorizationLevel_T
double CapacityAdjustment_T
double Availability_T
std::list< Inventory * > InventoryList_T
std::string FamilyCode_T
unsigned short FlightNumber_T
std::string AirlineCode_T
std::list< Bucket * > BucketList_T
boost::posix_time::time_duration Duration_T
std::list< LegCabin * > LegCabinList_T
LocationCode_T AirportCode_T
std::vector< BidPrice_T > BidPriceVector_T
std::list< LegDate * > LegDateList_T
std::string CabinCode_T
char ptree
static const std::string & getLabel(const EN_EventType &)
Definition EventType.cpp:83
static void jsonExportFlightDateObjects(std::ostream &, const FlightDate &)
static void jsonExportFlightDateList(std::ostream &, const BomRoot &, const AirlineCode_T &iAirlineCode="all", const FlightNumber_T &iFlightNumber=0)
static void jsonExportBreakPointObject(std::ostream &, const EventStruct &)
static void jsonExportBookingRequestObject(std::ostream &, const EventStruct &)
static bool hasList(const OBJECT1 &)
static const BomHolder< OBJECT2 >::BomList_T & getList(const OBJECT1 &)
static bool hasMap(const OBJECT1 &)
static const BomHolder< OBJECT2 >::BomMap_T & getMap(const OBJECT1 &)
Class representing the actual attributes for the Bom root.
Definition BomRoot.hpp:32
Structure holding the elements of a booking request.
const ChannelLabel_T & getBookingChannel() const
const CabinCode_T & getPreferredCabin() const
const CityCode_T & getPOS() const
const Date_T & getPreferedDepartureDate() const
const DayDuration_T & getStayDuration() const
const DateTime_T & getRequestDateTime() const
const NbOfSeats_T & getPartySize() const
const AirportCode_T & getOrigin() const
const Duration_T & getPreferredDepartureTime() const
const AirportCode_T & getDestination() const
const DateTime_T & getBreakPointTime() const
const BreakPointStruct & getBreakPoint() const
const BookingRequestStruct & getBookingRequest() const
const EventType::EN_EventType & getEventType() const
Class representing the actual attributes for an airline flight-date.
const AirlineCode_T & getAirlineCode() const
const FlightNumber_T & getFlightNumber() const
const Date_T & getDepartureDate() const
Class representing the actual attributes for an airline inventory.
Definition Inventory.hpp:41
const AirlineCode_T & getAirlineCode() const
Definition Inventory.hpp:64