class Data extends DatasetChild

This class allows the storage and retrieval of the attributes of a data item.

The Data object is where most of the information used by a simulator is stored:

  • User input
  • information from data sources
  • intermediate calculation data
  • information returned to the user.

The data item can have one of the following type:

  • date: a date stored in the d/m/Y format
  • boolean: the value of the data item can be true or false
  • number: a numeric data with decimal places
  • integer: a numeric value without decimal places.
  • text: a short text
  • textarea: a long text
  • money: a numeric data with decimal places. The value of the data will be displayed with the currency symbol
  • choice: the value of the data is chosen from a list of choices
  • multichoice: the values of the data are chosen from a list of choices
  • percent: a numeric data with decimal places. The display of the value of the data will be followed by the % symbol.
  • table: the data item has an associated Table object
  • department: a departement code
  • region: a region code
  • country: a country code

Properties

protected Simulator $simulator from DatasetChild
protected int $id from DatasetChild
protected string $name from DatasetChild
protected string $label from DatasetChild
protected string $description from DatasetChild
protected bool $error from DatasetChild
protected array $errorMessages from DatasetChild
protected bool $warning from DatasetChild
protected array $warningMessages from DatasetChild
protected bool $used from DatasetChild
private string $type
private string $min
private string $unparsedMin
private string $max
private string $unparsedMax
private string $default
private string $unit
private string $unparsedDefault
private int $round
private string $content
private string $source
private string $unparsedIndex
private string $index
private bool $memorize
private array $choices
private ChoiceSource $choiceSource
private Table $table
private string $value
private array $rulesDependency
private int $inputStepId

Methods

void
__construct(Simulator $simulator, int $id, string $name)

Constructor of class Data

getSimulator()

Returns the Simulator object that uses this dataset child

int
getId()

Returns the ID of this dataset child.

void
setId(int $id)

Sets the ID of this dataset child.

string
getName()

Returns the name of this dataset child.

void
setName(string $name)

Sets the name of this dataset child.

string
getLabel()

Returns the label of this dataset child.

void
setLabel(string $label)

Sets the label of this dataset child.

string
getDescription()

Returns the description of this dataset child.

void
setDescription(string $description)

Sets the description of this dataset child.

bool
isUsed()

Returns the state of use of this dataset child by the current simulation step

bool
getUsed()

Returns the state of use of this dataset child by the current simulation step

void
setUsed(bool $used)

Sets the state of use of this dataset child by the current simulation step

bool
isError()

Returns the error attribute of this dataset child

bool
getError()

Returns the error attribute of this dataset child

void
setError(bool $error)

Determines whether this dataset child has a issued error or not

array
getErrorMessages()

Returns the list of error messages.

void
setErrorMessages(array $errorMessages)

Sets the list of error messages.

void
addErrorMessage(string $errorMessage)

Adds a message to the list of error messages.

void
removeErrorMessage(int $index)

Removes a message from the list of error messages.

bool
isWarning()

Returns the warning attribute of this dataset child

bool
getWarning()

Returns the warning attribute of this dataset child

void
setWarning(bool $warning)

Determines whether this dataset child has a issued warning or not

array
getWarningMessages()

Returns the list of warning messages.

void
setWarningMessages(array $warningMessages)

Sets the list of warning messages.

void
addWarningMessage(string $warningMessage)

Adds a message to the list of warning messages.

void
removeWarningMessage(int $index)

Removes a message from the list of warning messages.

string
getClass()

Returns the class name of this dataset child. It's either "Data" or "DataGroup".

string
getType()

Returns the type of this data item

void
setType(string $type)

Sets the type of this data item

string
getMin()

Returns the minimum value of this data item

string
getPlainMin()

Returns the arithmetic expression used to calculate the minimum value of this data item where the ids (prefixed with #) of the data are replaced by their labels.

void
setMin(string $min)

Sets the minimum value of this data item

string
getUnparsedMin()

Returns the arithmetic expression used to calculate the minimum value of this data item.

void
setUnparsedMin(string $unparsedMin)

Sets the arithmetic expression used to calculate the minimum value of this data item.

string
getMax()

Returns the maximum value of this data item

string
getPlainMax()

Returns the arithmetic expression used to calculate the maximum value of this data item where the ids (prefixed with #) of the data are replaced by their labels.

void
setMax(string $max)

Sets the maximum value of this data item

string
getUnparsedMax()

Returns the arithmetic expression used to calculate the minimum value of this data item.

void
setUnparsedMax(string $unparsedMax)

Sets the arithmetic expression used to calculate the minimum value of this data item.

string
getDefault()

Returns the default value of this data item

string
getPlainDefault()

Returns the arithmetic expression used to calculate the default value of this data item where the ids (prefixed with #) of the data are replaced by their labels.

void
setDefault(string $default)

Sets the default value of this data item

string
getUnparsedDefault()

Returns the arithmetic expression used to calculate the default value of this data item.

void
setUnparsedDefault(string $unparsedDefault)

Sets the arithmetic expression used to calculate the default value of this data item.

string
getUnit()

Returns the unit (measurement) text of this data item.

void
setUnit(string $unit)

Sets the unit(measurement) text of this data item.

int
getRound()

Returns the number of decimal places for this data item.

void
setRound(int $round)

Sets the number of decimal places for this data item. The last digit of the value of the data will be rounded to the nearest integer.

string
getContent()

Returns the arithmetic expression used to calculate the current value of this data item.

string
getPlainContent()

Returns the arithmetic expression used to calculate the value of this data item where the ids (prefixed with #) of the data are replaced by their labels.

void
setContent(string $content)

Sets the arithmetic expression used to calculate the value of this data item.

string
getSource()

Returns the id of the source if this data item is filled with the result of a query on a data source

string
getPlainSource() deprecated

Returns the arithmetic expression used to calculate the id of the source where the ids (prefixed with #) of the data are replaced by their labels.

void
setSource(string $source)

Sets the id of the source if this data item is filled with the result of a query on a data source

string
getIndex()

Returns the key of the associative array of the result if this data item is filled with the result of a query on a data source

string
getPlainIndex()

Returns the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source. The ids (prefixed with #) of the data are replaced by their labels.

void
setIndex(string $index)

Sets the key of the associative array of the result if this data item is filled with the result of a query on a data source

string
getUnparsedIndex()

Returns the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source.

void
setUnparsedIndex(string $unparsedIndex)

Sets the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source.

bool
isMemorize()

Retrieves the memorize attribute of this data item.

bool
getMemorize()

Returns the memorize attribute of this data item.

void
setMemorize(bool $memorize)

Determines whether the value of this data should be stored in a cookie in the user's browser or not.

array
getChoices()

Returns the list of Choice Objects of this data item.

string
getChoiceLabel()

Returns the label of the choice corresponding to the current value of this data item.

string
getChoiceLabelByValue(string $avalue)

Retrieves the label of a choice by its value from the list of choices associated with that data item.

void
setChoices(array $choices)

Sets the list of Choice Objects of this data item.

void
addChoice(Choice $choice)

Adds a Choice object in the list of choices of this data item.

Choice|null
getChoiceById(int $id)

Retrieves a Choice object by its id in the list of choices of this data item.

getChoiceSource()

Returns the ChoiceSource object if the type of this data is "choice" or "multichoice" and the list of choices is made with the result of a query on a data source.

void
setChoiceSource(ChoiceSource $choiceSource)

Sets the ChoiceSource object if the type of this data is "choice" or "multichoice" and the list of choices is made with the result of a query on a data source.

getTable()

Returns the Table object associated with this data item if the type of this data is "table".

void
setTable(Table $table)

Returns the Table object associated with this data item if the type of this data is "table".

string
getValue()

Retrieves the current value of this data item

string
getPlainValue()

Returns the current value of this data item in a string

void
setValue(string $value)

Sets the current value of this data item

int
getInputStepId()

Retrieves the id of the step where the user enters the value of this data item

void
setInputStepId(int $inputStepId)

Sets the id of the step where the user enters the value of this data item

array
getRulesDependency()

Returns the list of business rules that use this data item

void
setRulesDependency(array $rulesDependency)

Sets the list of business rules that use this data item

void
addRuleDependency(int $ruleId)

Adds a business rule id to the list of business rules that use this data item

void
removeRuleDependency(int $index)

Removes a business rule id from the list of business rules that use this data item

bool
check()

Checks the value of this data item according to its type

string
replaceIdByDataLabel(array $matches)

Returns the label of the data item whose identifier is the first element of the given array. The argument is an array because this method is the callback function of a preg_replace_callback.

string
replaceByDataLabel(string $target)

Replaces all data id (prefixed with #) by its label in the given text

Details

at line 234
void __construct(Simulator $simulator, int $id, string $name)

Constructor of class Data

Parameters

Simulator $simulator The Simulator object that uses this dataset child.
int $id The ID of this dataset child.
string $name The name of this dataset child.

Return Value

void

in DatasetChild at line 144
Simulator getSimulator()

Returns the Simulator object that uses this dataset child

Return Value

Simulator The Simulator object

in DatasetChild at line 155
int getId()

Returns the ID of this dataset child.

Return Value

int The ID of this dataset child.

in DatasetChild at line 167
void setId(int $id)

Sets the ID of this dataset child.

Parameters

int $id The ID of this dataset child.

Return Value

void

in DatasetChild at line 178
string getName()

Returns the name of this dataset child.

Return Value

string The name of this dataset child.

in DatasetChild at line 190
void setName(string $name)

Sets the name of this dataset child.

Parameters

string $name The name of this dataset child.

Return Value

void

in DatasetChild at line 201
string getLabel()

Returns the label of this dataset child.

Return Value

string The label of this dataset child.

in DatasetChild at line 213
void setLabel(string $label)

Sets the label of this dataset child.

Parameters

string $label The label of this dataset child.

Return Value

void

in DatasetChild at line 224
string getDescription()

Returns the description of this dataset child.

Return Value

string The description of this dataset child.

in DatasetChild at line 236
void setDescription(string $description)

Sets the description of this dataset child.

Parameters

string $description The description of this dataset child.

Return Value

void

in DatasetChild at line 247
bool isUsed()

Returns the state of use of this dataset child by the current simulation step

Return Value

bool true if this dataset child is used (displayed) by the current simulation step, false otherwise

in DatasetChild at line 258
bool getUsed()

Returns the state of use of this dataset child by the current simulation step

Return Value

bool true if this dataset child is used (displayed) by the current simulation step, false otherwise

in DatasetChild at line 270
void setUsed(bool $used)

Sets the state of use of this dataset child by the current simulation step

Parameters

bool $used true if this dataset child is used (displayed) by the current simulation step, false otherwise

Return Value

void

in DatasetChild at line 281
bool isError()

Returns the error attribute of this dataset child

Return Value

bool true if an error was occured, false if not

in DatasetChild at line 292
bool getError()

Returns the error attribute of this dataset child

Return Value

bool true if an error was occured, false if not

in DatasetChild at line 304
void setError(bool $error)

Determines whether this dataset child has a issued error or not

Parameters

bool $error true if this dataset child has a issued error, false otherwise

Return Value

void

in DatasetChild at line 315
array getErrorMessages()

Returns the list of error messages.

Return Value

array The list of error messages

in DatasetChild at line 327
void setErrorMessages(array $errorMessages)

Sets the list of error messages.

Parameters

array $errorMessages The list of error messages

Return Value

void

in DatasetChild at line 339
void addErrorMessage(string $errorMessage)

Adds a message to the list of error messages.

Parameters

string $errorMessage The message to add

Return Value

void

in DatasetChild at line 353
void removeErrorMessage(int $index)

Removes a message from the list of error messages.

Parameters

int $index The index of the message in the list of error messages

Return Value

void

in DatasetChild at line 364
bool isWarning()

Returns the warning attribute of this dataset child

Return Value

bool true if an warning was issued, false if not

in DatasetChild at line 375
bool getWarning()

Returns the warning attribute of this dataset child

Return Value

bool true if an warning was issued, false if not

in DatasetChild at line 387
void setWarning(bool $warning)

Determines whether this dataset child has a issued warning or not

Parameters

bool $warning true if this dataset child has a issued warning, false otherwise

Return Value

void

in DatasetChild at line 398
array getWarningMessages()

Returns the list of warning messages.

Return Value

array The list of warning messages.

in DatasetChild at line 410
void setWarningMessages(array $warningMessages)

Sets the list of warning messages.

Parameters

array $warningMessages The list of warning messages.

Return Value

void

in DatasetChild at line 422
void addWarningMessage(string $warningMessage)

Adds a message to the list of warning messages.

Parameters

string $warningMessage The message to add.

Return Value

void

in DatasetChild at line 436
void removeWarningMessage(int $index)

Removes a message from the list of warning messages.

Parameters

int $index The index of the message in the list of warning messages

Return Value

void

in DatasetChild at line 447
string getClass()

Returns the class name of this dataset child. It's either "Data" or "DataGroup".

Return Value

string The class name

at line 245
string getType()

Returns the type of this data item

Return Value

string The type of this data item

at line 274
void setType(string $type)

Sets the type of this data item

The data item can have one of the following type:

  • date: a date stored in the d/m/Y format
  • boolean: the value of the data item can be true or false
  • number: a numeric data with decimal places
  • integer: a numeric value without decimal places.
  • text: a short text
  • textarea: a long text
  • money: a numeric data with decimal places. The value of the data will be displayed with the currency symbol
  • choice: the value of the data is chosen from a list of choices
  • multichoice: the values of the data are chosen from a list of choices
  • percent: a numeric data with decimal places. The display of the value of the data will be followed by the % symbol.
  • table: the data item has an associated Table object
  • department: a departement code
  • region: a region code
  • country: a country code

Parameters

string $type The type of this data item

Return Value

void

at line 288
string getMin()

Returns the minimum value of this data item

Return Value

string The mimimum value

at line 299
string getPlainMin()

Returns the arithmetic expression used to calculate the minimum value of this data item where the ids (prefixed with #) of the data are replaced by their labels.

Return Value

string The arithmetic expression

at line 311
void setMin(string $min)

Sets the minimum value of this data item

Parameters

string $min The minimum value

Return Value

void

at line 322
string getUnparsedMin()

Returns the arithmetic expression used to calculate the minimum value of this data item.

Return Value

string The arithmetic expression

at line 334
void setUnparsedMin(string $unparsedMin)

Sets the arithmetic expression used to calculate the minimum value of this data item.

Parameters

string $unparsedMin The arithmetic expression

Return Value

void

at line 345
string getMax()

Returns the maximum value of this data item

Return Value

string The maximum value

at line 356
string getPlainMax()

Returns the arithmetic expression used to calculate the maximum value of this data item where the ids (prefixed with #) of the data are replaced by their labels.

Return Value

string The arithmetic expression

at line 368
void setMax(string $max)

Sets the maximum value of this data item

Parameters

string $max The maximum value

Return Value

void

at line 379
string getUnparsedMax()

Returns the arithmetic expression used to calculate the minimum value of this data item.

Return Value

string The arithmetic expression

at line 391
void setUnparsedMax(string $unparsedMax)

Sets the arithmetic expression used to calculate the minimum value of this data item.

Parameters

string $unparsedMax The arithmetic expression

Return Value

void

at line 402
string getDefault()

Returns the default value of this data item

Return Value

string The default value

at line 413
string getPlainDefault()

Returns the arithmetic expression used to calculate the default value of this data item where the ids (prefixed with #) of the data are replaced by their labels.

Return Value

string The arithmetic expression

at line 425
void setDefault(string $default)

Sets the default value of this data item

Parameters

string $default The default value

Return Value

void

at line 436
string getUnparsedDefault()

Returns the arithmetic expression used to calculate the default value of this data item.

Return Value

string The arithmetic expression

at line 448
void setUnparsedDefault(string $unparsedDefault)

Sets the arithmetic expression used to calculate the default value of this data item.

Parameters

string $unparsedDefault The arithmetic expression

Return Value

void

at line 459
string getUnit()

Returns the unit (measurement) text of this data item.

Return Value

string The unit text

at line 471
void setUnit(string $unit)

Sets the unit(measurement) text of this data item.

Parameters

string $unit The unit text

Return Value

void

at line 484
int getRound()

Returns the number of decimal places for this data item.

Useless if this data is not of type "number", "money" or "percent".

Return Value

int The number of decimal places

at line 498
void setRound(int $round)

Sets the number of decimal places for this data item. The last digit of the value of the data will be rounded to the nearest integer.

Useless if this data is not of type "number", "money" or "percent".

Parameters

int $round The number of decimal places

Return Value

void

at line 509
string getContent()

Returns the arithmetic expression used to calculate the current value of this data item.

Return Value

string The arithmetic expression

at line 520
string getPlainContent()

Returns the arithmetic expression used to calculate the value of this data item where the ids (prefixed with #) of the data are replaced by their labels.

Return Value

string The arithmetic expression

at line 532
void setContent(string $content)

Sets the arithmetic expression used to calculate the value of this data item.

Parameters

string $content The arithmetic expression

Return Value

void

at line 543
string getSource()

Returns the id of the source if this data item is filled with the result of a query on a data source

Return Value

string The id of the source

at line 557
string getPlainSource() deprecated

deprecated

Returns the arithmetic expression used to calculate the id of the source where the ids (prefixed with #) of the data are replaced by their labels.

This function is no longer used.

Return Value

string The arithmetic expression

at line 569
void setSource(string $source)

Sets the id of the source if this data item is filled with the result of a query on a data source

Parameters

string $source The id of the source

Return Value

void

at line 580
string getIndex()

Returns the key of the associative array of the result if this data item is filled with the result of a query on a data source

Return Value

string The key of the associative array

at line 591
string getPlainIndex()

Returns the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source. The ids (prefixed with #) of the data are replaced by their labels.

Return Value

string The arithmetic expression

at line 603
void setIndex(string $index)

Sets the key of the associative array of the result if this data item is filled with the result of a query on a data source

Parameters

string $index The key of the associative array

Return Value

void

at line 614
string getUnparsedIndex()

Returns the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source.

Return Value

string The arithmetic expression

at line 626
void setUnparsedIndex(string $unparsedIndex)

Sets the arithmetic expression used to calculate the key of the associative array of the result if this data item is filled with the result of a query on a data source.

Parameters

string $unparsedIndex The arithmetic expression

Return Value

void

at line 639
bool isMemorize()

Retrieves the memorize attribute of this data item.

Indicates whether the value of this data should be saved in a cookie in the user's browser.

Return Value

bool The memorize attribute

at line 650
bool getMemorize()

Returns the memorize attribute of this data item.

Return Value

bool The memorize attribute

at line 662
void setMemorize(bool $memorize)

Determines whether the value of this data should be stored in a cookie in the user's browser or not.

Parameters

bool $memorize true if the value of this data should be stored in a cookie, false otherwise

Return Value

void

at line 675
array getChoices()

Returns the list of Choice Objects of this data item.

If the type of this data is "choice" or "multichoice", the list of choices allows the user to select the value of this data item.

Return Value

array The list of Choice Objects

at line 686
string getChoiceLabel()

Returns the label of the choice corresponding to the current value of this data item.

Return Value

string The label of the choice

at line 698
string getChoiceLabelByValue(string $avalue)

Retrieves the label of a choice by its value from the list of choices associated with that data item.

Parameters

string $avalue The value of the choice

Return Value

string The label of the choice

at line 754
void setChoices(array $choices)

Sets the list of Choice Objects of this data item.

If the type of this data is "choice" or "multichoice", the list of choices allows the user to select the value of this data item.

Parameters

array $choices The list of Choice Objects

Return Value

void

at line 766
void addChoice(Choice $choice)

Adds a Choice object in the list of choices of this data item.

Parameters

Choice $choice The Choice object

Return Value

void

at line 778
Choice|null getChoiceById(int $id)

Retrieves a Choice object by its id in the list of choices of this data item.

Parameters

int $id The id of the Choice object

Return Value

Choice|null The Choice object

at line 800
ChoiceSource|null getChoiceSource()

Returns the ChoiceSource object if the type of this data is "choice" or "multichoice" and the list of choices is made with the result of a query on a data source.

Return Value

ChoiceSource|null The ChoiceSource object

at line 812
void setChoiceSource(ChoiceSource $choiceSource)

Sets the ChoiceSource object if the type of this data is "choice" or "multichoice" and the list of choices is made with the result of a query on a data source.

Parameters

ChoiceSource $choiceSource The ChoiceSource object

Return Value

void

at line 823
Table getTable()

Returns the Table object associated with this data item if the type of this data is "table".

Return Value

Table The Table Object

at line 835
void setTable(Table $table)

Returns the Table object associated with this data item if the type of this data is "table".

Parameters

Table $table The Table Object

Return Value

void

at line 846
string getValue()

Retrieves the current value of this data item

Return Value

string The current value

at line 865
string getPlainValue()

Returns the current value of this data item in a string

Return Value

string The current value

at line 881
void setValue(string $value)

Sets the current value of this data item

Parameters

string $value The current value

Return Value

void

at line 914
int getInputStepId()

Retrieves the id of the step where the user enters the value of this data item

Returns -1 if the value is never entered by the user.

Return Value

int The id of the step

at line 926
void setInputStepId(int $inputStepId)

Sets the id of the step where the user enters the value of this data item

Parameters

int $inputStepId The id of the step

Return Value

void

at line 937
array getRulesDependency()

Returns the list of business rules that use this data item

Return Value

array The list of business rules

at line 949
void setRulesDependency(array $rulesDependency)

Sets the list of business rules that use this data item

Parameters

array $rulesDependency The list of business rules

Return Value

void

at line 961
void addRuleDependency(int $ruleId)

Adds a business rule id to the list of business rules that use this data item

Parameters

int $ruleId The id of the business rule.

Return Value

void

at line 975
void removeRuleDependency(int $index)

Removes a business rule id from the list of business rules that use this data item

Parameters

int $index The index of the rule to remove

Return Value

void

at line 986
bool check()

Checks the value of this data item according to its type

Return Value

bool false if there is an error, true otherwise

at line 1092
private string replaceIdByDataLabel(array $matches)

Returns the label of the data item whose identifier is the first element of the given array. The argument is an array because this method is the callback function of a preg_replace_callback.

If the data item is not found the given id prefixed by # is returned

Parameters

array $matches The first element is a data id

Return Value

string returned value : The label of the data

at line 1106
private string replaceByDataLabel(string $target)

Replaces all data id (prefixed with #) by its label in the given text

Parameters

string $target The text in which the data id are to be replaced

Return Value

string The text with data label