且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有没有办法检查pentaho中是否存在文件夹?

更新时间:2021-07-18 23:06:41

但是在Pentaho中使用它会更加复杂.当创建Job而不是转换时,直接Java是不直接可用的(据我所知).好消息是PDI的JavaScript解释器是Rhino.这意味着所有Java对象和类都可用于JavaScript.因此,检查非常简单.

But to use it in Pentaho is more complicated. When creating a Job rather than a transform, straight Java is not directly available (that I know of). The good news is PDI's JavaScript interpreter is Rhino. That means all Java's objects and classes are available to JavaScript. As such the check is pretty easy.

在作业中添加变量或参数,然后将其命名为dirpath,并为其提供求值路径.然后在工作中添加一个JavaScript步骤,并在其中添加以下代码:

Add a variable or parameter in your job and call it something like dirpath and give it a path to evaluate. Then add a JavaScript step to the job and add put the following code in it:

dirpath = parent_job.getVariable("dirpath");
fileobj = new java.io.File(dirpath);
fileobj.isDirectory();

根据最后一行的真相,控件将从此步骤开始沿成功或失败路径流动.

Control will flow down the Success or Failure paths from this step based on the truth of the last line.

Pentaho可能会将该功能添加到他们的检查文件是否存在"步骤中,但与此同时,这将起作用. OTOH,可能是可以编写的自定义插件的另一个很好的例子.

Pentaho will likely add that capability to their Check if File Exists step soon, but in the mean time, this will work. OTOH, might be another good example of a custom plugin that could be written.