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

#include <growthcurvetransform.h>

Inherits ITransform.

Collaboration diagram for GrowthCurveTransform:
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
 
const std::string buildDebuggingInfo (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

◆ buildDebuggingInfo()

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

Return all the classifier names and values in parameter classifierSet, in the format classifierName : classifierValue, separated by a ","

Parameters
classifierSetconst DynamicObject&
Returns
string

◆ buildSql()

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

Replace the placeholder values in SQL queries GrowthCurveTransform._baseSql, GrowthCurveTransform._matchSql

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 GrowthCurveTransform._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 GrowthCurveTransform._baseSql with placeholders classifierNamesSql and classifierValuesSql

Parameters
classifierSetconst DynamicObject&
Returns
string

◆ configure()

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

Assign GrowthCurveTransform._landUnitController, GrowthCurveTransform._dataRepository as parameters &landUnitController, &dataRepository
GrowthCurveTransform._provider, GrowthCurveTransform._csetVar value of "provider", "classifier_set_var" in parameter config

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

◆ controllerChanged()

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

Assign GrowthCurveTransform._landUnitController as parameter &controller

Parameters
controllerconst flint::ILandUnitController&
Returns
void

◆ value()

const DynamicVar & value ( ) const
override

If value of GrowthCurveTransform._csetVar is empty assign GrowthCurveTransform._value as DynamicObject() and return GrowthCurveTransform._value
Extract DynamicObject from the value of GrowthCurveTransform._csetVar and store it in variable cset
Assign variable sql, the result of GrowthCurveTransform.buildSql() on argument cset
If sql has a null value in GrowthCurveTransform._cache, return a pointer to the result
If the result of GetDataSet() on GrowthCurveTransform._provider with argument sql has a size > 0, add sql, and "growth_curve_id" at index 0 of the result to GrowthCurveTransform._cache,
else add sql, and a variable of type DynamicVar to GrowthCurveTransform._cache, indicate an error and invoke GrowthCurveTransform.buildDebuggingInfo() with argument cset
Return a pointer to the value of sql in GrowthCurveTransform._cache

Returns
const DynamicVar&

Member Data Documentation

◆ _baseSql

const std::string _baseSql
private
Initial value:
= R"(
SELECT growth_curve_id
FROM (
SELECT
gccv.growth_curve_id AS growth_curve_id,
SUM(CASE
WHEN c.name IN (%1%) THEN
CASE
WHEN cv.value LIKE '?' THEN 1
%2%
ELSE -1000
END
ELSE -1000
END
) AS score
FROM growth_curve_classifier_value gccv
INNER JOIN classifier_value cv
ON gccv.classifier_value_id = cv.id
INNER JOIN classifier c
ON cv.classifier_id = c.id
GROUP BY gccv.growth_curve_id
) AS growth_curve_ranking
WHERE score > 0
ORDER BY score DESC
LIMIT 1
)"

◆ _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: