Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The objective of this exercise is to generate MagicDraw SysML blocks and instances from a MySQL database. Many organizations store data about products in such databases and it is desirable to be able to import this data into the SysML model. In this exercise, we will use the MySQL table created in the previous example and import this information back into an empty model in MagicDraw.

  1. As in tutorials 2.3 and 2.5, create Create a new MagicDraw SysML project with an empty package and the Syndeia profile.
  2. Name the empty package Tutorial_2_07.
  3. Right-click on Tutorial_2_07 and open the Syndeia dashboard.
  4. Expand Component Database in the Connection Manager tab to show the databases and tables within the database. In this example, we are using the component table in the test_demo database, as shown in Figure 60.


    Figure 60 Syndeia Dashboard, Connection Manager tab, showing MySQl repository msz


    Figure 61 Dialog box
     
  5. In the first exercise, we will Create a block in SysML linked to the table test_demo in MySQL. Set the Connection Type to Model Transform. Drag the table test_demo (see red arrow in Figure 60) into the Tutorial_2_07 package in the SysML model. Click Yes on the dialog box (Figure 61). When complete, test_demo appears as a block in the SysML model panel as in Figure 62. Note that while the test_demo block contains the structure of the test_demo table (this can be seen in MagicDraw), it does not contain any of the data about specific components. This is the object of the next step.


    Figure 62 Syndeia Dashboard, Connection Manager tab, showing MySQl table test_demo and the SysML block test_demo


    Figure 63 Instance generation dialog box
     
  6. Set the Connection Type to Data Map. Select several of the individual records under the test_demo table in the right-hand panel. Drag them into the test_demo package in the left panel. A dialog box as in Figure 63 will appear. Leave the "As Specialization" checkbox unchecked and click Yes. The new SysML instances are shown in Figure 64.


     Figure 64Syndeia Dashboard, Connection Manager tab, showing new SysML instance created

  7. Explore other options for creating transferring MySQL records to the SysML model
    1. Drag more records from the test_demo table into the Tutorial_2_07 package in SysML, but check the "As Specialization" checkbox on the Syndeia dialog box. This will create a series of blocks that are specializations of the components block, but with the default values of the value properties showing the information from the individual records.
    2. 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 component block even if they are not in the same package.
    3. In the Filter query box (upper left corner) of the Connection Manager., enter a valid MySQL syntax query, for example, Select * from test_demo.component where Mass < '3'. Only those records satisfying the query will be displayed and can be dragged into the SysML model.
    4. Erase the current contents of the Tutorial_2_07 package in MagicDraw. Drag some MySQL records into it. Note that a component block is created automatically, along with the instances (or specializations) corresponding to the individual records.
       
  8. 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 65 where the left side shows the components table before making changes and the right side show the changes. The cost of the Communication Controller was reduced from 50 to 25 and the mass of the Payload Controller was reduced from 2.5 to 1.5.


     Figure 65Modify contents of database in MySQL Workbench
     
  9. Now multiple select (using Ctrl key) connections C30 and C34 that correspond to the 2 modified rows. Right click and select Sync Target → SysML, as shown in Figure 66.


    Figure 66 Multiple select connections, right click, and select Sync Target → SysML
     
  10. The Syndeia log window will show messages similar to below:

    [11:07:27] INFO Processing 2 connections...
    [11:07:27] INFO Updating SysML block from MySQL table row for connection C30.
    [11:07:27] INFO Default value of value property Mass is changed from 2.5 to 1.5
    [11:07:27] INFO C30 connected sources (SysML) updated.
    [11:07:27] INFO Updating SysML block from MySQL table row for connection C34.
    [11:07:27] INFO Default value of value property Cost is changed from 50.0 to 25.0
    [11:07:27] INFO C34 connected sources (SysML) updated.
     
  11. In the Containment Tree, you can see that the appropriate values have been updated, as shown in Figure 67.
  12. Similarly, you can change the SysML instance slot value or block (default) value in MagicDraw and sync to MySQL by right-clicking the appropriate connection and selecting Sync SysML → Target.

...