简体   繁体   中英

Pentaho java api job

I am currently using Java API to connect to Pentaho Repository.I want to know if we have any methods if a particular Pentaho file is of Job or Transformation type. I am using samle code as below.Here if you see I am manually creating Jobmeta or Transmeta. Is there any API to get the pentao job type.

Repository repository = new PentahoContext().initialize(repositoryName,
                       userName, password);

RepositoryDirectoryInterface directoryPublic = repository
                       .loadRepositoryDirectoryTree();

RepositoryDirectoryInterface directoryPublic1 = directoryPublic
                       .findDirectory(“/home");

JobMeta jobMeta = repository.loadJob(jobName, directoryPublic1, null,
                       null);

I don't think you can query for a single file, but you can use Repository.getJobAndTransformationObjects() or RepositoryDirectoryInterface.getRepositoryObjects() to return a list of objects in the specified directory. You can then iterate over that list looking for the object with that name, then call getObjectType() to see if it is equal to RepositoryObjectType.TRANSFORMATION or RepositoryObjectType.JOB:

// pseudo-Java code 
repositoryObjects = repository.getJobAndTransformationObjects( directoryPublic1.getObjectId(), false );

for (RepositoryElementMetaInterface object : repositoryObjects) {
  if(object.getName().equals("myFile")) {
    if(object.getObjectType().equals(RepositoryObjectType.TRANSFORMATION) {
      TransMeta transMeta = repository.loadTransformation(...);
    }
    else if(object.getObjectType().equals(RepositoryObjectType.JOB) {
      JobMeta jobMeta = repository.loadJob(...);
    }
  }
}

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