Search in sources :

Example 1 with CsvArray

use of org.talend.core.utils.CsvArray in project tdi-studio-se by Talend.

the class JSONShadowProcess 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 (outputErrorAsException) {
        if (error != null) {
            throw new ProcessorException(error);
        }
    } else {
        if (error != null) {
            log.warn(error, new ProcessorException(error));
        }
    }
    if (!outPath.toFile().exists()) {
        //$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 2 with CsvArray

use of org.talend.core.utils.CsvArray in project tdi-studio-se by Talend.

the class JSONShadowFilePreview method preview.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.preview.IPreview#preview(org.talend.repository.preview.IProcessDescription,
     * java.lang.String, boolean)
     */
public CsvArray preview(IProcessDescription description, String type, boolean outputErrorAsException) throws CoreException {
    CsvArray res = null;
    EJSONShadowProcessType typeShadow = EJSONShadowProcessType.valueOf(type);
    shadowProcess = new JSONShadowProcess<IProcessDescription>(description, typeShadow);
    try {
        res = shadowProcess.runWithErrorOutputAsException(outputErrorAsException);
    } catch (ProcessorException e) {
        Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
        RunProcessPlugin.getDefault().getLog().log(status);
        throw new CoreException(status);
    }
    return res;
}
Also used : EJSONShadowProcessType(org.talend.repository.json.ui.shadow.JSONShadowProcess.EJSONShadowProcessType) Status(org.eclipse.core.runtime.Status) CsvArray(org.talend.core.utils.CsvArray) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException) IProcessDescription(org.talend.core.repository.model.preview.IProcessDescription)

Example 3 with CsvArray

use of org.talend.core.utils.CsvArray in project tdi-studio-se by Talend.

the class JSONShadowFilePreview method preview.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.preview.filedelimited.IFileDelimitedPreview#
     * preview(org.talend.repository.preview.filedelimited.ProcessDescription)
     */
public CsvArray preview(IProcessDescription description, String type) throws CoreException {
    CsvArray res = null;
    EJSONShadowProcessType typeShadow = EJSONShadowProcessType.valueOf(type);
    shadowProcess = new JSONShadowProcess<IProcessDescription>(description, typeShadow);
    try {
        res = shadowProcess.run();
    } catch (ProcessorException e) {
        Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
        RunProcessPlugin.getDefault().getLog().log(status);
        throw new CoreException(status);
    }
    return res;
}
Also used : EJSONShadowProcessType(org.talend.repository.json.ui.shadow.JSONShadowProcess.EJSONShadowProcessType) Status(org.eclipse.core.runtime.Status) CsvArray(org.talend.core.utils.CsvArray) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException) IProcessDescription(org.talend.core.repository.model.preview.IProcessDescription)

Example 4 with CsvArray

use of org.talend.core.utils.CsvArray in project tdi-studio-se by Talend.

the class ShadowFilePreview method preview.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.preview.filedelimited.IFileDelimitedPreview#
     * preview(org.talend.repository.preview.filedelimited.ProcessDescription)
     */
public CsvArray preview(IProcessDescription description, String type) throws CoreException {
    CsvArray res = null;
    EShadowProcessType typeShadow = EShadowProcessType.valueOf(type);
    shadowProcess = new ShadowProcess<IProcessDescription>(description, typeShadow);
    try {
        res = shadowProcess.run();
    } catch (ProcessorException e) {
        Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
        RunProcessPlugin.getDefault().getLog().log(status);
        throw new CoreException(status);
    }
    return res;
}
Also used : Status(org.eclipse.core.runtime.Status) CsvArray(org.talend.core.utils.CsvArray) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException) IProcessDescription(org.talend.core.repository.model.preview.IProcessDescription) EShadowProcessType(org.talend.designer.runprocess.shadow.ShadowProcess.EShadowProcessType)

Example 5 with CsvArray

use of org.talend.core.utils.CsvArray in project tdi-studio-se by Talend.

the class ShadowFilePreview method preview.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.preview.IPreview#preview(org.talend.repository.preview.IProcessDescription,
     * java.lang.String, boolean)
     */
public CsvArray preview(IProcessDescription description, String type, boolean outputErrorAsException) throws CoreException {
    CsvArray res = null;
    EShadowProcessType typeShadow = EShadowProcessType.valueOf(type);
    shadowProcess = new ShadowProcess<IProcessDescription>(description, typeShadow);
    try {
        res = shadowProcess.runWithErrorOutputAsException(outputErrorAsException);
    } catch (ProcessorException e) {
        Status status = new Status(Status.ERROR, RunProcessPlugin.PLUGIN_ID, Status.OK, e.getMessage(), e);
        RunProcessPlugin.getDefault().getLog().log(status);
        throw new CoreException(status);
    }
    return res;
}
Also used : Status(org.eclipse.core.runtime.Status) CsvArray(org.talend.core.utils.CsvArray) ProcessorException(org.talend.designer.runprocess.ProcessorException) CoreException(org.eclipse.core.runtime.CoreException) IProcessDescription(org.talend.core.repository.model.preview.IProcessDescription) EShadowProcessType(org.talend.designer.runprocess.shadow.ShadowProcess.EShadowProcessType)

Aggregations

CsvArray (org.talend.core.utils.CsvArray)19 ProcessorException (org.talend.designer.runprocess.ProcessorException)10 File (java.io.File)7 CoreException (org.eclipse.core.runtime.CoreException)7 IOException (java.io.IOException)6 IProcessor (org.talend.designer.runprocess.IProcessor)5 Status (org.eclipse.core.runtime.Status)4 IContext (org.talend.core.model.process.IContext)4 IProcess (org.talend.core.model.process.IProcess)4 IProcessDescription (org.talend.core.repository.model.preview.IProcessDescription)4 ArrayList (java.util.ArrayList)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IPreview (org.talend.core.repository.model.preview.IPreview)2 EShadowProcessType (org.talend.designer.runprocess.shadow.ShadowProcess.EShadowProcessType)2 EJSONShadowProcessType (org.talend.repository.json.ui.shadow.JSONShadowProcess.EJSONShadowProcessType)2 JSONFileConnection (org.talend.repository.model.json.JSONFileConnection)2 BufferedReader (java.io.BufferedReader)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileReader (java.io.FileReader)1