Example usage for java.lang.reflect InvocationTargetException InvocationTargetException

List of usage examples for java.lang.reflect InvocationTargetException InvocationTargetException

Introduction

In this page you can find the example usage for java.lang.reflect InvocationTargetException InvocationTargetException.

Prototype

public InvocationTargetException(Throwable target, String s) 

Source Link

Document

Constructs a InvocationTargetException with a target exception and a detail message.

Usage

From source file:org.locationtech.udig.processingtoolbox.tools.ScatterPlotDialog.java

@SuppressWarnings("nls")
@Override/*from  ww  w  .j a va 2 s .co  m*/
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    monitor.beginTask(String.format(Messages.Task_Executing, windowTitle), 100);
    try {
        if (plotTab == null) {
            monitor.subTask("Preparing scatter plot...");
            createGraphTab(inputTab.getParent());
        }

        if (outputTab == null) {
            createOutputTab(inputTab.getParent());
        }

        monitor.worked(increment);

        String xField = cboXField.getText();
        String yField = cboYField.getText();
        SimpleFeatureCollection features = MapUtils.getFeatures(inputLayer);

        String fields = xField + "," + yField;

        HtmlWriter writer = new HtmlWriter(inputLayer.getName());
        DataStatisticsResult statistics = null;
        PearsonResult pearson = null;

        if (chkStatistics.getSelection()) {
            ProgressListener subMonitor = GeoToolsAdapters
                    .progress(SubMonitor.convert(monitor, Messages.Task_Internal, 20));
            statistics = StatisticsFeaturesProcess.process(features, fields, subMonitor);
            writer.writeDataStatistics(statistics);
        }

        if (chkPearson.getSelection()) {
            ProgressListener subMonitor = GeoToolsAdapters
                    .progress(SubMonitor.convert(monitor, Messages.Task_Internal, 20));
            pearson = PearsonCorrelationProcess.process(features, fields, subMonitor);
            writer.writePearson(pearson);
        }

        if (statistics != null || pearson != null) {
            browser.setText(writer.getHTML());
        }

        monitor.subTask("Updating scatter plot...");
        chartComposite.setLayer(inputLayer);
        updateChart(features, xField, yField);
        plotTab.getParent().setSelection(plotTab);
        monitor.worked(increment);
    } catch (Exception e) {
        ToolboxPlugin.log(e.getMessage());
        throw new InvocationTargetException(e.getCause(), e.getMessage());
    } finally {
        ToolboxPlugin.log(String.format(Messages.Task_Completed, windowTitle));
        monitor.done();
    }
}

From source file:net.paoding.rose.web.impl.thread.ActionEngine.java

private Exception createException(Rose rose, Throwable exception) {
    final RequestPath requestPath = rose.getInvocation().getRequestPath();
    StringBuilder sb = new StringBuilder(1024);
    sb.append("[Rose-").append(RoseVersion.getVersion()).append("@Spring-").append(SpringVersion.getVersion());
    sb.append("]Error happended: ").append(requestPath.getMethod());
    sb.append(" ").append(requestPath.getUri());
    sb.append("->");
    sb.append(this).append(" params=");
    sb.append(Arrays.toString(rose.getInvocation().getMethodParameters()));
    InvocationTargetException servletException = new InvocationTargetException(exception, sb.toString());
    return servletException;
}

From source file:com.laxser.blitz.web.impl.thread.ActionEngine.java

private Exception createException(Blitz blitz, Throwable exception) {
    final RequestPath requestPath = blitz.getInvocation().getRequestPath();
    StringBuilder sb = new StringBuilder(1024);
    sb.append("[Blitz-").append(BlitzVersion.getVersion()).append("@Spring-")
            .append(SpringVersion.getVersion());
    sb.append("]Error happended: ").append(requestPath.getMethod());
    sb.append(" ").append(requestPath.getUri());
    sb.append("->");
    sb.append(this).append(" params=");
    sb.append(Arrays.toString(blitz.getInvocation().getMethodParameters()));
    InvocationTargetException servletException = new InvocationTargetException(exception, sb.toString());
    return servletException;
}

From source file:org.locationtech.udig.processingtoolbox.tools.BubbleChartDialog.java

@SuppressWarnings("nls")
@Override/*from   w w  w.  j ava  2s.  c  o  m*/
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    monitor.beginTask(String.format(Messages.Task_Executing, windowTitle), 100);
    try {
        if (plotTab == null) {
            monitor.subTask("Preparing bubble chart...");
            createGraphTab(inputTab.getParent());
        }

        monitor.worked(increment);

        String xField = cboXField.getText();
        String yField = cboYField.getText();
        String sizeField = cboSize.getText();
        SimpleFeatureCollection features = MapUtils.getFeatures(inputLayer);

        String fields = xField + "," + yField + "," + sizeField;

        if (chkStatistics.getSelection()) {
            if (outputTab == null) {
                createOutputTab(inputTab.getParent());
            }

            ProgressListener subMonitor = GeoToolsAdapters
                    .progress(SubMonitor.convert(monitor, Messages.Task_Internal, 20));
            DataStatisticsResult statistics = StatisticsFeaturesProcess.process(features, fields, subMonitor);
            HtmlWriter writer = new HtmlWriter(inputLayer.getName());
            writer.writeDataStatistics(statistics);
            browser.setText(writer.getHTML());
        }

        monitor.subTask("Updating bubble chart...");
        chartComposite.setLayer(inputLayer);
        updateChart(features, xField, yField, sizeField);
        plotTab.getParent().setSelection(plotTab);
        monitor.worked(increment);
    } catch (Exception e) {
        ToolboxPlugin.log(e.getMessage());
        throw new InvocationTargetException(e.getCause(), e.getMessage());
    } finally {
        ToolboxPlugin.log(String.format(Messages.Task_Completed, windowTitle));
        monitor.done();
    }
}

From source file:com.sinosoft.one.mvc.web.impl.thread.ActionEngine.java

private Exception createException(Mvc mvc, Throwable exception) {
    final RequestPath requestPath = mvc.getInvocation().getRequestPath();
    StringBuilder sb = new StringBuilder(1024);
    sb.append("[Mvc-").append(MvcVersion.getVersion()).append("@Spring-").append(SpringVersion.getVersion());
    sb.append("]Error happended: ").append(requestPath.getMethod());
    sb.append(" ").append(requestPath.getUri());
    sb.append("->");
    sb.append(this).append(" params=");
    sb.append(Arrays.toString(mvc.getInvocation().getMethodParameters()));
    InvocationTargetException servletException = new InvocationTargetException(exception, sb.toString());
    return servletException;
}

From source file:org.locationtech.udig.processingtoolbox.tools.MoranScatterPlotDialog.java

@SuppressWarnings("nls")
@Override/*from  w ww  . j a v  a  2s.c  o m*/
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    monitor.beginTask(String.format(Messages.Task_Executing, windowTitle), 100);
    try {
        if (plotTab == null) {
            monitor.subTask("Preparing scatter plot...");
            createGraphTab(inputTab.getParent());
        }
        if (outputTab == null) {
            createOutputTab(inputTab.getParent());
        }
        monitor.worked(increment);

        monitor.subTask("Analyzing global moran...");
        ProgressListener subMonitor = GeoToolsAdapters
                .progress(SubMonitor.convert(monitor, Messages.Task_Internal, increment));
        Process process = new GlobalMoransIProcess(null);
        Map<String, Object> result = process.execute(params, subMonitor);
        MoransIProcessResult moran = (MoransIProcessResult) result.get(GlobalMoransIProcessFactory.RESULT.key);

        // write html
        HtmlWriter writer = new HtmlWriter(inputLayer.getName());
        writer.writeMoransI(moran);
        browser.setText(writer.getHTML());

        monitor.subTask("Analyzing local moran...");
        subMonitor = GeoToolsAdapters.progress(SubMonitor.convert(monitor, Messages.Task_Internal, increment));

        LocalMoranIStatisticOperation opertor = new LocalMoranIStatisticOperation();
        opertor.setSpatialConceptType(spatialConcept);
        opertor.setDistanceType(distanceMethod);
        opertor.setStandardizationType(standardization);

        if (searchDistance != null && searchDistance > 0 && !Double.isNaN(searchDistance)) {
            spatialConcept = SpatialConcept.FixedDistance;
            opertor.setDistanceBand(searchDistance);
            opertor.setSpatialConceptType(spatialConcept);
        }

        SimpleFeatureCollection features = opertor.execute(
                (SimpleFeatureCollection) params.get(GlobalMoransIProcessFactory.inputFeatures.key),
                (String) params.get(GlobalMoransIProcessFactory.inputField.key));

        swMatrix = opertor.getSpatialWeightMatrix();
        zScore = opertor.getZScore();

        subMonitor.complete();
        monitor.subTask(Messages.Task_AddingLayer);

        SSStyleBuilder ssBuilder = new SSStyleBuilder(features.getSchema());
        ssBuilder.setOpacity(0.95f);
        Style style = ssBuilder.getLISAStyle("COType"); //$NON-NLS-1$

        outputLayer = MapUtils.addFeaturesToMap(map, features, "Local Moran's I", style);

        features = MapUtils.getFeatures(outputLayer);
        monitor.worked(increment);

        monitor.subTask("Updating scatter plot...");
        chartComposite.setLayer(outputLayer);
        updateChart(features, moran.getPropertyName(), moran.getObserved_Index());
        plotTab.getParent().setSelection(plotTab);
        monitor.worked(increment);
    } catch (Exception e) {
        ToolboxPlugin.log(e.getMessage());
        throw new InvocationTargetException(e.getCause(), e.getMessage());
    } finally {
        ToolboxPlugin.log(String.format(Messages.Task_Completed, windowTitle));
        monitor.done();
    }
}

From source file:javadz.beanutils.locale.LocaleBeanUtilsBean.java

/**
 * Invoke the setter method./*from w  w  w  .jav a 2s .c  o  m*/
 *
 * @param target The bean
 * @param propName The Simple name of target property
 * @param key The Mapped key value (if any)
 * @param index The indexed subscript value (if any)
 * @param newValue The value to be set
 *
 * @exception IllegalAccessException if the caller does not have
 *  access to the property accessor method
 * @exception InvocationTargetException if the property accessor method
 *  throws an exception
 */
protected void invokeSetter(Object target, String propName, String key, int index, Object newValue)
        throws IllegalAccessException, InvocationTargetException {

    try {
        if (index >= 0) {
            getPropertyUtils().setIndexedProperty(target, propName, index, newValue);
        } else if (key != null) {
            getPropertyUtils().setMappedProperty(target, propName, key, newValue);
        } else {
            getPropertyUtils().setProperty(target, propName, newValue);
        }
    } catch (NoSuchMethodException e) {
        throw new InvocationTargetException(e, "Cannot set " + propName);
    }
}

From source file:javadz.beanutils.BeanUtilsBean.java

/**
 * <p>Set the specified property value, performing type conversions as
 * required to conform to the type of the destination property.</p>
 *
 * <p>If the property is read only then the method returns 
 * without throwing an exception.</p>
 *
 * <p>If <code>null</code> is passed into a property expecting a primitive value,
 * then this will be converted as if it were a <code>null</code> string.</p>
 *
 * <p><strong>WARNING</strong> - The logic of this method is customized
 * to meet the needs of <code>populate()</code>, and is probably not what
 * you want for general property copying with type conversion.  For that
 * purpose, check out the <code>copyProperty()</code> method instead.</p>
 *
 * <p><strong>WARNING</strong> - PLEASE do not modify the behavior of this
 * method without consulting with the Struts developer community.  There
 * are some subtleties to its functionality that are not documented in the
 * Javadoc description above, yet are vital to the way that Struts utilizes
 * this method.</p>//w  w w . j  ava2  s  .  c  om
 *
 * @param bean Bean on which setting is to be performed
 * @param name Property name (can be nested/indexed/mapped/combo)
 * @param value Value to be set
 *
 * @exception IllegalAccessException if the caller does not have
 *  access to the property accessor method
 * @exception InvocationTargetException if the property accessor method
 *  throws an exception
 */
public void setProperty(Object bean, String name, Object value)
        throws IllegalAccessException, InvocationTargetException {

    // Trace logging (if enabled)
    if (log.isTraceEnabled()) {
        StringBuffer sb = new StringBuffer("  setProperty(");
        sb.append(bean);
        sb.append(", ");
        sb.append(name);
        sb.append(", ");
        if (value == null) {
            sb.append("<NULL>");
        } else if (value instanceof String) {
            sb.append((String) value);
        } else if (value instanceof String[]) {
            String[] values = (String[]) value;
            sb.append('[');
            for (int i = 0; i < values.length; i++) {
                if (i > 0) {
                    sb.append(',');
                }
                sb.append(values[i]);
            }
            sb.append(']');
        } else {
            sb.append(value.toString());
        }
        sb.append(')');
        log.trace(sb.toString());
    }

    // Resolve any nested expression to get the actual target bean
    Object target = bean;
    Resolver resolver = getPropertyUtils().getResolver();
    while (resolver.hasNested(name)) {
        try {
            target = getPropertyUtils().getProperty(target, resolver.next(name));
            name = resolver.remove(name);
        } catch (NoSuchMethodException e) {
            return; // Skip this property setter
        }
    }
    if (log.isTraceEnabled()) {
        log.trace("    Target bean = " + target);
        log.trace("    Target name = " + name);
    }

    // Declare local variables we will require
    String propName = resolver.getProperty(name); // Simple name of target property
    Class type = null; // Java type of target property
    int index = resolver.getIndex(name); // Indexed subscript value (if any)
    String key = resolver.getKey(name); // Mapped key value (if any)

    // Calculate the property type
    if (target instanceof DynaBean) {
        DynaClass dynaClass = ((DynaBean) target).getDynaClass();
        DynaProperty dynaProperty = dynaClass.getDynaProperty(propName);
        if (dynaProperty == null) {
            return; // Skip this property setter
        }
        type = dynaProperty.getType();
    } else if (target instanceof Map) {
        type = Object.class;
    } else if (target != null && target.getClass().isArray() && index >= 0) {
        type = Array.get(target, index).getClass();
    } else {
        PropertyDescriptor descriptor = null;
        try {
            descriptor = getPropertyUtils().getPropertyDescriptor(target, name);
            if (descriptor == null) {
                return; // Skip this property setter
            }
        } catch (NoSuchMethodException e) {
            return; // Skip this property setter
        }
        if (descriptor instanceof MappedPropertyDescriptor) {
            if (((MappedPropertyDescriptor) descriptor).getMappedWriteMethod() == null) {
                if (log.isDebugEnabled()) {
                    log.debug("Skipping read-only property");
                }
                return; // Read-only, skip this property setter
            }
            type = ((MappedPropertyDescriptor) descriptor).getMappedPropertyType();
        } else if (index >= 0 && descriptor instanceof IndexedPropertyDescriptor) {
            if (((IndexedPropertyDescriptor) descriptor).getIndexedWriteMethod() == null) {
                if (log.isDebugEnabled()) {
                    log.debug("Skipping read-only property");
                }
                return; // Read-only, skip this property setter
            }
            type = ((IndexedPropertyDescriptor) descriptor).getIndexedPropertyType();
        } else if (key != null) {
            if (descriptor.getReadMethod() == null) {
                if (log.isDebugEnabled()) {
                    log.debug("Skipping read-only property");
                }
                return; // Read-only, skip this property setter
            }
            type = (value == null) ? Object.class : value.getClass();
        } else {
            if (descriptor.getWriteMethod() == null) {
                if (log.isDebugEnabled()) {
                    log.debug("Skipping read-only property");
                }
                return; // Read-only, skip this property setter
            }
            type = descriptor.getPropertyType();
        }
    }

    // Convert the specified value to the required type
    Object newValue = null;
    if (type.isArray() && (index < 0)) { // Scalar value into array
        if (value == null) {
            String[] values = new String[1];
            values[0] = null;
            newValue = getConvertUtils().convert(values, type);
        } else if (value instanceof String) {
            newValue = getConvertUtils().convert(value, type);
        } else if (value instanceof String[]) {
            newValue = getConvertUtils().convert((String[]) value, type);
        } else {
            newValue = convert(value, type);
        }
    } else if (type.isArray()) { // Indexed value into array
        if (value instanceof String || value == null) {
            newValue = getConvertUtils().convert((String) value, type.getComponentType());
        } else if (value instanceof String[]) {
            newValue = getConvertUtils().convert(((String[]) value)[0], type.getComponentType());
        } else {
            newValue = convert(value, type.getComponentType());
        }
    } else { // Value into scalar
        if (value instanceof String) {
            newValue = getConvertUtils().convert((String) value, type);
        } else if (value instanceof String[]) {
            newValue = getConvertUtils().convert(((String[]) value)[0], type);
        } else {
            newValue = convert(value, type);
        }
    }

    // Invoke the setter method
    try {
        getPropertyUtils().setProperty(target, name, newValue);
    } catch (NoSuchMethodException e) {
        throw new InvocationTargetException(e, "Cannot set " + propName);
    }

}

From source file:be.ibridge.kettle.spoon.Spoon.java

public JobMeta ripDB(final ArrayList databases, final String jobname, final RepositoryDirectory repdir,
        final String directory, final DatabaseMeta sourceDbInfo, final DatabaseMeta targetDbInfo,
        final String[] tables) {
    ///* w  w w  .j  a va2  s.co  m*/
    // Create a new job...
    //
    final JobMeta jobMeta = new JobMeta(log);
    jobMeta.setDatabases(databases);
    jobMeta.setFilename(null);
    jobMeta.setName(jobname);

    if (rep != null) {
        jobMeta.setDirectory(repdir);
    } else {
        jobMeta.setFilename(Const.createFilename(directory, jobname, Const.STRING_JOB_DEFAULT_EXT));
    }

    refreshTree();
    refreshGraph();

    final Point location = new Point(50, 50);

    // The start entry...
    final JobEntryCopy start = JobMeta.createStartEntry();
    start.setLocation(new Point(location.x, location.y));
    start.setDrawn();
    jobMeta.addJobEntry(start);

    // final Thread parentThread = Thread.currentThread();

    // Create a dialog with a progress indicator!
    IRunnableWithProgress op = new IRunnableWithProgress() {
        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            // This is running in a new process: copy some KettleVariables info
            // LocalVariables.getInstance().createKettleVariables(Thread.currentThread().getName(),
            // parentThread.getName(), true);

            monitor.beginTask(Messages.getString("Spoon.RipDB.Monitor.BuildingNewJob"), tables.length); //$NON-NLS-1$
            monitor.worked(0);
            JobEntryCopy previous = start;

            // Loop over the table-names...
            for (int i = 0; i < tables.length && !monitor.isCanceled(); i++) {
                monitor.setTaskName(
                        Messages.getString("Spoon.RipDB.Monitor.ProcessingTable") + tables[i] + "]..."); //$NON-NLS-1$ //$NON-NLS-2$
                //
                // Create the new transformation...
                //
                String transname = Messages.getString("Spoon.RipDB.Monitor.Transname1") + sourceDbInfo + "].[" //$NON-NLS-1$//$NON-NLS-2$
                        + tables[i] + Messages.getString("Spoon.RipDB.Monitor.Transname2") + targetDbInfo + "]"; //$NON-NLS-1$ //$NON-NLS-2$

                TransMeta transMeta = new TransMeta((String) null, transname, null);

                if (repdir != null) {
                    transMeta.setDirectory(repdir);
                } else {
                    transMeta.setFilename(
                            Const.createFilename(directory, transname, Const.STRING_TRANS_DEFAULT_EXT));
                }

                //
                // Add a note
                //
                String note = Messages.getString("Spoon.RipDB.Monitor.Note1") + tables[i] //$NON-NLS-1$
                        + Messages.getString("Spoon.RipDB.Monitor.Note2") + sourceDbInfo + "]" + Const.CR; //$NON-NLS-1$ //$NON-NLS-2$
                note += Messages.getString("Spoon.RipDB.Monitor.Note3") + tables[i] //$NON-NLS-1$
                        + Messages.getString("Spoon.RipDB.Monitor.Note4") + targetDbInfo + "]"; //$NON-NLS-1$ //$NON-NLS-2$
                NotePadMeta ni = new NotePadMeta(note, 150, 10, -1, -1);
                transMeta.addNote(ni);

                //
                // Add the TableInputMeta step...
                // 
                String fromstepname = Messages.getString("Spoon.RipDB.Monitor.FromStep.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$
                TableInputMeta tii = new TableInputMeta();
                tii.setDatabaseMeta(sourceDbInfo);
                tii.setSQL("SELECT * FROM " + sourceDbInfo.quoteField(tables[i])); //$NON-NLS-1$

                String fromstepid = StepLoader.getInstance().getStepPluginID(tii);
                StepMeta fromstep = new StepMeta(fromstepid, fromstepname, tii);
                fromstep.setLocation(150, 100);
                fromstep.setDraw(true);
                fromstep.setDescription(Messages.getString("Spoon.RipDB.Monitor.FromStep.Description") //$NON-NLS-1$
                        + tables[i] + Messages.getString("Spoon.RipDB.Monitor.FromStep.Description2") //$NON-NLS-1$
                        + sourceDbInfo + "]"); //$NON-NLS-1$
                transMeta.addStep(fromstep);

                //
                // Add the TableOutputMeta step...
                //
                String tostepname = Messages.getString("Spoon.RipDB.Monitor.ToStep.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$
                TableOutputMeta toi = new TableOutputMeta();
                toi.setDatabaseMeta(targetDbInfo);
                toi.setTablename(tables[i]);
                toi.setCommitSize(100);
                toi.setTruncateTable(true);

                String tostepid = StepLoader.getInstance().getStepPluginID(toi);
                StepMeta tostep = new StepMeta(tostepid, tostepname, toi);
                tostep.setLocation(500, 100);
                tostep.setDraw(true);
                tostep.setDescription(Messages.getString("Spoon.RipDB.Monitor.ToStep.Description1") + tables[i] //$NON-NLS-1$
                        + Messages.getString("Spoon.RipDB.Monitor.ToStep.Description2") + targetDbInfo + "]"); //$NON-NLS-1$ //$NON-NLS-2$
                transMeta.addStep(tostep);

                //
                // Add a hop between the two steps...
                //
                TransHopMeta hi = new TransHopMeta(fromstep, tostep);
                transMeta.addTransHop(hi);

                //
                // Now we generate the SQL needed to run for this transformation.
                //
                // First set the limit to 1 to speed things up!
                String tmpSql = tii.getSQL();
                tii.setSQL(tii.getSQL() + sourceDbInfo.getLimitClause(1));
                String sql = ""; //$NON-NLS-1$
                try {
                    sql = transMeta.getSQLStatementsString();
                } catch (KettleStepException kse) {
                    throw new InvocationTargetException(kse,
                            Messages.getString("Spoon.RipDB.Exception.ErrorGettingSQLFromTransformation") //$NON-NLS-1$
                                    + transMeta + "] : " + kse.getMessage()); //$NON-NLS-1$
                }
                // remove the limit
                tii.setSQL(tmpSql);

                //
                // Now, save the transformation...
                //
                boolean ok;
                if (rep != null) {
                    ok = saveTransRepository(transMeta);
                } else {
                    ok = saveTransFile(transMeta);
                }
                if (!ok) {
                    throw new InvocationTargetException(
                            new Exception(Messages
                                    .getString("Spoon.RipDB.Exception.UnableToSaveTransformationToRepository")), //$NON-NLS-1$
                            Messages.getString("Spoon.RipDB.Exception.UnableToSaveTransformationToRepository"));
                }

                // We can now continue with the population of the job...
                // //////////////////////////////////////////////////////////////////////

                location.x = 250;
                if (i > 0)
                    location.y += 100;

                //
                // We can continue defining the job.
                //
                // First the SQL, but only if needed!
                // If the table exists & has the correct format, nothing is done
                //
                if (!Const.isEmpty(sql)) {
                    String jesqlname = Messages.getString("Spoon.RipDB.JobEntrySQL.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$
                    JobEntrySQL jesql = new JobEntrySQL(jesqlname);
                    jesql.setDatabase(targetDbInfo);
                    jesql.setSQL(sql);
                    jesql.setDescription(Messages.getString("Spoon.RipDB.JobEntrySQL.Description") //$NON-NLS-1$
                            + targetDbInfo + "].[" + tables[i] + "]"); //$NON-NLS-1$ //$NON-NLS-2$

                    JobEntryCopy jecsql = new JobEntryCopy();
                    jecsql.setEntry(jesql);
                    jecsql.setLocation(new Point(location.x, location.y));
                    jecsql.setDrawn();
                    jobMeta.addJobEntry(jecsql);

                    // Add the hop too...
                    JobHopMeta jhi = new JobHopMeta(previous, jecsql);
                    jobMeta.addJobHop(jhi);
                    previous = jecsql;
                }

                //
                // Add the jobentry for the transformation too...
                //
                String jetransname = Messages.getString("Spoon.RipDB.JobEntryTrans.Name") + tables[i] + "]"; //$NON-NLS-1$ //$NON-NLS-2$
                JobEntryTrans jetrans = new JobEntryTrans(jetransname);
                jetrans.setTransname(transMeta.getName());
                if (rep != null) {
                    jetrans.setDirectory(transMeta.getDirectory());
                } else {
                    jetrans.setFileName(
                            Const.createFilename("${" + Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY + "}",
                                    transMeta.getName(), Const.STRING_TRANS_DEFAULT_EXT));
                }

                JobEntryCopy jectrans = new JobEntryCopy(log, jetrans);
                jectrans.setDescription(Messages.getString("Spoon.RipDB.JobEntryTrans.Description1") + Const.CR //$NON-NLS-1$
                        + Messages.getString("Spoon.RipDB.JobEntryTrans.Description2") + sourceDbInfo + "].[" //$NON-NLS-1$//$NON-NLS-2$
                        + tables[i] + "]" + Const.CR //$NON-NLS-1$
                        + Messages.getString("Spoon.RipDB.JobEntryTrans.Description3") + targetDbInfo + "].[" //$NON-NLS-1$//$NON-NLS-2$
                        + tables[i] + "]"); //$NON-NLS-1$
                jectrans.setDrawn();
                location.x += 400;
                jectrans.setLocation(new Point(location.x, location.y));
                jobMeta.addJobEntry(jectrans);

                // Add a hop between the last 2 job entries.
                JobHopMeta jhi2 = new JobHopMeta(previous, jectrans);
                jobMeta.addJobHop(jhi2);
                previous = jectrans;

                monitor.worked(1);
            }

            monitor.worked(100);
            monitor.done();
        }
    };

    try {
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
        pmd.run(false, true, op);
    } catch (InvocationTargetException e) {
        new ErrorDialog(shell, Messages.getString("Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Title"), //$NON-NLS-1$
                Messages.getString("Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Message"), e); //$NON-NLS-1$
        return null;
    } catch (InterruptedException e) {
        new ErrorDialog(shell, Messages.getString("Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Title"), //$NON-NLS-1$
                Messages.getString("Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Message"), e); //$NON-NLS-1$
        return null;
    } finally {
        refreshGraph();
        refreshTree();
    }

    return jobMeta;
}

From source file:net.sourceforge.tagsea.instrumentation.network.RegisterWithProgress.java

public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    GetMethod getUidMethod = new GetMethod(NetworkUtilities.REGISTER_SCRIPT);
    getUidMethod.setQueryString(new NameValuePair[] { new NameValuePair("firstName", firstName),
            new NameValuePair("lastName", lastName), new NameValuePair("email", email),
            new NameValuePair("jobFunction", job), new NameValuePair("company", company),
            new NameValuePair("companySize", companySize), new NameValuePair("companyBusiness", fieldOfWork),
            new NameValuePair("anonymous", Boolean.toString(anonymous)) });
    monitor.beginTask("Get User Id", 1);
    HttpClient client = new HttpClient();

    try {//  ww  w .j ava  2s .c o m
        status = client.executeMethod(getUidMethod);

        response = NetworkUtilities.readInputAsString(getUidMethod.getResponseBodyAsStream());
    } catch (HttpException e) {
        //there was a problem with the file upload so throw up
        // an error
        // dialog to inform the user and log the exception
        status = 500;
        response = e.getMessage();
        throw new InvocationTargetException(e, response);
    } catch (IOException e) {
        //there was a problem with the file upload so throw up
        // an error
        // dialog to inform the user and log the exception
        status = 500;
        response = e.getMessage();
        throw new InvocationTargetException(e, response);
    } finally {
        //             release the connection to the server
        getUidMethod.releaseConnection();
    }

    if (status != 200) {
    } else {
        String uidString = response.substring(response.indexOf(":") + 1).trim();
        userID = Integer.parseInt(uidString);
        InstrumentationPreferences.setAnonymous(anonymous);
        InstrumentationPreferences.setAskForRegistration(false);
        InstrumentationPreferences.setCompany(company);
        InstrumentationPreferences.setCompanySize(companySize);
        InstrumentationPreferences.setEmail(email);
        InstrumentationPreferences.setFieldOfWork(fieldOfWork);
        InstrumentationPreferences.setFirstName(firstName);
        InstrumentationPreferences.setJob(job);
        InstrumentationPreferences.setLastName(lastName);
        InstrumentationPreferences.setUID(userID);
        InstrumentationPreferences.setMonitoringEnabled(true);
        InstrumentationPreferences.setUploadInterval(1);
    }

    monitor.worked(1);
    monitor.done();
}