Search in sources :

Example 6 with ProcessorException

use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.

the class ShadowProcess method runWithErrorOutputAsException.

/**
     * 
     * DOC xye Comment method "runWithErrorOutputAsException".
     * 
     * @param outputErrorAsException
     * @return
     * @throws ProcessorException
     */
public CsvArray runWithErrorOutputAsException(final boolean outputErrorAsException) throws ProcessorException {
    IProcess talendProcess = buildProcess();
    IProcessor processor = ProcessorUtilities.getProcessor(talendProcess, null);
    processor.setProxyParameters(getProxyParameters());
    File previousFile = outPath.toFile();
    if (previousFile.exists()) {
        previousFile.delete();
    }
    IContext context = talendProcess.getContextManager().getDefaultContext();
    processor.setContext(context);
    process = processor.run(IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, null);
    String error = ProcessStreamTrashReader.readErrorStream(process);
    if (error != null) {
        log.warn(error, new ProcessorException(error));
    }
    if (!outPath.toFile().exists()) {
        if (outputErrorAsException && error != null) {
            throw new ProcessorException(error);
        } else {
            //$NON-NLS-1$
            throw new ProcessorException(Messages.getString("ShadowProcess.notGeneratedOutputException"));
        }
    }
    try {
        CsvArray array = new CsvArray();
        array = array.createFrom(outPath.toFile(), currentProcessEncoding);
        return array;
    } catch (IOException ioe) {
        throw new ProcessorException(ioe);
    }
}
Also used : IContext(org.talend.core.model.process.IContext) ProcessorException(org.talend.designer.runprocess.ProcessorException) CsvArray(org.talend.core.utils.CsvArray) IProcessor(org.talend.designer.runprocess.IProcessor) IOException(java.io.IOException) IProcess(org.talend.core.model.process.IProcess) File(java.io.File)

Example 7 with ProcessorException

use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.

the class Processor method debug.

/**
     * Debug the process using a given context.
     * 
     * @param context Context to be used.
     * @return The configuration to be launched in debug mode.
     * @throws ProcessorException Process failed.
     * @throws CoreException
     * @throws ProcessorException
     */
@Override
public ILaunchConfiguration debug() throws ProcessorException {
    if (context == null) {
        //$NON-NLS-1$
        throw new IllegalArgumentException("Context is empty, context must be set before call");
    }
    ILaunchConfiguration config = null;
    try {
        setProcessorStates(STATES_EDIT);
        config = (ILaunchConfiguration) saveLaunchConfiguration();
    } catch (CoreException ce) {
        throw new ProcessorException(ce);
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException)

Example 8 with ProcessorException

use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.

the class Processor method getDebugConfiguration.

/**
     * 
     * DOC xzhang Comment method "getDebugConfiguration". For the bug 5430
     * 
     * @param statOption
     * @param traceOption
     * @param codeOptions
     * @return
     * @throws ProcessorException
     */
public ILaunchConfiguration getDebugConfiguration(int statOption, int traceOption, String... codeOptions) throws ProcessorException {
    if (context == null) {
        //$NON-NLS-1$
        throw new IllegalArgumentException("Context is empty, context must be set before call");
    }
    //$NON-NLS-1$
    StringBuilder parameterStr = new StringBuilder(" ");
    if (codeOptions != null) {
        for (String string : codeOptions) {
            if (string != null) {
                //$NON-NLS-1$
                parameterStr.append(string).append(" ");
            }
        }
    }
    if (statOption != -1) {
        //$NON-NLS-1$
        parameterStr = parameterStr.append(STAT_PORT_ARG + statOption).append(" ");
    }
    if (traceOption != -1) {
        //$NON-NLS-1$
        parameterStr = parameterStr.append(TRACE_PORT_ARG + traceOption).append(" ");
    }
    ILaunchConfiguration config = null;
    try {
        setProcessorStates(STATES_EDIT);
        config = (ILaunchConfiguration) saveLaunchConfigurationWithParam(parameterStr.toString());
    } catch (CoreException ce) {
        throw new ProcessorException(ce);
    }
    return config;
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException)

Example 9 with ProcessorException

use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method createFileEditorInput.

protected FileEditorInput createFileEditorInput() {
    IPath codePath = processor.getCodePath();
    if (codePath == null || codePath.isEmpty()) {
        // (should not happen)
        try {
            processor.initPath();
        } catch (ProcessorException e) {
            MessageBoxExceptionHandler.process(e);
        }
        codePath = processor.getCodePath();
    }
    IFile codeFile = processor.getCodeProject().getFile(codePath);
    if (!codeFile.exists()) {
        // Create empty one
        try {
            //$NON-NLS-1$
            codeFile.create(new ByteArrayInputStream("".getBytes()), true, null);
        } catch (CoreException e) {
        // Do nothing.
        }
    }
    return new FileEditorInput(codeFile);
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) CoreException(org.eclipse.core.runtime.CoreException) ByteArrayInputStream(java.io.ByteArrayInputStream) FileEditorInput(org.eclipse.ui.part.FileEditorInput)

Example 10 with ProcessorException

use of org.talend.designer.runprocess.ProcessorException in project tdi-studio-se by Talend.

the class AbstractMultiPageTalendEditor method codeSync.

private void codeSync() {
    IProcess2 process = getProcess();
    if (!(process.getProperty().getItem() instanceof ProcessItem)) {
        // shouldn't work for joblet
        return;
    }
    if (jobletEditor == getEditor(oldPageIndex)) {
        // added for routines code generated switch editor 0 to 3.
        ProcessItem processItem = (ProcessItem) process.getProperty().getItem();
        covertJobscriptOnPageChange();
        ParametersType parameters = processItem.getProcess().getParameters();
        if (parameters != null && parameters.getRoutinesParameter() != null && parameters.getRoutinesParameter().size() == 0) {
            try {
                List<RoutinesParameterType> dependenciesInPreference = RoutinesUtil.createDependenciesInPreference();
                parameters.getRoutinesParameter().addAll(dependenciesInPreference);
            } catch (PersistenceException e) {
                ExceptionHandler.process(e);
            }
        }
    }
    // if some code has been generated already, for the editor we should need only the main job, not the childs.
    try {
        boolean lastGeneratedWithStats = ProcessorUtilities.getLastGeneratedWithStats(process.getId());
        boolean lastGeneratedWithTrace = ProcessorUtilities.getLastGeneratedWithTrace(process.getId());
        if (processor.isCodeGenerated()) {
            ProcessorUtilities.generateCode(process, process.getContextManager().getDefaultContext(), lastGeneratedWithStats, lastGeneratedWithTrace, true, ProcessorUtilities.GENERATE_MAIN_ONLY);
        } else {
            ProcessorUtilities.generateCode(process, process.getContextManager().getDefaultContext(), lastGeneratedWithStats, lastGeneratedWithTrace, true, ProcessorUtilities.GENERATE_WITH_FIRST_CHILD);
        }
    } catch (ProcessorException e) {
        ExceptionHandler.process(e);
    }
}
Also used : ProcessorException(org.talend.designer.runprocess.ProcessorException) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) RoutinesParameterType(org.talend.designer.core.model.utils.emf.talendfile.RoutinesParameterType) IProcess2(org.talend.core.model.process.IProcess2) PersistenceException(org.talend.commons.exception.PersistenceException) ParametersType(org.talend.designer.core.model.utils.emf.talendfile.ParametersType)

Aggregations

ProcessorException (org.talend.designer.runprocess.ProcessorException)40 IOException (java.io.IOException)15 File (java.io.File)11 IProcessor (org.talend.designer.runprocess.IProcessor)11 CoreException (org.eclipse.core.runtime.CoreException)10 ProcessItem (org.talend.core.model.properties.ProcessItem)10 CsvArray (org.talend.core.utils.CsvArray)10 IContext (org.talend.core.model.process.IContext)9 Status (org.eclipse.core.runtime.Status)8 IProcess (org.talend.core.model.process.IProcess)8 ExportFileResource (org.talend.repository.documentation.ExportFileResource)7 IFile (org.eclipse.core.resources.IFile)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)5 PersistenceException (org.talend.commons.exception.PersistenceException)5 ExportChoice (org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ArrayList (java.util.ArrayList)4 IStatus (org.eclipse.core.runtime.IStatus)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)4