本文整理汇总了Java中org.pentaho.metastore.persist.MetaStoreFactory.saveElement方法的典型用法代码示例。如果您正苦于以下问题:Java MetaStoreFactory.saveElement方法的具体用法?Java MetaStoreFactory.saveElement怎么用?Java MetaStoreFactory.saveElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.metastore.persist.MetaStoreFactory
的用法示例。
在下文中一共展示了MetaStoreFactory.saveElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addRepo
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
public void addRepo() throws MetaStoreException, XulException {
MetaStoreFactory<GitRepository> repoFactory = getRepoFactory();
GitRepository repo = new GitRepository();
EditRepositoryDialog dialog = new EditRepositoryDialog( getShell(), repo );
if ( dialog.open() == Window.OK ) {
repoFactory.saveElement( repo );
XulConfirmBox confirmBox = (XulConfirmBox) document.createElement( "confirmbox" );
confirmBox.setTitle( "Success" );
confirmBox.setMessage( "Open now?" );
confirmBox.setAcceptLabel( BaseMessages.getString( PKG, "Dialog.Ok" ) );
confirmBox.setCancelLabel( BaseMessages.getString( PKG, "Dialog.Cancel" ) );
confirmBox.addDialogCallback( (XulDialogLambdaCallback<Object>) ( sender, returnCode, retVal ) -> {
if ( returnCode == Status.ACCEPT ) {
gitController.openGit( repo );
}
} );
confirmBox.open();
}
}
示例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: 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);
}
}
示例4: 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);
}
}
示例5: editDataSet
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
private void editDataSet( Spoon spoon, DataSet dataSet, List<DataSetGroup> groups, MetaStoreFactory<DataSet> setFactory, String setName ) throws MetaStoreException {
try {
DataSetDialog setDialog = new DataSetDialog( spoon.getShell(), setFactory.getMetaStore(), dataSet, groups, getAvailableDatabases(spoon.getRepository()) );
while ( setDialog.open() ) {
String message = validateDataSet( dataSet, setName, setFactory.getElementNames() );
// Save the data set...
//
if ( message == null ) {
setFactory.saveElement( dataSet );
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", "Unable to edit data set", e);
}
}
示例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: saveRepository
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
@VisibleForTesting
void saveRepository( GitRepository repo ) {
MetaStoreFactory<GitRepository> repoFactory = getRepoFactory();
try {
repoFactory.saveElement( repo );
} catch ( MetaStoreException e ) {
e.printStackTrace();
}
}
示例8: 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() );
}
示例9: ok
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
@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 );
}
}
示例10: 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);
}
}
}
}
示例11: 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 );
}
}
示例12: addDataSetGroup
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的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 );
}
}
示例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: 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 );
}
}
示例15: setUp
import org.pentaho.metastore.persist.MetaStoreFactory; //导入方法依赖的package包/类
@Override
protected void setUp() throws Exception {
KettleClientEnvironment.init();
metaStore = new MemoryMetaStore();
// metaStore = MetaStoreConst.openLocalPentahoMetaStore();
// Temporary databases and so on.
//
File tmpSharedObjectsFile = File.createTempFile("shared-objects-unit-test", ".xml");
sharedObjects = new SharedObjects();
// This Database needs to be found in a shared objects store...
//
databaseMeta = new DatabaseMeta( "dataset", "H2", "JDBC", null, "/tmp/datasets", null, null, null );
sharedObjects.storeObject(databaseMeta);
sharedObjects.setFilename(tmpSharedObjectsFile.getAbsolutePath());
sharedObjects.saveToFile();
dataSetGroup = new DataSetGroup( GROUP_NAME, GROUP_DESC, databaseMeta, GROUP_SCHEMA );
// Write an input data set...
//
createInputDataSet();
// Write the golden data set...
//
createGoldenDataSet();
// Create a unit test...
//
createUnitTest();
// Create the data set group in the metastore...
//
MetaStoreFactory<DataSetGroup> groupFactory = new MetaStoreFactory<DataSetGroup>( DataSetGroup.class, metaStore, PentahoDefaults.NAMESPACE);
groupFactory.addNameList( DataSetConst.DATABASE_LIST_KEY, Arrays.asList( databaseMeta ) );
groupFactory.saveElement( dataSetGroup );
// Create the input data set in the metastore...
//
MetaStoreFactory<DataSet> setFactory = new MetaStoreFactory<DataSet>( DataSet.class, metaStore, PentahoDefaults.NAMESPACE);
setFactory.addNameList( DataSetConst.GROUP_LIST_KEY, groupFactory.getElements() );
setFactory.saveElement( inputDataSet );
// Create the golden data set in the metastore...
//
setFactory.saveElement( goldenDataSet );
// Create a unit test...
MetaStoreFactory<TransUnitTest> testFactory = new MetaStoreFactory<TransUnitTest>( TransUnitTest.class, metaStore, PentahoDefaults.NAMESPACE);
testFactory.saveElement( unitTest );
// Reload the whole thing...
factories = new FactoriesHierarchy( metaStore, Arrays.asList( databaseMeta ) );
DataSetGroup verifyGroup = factories.getGroupFactory().loadElement(dataSetGroup.getName());
assertNotNull(verifyGroup.getDatabaseMeta());
}