Search in sources :

Example 26 with IRunProcessService

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

the class RunProcessPreferenceInitializer method getLogTemplate.

protected String getLogTemplate(String logPath) {
    IRunProcessService service = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
        service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
    }
    if (service == null) {
        return EMPTY_STR;
    }
    File templateFile = new File(service.getResourceFilePath(logPath));
    if (!templateFile.exists()) {
        return EMPTY_STR;
    }
    return getLogTemplateString(templateFile);
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService) File(java.io.File)

Example 27 with IRunProcessService

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

the class RunProcessPreferencePage method performOk.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.preference.IPreferencePage#performOk()
     */
@Override
public boolean performOk() {
    boolean ok = super.performOk();
    // consoleFontField.store();
    // update high water mark to be (about) 100 lines (100 * 80 chars) greater than low water mark
    // IPreferenceStore store = RunRemoteProcessPlugin.getDefault().getPreferenceStore();
    // int low = store.getInt(IDebugPreferenceConstants.CONSOLE_LOW_WATER_MARK);
    // int high = low + 8000;
    // store.setValue(IDebugPreferenceConstants.CONSOLE_HIGH_WATER_MARK, high);
    RunProcessPlugin.getDefault().savePluginPreferences();
    IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
    service.refreshView();
    manager.setClearBeforeExec(onClearbeforeField.getBooleanValue());
    manager.setExecTime(onExecTimeField.getBooleanValue());
    manager.setStat(onStatisticsField.getBooleanValue());
    manager.setSaveJobBeforeRun(onSavebeforeField.getBooleanValue());
    return ok;
}
Also used : IRunProcessService(org.talend.designer.runprocess.IRunProcessService)

Example 28 with IRunProcessService

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

the class JobJavaScriptsManager method getExternalLibraries.

/**
     * Gets required java jars.
     * 
     * @param process
     * 
     * @param boolean1
     * @return
     */
protected List<URL> getExternalLibraries(boolean needLibraries, ExportFileResource[] process, final Set<String> neededLibraries) {
    List<URL> list = new ArrayList<URL>();
    if (!needLibraries) {
        return list;
    }
    IFolder libFolder = null;
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
        IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
        ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
        if (talendProcessJavaProject != null) {
            libFolder = talendProcessJavaProject.getLibFolder();
        }
    }
    if (libFolder == null) {
        return list;
    }
    File file = libFolder.getLocation().toFile();
    File[] files = file.listFiles(FilesUtils.getAcceptModuleFilesFilter());
    // Lists all the needed jar files
    Set<String> listModulesReallyNeeded = new HashSet<String>();
    if (neededLibraries == null) {
        // in case export as been done with option "not recompile", then libraires can't be retrieved when build.
        IDesignerCoreService designerService = RepositoryPlugin.getDefault().getDesignerCoreService();
        for (ExportFileResource resource : process) {
            ProcessItem item = (ProcessItem) resource.getItem();
            String version = item.getProperty().getVersion();
            if (!isMultiNodes() && this.getSelectedJobVersion() != null) {
                version = this.getSelectedJobVersion();
            }
            ProcessItem selectedProcessItem;
            if (resource.getNode() != null) {
                selectedProcessItem = ItemCacheManager.getProcessItem(resource.getNode().getRoot().getProject(), item.getProperty().getId(), version);
            } else {
                // if no node given, take in the current project only
                selectedProcessItem = ItemCacheManager.getProcessItem(item.getProperty().getId(), version);
            }
            IProcess iProcess = designerService.getProcessFromProcessItem(selectedProcessItem);
            Set<String> processNeededLibraries = iProcess.getNeededLibraries(true);
            if (processNeededLibraries != null) {
                listModulesReallyNeeded.addAll(processNeededLibraries);
            }
        }
    } else {
        listModulesReallyNeeded.addAll(neededLibraries);
    }
    // jar from routines
    List<IRepositoryViewObject> collectRoutines = new ArrayList<IRepositoryViewObject>();
    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;
        }
    }
    String include = null;
    if (useBeans) {
        include = USER_BEANS_PATH;
    } else {
        include = USER_ROUTINES_PATH;
    }
    collectRoutines.addAll(collectRoutines(process, include));
    collectRoutines.addAll(collectRoutines(process, USER_PIGUDF_PATH));
    for (IRepositoryViewObject object : collectRoutines) {
        Item item = object.getProperty().getItem();
        if (item instanceof RoutineItem) {
            RoutineItem routine = (RoutineItem) item;
            EList imports = routine.getImports();
            for (Object o : imports) {
                IMPORTType type = (IMPORTType) o;
                listModulesReallyNeeded.add(type.getMODULE());
            }
        }
    }
    if (Log4jPrefsSettingManager.getInstance().isLog4jEnable()) {
        addLog4jToJarList(listModulesReallyNeeded);
    }
    for (File tempFile : files) {
        try {
            if (listModulesReallyNeeded.contains(tempFile.getName())) {
                list.add(tempFile.toURL());
            }
        } catch (MalformedURLException e) {
            ExceptionHandler.process(e);
        }
    }
    return list;
// List<URL> libraries = new ArrayList<URL>();
// if (needLibraries) {
// try {
// ILibrariesService service = CorePlugin.getDefault().getLibrariesService();
// libraries = service.getTalendRoutines();
// } catch (Exception e) {
// ExceptionHandler.process(e);
// }
// }
// return libraries;
}
Also used : MalformedURLException(java.net.MalformedURLException) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) URL(java.net.URL) ITalendProcessJavaProject(org.talend.core.runtime.process.ITalendProcessJavaProject) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) RulesItem(org.talend.core.model.properties.RulesItem) RoutineItem(org.talend.core.model.properties.RoutineItem) IMPORTType(org.talend.designer.core.model.utils.emf.component.IMPORTType) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) LinkedHashSet(java.util.LinkedHashSet) HashSet(java.util.HashSet) ICamelDesignerCoreService(org.talend.designer.core.ICamelDesignerCoreService) RoutineItem(org.talend.core.model.properties.RoutineItem) EList(org.eclipse.emf.common.util.EList) ProcessItem(org.talend.core.model.properties.ProcessItem) ExportFileResource(org.talend.repository.documentation.ExportFileResource) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IFile(org.eclipse.core.resources.IFile) File(java.io.File) IFolder(org.eclipse.core.resources.IFolder)

Example 29 with IRunProcessService

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

the class JobJavaScriptsManager method addLog4jSetting.

protected void addLog4jSetting(ExportFileResource resource) {
    try {
        if (Log4jPrefsSettingManager.getInstance().isLog4jEnable() && GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
            IRunProcessService processService = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
            ITalendProcessJavaProject talendProcessJavaProject = processService.getTalendProcessJavaProject();
            if (talendProcessJavaProject != null) {
                IFolder resourcesFolder = talendProcessJavaProject.getResourcesFolder();
                IFile log4jFile = resourcesFolder.getFile(Log4jPrefsConstants.LOG4J_FILE_NAME);
                if (log4jFile.exists()) {
                    List<URL> log4jFileUrls = new ArrayList<URL>();
                    log4jFileUrls.add(FileLocator.toFileURL(log4jFile.getLocationURI().toURL()));
                    resource.addResources(PATH_SEPARATOR, log4jFileUrls);
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) ArrayList(java.util.ArrayList) 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) IFolder(org.eclipse.core.resources.IFolder)

Example 30 with IRunProcessService

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

the class RepositoryService method openLoginDialog.

/*
     * (non-Javadoc)
     * 
     * @see org.talend.repository.model.IRepositoryService#openLoginDialog()
     */
@Override
public void openLoginDialog() {
    if (isloginDialogDisabled()) {
        return;
    }
    if (CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY) != null) {
        return;
    }
    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    boolean logged = false;
    LoginDialogV2 loginDialog = new LoginDialogV2(shell);
    // PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().closeAllEditors(true);
    logged = loginDialog.open() == LoginDialogV2.OK;
    if (logged) {
        // addCommand();
        new DisableLanguageActions().earlyStartup();
        new BindingActions().bind();
        IMigrationToolService toolService = CorePlugin.getDefault().getMigrationToolService();
        toolService.executeMigration(SwitchProjectAction.PLUGIN_MODEL);
        IRunProcessService runService = CorePlugin.getDefault().getRunProcessService();
        runService.deleteAllJobs(SwitchProjectAction.PLUGIN_MODEL);
        CorePlugin.getDefault().getCodeGeneratorService().initializeTemplates();
        CorePlugin.getDefault().getDesignerCoreService().synchronizeDesignerUI(new PropertyChangeEvent(this, IComponentConstants.NORMAL, null, null));
    }
}
Also used : Shell(org.eclipse.swt.widgets.Shell) PropertyChangeEvent(java.beans.PropertyChangeEvent) IMigrationToolService(org.talend.core.model.migration.IMigrationToolService) DisableLanguageActions(org.talend.core.model.action.DisableLanguageActions) BindingActions(org.talend.repository.plugin.integration.BindingActions) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) LoginDialogV2(org.talend.repository.ui.login.LoginDialogV2)

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