use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class HTMLDocGenerator method generateSourceCodeInfo.
/**
* DOC qwei Comment method "generateSourceCodeInfo".
*/
private void generateSourceCodeInfo(ProcessItem item, Element element) {
if (CorePlugin.getDefault().getPreferenceStore().getBoolean(ITalendCorePrefConstants.DOC_GENERATESOURCECODE)) {
IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
IProcess process = service.getProcessFromProcessItem(item);
IProcessor processor = ProcessorUtilities.getProcessor(process, null, process.getContextManager().getDefaultContext());
// hidePasswordInSourceCode4Doc(process);
try {
processor.cleanBeforeGenerate(TalendProcessOptionConstants.CLEAN_JAVA_CODES | TalendProcessOptionConstants.CLEAN_CONTEXTS | TalendProcessOptionConstants.CLEAN_DATA_SETS);
processor.generateCode(false, true, false);
} catch (ProcessorException e) {
ExceptionHandler.process(e);
}
//$NON-NLS-1$
Element sourceCodeInfoElement = DocumentHelper.createElement("sourcecodes");
ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
// StringBuffer componentsCode = new StringBuffer();
try {
IFile codeFile = synchronizer.getFile(item);
if (codeFile == null) {
return;
}
//$NON-NLS-1$
String tempStr = "";
InputStream in = codeFile.getContents();
BufferedReader buffer = new BufferedReader(new InputStreamReader(in));
while ((tempStr = buffer.readLine()) != null) {
//$NON-NLS-1$
Element codeElement = DocumentHelper.createElement("code");
// componentsCode.append(tempStr).append("\n");
//$NON-NLS-1$
codeElement.addAttribute("content", tempStr);
sourceCodeInfoElement.add(codeElement);
}
buffer.close();
in.close();
} catch (Exception e) {
// TODO Auto-generated catch block
// e.printStackTrace();
ExceptionHandler.process(e);
}
element.add(sourceCodeInfoElement);
}
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class BDJobReArchieveCreator method getLibPath.
/**
*
* maybe, should be same result with JobJavaScriptsManager.getLibPath
*/
public List<File> getLibPath(File zipTmpFolder, boolean isSpecialMR) {
List<File> neededLibFiles = new ArrayList<File>();
File libFolder = new File(zipTmpFolder, JavaUtils.JAVA_LIB_DIRECTORY);
Set<String> compiledModulesSet = new HashSet<String>(100);
Set<ModuleNeeded> neededModules = LastGenerationInfo.getInstance().getModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion());
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
IDesignerCoreService designerCoreService = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
IProcess process = designerCoreService.getProcessFromProcessItem(processItem);
compiledModulesSet.addAll(PomUtil.getCodesExportJars(process));
if (neededModules.isEmpty()) {
neededModules = process.getNeededModules(true);
}
}
for (ModuleNeeded module : neededModules) {
if (((isSpecialMR || isSparkWithHDInsight) && module.isMrRequired()) || (!isSpecialMR && !isSparkWithHDInsight)) {
compiledModulesSet.add(module.getModuleName());
}
}
Set<String> jarNames = new HashSet<String>();
try {
// from org.talend.libraries.apache.storm/lib
Bundle bundle = Platform.getBundle(PLUGIN_ID);
if (bundle != null) {
//$NON-NLS-1$
URL stormLibUrl = FileLocator.toFileURL(FileLocator.find(bundle, new Path("lib"), null));
if (stormLibUrl != null) {
File file = new File(stormLibUrl.getFile());
File[] jars = file.listFiles();
for (File f : jars) {
jarNames.add(f.getName());
}
}
}
} catch (IOException e) {
ExceptionHandler.process(e);
}
for (String jarName : compiledModulesSet) {
File jarFile = new File(libFolder, jarName);
if (jarFile.exists()) {
if (!isSpecialMR && !jarNames.isEmpty()) {
// for storm not include the jar from libraries.apache.strom
if (!jarNames.contains(jarName)) {
neededLibFiles.add(jarFile);
}
} else {
neededLibFiles.add(jarFile);
}
}
}
return neededLibFiles;
}
use of org.talend.core.model.process.IProcess in project tesb-studio-se by Talend.
the class CheckRouteBuilderNodeService method checkNode.
@Override
public void checkNode(Node node) {
//TESB-7698
IProcess process = node.getProcess();
if (process == null || !(process instanceof RouteProcess)) {
return;
}
//End TESB-7698
checkIncomingConnections(node);
checkSpecialComponent(node);
}
use of org.talend.core.model.process.IProcess in project tesb-studio-se by Talend.
the class CheckMultiRestRequestNodes method checkNode.
@Override
public void checkNode(Node node) {
String name = node.getComponent().getName();
if (!RESTREQUEST_COMPONENT.equals(name)) {
return;
}
IProcess process = node.getProcess();
if (process.getNodesOfType(RESTREQUEST_COMPONENT).size() > 1) {
Problems.add(ProblemStatus.ERROR, (Element) node, "Only one " + RESTREQUEST_COMPONENT + " component is allowed in a Job!");
} else if (process.getNodesOfType(ESBPROVIDER_COMPONENT).size() > 0) {
Problems.add(ProblemStatus.ERROR, (Element) node, RESTREQUEST_COMPONENT + " and " + ESBPROVIDER_COMPONENT + " can't present in a same Job!");
}
}
use of org.talend.core.model.process.IProcess in project tdi-studio-se by Talend.
the class StandardJobStandaloneBuildProviderTest method test_createPomCreator.
@Test
public void test_createPomCreator() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
Item jobItem = createJobItem();
final IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
Assert.assertNotNull(designerCoreService);
final IProcess processFromItem = designerCoreService.getProcessFromItem(jobItem);
IProcessor processor = ProcessorUtilities.getProcessor(processFromItem, jobItem.getProperty());
final Class<? extends IProcessor> processorClazz = processor.getClass();
Assert.assertEquals("org.talend.designer.runprocess.maven.MavenJavaProcessor", processorClazz.getName());
processor.setContext(processor.getProcess().getContextManager().getDefaultContext());
parameters.put(IBuildPomCreatorParameters.PROCESSOR, processor);
final Method getPomFileMethod = processorClazz.getDeclaredMethod("getPomFile");
getPomFileMethod.setAccessible(true);
final Object getPomFile = getPomFileMethod.invoke(processor);
Assert.assertTrue(getPomFile instanceof IFile);
IFile pomFile = (IFile) getPomFile;
parameters.put(IBuildPomCreatorParameters.FILE_POM, pomFile);
final Method getAssemblyFileMethod = processorClazz.getDeclaredMethod("getAssemblyFile");
getAssemblyFileMethod.setAccessible(true);
final Object getAssemblyFile = getAssemblyFileMethod.invoke(processor);
Assert.assertTrue(getPomFile instanceof IFile);
IFile assemblyFile = (IFile) getAssemblyFile;
parameters.put(IBuildPomCreatorParameters.FILE_ASSEMBLY, assemblyFile);
// before set classpath, must do initJobClasspath
final Method initJobClasspathMethod = processorClazz.getDeclaredMethod("initJobClasspath");
initJobClasspathMethod.setAccessible(true);
initJobClasspathMethod.invoke(processor);
final Field windowsClasspathField = processorClazz.getDeclaredField("windowsClasspath");
windowsClasspathField.setAccessible(true);
parameters.put(IBuildPomCreatorParameters.CP_WIN, windowsClasspathField.get(processor));
final Field unixClasspathField = processorClazz.getDeclaredField("unixClasspath");
unixClasspathField.setAccessible(true);
parameters.put(IBuildPomCreatorParameters.CP_LINUX, unixClasspathField.get(processor));
parameters.put(IBuildParametes.ITEM, processor.getProperty().getItem());
final Map<String, Object> arguments = processor.getArguments();
parameters.put(IBuildPomCreatorParameters.ARGUMENTS_MAP, arguments);
parameters.put(IBuildPomCreatorParameters.OVERWRITE_POM, true);
// create pom and assembly
RepositoryObjectTypeBuildProvider provider = createTestBuildProvider();
final IMavenPomCreator pomCreator = provider.createPomCreator(parameters);
Assert.assertNotNull("Create the pom creator failure", pomCreator);
Assert.assertEquals(CreateMavenJobPom.class, pomCreator.getClass());
pomCreator.create(null);
pomFile.getParent().refreshLocal(IResource.DEPTH_ONE, null);
Assert.assertTrue("the pom file " + pomFile.getName() + " is not created ", pomFile.exists());
assemblyFile.getParent().refreshLocal(IResource.DEPTH_ONE, null);
Assert.assertTrue("the assembly file " + assemblyFile.getName() + " is not created ", assemblyFile.exists());
}
Aggregations