当前位置: 首页>>代码示例>>Java>>正文


Java Spoon.getMetaStore方法代码示例

本文整理汇总了Java中org.pentaho.di.ui.spoon.Spoon.getMetaStore方法的典型用法代码示例。如果您正苦于以下问题:Java Spoon.getMetaStore方法的具体用法?Java Spoon.getMetaStore怎么用?Java Spoon.getMetaStore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.pentaho.di.ui.spoon.Spoon的用法示例。


在下文中一共展示了Spoon.getMetaStore方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: editUnitTest

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
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);
  }
}
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:21,代码来源:ShowUnitTestMenuExtensionPoint.java

示例2: removeDataSetGroup

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public void removeDataSetGroup() {

    Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );

    IMetaStore metaStore = spoon.getMetaStore();
    MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE );
    
    try {

      List<String> groupNames = groupFactory.getElementNames();
      Collections.sort( groupNames );
      EnterSelectionDialog esd = new EnterSelectionDialog( spoon.getShell(), groupNames.toArray( new String[groupNames.size()] ), "Select the group", "Select the group to edit..." );
      String groupName = esd.open();
      if ( groupName != null ) {
        
        // TODO: Find the unit tests for this group, if there are any, we can't remove the group
        //
        groupFactory.deleteElement(groupName);
      }
    } catch ( Exception e ) {
      new ErrorDialog( spoon.getShell(), "Error", "Error retrieving the list of data set groups or deleting a group", e );
    }
  }
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:24,代码来源:DataSetHelper.java

示例3: addDataSet

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public void addDataSet() {

    Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );

    IMetaStore metaStore = spoon.getMetaStore();

    try {
      MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE );
      List<DatabaseMeta> databases = getAvailableDatabases( spoon.getRepository() );
      groupFactory.addNameList( DataSetConst.DATABASE_LIST_KEY, databases );
      List<DataSetGroup> groups = groupFactory.getElements();

      MetaStoreFactory<DataSet> setFactory = new MetaStoreFactory<DataSet>( DataSet.class, metaStore, PentahoDefaults.NAMESPACE );
      setFactory.addNameList( DataSetConst.GROUP_LIST_KEY, groups );

      DataSet dataSet = new DataSet();

      editDataSet( spoon, dataSet, groups, setFactory, null );

    } catch ( Exception e ) {
      new ErrorDialog( spoon.getShell(), "Error", "Error creating a new data set", e );
    }
  }
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:24,代码来源:DataSetHelper.java

示例4: editDataSetGroup

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public void editDataSetGroup() {

    Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );

    IMetaStore metaStore = spoon.getMetaStore();
    MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE );
    try {

      List<String> groupNames = groupFactory.getElementNames();
      Collections.sort( groupNames );
      EnterSelectionDialog esd = new EnterSelectionDialog( spoon.getShell(), groupNames.toArray( new String[groupNames.size()] ), "Select the group", "Select the group to edit..." );
      String groupName = esd.open();
      if ( groupName != null ) {
        List<DatabaseMeta> databases = getAvailableDatabases( spoon.getRepository() );
        groupFactory.addNameList( DataSetConst.DATABASE_LIST_KEY, databases );
        DataSetGroup dataSetGroup = groupFactory.loadElement( groupName );

        DataSetGroupDialog groupDialog = new DataSetGroupDialog( spoon.getShell(), dataSetGroup, databases );
        while ( groupDialog.open() ) {
          String message = validateDataSetGroup( dataSetGroup, groupName, groupFactory.getElementNames() );

          // Save the group ...
          //
          if ( message == null ) {
            groupFactory.saveElement( dataSetGroup );
            break;
          } else {
            MessageBox box = new MessageBox( spoon.getShell(), SWT.OK );
            box.setText( "Error" );
            box.setMessage( message );
            box.open();
          }
        }
      }
    } catch ( Exception e ) {
      new ErrorDialog( spoon.getShell(), "Error", "Error retrieving the list of data set groups", e );
    }
  }
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:39,代码来源:DataSetHelper.java

示例5: addDataSetGroup

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public void addDataSetGroup() {

    Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );

    IMetaStore metaStore = spoon.getMetaStore();
    MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE );

    try {

      DataSetGroup dataSetGroup = new DataSetGroup();
      List<DatabaseMeta> databases = getAvailableDatabases( spoon.getRepository() );

      DataSetGroupDialog groupDialog = new DataSetGroupDialog( spoon.getShell(), dataSetGroup, databases );
      while ( groupDialog.open() ) {
        // Verify empty name, existing name...
        //
        String message = validateDataSetGroup( dataSetGroup, null, groupFactory.getElementNames() );

        // Save the group again...
        //
        if ( message == null ) {
          groupFactory.saveElement( dataSetGroup );
          break;
        } else {
          MessageBox box = new MessageBox( spoon.getShell(), SWT.OK );
          box.setText( "Error" );
          box.setMessage( message );
          box.open();
        }
      }
    } catch ( Exception e ) {
      new ErrorDialog( spoon.getShell(), "Error", "Error creating a new data set group", e );
    }
  }
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:35,代码来源:DataSetHelper.java

示例6: editDataSet

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public void editDataSet() {

    Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
    IMetaStore metaStore = spoon.getMetaStore();

    try {
      MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE );
      List<DatabaseMeta> databases = getAvailableDatabases( spoon.getRepository() );
      groupFactory.addNameList( DataSetConst.DATABASE_LIST_KEY, databases );
      List<DataSetGroup> groups = groupFactory.getElements();

      MetaStoreFactory<DataSet> setFactory = new MetaStoreFactory<DataSet>( DataSet.class, metaStore, PentahoDefaults.NAMESPACE );
      setFactory.addNameList( DataSetConst.GROUP_LIST_KEY, groups );

      List<String> setNames = setFactory.getElementNames();
      Collections.sort( setNames );
      EnterSelectionDialog esd = new EnterSelectionDialog( spoon.getShell(), setNames.toArray( new String[setNames.size()] ), "Select the set", "Select the data set to edit..." );
      String setName = esd.open();
      if ( setName != null ) {
        DataSet dataSet = setFactory.loadElement( setName );

        editDataSet( spoon, dataSet, groups, setFactory, setName );
      }
    } catch ( Exception e ) {
      new ErrorDialog( spoon.getShell(), "Error", "Error retrieving the list of data set groups", e );
    }
  }
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:28,代码来源:DataSetHelper.java

示例7: createDataSetFromStep

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
/**
 * Create a new data set with the output from 
 */
public void createDataSetFromStep() {
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  TransGraph transGraph = spoon.getActiveTransGraph();
  IMetaStore metaStore = spoon.getMetaStore();
  if ( transGraph == null ) {
    return;
  }
  StepMeta stepMeta = transGraph.getCurrentStep();
  TransMeta transMeta = spoon.getActiveTransformation();
  if ( stepMeta == null || transMeta == null ) {
    return;
  }

  try {
    MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE );
    List<DatabaseMeta> databases = getAvailableDatabases( spoon.getRepository() );
    groupFactory.addNameList( DataSetConst.DATABASE_LIST_KEY, databases );
    List<DataSetGroup> groups = groupFactory.getElements();

    MetaStoreFactory<DataSet> setFactory = new MetaStoreFactory<DataSet>( DataSet.class, metaStore, PentahoDefaults.NAMESPACE );
    setFactory.addNameList( DataSetConst.GROUP_LIST_KEY, groups );

    DataSet dataSet = new DataSet();
    RowMetaInterface rowMeta = transMeta.getStepFields( stepMeta );
    for ( int i = 0; i < rowMeta.size(); i++ ) {
      ValueMetaInterface valueMeta = rowMeta.getValueMeta( i );
      DataSetField field = new DataSetField( valueMeta.getName(), "field" + i, valueMeta.getType(), valueMeta.getLength(), valueMeta.getPrecision(), valueMeta.getComments() );
      dataSet.getFields().add( field );
    }

    editDataSet( spoon, dataSet, groups, setFactory, null );

  } catch ( Exception e ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error creating a new data set", e );
  }
}
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:40,代码来源:DataSetHelper.java

示例8: selectUnitTest

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public void selectUnitTest() {
  
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  try {
    TransGraph transGraph = spoon.getActiveTransGraph();
    IMetaStore metaStore = spoon.getMetaStore();
    if ( transGraph == null ) {
      return;
    }
    TransMeta transMeta = spoon.getActiveTransformation();
    if ( transMeta == null ) {
      return;
    }

    MetaStoreFactory<TransUnitTest> testFactory = new MetaStoreFactory<TransUnitTest>( TransUnitTest.class, metaStore, PentahoDefaults.NAMESPACE);
    List<String> testNames = testFactory.getElementNames();
    String[] names = testNames.toArray( new String[testNames.size()] );
    Arrays.sort( names );
    EnterSelectionDialog esd = new EnterSelectionDialog( spoon.getShell(), names, "Select a unit test", "Select the unit test to use" );
    String testName = esd.open();
    if ( testName != null ) {
      
      TransUnitTest unitTest = testFactory.loadElement( testName );
      if (unitTest==null) {
        throw new KettleException( "Unit test '"+testName+"' could not be found (deleted)?" );
      }

      selectUnitTest(transMeta, unitTest);
      Spoon.getInstance().refreshGraph();
    }
  } catch ( Exception e ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error selecting a new transformation unit test", e );
  }
}
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:35,代码来源:DataSetHelper.java

示例9: getCurrentUnitTest

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public TransUnitTest getCurrentUnitTest(TransMeta transMeta) throws MetaStoreException, KettleException {
  // What is the unit test we are using?
  //
  String testName = transMeta.getAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_TRANS_SELECTED_UNIT_TEST_NAME );
  if (Const.isEmpty( testName )) {
    return null;
  }
  Spoon spoon = Spoon.getInstance();
  List<DatabaseMeta> databases = getAvailableDatabases( spoon.getRepository() );
  FactoriesHierarchy hierarchy = new FactoriesHierarchy( spoon.getMetaStore(), databases );
  TransUnitTest unitTest = hierarchy.getTestFactory().loadElement( testName );
  return unitTest;
}
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:14,代码来源:DataSetHelper.java

示例10: tweakUnitTestStep

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
private void tweakUnitTestStep(TransTweak stepTweak, boolean enable) {
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  TransGraph transGraph = spoon.getActiveTransGraph();
  IMetaStore metaStore = spoon.getMetaStore();
  if ( transGraph == null ) {
    return;
  }
  StepMeta stepMeta = transGraph.getCurrentStep();
  TransMeta transMeta = spoon.getActiveTransformation();
  if ( stepMeta == null || transMeta == null ) {
    return;
  }

  try {
    TransUnitTest unitTest = getCurrentUnitTest(transMeta);
    if (unitTest==null) {
      return;
    }
    TransUnitTestTweak unitTestTweak = unitTest.findTweak(stepMeta.getName());
    if (unitTestTweak!=null) {
      unitTest.getTweaks().remove(unitTestTweak);
      stepMeta.setAttribute(DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_STEP_TWEAK, null);
    }
    if (enable) {
      unitTest.getTweaks().add(new TransUnitTestTweak(stepTweak, stepMeta.getName()));
      stepMeta.setAttribute(DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_STEP_TWEAK, stepTweak.name());
    }
    
    new MetaStoreFactory<TransUnitTest>(TransUnitTest.class, metaStore, PentahoDefaults.NAMESPACE)
      .saveElement(unitTest);
    
    spoon.refreshGraph();
    
  } catch(Exception exception) {
    new ErrorDialog( spoon.getShell(), "Error", "Error tweaking transformation unit test on step '"+stepMeta.getName()+"' with operation "+stepTweak.name(), exception );
  }
}
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:38,代码来源:DataSetHelper.java

示例11: createUnitTest

import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public void createUnitTest() {
  Spoon spoon = ( (Spoon) SpoonFactory.getInstance() );
  Repository repository = spoon.getRepository();
  try {
    TransGraph transGraph = spoon.getActiveTransGraph();
    IMetaStore metaStore = spoon.getMetaStore();
    if ( transGraph == null ) {
      return;
    }
    TransMeta transMeta = transGraph.getTransMeta();
    
    EnterStringDialog stringDialog = new EnterStringDialog( spoon.getShell(), "", "Enter unit test name", "Unit test name: " );
    String testName = stringDialog.open();
    if (testName==null) {
      return;
    }
    
    MetaStoreFactory<TransUnitTest> testFactory = new MetaStoreFactory<TransUnitTest>( TransUnitTest.class, metaStore, PentahoDefaults.NAMESPACE);
    if (testFactory.loadElement( testName )!=null) {
      MessageBox box = new MessageBox( spoon.getShell(), SWT.YES | SWT.NO  );
      box.setText( "A test with that name exists" );
      box.setMessage( "A test with that name already exists.  Would you like to use and edit this test in this transformation?" );
      int answer = box.open();
      if ((answer&SWT.YES)!=0) {
        transMeta.setAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_TRANS_SELECTED_UNIT_TEST_NAME, testName );
        transGraph.redraw();
      }
      return;
    }
    
    TransUnitTest test = new TransUnitTest();
    test.setName( testName );
    
    if ( repository != null ) {
      test.setTransRepositoryPath( transMeta.getRepositoryDirectory().getPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + transMeta.getName() );
      if ( repository.getRepositoryMeta().getRepositoryCapabilities().supportsReferences() ) {
        test.setTransObjectId( transMeta.getObjectId().toString() );
      } else {
        test.setTransRepositoryPath( transMeta.getRepositoryDirectory().getPath() + "/" + transMeta.getName() );
      }
    } else {
      test.setTransFilename( transMeta.getFilename() );
    }

    testFactory.saveElement( test );
    transMeta.setAttribute( DataSetConst.ATTR_GROUP_DATASET, DataSetConst.ATTR_TRANS_SELECTED_UNIT_TEST_NAME, testName );
    
    // Don't carry on old indicators...
    //
    DataSetConst.clearStepDataSetIndicators( transMeta );
    
    spoon.refreshGraph();
    
  } catch ( Exception e ) {
    new ErrorDialog( spoon.getShell(), "Error", "Error creating a new transformation unit test", e );
  }
}
 
开发者ID:mattcasters,项目名称:pentaho-pdi-dataset,代码行数:58,代码来源:DataSetHelper.java


注:本文中的org.pentaho.di.ui.spoon.Spoon.getMetaStore方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。