Groovy API functions
As of version 8, d.3 server has a plug-in interface for API functions.
This allows you to register your own API functions developed in Java/Groovy.
Like other d.3 API functions, these can be called via the d.3 communication protocol d3fc.
Warning
Groovy API functions are not available via the d.3 web service API interface
The Groovy API functions can be used in d.ecs forms via the scripting contained therein, as well as for d.velop’s own projects.
Activating the plug-in interface
Open d.3 admin > System settings > d. 3 config.
Enter a directory in the Java/Groovy section for the Java/Groovy API functions entry.
The system will search for Groovy scripts that implement d.3 API functions in this directory and load them from this directory.
This activates the plug-in interface for API functions.
For a Java class to be loaded and registered as a d.3 API function, the Java class must be derived from the class D3ApiCall and implement a method public int execute(D3Interface d3).
The D3Interface is then available above this.
import com.dvelop.d3.server.core.D3Interface;
import com.dvelop.d3.server.D3ApiCall;
import com.dvelop.d3.server.User;
public class GetMyDBData extends D3ApiCall
{
public int execute(D3Interface d3)
{
def import_param = d3.remote.getImportParams()
def id_value = import_param.get("id")
def resultset = d3.sql.executeAndGet("SELECT column1, column2 FROM mytable WHERE id like ?", [id_value])
d3.remote.setExportTable( resultset )
d3.remote.setExportParams(["number" : resultset.size()])
return 0
}
}