Congratulations to Danilo! His post follows:
JDM
Jolie Database Manager for PostgreSQL database
by Danilo Sorano
The jolie database manager is a tool whose goal is to create a facilitator for the management of PostgresSQl data sources by using microservices. The tool can be get on github: https://github.com/jolie/db_connector
The main purpose of JDM is to simplify database management operations, specifically the simplifications of the insertion, modification, deletion and retrieval of data. The tool has been designed for preventing the user to write standard queries on tables and views which can be easily automatized.
Usage instructions:
- Creating the database and tables / views. Only if you are creating a database from scratch. Otherwise skip this step.
- Start the JDM server running main_table_generator.ol inside folder server
- Configure the information necessary to connect with the database (file config.ini)
- Start the client running createDbService.ol inside folder client
- In folder db_services all the files will be generated: Metadata extraction from the database and creation of the service for the database.
The database service is divided in two parts:
- Automatic service
- Custom service
The automatic part provides basic operations for the database:
- Create: INSERT query
- Update: UPDATE query
- Remove: DELETE query
- Get: SELECT query
The management of more complex operations such as JOIN between tables must be managed by creating view by the user.
The custom part allows for the development of customized query on the database and it can be freely edited by the user. This function gives to the user the possibility of being able to create the most complex operations, for example, to manage nested query.
From an architectural point of view, the database service's main part embeds the custom part and automatic one. This mechanism allows the two parties to be independent of each other, thus allowing the modification of the automatic part every time that, for example, is added to a view without going to change the custom part.
Example: Creation of a database service
In order to explain how the tool works we will use the example contained in the folder "examples", where there is a file sql "e-commerce.sql" to be used to generate the test database.
The file creates a database of a simple e-commerce with three tables. The three tables are:
- user (fiscal code, name, surname, email)
- product (bar code, product name, description, quantity)
- order (Order id, product id, user id, quantity)
Creating a service for a database
- Creation of PostgreSql database and its tables and views (It's possible using the e-commerce example.
- Starting the Tool for generate the service (main_table_generator.ol)
- Change the information in the config.ini file.
- Start the script server TableGenerator.bat
- Start the script client CreateDbService.bat
- If everything went well the service is created
- Go in the folder "server" and run the jolie file "main_table_generator.ol
- Go in the folder "client" and run the jolie file "createDbService.ol
- If the creation of the service is successful, the server print the message: “Database table generation is finished with SUCCESS”.
- automatic
- custom
- createuser, createproduct and createorder
- getUser, getproduct and getOrder
- updateUser, updateproduct and updateorder
- removeuser, removeproduct and removeorder.
- Importing of the interface and the location
include"../db_services/e_commerce_handler_service/automatic_service/public/interfaces/includes.iol"
include "../db_services/e_commerce_handler_service/locations.iol" - Creation of an output port for the service
outputPort Test {
Location: e_commerce
Protocol: sodep
Interfaces: userInterface, orderInterface, productInterface
}
Note that the default location is "socket://localhost:9100" taht is contained inside the file locations.iol - Inside the main you can make the call to the service operations.
- column_value: value of the colum
- column_name: name of the column of the expression
- expression: the operator used to check the value, this is an ExpressionFilterType
- and_operator: we define this field only if we want to concatenate another expression, in this case an AND operator
- or_operator: we define this field only if we want to concatenate another expression, in this case an OR operator
- lteq: "<="
- eq: "="
- gt: ">"
- lt: "<"
- gteq: ">="
- noteq: "!="
- Ability to integrate the service, for more Database (Postgres, MySql ecc...).
- Possibility to extend the management of most types and especially more complex.
Contact
- Danilo Sorano's LinkedIn Profile
C