Search in sources :

Example 6 with IRunProcessService

use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method getLog4jFiles.

/**
     * Gets required java jars.
     * 
     * @param process
     * 
     * @param boolean1
     * @return
     */
protected List<URL> getLog4jFiles() {
    List<URL> list = new ArrayList<URL>();
    if (Log4jUtil.isEnable() && Boolean.parseBoolean(Log4jPrefsSettingManager.getInstance().getValueOfPreNode(Log4jPrefsConstants.LOG4J_ENABLE_NODE)) && GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
        IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
        try {
            ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
            if (talendProcessJavaProject != null) {
                IFolder resourcesFolder = talendProcessJavaProject.getResourcesFolder();
                IFile log4jFile = resourcesFolder.getFile(Log4jPrefsConstants.LOG4J_FILE_NAME);
                if (log4jFile.exists()) {
                    list.add(FileLocator.toFileURL(log4jFile.getLocationURI().toURL()));
                }
            }
        } catch (MalformedURLException e) {
            ExceptionHandler.process(e);
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
    return list;
}
Also used : MalformedURLException(java.net.MalformedURLException) IFile(org.eclipse.core.resources.IFile) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) URL(java.net.URL) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) DocumentException(org.dom4j.DocumentException) ProcessorException(org.talend.designer.runprocess.ProcessorException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException) IFolder(org.eclipse.core.resources.IFolder)

Example 7 with IRunProcessService

use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method addXmlMapping.

protected void addXmlMapping(ExportFileResource resource, boolean needSource) {
    try {
        boolean hasDynamicMetadata = false;
        if (resource.getItem() instanceof ProcessItem) {
            List<JobInfo> list = new ArrayList<JobInfo>();
            hasDynamicMetadata = LastGenerationInfo.getInstance().isUseDynamic(resource.getItem().getProperty().getId(), resource.getItem().getProperty().getVersion());
        }
        if (hasDynamicMetadata) {
            needMappingInSystemRoutine = true;
            if (needSource) {
                IRunProcessService service = CorePlugin.getDefault().getRunProcessService();
                ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
                if (talendProcessJavaProject == null) {
                    return;
                }
                // for db mapping xml
                IFolder xmlMappingFolder = talendProcessJavaProject.getResourcesFolder().getFolder(JavaUtils.JAVA_XML_MAPPING);
                if (GlobalServiceRegister.getDefault().isServiceRegistered(ICoreService.class)) {
                    ICoreService coreService = (ICoreService) GlobalServiceRegister.getDefault().getService(ICoreService.class);
                    coreService.synchronizeMapptingXML();
                    coreService.syncLog4jSettings();
                }
                List<URL> xmlMappingFileUrls = new ArrayList<URL>();
                if (xmlMappingFolder.exists()) {
                    for (IResource fileResource : xmlMappingFolder.members()) {
                        if (XmlUtil.isXMLFile(fileResource.getName())) {
                            xmlMappingFileUrls.add(fileResource.getLocationURI().toURL());
                        }
                    }
                    resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + JavaUtils.JAVA_XML_MAPPING, xmlMappingFileUrls);
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) ICoreService(org.talend.core.ICoreService) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) URL(java.net.URL) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) DocumentException(org.dom4j.DocumentException) ProcessorException(org.talend.designer.runprocess.ProcessorException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException) ProcessItem(org.talend.core.model.properties.ProcessItem) JobInfo(org.talend.core.model.process.JobInfo) IResource(org.eclipse.core.resources.IResource) IFolder(org.eclipse.core.resources.IFolder)

Example 8 with IRunProcessService

use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method addDependenciesSourceCode.

protected void addDependenciesSourceCode(ExportFileResource[] process, ExportFileResource resource, boolean needSource) {
    if (!needSource) {
        return;
    }
    try {
        // get different routines.
        IRunProcessService service = CorePlugin.getDefault().getRunProcessService();
        ITalendProcessJavaProject talendProcessJavaProject = service.getTalendProcessJavaProject();
        if (talendProcessJavaProject == null) {
            return;
        }
        IFolder srcFolder = talendProcessJavaProject.getSrcFolder();
        IFolder systemRoutineFolder = srcFolder.getFolder(SYSTEM_ROUTINES_PATH);
        List<URL> systemRoutinesFileUrls = new ArrayList<URL>();
        if (systemRoutineFolder.exists()) {
            for (IResource fileResource : systemRoutineFolder.members()) {
                if (fileResource instanceof IFile && ((IFile) fileResource).getFileExtension().equals(ECodeLanguage.JAVA.getExtension())) {
                    systemRoutinesFileUrls.add(fileResource.getLocationURI().toURL());
                }
            }
            resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + SYSTEM_ROUTINES_PATH, systemRoutinesFileUrls);
        }
        // bug TDI-8647
        // empty and re-use it
        systemRoutinesFileUrls.clear();
        systemRoutineFolder = srcFolder.getFolder(SYSTEM_ROUTINES_PATH + PATH_SEPARATOR + JavaUtils.JAVA_SYSTEM_ROUTINES_API_DIRECTORY);
        if (systemRoutineFolder.exists()) {
            for (IResource fileResource : systemRoutineFolder.members()) {
                if (fileResource instanceof IFile && ((IFile) fileResource).getFileExtension().equals(ECodeLanguage.JAVA.getExtension())) {
                    systemRoutinesFileUrls.add(fileResource.getLocationURI().toURL());
                }
            }
            resource.addResources(JOB_SOURCE_FOLDER_NAME + PATH_SEPARATOR + SYSTEM_ROUTINES_PATH + PATH_SEPARATOR + JavaUtils.JAVA_SYSTEM_ROUTINES_API_DIRECTORY, systemRoutinesFileUrls);
        }
        // add for routines
        boolean useBeans = false;
        if (GlobalServiceRegister.getDefault().isServiceRegistered(ICamelDesignerCoreService.class)) {
            ICamelDesignerCoreService camelService = (ICamelDesignerCoreService) GlobalServiceRegister.getDefault().getService(ICamelDesignerCoreService.class);
            if (camelService.isInstanceofCamel(process[0].getItem())) {
                useBeans = true;
            }
        }
        addRoutinesSourceCodes(process, resource, talendProcessJavaProject, useBeans);
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) ICamelDesignerCoreService(org.talend.designer.core.ICamelDesignerCoreService) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) URL(java.net.URL) IResource(org.eclipse.core.resources.IResource) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) DocumentException(org.dom4j.DocumentException) ProcessorException(org.talend.designer.runprocess.ProcessorException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException) IFolder(org.eclipse.core.resources.IFolder)

Example 9 with IRunProcessService

use of org.talend.designer.runprocess.IRunProcessService in project tdi-studio-se by Talend.

the class JobJavaScriptsManager method addLog4jXmlToRes.

protected void addLog4jXmlToRes(ExportFileResource libResource) {
    List<URL> list = new ArrayList<URL>();
    if (Log4jPrefsSettingManager.getInstance().isLog4jEnable() && GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
        IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
        try {
            ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
            if (talendProcessJavaProject != null) {
                IFolder resourcesFolder = talendProcessJavaProject.getResourcesFolder();
                IFile log4jFile = resourcesFolder.getFile(Log4jPrefsConstants.LOG4J_FILE_NAME);
                if (log4jFile.exists()) {
                    list.add(log4jFile.getLocationURI().toURL());
                }
            }
        } catch (MalformedURLException e) {
            ExceptionHandler.process(e);
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
    libResource.addResources(list);
}
Also used : MalformedURLException(java.net.MalformedURLException) IFile(org.eclipse.core.resources.IFile) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) URL(java.net.URL) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) CoreException(org.eclipse.core.runtime.CoreException) IOException(java.io.IOException) DocumentException(org.dom4j.DocumentException) ProcessorException(org.talend.designer.runprocess.ProcessorException) MalformedURLException(java.net.MalformedURLException) PersistenceException(org.talend.commons.exception.PersistenceException) IFolder(org.eclipse.core.resources.IFolder)

Example 10 with IRunProcessService

use of org.talend.designer.runprocess.IRunProcessService in project tesb-studio-se by Talend.

the class RunContainerPreferencePage method performOk.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.designer.esb.runcontainer.preferences.FieldLayoutPreferencePage#performOk()
     */
@Override
public boolean performOk() {
    boolean performOk = super.performOk();
    if (runtimeEnable != getPreferenceStore().getBoolean(RunContainerPreferenceInitializer.P_ESB_IN_OSGI)) {
        IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
        if (service != null) {
            service.refreshView();
        }
        List<IEditorReference> editorRefs = new ArrayList();
        IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
        IEditorReference[] reference = page.getEditorReferences();
        for (IEditorReference editorRef : reference) {
            IEditorPart part = editorRef.getEditor(false);
            if (part.getEditorInput() instanceof JobEditorInput) {
                editorRefs.add(editorRef);
            }
        }
        if (editorRefs.size() > 0 && MessageDialog.openConfirm(getShell(), "Running Container Changed", "All editors need to be closed to apply the changes, do you want to close all opening editors now?")) {
            page.closeEditors(editorRefs.toArray(new IEditorReference[editorRefs.size()]), true);
        }
    }
    return performOk;
}
Also used : JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IEditorReference(org.eclipse.ui.IEditorReference) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart)

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