use of org.pentaho.di.core.EngineMetaInterface in project pentaho-kettle by pentaho.
the class SpoonTest method testVersioningCheckingOnServer.
@Test
public void testVersioningCheckingOnServer() throws Exception {
Repository repository = Mockito.mock(Repository.class);
RepositorySecurityProvider securityProvider = Mockito.mock(RepositorySecurityProvider.class);
Mockito.doReturn(securityProvider).when(repository).getSecurityProvider();
EngineMetaInterface jobTransMeta = Mockito.spy(new TransMeta());
RepositoryDirectoryInterface repositoryDirectoryInterface = Mockito.mock(RepositoryDirectoryInterface.class);
Mockito.doReturn("/home").when(repositoryDirectoryInterface).toString();
Mockito.doReturn("trans").when(jobTransMeta).getName();
Mockito.doReturn(RepositoryObjectType.TRANSFORMATION).when(jobTransMeta).getRepositoryElementType();
Mockito.doReturn(true).when(securityProvider).isVersioningEnabled(Mockito.anyString());
boolean result = Spoon.isVersionEnabled(repository, jobTransMeta);
Assert.assertTrue(result);
}
use of org.pentaho.di.core.EngineMetaInterface in project pentaho-kettle by pentaho.
the class SpoonTest method testVersioningDisabled.
@Test
public void testVersioningDisabled() throws Exception {
Repository repository = Mockito.mock(Repository.class);
RepositorySecurityProvider securityProvider = Mockito.mock(RepositorySecurityProvider.class);
Mockito.doReturn(securityProvider).when(repository).getSecurityProvider();
EngineMetaInterface jobTransMeta = Mockito.spy(new TransMeta());
RepositoryDirectoryInterface repositoryDirectoryInterface = Mockito.mock(RepositoryDirectoryInterface.class);
Mockito.doReturn("/home").when(repositoryDirectoryInterface).toString();
Mockito.doReturn("trans").when(jobTransMeta).getName();
Mockito.doReturn(RepositoryObjectType.TRANSFORMATION).when(jobTransMeta).getRepositoryElementType();
Mockito.doReturn(false).when(jobTransMeta).getVersioningEnabled();
boolean result = Spoon.isVersionEnabled(repository, jobTransMeta);
Assert.assertFalse(result);
Mockito.verify(securityProvider, Mockito.never()).isVersioningEnabled(Mockito.anyString());
}
use of org.pentaho.di.core.EngineMetaInterface in project pentaho-kettle by pentaho.
the class TransFileListener method save.
public boolean save(EngineMetaInterface meta, String fname, boolean export) {
Spoon spoon = Spoon.getInstance();
EngineMetaInterface lmeta;
if (export) {
lmeta = (TransMeta) ((TransMeta) meta).realClone(false);
} else {
lmeta = meta;
}
try {
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransBeforeSave.id, lmeta);
} catch (KettleException e) {
// fails gracefully
}
boolean saveStatus = spoon.saveMeta(lmeta, fname);
if (saveStatus) {
try {
ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.TransAfterSave.id, lmeta);
} catch (KettleException e) {
// fails gracefully
}
}
return saveStatus;
}
use of org.pentaho.di.core.EngineMetaInterface in project pentaho-kettle by pentaho.
the class SpoonTabsDelegate method getActiveMeta.
public EngineMetaInterface getActiveMeta() {
TabSet tabfolder = spoon.tabfolder;
if (tabfolder == null) {
return null;
}
TabItem tabItem = tabfolder.getSelected();
if (tabItem == null) {
return null;
}
// What transformation is in the active tab?
// TransLog, TransGraph & TransHist contain the same transformation
//
TabMapEntry mapEntry = getTab(tabfolder.getSelected());
EngineMetaInterface meta = null;
if (mapEntry != null) {
if (mapEntry.getObject() instanceof TransGraph) {
meta = (mapEntry.getObject()).getMeta();
}
if (mapEntry.getObject() instanceof JobGraph) {
meta = (mapEntry.getObject()).getMeta();
}
}
return meta;
}
use of org.pentaho.di.core.EngineMetaInterface in project pentaho-kettle by pentaho.
the class SpoonMenuLockController method updateMenu.
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
// $NON-NLS-1$
((XulToolbarbutton) doc.getElementById("toolbar-file-save")).setDisabled(true);
// $NON-NLS-1$
((XulMenuitem) doc.getElementById("file-save")).setDisabled(true);
}
}
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
Aggregations