Search in sources :

Example 1 with EngineMetaInterface

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);
}
Also used : RepositorySecurityProvider(org.pentaho.di.repository.RepositorySecurityProvider) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Repository(org.pentaho.di.repository.Repository) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) Test(org.junit.Test)

Example 2 with EngineMetaInterface

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());
}
Also used : RepositorySecurityProvider(org.pentaho.di.repository.RepositorySecurityProvider) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Repository(org.pentaho.di.repository.Repository) TransMeta(org.pentaho.di.trans.TransMeta) DummyTransMeta(org.pentaho.di.trans.steps.dummytrans.DummyTransMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) Test(org.junit.Test)

Example 3 with EngineMetaInterface

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TransMeta(org.pentaho.di.trans.TransMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface)

Example 4 with EngineMetaInterface

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;
}
Also used : TabItem(org.pentaho.xul.swt.tab.TabItem) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) TabSet(org.pentaho.xul.swt.tab.TabSet) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry)

Example 5 with EngineMetaInterface

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);
    }
}
Also used : EEJobMeta(org.pentaho.di.repository.pur.model.EEJobMeta) PurRepository(org.pentaho.di.repository.pur.PurRepository) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) Spoon(org.pentaho.di.ui.spoon.Spoon) ILockService(org.pentaho.di.ui.repository.pur.services.ILockService) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) RepositoryLock(org.pentaho.di.repository.pur.model.RepositoryLock) XulToolbarbutton(org.pentaho.ui.xul.components.XulToolbarbutton) KettleException(org.pentaho.di.core.exception.KettleException) ILockable(org.pentaho.di.repository.pur.model.ILockable)

Aggregations

EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)21 KettleException (org.pentaho.di.core.exception.KettleException)9 TransMeta (org.pentaho.di.trans.TransMeta)7 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)5 TransGraph (org.pentaho.di.ui.spoon.trans.TransGraph)5 MalformedURLException (java.net.MalformedURLException)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)4 SWTException (org.eclipse.swt.SWTException)4 Test (org.junit.Test)4 KettleAuthException (org.pentaho.di.core.exception.KettleAuthException)4 KettleFileException (org.pentaho.di.core.exception.KettleFileException)4 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)4 KettleRowException (org.pentaho.di.core.exception.KettleRowException)4 KettleValueException (org.pentaho.di.core.exception.KettleValueException)4 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)4 LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)4 JobMeta (org.pentaho.di.job.JobMeta)4 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)4 Repository (org.pentaho.di.repository.Repository)4 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)4