0
votes

I’m using Java to build a restful API around the functionality of Pentaho data integration.

I’ve implemented several end points such as the ability to create a repository containing jobs and transformations, running the jobs and transformations, displaying the image of the job and transformations, displaying the database connections within a repo, plus quite a few more.

I’m trying to build an endpoint that allows for the data sources to be changed, such as the hostname, database name, etc. But I’ve run into an issue when it comes to saving the new connection details.

Here’s a snippet of code I’ve got. I’ve hard coded the values simply for testing purposes. I loop through an array list containing the DatabaseMeta and then change the values of the fields.

for(DatabaseMeta meta: databaseMeta) {
       meta.setHostName(“test_host”) ;
       meta.setDBPort(“test_port”);
       meta.setDBName(“test_database”);
       repositoryService.updateDataSource(databaseMeta);
 }

The updateDatasource() method simply invokes repository.save() (which is part of the org.pentaho.di.repository package) and passes in the DatabaseMeta.

When this method executes, it creates a .kdb file in my repository, with the values I set above, and making a GET request to the endpoint returns the connection details from the new file. However, I simply want to overwrite the values in the existing transformation connection and return them in the GET request. Is there any way that this can be achieved? Any help will be greatly appreciated.

Thanks.

1
Just to check that you do not reinvent the wheel : (1) are you aware of carte a web API around PDI? (2) do you know the kettle.properties file?AlainD
So you want to get the values of the new connection without creating a new .kdb in the repository?AlainD
I'm aware of Carte, but the company I work for want to, as you say, "reinvent the wheel".J.A
Yes, I want to be able to store the new connection details in the exiting .ktr and then be able to retrieve them in the GET request, without creating a new .kdb in the repository. Is this possible? I've been racking my brain for 3 days trying to resolve it.J.A
I do not think so. The updateDatasource, which is a must, will automatically creates a new .kdb. What you can do however is to create a new tmp datasource which you delete afterwards.AlainD

1 Answers

0
votes

I don't know about the JAVA integration part, but as far as pure Pentaho goes, the Database Connection stated in the KTR/KJB needs to have the same parameters declared in the KTR/KJB, as such: enter image description here

This way, whatever parameters you pass through to the KTR/KJB will be swapped out in the connection.