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);
}
}
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;
}
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;
}
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);
}
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);
}
}
Aggregations