class Source

This class allows the storage and retrieval of the attributes of a source.

In a Source object, is defined a particular access query to a data source for a simulator.

Properties

private Simulator $simulator
private int $id
private string $label
private string $datasource
private string $request
private string $requestType
private array $parsed
private string $returnType
private string $separator
private string $delimiter
private string $returnPath
private array $parameters

Methods

void
__construct(Simulator|null $simulator, int $id, string $datasource, string $returnType)

Constructor of class Source

getSimulator()

Returns the Simulator object that uses this source

int
getId()

Returns the ID of this source.

void
setId(int $id)

Sets the ID of this source.

string
getLabel()

Returns the label of this source.

void
setLabel(string $label)

Sets the label of this source.

string
getDatasource()

Returns the name of the data source accessed by this source

void
setDatasource(string $datasource)

Sets the name of the data source accessed by this source

string
getRequest()

Returns the SQL Select clause for internal or external database

void
setRequest(string $request)

Sets the SQL Select clause for internal or external database

string
getRequestType()

Returns the type of the request ('simple' or 'complex')

void
setRequestType(string $requestType)

Sets the type of the request ('simple' or 'complex')

array
getParsed()

Returns the associative array, result of the parsing of the simple SQL Request

void
setParsed(array $parsed)

Sets the result of the parsing of the simple SQL Request

string
getReturnType()

Returns the type (format) or the result returned by the request

void
setReturnType(string $returnType)

Sets the type (format) or the result returned by the request

mixed
getSeparator()

Returns the character that separates the fields in a query result in csv format

void
setSeparator(string $separator)

Sets the character that separates the fields in a query result in csv format

string
getDelimiter()

Returns the character that delimits the fields in a query result in csv format

void
setDelimiter(string $delimiter)

Sets the character that delimits the fields in a query result in csv format

string
getReturnPath()

Returns the expression allowing the location of the value looked for in the result returned by the request of this source.

void
setReturnPath(string $returnPath)

Sets the expression allowing the location of the value looked for in the result returned by the request of this source.

array
getParameters()

Returns the list of parameters passed to the request of this source.

void
setParameters(array $parameters)

Sets the list of parameters passed to the request of this source.

void
addParameter(Parameter $parameter)

Adds a Parameter object to the list of parameters passed to the request of this source.

void
removeParameter(int $index)

Removes a Parameter object from the list of parameters passed to the request of this source.

Parameter|null
getParameterByName(string $name)

Retrieves a Parameter object by its name in the list of parameters passed to the request of this source.

Details

at line 146
void __construct(Simulator|null $simulator, int $id, string $datasource, string $returnType)

Constructor of class Source

Parameters

Simulator|null $simulator The Simulator object that uses this source
int $id The ID of this source
string $datasource The name of the data source accessed by this source
string $returnType The type (format) or the result returned by the request

Return Value

void

at line 160
Simulator getSimulator()

Returns the Simulator object that uses this source

Return Value

Simulator The Simulator object

at line 171
int getId()

Returns the ID of this source.

Return Value

int The ID of this source

at line 183
void setId(int $id)

Sets the ID of this source.

Parameters

int $id The ID of this source

Return Value

void

at line 194
string getLabel()

Returns the label of this source.

Return Value

string The label of this source.

at line 206
void setLabel(string $label)

Sets the label of this source.

Parameters

string $label The label of this source.

Return Value

void

at line 217
string getDatasource()

Returns the name of the data source accessed by this source

Return Value

string The name of the data source

at line 229
void setDatasource(string $datasource)

Sets the name of the data source accessed by this source

Parameters

string $datasource The name of the data source

Return Value

void

at line 240
string getRequest()

Returns the SQL Select clause for internal or external database

Return Value

string The SQL Select clause

at line 252
void setRequest(string $request)

Sets the SQL Select clause for internal or external database

Parameters

string $request The SQL Select clause

Return Value

void

at line 265
string getRequestType()

Returns the type of the request ('simple' or 'complex')

A request is simple if it concerns only one table and does not have a nested subquery, otherwise it is complex

Return Value

string The type of the request

at line 279
void setRequestType(string $requestType)

Sets the type of the request ('simple' or 'complex')

A request is simple if it concerns only one table and does not have a nested subquery, otherwise it is complex

Parameters

string $requestType The type of the request

Return Value

void

at line 293
array getParsed()

Returns the associative array, result of the parsing of the simple SQL Request

The associative array has the following keys : 'select', 'from', 'where', 'conditions', 'orderby', 'limit', 'offset'

Return Value

array The result of the parsing of the simple SQL Request

at line 308
void setParsed(array $parsed)

Sets the result of the parsing of the simple SQL Request

Th result of the parsing is an associative array with the following keys : 'select', 'from', 'where', 'conditions', 'orderby', 'limit', 'offset'

Parameters

array $parsed The result of the parsing of the simple SQL Request

Return Value

void

at line 328
string getReturnType()

Returns the type (format) or the result returned by the request

The possible values are:

  • json: Javascript Object Notation
  • xml: eXtended Markup Language
  • html: Hyper Text Markup Language
  • csv: Comma Separated Value
  • assocArray: Table of key / value pairs.
  • singleValue: Scalar value

Return Value

string The type (format) or the result returned by the request

at line 349
void setReturnType(string $returnType)

Sets the type (format) or the result returned by the request

The possible values are:

  • json: Javascript Object Notation
  • xml: eXtended Markup Language
  • html: Hyper Text Markup Language
  • csv: Comma Separated Value
  • assocArray: Table of key / value pairs.
  • singleValue: Scalar value

Parameters

string $returnType The type (format) or the result returned by the request

Return Value

void

at line 360
mixed getSeparator()

Returns the character that separates the fields in a query result in csv format

Return Value

mixed The character that separates the fields

at line 372
void setSeparator(string $separator)

Sets the character that separates the fields in a query result in csv format

Parameters

string $separator The character that separates the fields

Return Value

void

at line 383
string getDelimiter()

Returns the character that delimits the fields in a query result in csv format

Return Value

string The character that delimits the fields

at line 395
void setDelimiter(string $delimiter)

Sets the character that delimits the fields in a query result in csv format

Parameters

string $delimiter The character that delimits the fields

Return Value

void

at line 417
string getReturnPath()

Returns the expression allowing the location of the value looked for in the result returned by the request of this source.

The form of this expression depends on the format of the result of the query (returnType):

  • json: JSONPath or XPath expression
  • xml: XPath expression
  • html: XPath expression
  • csv: line number / column number
  • assocArray: line number / column name
  • singleValue : N/A

Return Value

string The expression allowing the location of the value

See also

http://goessner.net/articles/JsonPath/ JSONPath - XPath for JSON
http://xmlfr.org/w3c/TR/xpath/ Langage XML Path (XPath)

at line 441
void setReturnPath(string $returnPath)

Sets the expression allowing the location of the value looked for in the result returned by the request of this source.

The form of this expression depends on the format of the result of the query (returnType):

  • json: JSONPath or XPath expression
  • xml: XPath expression
  • html: XPath expression
  • csv: line number / column number
  • assocArray: line number / column name
  • singleValue : N/A

Parameters

string $returnPath The expression allowing the location of the value

Return Value

void

See also

http://goessner.net/articles/JsonPath/ JSONPath - XPath for JSON
http://xmlfr.org/w3c/TR/xpath/ Langage XML Path (XPath)

at line 452
array getParameters()

Returns the list of parameters passed to the request of this source.

Return Value

array The list of parameters

at line 464
void setParameters(array $parameters)

Sets the list of parameters passed to the request of this source.

Parameters

array $parameters The list of parameters

Return Value

void

at line 476
void addParameter(Parameter $parameter)

Adds a Parameter object to the list of parameters passed to the request of this source.

Parameters

Parameter $parameter The Parameter object

Return Value

void

at line 488
void removeParameter(int $index)

Removes a Parameter object from the list of parameters passed to the request of this source.

Parameters

int $index The index of the parameter in the list of parameters

Return Value

void

at line 500
Parameter|null getParameterByName(string $name)

Retrieves a Parameter object by its name in the list of parameters passed to the request of this source.

Parameters

string $name The name of the parameter

Return Value

Parameter|null The Parameter object