本文整理汇总了Java中org.pentaho.metastore.persist.MetaStoreFactory.loadElement方法的典型用法代码示例。如果您正苦于以下问题:Java MetaStoreFactory.loadElement方法的具体用法?Java MetaStoreFactory.loadElement怎么用?Java MetaStoreFactory.loadElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.metastore.persist.MetaStoreFactory
的用法示例。
在下文中一共展示了MetaStoreFactory.loadElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: openRepo
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
public void openRepo() {
MetaStoreFactory<GitRepository> repoFactory = getRepoFactory();
try {
List<String> names = repoFactory.getElementNames();
Collections.sort( names );
EnterSelectionDialog esd = new EnterSelectionDialog( getShell(), names.toArray( new String[names.size()] ), "Select Repository", "Select the repository to open..." );
String name = esd.open();
if ( name == null ) {
return;
}
GitRepository repo = repoFactory.loadElement( name );
gitController.openGit( repo );
} catch ( Exception e ) {
e.printStackTrace();
}
}
示例2: editRepo
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
public void editRepo() throws MetaStoreException {
MetaStoreFactory<GitRepository> repoFactory = getRepoFactory();
List<String> names = repoFactory.getElementNames();
Collections.sort( names );
EnterSelectionDialog esd = new EnterSelectionDialog( getShell(), names.toArray( new String[names.size()] ), "Select Repository", "Select the repository to edit..." );
String name = esd.open();
if ( name == null ) {
return;
}
GitRepository repo = repoFactory.loadElement( name );
EditRepositoryDialog dialog = new EditRepositoryDialog( getShell(), repo );
if ( dialog.open() == Window.OK ) {
repoFactory.saveElement( repo );
}
}
示例3: createNewService
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
protected String createNewService( Shell shell, IMetaStore metaStore ) {
EnterStringDialog dialog = new EnterStringDialog( shell, "table1", "Enter service name", "Enter the name of the new streaming service" );
String name = dialog.open();
if ( name != null ) {
try {
MetaStoreFactory<StreamingService> rtFactory = new MetaStoreFactory<StreamingService>( StreamingService.class, metaStore, PentahoDefaults.NAMESPACE );
if ( rtFactory.loadElement( name ) != null ) {
throw new MetaStoreException( "The streaming service with name '" + name + "' already exists" );
}
} catch ( MetaStoreException e ) {
new ErrorDialog( shell, "Error", "Error creating new streaming service", e );
return null;
}
return name;
} else {
return null;
}
}
示例4: editConnection
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
public static void editConnection(Shell shell, MetaStoreFactory<HCPConnection> factory, String connectionName) {
if (StringUtils.isEmpty(connectionName)) {
return;
}
try {
HCPConnection hcpConnection = factory.loadElement(connectionName);
if (hcpConnection==null) {
newConnection(shell, factory);
} else {
HCPConnectionDialog hcpConnectionDialog = new HCPConnectionDialog(shell, hcpConnection);
if (hcpConnectionDialog.open()) {
factory.saveElement(hcpConnection);
}
}
} catch(Exception exception) {
new ErrorDialog(shell,
BaseMessages.getString(PKG, "HCPConnectionUtils.Error.ErrorEditingConnection.Title"),
BaseMessages.getString(PKG, "HCPConnectionUtils.Error.ErrorEditingConnection.Message"),
exception);
}
}
示例5: editUnitTest
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的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);
}
}
示例6: testSerialisation
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
public void testSerialisation() throws Exception {
DataSetGroup group = new DataSetGroup( NAME, DESC, databaseMeta, SCHEMA );
MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, NAMESPACE );
// save the group
//
groupFactory.saveElement( group );
// Load the element
//
groupFactory.addNameList( DataSetConst.DATABASE_LIST_KEY, Arrays.asList( databaseMeta ) );
DataSetGroup verify = groupFactory.loadElement( NAME );
// Verify loading...
//
assertNotNull( verify );
assertEquals( group.getName(), verify.getName() );
assertEquals( group.getDescription(), verify.getDescription() );
assertNotNull( verify.getDatabaseMeta() );
assertEquals( group.getDatabaseMeta(), verify.getDatabaseMeta() );
assertEquals( group.getSchemaName(), verify.getSchemaName() );
}
示例7: testSerialisation
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
@Test
public void testSerialisation() throws MetaStoreException {
MetaStoreFactory<GitRepository> repoFactory = new MetaStoreFactory<GitRepository>( GitRepository.class, metaStore, NAMESPACE );
repoFactory.saveElement( repo );
GitRepository verify = repoFactory.loadElement( NAME );
assertEquals( NAME, verify.getName() );
assertEquals( DESCRIPTION, verify.getDescription() );
assertEquals( DIRECTORY, verify.getDirectory() );
}
示例8: getData
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
@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 );
}
}
示例9: newConnection
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
public static void newConnection(Shell shell, MetaStoreFactory<HCPConnection> factory) {
HCPConnection connection = new HCPConnection();
boolean ok = false;
while (!ok) {
HCPConnectionDialog dialog = new HCPConnectionDialog(shell, connection);
if (dialog.open()) {
// write to metastore...
try {
if (factory.loadElement(connection.getName())!=null) {
MessageBox box = new MessageBox(shell, SWT.YES | SWT.NO | SWT.ICON_ERROR);
box.setText(BaseMessages.getString(PKG, "HCPConnectionUtils.Error.ConnectionExists.Title"));
box.setMessage(BaseMessages.getString(PKG, "HCPConnectionUtils.Error.ConnectionExists.Message"));
int answer = box.open();
if ((answer&SWT.YES)!=0) {
factory.saveElement(connection);
ok=true;
}
} else {
factory.saveElement(connection);
ok=true;
}
} catch(Exception exception) {
new ErrorDialog(shell,
BaseMessages.getString(PKG, "HCPConnectionUtils.Error.ErrorSavingConnection.Title"),
BaseMessages.getString(PKG, "HCPConnectionUtils.Error.ErrorSavingConnection.Message"),
exception);
}
}
}
}
示例10: editDataSetGroup
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的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 );
}
}
示例11: editDataSet
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的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 );
}
}
示例12: selectUnitTest
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的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 );
}
}
示例13: testSerialisation
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
@Test
public void testSerialisation() throws Exception {
MetaStoreFactory<TransUnitTest> testFactory = new MetaStoreFactory<TransUnitTest>( TransUnitTest.class, metaStore, PentahoDefaults.NAMESPACE);
// Save the test...
//
testFactory.saveElement( test );
// Load it back up...
//
TransUnitTest verify = testFactory.loadElement( NAME );
// Verify if everything is still the same...
//
assertEquals( NAME, verify.getName() );
assertEquals( DESCRIPTION, verify.getDescription() );
List<TransUnitTestSetLocation> verifyInputs = verify.getInputDataSets();
List<TransUnitTestSetLocation> verifyGoldens = verify.getGoldenDataSets();
assertEquals( inputs.size(), verifyInputs.size());
for (int i=0;i<inputs.size();i++) {
assertEquals(inputs.get(i).getStepname(), verifyInputs.get(i).getStepname());
assertEquals(inputs.get(i).getDataSetName(), verifyInputs.get(i).getDataSetName());
assertEquals(inputs.get(i).getFieldMappings().size(), verifyInputs.get(i).getFieldMappings().size());
}
assertEquals( goldens.size(), verifyGoldens.size());
for (int i=0;i<goldens.size();i++) {
assertEquals(goldens.get(i).getStepname(), verifyGoldens.get(i).getStepname());
assertEquals(goldens.get(i).getDataSetName(), verifyGoldens.get(i).getDataSetName());
assertEquals(goldens.get(i).getFieldMappings().size(), verifyGoldens.get(i).getFieldMappings().size());
}
}
示例14: injectDataSetIntoStep
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
private void injectDataSetIntoStep( final Trans trans, final TransMeta transMeta,
final String dataSetName, final MetaStoreFactory<DataSet> dataSetFactory,
final Repository repository, final IMetaStore metaStore, final StepMeta stepMeta,
TransUnitTestSetLocation inputLocation ) throws MetaStoreException, KettleException {
final DataSet dataSet = dataSetFactory.loadElement( dataSetName );
final DataSetGroup group = dataSet.getGroup();
final Database database = new Database( trans, group.getDatabaseMeta() );
final LogChannelInterface log = trans.getLogChannel();
final RowMetaInterface injectRowMeta = DataSetConst.getStepOutputFields(log, transMeta, stepMeta, dataSet, inputLocation);
final RowProducer rowProducer = trans.addRowProducer( stepMeta.getName(), 0 );
// Look for the step into which we'll inject rows...
//
StepMetaDataCombi combi = null;
for ( StepMetaDataCombi step : trans.getSteps() ) {
if ( step.stepname.equals( stepMeta.getName() ) ) {
combi = step;
break;
}
}
if ( combi != null ) {
log.logBasic( "Injecting data set '" + dataSetName + "' into step '" + stepMeta.getName() + "', fields: "+injectRowMeta.toStringMeta() );
final List<Object[]> rows = dataSet.getAllRows(log, inputLocation, injectRowMeta);
// Pass rows
try {
Runnable runnable = new Runnable() {
@Override
public void run() {
try {
for( Object[] row : rows ) {
// pass the row with the external names
//
rowProducer.putRow( injectRowMeta, row );
}
rowProducer.finished();
} catch ( Exception e ) {
throw new RuntimeException( "Problem injecting data set '" + dataSetName + "' row into step '" + stepMeta.getName() + "'", e );
}
}
};
Thread thread = new Thread( runnable );
thread.start();
} finally {
database.disconnect();
}
}
}
示例15: createUnitTest
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的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 );
}
}