use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class Spoon method saveToFile.
public boolean saveToFile(EngineMetaInterface meta) throws KettleException {
if (meta == null) {
return false;
}
boolean saved = false;
((AbstractMeta) meta).setRepository(rep);
((AbstractMeta) meta).setMetaStore(metaStore);
if (getLog().isDetailed()) {
// "Save to file or repository...
getLog().logDetailed(BaseMessages.getString(PKG, "Spoon.Log.SaveToFileOrRepository"));
}
SpoonPerspective activePerspective = SpoonPerspectiveManager.getInstance().getActivePerspective();
//
if (activePerspective instanceof SpoonPerspectiveOpenSaveInterface) {
return ((SpoonPerspectiveOpenSaveInterface) activePerspective).save(meta);
}
String activePerspectiveId = activePerspective.getId();
boolean etlPerspective = activePerspectiveId.equals(MainSpoonPerspective.ID);
if (rep != null && etlPerspective) {
if (meta.getObjectId() == null) {
meta.setFilename(null);
}
saved = saveToRepository(meta);
} else {
if (meta.getFilename() != null) {
saved = save(meta, meta.getFilename(), false);
} else {
if (meta.canSave()) {
saved = saveFileAs(meta);
}
}
}
// throws Exception in case anything goes wrong
meta.saveSharedObjects();
try {
if (props.useDBCache() && meta instanceof TransMeta) {
((TransMeta) meta).getDbCache().saveCache();
}
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorSavingDatabaseCache.Title"), // "An error occurred saving the database cache to disk"
BaseMessages.getString(PKG, "Spoon.Dialog.ErrorSavingDatabaseCache.Message"), e);
}
// rename the tab only if the meta was successfully saved
if (saved) {
// filename or name of transformation might have changed.
delegates.tabs.renameTabs();
}
refreshTree();
// Update menu status for the newly saved object
enableMenus();
return saved;
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class RunConfigurationImportExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
AbstractMeta abstractMeta = (AbstractMeta) o;
final EmbeddedMetaStore embeddedMetaStore = abstractMeta.getEmbeddedMetaStore();
RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build(embeddedMetaStore);
List<RunConfiguration> runConfigurationList = embeddedRunConfigurationManager.load();
List<String> runConfigurationNames = runConfigurationList.stream().map(RunConfiguration::getName).collect(Collectors.toList());
runConfigurationNames.addAll(runConfigurationManager.getNames());
runConfigurationList.addAll(createSlaveServerRunConfigurations(runConfigurationNames, abstractMeta));
for (RunConfiguration runConfiguration : runConfigurationList) {
if (!runConfiguration.getName().equals(DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME)) {
runConfigurationManager.save(runConfiguration);
}
}
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class RunConfigurationRunExtensionPoint method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
ExecutionConfiguration executionConfiguration = (ExecutionConfiguration) ((Object[]) o)[0];
AbstractMeta meta = (AbstractMeta) ((Object[]) o)[1];
VariableSpace variableSpace = (VariableSpace) ((Object[]) o)[2];
Repository repository = (Repository) ((Object[]) o)[3];
EmbeddedMetaStore embeddedMetaStore = meta.getEmbeddedMetaStore();
RunConfiguration runConfiguration = runConfigurationManager.load(executionConfiguration.getRunConfiguration());
if (runConfiguration == null) {
RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build(embeddedMetaStore);
runConfiguration = embeddedRunConfigurationManager.load(executionConfiguration.getRunConfiguration());
}
if (runConfiguration != null) {
RunConfigurationExecutor runConfigurationExecutor = runConfigurationManager.getExecutor(runConfiguration.getType());
if (runConfigurationExecutor != null) {
runConfigurationExecutor.execute(runConfiguration, executionConfiguration, meta, variableSpace, repository);
}
} else {
String name = "";
if (variableSpace instanceof TransMeta) {
name = ((TransMeta) variableSpace).getFilename();
}
throw new KettleException(BaseMessages.getString(PKG, "RunConfigurationRunExtensionPoint.ConfigNotFound.Error", name, executionConfiguration.getRunConfiguration(), "{0}"));
}
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class ConnectionDelegate method delete.
public void delete(String label) {
ConnectionDeleteDialog connectionDeleteDialog = new ConnectionDeleteDialog(spoonSupplier.get().getShell());
if (connectionDeleteDialog.open(label) == SWT.YES) {
ConnectionManager connectionManager = ConnectionManager.getInstance();
connectionManager.delete(label);
spoonSupplier.get().getShell().getDisplay().asyncExec(() -> spoonSupplier.get().refreshTree(ConnectionFolderProvider.STRING_VFS_CONNECTIONS));
EngineMetaInterface engineMetaInterface = spoonSupplier.get().getActiveMeta();
if (engineMetaInterface instanceof AbstractMeta) {
((AbstractMeta) engineMetaInterface).setChanged();
}
}
}
use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.
the class ConnectionTreeDelegateExtension method callExtensionPoint.
@Override
public void callExtensionPoint(LogChannelInterface log, Object extension) throws KettleException {
SpoonTreeDelegateExtension treeDelExt = (SpoonTreeDelegateExtension) extension;
int caseNumber = treeDelExt.getCaseNumber();
AbstractMeta meta = treeDelExt.getTransMeta();
String[] path = treeDelExt.getPath();
List<TreeSelection> objects = treeDelExt.getObjects();
TreeSelection object = null;
if (path[2].equals(ConnectionFolderProvider.STRING_VFS_CONNECTIONS)) {
switch(caseNumber) {
case 3:
object = new TreeSelection(path[2], VFSConnectionDetails.class, meta);
break;
case 4:
try {
final String name = path[3];
object = new TreeSelection(name, new ConnectionTreeItem(name), meta);
} catch (Exception e) {
// Do Nothing
}
break;
}
}
if (object != null) {
objects.add(object);
}
}
Aggregations