Skip to content

Component_2 (JSONEncoder & MySqlInterface)

Marco Lori edited this page Dec 18, 2018 · 12 revisions

JSON Encoder and MySqlInterface

Component 2 ( JSONEncoder and MysqlInterface from now on) is used to initialize a JSON file, which will be filled with all the metrics extracted from the BPMN model by the Basic Metrics Extractor and the Advanced Metrics Extractor, and to save those metrics into a MySql database.

JSON Encoder

The JSON Encoder provides the methods that the extractor needs to initialize and build a JSON file. JSON stands for JavaScript Object Notation and it is a very popular file format used exchange data between applications or in client/server communication.

Following it is the JSON format description taken by Wikipedia:

In computing, JavaScript Object Notation (JSON) is an open-standard file format that uses human-readable text to transmit data objects consisting of attribute–value pairs and array data types (or any other serializable value).

We found useful to have all the extracted metrics stored into a JSON file so we could have a reliable data format that would allow us to manage those metrics in the most secure yet flexible way.

A first initialization of the JSON file ensures that all the metrics extracted are kept organized in different sections, that will allow the extractors to insert all the data contained in the JSON file right into the database without further computational efforts.

Another great advantage of having a JSON file initialized is that it provides a way for the Basic Metrics Extractor and the Advanced Metrics Extractor to gradually save the extracted metrics right into the JSON file as soon as they are computed.

As it is shown in the Architecture section of this Wiki, the JSON file is initialized like so:

{
"Header":{},
"Basic_Metrics":{},
"Advanced_Metrics":{}
}

The Header section contains the following fields:

{
"Creation_Date":,
"Creation_Time":,
"File_Name":,
"id":
}

The id is really important because it will serve as a primary key in the database, it is calculated using a customized hash function that use data taken from the specific BPMN model.

As their names suggests, the Basic_Metrics and the Advanced_Metrics section of the JSON file contain all the extracted metrics divided by their respective type. Since the extracted metrics are more than 240 altogether, we will report only few of them just to show the structure of these sections:

{
"NT":,
"NCD":,
"NDOin":,
"NDOout":,
...
}

MySqlInterface

The MysqlInterface permanently saves the JSON file into the database. The database, as shown in the Architecture section of this Wiki, is composed by four different tables:

  • Model_Infos
  • Basic_Metrics
  • Advanced_Metrics
  • Metrics_Infos

The JSON file structure is pretty much reflected on the database, the only difference can be found in the Metrics_Infos table.

The MySqlInterface class provides all the methods needed to open a connection with the database, store data and then close the previously opened connection.

Those methods have already been reported in the Architecture section.

Clone this wiki locally