Search in sources :

Example 91 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class JobLaunchShortcutManager method renameJobLaunch.

/**
     * 
     * cli Comment method "renameJobLaunch".
     */
public static void renameJobLaunch(IRepositoryViewObject obj, String oldLabel) {
    if (obj == null) {
        return;
    }
    Property property = obj.getProperty();
    if (property == null || !(property.getItem() instanceof ProcessItem)) {
        return;
    }
    String newLabel = property.getLabel();
    if (!newLabel.equals(oldLabel)) {
        Project project = ProjectManager.getInstance().getProject(property);
        if (project == null) {
            return;
        }
        final String objProjectName = project.getLabel();
        final String id = property.getId();
        final String version = property.getVersion();
        ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
        if (launchManager == null) {
            return;
        }
        try {
            for (ILaunchConfiguration configuration : launchManager.getLaunchConfigurations()) {
                String jobId = configuration.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
                String jobVersion = configuration.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
                String projectName = configuration.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);
                // ILaunchConfigurationType type = launchManager
                // .getLaunchConfigurationType(TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE);
                ILaunchConfigurationType type = configuration.getType();
                if (type != null && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(type.getIdentifier()) && objProjectName.equals(projectName) && id.equals(jobId) && version.equals(jobVersion) && type != null) {
                    //$NON-NLS-1$
                    String displayName = newLabel + " " + jobVersion;
                    ILaunchConfigurationWorkingCopy workingCopy = configuration.getWorkingCopy();
                    workingCopy.setAttribute(TalendDebugUIConstants.JOB_NAME, newLabel);
                    // workingCopy.setAttribute(TalendDebugUIConstants.JOB_ID, jobId);
                    // update to new version
                    workingCopy.setAttribute(TalendDebugUIConstants.JOB_VERSION, jobVersion);
                    // workingCopy.setAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, projectName);
                    workingCopy.rename(displayName);
                    workingCopy.doSave();
                    break;
                }
            }
            clearUnusedLaunchs();
        } catch (CoreException e) {
        // nothing to do
        }
    }
}
Also used : Project(org.talend.core.model.properties.Project) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ProcessItem(org.talend.core.model.properties.ProcessItem) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Property(org.talend.core.model.properties.Property)

Example 92 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class JobLaunchShortcutManager method removeJobLaunch.

// debug not used yet, so code is disabled
// public static void debug(ISelection selection) {
// List<LaunchShortcutExtension> launchShortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
// .getLaunchShortcuts();
//
// for (LaunchShortcutExtension lse : launchShortcuts) {
// if (lse.getId().equals(TalendDebugUIConstants.TALEND_JOB_LAUNCH_SHORTCUT_ID)) {
// lse.launch(selection, ILaunchManager.DEBUG_MODE);
// return;
// }
// }
// }
//
// public static void debug(IEditorPart editor) {
// List<LaunchShortcutExtension> launchShortcuts = DebugUIPlugin.getDefault().getLaunchConfigurationManager()
// .getLaunchShortcuts();
//
// for (LaunchShortcutExtension lse : launchShortcuts) {
// if (lse.getId().equals(TalendDebugUIConstants.TALEND_JOB_LAUNCH_SHORTCUT_ID)) {
// lse.launch(editor, ILaunchManager.DEBUG_MODE);
// return;
// }
// }
// }
/**
     * 
     * cli Comment method "removeJobLaunch".
     */
public static void removeJobLaunch(IRepositoryViewObject objToDelete) {
    if (objToDelete == null) {
        return;
    }
    Property property = objToDelete.getProperty();
    if (property == null || !(property.getItem() instanceof ProcessItem)) {
        return;
    }
    Project project = ProjectManager.getInstance().getProject(property);
    if (project == null) {
        return;
    }
    final String objProjectName = project.getLabel();
    final String objId = property.getId();
    // final String objName = property.getLabel();
    final String objVersion = property.getVersion();
    ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
    if (launchManager == null) {
        return;
    }
    try {
        ILaunchConfiguration configuration = null;
        for (ILaunchConfiguration config : launchManager.getLaunchConfigurations()) {
            String jobId = config.getAttribute(TalendDebugUIConstants.JOB_ID, (String) null);
            // String jobName = configuration.getAttribute(TalendDebugUIConstants.JOB_NAME, (String) null);
            String jobVersion = config.getAttribute(TalendDebugUIConstants.JOB_VERSION, (String) null);
            String projectName = config.getAttribute(TalendDebugUIConstants.CURRENT_PROJECT_NAME, (String) null);
            ILaunchConfigurationType type = config.getType();
            if (type != null && TalendDebugUIConstants.JOB_DEBUG_LAUNCH_CONFIGURATION_TYPE.equals(type.getIdentifier()) && objProjectName.equals(projectName) && objId.equals(jobId) && objVersion.equals(jobVersion)) {
                configuration = config;
                break;
            }
        }
        if (configuration == null) {
            return;
        }
        configuration.delete();
    } catch (CoreException e) {
    // nothing to do
    }
}
Also used : Project(org.talend.core.model.properties.Project) ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ProcessItem(org.talend.core.model.properties.ProcessItem) CoreException(org.eclipse.core.runtime.CoreException) ILaunchConfigurationType(org.eclipse.debug.core.ILaunchConfigurationType) ILaunchManager(org.eclipse.debug.core.ILaunchManager) Property(org.talend.core.model.properties.Property)

Example 93 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class JobLaunchShortcutManager method resetJobProblemList.

/**
     * 
     * ldong Comment method "resetJobProblemList".
     */
public static void resetJobProblemList(IRepositoryViewObject obj, String oldLabel) {
    if (obj == null) {
        return;
    }
    Property property = obj.getProperty();
    if (property == null || !(property.getItem() instanceof ProcessItem)) {
        return;
    }
    String newLabel = property.getLabel();
    if (!newLabel.equals(oldLabel)) {
        for (Iterator<Problem> iter = Problems.getProblemList().getProblemList().iterator(); iter.hasNext(); ) {
            Problem problem = iter.next();
            if (problem instanceof TalendProblem) {
                TalendProblem routineProblem = (TalendProblem) problem;
                if (routineProblem.getJavaUnitName() != null && (routineProblem.getJavaUnitName().equals(oldLabel))) {
                    // TDI-24683:if rename the jobItem,need clear the problem view to avoid use the old
                    // problem list
                    iter.remove();
                }
            }
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) TalendProblem(org.talend.core.model.process.TalendProblem) TalendProblem(org.talend.core.model.process.TalendProblem) Problem(org.talend.core.model.process.Problem) Property(org.talend.core.model.properties.Property)

Example 94 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class StandardJobStandaloneBuildProvider method createBuildExportHandler.

@Override
public IBuildExportHandler createBuildExportHandler(Map<String, Object> parameters) {
    if (parameters == null || parameters.isEmpty()) {
        return null;
    }
    final Object item = parameters.get(ITEM);
    if (item == null || !(item instanceof ProcessItem)) {
        return null;
    }
    final Object version = parameters.get(VERSION);
    if (version == null) {
        return null;
    }
    final Object contextGroup = parameters.get(CONTEXT_GROUP);
    if (contextGroup == null) {
        return null;
    }
    Object choiceOption = parameters.get(CHOICE_OPTION);
    if (choiceOption == null) {
        choiceOption = Collections.emptyMap();
    }
    if (!(choiceOption instanceof Map)) {
        return null;
    }
    IBuildJobHandler buildHandler = new BuildJobHandler((ProcessItem) item, version.toString(), contextGroup.toString(), (Map<ExportChoice, Object>) choiceOption);
    return buildHandler;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) IBuildJobHandler(org.talend.core.runtime.process.IBuildJobHandler) BuildJobHandler(org.talend.repository.ui.wizards.exportjob.handler.BuildJobHandler) IBuildJobHandler(org.talend.core.runtime.process.IBuildJobHandler) ExportChoice(org.talend.repository.ui.wizards.exportjob.scriptsmanager.JobScriptsManager.ExportChoice) Map(java.util.Map)

Example 95 with ProcessItem

use of org.talend.core.model.properties.ProcessItem in project tdi-studio-se by Talend.

the class JobLaunchConfigurationDelegate method findProcessFromRepository.

/**
     * DOC bqian Comment method "findProcessFromRepository".
     * 
     * @param jobName
     * @return
     */
private IProcess2 findProcessFromRepository(String jobId, String version) {
    try {
        ItemCacheManager.clearCache();
        ProcessItem processItem = ItemCacheManager.getProcessItem(jobId, version);
        if (processItem != null) {
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreService.class)) {
                IDesignerCoreService service = (IDesignerCoreService) GlobalServiceRegister.getDefault().getService(IDesignerCoreService.class);
                IProcess process = service.getProcessFromItem(processItem);
                if (process instanceof IProcess2) {
                    return (IProcess2) process;
                }
            }
            // keep old code for now, but it should never be called.
            ProcessEditorInput fileEditorInput = new ProcessEditorInput(processItem, true, true, true);
            IProcess2 process = fileEditorInput.getLoadedProcess();
            return process;
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    return null;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) IProcess(org.talend.core.model.process.IProcess) CoreException(org.eclipse.core.runtime.CoreException) ProcessEditorInput(org.talend.designer.core.ui.editor.ProcessEditorInput)

Aggregations

ProcessItem (org.talend.core.model.properties.ProcessItem)160 PersistenceException (org.talend.commons.exception.PersistenceException)49 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)49 ArrayList (java.util.ArrayList)44 Item (org.talend.core.model.properties.Item)40 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)37 Property (org.talend.core.model.properties.Property)30 IProcess2 (org.talend.core.model.process.IProcess2)24 ProcessType (org.talend.designer.core.model.utils.emf.talendfile.ProcessType)24 IProcess (org.talend.core.model.process.IProcess)23 File (java.io.File)22 IDesignerCoreService (org.talend.designer.core.IDesignerCoreService)21 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)21 ExportFileResource (org.talend.repository.documentation.ExportFileResource)21 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)21 IOException (java.io.IOException)20 INode (org.talend.core.model.process.INode)20 List (java.util.List)19 EList (org.eclipse.emf.common.util.EList)19 ProcessorException (org.talend.designer.runprocess.ProcessorException)17