本文整理汇总了Java中org.pentaho.di.ui.spoon.Spoon.getRepository方法的典型用法代码示例。如果您正苦于以下问题:Java Spoon.getRepository方法的具体用法?Java Spoon.getRepository怎么用?Java Spoon.getRepository使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.pentaho.di.ui.spoon.Spoon
的用法示例。
在下文中一共展示了Spoon.getRepository方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: connectToRepository
import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public void connectToRepository( RepositoryMeta repositoryMeta, String username, String password ) throws KettleException {
final Repository repository = loadRepositoryObject( repositoryMeta.getId() );
repository.init( repositoryMeta );
repositoryConnect( repository, username, password );
if ( username != null ) {
getPropsUI().setLastRepositoryLogin( username );
}
Spoon spoon = spoonSupplier.get();
Runnable execute = () -> {
if ( spoon.getRepository() != null ) {
spoon.closeRepository();
} else {
spoon.closeAllJobsAndTransformations( true );
}
spoon.setRepository( repository );
setConnectedRepository( repositoryMeta );
fireListeners();
};
if ( spoon.getShell() != null ) {
spoon.getShell().getDisplay().asyncExec( execute );
} else {
execute.run();
}
}
示例2: updateMenu
import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public void updateMenu( Document doc ) {
try {
Spoon spoon = Spoon.getInstance();
// If we are working with an Enterprise Repository
if ( ( spoon != null ) && ( spoon.getRepository() != null ) && ( spoon.getRepository() instanceof PurRepository ) ) {
ILockService service = getService( spoon.getRepository() );
EngineMetaInterface meta = spoon.getActiveMeta();
// If (meta is not null) and (meta is either a Transformation or Job)
if ( ( meta != null ) && ( meta instanceof ILockable ) ) {
RepositoryLock repoLock = null;
if ( service != null && meta.getObjectId() != null ) {
if ( meta instanceof EEJobMeta ) {
repoLock = service.getJobLock( meta.getObjectId() );
} else {
repoLock = service.getTransformationLock( meta.getObjectId() );
}
}
// If (there is a lock on this item) and (the UserInfo does not have permission to unlock this file)
if ( repoLock != null ) {
if ( !service.canUnlockFileById( meta.getObjectId() ) ) {
// User does not have modify permissions on this file
( (XulToolbarbutton) doc.getElementById( "toolbar-file-save" ) ).setDisabled( true ); //$NON-NLS-1$
( (XulMenuitem) doc.getElementById( "file-save" ) ).setDisabled( true ); //$NON-NLS-1$
}
}
}
}
} catch ( Exception e ) {
throw new RuntimeException( e );
}
}
示例3: SpoonEETransformationDelegate
import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public SpoonEETransformationDelegate( Spoon spoon ) {
super( spoon );
Repository repository = spoon.getRepository();
try {
if ( repository.hasService( ILockService.class ) ) {
service = (ILockService) repository.getService( ILockService.class );
} else {
throw new IllegalStateException();
}
} catch ( KettleException e ) {
throw new RuntimeException( e );
}
}
示例4: SpoonEEJobDelegate
import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
public SpoonEEJobDelegate( Spoon spoon ) {
super( spoon );
Repository repository = spoon.getRepository();
try {
if ( repository.hasService( ILockService.class ) ) {
service = (ILockService) repository.getService( ILockService.class );
} else {
throw new IllegalStateException();
}
} catch ( KettleException e ) {
throw new RuntimeException( e );
}
}
示例5: 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 );
}
}
示例6: warnClosingOfOpenTabsBasedOnPerms
import org.pentaho.di.ui.spoon.Spoon; //导入方法依赖的package包/类
private void warnClosingOfOpenTabsBasedOnPerms( Spoon spoon ) throws KettleException {
Class<PurRepositoryDialog> PKG = PurRepositoryDialog.class;
// Check to see if there are any open jobs/trans
Repository repository = spoon.getRepository();
if ( spoon.getActiveMeta() == null ) {
return;
}
String warningTitle = BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllForce.Connect.Title" );
String warningText =
BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllOptionAdditional.Connect.Message" );
String additionalWarningText = "";
int buttons = SWT.OK;
IAbsSecurityProvider absSecurityProvider =
(IAbsSecurityProvider) repository.getService( IAbsSecurityProvider.class );
if ( absSecurityProvider != null ) {
boolean createPerms = false;
boolean executePerms = false;
boolean readPerms = false;
try {
createPerms = absSecurityProvider.isAllowed( IAbsSecurityProvider.CREATE_CONTENT_ACTION );
executePerms = absSecurityProvider.isAllowed( IAbsSecurityProvider.EXECUTE_CONTENT_ACTION );
readPerms = absSecurityProvider.isAllowed( IAbsSecurityProvider.READ_CONTENT_ACTION );
} catch ( KettleException e ) {
// No nothing - we are just checking perms
}
// Check to see if display of warning dialog has been disabled
if ( readPerms && createPerms && executePerms ) {
warningTitle = BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllOption.Connect.Title" );
warningText = BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllOption.Connect.Message" );
buttons = SWT.YES | SWT.NO | SWT.ICON_INFORMATION;
} else {
warningText = BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllForce.Connect.Message" );
if ( createPerms ) {
additionalWarningText =
BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllForceAdditional.Connect.Message" );
buttons = SWT.YES | SWT.NO | SWT.ICON_WARNING;
} else {
additionalWarningText =
BaseMessages.getString( PKG, "PurRepository.Dialog.WarnToCloseAllOptionAdditional.Connect.Message" );
buttons = SWT.OK | SWT.ICON_WARNING;
}
}
}
MessageBox mb = new MessageBox( spoon.getShell(), buttons );
mb.setMessage( additionalWarningText.length() != 0 ? warningText + "\n\n" + additionalWarningText : warningText );
mb.setText( warningTitle );
final int isCloseAllFiles = mb.open();
// If user has create content perms, then they can leave the tabs open.
// Otherwise, we force close the tabs
if ( ( isCloseAllFiles == SWT.YES ) || ( isCloseAllFiles == SWT.OK ) ) {
spoon.closeAllFiles();
}
}