简体   繁体   中英

How do I update a Pentaho transformations connection data using Java?

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.

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: 在此处输入图片说明

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM