Search in sources :

Example 81 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class SpoonJobDelegate method pasteXML.

public void pasteXML(JobMeta jobMeta, String clipcontent, Point loc) {
    try {
        Document doc = XMLHandler.loadXMLString(clipcontent);
        // De-select all, re-select pasted steps...
        jobMeta.unselectAll();
        Node entriesnode = XMLHandler.getSubNode(doc, Spoon.XML_TAG_JOB_JOB_ENTRIES);
        int nr = XMLHandler.countNodes(entriesnode, "entry");
        spoon.getLog().logDebug(spoon.toString(), "I found " + nr + " job entries to paste on location: " + loc);
        List<JobEntryCopy> entryList = new ArrayList<>(nr);
        // Point min = new Point(loc.x, loc.y);
        Point min = new Point(99999999, 99999999);
        for (int i = 0; i < nr; i++) {
            Node entrynode = XMLHandler.getSubNodeByNr(entriesnode, "entry", i);
            JobEntryCopy copy = new JobEntryCopy(entrynode, jobMeta.getDatabases(), jobMeta.getSlaveServers(), spoon.getRepository(), spoon.getMetaStore());
            if (copy.isStart() && (jobMeta.findStart() != null)) {
                JobGraph.showOnlyStartOnceMessage(spoon.getShell());
                continue;
            }
            String name = jobMeta.getAlternativeJobentryName(copy.getName());
            copy.setName(name);
            if (loc != null) {
                Point p = copy.getLocation();
                if (min.x > p.x) {
                    min.x = p.x;
                }
                if (min.y > p.y) {
                    min.y = p.y;
                }
            }
            entryList.add(copy);
        }
        JobEntryCopy[] entries = entryList.toArray(new JobEntryCopy[] {});
        // What's the difference between loc and min?
        // This is the offset:
        Point offset = new Point(loc.x - min.x, loc.y - min.y);
        // Undo/redo object positions...
        int[] position = new int[entries.length];
        for (int i = 0; i < entries.length; i++) {
            Point p = entries[i].getLocation();
            String name = entries[i].getName();
            entries[i].setLocation(p.x + offset.x, p.y + offset.y);
            // Check the name, find alternative...
            entries[i].setName(jobMeta.getAlternativeJobentryName(name));
            jobMeta.addJobEntry(entries[i]);
            position[i] = jobMeta.indexOfJobEntry(entries[i]);
        }
        // Save undo information too...
        spoon.addUndoNew(jobMeta, entries, position);
        if (jobMeta.hasChanged()) {
            spoon.refreshTree();
            spoon.refreshGraph();
        }
    } catch (KettleException e) {
        new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.ErrorDialog.ErrorPasingJobEntries.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.ErrorPasingJobEntries.Message"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Node(org.w3c.dom.Node) ArrayList(java.util.ArrayList) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Document(org.w3c.dom.Document) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 82 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class SpoonJobDelegate method executeJob.

public void executeJob(JobMeta jobMeta, boolean local, boolean remote, Date replayDate, boolean safe, String startCopyName, int startCopyNr) throws KettleException {
    if (jobMeta == null) {
        return;
    }
    JobExecutionConfiguration executionConfiguration = spoon.getJobExecutionConfiguration();
    // Remember the variables set previously
    // 
    Object[] data = spoon.variables.getData();
    String[] fields = spoon.variables.getRowMeta().getFieldNames();
    Map<String, String> variableMap = new HashMap<>();
    for (int idx = 0; idx < fields.length; idx++) {
        variableMap.put(fields[idx], data[idx].toString());
    }
    executionConfiguration.setVariables(variableMap);
    executionConfiguration.getUsedVariables(jobMeta);
    executionConfiguration.setReplayDate(replayDate);
    executionConfiguration.setRepository(spoon.rep);
    executionConfiguration.setSafeModeEnabled(safe);
    executionConfiguration.setStartCopyName(startCopyName);
    executionConfiguration.setStartCopyNr(startCopyNr);
    executionConfiguration.getUsedArguments(jobMeta, spoon.getArguments(), spoon.getMetaStore());
    executionConfiguration.setLogLevel(DefaultLogLevel.getLogLevel());
    JobExecutionConfigurationDialog dialog = newJobExecutionConfigurationDialog(executionConfiguration, jobMeta);
    if (!jobMeta.isShowDialog() || dialog.open()) {
        JobGraph jobGraph = spoon.getActiveJobGraph();
        jobGraph.jobLogDelegate.addJobLog();
        // 
        for (String varName : executionConfiguration.getVariables().keySet()) {
            String varValue = executionConfiguration.getVariables().get(varName);
            jobMeta.setVariable(varName, varValue);
        }
        // 
        for (String paramName : executionConfiguration.getParams().keySet()) {
            String paramValue = executionConfiguration.getParams().get(paramName);
            jobMeta.setParameterValue(paramName, paramValue);
        }
        jobMeta.activateParameters();
        // 
        if (executionConfiguration.getLogLevel() != null) {
            jobMeta.setLogLevel(executionConfiguration.getLogLevel());
        }
        // 
        if (executionConfiguration.getStartCopyName() != null) {
            jobMeta.setStartCopyName(executionConfiguration.getStartCopyName());
        }
        // Set the run options
        // 
        jobMeta.setClearingLog(executionConfiguration.isClearingLog());
        jobMeta.setSafeModeEnabled(executionConfiguration.isSafeModeEnabled());
        jobMeta.setExpandingRemoteJob(executionConfiguration.isExpandingRemoteJob());
        ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonJobMetaExecutionStart.id, jobMeta);
        ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonJobExecutionConfiguration.id, executionConfiguration);
        try {
            ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonTransBeforeStart.id, new Object[] { executionConfiguration, jobMeta, jobMeta, spoon.getRepository() });
        } catch (KettleException e) {
            log.logError(e.getMessage(), jobMeta.getFilename());
            return;
        }
        if (!executionConfiguration.isExecutingLocally() && !executionConfiguration.isExecutingRemotely()) {
            if (jobMeta.hasChanged()) {
                jobGraph.showSaveFileMessage();
            }
        }
        // 
        if (executionConfiguration.isExecutingLocally()) {
            jobGraph.startJob(executionConfiguration);
        } else if (executionConfiguration.isExecutingRemotely()) {
            // Executing remotely
            // Check if jobMeta has changed
            jobGraph.handleJobMetaChanges(jobMeta);
            // Activate the parameters, turn them into variables...
            // jobMeta.hasChanged()
            jobMeta.activateParameters();
            if (executionConfiguration.getRemoteServer() != null) {
                Job.sendToSlaveServer(jobMeta, executionConfiguration, spoon.rep, spoon.metaStore);
                spoon.delegates.slaves.addSpoonSlave(executionConfiguration.getRemoteServer());
            } else {
                MessageBox mb = new MessageBox(spoon.getShell(), SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.NoRemoteServerSpecified.Message"));
                mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.NoRemoteServerSpecified.Title"));
                mb.open();
            }
        }
    }
}
Also used : JobExecutionConfigurationDialog(org.pentaho.di.ui.job.dialog.JobExecutionConfigurationDialog) KettleException(org.pentaho.di.core.exception.KettleException) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) HashMap(java.util.HashMap) JobExecutionConfiguration(org.pentaho.di.job.JobExecutionConfiguration) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 83 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class SpoonPartitionsDelegate method newPartitioningSchema.

public void newPartitioningSchema(TransMeta transMeta) {
    PartitionSchema partitionSchema = new PartitionSchema();
    PartitionSchemaDialog dialog = new PartitionSchemaDialog(spoon.getShell(), partitionSchema, transMeta.getPartitionSchemas(), transMeta.getDatabases(), transMeta);
    if (dialog.open()) {
        List<PartitionSchema> partitions = transMeta.getPartitionSchemas();
        if (isDuplicate(partitions, partitionSchema)) {
            new ErrorDialog(spoon.getShell(), getMessage("Spoon.Dialog.ErrorSavingPartition.Title"), getMessage("Spoon.Dialog.ErrorSavingPartition.Message", partitionSchema.getName()), new KettleException(getMessage("Spoon.Dialog.ErrorSavingPartition.NotUnique")));
            return;
        }
        partitions.add(partitionSchema);
        if (spoon.rep != null) {
            try {
                if (!spoon.rep.getSecurityProvider().isReadOnly()) {
                    spoon.rep.save(partitionSchema, Const.VERSION_COMMENT_INITIAL_VERSION, null);
                    if (sharedObjectSyncUtil != null) {
                        sharedObjectSyncUtil.reloadTransformationRepositoryObjects(false);
                    }
                } else {
                    throw new KettleException(BaseMessages.getString(PKG, "Spoon.Dialog.Exception.ReadOnlyRepositoryUser"));
                }
            } catch (KettleException e) {
                showSaveErrorDialog(partitionSchema, e);
            }
        }
        spoon.refreshTree();
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) PartitionSchema(org.pentaho.di.partition.PartitionSchema) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) PartitionSchemaDialog(org.pentaho.di.ui.partition.dialog.PartitionSchemaDialog)

Example 84 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class SpoonSharedObjectDelegate method saveSharedObjectToRepository.

protected <T extends SharedObjectInterface & RepositoryElementInterface & ChangedFlagInterface> void saveSharedObjectToRepository(T sharedObject, String versionComment) throws KettleException {
    Repository rep = spoon.getRepository();
    if (rep != null) {
        if (!rep.getSecurityProvider().isReadOnly()) {
            rep.save(sharedObject, versionComment, null);
            sharedObject.clearChanged();
        } else {
            throw new KettleException(BaseMessages.getString(PKG, "Spoon.Dialog.Exception.ReadOnlyRepositoryUser"));
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository)

Example 85 with KettleException

use of org.pentaho.di.core.exception.KettleException in project pentaho-kettle by pentaho.

the class SpoonSlaveDelegate method edit.

public boolean edit(SlaveServer slaveServer, List<SlaveServer> existingServers) {
    String originalName = slaveServer.getName();
    SlaveServerDialog dialog = new SlaveServerDialog(spoon.getShell(), slaveServer, existingServers);
    if (dialog.open()) {
        if (spoon.rep != null) {
            try {
                saveSharedObjectToRepository(slaveServer, null);
            } catch (KettleException e) {
                showSaveErrorDialog(slaveServer, e);
            }
        }
        if (sharedObjectSyncUtil != null) {
            sharedObjectSyncUtil.synchronizeSlaveServers(slaveServer, originalName);
        }
        spoon.refreshTree();
        spoon.refreshGraph();
        return true;
    }
    return false;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) SlaveServerDialog(org.pentaho.di.ui.cluster.dialog.SlaveServerDialog)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)1977 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)449 KettleStepException (org.pentaho.di.core.exception.KettleStepException)438 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)317 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)316 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)233 IOException (java.io.IOException)208 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)195 FileObject (org.apache.commons.vfs2.FileObject)150 StepMeta (org.pentaho.di.trans.step.StepMeta)150 ArrayList (java.util.ArrayList)149 KettleFileException (org.pentaho.di.core.exception.KettleFileException)124 TransMeta (org.pentaho.di.trans.TransMeta)119 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)113 Test (org.junit.Test)111 KettleValueException (org.pentaho.di.core.exception.KettleValueException)100 Database (org.pentaho.di.core.database.Database)97 BaseStepMeta (org.pentaho.di.trans.step.BaseStepMeta)95 ObjectId (org.pentaho.di.repository.ObjectId)91 Shell (org.eclipse.swt.widgets.Shell)90