Package org.pentaho.reporting.engine.classic.extensions.datasources.kettle

Source Code of org.pentaho.reporting.engine.classic.extensions.datasources.kettle.KettleTransFromRepositoryProducer

/*
* This program is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
* Foundation.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
* or from the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* Copyright (c) 2008 - 2009 Pentaho Corporation, .  All rights reserved.
*/

package org.pentaho.reporting.engine.classic.extensions.datasources.kettle;

import java.util.ArrayList;

import org.pentaho.di.core.exception.KettleException;
import org.pentaho.di.repository.Repository;
import org.pentaho.di.repository.RepositoryDirectoryInterface;
import org.pentaho.di.trans.TransMeta;
import org.pentaho.reporting.engine.classic.core.ParameterMapping;
import org.pentaho.reporting.engine.classic.core.ReportDataFactoryException;
import org.pentaho.reporting.libraries.resourceloader.ResourceKey;
import org.pentaho.reporting.libraries.resourceloader.ResourceManager;

/**
* This class requires access to the system-properties and the local filesystem. I do not believe
* that this code can be safely executed under a restrictive security manager rule.
*
* @author Thomas Morgner
*/
public class KettleTransFromRepositoryProducer extends AbstractKettleTransformationProducer
{
  private String directoryName;
  private String transformationName;

  public KettleTransFromRepositoryProducer(final String repositoryName,
                                           final String directoryName,
                                           final String transformationName,
                                           final String stepName,
                                           final String username,
                                           final String password,
                                           final String[] definedArgumentNames,
                                           final ParameterMapping[] definedVariableNames)
  {
    super(repositoryName, stepName, username, password, definedArgumentNames, definedVariableNames);
    if (directoryName == null)
    {
      throw new NullPointerException();
    }
    if (transformationName == null)
    {
      throw new NullPointerException();
    }

    this.directoryName = directoryName;
    this.transformationName = transformationName;
  }

  public String getDirectoryName()
  {
    return directoryName;
  }

  public String getTransformationName()
  {
    return transformationName;
  }

  protected TransMeta loadTransformation(final Repository repository,
                                         final ResourceManager resourceManager,
                                         final ResourceKey contextKey)
      throws ReportDataFactoryException, KettleException
  {
    // Find the directory specified.
    final RepositoryDirectoryInterface repositoryDirectory = repository.loadRepositoryDirectoryTree().findDirectory(directoryName);
    if (repositoryDirectory == null)
    {
      throw new ReportDataFactoryException("No such directory in repository: " + directoryName);
    }
    return repository.loadTransformation(transformationName, repositoryDirectory, null, true, null);
  }

  public Object getQueryHash(final ResourceManager resourceManager, final ResourceKey resourceKey)
  {
    final ArrayList<Object> retval = internalGetQueryHash();
    retval.add(getDirectoryName());
    retval.add(getTransformationName());
    return retval;
  }
}
TOP

Related Classes of org.pentaho.reporting.engine.classic.extensions.datasources.kettle.KettleTransFromRepositoryProducer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.