Search in sources :

Example 1 with SharedObjects

use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.

the class BaseStreamingDialog method createSubtrans.

private void createSubtrans(TransMeta newTransMeta) {
    // remember current tab
    TabItem tabItem = spoonInstance.getTabSet().getSelected();
    newTransMeta.setMetaStore(spoonInstance.getMetaStore());
    try {
        SharedObjects sharedObjects = newTransMeta.readSharedObjects();
        newTransMeta.setSharedObjects(sharedObjects);
        newTransMeta.importFromMetaStore();
        newTransMeta.clearChanged();
    } catch (Exception e) {
        log.logError("Failed to retrieve shared objects", e);
    }
    spoonInstance.delegates.tabs.makeTabName(newTransMeta, false);
    spoonInstance.addTransGraph(newTransMeta);
    spoonInstance.applyVariables();
    if (spoonInstance.setDesignMode()) {
        // No refresh done yet, do so
        spoonInstance.refreshTree();
    }
    spoonInstance.loadPerspective(MainSpoonPerspective.ID);
    try {
        ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.TransformationCreateNew.id, newTransMeta);
    } catch (KettleException e) {
        log.logError("Failed to call extension point", e);
    }
    // go back to inital tab
    TabSet ts = spoonInstance.getTabSet();
    ts.setSelected(tabItem);
}
Also used : TabItem(org.pentaho.xul.swt.tab.TabItem) CTabItem(org.eclipse.swt.custom.CTabItem) KettleException(org.pentaho.di.core.exception.KettleException) TabSet(org.pentaho.xul.swt.tab.TabSet) SharedObjects(org.pentaho.di.shared.SharedObjects) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException)

Example 2 with SharedObjects

use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.

the class SharedObjectSyncUtilTest method saveSharedObjects.

private SharedObjects saveSharedObjects(String location, SharedObjectInterface... objects) throws Exception {
    SharedObjects sharedObjects = createSharedObjects(location, objects);
    sharedObjects.saveToFile();
    return sharedObjects;
}
Also used : SharedObjects(org.pentaho.di.shared.SharedObjects)

Example 3 with SharedObjects

use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.

the class EditConnectionListenerTest method replaceSharedConnection.

@Test
public void replaceSharedConnection() throws IOException, KettleException {
    dialog.transMeta.addDatabase(createDefaultDatabase(true));
    SharedObjects sharedObjects = mock(SharedObjects.class);
    doReturn(sharedObjects).when(dialog.transMeta).getSharedObjects();
    editConnectionListener.widgetSelected(null);
    verify(editConnectionListener).replaceSharedConnection(any(DatabaseMeta.class), any(DatabaseMeta.class));
    verify(sharedObjects).removeObject(any(SharedObjectInterface.class));
    verify(sharedObjects).storeObject(any(SharedObjectInterface.class));
    verify(sharedObjects).saveToFile();
}
Also used : SharedObjectInterface(org.pentaho.di.shared.SharedObjectInterface) SharedObjects(org.pentaho.di.shared.SharedObjects) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Test(org.junit.Test)

Example 4 with SharedObjects

use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.

the class EditConnectionListenerTest method replaceSharedConnectionReturnsFalse_on_error.

@Test
public void replaceSharedConnectionReturnsFalse_on_error() throws IOException, KettleException {
    dialog.transMeta.addDatabase(createDefaultDatabase(false));
    SharedObjects sharedObjects = mock(SharedObjects.class);
    doThrow(Exception.class).when(sharedObjects).saveToFile();
    boolean actualResult = editConnectionListener.replaceSharedConnection(anyDbMeta(), anyDbMeta());
    assertFalse(actualResult);
    verify(editConnectionListener).showErrorDialog(any(Exception.class));
}
Also used : SharedObjects(org.pentaho.di.shared.SharedObjects) KettleException(org.pentaho.di.core.exception.KettleException) IOException(java.io.IOException) Test(org.junit.Test)

Example 5 with SharedObjects

use of org.pentaho.di.shared.SharedObjects in project pentaho-kettle by pentaho.

the class JobGraph method editProperties.

public static boolean editProperties(JobMeta jobMeta, Spoon spoon, Repository rep, boolean allowDirectoryChange) {
    if (jobMeta == null) {
        return false;
    }
    JobDialog jd = new JobDialog(spoon.getShell(), SWT.NONE, jobMeta, rep);
    jd.setDirectoryChangeAllowed(allowDirectoryChange);
    JobMeta ji = jd.open();
    // 
    if (jd.isSharedObjectsFileChanged()) {
        try {
            SharedObjects sharedObjects = rep != null ? rep.readJobMetaSharedObjects(jobMeta) : jobMeta.readSharedObjects();
            spoon.sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
        } catch (Exception e) {
            new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message", spoon.delegates.tabs.makeTabName(jobMeta, true)), e);
        }
    }
    // If we added properties, add them to the variables too, so that they appear in the CTRL-SPACE variable completion.
    // 
    spoon.setParametersAsVariablesInUI(jobMeta, jobMeta);
    if (jd.isSharedObjectsFileChanged() || ji != null) {
        spoon.refreshTree();
        // cheap operation, might as will do it anyway
        spoon.delegates.tabs.renameTabs();
    }
    spoon.setShellText();
    return ji != null;
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobDialog(org.pentaho.di.ui.job.dialog.JobDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SharedObjects(org.pentaho.di.shared.SharedObjects) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

SharedObjects (org.pentaho.di.shared.SharedObjects)25 KettleException (org.pentaho.di.core.exception.KettleException)13 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)10 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)8 KettleFileException (org.pentaho.di.core.exception.KettleFileException)6 KettleValueException (org.pentaho.di.core.exception.KettleValueException)6 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)6 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)6 MalformedURLException (java.net.MalformedURLException)5 FileSystemException (org.apache.commons.vfs2.FileSystemException)5 SWTException (org.eclipse.swt.SWTException)5 KettleAuthException (org.pentaho.di.core.exception.KettleAuthException)5 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)5 KettleRowException (org.pentaho.di.core.exception.KettleRowException)5 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)5 LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)5 JobMeta (org.pentaho.di.job.JobMeta)5 TransMeta (org.pentaho.di.trans.TransMeta)5 SlaveServer (org.pentaho.di.cluster.SlaveServer)4 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)4