Search in sources :

Example 1 with MissingEntry

use of org.pentaho.di.job.entries.missing.MissingEntry in project pentaho-kettle by pentaho.

the class JobMeta method removeJobEntry.

/**
 * Removes the job entry.
 *
 * @param i the i
 */
public void removeJobEntry(int i) {
    JobEntryCopy deleted = jobcopies.remove(i);
    if (deleted != null) {
        // give step a chance to cleanup
        deleted.setParentJobMeta(null);
        if (deleted.getEntry() instanceof MissingEntry) {
            removeMissingEntry((MissingEntry) deleted.getEntry());
        }
    }
    setChanged();
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) MissingEntry(org.pentaho.di.job.entries.missing.MissingEntry)

Example 2 with MissingEntry

use of org.pentaho.di.job.entries.missing.MissingEntry in project pentaho-kettle by pentaho.

the class KettleDatabaseRepositoryJobEntryDelegate method loadJobEntryCopy.

/**
 * Load the chef graphical entry from repository We load type, name & description if no entry can be found.
 *
 * @param log
 *          the logging channel
 * @param rep
 *          the Repository
 * @param jobId
 *          The job ID
 * @param jobEntryCopyId
 *          The jobentry copy ID
 * @param jobentries
 *          A list with all jobentries
 * @param databases
 *          A list with all defined databases
 */
public JobEntryCopy loadJobEntryCopy(ObjectId jobId, ObjectId jobEntryCopyId, List<JobEntryInterface> jobentries, List<DatabaseMeta> databases, List<SlaveServer> slaveServers, String jobname) throws KettleException {
    JobEntryCopy jobEntryCopy = new JobEntryCopy();
    try {
        jobEntryCopy.setObjectId(jobEntryCopyId);
        // Handle GUI information: nr, location, ...
        RowMetaAndData r = getJobEntryCopy(jobEntryCopyId);
        if (r != null) {
            // These are the jobentry_copy fields...
            // 
            ObjectId jobEntryId = new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY, 0));
            ObjectId jobEntryTypeId = new LongObjectId(r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_ID_JOBENTRY_TYPE, 0));
            jobEntryCopy.setNr((int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_NR, 0));
            int locx = (int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_X, 0);
            int locy = (int) r.getInteger(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_LOCATION_Y, 0);
            boolean isdrawn = r.getBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_GUI_DRAW, false);
            boolean isparallel = r.getBoolean(KettleDatabaseRepository.FIELD_JOBENTRY_COPY_PARALLEL, false);
            // Do we have the jobentry already?
            // 
            jobEntryCopy.setEntry(JobMeta.findJobEntry(jobentries, jobEntryId));
            if (jobEntryCopy.getEntry() == null) {
                // What type of jobentry do we load now?
                // Get the jobentry type code
                // 
                RowMetaAndData rt = getJobEntryType(new LongObjectId(jobEntryTypeId));
                if (rt != null) {
                    String jet_code = rt.getString(KettleDatabaseRepository.FIELD_JOBENTRY_TYPE_CODE, null);
                    JobEntryInterface jobEntry = null;
                    PluginRegistry registry = PluginRegistry.getInstance();
                    PluginInterface jobPlugin = registry.findPluginWithId(JobEntryPluginType.class, jet_code);
                    if (jobPlugin == null) {
                        jobEntry = new MissingEntry(jobname, jet_code);
                    } else {
                        jobEntry = (JobEntryInterface) registry.loadClass(jobPlugin);
                    }
                    if (jobEntry != null) {
                        jobEntryCopy.setEntry(jobEntry);
                        // 
                        if (jobEntry instanceof JobEntryBase) {
                            loadJobEntryBase((JobEntryBase) jobEntry, jobEntryId, databases, slaveServers);
                            ((JobEntryBase) jobEntry).setAttributesMap(loadJobEntryAttributesMap(jobId, jobEntryId));
                        }
                        compatibleJobEntryLoadRep(jobEntry, repository, jobEntryTypeId, databases, slaveServers);
                        jobEntry.loadRep(repository, repository.metaStore, jobEntryId, databases, slaveServers);
                        jobEntryCopy.getEntry().setObjectId(jobEntryId);
                        jobentries.add(jobEntryCopy.getEntry());
                    } else {
                        throw new KettleException("JobEntryLoader was unable to find Job Entry Plugin with description [" + jet_code + "].");
                    }
                } else {
                    throw new KettleException("Unable to find Job Entry Type with id=" + jobEntryTypeId + " in the repository");
                }
            }
            jobEntryCopy.setLocation(locx, locy);
            jobEntryCopy.setDrawn(isdrawn);
            jobEntryCopy.setLaunchingInParallel(isparallel);
            return jobEntryCopy;
        } else {
            throw new KettleException("Unable to find job entry copy in repository with id_jobentry_copy=" + jobEntryCopyId);
        }
    } catch (KettleDatabaseException dbe) {
        throw new KettleException("Unable to load job entry copy from repository with id_jobentry_copy=" + jobEntryCopyId, dbe);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) KettleDatabaseException(org.pentaho.di.core.exception.KettleDatabaseException) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) LongObjectId(org.pentaho.di.repository.LongObjectId) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) MissingEntry(org.pentaho.di.job.entries.missing.MissingEntry) JobEntryBase(org.pentaho.di.job.entry.JobEntryBase) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry)

Example 3 with MissingEntry

use of org.pentaho.di.job.entries.missing.MissingEntry in project pentaho-kettle by pentaho.

the class JobDelegate method readJobEntry.

protected JobEntryInterface readJobEntry(DataNode copyNode, JobMeta jobMeta, List<JobEntryInterface> jobentries) throws KettleException {
    try {
        String name = getString(copyNode, PROP_NAME);
        for (JobEntryInterface entry : jobentries) {
            if (entry.getName().equalsIgnoreCase(name)) {
                // already loaded!
                return entry;
            }
        }
        // load the entry from the node
        // 
        String typeId = getString(copyNode, PROP_JOBENTRY_TYPE);
        PluginRegistry registry = PluginRegistry.getInstance();
        PluginInterface jobPlugin = registry.findPluginWithId(JobEntryPluginType.class, typeId);
        JobEntryInterface jobMetaInterface = null;
        boolean isMissing = jobPlugin == null;
        if (!isMissing) {
            jobMetaInterface = (JobEntryInterface) registry.loadClass(jobPlugin);
        } else {
            MissingEntry missingEntry = new MissingEntry(jobMeta.getName(), typeId);
            jobMeta.addMissingEntry(missingEntry);
            jobMetaInterface = missingEntry;
        }
        jobMetaInterface.setName(name);
        jobMetaInterface.setDescription(getString(copyNode, PROP_DESCRIPTION));
        jobMetaInterface.setObjectId(new StringObjectId(copyNode.getId().toString()));
        RepositoryProxy proxy = new RepositoryProxy(copyNode.getNode(NODE_CUSTOM));
        // make sure metastore is passed
        jobMetaInterface.setMetaStore(jobMeta.getMetaStore());
        if (!isMissing) {
            compatibleJobEntryLoadRep(jobMetaInterface, proxy, null, jobMeta.getDatabases(), jobMeta.getSlaveServers());
            jobMetaInterface.loadRep(proxy, jobMeta.getMetaStore(), null, jobMeta.getDatabases(), jobMeta.getSlaveServers());
        }
        jobentries.add(jobMetaInterface);
        return jobMetaInterface;
    } catch (Exception e) {
        throw new KettleException("Unable to read job entry interface information from repository", e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) StringObjectId(org.pentaho.di.repository.StringObjectId) KettleException(org.pentaho.di.core.exception.KettleException) MissingEntry(org.pentaho.di.job.entries.missing.MissingEntry)

Example 4 with MissingEntry

use of org.pentaho.di.job.entries.missing.MissingEntry in project pentaho-kettle by pentaho.

the class MissingEntryDialog method open.

public JobEntryInterface open() {
    this.props = PropsUI.getInstance();
    Display display = shellParent.getDisplay();
    int margin = Const.MARGIN;
    shell = new Shell(shellParent, SWT.DIALOG_TRIM | SWT.CLOSE | SWT.ICON | SWT.APPLICATION_MODAL);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageSpoon());
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginLeft = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setText(BaseMessages.getString(PKG, "MissingEntryDialog.MissingPlugins"));
    shell.setLayout(formLayout);
    Label image = new Label(shell, SWT.NONE);
    props.setLook(image);
    Image icon = display.getSystemImage(SWT.ICON_QUESTION);
    image.setImage(icon);
    FormData imageData = new FormData();
    imageData.left = new FormAttachment(0, 5);
    imageData.right = new FormAttachment(11, 0);
    imageData.top = new FormAttachment(0, 10);
    image.setLayoutData(imageData);
    Label error = new Label(shell, SWT.WRAP);
    props.setLook(error);
    error.setText(getErrorMessage(missingEntries, mode));
    FormData errorData = new FormData();
    errorData.left = new FormAttachment(image, 5);
    errorData.right = new FormAttachment(100, -5);
    errorData.top = new FormAttachment(0, 10);
    error.setLayoutData(errorData);
    Label separator = new Label(shell, SWT.WRAP);
    props.setLook(separator);
    FormData separatorData = new FormData();
    separatorData.top = new FormAttachment(error, 10);
    separator.setLayoutData(separatorData);
    Button closeButton = new Button(shell, SWT.PUSH);
    props.setLook(closeButton);
    FormData fdClose = new FormData();
    fdClose.right = new FormAttachment(98);
    fdClose.top = new FormAttachment(separator);
    closeButton.setLayoutData(fdClose);
    closeButton.setText(BaseMessages.getString(PKG, "MissingEntryDialog.Close"));
    closeButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            shell.dispose();
            jobEntryResult = null;
        }
    });
    FormData fdSearch = new FormData();
    if (this.mode == MISSING_JOB_ENTRIES) {
        Button openButton = new Button(shell, SWT.PUSH);
        props.setLook(openButton);
        FormData fdOpen = new FormData();
        fdOpen.right = new FormAttachment(closeButton, -5);
        fdOpen.bottom = new FormAttachment(closeButton, 0, SWT.BOTTOM);
        openButton.setLayoutData(fdOpen);
        openButton.setText(BaseMessages.getString(PKG, "MissingEntryDialog.OpenFile"));
        openButton.addSelectionListener(new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                shell.dispose();
                jobEntryResult = new MissingEntry();
            }
        });
        fdSearch.right = new FormAttachment(openButton, -5);
        fdSearch.bottom = new FormAttachment(openButton, 0, SWT.BOTTOM);
    } else {
        fdSearch.right = new FormAttachment(closeButton, -5);
        fdSearch.bottom = new FormAttachment(closeButton, 0, SWT.BOTTOM);
    }
    Button searchButton = new Button(shell, SWT.PUSH);
    props.setLook(searchButton);
    searchButton.setText(BaseMessages.getString(PKG, "MissingEntryDialog.SearchMarketplace"));
    searchButton.setLayoutData(fdSearch);
    searchButton.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            try {
                shell.dispose();
                Spoon.getInstance().openMarketplace();
            } catch (Exception ex) {
                ex.printStackTrace();
            }
        }
    });
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobEntryResult;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Image(org.eclipse.swt.graphics.Image) MissingEntry(org.pentaho.di.job.entries.missing.MissingEntry) Shell(org.eclipse.swt.widgets.Shell) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Example 5 with MissingEntry

use of org.pentaho.di.job.entries.missing.MissingEntry in project pentaho-kettle by pentaho.

the class MissingEntryDialog method getErrorMessage.

private String getErrorMessage(List<MissingEntry> missingEntries, int mode) {
    String message = "";
    if (mode == MISSING_JOB_ENTRIES) {
        StringBuilder entries = new StringBuilder();
        for (MissingEntry entry : missingEntries) {
            if (missingEntries.indexOf(entry) == missingEntries.size() - 1) {
                entries.append("- " + entry.getName() + " - " + entry.getMissingPluginId() + "\n\n");
            } else {
                entries.append("- " + entry.getName() + " - " + entry.getMissingPluginId() + "\n");
            }
        }
        message = BaseMessages.getString(PKG, "MissingEntryDialog.MissingJobEntries", entries.toString());
    }
    if (mode == MISSING_JOB_ENTRY_ID) {
        message = BaseMessages.getString(PKG, "MissingEntryDialog.MissingJobEntryId", jobEntryInt.getName() + " - " + ((MissingEntry) jobEntryInt).getMissingPluginId());
    }
    return message;
}
Also used : MissingEntry(org.pentaho.di.job.entries.missing.MissingEntry)

Aggregations

MissingEntry (org.pentaho.di.job.entries.missing.MissingEntry)5 KettleException (org.pentaho.di.core.exception.KettleException)2 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)2 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)2 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)2 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Image (org.eclipse.swt.graphics.Image)1 FormAttachment (org.eclipse.swt.layout.FormAttachment)1 FormData (org.eclipse.swt.layout.FormData)1 FormLayout (org.eclipse.swt.layout.FormLayout)1 Button (org.eclipse.swt.widgets.Button)1 Display (org.eclipse.swt.widgets.Display)1 Label (org.eclipse.swt.widgets.Label)1 Shell (org.eclipse.swt.widgets.Shell)1 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)1 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 JobEntryBase (org.pentaho.di.job.entry.JobEntryBase)1