SimCRS Logo  1.01.8
C++ Simulated Travel-Oriented Distribution System Library
Loading...
Searching...
No Matches
SIMCRS_Service.cpp
Go to the documentation of this file.
1// //////////////////////////////////////////////////////////////////////
2// Import section
3// //////////////////////////////////////////////////////////////////////
4// STL
5#include <cassert>
6#include <sstream>
7// Boost
8#include <boost/make_shared.hpp>
9// Standard Airline Object Model
10#include <stdair/stdair_exceptions.hpp>
11#include <stdair/stdair_basic_types.hpp>
12#include <stdair/stdair_json.hpp>
13#include <stdair/basic/BasChronometer.hpp>
14#include <stdair/basic/BasFileMgr.hpp>
15#include <stdair/bom/BomManager.hpp>
16#include <stdair/bom/BookingRequestStruct.hpp>
17#include <stdair/bom/TravelSolutionStruct.hpp>
18#include <stdair/bom/CancellationStruct.hpp>
19#include <stdair/bom/BomRoot.hpp>
20#include <stdair/bom/Inventory.hpp>
21#include <stdair/service/Logger.hpp>
22#include <stdair/STDAIR_Service.hpp>
23// SEvMgr
24#include <sevmgr/SEVMGR_Service.hpp>
25// Airline Inventory
26#include <airinv/AIRINV_Master_Service.hpp>
27// Airline Schedule
28#include <airtsp/AIRTSP_Service.hpp>
29// Fare Quote
30#include <simfqt/SIMFQT_Service.hpp>
31// SimCRS
37
38namespace SIMCRS {
39
40 // ////////////////////////////////////////////////////////////////////
41 SIMCRS_Service::SIMCRS_Service() : _simcrsServiceContext (NULL) {
42 assert (false);
43 }
44
45 // ////////////////////////////////////////////////////////////////////
46 SIMCRS_Service::SIMCRS_Service (const SIMCRS_Service& iService) {
47 assert (false);
48 }
49
50 // ////////////////////////////////////////////////////////////////////
51 SIMCRS_Service::SIMCRS_Service (const stdair::BasLogParams& iLogParams,
52 const CRSCode_T& iCRSCode)
53 : _simcrsServiceContext (NULL) {
54
55 // Initialise the StdAir service handler
56 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
57 initStdAirService (iLogParams);
58
59 // Initialise the service context
60 initServiceContext (iCRSCode);
61
62 // Add the StdAir service context to the SimCRS service context
63 // \note SIMCRS owns the STDAIR service resources here.
64 const bool ownStdairService = true;
65 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
66
67 // Initalise the SimFQT service.
68 initSIMFQTService();
69
70 // Initalise the AirTSP service.
71 initAIRTSPService();
72
73 // Initalise the AirInv service.
74 initAIRINVService();
75
76 // Initialise the (remaining of the) context
77 initSimcrsService();
78 }
79
80 // ////////////////////////////////////////////////////////////////////
81 SIMCRS_Service::SIMCRS_Service (const stdair::BasLogParams& iLogParams,
82 const stdair::BasDBParams& iDBParams,
83 const CRSCode_T& iCRSCode)
84 : _simcrsServiceContext (NULL) {
85
86 // Initialise the STDAIR service handler
87 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
88 initStdAirService (iLogParams, iDBParams);
89
90 // Initialise the service context
91 initServiceContext (iCRSCode);
92
93 // Add the StdAir service context to the SIMCRS service context
94 // \note SIMCRS owns the STDAIR service resources here.
95 const bool ownStdairService = true;
96 addStdAirService (lSTDAIR_Service_ptr, ownStdairService);
97
98 // Initalise the SIMFQT service.
99 initSIMFQTService();
100
101 // Initalise the AIRTSP service.
102 initAIRTSPService();
103
104 // Initalise the AIRINV service.
105 initAIRINVService();
106
107 // Initialise the (remaining of the) context
108 initSimcrsService();
109 }
110
111 // ////////////////////////////////////////////////////////////////////
112 SIMCRS_Service::
113 SIMCRS_Service (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
114 SEVMGR::SEVMGR_ServicePtr_T ioSEVMGR_Service_ptr,
115 const CRSCode_T& iCRSCode)
116 : _simcrsServiceContext (NULL) {
117
118 // Initialise the service context
119 initServiceContext (iCRSCode);
120
121 // Store the STDAIR service object within the (AIRINV) service context
122 // \note AirInv does not own the STDAIR service resources here.
123 const bool doesNotOwnStdairService = false;
124 addStdAirService (ioSTDAIR_Service_ptr, doesNotOwnStdairService);
125
126 //Add the SEvMgr service to the TRADEMGEN service context.
127 const bool doesNotOwnSEVMGRService = false;
128 addSEVMGRService (ioSEVMGR_Service_ptr, doesNotOwnSEVMGRService);
129
130 // Initalise the SIMFQT service.
131 initSIMFQTService();
132
133 // Initalise the AIRTSP service.
134 initAIRTSPService();
135
136 // Initalise the AIRINV service.
137 initAIRINVService();
138
139 // Initialise the (remaining of the) context
140 initSimcrsService();
141 }
142
143 // ////////////////////////////////////////////////////////////////////
145 // Delete/Clean all the objects from memory
146 finalise();
147 }
148
149 // ////////////////////////////////////////////////////////////////////
150 void SIMCRS_Service::finalise() {
151 assert (_simcrsServiceContext != NULL);
152 // Reset the (Boost.)Smart pointer pointing on the STDAIR_Service object.
153 _simcrsServiceContext->reset();
154 }
155
156 // ////////////////////////////////////////////////////////////////////
157 void SIMCRS_Service::initServiceContext (const CRSCode_T& iCRSCode) {
158 // Initialise the service context
159 SIMCRS_ServiceContext& lSIMCRS_ServiceContext =
161 _simcrsServiceContext = &lSIMCRS_ServiceContext;
162 }
163
164 // ////////////////////////////////////////////////////////////////////
165 void SIMCRS_Service::
166 addStdAirService (stdair::STDAIR_ServicePtr_T ioSTDAIR_Service_ptr,
167 const bool iOwnStdairService) {
168
169 // Retrieve the SimCRS service context
170 assert (_simcrsServiceContext != NULL);
171 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
172
173 // Store the StdAir service object within the (SimCRS) service context
174 lSIMCRS_ServiceContext.setSTDAIR_Service (ioSTDAIR_Service_ptr,
175 iOwnStdairService);
176 }
177
178 // ////////////////////////////////////////////////////////////////////
179 void SIMCRS_Service::
180 addSEVMGRService (SEVMGR::SEVMGR_ServicePtr_T ioSEVMGR_Service_ptr,
181 const bool iOwnSEVMGRService) {
182
183 // Retrieve the SimCRS service context
184 assert (_simcrsServiceContext != NULL);
185 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
186
187 // Store the STDAIR service object within the (TRADEMGEN) service context
188 lSIMCRS_ServiceContext.setSEVMGR_Service (ioSEVMGR_Service_ptr,
189 iOwnSEVMGRService);
190 }
191
192 // ////////////////////////////////////////////////////////////////////
193 stdair::STDAIR_ServicePtr_T SIMCRS_Service::
194 initStdAirService (const stdair::BasLogParams& iLogParams) {
195
203 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
204 boost::make_shared<stdair::STDAIR_Service> (iLogParams);
205
206 return lSTDAIR_Service_ptr;
207 }
208
209 // ////////////////////////////////////////////////////////////////////
210 stdair::STDAIR_ServicePtr_T SIMCRS_Service::
211 initStdAirService (const stdair::BasLogParams& iLogParams,
212 const stdair::BasDBParams& iDBParams) {
213
221 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
222 boost::make_shared<stdair::STDAIR_Service> (iLogParams, iDBParams);
223
224 return lSTDAIR_Service_ptr;
225 }
226
227 // ////////////////////////////////////////////////////////////////////
228 void SIMCRS_Service::initAIRTSPService() {
229
230 // Retrieve the SimCRS service context
231 assert (_simcrsServiceContext != NULL);
232 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
233
234 // Retrieve the StdAir service context
235 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
236 lSIMCRS_ServiceContext.getSTDAIR_ServicePtr();
237
245 AIRTSP::AIRTSP_ServicePtr_T lAIRTSP_Service_ptr =
246 boost::make_shared<AIRTSP::AIRTSP_Service> (lSTDAIR_Service_ptr);
247
248 // Store the AIRTSP service object within the (SimCRS) service context
249 lSIMCRS_ServiceContext.setAIRTSP_Service (lAIRTSP_Service_ptr);
250 }
251
252 // ////////////////////////////////////////////////////////////////////
253 void SIMCRS_Service::initSIMFQTService() {
254
255 // Retrieve the SimCRS service context
256 assert (_simcrsServiceContext != NULL);
257 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
258
259 // Retrieve the StdAir service context
260 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
261 lSIMCRS_ServiceContext.getSTDAIR_ServicePtr();
262
270 SIMFQT::SIMFQT_ServicePtr_T lSIMFQT_Service_ptr =
271 boost::make_shared<SIMFQT::SIMFQT_Service> (lSTDAIR_Service_ptr);
272
273 // Store the SIMFQT service object within the (SimCRS) service context
274 lSIMCRS_ServiceContext.setSIMFQT_Service (lSIMFQT_Service_ptr);
275 }
276
277 // ////////////////////////////////////////////////////////////////////
278 void SIMCRS_Service::initAIRINVService() {
279
280 // Retrieve the SimCRS service context
281 assert (_simcrsServiceContext != NULL);
282 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
283
284 // Retrieve the StdAir service context
285 stdair::STDAIR_ServicePtr_T lSTDAIR_Service_ptr =
286 lSIMCRS_ServiceContext.getSTDAIR_ServicePtr();
287
295 AIRINV::AIRINV_Master_ServicePtr_T lAIRINV_Master_Service_ptr;
296 const bool ownSEVMGRService =
297 lSIMCRS_ServiceContext.getOwnSEVMGRServiceFlag();
298 if (ownSEVMGRService == false) {
299 // Retrieve the SEVMGR service
300 SEVMGR::SEVMGR_ServicePtr_T lSEVMGR_Service_ptr =
301 lSIMCRS_ServiceContext.getSEVMGR_ServicePtr();
302 assert (lSEVMGR_Service_ptr != NULL);
303 lAIRINV_Master_Service_ptr =
304 boost::make_shared<AIRINV::AIRINV_Master_Service> (lSTDAIR_Service_ptr,
305 lSEVMGR_Service_ptr);
306 } else {
307 lAIRINV_Master_Service_ptr =
308 boost::make_shared<AIRINV::AIRINV_Master_Service> (lSTDAIR_Service_ptr);
309 }
310 assert (lAIRINV_Master_Service_ptr != NULL);
311
312 // Store the AIRINV service object within the (SimCRS) service context
313 lSIMCRS_ServiceContext.setAIRINV_Service (lAIRINV_Master_Service_ptr);
314 }
315
316 // ////////////////////////////////////////////////////////////////////
317 void SIMCRS_Service::initSimcrsService() {
318 // Do nothing at this stage. A sample BOM tree may be built by
319 // calling the buildSampleBom() method
320 }
321
322 // ////////////////////////////////////////////////////////////////////
324 parseAndLoad (const stdair::ScheduleFilePath& iScheduleInputFilepath,
325 const stdair::ODFilePath& iODInputFilepath,
326 const stdair::FRAT5FilePath& iFRAT5InputFilepath,
327 const stdair::FFDisutilityFilePath& iFFDisutilityInputFilepath,
328 const AIRRAC::YieldFilePath& iYieldInputFilepath,
329 const SIMFQT::FareFilePath& iFareInputFilepath) {
330
331 // Retrieve the SimCRS service context
332 if (_simcrsServiceContext == NULL) {
333 throw stdair::NonInitialisedServiceException ("The SimCRS service "
334 "has not been initialised");
335 }
336 assert (_simcrsServiceContext != NULL);
337
338 // Retrieve the SimCRS service context and whether it owns the Stdair
339 // service
340 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
341 const bool doesOwnStdairService =
342 lSIMCRS_ServiceContext.getOwnStdairServiceFlag();
343
344 // Retrieve the StdAir service object from the (SimCRS) service context
345 stdair::STDAIR_Service& lSTDAIR_Service =
346 lSIMCRS_ServiceContext.getSTDAIR_Service();
347
348 // Retrieve the persistent BOM root object.
349 stdair::BomRoot& lPersistentBomRoot =
350 lSTDAIR_Service.getPersistentBomRoot();
351
361 AIRTSP::AIRTSP_Service& lAIRTSP_Service =
362 lSIMCRS_ServiceContext.getAIRTSP_Service();
363 lAIRTSP_Service.parseAndLoad (iScheduleInputFilepath);
364
371 AIRINV::AIRINV_Master_Service& lAIRINV_Service =
372 lSIMCRS_ServiceContext.getAIRINV_Service();
373 lAIRINV_Service.parseAndLoad (iScheduleInputFilepath, iODInputFilepath,
374 iFRAT5InputFilepath,
375 iFFDisutilityInputFilepath,
376 iYieldInputFilepath);
377
381 SIMFQT::SIMFQT_Service& lSIMFQT_Service =
382 lSIMCRS_ServiceContext.getSIMFQT_Service();
383 lSIMFQT_Service.parseAndLoad (iFareInputFilepath);
384
389 buildComplementaryLinks (lPersistentBomRoot);
390
395 if (doesOwnStdairService == true) {
396 //
398 }
399 }
400
401 // ////////////////////////////////////////////////////////////////////
403
404 // Retrieve the SimCRS service context
405 if (_simcrsServiceContext == NULL) {
406 throw stdair::NonInitialisedServiceException ("The SimCRS service "
407 "has not been initialised");
408 }
409 assert (_simcrsServiceContext != NULL);
410
411 // Retrieve the SimCRS service context and whether it owns the Stdair
412 // service
413 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
414 const bool doesOwnStdairService =
415 lSIMCRS_ServiceContext.getOwnStdairServiceFlag();
416
417 // Retrieve the StdAir service object from the (SimCRS) service context
418 stdair::STDAIR_Service& lSTDAIR_Service =
419 lSIMCRS_ServiceContext.getSTDAIR_Service();
420
421 // Retrieve the persistent BOM root object.
422 stdair::BomRoot& lPersistentBomRoot =
423 lSTDAIR_Service.getPersistentBomRoot();
424
429 if (doesOwnStdairService == true) {
430 //
431 lSTDAIR_Service.buildSampleBom();
432 }
433
443 AIRTSP::AIRTSP_Service& lAIRTSP_Service =
444 lSIMCRS_ServiceContext.getAIRTSP_Service();
445 lAIRTSP_Service.buildSampleBom();
446
453 AIRINV::AIRINV_Master_Service& lAIRINV_Service =
454 lSIMCRS_ServiceContext.getAIRINV_Service();
455 lAIRINV_Service.buildSampleBom();
456
460 SIMFQT::SIMFQT_Service& lSIMFQT_Service =
461 lSIMCRS_ServiceContext.getSIMFQT_Service();
462 lSIMFQT_Service.buildSampleBom();
463
468 buildComplementaryLinks (lPersistentBomRoot);
469
474 if (doesOwnStdairService == true) {
475 //
477 }
478 }
479
480 // ////////////////////////////////////////////////////////////////////
482
483 // Retrieve the SimCRS service context
484 if (_simcrsServiceContext == NULL) {
485 throw stdair::NonInitialisedServiceException ("The SimCRS service "
486 "has not been initialised");
487 }
488 assert (_simcrsServiceContext != NULL);
489
490 // Retrieve the SimCRS service context and whether it owns the Stdair
491 // service
492 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
493 const bool doesOwnStdairService =
494 lSIMCRS_ServiceContext.getOwnStdairServiceFlag();
495
496 // Retrieve the StdAir service object from the (SimCRS) service context
497 stdair::STDAIR_Service& lSTDAIR_Service =
498 lSIMCRS_ServiceContext.getSTDAIR_Service();
499
504 if (doesOwnStdairService == true) {
505 //
506 lSTDAIR_Service.clonePersistentBom ();
507 }
508
518 AIRTSP::AIRTSP_Service& lAIRTSP_Service =
519 lSIMCRS_ServiceContext.getAIRTSP_Service();
520 lAIRTSP_Service.clonePersistentBom ();
521
528 AIRINV::AIRINV_Master_Service& lAIRINV_Service =
529 lSIMCRS_ServiceContext.getAIRINV_Service();
530 lAIRINV_Service.clonePersistentBom ();
531
535 SIMFQT::SIMFQT_Service& lSIMFQT_Service =
536 lSIMCRS_ServiceContext.getSIMFQT_Service();
537 lSIMFQT_Service.clonePersistentBom ();
538
543 stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
544 buildComplementaryLinks (lBomRoot);
545 }
546
547 // ////////////////////////////////////////////////////////////////////
548 void SIMCRS_Service::buildComplementaryLinks (stdair::BomRoot& ioBomRoot) {
549 // Currently, no more things to do by TravelCCM at that stage.
550 }
551
552 // //////////////////////////////////////////////////////////////////////
554 buildSampleTravelSolutions(stdair::TravelSolutionList_T& ioTravelSolutionList){
555
556 // Retrieve the SimCRS service context
557 if (_simcrsServiceContext == NULL) {
558 throw stdair::NonInitialisedServiceException ("The SimCRS service "
559 "has not been initialised");
560 }
561 assert (_simcrsServiceContext != NULL);
562
563 // Retrieve the StdAir service object from the (SimCRS) service context
564 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
565 stdair::STDAIR_Service& lSTDAIR_Service =
566 lSIMCRS_ServiceContext.getSTDAIR_Service();
567
568 // Delegate the BOM building to the dedicated service
569 lSTDAIR_Service.buildSampleTravelSolutions (ioTravelSolutionList);
570 }
571
572 // //////////////////////////////////////////////////////////////////////
573 stdair::BookingRequestStruct SIMCRS_Service::
574 buildSampleBookingRequest (const bool isForCRS) {
575
576 // Retrieve the SimCRS service context
577 if (_simcrsServiceContext == NULL) {
578 throw stdair::NonInitialisedServiceException ("The SimCRS service "
579 "has not been initialised");
580 }
581 assert (_simcrsServiceContext != NULL);
582
583 // Retrieve the StdAir service object from the (SimCRS) service context
584 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
585 stdair::STDAIR_Service& lSTDAIR_Service =
586 lSIMCRS_ServiceContext.getSTDAIR_Service();
587
588 // Delegate the BOM building to the dedicated service
589 return lSTDAIR_Service.buildSampleBookingRequest (isForCRS);
590 }
591
592 // ////////////////////////////////////////////////////////////////////
593 bool SIMCRS_Service::sell (const std::string& iSegmentDateKey,
594 const stdair::ClassCode_T& iClassCode,
595 const stdair::PartySize_T& iPartySize) {
596
597 // Retrieve the SimCRS service context
598 if (_simcrsServiceContext == NULL) {
599 throw stdair::NonInitialisedServiceException ("The SimCRS service "
600 "has not been initialised");
601 }
602 assert (_simcrsServiceContext != NULL);
603 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
604
605 // Retrieve the AIRINV Master service.
606 AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
607 lSIMCRS_ServiceContext.getAIRINV_Service();
608
609 return lAIRINV_Master_Service.sell (iSegmentDateKey, iClassCode,
610 iPartySize);
611 }
612
613 // ////////////////////////////////////////////////////////////////////
615 jsonHandler (const stdair::JSONString& iJSONString) const {
616
617 // Retrieve the SimCRS service context
618 if (_simcrsServiceContext == NULL) {
619 throw stdair::NonInitialisedServiceException ("The SimCRS service "
620 "has not been initialised");
621 }
622 assert (_simcrsServiceContext != NULL);
623 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
624
625 // Retrieve the AIRINV Master service.
626 AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
627 lSIMCRS_ServiceContext.getAIRINV_Service();
628
629 return lAIRINV_Master_Service.jsonHandler (iJSONString);
630
631 }
632
633 // ////////////////////////////////////////////////////////////////////
635 initSnapshotAndRMEvents (const stdair::Date_T& iStartDate,
636 const stdair::Date_T& iEndDate) {
637
638 // Retrieve the SimCRS service context
639 if (_simcrsServiceContext == NULL) {
640 throw stdair::NonInitialisedServiceException ("The SimCRS service has "
641 "not been initialised");
642 }
643 assert (_simcrsServiceContext != NULL);
644 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
645
646 // Retrieve the AIRINV Master service.
647 AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
648 lSIMCRS_ServiceContext.getAIRINV_Service();
649
650 lAIRINV_Master_Service.initSnapshotAndRMEvents (iStartDate, iEndDate);
651 }
652
653 // //////////////////////////////////////////////////////////////////////
654 std::string SIMCRS_Service::csvDisplay() const {
655
656 // Retrieve the SimCRS service context
657 if (_simcrsServiceContext == NULL) {
658 throw stdair::NonInitialisedServiceException ("The SimCRS service "
659 "has not been initialised");
660 }
661 assert (_simcrsServiceContext != NULL);
662
663 // Retrieve the StdAir service object from the (SimCRS) service context
664 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
665 stdair::STDAIR_Service& lSTDAIR_Service =
666 lSIMCRS_ServiceContext.getSTDAIR_Service();
667 const stdair::BomRoot& lBomRoot = lSTDAIR_Service.getBomRoot();
668
669 // Delegate the BOM building to the dedicated service
670 return lSTDAIR_Service.csvDisplay(lBomRoot);
671 }
672
673 // //////////////////////////////////////////////////////////////////////
675 csvDisplay (const stdair::TravelSolutionList_T& ioTravelSolutionList) const {
676
677 // Retrieve the SimCRS service context
678 if (_simcrsServiceContext == NULL) {
679 throw stdair::NonInitialisedServiceException ("The SimCRS service "
680 "has not been initialised");
681 }
682 assert (_simcrsServiceContext != NULL);
683
684 // Retrieve the StdAir service object from the (SimCRS) service context
685 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
686 stdair::STDAIR_Service& lSTDAIR_Service =
687 lSIMCRS_ServiceContext.getSTDAIR_Service();
688
689 // Delegate the BOM building to the dedicated service
690 return lSTDAIR_Service.csvDisplay (ioTravelSolutionList);
691 }
692
693 // ////////////////////////////////////////////////////////////////////
695 list (const stdair::AirlineCode_T& iAirlineCode,
696 const stdair::FlightNumber_T& iFlightNumber) const {
697
698 // Retrieve the SimCRS service context
699 if (_simcrsServiceContext == NULL) {
700 throw stdair::NonInitialisedServiceException ("The SimCRS service has "
701 "not been initialised");
702 }
703 assert (_simcrsServiceContext != NULL);
704 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
705
706 // Retrieve the AIRINV Master service.
707 AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
708 lSIMCRS_ServiceContext.getAIRINV_Service();
709
710 // Delegate the BOM display to the dedicated service
711 return lAIRINV_Master_Service.list (iAirlineCode, iFlightNumber);
712 }
713
714 // ////////////////////////////////////////////////////////////////////
716 csvDisplay (const stdair::AirlineCode_T& iAirlineCode,
717 const stdair::FlightNumber_T& iFlightNumber,
718 const stdair::Date_T& iDepartureDate) const {
719
720 // Retrieve the SimCRS service context
721 if (_simcrsServiceContext == NULL) {
722 throw stdair::NonInitialisedServiceException ("The SimCRS service has "
723 "not been initialised");
724 }
725 assert (_simcrsServiceContext != NULL);
726 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
727
728 // Retrieve the AIRINV Master service.
729 AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
730 lSIMCRS_ServiceContext.getAIRINV_Service();
731
732 // Delegate the BOM display to the dedicated service
733 return lAIRINV_Master_Service.csvDisplay (iAirlineCode, iFlightNumber,
734 iDepartureDate);
735 }
736
737 // ////////////////////////////////////////////////////////////////////
738 stdair::TravelSolutionList_T SIMCRS_Service::
739 calculateSegmentPathList(const stdair::BookingRequestStruct& iBookingRequest){
740
741 // Retrieve the SimCRS service context
742 if (_simcrsServiceContext == NULL) {
743 throw stdair::NonInitialisedServiceException ("The SimCRS service "
744 "has not been initialised");
745 }
746 assert (_simcrsServiceContext != NULL);
747
748 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
749
750 stdair::TravelSolutionList_T oTravelSolutionList;
751
752 // Get a reference on the AIRTSP service handler
753 AIRTSP::AIRTSP_Service& lAIRTSP_Service =
754 lSIMCRS_ServiceContext.getAIRTSP_Service();
755
756 // Delegate the booking to the dedicated service
757 stdair::BasChronometer lTravelSolutionRetrievingChronometer;
758 lTravelSolutionRetrievingChronometer.start();
759
760 lAIRTSP_Service.buildSegmentPathList (oTravelSolutionList,
761 iBookingRequest);
762
763 // DEBUG
764 const double lSegmentPathRetrievingMeasure =
765 lTravelSolutionRetrievingChronometer.elapsed();
766 STDAIR_LOG_DEBUG ("Travel solution retrieving: "
767 << lSegmentPathRetrievingMeasure << " - "
768 << lSIMCRS_ServiceContext.display());
769
770 return oTravelSolutionList;
771 }
772
773 // ////////////////////////////////////////////////////////////////////
775 fareQuote (const stdair::BookingRequestStruct& iBookingRequest,
776 stdair::TravelSolutionList_T& ioTravelSolutionList) {
777
778 // Retrieve the SimCRS service context
779 if (_simcrsServiceContext == NULL) {
780 throw stdair::NonInitialisedServiceException ("The SimCRS service has "
781 "not been initialised");
782 }
783 assert (_simcrsServiceContext != NULL);
784
785 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
786
787 // Get a reference on the SIMFQT service handler
788 SIMFQT::SIMFQT_Service& lSIMFQT_Service =
789 lSIMCRS_ServiceContext.getSIMFQT_Service();
790
791 // Delegate the action to the dedicated command
792 stdair::BasChronometer lFareQuoteRetrievalChronometer;
793 lFareQuoteRetrievalChronometer.start();
794
795 lSIMFQT_Service.quotePrices (iBookingRequest, ioTravelSolutionList);
796
797 // DEBUG
798 const double lFareQuoteRetrievalMeasure =
799 lFareQuoteRetrievalChronometer.elapsed();
800 STDAIR_LOG_DEBUG ("Fare Quote retrieving: " << lFareQuoteRetrievalMeasure
801 << " - " << lSIMCRS_ServiceContext.display());
802 }
803
804 // ////////////////////////////////////////////////////////////////////
806 calculateAvailability (stdair::TravelSolutionList_T& ioTravelSolutionList) {
807
808 // Retrieve the SimCRS service context
809 if (_simcrsServiceContext == NULL) {
810 throw stdair::NonInitialisedServiceException ("The SimCRS service has "
811 "not been initialised");
812 }
813 assert (_simcrsServiceContext != NULL);
814
815 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
816
817 // Retrieve the CRS code
818 //const CRSCode_T& lCRSCode = lSIMCRS_ServiceContext.getCRSCode();
819
820 // Retrieve the AIRINV Master service.
821 AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
822 lSIMCRS_ServiceContext.getAIRINV_Service();
823
824 // Delegate the availability retrieval to the dedicated command
825 stdair::BasChronometer lAvlChronometer;
826 lAvlChronometer.start();
827
828 DistributionManager::calculateAvailability (lAIRINV_Master_Service,
829 ioTravelSolutionList);
830
831 // DEBUG
832 const double lAvlMeasure = lAvlChronometer.elapsed();
833 STDAIR_LOG_DEBUG ("Availability retrieval: " << lAvlMeasure << " - "
834 << lSIMCRS_ServiceContext.display());
835 }
836
837 // ////////////////////////////////////////////////////////////////////
839 sell (const stdair::TravelSolutionStruct& iTravelSolution,
840 const stdair::PartySize_T& iPartySize) {
841 bool hasSaleBeenSuccessful = false;
842
843 // Retrieve the SimCRS service context
844 if (_simcrsServiceContext == NULL) {
845 throw stdair::NonInitialisedServiceException ("The SimCRS service has "
846 "not been initialised");
847 }
848 assert (_simcrsServiceContext != NULL);
849
850 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
851
852 // Retrieve the CRS code
853 //const CRSCode_T& lCRSCode = lSIMCRS_ServiceContext.getCRSCode();
854
855 // Retrieve the AIRINV Master service.
856 AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
857 lSIMCRS_ServiceContext.getAIRINV_Service();
858
859 // Delegate the booking to the dedicated command
860 stdair::BasChronometer lSellChronometer;
861 lSellChronometer.start();
862
863 hasSaleBeenSuccessful = DistributionManager::sell (lAIRINV_Master_Service,
864 iTravelSolution,
865 iPartySize);
866
867 // DEBUG
868 STDAIR_LOG_DEBUG ("Made a sell of " << iPartySize
869 << " persons on the following travel solution: "
870 << iTravelSolution.describe()
871 << " with the chosen fare option: "
872 << iTravelSolution.getChosenFareOption().describe()
873 << ". Successful? " << hasSaleBeenSuccessful);
874
875 // DEBUG
876 const double lSellMeasure = lSellChronometer.elapsed();
877 STDAIR_LOG_DEBUG ("Booking sell: " << lSellMeasure << " - "
878 << lSIMCRS_ServiceContext.display());
879
880 return hasSaleBeenSuccessful;
881 }
882
883
884 // ////////////////////////////////////////////////////////////////////
886 playCancellation (const stdair::CancellationStruct& iCancellation) {
887 bool hasCancellationBeenSuccessful = false;
888
889 // Retrieve the SimCRS service context
890 if (_simcrsServiceContext == NULL) {
891 throw stdair::NonInitialisedServiceException ("The SimCRS service has "
892 "not been initialised");
893 }
894 assert (_simcrsServiceContext != NULL);
895
896 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
897
898 // Retrieve the CRS code
899 //const CRSCode_T& lCRSCode = lSIMCRS_ServiceContext.getCRSCode();
900
901 // Retrieve the AIRINV Master service.
902 AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
903 lSIMCRS_ServiceContext.getAIRINV_Service();
904
905 // Delegate the booking to the dedicated command
906 stdair::BasChronometer lCancellationChronometer;
907 lCancellationChronometer.start();
908
909 hasCancellationBeenSuccessful =
910 DistributionManager::playCancellation (lAIRINV_Master_Service,
911 iCancellation);
912
913 // DEBUG
914 STDAIR_LOG_DEBUG ("Made a cancellation of " << iCancellation.describe());
915
916 // DEBUG
917 const double lCancellationMeasure = lCancellationChronometer.elapsed();
918 STDAIR_LOG_DEBUG ("Booking cancellation: " << lCancellationMeasure << " - "
919 << lSIMCRS_ServiceContext.display());
920
921 return hasCancellationBeenSuccessful;
922 }
923
924 // ////////////////////////////////////////////////////////////////////
925 void SIMCRS_Service::takeSnapshots (const stdair::SnapshotStruct& iSnapshot) {
926
927 // Retrieve the SimCRS service context
928 if (_simcrsServiceContext == NULL) {
929 throw stdair::NonInitialisedServiceException ("The SimCRS service has "
930 "not been initialised");
931 }
932 assert (_simcrsServiceContext != NULL);
933 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
934
935 // Retrieve the AIRINV Master service.
936 AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
937 lSIMCRS_ServiceContext.getAIRINV_Service();
938
939 lAIRINV_Master_Service.takeSnapshots (iSnapshot);
940 }
941
942 // ////////////////////////////////////////////////////////////////////
944 optimise (const stdair::RMEventStruct& iRMEvent) {
945
946 // Retrieve the SimCRS service context
947 if (_simcrsServiceContext == NULL) {
948 throw stdair::NonInitialisedServiceException ("The SimCRS service has "
949 "not been initialised");
950 }
951 assert (_simcrsServiceContext != NULL);
952 SIMCRS_ServiceContext& lSIMCRS_ServiceContext = *_simcrsServiceContext;
953
954 // Retrieve the AIRINV Master service.
955 AIRINV::AIRINV_Master_Service& lAIRINV_Master_Service =
956 lSIMCRS_ServiceContext.getAIRINV_Service();
957
958 lAIRINV_Master_Service.optimise (iRMEvent);
959 }
960}
SIMCRS_ServiceContext & create(const std::string &iTravelDatabaseName)
static FacSimcrsServiceContext & instance()
Class holding the context of the Simcrs services.
void parseAndLoad(const stdair::ScheduleFilePath &, const stdair::ODFilePath &, const stdair::FRAT5FilePath &, const stdair::FFDisutilityFilePath &, const AIRRAC::YieldFilePath &, const SIMFQT::FareFilePath &)
bool sell(const stdair::TravelSolutionStruct &, const stdair::PartySize_T &)
void initSnapshotAndRMEvents(const stdair::Date_T &iStartDate, const stdair::Date_T &iEndDate)
void takeSnapshots(const stdair::SnapshotStruct &)
void buildComplementaryLinks(stdair::BomRoot &)
std::string list(const stdair::AirlineCode_T &iAirlineCode="all", const stdair::FlightNumber_T &iFlightNumber=0) const
std::string csvDisplay() const
void optimise(const stdair::RMEventStruct &)
stdair::TravelSolutionList_T calculateSegmentPathList(const stdair::BookingRequestStruct &)
void buildSampleTravelSolutions(stdair::TravelSolutionList_T &)
std::string jsonHandler(const stdair::JSONString &) const
void fareQuote(const stdair::BookingRequestStruct &, stdair::TravelSolutionList_T &)
bool playCancellation(const stdair::CancellationStruct &)
void calculateAvailability(stdair::TravelSolutionList_T &)
stdair::BookingRequestStruct buildSampleBookingRequest(const bool isForCRS=false)
std::string CRSCode_T