Data
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
Constants
TYPES |
|
Properties
protected Simulator | $simulator | from DatasetChild | |
protected int | $id | from DatasetChild | |
protected string | $name | from DatasetChild | |
protected string | $label | from DatasetChild | |
protected RichText | $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 | $pattern | ||
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 mixed | $value | ||
private array | $rulesDependency | ||
private int | $inputStepId |
Methods
Returns the Simulator object that uses this dataset child
Returns the state of use of this dataset child by the current simulation step
Returns the state of use of this dataset child by the current simulation step
Sets the state of use of this dataset child by the current simulation step
Determines whether this dataset child has a issued error or not
Adds a message to the list of error messages.
Removes a message from the list of error messages.
Determines whether this dataset child has a issued warning or not
Sets the list of warning messages.
Adds a message to the list of warning messages.
Removes a message from the list of warning messages.
Returns the class name of this dataset child. It's either "Data" or "DataGroup".
Returns the type of this data item
Sets the type of this data item
Returns the minimum value of this data item
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.
Sets the minimum value of this data item
Returns the arithmetic expression used to calculate the minimum value of this data item.
Sets the arithmetic expression used to calculate the minimum value of this data item.
Returns the maximum value of this data item
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.
Sets the maximum value of this data item
Returns the arithmetic expression used to calculate the minimum value of this data item.
Sets the arithmetic expression used to calculate the minimum value of this data item.
Returns the pattern of this data item.
Sets the pattern of this data item.
Returns the default value of this data item
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.
Sets the default value of this data item
Returns the arithmetic expression used to calculate the default value of this data item.
Sets the arithmetic expression used to calculate the default value of this data item.
Returns the unit (measurement) text of this data item.
Sets the unit(measurement) text of this data item.
Returns the number of decimal places for this data item.
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.
Returns the arithmetic expression used to calculate the current value of this data item.
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.
Sets the arithmetic expression used to calculate the value of this data item.
Returns the id of the source if this data item is filled with the result of a query on a data source
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.
Sets the id of the source if this data item is filled with the result of a query on a data source
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
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.
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
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.
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.
Retrieves the memorize attribute of this data item.
Returns the memorize attribute of this data item.
Determines whether the value of this data should be stored in a cookie in the user's browser or not.
Returns the list of Choice Objects of this data item.
Returns the label of the choice corresponding to the current value of this data item.
Retrieves the label of a choice by its value from the list of choices associated with that data item.
Sets the list of Choice Objects of this data item.
Adds a Choice object in the list of choices of this data item.
Retrieves a Choice object by its id in the list of choices of this data item.
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.
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.
Returns the Table object associated with this data item if the type of this data is "table".
Retrieves the current value of this data item
Returns the current value of this data item in a string
Sets the current value of this data item
Retrieves the id of the step where the user enters the value of this data item
Sets the id of the step where the user enters the value of this data item
Returns the list of business rules that use this data item
Sets the list of business rules that use this data item
Adds a business rule id to the list of business rules that use this data item
Removes a business rule id from the list of business rules that use this data item
Checks the value of this data item according to its type
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.
Replaces all data id (prefixed with #) by its label in the given text
Details
at line 270
void
__construct(Simulator $simulator, int $id, string $name)
Constructor of class Data
in DatasetChild at line 144
Simulator
getSimulator()
Returns the Simulator object that uses this dataset child
in DatasetChild at line 155
int
getId()
Returns the ID of this dataset child.
in DatasetChild at line 167
void
setId(int $id)
Sets the ID of this dataset child.
in DatasetChild at line 178
string
getName()
Returns the name of this dataset child.
in DatasetChild at line 190
void
setName(string $name)
Sets the name of this dataset child.
in DatasetChild at line 201
string
getLabel()
Returns the label of this dataset child.
in DatasetChild at line 213
void
setLabel(string $label)
Sets the label of this dataset child.
in DatasetChild at line 224
RichText
getDescription()
Returns the description of this dataset child.
in DatasetChild at line 236
void
setDescription(RichText $description)
Sets the description of this dataset child.
in DatasetChild at line 247
bool
isUsed()
Returns the state of use of this dataset child by the current simulation step
in DatasetChild at line 258
bool
getUsed()
Returns the state of use of this dataset child by the current simulation step
in DatasetChild at line 270
void
setUsed(bool $used)
Sets the state of use of this dataset child by the current simulation step
in DatasetChild at line 281
bool
isError()
Returns the error attribute of this dataset child
in DatasetChild at line 292
bool
getError()
Returns the error attribute of this dataset child
in DatasetChild at line 304
void
setError(bool $error)
Determines whether this dataset child has a issued error or not
in DatasetChild at line 315
array
getErrorMessages()
Returns the list of error messages.
in DatasetChild at line 327
void
setErrorMessages(array $errorMessages)
Sets the list of error messages.
in DatasetChild at line 339
void
addErrorMessage(string $errorMessage)
Adds a message to the list of error messages.
in DatasetChild at line 353
void
removeErrorMessage(int $index)
Removes a message from the list of error messages.
in DatasetChild at line 364
bool
isWarning()
Returns the warning attribute of this dataset child
in DatasetChild at line 375
bool
getWarning()
Returns the warning attribute of this dataset child
in DatasetChild at line 387
void
setWarning(bool $warning)
Determines whether this dataset child has a issued warning or not
in DatasetChild at line 398
array
getWarningMessages()
Returns the list of warning messages.
in DatasetChild at line 410
void
setWarningMessages(array $warningMessages)
Sets the list of warning messages.
in DatasetChild at line 422
void
addWarningMessage(string $warningMessage)
Adds a message to the list of warning messages.
in DatasetChild at line 436
void
removeWarningMessage(int $index)
Removes a message from the list of warning messages.
in DatasetChild at line 447
string
getClass()
Returns the class name of this dataset child. It's either "Data" or "DataGroup".
at line 281
string
getType()
Returns the type of this data item
at line 293
void
setType(string $type)
Sets the type of this data item
at line 307
string
getMin()
Returns the minimum value of this data item
at line 318
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.
at line 330
void
setMin(string $min)
Sets the minimum value of this data item
at line 341
string
getUnparsedMin()
Returns the arithmetic expression used to calculate the minimum value of this data item.
at line 353
void
setUnparsedMin(string $unparsedMin)
Sets the arithmetic expression used to calculate the minimum value of this data item.
at line 364
string
getMax()
Returns the maximum value of this data item
at line 375
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.
at line 387
void
setMax(string $max)
Sets the maximum value of this data item
at line 398
string
getUnparsedMax()
Returns the arithmetic expression used to calculate the minimum value of this data item.
at line 410
void
setUnparsedMax(string $unparsedMax)
Sets the arithmetic expression used to calculate the minimum value of this data item.
at line 421
string
getPattern()
Returns the pattern of this data item.
at line 433
void
setPattern(string $pattern)
Sets the pattern of this data item.
at line 444
string
getDefault()
Returns the default value of this data item
at line 455
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.
at line 467
void
setDefault(string $default)
Sets the default value of this data item
at line 478
string
getUnparsedDefault()
Returns the arithmetic expression used to calculate the default value of this data item.
at line 490
void
setUnparsedDefault(string $unparsedDefault)
Sets the arithmetic expression used to calculate the default value of this data item.
at line 501
string
getUnit()
Returns the unit (measurement) text of this data item.
at line 513
void
setUnit(string $unit)
Sets the unit(measurement) text of this data item.
at line 526
int|null
getRound()
Returns the number of decimal places for this data item.
Useless if this data is not of type "number", "money" or "percent".
at line 540
void
setRound(int|null $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".
at line 551
string
getContent()
Returns the arithmetic expression used to calculate the current value of this data item.
at line 562
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.
at line 574
void
setContent(string $content)
Sets the arithmetic expression used to calculate the value of this data item.
at line 585
string
getSource()
Returns the id of the source if this data item is filled with the result of a query on a data source
at line 599
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.
at line 611
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
at line 622
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
at line 633
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.
at line 645
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
at line 656
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.
at line 668
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.
at line 681
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.
at line 692
bool
getMemorize()
Returns the memorize attribute of this data item.
at line 704
void
setMemorize(bool $memorize)
Determines whether the value of this data should be stored in a cookie in the user's browser or not.
at line 717
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.
at line 728
string|array
getChoiceLabel()
Returns the label of the choice corresponding to the current value of this data item.
at line 740
string|array
getChoiceLabelByValue(mixed $avalue)
Retrieves the label of a choice by its value from the list of choices associated with that data item.
at line 796
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.
at line 808
void
addChoice(ChoiceGroup|Choice $choice)
Adds a Choice object in the list of choices of this data item.
at line 820
Choice|null
getChoiceById(int $id)
Retrieves a Choice object by its id in the list of choices of this data item.
at line 842
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.
at line 854
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.
at line 865
Table
getTable()
Returns the Table object associated with this data item if the type of this data is "table".
at line 877
void
setTable(Table $table)
Returns the Table object associated with this data item if the type of this data is "table".
at line 888
mixed
getValue()
Retrieves the current value of this data item
at line 911
string
getPlainValue()
Returns the current value of this data item in a string
at line 947
void
setValue(mixed $value)
Sets the current value of this data item
at line 991
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.
at line 1003
void
setInputStepId(int $inputStepId)
Sets the id of the step where the user enters the value of this data item
at line 1014
array
getRulesDependency()
Returns the list of business rules that use this data item
at line 1026
void
setRulesDependency(array $rulesDependency)
Sets the list of business rules that use this data item
at line 1038
void
addRuleDependency(int $ruleId)
Adds a business rule id to the list of business rules that use this data item
at line 1052
void
removeRuleDependency(int $index)
Removes a business rule id from the list of business rules that use this data item
at line 1063
bool
check()
Checks the value of this data item according to its type
at line 1166
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
at line 1180
private string
replaceByDataLabel(string $target)
Replaces all data id (prefixed with #) by its label in the given text