Java Code Examples for org.pentaho.di.trans.TransMeta

The following are top voted examples for showing how to use org.pentaho.di.trans.TransMeta. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: KettleEasyExpand   File: KettleUtils.java   Source Code and License 8 votes vote down vote up
/**
* 生成转换图 <br/>
* @author jingma
* @param transMeta
* @return
* @throws Exception
*/
public static BufferedImage generateTransformationImage( TransMeta transMeta ) throws Exception {
  float magnification = 1.0f;
  Point maximum = transMeta.getMaximum();
  maximum.multiply( magnification );

  SwingGC gc = new SwingGC( null, maximum, 32, 0, 0 );
  TransPainter transPainter =
    new TransPainter(
      gc, transMeta, maximum, null, null, null, null, null, new ArrayList<AreaOwner>(),
      new ArrayList<StepMeta>(), 32, 1, 0, 0, true, "Arial", 10 );
  transPainter.setMagnification( magnification );
  transPainter.buildTransformationImage();

  BufferedImage image = (BufferedImage) gc.getImage();

  return image;
}
 
Example 2
Project: KettleEasyExpand   File: KettleUtils.java   Source Code and License 6 votes vote down vote up
/**
* 将指定转换复制到KettleUtils中的资源库 <br/>
* @author jingma
* @param jobName 转换名称
* @param jobPath 转换路径
   * @param fromRepository 来源资源库
   * @param toRepository 目标资源库
* @throws KettleException
*/
public static void transCopy(String transName,String transPath,Repository fromRepository,
           Repository toRepository) throws KettleException {
	TransMeta tm = KettleUtils.loadTrans(transName, transPath, fromRepository);
	for(StepMeta sm:tm.getSteps()){
		if(sm.isJobExecutor()){
			JobExecutorMeta jem = (JobExecutorMeta)sm.getStepMetaInterface();
			jobCopy(jem.getJobName(),jem.getDirectoryPath(),fromRepository,toRepository);
		}
		else if(sm.getStepMetaInterface() instanceof TransExecutorMeta){
			TransExecutorMeta te = (TransExecutorMeta)sm.getStepMetaInterface();
			transCopy(te.getTransName(), te.getDirectoryPath(),fromRepository,toRepository);
		}
	}
	if(!isDirectoryExist(toRepository,transPath)){
		//所在目录不存在则创建
	    toRepository.createRepositoryDirectory(toRepository.findDirectory("/"), transPath);
	}
	tm.setRepository(toRepository);
	tm.setMetaStore(toRepository.getMetaStore());
	KettleUtils.saveTrans(toRepository,tm);
}
 
Example 3
Project: KettleUtil   File: KettleUtils.java   Source Code and License 6 votes vote down vote up
/**
* 将指定转换复制到KettleUtils中的资源库 <br/>
* @author jingma
* @param jobName 转换名称
* @param jobPath 转换路径
   * @param fromRepository 来源资源库
   * @param toRepository 目标资源库
* @throws KettleException
*/
public static void transCopy(String transName,String transPath,Repository fromRepository,
           Repository toRepository) throws KettleException {
	TransMeta tm = KettleUtils.loadTrans(transName, transPath, fromRepository);
	for(StepMeta sm:tm.getSteps()){
		if(sm.isJobExecutor()){
			JobExecutorMeta jem = (JobExecutorMeta)sm.getStepMetaInterface();
			jobCopy(jem.getJobName(),jem.getDirectoryPath(),fromRepository,toRepository);
		}
		else if(sm.getStepMetaInterface() instanceof TransExecutorMeta){
			TransExecutorMeta te = (TransExecutorMeta)sm.getStepMetaInterface();
			transCopy(te.getTransName(), te.getDirectoryPath(),fromRepository,toRepository);
		}
	}
	if(!isDirectoryExist(toRepository,transPath)){
		//所在目录不存在则创建
	    toRepository.createRepositoryDirectory(toRepository.findDirectory("/"), transPath);
	}
	tm.setRepository(toRepository);
	tm.setMetaStore(toRepository.getMetaStore());
	KettleUtils.saveTrans(toRepository,tm);
}
 
Example 4
Project: pdi-git-plugin   File: PdiDiffTest.java   Source Code and License 6 votes vote down vote up
@Test
public void diffTransTest() throws Exception {
  File file = new File( "src/test/resources/r1.ktr" );
  InputStream xmlStream = new FileInputStream( file );
  TransMeta transMeta = new TransMeta( xmlStream, null, true, null, null );
  transMeta.sortSteps();

  File file2 = new File( "src/test/resources/r2.ktr" );
  InputStream xmlStream2 = new FileInputStream( file2 );
  TransMeta transMeta2 = new TransMeta( xmlStream2, null, true, null, null );
  transMeta2.sortSteps();

  transMeta = compareSteps( transMeta, transMeta2, true );
  transMeta2 = compareSteps( transMeta2, transMeta, false );
  assertEquals( UNCHANGED, transMeta.getStep( 0 ).getAttribute( ATTR_GIT, ATTR_STATUS ) );
  assertEquals( CHANGED, transMeta.getStep( 1 ).getAttribute( ATTR_GIT, ATTR_STATUS ) );
  assertEquals( REMOVED, transMeta.getStep( 2 ).getAttribute( ATTR_GIT, ATTR_STATUS ) );
  assertEquals( ADDED, transMeta2.getStep( 2 ).getAttribute( ATTR_GIT, ATTR_STATUS ) );
}
 
Example 5
Project: pentaho-pdi-streaming   File: ListStreamingServicesServlet.java   Source Code and License 6 votes vote down vote up
protected void startTransformation( Repository repository, IMetaStore metaStore, final StreamingService service ) {
  try {

    TransMeta transMeta = StreamingConst.loadTransMeta( repository, metaStore, service );
    Trans trans = new Trans( transMeta );
    String carteObjectId = UUID.randomUUID().toString();
    trans.setContainerObjectId( carteObjectId );
    
    if (service.getLogLevel()!=null) {
      trans.setLogLevel(service.getLogLevel());
    }
    TransExecutionConfiguration transExecutionConfiguration = new TransExecutionConfiguration();
    TransConfiguration transConfiguration = new TransConfiguration( transMeta, transExecutionConfiguration );
    transformationMap.addTransformation( transMeta.getName(), carteObjectId, trans, transConfiguration );
    trans.prepareExecution( null );

    // Start the transformation

    trans.startThreads();
    
    // This transformation routinely never ends so we won't wait for it...
    
  } catch ( Exception e ) {
    throw new RuntimeException( "Unable to start transformation for streaming service '" + service.getName() + "'", e );
  }
}
 
Example 6
Project: kettle-docker   File: DockerTransExecutorDialog.java   Source Code and License 6 votes vote down vote up
public DockerTransExecutorDialog(Shell parent, Object in, TransMeta transMeta, String stepname) {
    super("com/github/brosander/kettle/docker/dockerTransExecutorDialog.xul", parent, (BaseStepMeta) in, transMeta, stepname);
    loadMeta((DockerTransExecutorMeta) baseStepMeta);
    this.stepname = stepname;
    tempStepName = stepname;
    this.transMeta = transMeta;
    try {
        bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
        bf.createBinding(this, "tempStepName", "step-name", "value").fireSourceChanged();
        bf.createBinding(this, DockerTransExecutorMeta.IMAGE, "image", "value").fireSourceChanged();
        bf.createBinding(this, DockerTransExecutorMeta.TRANSFORMATION, "transformation", "value").fireSourceChanged();
        bf.createBinding(this, DockerTransExecutorMeta.KILL_CONTAINER, "killContainer", "checked").fireSourceChanged();
        bf.createBinding(this, DockerTransExecutorMeta.REMOVE_CONTAINER, "removeContainer", "checked").fireSourceChanged();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
 
Example 7
Project: pentaho-pdi-dataset   File: SpoonFlagUnitTestExtensionPoint.java   Source Code and License 6 votes vote down vote up
@Override
public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException {
  if ( !( object instanceof TransMeta ) ) {
    return;
  }
  
  TransMeta transMeta = (TransMeta) object;
  
  String unitTestName = transMeta.getAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_TRANS_SELECTED_UNIT_TEST_NAME );
  
  if (!Const.isEmpty( unitTestName )) {
    // We're running in Spoon and there's a unit test selected : test it
    //
    System.out.println( "==== Running unit test on this transformation ====" );
    transMeta.setVariable( DataSetConst.VAR_RUN_UNIT_TEST, "Y" );
  }
}
 
Example 8
Project: pentaho-pdi-dataset   File: ShowUnitTestMenuExtensionPoint.java   Source Code and License 6 votes vote down vote up
protected void editUnitTest(String unitTestName, TransMeta transMeta) {
  try {
    Spoon spoon = Spoon.getInstance();
    MetaStoreFactory<TransUnitTest> setFactory = new MetaStoreFactory<TransUnitTest>(
        TransUnitTest.class, spoon.getMetaStore(), PentahoDefaults.NAMESPACE);
    TransUnitTest unitTest = setFactory.loadElement(unitTestName);
    if (unitTest==null) {
      throw new KettleException(BaseMessages.getString(PKG, "ShowUnitTestMenuExtensionPoint.ErrorEditingUnitTest.Message", unitTestName));
    }
    TransUnitTestDialog dialog = new TransUnitTestDialog(spoon.getShell(), transMeta, spoon.getMetaStore(), unitTest);
    if (dialog.open()) {
      setFactory.saveElement(unitTest);
    }
  } catch(Exception exception) {
    new ErrorDialog(Spoon.getInstance().getShell(), 
        BaseMessages.getString(PKG, "ShowUnitTestMenuExtensionPoint.ErrorEditingUnitTest.Title"),
        BaseMessages.getString(PKG, "ShowUnitTestMenuExtensionPoint.ErrorEditingUnitTest.Message", unitTestName), 
        exception);
  }
}
 
Example 9
Project: pentaho-pdi-dataset   File: DataSetHelper.java   Source Code and License 6 votes vote down vote up
private boolean checkTestPresent(Spoon spoon, TransMeta transMeta) {
  
  spoon.getLog().logBasic("Check test present...");
  
  String testName = transMeta.getAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_TRANS_SELECTED_UNIT_TEST_NAME );
  if (!Const.isEmpty( testName )) {
    return false;
  }
  
  // there is no test defined of selected in the transformation.
  // Show a warning
  //
  MessageBox box = new MessageBox(spoon.getShell(), SWT.OK | SWT.ICON_INFORMATION );
  box.setMessage("Please create a test-case first by left clicking on the test icon.");
  box.setText("First create a test-case");
  box.open();
  
  return true;
}
 
Example 10
Project: pentaho-pdi-dataset   File: DataSetHelper.java   Source Code and License 6 votes vote down vote up
public void detachUnitTest() {
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  try {
    TransGraph transGraph = spoon.getActiveTransGraph();
    if ( transGraph == null ) {
      return;
    }
    TransMeta transMeta = spoon.getActiveTransformation();
    if (transMeta == null ) {
      return;
    }

    transMeta.setAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_TRANS_SELECTED_UNIT_TEST_NAME, null );
    transMeta.setChanged();
    
    DataSetConst.clearStepDataSetIndicators( transMeta );
    
    spoon.refreshGraph();
  } catch ( Exception e ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error detaching unit test", e );
  }
}
 
Example 11
Project: pentaho-cassandra-plugin   File: CassandraInputDialog.java   Source Code and License 5 votes vote down vote up
private void preview() {
    CassandraInputMeta oneMeta = new CassandraInputMeta();
    getInfo(oneMeta, true);

    TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(this.transMeta, oneMeta, this.wStepname.getText());

    EnterNumberDialog numberDialog = new EnterNumberDialog(this.shell, this.props.getDefaultPreviewSize(),
            BaseMessages.getString(PKG, "AutSoftCassandraInputDialog.EnterPreviewSize"),
            BaseMessages.getString(PKG, "AutSoftCassandraInputDialog.NumberOfRowsToPreview"));
    int previewSize = numberDialog.open();

    if (previewSize > 0) {
        TransPreviewProgressDialog progressDialog = new TransPreviewProgressDialog(this.shell, previewMeta,
                new String[]{this.wStepname.getText()}, new int[]{previewSize});
        progressDialog.open();

        Trans trans = progressDialog.getTrans();
        String loggingText = progressDialog.getLoggingText();

        if (!progressDialog.isCancelled()) {
            if ((trans.getResult() != null) && (trans.getResult().getNrErrors() > 0L)) {
                EnterTextDialog etd = new EnterTextDialog(this.shell,
                        BaseMessages.getString(PKG, "System.Dialog.PreviewError.Title"),
                        BaseMessages.getString(PKG, "System.Dialog.PreviewError.Message"), loggingText, true);
                etd.setReadOnly();
                etd.open();
            } else {
                PreviewRowsDialog prd = new PreviewRowsDialog(this.shell, this.transMeta, 0, this.wStepname.getText(),
                        progressDialog.getPreviewRowsMeta(this.wStepname.getText()),
                        progressDialog.getPreviewRows(this.wStepname.getText()), loggingText);
                prd.open();
            }
        }
    }
}
 
Example 12
Project: KettleEasyExpand   File: KettleUtils.java   Source Code and License 5 votes vote down vote up
/**
* 步骤数据预览 <br/>
* @author jingma
* @param teans 转换
* @param testStep 步骤名称
* @param smi 步骤实体
* @param previewSize 预览的条数
* @return 预览结果
*/
public static List<List<Object>> stepPreview(TransMeta teans,
		String testStep, StepMetaInterface smi, int previewSize) {
	TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(
			teans,
			smi,
			testStep);
	TransPreviewUtil tpu = new TransPreviewUtil(
			previewMeta,
	        new String[] { testStep },
	        new int[] { previewSize } );
	tpu.doPreview();
	return TransPreviewUtil.getData(tpu.getPreviewRowsMeta(testStep),tpu.getPreviewRows(testStep));
}
 
Example 13
Project: KettleEasyExpand   File: KettleUtils.java   Source Code and License 5 votes vote down vote up
/**
* 修复转换连接线 <br/>
* @author jingma
* @param tm 转换元数据
*/
public static void repairTransHop(TransMeta tm) {
    for(int i=0;i<tm.nrTransHops();i++){
        TransHopMeta hop = tm.getTransHop(i);
        hop.setFromStep(tm.findStep(hop.getFromStep().getName()));
        hop.setToStep(tm.findStep(hop.getToStep().getName()));
    }
}
 
Example 14
Project: KettleEasyExpand   File: KettleUtils.java   Source Code and License 5 votes vote down vote up
/**
	 * @return transMetaTemplate 
	 */
	public static TransMeta getTransMetaTemplate() {
//		if(transMetaTemplate==null){
//			setTransMetaTemplate(KettleUtils.loadTrans(SysCode.TRANS_TEMPLATE_NAME, SysCode.TEMPLATE_DIR));
//		}
		return transMetaTemplate;
	}
 
Example 15
Project: KettleEasyExpand   File: TransPreviewUtil.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a new dialog that will handle the wait while previewing a transformation...
 */
public TransPreviewUtil( TransMeta transMeta, String[] previewStepNames, int[] previewSize ) {
  this.transMeta = transMeta;
  this.previewStepNames = previewStepNames;
  this.previewSize = previewSize;

  cancelled = false;
}
 
Example 16
Project: KettleEasyExpand   File: EasyExpandMeta.java   Source Code and License 5 votes vote down vote up
public String getDefaultConfigInfo(TransMeta transMeta, String stepName, VariableSpace space) throws Exception {
    if(StringUtils.isNotBlank(getClassName())){
        //实例化配置的类,获取输出字段
        EasyExpandRunBase kui = (EasyExpandRunBase) Class.forName(space.environmentSubstitute(getClassName())).newInstance();
        kui.setKu(null);
        kui.setMeta(this,space);
        return kui.getDefaultConfigInfo(transMeta,stepName);
    }
    return null;
}
 
Example 17
Project: KettleEasyExpand   File: EasyExpandDemo.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * @see cn.benma666.kettle.steps.easyexpand.EasyExpandRunBase#getDefaultConfigInfo(org.pentaho.di.trans.TransMeta, java.lang.String)
 */
 @Override
 public String getDefaultConfigInfo(TransMeta transMeta, String stepName) throws Exception{
    //创建一个JSON对象,用于构建配置对象,避免直接拼字符串构建JSON字符串
    JSONObject params = new JSONObject();
    //设置一个参数key1
    params.put("key1", "");
    RowMetaInterface fields = transMeta.getPrevStepFields(stepName);
    if(fields.size()==0){
        throw new RuntimeException("没有获取到上一步骤的字段,请确认连接好上一步骤");
    }
    params.put("PrevInfoFields", fields.toString());
    //创建一个JSON数组对象,用于存放数组参数
    JSONArray arr = new JSONArray();
    arr.add("arr1");
    arr.add("arr2");
    params.put("array", arr);
    //生成的参数样例
    //{
    //  "array":[
    //          "arr1",
    //          "arr2"
    //  ],
    //  "key1":""
    //}
    //返回格式化后的默认JSON配置参数,供使用者方便快捷的修改配置
    return JSON.toJSONString(params, true);
}
 
Example 18
Project: KettleUtil   File: KettleUtils.java   Source Code and License 5 votes vote down vote up
/**
* 步骤数据预览 <br/>
* @author jingma
* @param teans 转换
* @param testStep 步骤名称
* @param smi 步骤实体
* @param previewSize 预览的条数
* @return 预览结果
*/
public static List<List<Object>> stepPreview(TransMeta teans,
		String testStep, StepMetaInterface smi, int previewSize) {
	TransMeta previewMeta = TransPreviewFactory.generatePreviewTransformation(
			teans,
			smi,
			testStep);
	TransPreviewUtil tpu = new TransPreviewUtil(
			previewMeta,
	        new String[] { testStep },
	        new int[] { previewSize } );
	tpu.doPreview();
	return TransPreviewUtil.getData(tpu.getPreviewRowsMeta(testStep),tpu.getPreviewRows(testStep));
}
 
Example 19
Project: KettleUtil   File: KettleUtils.java   Source Code and License 5 votes vote down vote up
/**
* 修复转换连接线 <br/>
* @author jingma
* @param tm 转换元数据
*/
public static void repairTransHop(TransMeta tm) {
    for(int i=0;i<tm.nrTransHops();i++){
        TransHopMeta hop = tm.getTransHop(i);
        hop.setFromStep(tm.findStep(hop.getFromStep().getName()));
        hop.setToStep(tm.findStep(hop.getToStep().getName()));
    }
}
 
Example 20
Project: KettleUtil   File: KettleUtils.java   Source Code and License 5 votes vote down vote up
/**
	 * @return transMetaTemplate 
	 */
	public static TransMeta getTransMetaTemplate() {
//		if(transMetaTemplate==null){
//			setTransMetaTemplate(KettleUtils.loadTrans(SysCode.TRANS_TEMPLATE_NAME, SysCode.TEMPLATE_DIR));
//		}
		return transMetaTemplate;
	}
 
Example 21
Project: KettleUtil   File: TransPreviewUtil.java   Source Code and License 5 votes vote down vote up
/**
 * Creates a new dialog that will handle the wait while previewing a transformation...
 */
public TransPreviewUtil( TransMeta transMeta, String[] previewStepNames, int[] previewSize ) {
  this.transMeta = transMeta;
  this.previewStepNames = previewStepNames;
  this.previewSize = previewSize;

  cancelled = false;
}
 
Example 22
Project: KettleUtil   File: EasyExpandMeta.java   Source Code and License 5 votes vote down vote up
public String getDefaultConfigInfo(TransMeta transMeta, String stepName, VariableSpace space) throws Exception {
    if(StringUtils.isNotBlank(getClassName())){
        //实例化配置的类,获取输出字段
        EasyExpandRunBase kui = (EasyExpandRunBase) Class.forName(space.environmentSubstitute(getClassName())).newInstance();
        kui.setKu(null);
        kui.setMeta(this,space);
        return kui.getDefaultConfigInfo(transMeta,stepName);
    }
    return null;
}
 
Example 23
Project: KettleUtil   File: EasyExpandDemo.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * @see cn.benma666.kettle.steps.easyexpand.EasyExpandRunBase#getDefaultConfigInfo(org.pentaho.di.trans.TransMeta, java.lang.String)
 */
 @Override
 public String getDefaultConfigInfo(TransMeta transMeta, String stepName) throws Exception{
    //创建一个JSON对象,用于构建配置对象,避免直接拼字符串构建JSON字符串
    JSONObject params = new JSONObject();
    //设置一个参数key1
    params.put("key1", "");
    RowMetaInterface fields = transMeta.getPrevStepFields(stepName);
    if(fields.size()==0){
        throw new RuntimeException("没有获取到上一步骤的字段,请确认连接好上一步骤");
    }
    params.put("PrevInfoFields", fields.toString());
    //创建一个JSON数组对象,用于存放数组参数
    JSONArray arr = new JSONArray();
    arr.add("arr1");
    arr.add("arr2");
    params.put("array", arr);
    //生成的参数样例
    //{
    //  "array":[
    //          "arr1",
    //          "arr2"
    //  ],
    //  "key1":""
    //}
    //返回格式化后的默认JSON配置参数,供使用者方便快捷的修改配置
    return JSON.toJSONString(params, true);
}
 
Example 24
Project: pdi-git-plugin   File: PdiDiff.java   Source Code and License 5 votes vote down vote up
public static TransMeta compareSteps( TransMeta transMeta1, TransMeta transMeta2, boolean isForward ) {
  transMeta1.getSteps().forEach( step -> {
    Optional<StepMeta> step2 = transMeta2.getSteps().stream()
        .filter( obj -> step.getName().equals( obj.getName() ) ).findFirst();
    String status = null;
    if ( step2.isPresent() ) {
      Map<String, String> tmp = null, tmp2 = null;
      try {
        // AttributeMap("Git") cannot affect the XML comparison
        tmp = step.getAttributesMap().remove( ATTR_GIT );
        tmp2 = step2.get().getAttributesMap().remove( ATTR_GIT );
        if ( step.getXML().equals( step2.get().getXML() ) ) {
          status = UNCHANGED;
        } else {
          status = CHANGED;
        }
      } catch ( KettleException e ) {
        e.printStackTrace();
      } finally {
        step.setAttributes( ATTR_GIT, tmp );
        step2.get().setAttributes( ATTR_GIT, tmp2 );
      }
    } else {
      if ( isForward ) {
        status = REMOVED;
      } else {
        status = ADDED;
      }
    }
    step.setAttribute( ATTR_GIT, ATTR_STATUS, status.toString() );
  } );
  return transMeta1;
}
 
Example 25
Project: pdi-git-plugin   File: DrawDiffOnStepExtensionPoint.java   Source Code and License 5 votes vote down vote up
@Override
public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException {
  if ( !( object instanceof TransPainter ) ) {
    return;
  }
  int iconsize = PropsUI.getInstance().getIconSize();
  TransPainter painter = (TransPainter) object;
  Point offset = painter.getOffset();
  GCInterface gc = painter.getGc();
  TransMeta transMeta = painter.getTransMeta();
  transMeta.getSteps().stream().filter( step -> step.getAttribute( ATTR_GIT, ATTR_STATUS ) != null )
    .forEach( step -> {
      if ( transMeta.getTransversion() == null ? false : transMeta.getTransversion().startsWith( "git" ) ) {
        String status = step.getAttribute( ATTR_GIT, ATTR_STATUS );
        Point n = step.getLocation();
        String location = "org/pentaho/di/git/spoon/images/";
        if ( status.equals( REMOVED ) ) {
          location += "removed.svg";
        } else if ( status.equals( CHANGED ) ) {
          location += "changed.svg";
        } else if ( status.equals( ADDED ) ) {
          location += "added.svg";
        } else { // Unchanged
          return;
        }
        gc.drawImage( location, getClass().getClassLoader(), ( n.x + iconsize + offset.x ) - ( BasePainter.MINI_ICON_SIZE / 2 ), n.y + offset.y - ( BasePainter.MINI_ICON_SIZE / 2 ) );
      } else {
        step.getAttributesMap().remove( ATTR_GIT );
      }
    } );
}
 
Example 26
Project: pdi-git-plugin   File: GitController.java   Source Code and License 5 votes vote down vote up
@VisibleForTesting
void addGraph( EngineMetaInterface meta, String filePath ) {
  meta.clearChanged();
  meta.setFilename( filePath );
  if ( meta instanceof TransMeta ) {
    Spoon.getInstance().addTransGraph( (TransMeta) meta );
  } else {
    Spoon.getInstance().addJobGraph( (JobMeta) meta );
  }
}
 
Example 27
Project: pentaho-pdi-streaming   File: StreamingTransDialogTab.java   Source Code and License 5 votes vote down vote up
@Override
public void getData( TransMeta transMeta ) throws KettleException {
  try {

    String serviceName = transMeta.getAttribute( StreamingConst.STREAMING_GROUP, StreamingConst.STREAMING_SERVICE_NAME );
    if ( Const.isEmpty( serviceName ) ) {
      return;
    }
    MetaStoreFactory<StreamingService> rtFactory = new MetaStoreFactory<StreamingService>( StreamingService.class, transMeta.getMetaStore(), PentahoDefaults.NAMESPACE );
    StreamingService streamingService = rtFactory.loadElement( serviceName );
    if ( streamingService == null ) {
      return;
    }

    wServiceName.setText( Const.NVL( streamingService.getName(), "" ) );
    wServiceStep.setText( Const.NVL( streamingService.getStepname(), "" ) );
    wServiceCacheDuration.setText( Const.NVL( streamingService.getCacheDuration(), "" ) );
    wServiceCacheSize.setText( Const.NVL( streamingService.getCacheSize(), "" ) );
    wPreloadService.setSelection( streamingService.isPreloaded() );
    wClearOnStart.setSelection( streamingService.isClearingOnStart() );
    wReplaceAtTransEnd.setSelection(streamingService.isCacheFlipping());
    LogLevel logLevel = streamingService.getLogLevel()==null ? LogLevel.BASIC : streamingService.getLogLevel();
    wLogLevel.select( logLevel.getLevel() );

  } catch ( Exception e ) {
    throw new KettleException( "Unable to load streaming service", e );
  }
}
 
Example 28
Project: pentaho-pdi-streaming   File: StreamingTransDialogTab.java   Source Code and License 5 votes vote down vote up
@Override
public void ok( TransMeta transMeta ) throws KettleException {

  try {
    // Get streaming service details...
    //
    StreamingService streamingService = new StreamingService();
    streamingService.setName( wServiceName.getText() );
    streamingService.setStepname( wServiceStep.getText() );
    streamingService.setCacheDuration( wServiceCacheDuration.getText() );
    streamingService.setCacheSize( wServiceCacheSize.getText() );
    streamingService.setPreloaded( wPreloadService.getSelection() );
    streamingService.setClearingOnStart( wClearOnStart.getSelection() );
    streamingService.setCacheFlipping(wReplaceAtTransEnd.getSelection());
    streamingService.setLogLevel( LogLevel.values()[wLogLevel.getSelectionIndex()] );

    streamingService.setTransFilename( transMeta.getFilename() );
    Repository repository = transMeta.getRepository();
    if ( repository != null ) {
      if ( repository.getRepositoryMeta().getRepositoryCapabilities().supportsReferences() ) {
        ObjectId objectId = transMeta.getObjectId();
        streamingService.setTransObjectId( objectId == null ? null : objectId.getId() );
      }
      streamingService.setTransRepositoryPath( transMeta.getRepositoryDirectory().getPath() + "/" + transMeta.getName() );
    }

    MetaStoreFactory<StreamingService> rtFactory = new MetaStoreFactory<StreamingService>( StreamingService.class, transMeta.getMetaStore(), PentahoDefaults.NAMESPACE );
    rtFactory.saveElement( streamingService );

    transMeta.setAttribute( StreamingConst.STREAMING_GROUP, StreamingConst.STREAMING_SERVICE_NAME, streamingService.getName() );
    transMeta.setChanged();

  } catch ( Exception e ) {
    throw new KettleException( "Error saveing streaming service metadata", e );
  }

}
 
Example 29
Project: carbondata   File: CsvInputMeta.java   Source Code and License 5 votes vote down vote up
@Override
public List<ResourceReference> getResourceDependencies(TransMeta transMeta, StepMeta stepInfo) {
  List<ResourceReference> references = new ArrayList<ResourceReference>(5);

  ResourceReference reference = new ResourceReference(stepInfo);
  references.add(reference);
  if (!Const.isEmpty(filename)) {
    // Add the filename to the references, including a reference to this
    // step meta data.
    //
    reference.getEntries()
        .add(new ResourceEntry(transMeta.environmentSubstitute(filename), ResourceType.FILE));
  }
  return references;
}
 
Example 30
Project: pentaho-mqtt-plugin   File: MQTTPublisherMeta.java   Source Code and License 5 votes vote down vote up
@Override
public void check( List<CheckResultInterface> remarks, TransMeta transMeta, StepMeta stepMeta, RowMetaInterface prev,
    String[] input, String[] output, RowMetaInterface info, VariableSpace space, Repository repository,
    IMetaStore metaStore ) {

  if ( broker == null ) {
    remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR,
        BaseMessages.getString( PKG, "MQTTClientMeta.Check.InvalidBroker" ), stepMeta ) );
  }
  if ( topic == null ) {
    remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR,
        BaseMessages.getString( PKG, "MQTTClientMeta.Check.InvalidTopic" ), stepMeta ) );
  }
  if ( field == null ) {
    remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR,
        BaseMessages.getString( PKG, "MQTTClientMeta.Check.InvalidField" ), stepMeta ) );
  }
  if ( clientId == null ) {
    remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR,
        BaseMessages.getString( PKG, "MQTTClientMeta.Check.InvalidClientID" ), stepMeta ) );
  }
  if ( timeout == null ) {
    remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR,
        BaseMessages.getString( PKG, "MQTTClientMeta.Check.InvalidConnectionTimeout" ), stepMeta ) );
  }
  if ( qos == null ) {
    remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR,
        BaseMessages.getString( PKG, "MQTTClientMeta.Check.InvalidQOS" ), stepMeta ) );
  }
  if ( requiresAuth ) {
    if ( username == null ) {
      remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR,
          BaseMessages.getString( PKG, "MQTTClientMeta.Check.InvalidUsername" ), stepMeta ) );
    }
    if ( password == null ) {
      remarks.add( new CheckResult( CheckResultInterface.TYPE_RESULT_ERROR,
          BaseMessages.getString( PKG, "MQTTClientMeta.Check.InvalidPassword" ), stepMeta ) );
    }
  }
}
 
Example 31
Project: ARXPlugin   File: LayoutField.java   Source Code and License 5 votes vote down vote up
/**
 * Creates the new View of the FieldTab
 * @param parent The Parent Folder
 * @param meta The Meta for Saving
 * @param props The PropsUI
 * @param fieldNames The FieldNames
 * @param transMeta The TransMeta for this Step
 */
public LayoutField(final CTabFolder parent, ARXPluginMeta meta, final PropsUI props,
		String[] fieldNames, TransMeta transMeta) {
	this.meta = meta;
	this.props = props;
	this.fieldNames = fieldNames;
	this.transMeta = transMeta;
	this.field=fieldNames[0];
	
	/**
	 * TAB FieldWise ***************
	 */
	CTabItem tabField = new CTabItem(parent, SWT.NONE);
	tabField.setText(Resources.getMessage("Attribut.2"));

	ScrolledComposite scroller = new ScrolledComposite(parent, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

	Composite tabFieldComp = new Composite(scroller, SWT.NONE);
	props.setLook(tabFieldComp);

	tabFieldComp.setLayout(SWTUtil.createGridLayout(1));
	
	this.build(tabFieldComp);
	
	FormData tabFieldFileComp = new FormData();
	tabFieldFileComp.left = new FormAttachment(0, 0);
	tabFieldFileComp.top = new FormAttachment(0, 0);
	tabFieldFileComp.right = new FormAttachment(100, 0);
	tabFieldFileComp.bottom = new FormAttachment(100, 0);
	tabFieldComp.setLayoutData(tabFieldFileComp);
	tabFieldComp.layout();
	tabField.setControl(scroller);
	scroller.setContent(tabFieldComp);
	scroller.setExpandVertical(true);
	scroller.setExpandHorizontal(true);
	scroller.setMinSize(tabFieldComp.computeSize(SWT.DEFAULT, SWT.DEFAULT));

}
 
Example 32
Project: ARXPlugin   File: ViewAttributeTransformation.java   Source Code and License 5 votes vote down vote up
/**
 * Creates the new View with a Default Attribut Value
 * 
 * @param parent
 *            The Parent Composite
 * @param meta
 *            The Meta Information
 * @param props
 *            The PropsUI from the Kettle Project
 * @param parentFieldTab
 *            The Parent FieldTab
 * @param transMeta
 *            The TransMeta from this Step
 * @param field
 *            The Starting default FieldName
 */
public ViewAttributeTransformation(final Composite parent, ARXPluginMeta meta, final PropsUI props,
		LayoutField parentFieldTab, TransMeta transMeta, String field) {
	this.meta = meta;
	this.fieldName=field;
	this.props = props;
	this.transMeta = transMeta;
	this.parentFieldTab = parentFieldTab;

	CTabFolder wTabFolder = new CTabFolder(parent, SWT.BORDER);
	props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
	wTabFolder.setSimple(false);
	wTabFolder.setLayoutData(SWTUtil.createFillHorizontallyGridData());

	cTabTransformation = new CTabItem(wTabFolder, SWT.NONE);
	cTabTransformation.setText(Resources.getMessage("LayoutAttributeMetadata.0"));
	wTabFolder.setSelection(0);
	Composite cTabTransformationComp = new Composite(wTabFolder, SWT.NONE);
	props.setLook(cTabTransformationComp);
	cTabTransformationComp.setLayoutData(SWTUtil.createFillHorizontallyGridData());
	cTabTransformationComp.setLayout(new FillLayout());

	Composite root = new Composite(cTabTransformationComp, SWT.NULL);
	final GridLayout groupInputGridLayout = new GridLayout();
	groupInputGridLayout.numColumns = 1;
	root.setLayout(groupInputGridLayout);
	this.build(root);
	cTabTransformationComp.layout();
	cTabTransformation.setControl(cTabTransformationComp);
}
 
Example 33
Project: kettle-docker   File: DockerTransExecutorMeta.java   Source Code and License 5 votes vote down vote up
@Override
public TransMeta loadReferencedObject(int index, Repository rep, IMetaStore metaStore, VariableSpace space) throws KettleException {
    if (subTransMeta == null) {
        subTransMeta = transSpecificationMethod.loadTrans(transformation, null, rep, metaStore, space);
    }
    return subTransMeta;
}
 
Example 34
Project: kettle-docker   File: DockerTransExecutorMeta.java   Source Code and License 5 votes vote down vote up
@Override
public void saveTrans(TransMeta transMeta, String name, String directoryPath, Repository repository, IMetaStore metaStore, VariableSpace variableSpace) throws KettleException {
    String xml = XMLHandler.getXMLHeader() + transMeta.getXML();
    DataOutputStream dos = new DataOutputStream(KettleVFS.getOutputStream(name, false));
    try {
        dos.write(xml.getBytes(Const.XML_ENCODING));
        dos.close();
    } catch (IOException e) {
        throw new KettleException(e);
    }
}
 
Example 35
Project: pdi-layout   File: GraphUtils.java   Source Code and License 5 votes vote down vote up
public static Graph createGraph( EngineMetaInterface meta ) {
  if ( meta == null ) {
    return null;
  }
  Graph g = new TinkerGraph();
  if ( meta instanceof TransMeta ) {
    TransMeta transMeta = (TransMeta) meta;

    // Add nodes
    List<StepMeta> steps = transMeta.getSteps();
    if ( steps != null ) {
      for ( StepMeta step : steps ) {
        Vertex v = g.addVertex( step.getName() );
        v.setProperty( PROPERTY_NAME, step.getName() );
        v.setProperty( PROPERTY_PLUGINID, step.getStepID() );
        Point location = step.getLocation();
        v.setProperty( PROPERTY_X, location.x );
        v.setProperty( PROPERTY_Y, location.y );
        v.setProperty( PROPERTY_REF, step );
      }
    }
    int numHops = transMeta.nrTransHops();
    for ( int i = 0; i < numHops; i++ ) {
      TransHopMeta hop = transMeta.getTransHop( i );
      StepMeta fromStep = hop.getFromStep();
      StepMeta toStep = hop.getToStep();
      Vertex fromV = g.getVertex( fromStep.getName() );
      Vertex toV = g.getVertex( toStep.getName() );
      g.addEdge( null, fromV, toV, EDGE_HOPSTO );
    }
  }
  return g;
}
 
Example 36
Project: pentaho-pdi-dataset   File: TransUnitTestDialog.java   Source Code and License 5 votes vote down vote up
public TransUnitTestDialog(Shell parent, TransMeta transMeta, IMetaStore metaStore, TransUnitTest transUnitTest) throws KettleException, MetaStoreException {
  super(parent, SWT.NONE);
  this.transMeta = transMeta;
  this.metaStore = metaStore;
  this.transUnitTest = transUnitTest;
  props = PropsUI.getInstance();
  ok = false;

  setFactory = new MetaStoreFactory<TransUnitTest>(TransUnitTest.class, metaStore, PentahoDefaults.NAMESPACE);
}
 
Example 37
Project: pentaho-pdi-dataset   File: DrawUnitTestOnTransExtentionPoint.java   Source Code and License 5 votes vote down vote up
@Override
public void callExtensionPoint( LogChannelInterface log, Object object ) throws KettleException {
  if ( !( object instanceof TransPainter ) ) {
    return;
  }

  TransPainter painter = (TransPainter) object;
  TransMeta transMeta = painter.getTransMeta();
  String testName = transMeta.getAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_TRANS_SELECTED_UNIT_TEST_NAME);
  // System.out.println("Drawing unit test usage/editing : '"+testName+"'");
  drawUnitTestName( painter, transMeta, testName );
}
 
Example 38
Project: pentaho-pdi-dataset   File: ChangeTransMetaPriorToExecutionExtensionPoint.java   Source Code and License 5 votes vote down vote up
private void handleInputDataSet(LogChannelInterface log, String inputSetName, TransUnitTest unitTest, TransMeta transMeta, StepMeta stepMeta, FactoriesHierarchy factoriesHierarchy) throws KettleException {
  TransUnitTestSetLocation inputLocation = unitTest.findInputLocation( stepMeta.getName() );
  if (inputLocation!=null) {
    inputSetName = inputLocation.getDataSetName();
  }

  if (log.isDetailed()) {
    log.logDetailed("Replacing step '"+stepMeta.getName()+"' with an Injector for dataset '"+inputSetName+"'");
  }
  
  DataSet dataSet;
  try {
    dataSet = factoriesHierarchy.getSetFactory().loadElement(inputSetName);
  } catch (MetaStoreException e) {
    throw new KettleException("Unable to load data set '"+inputSetName+"'");
  }
  
  // OK, this step needs to be replaced by an Injector step...
  // Which fields do we need to use?
  //
  final RowMetaInterface stepFields = DataSetConst.getStepOutputFields(log, transMeta, stepMeta, dataSet, inputLocation);
  
  if (log.isDetailed()) {
    log.logDetailed("Input Data Set '"+inputSetName+"' Injector fields : '"+stepFields.toString());
  }
  
  InjectorMeta injectorMeta = new InjectorMeta();
  injectorMeta.allocate( stepFields.size() );
  for (int x=0;x<stepFields.size();x++) {
    injectorMeta.getFieldname()[x] = stepFields.getValueMeta( x ).getName();
    injectorMeta.getType()[x] = stepFields.getValueMeta( x ).getType();
    injectorMeta.getLength()[x] = stepFields.getValueMeta( x ).getLength();
    injectorMeta.getPrecision()[x] = stepFields.getValueMeta( x ).getPrecision();
    
    // Only the step metadata, type...
    stepMeta.setStepMetaInterface( injectorMeta );
    stepMeta.setStepID( PluginRegistry.getInstance().getPluginId( StepPluginType.class, injectorMeta) );          
  }
}
 
Example 39
Project: pentaho-pdi-dataset   File: DataSetHelper.java   Source Code and License 5 votes vote down vote up
public void clearInputDataSet() {
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  TransGraph transGraph = spoon.getActiveTransGraph();
  TransMeta transMeta = spoon.getActiveTransformation();
  StepMeta stepMeta = transGraph.getCurrentStep();
  if ( transGraph == null || transMeta == null || stepMeta == null ) {
    return;
  }

  stepMeta.setAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_STEP_DATASET_INPUT, null );
  transGraph.redraw();
}
 
Example 40
Project: pentaho-pdi-dataset   File: DataSetHelper.java   Source Code and License 5 votes vote down vote up
public void clearGoldenDataSet() {
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  TransGraph transGraph = spoon.getActiveTransGraph();
  TransMeta transMeta = spoon.getActiveTransformation();
  StepMeta stepMeta = transGraph.getCurrentStep();
  if ( transGraph == null || transMeta == null || stepMeta == null ) {
    return;
  }

  stepMeta.setAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_STEP_DATASET_GOLDEN, null );
  transGraph.redraw();
}