use of org.talend.designer.runprocess.IRunProcessService in project tesb-studio-se by Talend.
the class RouteJavaScriptOSGIForESBManager method addOsgiDependencies.
@Override
protected void addOsgiDependencies(Analyzer analyzer, ExportFileResource libResource, ProcessItem processItem) throws IOException {
final DependenciesResolver resolver = new DependenciesResolver(processItem);
// add manifest items
analyzer.setProperty(Analyzer.REQUIRE_BUNDLE, resolver.getManifestRequireBundle(MANIFEST_ITEM_SEPARATOR));
StringBuilder manifestImportPackage = new StringBuilder();
if (subjobImportPackages != null && subjobImportPackages.containsKey(processItem.getProperty().getId())) {
// Add subjob import packages
manifestImportPackage.append(subjobImportPackages.get(processItem.getProperty().getId()));
manifestImportPackage.append(MANIFEST_ITEM_SEPARATOR);
}
// https://jira.talendforge.org/browse/APPINT-33388
manifestImportPackage.append("org.apache.camel.component.cxf.jaxrs.blueprint;resolution:=optional");
manifestImportPackage.append(MANIFEST_ITEM_SEPARATOR);
// https://jira.talendforge.org/browse/APPINT-34061
Set<String> relativePathList = libResource.getRelativePathList();
search: for (String path : relativePathList) {
Set<URL> resources = libResource.getResourcesByRelativePath(path);
for (URL url : resources) {
String urlStr = url.getPath().replace("\\", "/");
if (urlStr.matches("(.*)camel-xslt-alldep-(.*)$")) {
manifestImportPackage.append("net.sf.saxon;resolution:=optional");
manifestImportPackage.append(MANIFEST_ITEM_SEPARATOR);
break search;
}
}
}
IDesignerCoreService designerService = RepositoryPlugin.getDefault().getDesignerCoreService();
IProcess process = designerService.getProcessFromProcessItem(processItem, false);
for (String lib : process.getNeededLibraries(TalendProcessOptionConstants.MODULES_WITH_CHILDREN)) {
if (lib != null && lib.matches("camel-jsonpath-(.*)jar")) {
manifestImportPackage.append("org.apache.camel.jsonpath.jackson");
manifestImportPackage.append(MANIFEST_ITEM_SEPARATOR);
break;
}
}
manifestImportPackage.append(resolver.getManifestImportPackage(MANIFEST_ITEM_SEPARATOR)).append(// $NON-NLS-1$
",*;resolution:=optional");
analyzer.setProperty(Analyzer.IMPORT_PACKAGE, manifestImportPackage.toString());
analyzer.setProperty(Analyzer.EXPORT_PACKAGE, resolver.getManifestExportPackage(MANIFEST_ITEM_SEPARATOR));
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService processService = GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
if (talendProcessJavaProject != null) {
final IPath libPath = talendProcessJavaProject.getLibFolder().getLocation();
// process external libs
final List<URL> list = new ArrayList<URL>();
for (String s : resolver.getManifestBundleClasspath(MANIFEST_ITEM_SEPARATOR).split(Character.toString(MANIFEST_ITEM_SEPARATOR))) {
if (!s.isEmpty()) {
list.add(libPath.append(s).toFile().toURI().toURL());
}
}
libResource.addResources(list);
}
}
}
use of org.talend.designer.runprocess.IRunProcessService in project tesb-studio-se by Talend.
the class ServiceExportWizard method performFinish.
@Override
public boolean performFinish() {
final String destinationValue = mainPage.getDestinationValue();
// TESB-7319: add confirm dialog
if (new File(destinationValue).exists()) {
boolean openQuestion = MessageDialog.openQuestion(getShell(), Messages.ServiceExportWizard_destinationExistTitle, Messages.ServiceExportWizard_destinationExistMessage);
if (!openQuestion) {
return false;
}
}
// END TESB-7319
Map<ExportChoice, Object> exportChoiceMap = mainPage.getExportChoiceMap();
exportChoiceMap.put(ExportChoice.doNotCompileCode, false);
exportChoiceMap.put(ExportChoice.needDependencies, false);
exportChoiceMap.put(ExportChoice.addStatistics, false);
exportChoiceMap.put(ExportChoice.addTracs, false);
exportChoiceMap.put(ExportChoice.needAntScript, false);
exportChoiceMap.put(ExportChoice.needMavenScript, false);
exportChoiceMap.put(ExportChoice.applyToChildren, false);
exportChoiceMap.put(ExportChoice.needContext, true);
exportChoiceMap.put(ExportChoice.binaries, true);
exportChoiceMap.put(ExportChoice.needSourceCode, false);
exportChoiceMap.put(ExportChoice.executeTests, false);
exportChoiceMap.put(ExportChoice.includeTestSource, false);
exportChoiceMap.put(ExportChoice.includeLibs, true);
exportChoiceMap.put(ExportChoice.needLog4jLevel, false);
exportChoiceMap.put(ExportChoice.needAssembly, true);
String bundleVersion = PomIdsHelper.getJobVersion(serviceItem.getProperty());
if (bundleVersion != null) {
bundleVersion = bundleVersion.replace("-", ".");
}
exportChoiceMap.put(ExportChoice.bundleVersion, bundleVersion);
// update to use BuildDataServiceHandler
IProgressMonitor pMonitor = new NullProgressMonitor();
int scale = 10;
BuildDataServiceHandler buildServiceHandler = new BuildDataServiceHandler(serviceItem, serviceItem.getProperty().getVersion(), IContext.DEFAULT, exportChoiceMap);
Map<String, Object> prepareParams = new HashMap<String, Object>();
prepareParams.put(IBuildResourceParametes.OPTION_ITEMS, true);
prepareParams.put(IBuildResourceParametes.OPTION_ITEMS_DEPENDENCIES, true);
try {
buildServiceHandler.prepare(pMonitor, prepareParams);
buildServiceHandler.build(new SubProgressMonitor(pMonitor, scale));
IFile serviceTargetFile = buildServiceHandler.getJobTargetFile();
if (serviceTargetFile != null && serviceTargetFile.exists()) {
FilesUtils.copyFile(serviceTargetFile.getLocation().toFile(), new File(destinationValue));
} else {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendJavaProject = service.getTalendJobJavaProject(serviceItem.getProperty());
String mvnLogFilePath = // $NON-NLS-1$
talendJavaProject.getProject().getFile("lastGenerated.log").getLocation().toPortableString();
Exception e = new Exception("Service was not built successfully, please check the logs for more details available on " + mvnLogFilePath);
MessageBoxExceptionHandler.process(e, getShell());
}
return false;
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e, getShell());
BuildCacheManager.getInstance().performBuildFailure();
return false;
} finally {
ProcessorUtilities.resetExportConfig();
}
mainPage.finish();
return true;
}
use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class RoutinesMavenInstallLoginTask method run.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
*/
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
if (talendProcessJavaProject != null) {
talendProcessJavaProject.updateRoutinesPom(true, true);
}
}
}
use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class Log4jPreferencePage method updateLogFiles.
private void updateLogFiles() {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendJavaProject = JavaProcessorUtilities.getTalendJavaProject();
if (service != null && talendJavaProject != null) {
IProject project = talendJavaProject.getProject();
service.updateLogFiles(project, false);
}
}
}
use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.
the class FileInputDelimitedNode method getColumnCount.
private int getColumnCount(String filename, String rowSep, String fieldSep, int limitRows, int headerRows, String escapeChar, String textEnclosure, EShadowProcessType fileType) {
File config = new File(CorePlugin.getDefault().getPreferenceStore().getString(ITalendCorePrefConstants.FILE_PATH_TEMP) + //$NON-NLS-1$
"/conf.pl");
if (config.exists()) {
config.delete();
}
String modulepath = LibrariesManagerUtils.getLibrariesPath(ECodeLanguage.PERL);
FileWriter filewriter;
//$NON-NLS-1$
String str = "0";
File resultFile = new File(CorePlugin.getDefault().getPreferenceStore().getString(ITalendCorePrefConstants.FILE_PATH_TEMP) + //$NON-NLS-1$
"/result.txt");
if (resultFile.exists()) {
resultFile.delete();
}
try {
filewriter = new FileWriter(config, true);
switch(fileType) {
case FILE_DELIMITED:
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{filename} = " + filename + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{row_separator} = " + rowSep + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{field_separator} = " + fieldSep + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{header} = " + headerRows + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{limit} = " + limitRows + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{result_file} =\'" + resultFile.toString() + "\';");
//$NON-NLS-1$
filewriter.write("$conf{type} = \'delimited\';");
break;
case FILE_CSV:
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{filename} = " + filename + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{row_separator} = " + rowSep + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{field_separator} = " + fieldSep + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{escape_char} = " + escapeChar + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{text_enclosure} = " + textEnclosure + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{header} = " + headerRows + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{limit} = " + limitRows + ";");
//$NON-NLS-1$ //$NON-NLS-2$
filewriter.write("$conf{result_file} =\'" + resultFile.toString() + "\';");
//$NON-NLS-1$
filewriter.write("$conf{type} = \'CSV\';");
break;
default:
break;
}
filewriter.close();
//$NON-NLS-1$
modulepath = modulepath + "/column_counter_delimited.pl";
StringBuffer out = new StringBuffer();
StringBuffer err = new StringBuffer();
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
service.perlExec(out, err, new Path(modulepath), null, Level.DEBUG, "", null, -1, -1, new String[] { //$NON-NLS-1$ //$NON-NLS-2$
"--conf=" + config });
FileReader filereader = new FileReader(resultFile);
BufferedReader reader = new BufferedReader(filereader);
str = reader.readLine();
} catch (IOException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
ExceptionHandler.process(e);
} catch (ProcessorException e) {
// TODO Auto-generated catch block
// e.printStackTrace();
ExceptionHandler.process(e);
}
return Integer.parseInt(str);
}
Aggregations