use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.
the class JavaProcessorUtilities method getTalendJavaProject.
/**
* A java project under folder .Java will be created if there is no existed.
*
* DOC ggu Comment method "getTalendJavaProject".
*
* @return
* @throws CoreException
*/
public static ITalendProcessJavaProject getTalendJavaProject() {
if (talendJavaProject == null) {
synchronized (JavaProcessorUtilities.class) {
if (talendJavaProject == null) {
try {
IProject project = TalendCodeProjectUtil.initCodeProject(new NullProgressMonitor());
if (project != null) {
IJavaProject javaProject = JavaCore.create(project);
talendJavaProject = new TalendProcessJavaProject(javaProject);
// synchronize templates
if (talendJavaProject != null) {
MavenPomSynchronizer pomSynchronizer = new MavenPomSynchronizer(talendJavaProject);
pomSynchronizer.syncTemplates(false);
}
}
} catch (Exception e) {
// create failure, only log it?
ExceptionHandler.process(e);
}
}
}
}
return talendJavaProject;
}
use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.
the class JavaProcessor method createInternalPackage.
private void createInternalPackage() {
ITalendProcessJavaProject tProcessJvaProject = getTalendJavaProject();
if (tProcessJvaProject == null) {
return;
}
tProcessJvaProject.createSubFolder(null, tProcessJvaProject.getSrcFolder(), JavaUtils.JAVA_INTERNAL_DIRECTORY);
}
use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.
the class JavaProcessor method generateEsbFiles.
/*
* (non-Javadoc) generate ESB files on classpath for jobs with ESB components
*/
@Override
public void generateEsbFiles() throws ProcessorException {
// process.getGeneratingNodes();
List<? extends INode> graphicalNodes = process.getGraphicalNodes();
try {
IPath jobPackagePath = getSrcCodePath().removeLastSegments(1);
IFolder jobPackageFolder = this.getCodeProject().getFolder(jobPackagePath);
//$NON-NLS-1$
IFolder wsdlsPackageFolder = jobPackageFolder.getFolder("wsdl");
if (wsdlsPackageFolder.exists()) {
wsdlsPackageFolder.delete(true, null);
}
for (INode node : graphicalNodes) {
if (node.getComponent().getComponentType() == EComponentType.JOBLET) {
List<? extends INode> graphicalNodesOfJoblet = node.getProcess().getGeneratingNodes();
for (INode nodeOfJoblet : graphicalNodesOfJoblet) {
if ("tESBConsumer".equals(nodeOfJoblet.getComponent().getName()) && nodeOfJoblet.isActivate()) {
//$NON-NLS-1$
generateWSDL(wsdlsPackageFolder, nodeOfJoblet);
}
}
} else {
if ("tESBConsumer".equals(node.getComponent().getName()) && node.isActivate()) {
//$NON-NLS-1$
generateWSDL(wsdlsPackageFolder, node);
}
}
}
} catch (CoreException e) {
if (e.getStatus() != null && e.getStatus().getException() != null) {
ExceptionHandler.process(e.getStatus().getException());
}
//$NON-NLS-1$
throw new ProcessorException(Messages.getString("Processor.tempFailed"), e);
} catch (IOException e) {
//$NON-NLS-1$
throw new ProcessorException(Messages.getString("Processor.tempFailed"), e);
}
boolean samEnabled = false;
boolean slEnabled = false;
boolean oidcEnabled = false;
for (INode node : graphicalNodes) {
if (node.isActivate()) {
final String nodeName = node.getComponent().getName();
Object slValue = null, samValue = null;
if (//$NON-NLS-1$
"tESBConsumer".equals(nodeName) || //$NON-NLS-1$
"tRESTClient".equals(nodeName) || //$NON-NLS-1$
"tRESTRequest".equals(nodeName) || "cREST".equals(nodeName)) {
//$NON-NLS-1$
if (!slEnabled) {
//$NON-NLS-1$
slValue = node.getPropertyValue("SERVICE_LOCATOR");
}
if (!samEnabled) {
//$NON-NLS-1$
samValue = node.getPropertyValue("SERVICE_ACTIVITY_MONITOR");
}
oidcEnabled = true;
} else if ("cSOAP".equals(nodeName)) {
//$NON-NLS-1$
if (!slEnabled) {
//$NON-NLS-1$
slValue = node.getPropertyValue("ENABLE_SL");
}
if (!samEnabled) {
//$NON-NLS-1$
samValue = node.getPropertyValue("ENABLE_SAM");
}
}
if (null != slValue) {
slEnabled = (Boolean) slValue;
}
if (null != samValue) {
samEnabled = (Boolean) samValue;
}
if (samEnabled && slEnabled && oidcEnabled) {
break;
}
}
}
if (samEnabled || slEnabled || oidcEnabled) {
File esbConfigsSourceFolder = EsbConfigUtils.getEclipseEsbFolder();
if (!esbConfigsSourceFolder.exists()) {
RunProcessPlugin.getDefault().getLog().log(new Status(IStatus.WARNING, RunProcessPlugin.getDefault().getBundle().getSymbolicName(), //$NON-NLS-1$
"ESB configuration folder does not exists - " + esbConfigsSourceFolder.toURI()));
return;
}
ITalendProcessJavaProject tProcessJvaProject = this.getTalendJavaProject();
if (tProcessJvaProject == null) {
return;
}
IFolder esbConfigsTargetFolder = tProcessJvaProject.getResourcesFolder();
// add SAM config file to classpath
if (samEnabled) {
//$NON-NLS-1$
copyEsbConfigFile(esbConfigsSourceFolder, esbConfigsTargetFolder, "agent.properties");
}
// add SL config file to classpath
if (slEnabled) {
//$NON-NLS-1$
copyEsbConfigFile(esbConfigsSourceFolder, esbConfigsTargetFolder, "locator.properties");
}
// add OIDC config file to classpath
if (oidcEnabled) {
//$NON-NLS-1$
copyEsbConfigFile(esbConfigsSourceFolder, esbConfigsTargetFolder, "oidc.properties");
}
}
}
use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.
the class JavaCompilationParticipant method updateProblems.
/**
* yzhang Comment method "updateProblems".
*/
private void updateProblems(List<IRepositoryViewObject> routineObjectList, String filePath) {
IRunProcessService runProcessService = CorePlugin.getDefault().getRunProcessService();
try {
ITalendProcessJavaProject talendProcessJavaProject = runProcessService.getTalendProcessJavaProject();
if (talendProcessJavaProject == null) {
return;
}
final ITalendSynchronizer synchronizer = CorePlugin.getDefault().getCodeGeneratorService().createRoutineSynchronizer();
IProject javaProject = talendProcessJavaProject.getProject();
IFile file = javaProject.getFile(filePath);
String fileName = file.getName();
for (IRepositoryViewObject repositoryObject : routineObjectList) {
Property property = repositoryObject.getProperty();
Item item = property.getItem();
IFile currentFile = synchronizer.getFile(item);
if (currentFile != null && fileName.equals(currentFile.getName()) && currentFile.exists()) {
Problems.addRoutineFile(currentFile, property);
break;
}
}
} catch (SystemException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.runtime.process.ITalendProcessJavaProject in project tdi-studio-se by Talend.
the class JavaProcessorUtilities method sortClasspath.
// // see bug 3914, make the order of the jar files consistent with the
// command
// // line in run mode
private static void sortClasspath(Set<ModuleNeeded> jobModuleList, IProcess process, Set<ModuleNeeded> alreadyRetrievedModules) throws CoreException, ProcessorException {
ITalendProcessJavaProject jProject = getTalendJavaProject();
if (jProject == null) {
return;
}
Set<ModuleNeeded> listModulesReallyNeeded = new HashSet<ModuleNeeded>();
listModulesReallyNeeded.addAll(jobModuleList);
Set<ModuleNeeded> optionalJarsOnlyForRoutines = new HashSet<ModuleNeeded>();
// only for wizards or additional jars only to make the java project compile without any error.
for (ModuleNeeded moduleNeeded : ModulesNeededProvider.getSystemRunningModules()) {
optionalJarsOnlyForRoutines.add(moduleNeeded);
}
// list contains all routines linked to job as well as routines not used in the job
// rebuild the list to have only the libs linked to routines "not used".
optionalJarsOnlyForRoutines.removeAll(listModulesReallyNeeded);
// only to be able to compile java project without error.
for (ModuleNeeded jar : optionalJarsOnlyForRoutines) {
listModulesReallyNeeded.add(jar);
}
addLog4jToModuleList(listModulesReallyNeeded);
listModulesReallyNeeded.removeAll(alreadyRetrievedModules);
alreadyRetrievedModules.addAll(listModulesReallyNeeded);
String missingJars = null;
Set<String> missingJarsForRoutinesOnly = new HashSet<String>();
Set<String> missingJarsForProcessOnly = new HashSet<String>();
File libDir = getJavaProjectLibFolder();
ILibraryManagerService repositoryBundleService = CorePlugin.getDefault().getRepositoryBundleService();
if ((libDir != null) && (libDir.isDirectory())) {
Set<ModuleNeeded> jarsNeedRetrieve = new HashSet<ModuleNeeded>();
for (ModuleNeeded moduleNeeded : listModulesReallyNeeded) {
jarsNeedRetrieve.add(moduleNeeded);
}
if (!jarsNeedRetrieve.isEmpty()) {
repositoryBundleService.retrieve(jarsNeedRetrieve, libDir.getAbsolutePath(), true);
if (process instanceof IProcess2) {
((IProcess2) process).checkProcess();
}
}
Set<ModuleNeeded> exist = new HashSet<ModuleNeeded>();
for (File externalLib : libDir.listFiles(FilesUtils.getAcceptJARFilesFilter())) {
for (ModuleNeeded module : jarsNeedRetrieve) {
if (externalLib.getName().equals(module.getModuleName())) {
exist.add(module);
}
}
}
jarsNeedRetrieve.removeAll(exist);
Set<String> jarStringListNeededByProcess = new HashSet<String>();
for (ModuleNeeded moduleNeeded : jobModuleList) {
jarStringListNeededByProcess.add(moduleNeeded.getModuleName());
}
for (ModuleNeeded jar : jarsNeedRetrieve) {
if (jobModuleList.contains(jar)) {
missingJarsForProcessOnly.add(jar.getModuleName());
} else {
missingJarsForRoutinesOnly.add(jar.getModuleName());
}
if (missingJars == null) {
//$NON-NLS-1$
missingJars = Messages.getString("JavaProcessorUtilities.msg.missingjar.forProcess") + jar;
} else {
//$NON-NLS-1$
missingJars = missingJars + ", " + jar;
}
}
}
repositoryBundleService.deployModules(listModulesReallyNeeded, null);
if (missingJars != null) {
handleMissingJarsForProcess(missingJarsForRoutinesOnly, missingJarsForProcessOnly, missingJars);
}
}
Aggregations