Search in sources :

Example 71 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class Spoon method handleStartOptions.

public void handleStartOptions(CommandLineOption[] options) {
    // note that at this point the rep object is populated by previous calls
    StringBuilder optionRepname = getCommandLineOption(options, "rep").getArgument();
    StringBuilder optionFilename = getCommandLineOption(options, "file").getArgument();
    StringBuilder optionDirname = getCommandLineOption(options, "dir").getArgument();
    StringBuilder optionTransname = getCommandLineOption(options, "trans").getArgument();
    StringBuilder optionJobname = getCommandLineOption(options, "job").getArgument();
    try {
        // Read kettle transformation specified on command-line?
        if (!Utils.isEmpty(optionRepname) || !Utils.isEmpty(optionFilename)) {
            if (!Utils.isEmpty(optionRepname)) {
                if (rep != null) {
                    if (Utils.isEmpty(optionDirname)) {
                        optionDirname = new StringBuilder(RepositoryDirectory.DIRECTORY_SEPARATOR);
                    }
                    // Options /file, /job and /trans are mutually
                    // exclusive
                    int t = (Utils.isEmpty(optionFilename) ? 0 : 1) + (Utils.isEmpty(optionJobname) ? 0 : 1) + (Utils.isEmpty(optionTransname) ? 0 : 1);
                    if (t > 1) {
                        // "More then one mutually exclusive options /file, /job and /trans are specified."
                        log.logError(BaseMessages.getString(PKG, "Spoon.Log.MutuallyExcusive"));
                    } else if (t == 1) {
                        if (!Utils.isEmpty(optionFilename)) {
                            openFile(optionFilename.toString(), false);
                        } else {
                            // OK, if we have a specified job or
                            // transformation, try to load it...
                            // If not, keep the repository logged
                            // in.
                            RepositoryDirectoryInterface rdi = rep.findDirectory(optionDirname.toString());
                            if (rdi == null) {
                                log.logError(BaseMessages.getString(PKG, "Spoon.Log.UnableFindDirectory", optionDirname.toString()));
                            } else {
                                if (!Utils.isEmpty(optionTransname)) {
                                    TransMeta transMeta = // reads
                                    rep.loadTransformation(optionTransname.toString(), rdi, null, true, null);
                                    // last
                                    // version
                                    transMeta.clearChanged();
                                    transMeta.setInternalKettleVariables();
                                    addTransGraph(transMeta);
                                } else {
                                    // Try to load a specified job
                                    // if any
                                    // reads
                                    JobMeta jobMeta = rep.loadJob(optionJobname.toString(), rdi, null, null);
                                    // last
                                    // version
                                    jobMeta.clearChanged();
                                    jobMeta.setInternalKettleVariables();
                                    addJobGraph(jobMeta);
                                }
                            }
                        }
                    }
                } else {
                    // "No repositories defined on this system."
                    log.logError(BaseMessages.getString(PKG, "Spoon.Log.NoRepositoriesDefined"));
                }
            } else if (!Utils.isEmpty(optionFilename)) {
                openFile(optionFilename.toString(), false);
            }
        }
    } catch (KettleException ke) {
        hideSplash();
        log.logError(BaseMessages.getString(PKG, "Spoon.Log.ErrorOccurred") + Const.CR + ke.getMessage());
        log.logError(Const.getStackTracker(ke));
        // do not just eat the exception
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Log.ErrorOccurred"), BaseMessages.getString(PKG, "Spoon.Log.ErrorOccurred") + Const.CR + ke.getMessage(), ke);
        rep = null;
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 72 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class Spoon method loadLastUsedFile.

private void loadLastUsedFile(LastUsedFile lastUsedFile, String repositoryName, boolean trackIt, boolean isStartup) throws KettleException {
    boolean useRepository = repositoryName != null;
    // 
    if (lastUsedFile.isSourceRepository()) {
        if (!Utils.isEmpty(lastUsedFile.getRepositoryName())) {
            if (useRepository && !lastUsedFile.getRepositoryName().equalsIgnoreCase(repositoryName)) {
                // We just asked...
                useRepository = false;
            }
        }
    }
    if (useRepository && lastUsedFile.isSourceRepository()) {
        if (rep != null) {
            // load from this repository...
            if (rep.getName().equalsIgnoreCase(lastUsedFile.getRepositoryName())) {
                RepositoryDirectoryInterface rdi = rep.findDirectory(lastUsedFile.getDirectory());
                if (rdi != null) {
                    // does the file exist in the repo?
                    final RepositoryObjectType fileType = lastUsedFile.isJob() ? RepositoryObjectType.JOB : RepositoryObjectType.TRANSFORMATION;
                    if (!rep.exists(lastUsedFile.getFilename(), rdi, fileType)) {
                        // opening this file
                        if (isStartup) {
                            if (log.isDetailed()) {
                                log.logDetailed(BaseMessages.getString(PKG, "Spoon.log.openingMissingFile"));
                            }
                        } else {
                            final Dialog dlg = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Message", lastUsedFile.getLongFileType().toLowerCase()), MessageDialog.ERROR, BaseMessages.getString(PKG, "System.Button.Close"), MISSING_RECENT_DLG_WIDTH, SimpleMessageDialog.BUTTON_WIDTH);
                            dlg.open();
                        }
                    } else {
                        // Are we loading a transformation or a job?
                        if (lastUsedFile.isTransformation()) {
                            if (log.isDetailed()) {
                                // "Auto loading transformation ["+lastfiles[0]+"] from repository directory ["+lastdirs[0]+"]"
                                log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.AutoLoadingTransformation", lastUsedFile.getFilename(), lastUsedFile.getDirectory()));
                            }
                            TransLoadProgressDialog tlpd = new TransLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null);
                            TransMeta transMeta = tlpd.open();
                            if (transMeta != null) {
                                if (trackIt) {
                                    props.addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null);
                                }
                                // transMeta.setFilename(lastUsedFile.getFilename());
                                transMeta.clearChanged();
                                addTransGraph(transMeta);
                                refreshTree();
                            }
                        } else if (lastUsedFile.isJob()) {
                            JobLoadProgressDialog progressDialog = new JobLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null);
                            JobMeta jobMeta = progressDialog.open();
                            if (jobMeta != null) {
                                if (trackIt) {
                                    props.addLastFile(LastUsedFile.FILE_TYPE_JOB, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null);
                                }
                                jobMeta.clearChanged();
                                addJobGraph(jobMeta);
                            }
                        }
                        refreshTree();
                    }
                }
            }
        }
    }
    // open files stored locally, not in the repository
    if (!lastUsedFile.isSourceRepository() && !Utils.isEmpty(lastUsedFile.getFilename())) {
        if (lastUsedFile.isTransformation()) {
            openFile(lastUsedFile.getFilename(), rep != null);
        }
        if (lastUsedFile.isJob()) {
            openFile(lastUsedFile.getFilename(), false);
        }
        refreshTree();
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) SimpleMessageDialog(org.pentaho.di.ui.core.dialog.SimpleMessageDialog) TransLoadProgressDialog(org.pentaho.di.ui.trans.dialog.TransLoadProgressDialog) LogSettingsDialog(org.pentaho.di.ui.spoon.dialog.LogSettingsDialog) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) SubjectDataBrowserDialog(org.pentaho.di.ui.core.dialog.SubjectDataBrowserDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ImportRulesDialog(org.pentaho.di.ui.imp.ImportRulesDialog) RepositoriesDialog(org.pentaho.di.ui.repository.RepositoriesDialog) KettlePropertiesFileDialog(org.pentaho.di.ui.core.dialog.KettlePropertiesFileDialog) EnterMappingDialog(org.pentaho.di.ui.core.dialog.EnterMappingDialog) Dialog(org.eclipse.jface.dialogs.Dialog) CheckTransProgressDialog(org.pentaho.di.ui.spoon.dialog.CheckTransProgressDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) ShowMessageDialog(org.pentaho.di.ui.core.dialog.ShowMessageDialog) CapabilityManagerDialog(org.pentaho.di.ui.spoon.dialog.CapabilityManagerDialog) TransHopDialog(org.pentaho.di.ui.trans.dialog.TransHopDialog) TransLoadProgressDialog(org.pentaho.di.ui.trans.dialog.TransLoadProgressDialog) EnterOptionsDialog(org.pentaho.di.ui.core.dialog.EnterOptionsDialog) BrowserEnvironmentWarningDialog(org.pentaho.di.ui.core.dialog.BrowserEnvironmentWarningDialog) AuthProviderDialog(org.pentaho.di.ui.core.auth.AuthProviderDialog) EnterSearchDialog(org.pentaho.di.ui.core.dialog.EnterSearchDialog) EnterStringsDialog(org.pentaho.di.ui.core.dialog.EnterStringsDialog) VfsFileChooserDialog(org.pentaho.vfs.ui.VfsFileChooserDialog) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) SelectDirectoryDialog(org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog) MetaStoreExplorerDialog(org.pentaho.di.ui.spoon.dialog.MetaStoreExplorerDialog) RepositoryImportProgressDialog(org.pentaho.di.ui.repository.dialog.RepositoryImportProgressDialog) SaveProgressDialog(org.pentaho.di.ui.spoon.dialog.SaveProgressDialog) AnalyseImpactProgressDialog(org.pentaho.di.ui.spoon.dialog.AnalyseImpactProgressDialog) RepositoryExportProgressDialog(org.pentaho.di.ui.repository.dialog.RepositoryExportProgressDialog) AboutDialog(org.pentaho.di.ui.core.dialog.AboutDialog) JobLoadProgressDialog(org.pentaho.di.ui.job.dialog.JobLoadProgressDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SimpleMessageDialog(org.pentaho.di.ui.core.dialog.SimpleMessageDialog) CheckResultDialog(org.pentaho.di.ui.core.dialog.CheckResultDialog) ShowBrowserDialog(org.pentaho.di.ui.core.dialog.ShowBrowserDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) TransMeta(org.pentaho.di.trans.TransMeta) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) JobLoadProgressDialog(org.pentaho.di.ui.job.dialog.JobLoadProgressDialog)

Example 73 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-kettle by pentaho.

the class TransDialog method addTransTab.

private void addTransTab() {
    // ////////////////////////
    // START OF TRANS TAB///
    // /
    wTransTab = new CTabItem(wTabFolder, SWT.NONE);
    wTransTab.setText(BaseMessages.getString(PKG, "TransDialog.TransTab.Label"));
    Composite wTransComp = new Composite(wTabFolder, SWT.NONE);
    props.setLook(wTransComp);
    FormLayout transLayout = new FormLayout();
    transLayout.marginWidth = Const.FORM_MARGIN;
    transLayout.marginHeight = Const.FORM_MARGIN;
    wTransComp.setLayout(transLayout);
    // Transformation name:
    Label wlTransname = new Label(wTransComp, SWT.RIGHT);
    wlTransname.setText(BaseMessages.getString(PKG, "TransDialog.Transname.Label"));
    props.setLook(wlTransname);
    FormData fdlTransname = new FormData();
    fdlTransname.left = new FormAttachment(0, 0);
    fdlTransname.right = new FormAttachment(middle, -margin);
    fdlTransname.top = new FormAttachment(0, margin);
    wlTransname.setLayoutData(fdlTransname);
    wTransname = new Text(wTransComp, rep == null ? SWT.SINGLE | SWT.LEFT | SWT.BORDER : SWT.SINGLE | SWT.LEFT | SWT.BORDER | SWT.READ_ONLY);
    wTransname.setEnabled(rep == null);
    props.setLook(wTransname);
    wTransname.addModifyListener(lsMod);
    FormData fdTransname = new FormData();
    fdTransname.left = new FormAttachment(middle, 0);
    fdTransname.top = new FormAttachment(0, margin);
    fdTransname.right = new FormAttachment(100, 0);
    wTransname.setLayoutData(fdTransname);
    // Transformation name:
    Label wlTransFilename = new Label(wTransComp, SWT.RIGHT);
    wlTransFilename.setText(BaseMessages.getString(PKG, "TransDialog.TransFilename.Label"));
    props.setLook(wlTransFilename);
    FormData fdlTransFilename = new FormData();
    fdlTransFilename.left = new FormAttachment(0, 0);
    fdlTransFilename.right = new FormAttachment(middle, -margin);
    fdlTransFilename.top = new FormAttachment(wTransname, margin);
    wlTransFilename.setLayoutData(fdlTransFilename);
    wTransFilename = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTransFilename);
    wTransFilename.addModifyListener(lsMod);
    FormData fdTransFilename = new FormData();
    fdTransFilename.left = new FormAttachment(middle, 0);
    fdTransFilename.top = new FormAttachment(wTransname, margin);
    fdTransFilename.right = new FormAttachment(100, 0);
    wTransFilename.setLayoutData(fdTransFilename);
    wTransFilename.setEditable(false);
    wTransFilename.setBackground(GUIResource.getInstance().getColorLightGray());
    // Transformation description:
    Label wlTransdescription = new Label(wTransComp, SWT.RIGHT);
    wlTransdescription.setText(BaseMessages.getString(PKG, "TransDialog.Transdescription.Label"));
    props.setLook(wlTransdescription);
    FormData fdlTransdescription = new FormData();
    fdlTransdescription.left = new FormAttachment(0, 0);
    fdlTransdescription.right = new FormAttachment(middle, -margin);
    fdlTransdescription.top = new FormAttachment(wTransFilename, margin);
    wlTransdescription.setLayoutData(fdlTransdescription);
    wTransdescription = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTransdescription);
    wTransdescription.addModifyListener(lsMod);
    FormData fdTransdescription = new FormData();
    fdTransdescription.left = new FormAttachment(middle, 0);
    fdTransdescription.top = new FormAttachment(wTransFilename, margin);
    fdTransdescription.right = new FormAttachment(100, 0);
    wTransdescription.setLayoutData(fdTransdescription);
    // Transformation Extended description
    wlExtendeddescription = new Label(wTransComp, SWT.RIGHT);
    wlExtendeddescription.setText(BaseMessages.getString(PKG, "TransDialog.Extendeddescription.Label"));
    props.setLook(wlExtendeddescription);
    fdlExtendeddescription = new FormData();
    fdlExtendeddescription.left = new FormAttachment(0, 0);
    fdlExtendeddescription.top = new FormAttachment(wTransdescription, margin);
    fdlExtendeddescription.right = new FormAttachment(middle, -margin);
    wlExtendeddescription.setLayoutData(fdlExtendeddescription);
    wExtendeddescription = new Text(wTransComp, SWT.MULTI | SWT.LEFT | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    props.setLook(wExtendeddescription, Props.WIDGET_STYLE_FIXED);
    wExtendeddescription.addModifyListener(lsMod);
    fdExtendeddescription = new FormData();
    fdExtendeddescription.left = new FormAttachment(middle, 0);
    fdExtendeddescription.top = new FormAttachment(wTransdescription, margin);
    fdExtendeddescription.right = new FormAttachment(100, 0);
    fdExtendeddescription.bottom = new FormAttachment(50, -margin);
    wExtendeddescription.setLayoutData(fdExtendeddescription);
    // Trans Status
    wlTransstatus = new Label(wTransComp, SWT.RIGHT);
    wlTransstatus.setText(BaseMessages.getString(PKG, "TransDialog.Transstatus.Label"));
    props.setLook(wlTransstatus);
    fdlTransstatus = new FormData();
    fdlTransstatus.left = new FormAttachment(0, 0);
    fdlTransstatus.right = new FormAttachment(middle, 0);
    fdlTransstatus.top = new FormAttachment(wExtendeddescription, margin * 2);
    wlTransstatus.setLayoutData(fdlTransstatus);
    wTransstatus = new CCombo(wTransComp, SWT.SINGLE | SWT.READ_ONLY | SWT.BORDER);
    wTransstatus.add(BaseMessages.getString(PKG, "TransDialog.Draft_Transstatus.Label"));
    wTransstatus.add(BaseMessages.getString(PKG, "TransDialog.Production_Transstatus.Label"));
    wTransstatus.add("");
    // +1: starts at -1
    wTransstatus.select(-1);
    wTransstatus.addSelectionListener(lsModSel);
    props.setLook(wTransstatus);
    fdTransstatus = new FormData();
    fdTransstatus.left = new FormAttachment(middle, 0);
    fdTransstatus.top = new FormAttachment(wExtendeddescription, margin * 2);
    fdTransstatus.right = new FormAttachment(100, 0);
    wTransstatus.setLayoutData(fdTransstatus);
    // Transformation Transversion:
    Label wlTransversion = new Label(wTransComp, SWT.RIGHT);
    wlTransversion.setText(BaseMessages.getString(PKG, "TransDialog.Transversion.Label"));
    props.setLook(wlTransversion);
    FormData fdlTransversion = new FormData();
    fdlTransversion.left = new FormAttachment(0, 0);
    fdlTransversion.right = new FormAttachment(middle, -margin);
    fdlTransversion.top = new FormAttachment(wTransstatus, margin);
    wlTransversion.setLayoutData(fdlTransversion);
    wTransversion = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wTransversion);
    wTransversion.addModifyListener(lsMod);
    FormData fdTransversion = new FormData();
    fdTransversion.left = new FormAttachment(middle, 0);
    fdTransversion.top = new FormAttachment(wTransstatus, margin);
    fdTransversion.right = new FormAttachment(100, 0);
    wTransversion.setLayoutData(fdTransversion);
    // Directory:
    wlDirectory = new Label(wTransComp, SWT.RIGHT);
    wlDirectory.setText(BaseMessages.getString(PKG, "TransDialog.Directory.Label"));
    props.setLook(wlDirectory);
    FormData fdlDirectory = new FormData();
    fdlDirectory.left = new FormAttachment(0, 0);
    fdlDirectory.right = new FormAttachment(middle, -margin);
    fdlDirectory.top = new FormAttachment(wTransversion, margin);
    wlDirectory.setLayoutData(fdlDirectory);
    wbDirectory = new Button(wTransComp, SWT.PUSH);
    wbDirectory.setToolTipText(BaseMessages.getString(PKG, "TransDialog.selectTransFolder.Tooltip"));
    wbDirectory.setImage(GUIResource.getInstance().getImageArrow());
    props.setLook(wbDirectory);
    FormData fdbDirectory = new FormData();
    fdbDirectory.right = new FormAttachment(100, 0);
    fdbDirectory.top = new FormAttachment(wTransversion, 0);
    wbDirectory.setLayoutData(fdbDirectory);
    wbDirectory.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent arg0) {
            RepositoryDirectoryInterface directoryFrom = transMeta.getRepositoryDirectory();
            RepositoryDirectoryInterface rd = RepositoryDirectoryUI.chooseDirectory(shell, rep, directoryFrom);
            if (rd == null) {
                return;
            }
            // We need to change this in the repository as well!!
            // We do this when the user pressed OK
            newDirectory = rd;
            wDirectory.setText(rd.getPath());
        }
    });
    wDirectory = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wDirectory);
    wDirectory.setEditable(false);
    wDirectory.setEnabled(false);
    FormData fdDirectory = new FormData();
    fdDirectory.left = new FormAttachment(middle, 0);
    fdDirectory.top = new FormAttachment(wTransversion, margin);
    fdDirectory.right = new FormAttachment(wbDirectory, 0);
    wDirectory.setLayoutData(fdDirectory);
    // Create User:
    Label wlCreateUser = new Label(wTransComp, SWT.RIGHT);
    wlCreateUser.setText(BaseMessages.getString(PKG, "TransDialog.CreateUser.Label"));
    props.setLook(wlCreateUser);
    FormData fdlCreateUser = new FormData();
    fdlCreateUser.left = new FormAttachment(0, 0);
    fdlCreateUser.right = new FormAttachment(middle, -margin);
    fdlCreateUser.top = new FormAttachment(wDirectory, margin);
    wlCreateUser.setLayoutData(fdlCreateUser);
    wCreateUser = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wCreateUser);
    wCreateUser.setEditable(false);
    wCreateUser.addModifyListener(lsMod);
    FormData fdCreateUser = new FormData();
    fdCreateUser.left = new FormAttachment(middle, 0);
    fdCreateUser.top = new FormAttachment(wDirectory, margin);
    fdCreateUser.right = new FormAttachment(100, 0);
    wCreateUser.setLayoutData(fdCreateUser);
    // Created Date:
    Label wlCreateDate = new Label(wTransComp, SWT.RIGHT);
    wlCreateDate.setText(BaseMessages.getString(PKG, "TransDialog.CreateDate.Label"));
    props.setLook(wlCreateDate);
    FormData fdlCreateDate = new FormData();
    fdlCreateDate.left = new FormAttachment(0, 0);
    fdlCreateDate.right = new FormAttachment(middle, -margin);
    fdlCreateDate.top = new FormAttachment(wCreateUser, margin);
    wlCreateDate.setLayoutData(fdlCreateDate);
    wCreateDate = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wCreateDate);
    wCreateDate.setEditable(false);
    wCreateDate.addModifyListener(lsMod);
    FormData fdCreateDate = new FormData();
    fdCreateDate.left = new FormAttachment(middle, 0);
    fdCreateDate.top = new FormAttachment(wCreateUser, margin);
    fdCreateDate.right = new FormAttachment(100, 0);
    wCreateDate.setLayoutData(fdCreateDate);
    // Modified User:
    Label wlModUser = new Label(wTransComp, SWT.RIGHT);
    wlModUser.setText(BaseMessages.getString(PKG, "TransDialog.LastModifiedUser.Label"));
    props.setLook(wlModUser);
    FormData fdlModUser = new FormData();
    fdlModUser.left = new FormAttachment(0, 0);
    fdlModUser.right = new FormAttachment(middle, -margin);
    fdlModUser.top = new FormAttachment(wCreateDate, margin);
    wlModUser.setLayoutData(fdlModUser);
    wModUser = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wModUser);
    wModUser.setEditable(false);
    wModUser.addModifyListener(lsMod);
    FormData fdModUser = new FormData();
    fdModUser.left = new FormAttachment(middle, 0);
    fdModUser.top = new FormAttachment(wCreateDate, margin);
    fdModUser.right = new FormAttachment(100, 0);
    wModUser.setLayoutData(fdModUser);
    // Modified Date:
    Label wlModDate = new Label(wTransComp, SWT.RIGHT);
    wlModDate.setText(BaseMessages.getString(PKG, "TransDialog.LastModifiedDate.Label"));
    props.setLook(wlModDate);
    FormData fdlModDate = new FormData();
    fdlModDate.left = new FormAttachment(0, 0);
    fdlModDate.right = new FormAttachment(middle, -margin);
    fdlModDate.top = new FormAttachment(wModUser, margin);
    wlModDate.setLayoutData(fdlModDate);
    wModDate = new Text(wTransComp, SWT.SINGLE | SWT.LEFT | SWT.BORDER);
    props.setLook(wModDate);
    wModDate.setEditable(false);
    wModDate.addModifyListener(lsMod);
    FormData fdModDate = new FormData();
    fdModDate.left = new FormAttachment(middle, 0);
    fdModDate.top = new FormAttachment(wModUser, margin);
    fdModDate.right = new FormAttachment(100, 0);
    wModDate.setLayoutData(fdModDate);
    FormData fdTransComp = new FormData();
    fdTransComp.left = new FormAttachment(0, 0);
    fdTransComp.top = new FormAttachment(0, 0);
    fdTransComp.right = new FormAttachment(100, 0);
    fdTransComp.bottom = new FormAttachment(100, 0);
    wTransComp.setLayoutData(fdTransComp);
    wTransComp.layout();
    wTransTab.setControl(wTransComp);
// ///////////////////////////////////////////////////////////
// / END OF TRANS TAB
// ///////////////////////////////////////////////////////////
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) CCombo(org.eclipse.swt.custom.CCombo) Composite(org.eclipse.swt.widgets.Composite) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) CTabItem(org.eclipse.swt.custom.CTabItem) FormAttachment(org.eclipse.swt.layout.FormAttachment)

Example 74 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-metaverse by pentaho.

the class JobExecutorStepAnalyzer method customAnalyze.

@Override
protected void customAnalyze(JobExecutorMeta meta, IMetaverseNode node) throws MetaverseAnalyzerException {
    String jobPath = meta.getFileName();
    JobMeta subJobMeta = null;
    Repository repo = parentTransMeta.getRepository();
    switch(meta.getSpecificationMethod()) {
        case FILENAME:
            jobPath = parentTransMeta.environmentSubstitute(meta.getFileName());
            try {
                String normalized = KettleAnalyzerUtil.normalizeFilePath(jobPath);
                subJobMeta = getSubJobMeta(parentTransMeta, normalized);
                jobPath = normalized;
            } catch (Exception e) {
                throw new MetaverseAnalyzerException("Sub transformation can not be found - " + jobPath, e);
            }
            break;
        case REPOSITORY_BY_NAME:
            if (repo != null) {
                String dir = parentTransMeta.environmentSubstitute(meta.getDirectoryPath());
                String file = parentTransMeta.environmentSubstitute(meta.getJobName());
                try {
                    RepositoryDirectoryInterface rdi = repo.findDirectory(dir);
                    subJobMeta = repo.loadJob(file, rdi, null, null);
                    String filename = subJobMeta.getFilename() == null ? subJobMeta.toString() : subJobMeta.getFilename();
                    jobPath = filename + "." + subJobMeta.getDefaultExtension();
                } catch (KettleException e) {
                    throw new MetaverseAnalyzerException("Sub transformation can not be found in repository - " + file, e);
                }
            } else {
                throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
            }
            break;
        case REPOSITORY_BY_REFERENCE:
            if (repo != null) {
                try {
                    subJobMeta = repo.loadJob(meta.getJobObjectId(), null);
                    String filename = subJobMeta.getFilename() == null ? subJobMeta.toString() : subJobMeta.getFilename();
                    jobPath = filename + "." + subJobMeta.getDefaultExtension();
                } catch (KettleException e) {
                    throw new MetaverseAnalyzerException("Sub transformation can not be found by reference - " + meta.getJobObjectId(), e);
                }
            } else {
                throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
            }
            break;
    }
    // analyze the sub trans?
    IComponentDescriptor ds = new MetaverseComponentDescriptor(subJobMeta.getName(), DictionaryConst.NODE_TYPE_JOB, descriptor.getNamespace().getParentNamespace());
    IMetaverseNode jobNode = createNodeFromDescriptor(ds);
    jobNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, ds.getNamespaceId());
    jobNode.setProperty(DictionaryConst.PROPERTY_PATH, jobPath);
    jobNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
    metaverseBuilder.addLink(node, DictionaryConst.LINK_EXECUTES, jobNode);
    connectToSubJobOutputFields(meta, subJobMeta, jobNode, descriptor);
    node.setProperty(JOB_TO_EXECUTE, jobPath);
    if (StringUtils.isNotEmpty(meta.getExecutionResultTargetStep())) {
        node.setProperty(EXECUTION_RESULTS_TARGET, meta.getExecutionResultTargetStep());
    }
    if (StringUtils.isNotEmpty(meta.getResultFilesTargetStep())) {
        node.setProperty(RESULT_FILES_TARGET, meta.getResultFilesTargetStep());
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) Repository(org.pentaho.di.repository.Repository) IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) FileNotFoundException(java.io.FileNotFoundException) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Example 75 with RepositoryDirectoryInterface

use of org.pentaho.di.repository.RepositoryDirectoryInterface in project pentaho-metaverse by pentaho.

the class TransExecutorStepAnalyzer method customAnalyze.

@Override
protected void customAnalyze(TransExecutorMeta meta, IMetaverseNode node) throws MetaverseAnalyzerException {
    String transPath = meta.getFileName();
    TransMeta subTransMeta = null;
    Repository repo = parentTransMeta.getRepository();
    switch(meta.getSpecificationMethod()) {
        case FILENAME:
            transPath = parentTransMeta.environmentSubstitute(meta.getFileName());
            try {
                String normalized = KettleAnalyzerUtil.normalizeFilePath(transPath);
                subTransMeta = getSubTransMeta(normalized);
                transPath = normalized;
            } catch (Exception e) {
                throw new MetaverseAnalyzerException("Sub transformation can not be found - " + transPath, e);
            }
            break;
        case REPOSITORY_BY_NAME:
            if (repo != null) {
                String dir = parentTransMeta.environmentSubstitute(meta.getDirectoryPath());
                String file = parentTransMeta.environmentSubstitute(meta.getTransName());
                try {
                    RepositoryDirectoryInterface rdi = repo.findDirectory(dir);
                    subTransMeta = repo.loadTransformation(file, rdi, null, true, null);
                    transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
                } catch (KettleException e) {
                    throw new MetaverseAnalyzerException("Sub transformation can not be found in repository - " + file, e);
                }
            } else {
                throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
            }
            break;
        case REPOSITORY_BY_REFERENCE:
            if (repo != null) {
                try {
                    subTransMeta = repo.loadTransformation(meta.getTransObjectId(), null);
                    transPath = subTransMeta.getPathAndName() + "." + subTransMeta.getDefaultExtension();
                } catch (KettleException e) {
                    throw new MetaverseAnalyzerException("Sub transformation can not be found by reference - " + meta.getTransObjectId(), e);
                }
            } else {
                throw new MetaverseAnalyzerException("Not connected to a repository, can't get the transformation");
            }
            break;
    }
    // analyze the sub trans?
    IComponentDescriptor ds = new MetaverseComponentDescriptor(subTransMeta.getName(), DictionaryConst.NODE_TYPE_TRANS, descriptor.getNamespace().getParentNamespace());
    IMetaverseNode transformationNode = createNodeFromDescriptor(ds);
    transformationNode.setProperty(DictionaryConst.PROPERTY_NAMESPACE, ds.getNamespaceId());
    transformationNode.setProperty(DictionaryConst.PROPERTY_PATH, transPath);
    transformationNode.setLogicalIdGenerator(DictionaryConst.LOGICAL_ID_GENERATOR_DOCUMENT);
    metaverseBuilder.addLink(node, DictionaryConst.LINK_EXECUTES, transformationNode);
    connectToSubTransInputFields(meta, subTransMeta, transformationNode, descriptor);
    connectToSubTransOutputFields(meta, subTransMeta, transformationNode, descriptor);
    node.setProperty(TRANSFORMATION_TO_EXECUTE, transPath);
    if (StringUtils.isNotEmpty(meta.getExecutionResultTargetStep())) {
        node.setProperty(EXECUTION_RESULTS_TARGET, meta.getExecutionResultTargetStep());
    }
    if (StringUtils.isNotEmpty(meta.getOutputRowsSourceStep())) {
        node.setProperty(OUTPUT_ROWS_TARGET, meta.getOutputRowsSourceStep());
    }
    if (StringUtils.isNotEmpty(meta.getResultFilesTargetStep())) {
        node.setProperty(RESULT_FILES_TARGET, meta.getResultFilesTargetStep());
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) IComponentDescriptor(org.pentaho.metaverse.api.IComponentDescriptor) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) TransMeta(org.pentaho.di.trans.TransMeta) KettleException(org.pentaho.di.core.exception.KettleException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) FileNotFoundException(java.io.FileNotFoundException) MetaverseAnalyzerException(org.pentaho.metaverse.api.MetaverseAnalyzerException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) MetaverseComponentDescriptor(org.pentaho.metaverse.api.MetaverseComponentDescriptor)

Aggregations

RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)163 KettleException (org.pentaho.di.core.exception.KettleException)68 Test (org.junit.Test)32 TransMeta (org.pentaho.di.trans.TransMeta)30 ObjectId (org.pentaho.di.repository.ObjectId)27 JobMeta (org.pentaho.di.job.JobMeta)23 Repository (org.pentaho.di.repository.Repository)22 ArrayList (java.util.ArrayList)17 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)17 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)15 IOException (java.io.IOException)14 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)13 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)11 RepositoryObject (org.pentaho.di.repository.RepositoryObject)11 FileObject (org.apache.commons.vfs2.FileObject)10 List (java.util.List)8 TreeItem (org.eclipse.swt.widgets.TreeItem)8 KettleFileException (org.pentaho.di.core.exception.KettleFileException)8 Date (java.util.Date)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)7