GCBM
cbmaggregatorsqlitewriter.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_CBMAGGREGATORSQLITEWRITER_H_
2 #define MOJA_MODULES_CBM_CBMAGGREGATORSQLITEWRITER_H_
3 
4 #include "moja/modules/cbm/_modules.cbm_exports.h"
7 
8 #include <Poco/Data/Session.h>
9 #include <vector>
10 
11 namespace moja {
12 namespace flint {
13  template<class TPersistable, class TRecord>
14  class RecordAccumulatorWithMutex2;
15 }
16 
17 namespace modules {
18 namespace cbm {
19 
20  class CBM_API CBMAggregatorSQLiteWriter : public CBMModuleBase {
21  public:
23  std::shared_ptr<flint::RecordAccumulatorWithMutex2<DateRow, DateRecord>> dateDimension,
24  std::shared_ptr<flint::RecordAccumulatorWithMutex2<PoolInfoRow, PoolInfoRecord>> poolInfoDimension,
31  std::shared_ptr<std::vector<std::string>> classifierNames,
32  std::shared_ptr<flint::RecordAccumulatorWithMutex2<PoolRow, PoolRecord>> poolDimension,
33  std::shared_ptr<flint::RecordAccumulatorWithMutex2<FluxRow, FluxRecord>> fluxDimension,
34  std::shared_ptr<flint::RecordAccumulatorWithMutex2<AgeClassRow, AgeClassRecord>> ageClassDimension,
35  std::shared_ptr<flint::RecordAccumulatorWithMutex2<AgeAreaRow, AgeAreaRecord>> ageAreaDimension,
36  std::shared_ptr<flint::RecordAccumulatorWithMutex2<ErrorRow, ErrorRecord>> errorDimension,
38  bool isPrimary = false)
39  : CBMModuleBase(),
40  _dateDimension(dateDimension),
41  _poolInfoDimension(poolInfoDimension),
42  _classifierSetDimension(classifierSetDimension),
43  _landClassDimension(landClassDimension),
44  _locationDimension(locationDimension),
45  _moduleInfoDimension(moduleInfoDimension),
46  _disturbanceTypeDimension(disturbanceTypeDimension),
47  _disturbanceDimension(disturbanceDimension),
48  _classifierNames(classifierNames),
49  _poolDimension(poolDimension),
50  _fluxDimension(fluxDimension),
51  _ageClassDimension(ageClassDimension),
52  _ageAreaDimension(ageAreaDimension),
53  _errorDimension(errorDimension),
54  _locationErrorDimension(locationErrorDimension),
55  _isPrimaryAggregator(isPrimary) {}
56 
57  virtual ~CBMAggregatorSQLiteWriter() = default;
58 
59  void configure(const DynamicObject& config) override;
60  void subscribe(NotificationCenter& notificationCenter) override;
61 
62  flint::ModuleTypes moduleType() override { return flint::ModuleTypes::System; };
63 
64  void doSystemInit() override;
65  void doSystemShutdown() override;
66 
67  private:
68  std::shared_ptr<flint::RecordAccumulatorWithMutex2<DateRow, DateRecord>> _dateDimension;
69  std::shared_ptr<flint::RecordAccumulatorWithMutex2<PoolInfoRow, PoolInfoRecord>> _poolInfoDimension;
70  std::shared_ptr<flint::RecordAccumulatorWithMutex2<ClassifierSetRow, ClassifierSetRecord>> _classifierSetDimension;
71  std::shared_ptr<flint::RecordAccumulatorWithMutex2<LandClassRow, LandClassRecord>> _landClassDimension;
72  std::shared_ptr<flint::RecordAccumulatorWithMutex2<TemporalLocationRow, TemporalLocationRecord>> _locationDimension;
73  std::shared_ptr<flint::RecordAccumulatorWithMutex2<ModuleInfoRow, ModuleInfoRecord>> _moduleInfoDimension;
74  std::shared_ptr<flint::RecordAccumulatorWithMutex2<PoolRow, PoolRecord>> _poolDimension;
75  std::shared_ptr<flint::RecordAccumulatorWithMutex2<FluxRow, FluxRecord>> _fluxDimension;
76  std::shared_ptr<flint::RecordAccumulatorWithMutex2<AgeClassRow, AgeClassRecord>> _ageClassDimension;
77  std::shared_ptr<flint::RecordAccumulatorWithMutex2<AgeAreaRow, AgeAreaRecord>> _ageAreaDimension;
78  std::shared_ptr<flint::RecordAccumulatorWithMutex2<DisturbanceTypeRow, DisturbanceTypeRecord>> _disturbanceTypeDimension;
79  std::shared_ptr<flint::RecordAccumulatorWithMutex2<DisturbanceRow, DisturbanceRecord>> _disturbanceDimension;
80  std::shared_ptr<flint::RecordAccumulatorWithMutex2<ErrorRow, ErrorRecord>> _errorDimension;
81  std::shared_ptr<flint::RecordAccumulatorWithMutex2<LocationErrorRow, LocationErrorRecord>> _locationErrorDimension;
82  std::shared_ptr<std::vector<std::string>> _classifierNames;
83 
84  std::string _dbName;
86 
87  template<typename TAccumulator>
88  void load(Poco::Data::Session& session,
89  const std::string& table,
90  std::shared_ptr<TAccumulator> dataDimension);
91 
92  static void tryExecute(Poco::Data::Session& session,
93  std::function<void(Poco::Data::Session&)> fn);
94  };
95 
96 }}} // namespace moja::modules::cbm
97 
98 #endif // MOJA_MODULES_CBM_CBMAGGREGATORSQLITEWRITER_H_
moja::modules::cbm::CBMAggregatorSQLiteWriter::_locationDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< TemporalLocationRow, TemporalLocationRecord > > _locationDimension
Definition: cbmaggregatorsqlitewriter.h:72
moja::modules::cbm
Definition: ageclasshelper.cpp:12
moja::modules::cbm::CBMAggregatorSQLiteWriter
Definition: cbmaggregatorsqlitewriter.h:20
moja::modules::cbm::CBMAggregatorSQLiteWriter::_errorDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< ErrorRow, ErrorRecord > > _errorDimension
Definition: cbmaggregatorsqlitewriter.h:80
moja::modules::cbm::CBMAggregatorSQLiteWriter::_poolDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< PoolRow, PoolRecord > > _poolDimension
Definition: cbmaggregatorsqlitewriter.h:74
moja::modules::cbm::CBMAggregatorSQLiteWriter::_poolInfoDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< PoolInfoRow, PoolInfoRecord > > _poolInfoDimension
Definition: cbmaggregatorsqlitewriter.h:69
moja::flint::RecordAccumulatorWithMutex2
Definition: cbmaggregatorcsvwriter.h:21
moja::modules::cbm::CBMModuleBase
Definition: cbmmodulebase.h:22
moja::modules::cbm::CBMAggregatorSQLiteWriter::_dateDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< DateRow, DateRecord > > _dateDimension
Definition: cbmaggregatorsqlitewriter.h:68
moja::modules::cbm::CBMAggregatorSQLiteWriter::_locationErrorDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< LocationErrorRow, LocationErrorRecord > > _locationErrorDimension
Definition: cbmaggregatorsqlitewriter.h:81
moja::modules::cbm::CBMAggregatorSQLiteWriter::_dbName
std::string _dbName
Definition: cbmaggregatorsqlitewriter.h:84
moja::modules::cbm::CBMAggregatorSQLiteWriter::CBMAggregatorSQLiteWriter
CBMAggregatorSQLiteWriter(std::shared_ptr< flint::RecordAccumulatorWithMutex2< DateRow, DateRecord >> dateDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< PoolInfoRow, PoolInfoRecord >> poolInfoDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< ClassifierSetRow, ClassifierSetRecord >> classifierSetDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< LandClassRow, LandClassRecord >> landClassDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< TemporalLocationRow, TemporalLocationRecord >> locationDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< ModuleInfoRow, ModuleInfoRecord >> moduleInfoDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< DisturbanceTypeRow, DisturbanceTypeRecord >> disturbanceTypeDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< DisturbanceRow, DisturbanceRecord >> disturbanceDimension, std::shared_ptr< std::vector< std::string >> classifierNames, std::shared_ptr< flint::RecordAccumulatorWithMutex2< PoolRow, PoolRecord >> poolDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< FluxRow, FluxRecord >> fluxDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< AgeClassRow, AgeClassRecord >> ageClassDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< AgeAreaRow, AgeAreaRecord >> ageAreaDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< ErrorRow, ErrorRecord >> errorDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< LocationErrorRow, LocationErrorRecord >> locationErrorDimension, bool isPrimary=false)
Definition: cbmaggregatorsqlitewriter.h:22
record.h
moja::modules::cbm::CBMAggregatorSQLiteWriter::_ageClassDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< AgeClassRow, AgeClassRecord > > _ageClassDimension
Definition: cbmaggregatorsqlitewriter.h:76
moja::flint
Definition: cbmaggregatorcsvwriter.h:19
moja::modules::cbm::CBMAggregatorSQLiteWriter::_classifierSetDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< ClassifierSetRow, ClassifierSetRecord > > _classifierSetDimension
Definition: cbmaggregatorsqlitewriter.h:70
moja::modules::cbm::CBMAggregatorSQLiteWriter::moduleType
flint::ModuleTypes moduleType() override
Definition: cbmaggregatorsqlitewriter.h:62
moja::modules::cbm::CBMAggregatorSQLiteWriter::_moduleInfoDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< ModuleInfoRow, ModuleInfoRecord > > _moduleInfoDimension
Definition: cbmaggregatorsqlitewriter.h:73
moja::modules::cbm::CBMAggregatorSQLiteWriter::_ageAreaDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< AgeAreaRow, AgeAreaRecord > > _ageAreaDimension
Definition: cbmaggregatorsqlitewriter.h:77
moja::modules::cbm::CBMAggregatorSQLiteWriter::_disturbanceDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< DisturbanceRow, DisturbanceRecord > > _disturbanceDimension
Definition: cbmaggregatorsqlitewriter.h:79
moja::modules::cbm::CBMAggregatorSQLiteWriter::_fluxDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< FluxRow, FluxRecord > > _fluxDimension
Definition: cbmaggregatorsqlitewriter.h:75
moja::modules::cbm::CBMAggregatorSQLiteWriter::_classifierNames
std::shared_ptr< std::vector< std::string > > _classifierNames
Definition: cbmaggregatorsqlitewriter.h:82
moja::modules::cbm::CBMAggregatorSQLiteWriter::_isPrimaryAggregator
bool _isPrimaryAggregator
Definition: cbmaggregatorsqlitewriter.h:85
moja
Definition: ageclasshelper.cpp:10
cbmmodulebase.h
moja::modules::cbm::CBMAggregatorSQLiteWriter::_landClassDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< LandClassRow, LandClassRecord > > _landClassDimension
Definition: cbmaggregatorsqlitewriter.h:71
moja::modules::cbm::CBMAggregatorSQLiteWriter::_disturbanceTypeDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< DisturbanceTypeRow, DisturbanceTypeRecord > > _disturbanceTypeDimension
Definition: cbmaggregatorsqlitewriter.h:78