BellaDati is Java Enterprise Application. It is working with different libraries to support various analytics and machine learning algorithms. This tutorial shows, how to use your custom Java Library (JAR) directly from within the Formula editor. Same Java Library will become available also from Transformation script editor without additional efforts. There are 3 prerequisites to make it work

  • You have to have full access to on-premise installation of BellaDati (otherwise contact your admin or cloud provider)
  • Your Java class location must not interfere with other classes used by BellaDati. Using your company web address as an Java package structure is good idea
  • Properties of your Java Class have to be marked as static. As you can see in code used in Outerclass, that we are using for this tutorial

    Our custom Outerclass.java
    package com.martin.knn;
    import java.util.*;
     
    public class Outerclass {
     
     public static String Saysomething(String string){
      return (string);
     }

For this tutorial we will use our dummy Outerclass example. Your Java classes have to be provided in JAR file package. Outerclass is packaged in the Outerclass.jar file.Feel free to download it here. After finishing this tutorial, you will be able to use Outerclass properties (methods, variables) directly from Formula editor and from Transformation script editor.Picture below shows, that your code can be really powerful. In case of example in the picture it is custom KNN machine learning algorithm being used in the Report's Formula editor.

Step 1 - Injecting the JAR file into the BellaDati

Use Outerclass.jar file (or use your own jar file, that includes your classes). Search for the lib directory located in your_belladati_installation_folder/belladati/WEB-INF/lib. Complete path to the lib directory can differ according the installation path of your Application server and according type of Application server that you use. In this tutorial we use Glassfish and path to the lib folder can be seen on the picture below.

 

Now copy Outerclass.jar into the belladati/WEB-INF/lib folder and do not forget to restart your Application server.

Step 2 - Using custom class in Formula editor

Now is the time to check if we can use our Outerclass. Create new BellaDati report. Create new KPILabel view. Name it Outerclass. Into the KPI label view add new calculated KPI called Outerclass. Into the Formula editor insert following snippet of the code to test that everything works

Formula editor code using Outerclass
import static com.martin.knn.Outerclass.*
return Saysomething("is COOL!")

Below you can see, that our Outerclass KPI has COOL! output

Step 3 - Manage your custom libraries

Backup your custom Libraries into the separate Folder. With each new installation of BellaDati you will have to copy your Libraries into the BellaDati again

Tips on debugging and coding

 

 

  • No labels