有没有办法检查pentaho中是否存在文件夹? [英] Is there a way to check for existence of a folder in pentaho?

查看:81
本文介绍了有没有办法检查pentaho中是否存在文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道有一个检查文件夹是否为空",但它不检查文件夹是否存在.

I know that there is a "Check if a folder is empty", but it does not check for existing of the folder.

推荐答案

但是在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.

这篇关于有没有办法检查pentaho中是否存在文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆