GCBM
cbmaggregatorlibpqxxwriter.h
Go to the documentation of this file.
1 #ifndef MOJA_MODULES_CBM_CBMAGGREGATORLIBPQXXWRITER_H_
2 #define MOJA_MODULES_CBM_CBMAGGREGATORLIBPQXXWRITER_H_
3 
4 #include "moja/modules/cbm/_modules.cbm_exports.h"
7 
8 #include <moja/flint/spatiallocationinfo.h>
9 
10 #include <pqxx/pqxx>
11 #include <vector>
12 
13 namespace moja {
14 namespace flint {
15  template<class TPersistable, class TRecord>
16  class RecordAccumulatorWithMutex2;
17 }
18 
19 namespace modules {
20 namespace cbm {
21 
22  class CBM_API CBMAggregatorLibPQXXWriter : public CBMModuleBase {
23  public:
30  std::shared_ptr<std::vector<std::string>> classifierNames,
31  bool isPrimary = false)
32  : CBMModuleBase(),
33  _fluxDimension(fluxDimension),
34  _poolDimension(poolDimension),
35  _errorDimension(errorDimension),
36  _ageDimension(ageDimension),
37  _disturbanceDimension(disturbanceDimension),
38  _classifierNames(classifierNames),
39  _isPrimaryAggregator(isPrimary),
40  _dropSchema(true) {}
41 
42  virtual ~CBMAggregatorLibPQXXWriter() = default;
43 
44  void configure(const DynamicObject& config) override;
45  void subscribe(NotificationCenter& notificationCenter) override;
46 
47  flint::ModuleTypes moduleType() override { return flint::ModuleTypes::System; };
48 
49  void doSystemInit() override;
50  void doLocalDomainInit() override;
51  void doSystemShutdown() override;
52 
53  private:
54  std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatFluxRecord>> _fluxDimension;
55  std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatPoolRecord>> _poolDimension;
56  std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatErrorRecord>> _errorDimension;
57  std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatAgeAreaRecord>> _ageDimension;
58  std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatDisturbanceRecord>> _disturbanceDimension;
59  std::shared_ptr<std::vector<std::string>> _classifierNames;
60 
61  std::shared_ptr<const flint::SpatialLocationInfo> _spatialLocationInfo;
62 
63  std::string _connectionString;
64  std::string _schema;
65  Int64 _jobId;
68 
69  template<typename TAccumulator>
70  void load(pqxx::work& tx,
71  Int64 jobId,
72  const std::string& table,
73  std::shared_ptr<TAccumulator> dataDimension);
74 
75  void doIsolated(pqxx::connection_base& conn, std::string sql, bool optional = false);
76  void doIsolated(pqxx::connection_base& conn, std::vector<std::string> sql, bool optional = false);
77  };
78 
79 }}} // namespace moja::modules::cbm
80 
81 #endif // MOJA_MODULES_CBM_CBMAGGREGATORLIBPQXXWRITER_H_
moja::modules::cbm
Definition: ageclasshelper.cpp:12
flatrecord.h
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_connectionString
std::string _connectionString
Definition: cbmaggregatorlibpqxxwriter.h:63
moja::flint::RecordAccumulatorWithMutex2
Definition: cbmaggregatorcsvwriter.h:21
moja::modules::cbm::CBMModuleBase
Definition: cbmmodulebase.h:22
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_spatialLocationInfo
std::shared_ptr< const flint::SpatialLocationInfo > _spatialLocationInfo
Definition: cbmaggregatorlibpqxxwriter.h:61
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_disturbanceDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatDisturbanceRecord > > _disturbanceDimension
Definition: cbmaggregatorlibpqxxwriter.h:58
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_jobId
Int64 _jobId
Definition: cbmaggregatorlibpqxxwriter.h:65
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_ageDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatAgeAreaRecord > > _ageDimension
Definition: cbmaggregatorlibpqxxwriter.h:57
moja::modules::cbm::CBMAggregatorLibPQXXWriter
Definition: cbmaggregatorlibpqxxwriter.h:22
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_isPrimaryAggregator
bool _isPrimaryAggregator
Definition: cbmaggregatorlibpqxxwriter.h:66
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_fluxDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatFluxRecord > > _fluxDimension
Definition: cbmaggregatorlibpqxxwriter.h:54
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_classifierNames
std::shared_ptr< std::vector< std::string > > _classifierNames
Definition: cbmaggregatorlibpqxxwriter.h:59
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_schema
std::string _schema
Definition: cbmaggregatorlibpqxxwriter.h:64
moja::flint
Definition: cbmaggregatorcsvwriter.h:19
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_errorDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatErrorRecord > > _errorDimension
Definition: cbmaggregatorlibpqxxwriter.h:56
moja::modules::cbm::CBMAggregatorLibPQXXWriter::CBMAggregatorLibPQXXWriter
CBMAggregatorLibPQXXWriter(std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatFluxRecord >> fluxDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatPoolRecord >> poolDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatErrorRecord >> errorDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatAgeAreaRecord >> ageDimension, std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatDisturbanceRecord >> disturbanceDimension, std::shared_ptr< std::vector< std::string >> classifierNames, bool isPrimary=false)
Definition: cbmaggregatorlibpqxxwriter.h:24
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_dropSchema
bool _dropSchema
Definition: cbmaggregatorlibpqxxwriter.h:67
moja::modules::cbm::CBMAggregatorLibPQXXWriter::moduleType
flint::ModuleTypes moduleType() override
Definition: cbmaggregatorlibpqxxwriter.h:47
moja::modules::cbm::CBMAggregatorLibPQXXWriter::_poolDimension
std::shared_ptr< flint::RecordAccumulatorWithMutex2< std::string, FlatPoolRecord > > _poolDimension
Definition: cbmaggregatorlibpqxxwriter.h:55
moja
Definition: ageclasshelper.cpp:10
cbmmodulebase.h