GCBM
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CBMAggregatorLibPQXXWriter Class Reference

#include <cbmaggregatorlibpqxxwriter.h>

Inheritance diagram for CBMAggregatorLibPQXXWriter:
Inheritance graph
Collaboration diagram for CBMAggregatorLibPQXXWriter:
Collaboration graph

Public Member Functions

 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)
 
virtual ~CBMAggregatorLibPQXXWriter ()=default
 
void configure (const DynamicObject &config) override
 
void subscribe (NotificationCenter &notificationCenter) override
 
flint::ModuleTypes moduleType () override
 
void doSystemInit () override
 
void doLocalDomainInit () override
 
void doSystemShutdown () override
 
- Public Member Functions inherited from CBMModuleBase
virtual ~CBMModuleBase ()=default
 
void onSystemInit () override
 
void onSystemShutdown () override
 
void onLocalDomainInit () override
 
void onLocalDomainShutdown () override
 
void onLocalDomainProcessingUnitInit () override
 
void onLocalDomainProcessingUnitShutdown () override
 
void onPreTimingSequence () override
 
void onTimingInit () override
 
void onTimingPrePostInit () override
 
void onTimingPostInit () override
 
void onTimingPostInit2 () override
 
void onTimingShutdown () override
 
void onTimingStep () override
 
void onTimingPreEndStep () override
 
void onTimingEndStep () override
 
void onTimingPostStep () override
 
void onOutputStep () override
 
void onPrePostDisturbanceEvent () override
 
void onPostDisturbanceEvent () override
 
void onPostDisturbanceEvent2 () override
 
void onError (std::string msg) override
 
void onDisturbanceEvent (DynamicVar e) override
 
void onPostNotification (short preMessageSignal) override
 
virtual void doLocalDomainShutdown ()
 
virtual void doLocalDomainProcessingUnitInit ()
 
virtual void doLocalDomainProcessingUnitShutdown ()
 
virtual void doPreTimingSequence ()
 
virtual void doTimingInit ()
 
virtual void doTimingPrePostInit ()
 
virtual void doTimingPostInit ()
 
virtual void doTimingPostInit2 ()
 
virtual void doTimingShutdown ()
 
virtual void doTimingStep ()
 
virtual void doTimingPreEndStep ()
 
virtual void doTimingEndStep ()
 
virtual void doTimingPostStep ()
 
virtual void doOutputStep ()
 
virtual void doError (std::string msg)
 
virtual void doDisturbanceEvent (DynamicVar)
 
virtual void doPrePostDisturbanceEvent ()
 
virtual void doPostDisturbanceEvent ()
 
virtual void doPostDisturbanceEvent2 ()
 
virtual void doPostNotification (short preMessageSignal)
 

Private Member Functions

template<typename TAccumulator >
void load (pqxx::work &tx, Int64 jobId, const std::string &table, std::shared_ptr< TAccumulator > dataDimension)
 
void doIsolated (pqxx::connection_base &conn, std::string sql, bool optional=false)
 
void doIsolated (pqxx::connection_base &conn, std::vector< std::string > sql, bool optional=false)
 

Private Attributes

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
 
std::shared_ptr< const flint::SpatialLocationInfo > _spatialLocationInfo
 
std::string _connectionString
 
std::string _schema
 
Int64 _jobId
 
bool _isPrimaryAggregator
 
bool _dropSchema
 

Constructor & Destructor Documentation

◆ 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 
)

◆ ~CBMAggregatorLibPQXXWriter()

virtual ~CBMAggregatorLibPQXXWriter ( )
virtualdefault

Member Function Documentation

◆ configure()

void configure ( const DynamicObject &  config)
override

Configuration function

Assign CBMAggregatorLibPQXXWriter._connectionString as variable "connection_string" in parameter config,
CBMAggregatorLibPQXXWriter._schema as variable "schema" in parameter config,
If parameter config has "drop_schema", assign it to CBMAggregatorLibPQXXWriter._dropSchema

Parameters
configDynamicObject&
Returns
void

◆ doIsolated() [1/2]

void doIsolated ( pqxx::connection_base &  conn,
std::string  sql,
bool  optional = false 
)
private

Perform a single transaction using SQL commands (Overloaded function)

Parameters
connconnection_base&
sqlstring
optionalbool
Returns
void

◆ doIsolated() [2/2]

void doIsolated ( pqxx::connection_base &  conn,
std::vector< std::string >  sql,
bool  optional = false 
)
private

Perform transactions using SQL commands (Overloaded function)

Parameters
connconnection_base&
sqlvector<string>
optionalbool
Returns
void

◆ doLocalDomainInit()

void doLocalDomainInit ( )
overridevirtual

Initiate Local Domain

Assign CBMAggregatorLibPQXXWriter._jobId the value of variable "job_id" in _landUnitData,
if it exists, else to 0

Returns
void

Reimplemented from CBMModuleBase.

◆ doSystemInit()

void doSystemInit ( )
overridevirtual

◆ doSystemShutdown()

void doSystemShutdown ( )
overridevirtual

doSystemShutDown

If CBMAggregatorLibPQXXWriter._isPrimaryAggregator is true, create unlogged tables for the DateDimension, LandClassDimension,
PoolDimension, ClassifierSetDimension, ModuleInfoDimension, LocationDimension, DisturbanceTypeDimension, 
DisturbanceDimension, Pools, Fluxes, ErrorDimension, AgeClassDimension, LocationErrorDimension,
and AgeArea if they do not already exist, and load data into tables on PostgreSQL

Returns
void

Reimplemented from CBMModuleBase.

◆ load()

void load ( pqxx::work &  tx,
Int64  jobId,
const std::string &  table,
std::shared_ptr< TAccumulator >  dataDimension 
)
private

Load each record in paramter dataDimension into table (table name is based on parameter table and jobId)

Parameters
txwork&
jobIdInt64
tablestring
dataDimensionshared_ptr<TAccumulator>
Returns
void

◆ moduleType()

flint::ModuleTypes moduleType ( )
override

◆ subscribe()

void subscribe ( NotificationCenter &  notificationCenter)
override

Subscribes to the signals SystemInit, LocalDomainInit and SystemShutDown

Parameters
notificationCenterNotificationCenter&
Returns
void

Member Data Documentation

◆ _ageDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatAgeAreaRecord> > _ageDimension
private

◆ _classifierNames

std::shared_ptr<std::vector<std::string> > _classifierNames
private

◆ _connectionString

std::string _connectionString
private

◆ _disturbanceDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatDisturbanceRecord> > _disturbanceDimension
private

◆ _dropSchema

bool _dropSchema
private

◆ _errorDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatErrorRecord> > _errorDimension
private

◆ _fluxDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatFluxRecord> > _fluxDimension
private

◆ _isPrimaryAggregator

bool _isPrimaryAggregator
private

◆ _jobId

Int64 _jobId
private

◆ _poolDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<std::string, FlatPoolRecord> > _poolDimension
private

◆ _schema

std::string _schema
private

◆ _spatialLocationInfo

std::shared_ptr<const flint::SpatialLocationInfo> _spatialLocationInfo
private

The documentation for this class was generated from the following files: