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);
}
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;
}
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();
}
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));
}
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;
}
Aggregations