use of org.talend.designer.runprocess.IProcessor in project tdi-studio-se by Talend.
the class RowGenProcessMain method runPreviewCode.
/**
* qzhang Comment method "runPreviewCode".
*/
public Process runPreviewCode() {
getProcess();
if (jobContextManager == null) {
// proc.getContextManager().setListContext(component.getProcess().getContextManager().getListContext());
proc.getContextManager().setDefaultContext(component.getProcess().getContextManager().getDefaultContext());
} else {
// proc.getContextManager().setListContext(jobContextManager.getListContext());
proc.getContextManager().setDefaultContext(jobContextManager.getDefaultContext());
}
// IContext context2 = new org.talend.core.model.context.JobContext(PREVIEW);
// if (UIManager.isJavaProject()) {
// List<IContextParameter> params = new ArrayList<IContextParameter>();
// JobContextParameter contextParameter = new JobContextParameter();
// contextParameter.setContext(context2);
// contextParameter.setName(PREVIEW);
// contextParameter.setValue(PREVIEW);
// contextParameter.setType("String");
// params.add(contextParameter);
// context2.setContextParameterList(params);
// }
// generate context files.
IProcessor contextProcessor = ProcessorUtilities.getProcessor(proc, null);
contextProcessor.setContext(proc.getContextManager().getDefaultContext());
try {
contextProcessor.cleanBeforeGenerate(TalendProcessOptionConstants.CLEAN_CONTEXTS);
contextProcessor.generateContextCode();
} catch (ProcessorException pe) {
ExceptionHandler.process(pe);
}
IProcessor processor = ProcessorUtilities.getProcessor(proc, null, proc.getContextManager().getDefaultContext());
try {
return processor.run(IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, null);
} catch (Exception e) {
ExceptionHandler.process(e);
return null;
}
}
use of org.talend.designer.runprocess.IProcessor in project tesb-studio-se by Talend.
the class CreateMavenBundlePom method getProcessor.
public static IProcessor getProcessor(JobInfo jobInfo) {
if (jobInfo.getProcessor() != null) {
return jobInfo.getProcessor();
}
IProcess process = null;
ProcessItem processItem;
processItem = jobInfo.getProcessItem();
if (processItem == null && jobInfo.getJobVersion() == null) {
processItem = ItemCacheManager.getProcessItem(jobInfo.getJobId());
}
if (processItem == null && jobInfo.getJobVersion() != null) {
processItem = ItemCacheManager.getProcessItem(jobInfo.getJobId(), jobInfo.getJobVersion());
}
if (processItem == null && jobInfo.getProcess() == null) {
return null;
}
if (jobInfo.getProcess() == null) {
if (processItem != null) {
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
process = service.getProcessFromProcessItem(processItem);
if (process instanceof IProcess2) {
((IProcess2) process).setProperty(processItem.getProperty());
}
}
if (process == null) {
return null;
}
} else {
process = jobInfo.getProcess();
}
Property curProperty = processItem.getProperty();
if (processItem.getProperty() == null && process instanceof IProcess2) {
curProperty = ((IProcess2) process).getProperty();
}
IRunProcessService service = CorePlugin.getDefault().getRunProcessService();
IProcessor processor = service.createCodeProcessor(process, curProperty, ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage(), true);
jobInfo.setProcessor(processor);
return processor;
}
use of org.talend.designer.runprocess.IProcessor in project tesb-studio-se by Talend.
the class RouteOSGiBundleBuildProvider method createPomCreator.
/*
* (non-Javadoc)
*
* @see org.talend.core.runtime.repository.build.AbstractBuildProvider#createPomCreator(java.util.Map)
*/
@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;
}
final Object assemblyFile = parameters.get(FILE_ASSEMBLY);
if (!ProcessorUtilities.isGeneratePomOnly() && (assemblyFile == null || !(assemblyFile instanceof IFile))) {
return null;
}
final Object winClassPath = parameters.get(CP_WIN);
if (winClassPath == null) {
return null;
}
final Object linuxClassPath = parameters.get(CP_LINUX);
if (linuxClassPath == null) {
return null;
}
CreateMavenBundlePom osgiPomCreator = new CreateMavenBundlePom((IProcessor) processor, (IFile) pomFile);
osgiPomCreator.setUnixClasspath(linuxClassPath.toString());
osgiPomCreator.setWindowsClasspath(winClassPath.toString());
osgiPomCreator.setAssemblyFile((IFile) assemblyFile);
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 tesb-studio-se by Talend.
the class RouteletOSGiBundleBuildProvider 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;
}
final Object assemblyFile = parameters.get(FILE_ASSEMBLY);
if (!ProcessorUtilities.isGeneratePomOnly() && (assemblyFile == null || !(assemblyFile instanceof IFile))) {
return null;
}
final Object winClassPath = parameters.get(CP_WIN);
if (winClassPath == null) {
return null;
}
final Object linuxClassPath = parameters.get(CP_LINUX);
if (linuxClassPath == null) {
return null;
}
CreateRouteletMavenBundlePom osgiPomCreator = new CreateRouteletMavenBundlePom((IProcessor) processor, (IFile) pomFile);
osgiPomCreator.setUnixClasspath(linuxClassPath.toString());
osgiPomCreator.setWindowsClasspath(winClassPath.toString());
osgiPomCreator.setAssemblyFile((IFile) assemblyFile);
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 tesb-studio-se by Talend.
the class CreateRouteAsOSGIPomTest method initializeAndCompare.
private void initializeAndCompare(String testCaseName) throws PersistenceException, IOException, CoreException {
IProcessor processor = getProcessor(testCaseName);
Project project = ProjectManager.getInstance().getCurrentProject();
IProject fsProject = ResourceUtils.getProject(project);
IPath path = getPomPathForTest(testCaseName);
IMavenPomCreator pomCreator = createPomCreator(processor, fsProject.getFile(path));
try {
pomCreator.create(new NullProgressMonitor());
} catch (Exception e) {
e.printStackTrace();
ExceptionHandler.process(e);
fail(e.getMessage());
}
compareGeneratedFilesWithReference(processor.getCodeProject(), testCaseName.toLowerCase() + UNDERSCORE + TEST_ITEM_VERSION);
}
Aggregations