mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
english corrected
This commit is contained in:
parent
da556248d4
commit
d7c1498882
@ -10,10 +10,10 @@
|
|||||||
Exports
|
Exports
|
||||||
*******
|
*******
|
||||||
|
|
||||||
Export is an important issue for the Chill software : users should be able to :
|
Export is an important issue within the Chill software : users should be able to :
|
||||||
|
|
||||||
- compute statistics about their activity ;
|
- compute statistics about their activity ;
|
||||||
- list "things" which make part of their activities.
|
- list "things" which are a part of their activities.
|
||||||
|
|
||||||
The `main bundle`_ provides a powerful framework to build custom queries with re-usable parts across differents bundles.
|
The `main bundle`_ provides a powerful framework to build custom queries with re-usable parts across differents bundles.
|
||||||
|
|
||||||
@ -34,31 +34,31 @@ Some vocabulary: 3 "Export elements"
|
|||||||
|
|
||||||
Four terms are used for this framework :
|
Four terms are used for this framework :
|
||||||
|
|
||||||
exports
|
Exports
|
||||||
provides some basic operation on the date. Two kind of exports are available :
|
provide some basic operation on the data. Two kinds of exports are available :
|
||||||
|
|
||||||
- computed data : it may be "the number of people", "the number of activities", "the duration of activities", ...
|
- computed data : it may be "the number of people", "the number of activities", "the duration of activities", ...
|
||||||
- list data : it may be "the list of people", "the list of activity", ...
|
- list data : it may be "the list of people", "the list of activities", ...
|
||||||
|
|
||||||
filters
|
Filters
|
||||||
The filters make a filter on the date: it removes some information the user doesn't want to introduce in the computation done by export. In other word, filters make a filter...
|
The filters create a filter on the data: it removes some information the user doesn't want to introduce in the computation done by the export.
|
||||||
|
|
||||||
Example of filter: "people under 18 years olds", "activities between the 1st of June and the 31st December", ...
|
Example of a filter: "people under 18 years olds", "activities between the 1st of June and the 31st December", ...
|
||||||
|
|
||||||
aggregators
|
Aggregators
|
||||||
The aggregator aggregates the data into some group (some software use the term 'bucket').
|
The aggregator aggregates the data into some group (some software use the term 'bucket').
|
||||||
|
|
||||||
Example of aggregator : "group people by gender", "group people by nationality", "group activity by type", ...
|
Example of an aggregator : "group people by gender", "group people by nationality", "group activity by type", ...
|
||||||
|
|
||||||
formatters
|
Formatters
|
||||||
The formatters format the data into a :class:`Symfony\Component\HttpFoundation\Response`, which will be returned "as is" by the controller to the web client.
|
The formatters format the data into a :class:`Symfony\Component\HttpFoundation\Response`, which will be returned "as is" by the controller to the web client.
|
||||||
|
|
||||||
Example of formatter: "format data as CSV", "format data as ods spreadsheet", ...
|
Example of a formatter: "format data as CSV", "format data as an ods spreadsheet", ...
|
||||||
|
|
||||||
Anatomy of an export
|
Anatomy of an export
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
An export may be explained as a sentence, where each part of this sentence refers to one or multiple exports element. Examples :
|
An export can be thought of as a sentence where each part of this sentence refers to one or multiple export elements. Examples :
|
||||||
|
|
||||||
**Example 1**: Count the number of people having at least one activity in the last 12 month, and group them by nationality and gender, and format them in a CSV spreadsheet.
|
**Example 1**: Count the number of people having at least one activity in the last 12 month, and group them by nationality and gender, and format them in a CSV spreadsheet.
|
||||||
|
|
||||||
@ -72,8 +72,8 @@ Here :
|
|||||||
|
|
||||||
Note that :
|
Note that :
|
||||||
|
|
||||||
- aggregators, filters, exports and aggregators are cross-bundle. Here the bundle *activity* provides a filter which apply on an export provided by the person bundle ;
|
- Aggregators, filters, exports and formatters are cross-bundle. Here the bundle *activity* provides a filter which is applied on an export provided by the person bundle ;
|
||||||
- there may exists multiple aggregator or filter for one export. Currently, only one export is allowed.
|
- Multiple aggregator or filter for one export may exist. Currently, only one export is allowed.
|
||||||
|
|
||||||
The result might be :
|
The result might be :
|
||||||
|
|
||||||
@ -89,7 +89,7 @@ The result might be :
|
|||||||
| France | Female | 150 |
|
| France | Female | 150 |
|
||||||
+-----------------------+----------------+---------------------------+
|
+-----------------------+----------------+---------------------------+
|
||||||
|
|
||||||
**Example 2**: Count the average duration of an activity with type "meeting", which occurs between the 1st of June and the 31st of December, group them by week, and format the data in a OpenDocument spreadsheet.
|
**Example 2**: Count the average duration of an activity with type "meeting", which occurs between the 1st of June and the 31st of December, group them by week, and format the data in an OpenDocument spreadsheet.
|
||||||
|
|
||||||
Here :
|
Here :
|
||||||
|
|
||||||
@ -116,13 +116,13 @@ The result might be :
|
|||||||
Authorization and exports
|
Authorization and exports
|
||||||
-------------------------
|
-------------------------
|
||||||
|
|
||||||
Exports, filters and aggregators should not make see data the user is not allowed to see.
|
Exports, filters and aggregators should not show data the user is not allowed to see within the application.
|
||||||
|
|
||||||
In other words, developers are required to take care of user authorization for each export.
|
In other words, developers are required to take care of user authorization for each export.
|
||||||
|
|
||||||
It should exists a special role that should be granted to users which are allowed to build exports. For more simplicity, this role should apply on center, and should not requires special circles.
|
There should be a specific role that grants permission to users who are allowed to build exports. For more simplicity, this role should apply on a center, and should not require special circles.
|
||||||
|
|
||||||
How does the magic works ?
|
How does the magic work ?
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
To build an export, we rely on the capacity of the database to execute queries with aggregate (i.e. GROUP BY) and filter (i.e. WHERE) instructions.
|
To build an export, we rely on the capacity of the database to execute queries with aggregate (i.e. GROUP BY) and filter (i.e. WHERE) instructions.
|
||||||
@ -133,13 +133,13 @@ An export is an SQL query which is initiated by an export, and modified by aggre
|
|||||||
|
|
||||||
**Example**: Count the number of people having at least one activity in the last 12 month, and group them by nationality and gender
|
**Example**: Count the number of people having at least one activity in the last 12 month, and group them by nationality and gender
|
||||||
|
|
||||||
1. The report initiate the query
|
1. The report initiates the query
|
||||||
|
|
||||||
.. code-block:: SQL
|
.. code-block:: SQL
|
||||||
|
|
||||||
SELECT count(people.*) FROM people
|
SELECT count(people.*) FROM people
|
||||||
|
|
||||||
2. The filter add a where and join clause :
|
2. The filter adds a where and join clause :
|
||||||
|
|
||||||
.. code-block:: SQL
|
.. code-block:: SQL
|
||||||
|
|
||||||
@ -147,7 +147,7 @@ An export is an SQL query which is initiated by an export, and modified by aggre
|
|||||||
RIGHT JOIN activity
|
RIGHT JOIN activity
|
||||||
WHERE activity.date IS BETWEEN now AND 6 month ago
|
WHERE activity.date IS BETWEEN now AND 6 month ago
|
||||||
|
|
||||||
3. The aggregator "nationality" add a GROUP BY clause and a column in the SELECT statement:
|
3. The aggregator "nationality" adds a GROUP BY clause and a column in the SELECT statement:
|
||||||
|
|
||||||
.. code-block:: sql
|
.. code-block:: sql
|
||||||
|
|
||||||
@ -156,7 +156,7 @@ An export is an SQL query which is initiated by an export, and modified by aggre
|
|||||||
WHERE activity.date IS BETWEEN now AND 6 month ago
|
WHERE activity.date IS BETWEEN now AND 6 month ago
|
||||||
GROUP BY nationality
|
GROUP BY nationality
|
||||||
|
|
||||||
4. The aggregator "gender" do the same job as the nationality aggregator : it adds a GROUP BY clause and a column in the SELECT statement :
|
4. The aggregator "gender" does the same job as the nationality aggregator : it adds a GROUP BY clause and a column in the SELECT statement :
|
||||||
|
|
||||||
.. code-block:: sql
|
.. code-block:: sql
|
||||||
|
|
||||||
@ -165,28 +165,28 @@ An export is an SQL query which is initiated by an export, and modified by aggre
|
|||||||
WHERE activity.date IS BETWEEN now AND 6 month ago
|
WHERE activity.date IS BETWEEN now AND 6 month ago
|
||||||
GROUP BY nationality, gender
|
GROUP BY nationality, gender
|
||||||
|
|
||||||
Each filter, aggregator and filter may collect parameters from the user by providing a form. This form is appended to the export form. Here is an example.
|
Each filter, aggregator and filter may collect parameters from the user through a form. This form is appended to the export form. Here is an example.
|
||||||
|
|
||||||
.. figure:: /_static/screenshots/development/export_form-fullpage.png
|
.. figure:: /_static/screenshots/development/export_form-fullpage.png
|
||||||
|
|
||||||
The screenshot show the export form for ``CountPeople`` (Nombre de personnes). The filter by date of birth is checked (*Filtrer par date de naissance de la personne*), which allow to show a subform, which is provided by the :class:`Chill\PersonBundle\Export\Filter\BirthdateFilter`. The other filter, which are unchecked, does not show the subform.
|
The screenshot shows the export form for ``CountPeople`` (Nombre de personnes). The filter by date of birth is checked (*Filtrer par date de naissance de la personne*), which triggers a subform, which is provided by the :class:`Chill\PersonBundle\Export\Filter\BirthdateFilter`. The other unchecked filter does not show the subform.
|
||||||
|
|
||||||
Two aggregators are also checked : by Country of birth (*Aggréger les personnes par pays de naissance*, corresponding class is :class:`Chill\PersonBundle\Export\Aggregator\CountryOfBirthAggregator`, which also open a subform. The aggregator by gender (*Aggréger les personnes par genre*) is also checked, but there is no corresponding subform.
|
Two aggregators are also checked : by Country of birth (*Aggréger les personnes par pays de naissance*, the corresponding class is :class:`Chill\PersonBundle\Export\Aggregator\CountryOfBirthAggregator`, which also triggers a subform. The aggregator by gender (*Aggréger les personnes par genre*) is also checked, but there is no corresponding subform.
|
||||||
|
|
||||||
The Export Manager
|
The Export Manager
|
||||||
------------------
|
------------------
|
||||||
|
|
||||||
The Export manager (:class:`Chill\MainBundle\Export\ExportManager` is the central class which register all exports, aggregators, filters and formatters.
|
The Export manager (:class:`Chill\MainBundle\Export\ExportManager` is the central class which registers all exports, aggregators, filters and formatters.
|
||||||
|
|
||||||
The export manager is also responsible for orchestrating the whole export process, producing a :class:`Symfony\FrameworkBundle\HttpFoundation\Request` to each export request.
|
The export manager is also responsible for orchestrating the whole export process, producing a :class:`Symfony\FrameworkBundle\HttpFoundation\Request` for each export request.
|
||||||
|
|
||||||
|
|
||||||
The export form step
|
The export form step
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
The form step allow to build a form, aggregating different parts of the module.
|
The form step allows you to build a form, combining different parts of the module.
|
||||||
|
|
||||||
The building of forms is separated between different subform, which are responsible for rendering their part of the form (aggregators, filters, and export).
|
The building of forms is split into different subforms, where each one is responsible for rendering their part of the form (aggregators, filters, and export).
|
||||||
|
|
||||||
.. figure:: /_static/puml/exports/form_steps.png
|
.. figure:: /_static/puml/exports/form_steps.png
|
||||||
:scale: 40%
|
:scale: 40%
|
||||||
@ -194,12 +194,12 @@ The building of forms is separated between different subform, which are responsi
|
|||||||
The formatter form step
|
The formatter form step
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
The formatter form is processed *after* the user filled the export form. It is built the same way, but receive in parameters the data entered by the user on the previous step (i.e. export form). It may then adapt it accordingly (example: show a list of columns selected in aggregators).
|
The formatter form is processed *after* the user filled the export form. It is built the same way, but receives the data entered by the user on the previous step as parameters (i.e. export form). It may then adapt it accordingly (example: show a list of columns selected in aggregators).
|
||||||
|
|
||||||
Processing the export
|
Processing the export
|
||||||
---------------------
|
---------------------
|
||||||
|
|
||||||
The export process may be explained by this schema :
|
The export process can be explained by this schema :
|
||||||
|
|
||||||
.. figure:: /_static/puml/exports/processing_export.png
|
.. figure:: /_static/puml/exports/processing_export.png
|
||||||
:scale: 40%
|
:scale: 40%
|
||||||
@ -219,20 +219,20 @@ This is an example of the ``CountPerson`` export :
|
|||||||
:language: php
|
:language: php
|
||||||
:linenos:
|
:linenos:
|
||||||
|
|
||||||
* **Line 36**: the ``getType`` function return a string. This string will be used to find the aggregtors and filters which will apply to this export.
|
* **Line 36**: the ``getType`` function returns a string. This string will be used to find the aggregtors and filters which will apply to this export.
|
||||||
* **Line 41**: a simple description to help user to understand what your export does.
|
* **Line 41**: a simple description to help users understand what your export does.
|
||||||
* **Line 46**: The title of the export. A summary of what your export does.
|
* **Line 46**: The title of the export. A summary of what your export does.
|
||||||
* **Line 51**: The list of roles requires to execute this export.
|
* **Line 51**: The list of roles required to execute this export.
|
||||||
* **Line 56**: We initiate the query here...
|
* **Line 56**: We initiate the query here...
|
||||||
* **Line 59**: We have to filter the query with centers the users checked in the form. We process the $acl variable to get all ``Center`` object in one array
|
* **Line 59**: We have to filter the query with centers the users checked in the form. We process the $acl variable to get all ``Center`` objects in one array
|
||||||
* **Line 63**: We create the query, with a query builder.
|
* **Line 63**: We create the query with a query builder.
|
||||||
* **Line 74**: We simply returns the result, but take care of hydrating the results as an array.
|
* **Line 74**: We return the result, but make sure to hydrate the results as an array.
|
||||||
* **Line 103**: return the list of formatters types which are allowed to apply on this filter
|
* **Line 103**: return the list of formatter types which are allowed to be applied on this filter
|
||||||
|
|
||||||
Filters
|
Filters
|
||||||
-------
|
-------
|
||||||
|
|
||||||
This is an example of the *filter by birthdate*. This filter ask some information in a form (`buildForm` is not empty), and this form must be validated. To performs this validations, we implement a new Interface: :class:`Chill\MainBundle\Export\ExportElementValidatedInterface`:
|
This is an example of the *filter by birthdate*. This filter asks some information through a form (`buildForm` is not empty), and this form must be validated. To perform this validation, we implement a new Interface: :class:`Chill\MainBundle\Export\ExportElementValidatedInterface`:
|
||||||
|
|
||||||
.. literalinclude:: /_static/code/exports/BirthdateFilter.php
|
.. literalinclude:: /_static/code/exports/BirthdateFilter.php
|
||||||
:language: php
|
:language: php
|
||||||
|
Loading…
x
Reference in New Issue
Block a user