...
- As in tutorials 2.3 and 2.5, create a new Rhapsody SysML project with an empty package and the Syndeia profile.
- Name the empty package package Tutorial_2_07.
- Right-click on on Tutorial_2_07 and and open the Syndeia dashboard.
Expand Expand Component database in in the Connection Manager tab to show the databases and tables within the database. In this example, we are using the the component table table in the the test_demo database, as shown in Figure 59 database.
Figure 59Syndeia Dashboard, Connection Manager tab, showing MySQl repository Component
Figure 60Dialog boxIn the first exercise, we will Create a block in SysML linked to the table table component in in MySQL. Set the Connection Type to Model Transform. Drag the table component (see red arrow in Figure 59) into table component into the Tutorial_2_07 package in the SysML model. Click Yes on the dialog box (Figure 60). When complete, component appears appears as a block in the SysML model panel as in Figure 61. Note that while the the component block block contains the structure of the the component table table (this can be seen in Rhapsody), it does not contain any of the data about specific components. This is the object of the next step.
Figure 61Syndeia Dashboard, Connection Manager tab, showing MySQl table componentand the SysML block component
Figure 62Instance generation dialog box
Set the Connection Type to Data Map. Select several of the individual records under the the component table table in the right-hand panel. Drag them into the the Tutorial_2_07 package package in the left panel. A dialog box as in Figure 62 will appear. Leave the "As Specialization" checkbox unchecked and click Yes. The new SysML instances are shown in Figure 63.
Figure 63Syndeia Dashboard, Connection Manager tab, showing new SysML instance created- Explore other options for creating transferring MySQL records to the SysML model
- Create a new package in the SysML project and drag some MySQL records into it. They will still be treated as instances (or specializations) of the the component block block even if they are not in the same package.
- In the Filter query box (upper left corner) of the Connection Manager., enter a valid MySQL syntax query, for example, Select * from from test_demo.component where where Mass < '3'. Only those records satisfying the query will be displayed and can be dragged into the SysML model.
- Erase the current contents of the the Tutorial_2_07 package package in Rhapsody, including all connections. Drag some MySQL records into it. Note that a a component block block is created automatically, along with the specializations corresponding to the individual records.
- In the next part of the exercise, we will make change to the data in the database and update the SysML model from MySQL. Go to the MySQL Workbench and modify some details of the connected rows. For example, see Figure 64 the image below where the left side shows the the components table table before making changes and the right side show the changes. The cost of the Communication Controller was increased from 25 to 50 and the mass of the Payload Controller was increased from 1.5 to 2.5.
Figure 64 Modify contents of database in MySQL Workbench
Now multiple select (using Ctrl key) connections C2 and C6 that correspond to the 2 modified rows. Right click and select Sync Target → SysML, as shown in Figure 65.
Figure 65Multiple select connections, right click, and select Sync Target → SysML- The Syndeia log window will show messages similar to below:
16:57:19] INFO Processing 2 connections...
[16:57:19] INFO Updating SysML block from MySQL table row for connection C2.
[16:57:19] DEBUG GID of source: GUID 9e4c94e6-6344-4ea5-a8dd-25f28a3ddc0d | GUID a2f00ea8-6d04-44f1-bdae-cd993895cd41
[16:57:19] DEBUG GID of target: Component database | {"database":"test_demo","table":"component","row":"Payload Controller","column":null}
[16:57:19] DEBUG Setting real number 2.5 as the default value for property Mass. Creating a LiteralReal.
[16:57:19] INFO Default value of value property Mass is changed from 1.5 to 2.5
[16:57:19] INFO C2 connected sources (SysML) updated.
[16:57:19] INFO Updating SysML block from MySQL table row for connection C6.
Figure 66 Updated values from MySQL
- In the Rhapsody Features windows, you can see that the appropriate initial values have been updated, as shown in Figure 66.
- Similarly, you can change the SysML instance slot value or block (default) value in Rhapsody and sync to MySQL by right-clicking the appropriate connection and selecting Sync SysML → Target.