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

#include <transitionruletransform.h>

Inherits ITransform.

Collaboration diagram for TransitionRuleTransform:
Collaboration graph

Public Member Functions

void configure (DynamicObject config, const flint::ILandUnitController &landUnitController, datarepository::DataRepository &dataRepository) override
 
void controllerChanged (const flint::ILandUnitController &controller) override
 
const DynamicVar & value () const override
 

Private Member Functions

const std::string buildSql (const DynamicObject &classifierSet) const
 

Private Attributes

const flint::ILandUnitController * _landUnitController
 
datarepository::DataRepository * _dataRepository
 
std::shared_ptr< datarepository::IProviderRelationalInterface > _provider
 
const flint::IVariable * _csetVar
 
DynamicVar _value
 
Poco::ThreadLocal< Poco::LRUCache< std::string, DynamicVar > > _cache
 
const std::string _baseSql
 
const std::string _matchSql = "WHEN c.name LIKE '%1%' AND cv.value LIKE '%2%' THEN 4 "
 

Member Function Documentation

◆ buildSql()

const std::string buildSql ( const DynamicObject &  classifierSet) const
private

Create variables classifierNames, a vector of strings and classifierValuesSql, a string
For each classifier in parameter classifierSet, append classifier.first to classifierNames, concatenate classifierValuesSql with the SQL query TransitionRuleTransform._matchSql, placeholder values clasifier.first and classifier.second (gives the classifier value) Assign a variable classifierNamesSql the join vector classifierNames, separated by ","
Return the SQL query TransitionRuleTransform._baseSql with placeholders classifierNamesSql and classifierValuesSql

Parameters
classifierSetconst DynamicObject&
Returns
string

◆ configure()

void configure ( DynamicObject  config,
const flint::ILandUnitController &  landUnitController,
datarepository::DataRepository &  dataRepository 
)
override

Configuration function

Assign TransitionRuleTransform._landUnitController, TransitionRuleTransform._dataRepository as parameters &landUnitController, &dataRepository, TransitionRuleTransform._provider the result of getProvider() on "provider" in config, TransitionRuleTransform._csetVar, value of "classifier_set_var" of config in TransitionRuleTransform._landUnitController

Parameters
configDynamicObject
landUnitControllerconst flint::ILandUnitController&
dataRepositorydatarepository::DataRepository&
Returns
void

◆ controllerChanged()

void controllerChanged ( const flint::ILandUnitController &  controller)
override

Assign TransitionRuleTransform._landUnitController as parameter &contoller

Parameters
controllerconst flint::ILandUnitController&
Returns
void

◆ value()

const DynamicVar & value ( ) const
override

If value of TransitionRuleTransform._csetVar is empty assign TransitionRuleTransform._value as DynamicObject() and return TransitionRuleTransform._value
Extract DynamicObject from the value of TransitionRuleTransform._csetVar and store it in variable cset
Assign variable sql, the result of TransitionRuleTransform.buildSql() on argument cset
If sql has a null value in TransitionRuleTransform._cache, assign TransitionRuleTransform._value, a pointer to the result and return TransitionRuleTransform._value
Create a variable disturbanceTypeTransitions
For each row in the result of GetDataSet() on TransitionRuleTransform._provider with argument sql, using row["disturbance_type"] as the key in disturbanceTypeTransitions, map it to row["transition_id"] Add (sql, disturbanceTypeTransitions) to TransitionRuleTransform._cache, assign TransitionRuleTransform._value as disturbanceTypeTransitions.
Return TransitionRuleTransform._value

Returns
const DynamicVar&

Member Data Documentation

◆ _baseSql

const std::string _baseSql
private

◆ _cache

Poco::ThreadLocal<Poco::LRUCache<std::string, DynamicVar> > _cache
mutableprivate

◆ _csetVar

const flint::IVariable* _csetVar
mutableprivate

◆ _dataRepository

datarepository::DataRepository* _dataRepository
private

◆ _landUnitController

const flint::ILandUnitController* _landUnitController
private

◆ _matchSql

const std::string _matchSql = "WHEN c.name LIKE '%1%' AND cv.value LIKE '%2%' THEN 4 "
private

◆ _provider

std::shared_ptr<datarepository::IProviderRelationalInterface> _provider
private

◆ _value

DynamicVar _value
mutableprivate

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