Papyrus And Sirius Tables

As tables exist in Papyrus and Sirius we want to provide a way to integrate them as Word tables or LibreOffice tables.

Gendoc tag already exists, so the solution proposed is to have a pivot generic Table object, offered by a dedicated Gendoc metamodel, in order to generate all kinds of table the same way. Dedicated acceleo bundles, already existing for Papyrus and Sirius, have a new service to transform their table to the Gendoc generic table.

An overview of the Gendoc table very simple metamodel is shown in the picture below.

Papyrus table generation (with manual configuration of the table columns in the template)

From a Papyrus model containing this table:

Gendoc template fragment :

<config> <drop/>
   <param key='modelPath' value='${project_loc}/...'/>
   <output path='...'/>
</config> <drop/>

<context model='${modelPath}' element='RootElement/Requirements' importedBundle='gmf;papyrus' searchMetamodel='true'/>
<gendoc id='requirements'> <drop/>
   [for (table: table::Table | self.getPapyrusTables())] <drop/>
   <table> <drop/>
[table.name/]:

[table.tableheader.cells -> at(1).label/] [table.tableheader.cells -> at(2).label/] [table.tableheader.cells -> at(3).label/]
   [for (row: table::Row | table.rows)] <drop/>
[row.cells->at(1).label/] [row.cells->at(1).label/] [row.cells->at(1).label/]
   [/for] <drop/>
   </table> <drop/>
</gendoc> <drop/>

In this example the service "getPapyrusTables()" will return the list of tables contained in the context element.

It is possible to navigate in a table using relations “tableheader” and “row”. The first relation returns the headers of a table and the latter a list of row. From each of these objects we use the relation “cells” to access to the list of cells composing a row or the table header.

Result in the word document produced by Gendoc :

id name text
REQ_001 Automated alarm clock The alarm clock radio shall wake up the user automatically at the right time, through radio or buzzer
REQ_0012 Radio management The user shall be able to modify easily the radio station and the volume.
REQ_003 Clock management The user shall be able to update easily the time displayed by the clock or the alarm.
...

Sirius table generation (with manual configuration of the table columns in the template)

From a Sirius model containing this table:

Gendoc template fragment:

<config> <drop/>
   <param key='modelPath' value='${project_loc}/...'/>
   <output path='...'/>
</config> <drop/>

<context model='${modelPath}' element='RootElement/Requirements' importedBundle='gmf;sirius' searchMetamodel='true'/>
<gendoc id='requirements'> <drop/>
   [for (table: table::Table | self.getSiriusTables())] <drop/>
   <table> <drop/>
[table.name/]:

[table.tableheader.cells -> at(1).label/] [table.tableheader.cells -> at(2).label/] [table.tableheader.cells -> at(3).label/]
   [for (row: table::Row | table.rows)] <drop/>
[row.cells->at(1).label/] [row.cells->at(1).label/] [row.cells->at(1).label/]
   [/for] <drop/>
   </table> <drop/>
</gendoc> <drop/>

This example is very similar to the precedent. The only notable difference is how we access to the list of tables. In this case as we are in a Sirius model, we use the “getSiriusTables()” service.

Result in the word document produced by Gendoc :


Father Mother
Man Paul

Woman Isa

Man Elias Paul Isa
Woman Lea Paul
Isa
Man Dave Elias
Man Alain Dave Katell
...

Example of an automated table generation from a Papyrus table

From a Papyrus model containing several tables on a package the following gendoc fragment allows a full table generation.

Note: Automated mode also works with Sirius

Gendoc code:

<config> <drop/>
   <param key='modelPath' value='${project_loc}/...'/>
   <output path='...'/>
</config> <drop/>

<context model='${modelPath}' element='RootElement/Requirements' importedBundle='gmf;papyrus' searchMetamodel='true'/>
<gendoc id='requirements'> <drop/>
   [for (table: table::Table | self.getPapyrusTables())] <drop/>
[table.name/]:[t.type/]
   <table object='[t.getTableId()/]'> <drop/>
 
   </table> <drop/>
</gendoc> <drop/>

The table tag has a new attribute “object” for the automatic generation. This attribute has to be set to the identifier of the table. The service “getTableId()” is used to retrieve this identifier.

Note: in this mode all cells will have the same style.

Gendoc result :

RequirementTable0 : PapyrusSysMLRequirementTable

id : String [1]
name : String [0..1]
text : String [1]
REQ_001 Automated alarm clock The alarm clock radio shall wake up the user automatically at the right time, through radio or buzzer
REQ_0012 Radio management The user shall be able to modify easily the radio station and the volume.
REQ_003 Clock management The user shall be able to update easily the time displayed by the clock or the alarm.
...

AllocationTable0 : PapyrusSysMLAllocationTable

name : String [0..1]
Allocate1
Allocate2
Allocate3
Allocate4
Allocate5