Search in sources :

Example 21 with IRunProcessService

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);
        }
    }
}
Also used : Set(java.util.Set) HashSet(java.util.HashSet) IPath(org.eclipse.core.runtime.IPath) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) URL(java.net.URL) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) DependenciesResolver(org.talend.designer.camel.dependencies.core.DependenciesResolver) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess)

Example 22 with IRunProcessService

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;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) HashMap(java.util.HashMap) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) BuildDataServiceHandler(org.talend.repository.services.export.BuildDataServiceHandler) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Example 23 with IRunProcessService

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);
        }
    }
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject)

Example 24 with IRunProcessService

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);
        }
    }
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) IProject(org.eclipse.core.resources.IProject)

Example 25 with IRunProcessService

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);
}
Also used : Path(org.eclipse.core.runtime.Path) ProcessorException(org.talend.designer.runprocess.ProcessorException) FileWriter(java.io.FileWriter) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) IOException(java.io.IOException) File(java.io.File)

Aggregations

IRunProcessService (org.talend.designer.runprocess.IRunProcessService)51 ITalendProcessJavaProject (org.talend.core.runtime.process.ITalendProcessJavaProject)30 IFolder (org.eclipse.core.resources.IFolder)17 IFile (org.eclipse.core.resources.IFile)15 File (java.io.File)14 IOException (java.io.IOException)13 ArrayList (java.util.ArrayList)12 CoreException (org.eclipse.core.runtime.CoreException)11 URL (java.net.URL)9 PersistenceException (org.talend.commons.exception.PersistenceException)9 MalformedURLException (java.net.MalformedURLException)7 IPath (org.eclipse.core.runtime.IPath)7 IProcess (org.talend.core.model.process.IProcess)7 ProcessorException (org.talend.designer.runprocess.ProcessorException)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 DocumentException (org.dom4j.DocumentException)5 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)5 HashSet (java.util.HashSet)4 ProcessItem (org.talend.core.model.properties.ProcessItem)4 ByteArrayInputStream (java.io.ByteArrayInputStream)3