Package org.pentaho.di.trans

Examples of org.pentaho.di.trans.TransMeta


    try
    {
      final Repository repository = connectToRepository(logWriter);
      try
      {
        final TransMeta transMeta = loadTransformation(repository, resourceManager, resourceKey);
        transMeta.setArguments(params);
        final Trans trans = new Trans(transMeta);
        for (int i = 0; i < definedVariableNames.length; i++)
        {
          final ParameterMapping mapping = definedVariableNames[i];
          final String sourceName = mapping.getName();
          final String variableName = mapping.getAlias();
          final Object value = parameters.get(sourceName);
          if (value != null)
          {
            trans.setParameterValue(variableName, String.valueOf(value));
          }
        }

        transMeta.setInternalKettleVariables();
        trans.prepareExecution(transMeta.getArguments());

        TableProducer tableProducer = null;
        final List stepList = trans.getSteps();
        for (int i = 0; i < stepList.size(); i++)
        {
          final StepMetaDataCombi metaDataCombi = (StepMetaDataCombi) stepList.get(i);
          if (stepName.equals(metaDataCombi.stepname) == false)
          {
            continue;
          }
          final RowMetaInterface row = transMeta.getStepFields(stepName);
          tableProducer = new TableProducer(row, queryLimit, stopOnError);
          metaDataCombi.step.addRowListener(tableProducer);
          break;
        }
View Full Code Here


      throw new ReportDataFactoryException("No Transformation file given");
    }

    if (resourceManager == null || contextKey == null)
    {
      return new TransMeta(transformationFile, repository);
    }

    try
    {
      final ResourceKey resourceKey = createKey(resourceManager, contextKey);
      final Resource resource = resourceManager.create(resourceKey, contextKey, Document.class);
      final Document document = (Document) resource.getResource();
      final Node node = XMLHandler.getSubNode(document, TransMeta.XML_TAG);
      final TransMeta meta = new TransMeta();
      meta.loadXML(node, repository, true, null, null);
      final String filename = computeFullFilename(resourceKey);
      if (filename != null)
      {
        meta.setFilename(filename);
      }
      else
      {
        meta.setFilename(transformationFile);
      }
      return meta;
    }
    catch (ResourceException re)
    {
View Full Code Here

        // Spoon.getInstance().openFile(tmpFile.toString(), false);
        Spoon.getInstance().openFile(f.toString(), false);

        // assuming that the new one is the last one... a shame openFile does not return the opened TransMeta
        TransMeta[] transForms = Spoon.getInstance().getLoadedTransformations();
        TransMeta newOne = transForms[transForms.length - 1];

        // make it a prestine transformation
        newOne.setFilename(null);
        newOne.setChanged();

        if (changedInDialog) {
          MessageBox messageBox = new MessageBox(shell, SWT.ICON_QUESTION | SWT.NO | SWT.YES);
          messageBox.setText(BaseMessages.getString(PKG, "RubyStepDialog.OpenedSample.Title"));
          messageBox.setMessage(BaseMessages.getString(PKG, "RubyStepDialog.OpenedSample.Message"));
View Full Code Here

      throw new ReportDataFactoryException("No Transformation file given");
    }

    if (resourceManager == null || contextKey == null)
    {
      return new TransMeta(transformationFile, repository);
    }

    try
    {
      final ResourceKey resourceKey = createKey(resourceManager, contextKey);
      final Resource resource = resourceManager.create(resourceKey, contextKey, Document.class);
      final Document document = (Document) resource.getResource();
      final Node node = XMLHandler.getSubNode(document, TransMeta.XML_TAG);
      final TransMeta meta = new TransMeta();
      meta.loadXML(node, repository, true, null, null);
      final String filename = computeFullFilename(resourceKey);
      if (filename != null)
      {
        logger.debug("Computed Transformation Location: " + filename);
        meta.setFilename(filename);
      }
      else
      {
        logger.debug("No Computed Transformation Location, using raw name: " + transformationFile);
        meta.setFilename(transformationFile);
      }
      return meta;
    }
    catch (ResourceException re)
    {
View Full Code Here

  private TransMeta loadTransformation(final ResourceKey contextKey) throws KettleMissingPluginsException,
      KettlePluginException, KettleXMLException
  {
    final Document document = DocumentHelper.loadDocumentFromBytes(getTransformationRaw());
    final Node node = XMLHandler.getSubNode(document, TransMeta.XML_TAG);
    final TransMeta meta = new TransMeta();
    meta.loadXML(node, null, true, null, null);
    final String filename = computeFullFilename(contextKey);
    if (filename != null)
    {
      logger.debug("Computed Transformation Location: " + filename);
      meta.setFilename(filename);
    }
    return meta;
  }
View Full Code Here

    final Repository repository = connectToRepository();
    try
    {
      ResourceManager resourceManager = context.getResourceManager();
      final TransMeta transMeta = loadTransformation(repository, resourceManager, context.getContextKey());
      if (isDynamicTransformation(transMeta))
      {
        // we cannot safely guess columns from transformations that use Metadata-Injection.
        // So lets solve them the traditional way.
        return performQueryOnTransformation(parameter, 1, context, transMeta);
      }

      StepMeta step = transMeta.findStep(stepName);
      if (step == null)
      {
        throw new ReportDataFactoryException("Cannot find the specified transformation step " + stepName);
      }

      final RowMetaInterface row = transMeta.getStepFields(getStepName());
      final TableProducer tableProducer = new TableProducer(row, 1, true);
      return tableProducer.getTableModel();
    }
    catch (final EvaluationException e)
    {
View Full Code Here

    }

    final Repository repository = connectToRepository();
    try
    {
      final TransMeta transMeta = loadTransformation(repository, context.getResourceManager(), context.getContextKey());
      return performQueryOnTransformation(parameters, queryLimit, context, transMeta);
    }
    catch (final EvaluationException e)
    {
      throw new ReportDataFactoryException("Failed to evaluate parameter", e);
View Full Code Here

  public KettleParameterInfo[] getDeclaredParameter() throws KettleException, ReportDataFactoryException
  {
    if (parameters == null)
    {
      TransMeta transMeta = transformationProducer.loadTransformation(dataFactoryContext);
      String[] parameterNames = transMeta.listParameters();
      ArrayList<KettleParameterInfo> infos = new ArrayList<KettleParameterInfo>();
      for (String parameterName : parameterNames)
      {
        String defaultValue = transMeta.getParameterDefault(parameterName);
        String description = transMeta.getParameterDescription(parameterName);
        infos.add(new KettleParameterInfo(parameterName, description, defaultValue));
      }
      parameters = infos.toArray(new KettleParameterInfo[infos.size()]);
    }
    return parameters;
View Full Code Here

      return Collections.emptyList();
    }
    if (cachedSteps == null)
    {
      AbstractKettleTransformationProducer trans = loadTransformation(context);
      TransMeta transMeta = trans.loadTransformation(context);
      cachedSteps = Collections.unmodifiableList(transMeta.getSteps());
    }
    return cachedSteps;
  }
View Full Code Here

  private static TransMeta loadTemplate(String pluginId) throws KettleException
  {
    final Document document = DocumentHelper.loadDocumentFromPlugin(pluginId);
    final Node node = XMLHandler.getSubNode(document, TransMeta.XML_TAG);
    final TransMeta meta = new TransMeta();
    meta.loadXML(node, null, true, null, null);
    return meta;
  }
View Full Code Here

TOP

Related Classes of org.pentaho.di.trans.TransMeta

Copyright © 2018 www.massapicom. 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.