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