private void getProcess() { initPerlArray(); this.component.setNumber(number); if (component.getProcess() instanceof IProcess2) { // get current job context manager. jobContextManager = component.getProcess().getContextManager(); } Property property = PropertiesFactory.eINSTANCE.createProperty(); property.setLabel(PREVIEW + "_RowGenerator2"); // $NON-NLS-1$ property.setId(PREVIEW + "_RowGenerator2"); // $NON-NLS-1$ proc = new RowGenProcess(property, component); }
/** 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; } }