This is a sample plugin for Mitsi (more information on Mitsi here : https://github.com/jelebg/mitsi). Clone this repo if you want to create your own plugin. Any RDBMS can be addresed, provided that there is a JDBC driver available. PostgreSQL and Oracle JDBC drivers are already provided, but you may add any other driver with your plugin if you need to.
First you will need to install maven(version >3) and a jdk (version >7).
Then :
- Edit the file /src/main/resources/org/mitsi/datasources/mapper/oraclelight/IOracleLightMapper.xml You will have to change the SQL contains in this file. The are 6 mandatory SQL that you will have to adapt to your needs or your specific database :
- testOK
- getAllSchemas
- getTablesAndViews
- getSchemaIndexes
- getSchemaConstraints
- getData
The other SQLs are to display various informations, either for the whole database or for a specific table. There are not mandatory, you may provide 0 or N in your plugin if you want. But remember that this XML uses a MyBatis format : every SQL defined in this file has to match a java method with the same name in the file /src/main/java/org/mitsi/datasources/mapper/oraclelight/IOracleLightMapper.java (If you used MyBatis before, you already know that :) ). You will find variables in this SQLs :
- #{owner} is the schema containing the table(s) or other database objects that you want to explore
- #{tableName} are the name of the table.
inside the getData SQL, you will also find the following variables
- ${filter.name}
- #{filter.filter}
- ${orderByColumn.column}
- #{fromRow}
- #{count}
You may have noticed that sometime $ is used instead of #. This is a MyBatis syntax : # will use a bind variable to send the value to the database, whereas $ will copy it directly inside the SQL.
- Edit the file /src/main/java/org/mitsi/datasources/mapper/oraclelight/IOracleLightMapper.java
Please note that this class extends IMitsiMapper. This interface will provided the 6 mandatory methods corresponding to the 6 mandatory SQL defined in 1/ In this file you have to define a java class, using the following annotations :
-
for the class : @MitsiProviderMapper("xxx") xxx will have to match the field ""provider"" inside your configuration file ""mitsi-datasources.json""
-
for the methods : @MitsiTableDetail(value="xxx", order=1) or @MitsiDatasourceDetail(value="xxx", order=1). The annotation will indicate if the method will display informations on a table or on a datasource. "xxx" will give the name of the accordion or tab that will display this peace of information.
-
@MitsiColumnTitles will allow you to give another name to the column of the SQL when displayed in Mitsi
-
@MitsiColumnsAsRows (optional) will display one row for each column returned by the SQL. It works only if there is only one row returned by the SQL ...
You can provide as many method annoted by @MitsiTableDetail or @MitsiDatasourceDetail as you want, provided that they have a match in the XML described in 1.
-
Adapt the tests suites defined in src/test. You are free to delete every test if you want, do what you want.
-
Compile it using : mvn clean install
-
To install your plugin in mitsi, copy the .jar generated in the folder target/ inside the plugins/ folder of your Mitsi's intallation. Place the JDBC driver's jar in the same folder.
-
Configure a datasource using your plugin in mitsi-datasources.json. As mentionned before, the "provider" field will have to match the value given in the annotation @MitsiProviderMapper of your plugin.
-
restart mitsi and enjoy.