Search in sources :

Example 6 with IProcessor

use of org.talend.designer.runprocess.IProcessor 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 IProcessor

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

the class StandardJobOSGiBundleBuildProvider method createPomCreator.

@Override
public IMavenPomCreator createPomCreator(Map<String, Object> parameters) {
    if (parameters == null || parameters.isEmpty()) {
        return null;
    }
    final Object processor = parameters.get(PROCESSOR);
    if (processor == null || !(processor instanceof IProcessor)) {
        return null;
    }
    final Object pomFile = parameters.get(FILE_POM);
    if (pomFile == null || !(pomFile instanceof IFile)) {
        return null;
    }
    final Object item = parameters.get(ITEM);
    if (item == null || !(item instanceof Item)) {
        return null;
    }
    Object argumentsMap = parameters.get(ARGUMENTS_MAP);
    if (argumentsMap == null) {
        argumentsMap = Collections.emptyMap();
    }
    if (!(argumentsMap instanceof Map)) {
        return null;
    }
    Object overwrite = parameters.get(OVERWRITE_POM);
    if (overwrite == null) {
        overwrite = Boolean.FALSE;
    }
    CreateMavenStandardJobOSGiPom osgiPomCreator = new CreateMavenStandardJobOSGiPom((IProcessor) processor, (IFile) pomFile);
    osgiPomCreator.setArgumentsMap((Map<String, Object>) argumentsMap);
    osgiPomCreator.setOverwrite(Boolean.parseBoolean(overwrite.toString()));
    final Property itemProperty = ((Item) item).getProperty();
    IPath itemLocationPath = ItemResourceUtil.getItemLocationPath(itemProperty);
    IFolder objectTypeFolder = ItemResourceUtil.getObjectTypeFolder(itemProperty);
    if (itemLocationPath != null && objectTypeFolder != null) {
        IPath itemRelativePath = itemLocationPath.removeLastSegments(1).makeRelativeTo(objectTypeFolder.getLocation());
        osgiPomCreator.setObjectTypeFolder(objectTypeFolder);
        osgiPomCreator.setItemRelativePath(itemRelativePath);
    }
    return osgiPomCreator;
}
Also used : CreateMavenStandardJobOSGiPom(org.talend.designer.maven.tools.creator.CreateMavenStandardJobOSGiPom) Item(org.talend.core.model.properties.Item) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) IProcessor(org.talend.designer.runprocess.IProcessor) Map(java.util.Map) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 8 with IProcessor

use of org.talend.designer.runprocess.IProcessor 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 9 with IProcessor

use of org.talend.designer.runprocess.IProcessor in project tesb-studio-se by Talend.

the class BuildDataServiceProvider method createPomCreator.

@Override
public IMavenPomCreator createPomCreator(Map<String, Object> parameters) {
    if (parameters == null || parameters.isEmpty()) {
        return null;
    }
    final Object processor = parameters.get(PROCESSOR);
    if (processor == null || !(processor instanceof IProcessor)) {
        return null;
    }
    final Object pomFile = parameters.get(FILE_POM);
    if (pomFile == null || !(pomFile instanceof IFile)) {
        return null;
    }
    final Object item = parameters.get(ITEM);
    if (item == null || !(item instanceof Item)) {
        return null;
    }
    Object argumentsMap = parameters.get(ARGUMENTS_MAP);
    if (argumentsMap == null) {
        argumentsMap = Collections.emptyMap();
    }
    if (!(argumentsMap instanceof Map)) {
        return null;
    }
    Object overwrite = parameters.get(OVERWRITE_POM);
    if (overwrite == null) {
        overwrite = Boolean.FALSE;
    }
    Object assemblyFile = parameters.get(FILE_ASSEMBLY);
    CreateMavenDataServicePom creator = new CreateMavenDataServicePom((IProcessor) processor, (IFile) pomFile);
    creator.setArgumentsMap((Map<String, Object>) argumentsMap);
    creator.setOverwrite(Boolean.parseBoolean(overwrite.toString()));
    creator.setAssemblyFile((IFile) assemblyFile);
    final Property itemProperty = ((Item) item).getProperty();
    IPath itemLocationPath = ItemResourceUtil.getItemLocationPath(itemProperty);
    IFolder objectTypeFolder = ItemResourceUtil.getObjectTypeFolder(itemProperty);
    if (itemLocationPath != null && objectTypeFolder != null) {
        IPath itemRelativePath = itemLocationPath.removeLastSegments(1).makeRelativeTo(objectTypeFolder.getLocation());
        creator.setObjectTypeFolder(objectTypeFolder);
        creator.setItemRelativePath(itemRelativePath);
    }
    return creator;
}
Also used : ServiceItem(org.talend.repository.services.model.services.ServiceItem) Item(org.talend.core.model.properties.Item) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) CreateMavenDataServicePom(org.talend.repository.services.maven.CreateMavenDataServicePom) IProcessor(org.talend.designer.runprocess.IProcessor) Map(java.util.Map) Property(org.talend.core.model.properties.Property) IFolder(org.eclipse.core.resources.IFolder)

Example 10 with IProcessor

use of org.talend.designer.runprocess.IProcessor in project tesb-studio-se by Talend.

the class CreateRouteAsOSGIPomTest method getProcessor.

private IProcessor getProcessor(String name) {
    Property property = PropertiesFactory.eINSTANCE.createProperty();
    property.setId(name.toLowerCase() + "_Item_ID");
    property.setLabel(name);
    property.setVersion(TEST_ITEM_VERSION);
    ProcessItem item = createProcessItem();
    item.setProperty(property);
    property.setItem(item);
    ProcessType processType = TalendFileFactory.eINSTANCE.createProcessType();
    item.setProcess(processType);
    JobContextManager contextManager = new JobContextManager();
    IContext context = new JobContext("Test");
    contextManager.getListContext().add(context);
    IProcessor processor = createProcessor(property);
    processor.setContext(context);
    return processor;
}
Also used : ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) IContext(org.talend.core.model.process.IContext) ProcessItem(org.talend.core.model.properties.ProcessItem) JobContextManager(org.talend.core.model.context.JobContextManager) JobContext(org.talend.core.model.context.JobContext) IProcessor(org.talend.designer.runprocess.IProcessor) Property(org.talend.core.model.properties.Property)

Aggregations

IProcessor (org.talend.designer.runprocess.IProcessor)25 ProcessorException (org.talend.designer.runprocess.ProcessorException)11 IProcess (org.talend.core.model.process.IProcess)10 IOException (java.io.IOException)9 IFile (org.eclipse.core.resources.IFile)8 IContext (org.talend.core.model.process.IContext)8 Item (org.talend.core.model.properties.Item)7 Property (org.talend.core.model.properties.Property)7 File (java.io.File)6 IPath (org.eclipse.core.runtime.IPath)6 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)6 Map (java.util.Map)5 IFolder (org.eclipse.core.resources.IFolder)5 ProcessItem (org.talend.core.model.properties.ProcessItem)5 CsvArray (org.talend.core.utils.CsvArray)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)3 HashMap (java.util.HashMap)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IStatus (org.eclipse.core.runtime.IStatus)3 Status (org.eclipse.core.runtime.Status)3