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

#include <cbmaggregatorpostgresqlwriter.h>

Inheritance diagram for CBMAggregatorPostgreSQLWriter:
Inheritance graph
Collaboration diagram for CBMAggregatorPostgreSQLWriter:
Collaboration graph

Public Member Functions

 CBMAggregatorPostgreSQLWriter (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)
 
virtual ~CBMAggregatorPostgreSQLWriter ()=default
 
void configure (const DynamicObject &config) override
 
void subscribe (NotificationCenter &notificationCenter) override
 
flint::ModuleTypes moduleType () override
 
void doSystemInit () 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 doLocalDomainInit ()
 
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 (Poco::Data::Session &session, Int64 jobId, const std::string &table, std::shared_ptr< TAccumulator > dataDimension)
 

Static Private Member Functions

static void tryExecute (Poco::Data::Session &session, std::function< void(Poco::Data::Session &)> fn)
 

Private Attributes

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< 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< DisturbanceTypeRow, DisturbanceTypeRecord > > _disturbanceTypeDimension
 
std::shared_ptr< flint::RecordAccumulatorWithMutex2< DisturbanceRow, DisturbanceRecord > > _disturbanceDimension
 
std::shared_ptr< flint::RecordAccumulatorWithMutex2< ErrorRow, ErrorRecord > > _errorDimension
 
std::shared_ptr< flint::RecordAccumulatorWithMutex2< LocationErrorRow, LocationErrorRecord > > _locationErrorDimension
 
std::shared_ptr< std::vector< std::string > > _classifierNames
 
std::shared_ptr< const flint::SpatialLocationInfo > _spatialLocationInfo
 
std::string _connectionString
 
std::string _schema
 
Int64 _schemaLock
 
Int64 _jobId
 
bool _isPrimaryAggregator
 
bool _dropSchema
 

Constructor & Destructor Documentation

◆ CBMAggregatorPostgreSQLWriter()

CBMAggregatorPostgreSQLWriter ( 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 
)

◆ ~CBMAggregatorPostgreSQLWriter()

virtual ~CBMAggregatorPostgreSQLWriter ( )
virtualdefault

Member Function Documentation

◆ configure()

void configure ( const DynamicObject &  config)
override

Configuration function Assign the CBMAggregatorPostgreSQLWriter._connectionString as value of "connection_string",
CBMAggregatorPostgreSQLWriter._schema as "schema" in parameter config If parameter config has "drop_schema", assign it to CBMAggregatorPostgreSQLWriter._dropSchema.

Parameters
configDynamicObject&
Returns
void

◆ doSystemInit()

void doSystemInit ( )
overridevirtual

If CBMAggregatorPostgreSQLWriter._isPrimaryAggregator is true, drop schema if it
already exists. Create schema if it does not exist

Returns
void

Reimplemented from CBMModuleBase.

◆ doSystemShutdown()

void doSystemShutdown ( )
overridevirtual

If CBMAggregatorPostgreSQLWriter._isPrimaryAggregator, creates 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 loads data into these tables on PostgreSQL.

Returns
void

Reimplemented from CBMModuleBase.

◆ load()

void load ( Poco::Data::Session &  session,
Int64  jobId,
const std::string &  table,
std::shared_ptr< TAccumulator >  dataDimension 
)
private

Load persistable collecton data into the table using SQL.

Parameters
sessionSession&
jobIdInt64
dataDimensionshared_ptr<TAccumulator>
Returns
void

◆ moduleType()

flint::ModuleTypes moduleType ( )
override

◆ subscribe()

void subscribe ( NotificationCenter &  notificationCenter)
override

Subscribe to the signals SystemInit and SystemShutdown

Parameters
notificationCenterNotificationCenter&
Returns
void

◆ tryExecute()

void tryExecute ( Poco::Data::Session &  session,
std::function< void(Poco::Data::Session &)>  fn 
)
staticprivate

Executes the session.

Parameters
sessionSession&
fnfunction<void(session&)>
Returns
void
Exceptions
AssertionViolationException&Handles any program error
StatementException&If the statement is invalid
ODBCException&Handles database error
invalidAccessException&
BindingException&
exception:Handleserror

Member Data Documentation

◆ _ageAreaDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<AgeAreaRow, AgeAreaRecord> > _ageAreaDimension
private

◆ _ageClassDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<AgeClassRow, AgeClassRecord> > _ageClassDimension
private

◆ _classifierNames

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

◆ _classifierSetDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<ClassifierSetRow, ClassifierSetRecord> > _classifierSetDimension
private

◆ _connectionString

std::string _connectionString
private

◆ _dateDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<DateRow, DateRecord> > _dateDimension
private

◆ _disturbanceDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<DisturbanceRow, DisturbanceRecord> > _disturbanceDimension
private

◆ _disturbanceTypeDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<DisturbanceTypeRow, DisturbanceTypeRecord> > _disturbanceTypeDimension
private

◆ _dropSchema

bool _dropSchema
private

◆ _errorDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<ErrorRow, ErrorRecord> > _errorDimension
private

◆ _fluxDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<FluxRow, FluxRecord> > _fluxDimension
private

◆ _isPrimaryAggregator

bool _isPrimaryAggregator
private

◆ _jobId

Int64 _jobId
private

◆ _landClassDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<LandClassRow, LandClassRecord> > _landClassDimension
private

◆ _locationDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<TemporalLocationRow, TemporalLocationRecord> > _locationDimension
private

◆ _locationErrorDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<LocationErrorRow, LocationErrorRecord> > _locationErrorDimension
private

◆ _moduleInfoDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<ModuleInfoRow, ModuleInfoRecord> > _moduleInfoDimension
private

◆ _poolDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<PoolRow, PoolRecord> > _poolDimension
private

◆ _poolInfoDimension

std::shared_ptr<flint::RecordAccumulatorWithMutex2<PoolInfoRow, PoolInfoRecord> > _poolInfoDimension
private

◆ _schema

std::string _schema
private

◆ _schemaLock

Int64 _schemaLock
private

◆ _spatialLocationInfo

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

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