首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

pentaho 4.8 平添 kettle 文件资源库的支持

2013-10-30 
pentaho 4.8 添加 kettle 文件资源库的支持pentaho 4.8 添加 kettle 默认情况下只对数据库资源库的支持对

pentaho 4.8 添加 kettle 文件资源库的支持

pentaho 4.8 添加 kettle 默认情况下只对数据库资源库的支持

对于文件资源库是不支持的。

与文件资源库相比,数据库资源库不利于开发与维护。

pentaho在国内的资料很少,社区不太活跃,其稍微深入的问题都没有现成的答案。。。

看源码,发现其代码里面没有添加对文件资源库的支持。

好在 pentaho 与 kettle 的核心源码都看过。。。小小改动下,还是让其能够支持文件资源库了。。。

修改

org.pentaho.platform.plugin.action.kettle.KettleComponent类

搜索

PentahoSystem.getSystemSetting("kettle/settings.xml", "repository.type", "files").equals("rdbms");

发现有三处

验证系统设置

  @Override  protected boolean validateSystemSettings() {    // set pentaho.solutionpath so that it can be used in file paths    boolean useRepository = PentahoSystem.getSystemSetting("kettle/settings.xml", "repository.type", "files").equals("rdbms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$    if (useRepository) {      repositoriesXMLFile = PentahoSystem.getSystemSetting("kettle/settings.xml", "repositories.xml.file", null); //$NON-NLS-1$ //$NON-NLS-2$      repositoryName = PentahoSystem.getSystemSetting("kettle/settings.xml", "repository.name", null); //$NON-NLS-1$ //$NON-NLS-2$      username = PentahoSystem.getSystemSetting("kettle/settings.xml", "repository.userid", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$      password = PentahoSystem.getSystemSetting("kettle/settings.xml", "repository.password", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$      // Check the Kettle settings...      if ("".equals(repositoryName) || username.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$        // looks like the Kettle stuff is not configured yet...        // see if we can provide feedback to the user...        error(Messages.getErrorString("Kettle.ERROR_0001_SERVER_SETTINGS_NOT_SET")); //$NON-NLS-1$        return false;      }      boolean ok = ((repositoryName != null) && (repositoryName.length() > 0));      ok = ok || ((username != null) && (username.length() > 0));      return ok;    } else {        repositoriesXMLFile = PentahoSystem.getSystemSetting("kettle/settings.xml", "repositories.xml.file", null); //$NON-NLS-1$ //$NON-NLS-2$        repositoryName = PentahoSystem.getSystemSetting("kettle/settings.xml", "repository.name", null); //$NON-NLS-1$ //$NON-NLS-2$        // Check the Kettle settings...        if ("".equals(repositoryName)) { //$NON-NLS-1$ //$NON-NLS-2$          // looks like the Kettle stuff is not configured yet...          // see if we can provide feedback to the user...          error(Messages.getErrorString("Kettle.ERROR_0001_SERVER_SETTINGS_NOT_SET")); //$NON-NLS-1$          return false;        }        boolean ok = ((repositoryName != null) && (repositoryName.length() > 0));        return ok;    }  }

?

其验证Action,注释一部分如下

?

  @SuppressWarnings("unchecked")  @Override  public boolean validateAction() {    ...    if (isDefinedResource(KettleComponent.TRANSFORMFILE) || isDefinedResource(KettleComponent.JOBFILE)) {      return true;    }/*    boolean useRepository = PentahoSystem.getSystemSetting("kettle/settings.xml", "repository.type", "files").equals("rdbms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$    if (!useRepository) {      error(Messages.getErrorString("Kettle.ERROR_0019_REPOSITORY_TYPE_FILES")); //$NON-NLS-1$      return false;    }*/    if (isDefinedInput(KettleComponent.DIRECTORY) && (isDefinedInput(KettleComponent.TRANSFORMATION) || isDefinedInput(KettleComponent.JOB))) {      return true;    }    ...  }

?修改其连接资源库部分

  private Repository connectToRepository(final LogWriter logWriter) {    boolean useRepository = PentahoSystem.getSystemSetting("kettle/settings.xml", "repository.type", "files").equals("rdbms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$    if (!useRepository) {// if方法默认返回为空,这里添加对文件资源库的支持。        RepositoriesMeta repositoriesMeta = null;        try {          repositoriesMeta = new RepositoriesMeta();        } catch (Exception e) {          error(Messages.getErrorString("Kettle.ERROR_0007_BAD_META_REPOSITORY"), e); //$NON-NLS-1$          return null;        }        if (ComponentBase.debug) {          debug(Messages.getString("Kettle.DEBUG_POPULATING_META")); //$NON-NLS-1$        }        try {          // TODO: add support for specified repositories.xml files...          repositoriesMeta.readData(); // Read from the default          // $HOME/.kettle/repositories.xml          // file.        } catch (Exception e) {          error(Messages.getErrorString("Kettle.ERROR_0018_META_REPOSITORY_NOT_POPULATED"), e); //$NON-NLS-1$          return null;        }        if (ComponentBase.debug) {          debug(Messages.getString("Kettle.DEBUG_FINDING_REPOSITORY")); //$NON-NLS-1$        }        // Find the specified repository.        RepositoryMeta repositoryMeta = null;        try {          repositoryMeta = repositoriesMeta.findRepository(repositoryName);        } catch (Exception e) {          error(Messages.getErrorString("Kettle.ERROR_0004_REPOSITORY_NOT_FOUND", repositoryName), e); //$NON-NLS-1$          return null;        }        if (repositoryMeta == null) {          error(Messages.getErrorString("Kettle.ERROR_0004_REPOSITORY_NOT_FOUND", repositoryName)); //$NON-NLS-1$          return null;        }        if (ComponentBase.debug) {          debug(Messages.getString("Kettle.DEBUG_GETTING_REPOSITORY")); //$NON-NLS-1$        }        Repository repository = null;        try {                    repository = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, repositoryMeta.getId(), Repository.class);          repository.init(repositoryMeta);        } catch (Exception e) {          error(Messages.getErrorString("Kettle.ERROR_0016_COULD_NOT_GET_REPOSITORY_INSTANCE"), e); //$NON-NLS-1$          return null;        }        // OK, now try the username and password        if (ComponentBase.debug) {          debug(Messages.getString("Kettle.DEBUG_CONNECTING")); //$NON-NLS-1$        }      return repository;    }    。。。  }

?

具体修改后的源代码文件以及生成的类文件在附件中。

?

?

?

热点排行