Search in sources :

Example 86 with ProcessItem

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

the class OpenExistVersionProcessWizard method openAnotherVersion.

protected void openAnotherVersion(final RepositoryNode node, final boolean readonly) {
    try {
        if (node.getObject() != null) {
            final Item item = node.getObject().getProperty().getItem();
            final IWorkbenchPage page = getActivePage();
            final RepositoryEditorInput fileEditorInput = getEditorInput(item, readonly, page);
            if (fileEditorInput != null) {
                IEditorPart editorPart = page.findEditor(fileEditorInput);
                if (editorPart == null) {
                    fileEditorInput.setRepositoryNode(node);
                    if (item instanceof ProcessItem) {
                        page.openEditor(fileEditorInput, MultiPageTalendEditor.ID, readonly);
                    } else if (item instanceof BusinessProcessItem) {
                        CorePlugin.getDefault().getDiagramModelService().openBusinessDiagramEditor(page, fileEditorInput);
                    } else {
                        ECodeLanguage lang = ((RepositoryContext) CorePlugin.getContext().getProperty(Context.REPOSITORY_CONTEXT_KEY)).getProject().getLanguage();
                        //$NON-NLS-1$ //$NON-NLS-2$
                        String talendEditorID = "org.talend.designer.core.ui.editor.StandAloneTalend" + lang.getCaseName() + "Editor";
                        page.openEditor(fileEditorInput, talendEditorID);
                    }
                } else {
                    page.activate(editorPart);
                }
            } else {
                // TDI-19014:open another version of jobScript
                if (item instanceof JobScriptItem) {
                    IProject fsProject = ResourceUtils.getProject(ProjectManager.getInstance().getCurrentProject());
                    openXtextEditor(node, fsProject, readonly);
                }
            }
        }
    } catch (PartInitException e) {
        MessageBoxExceptionHandler.process(e);
    } catch (SystemException e) {
        MessageBoxExceptionHandler.process(e);
    }
}
Also used : RepositoryContext(org.talend.core.context.RepositoryContext) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) JobScriptItem(org.talend.core.model.properties.JobScriptItem) IEditorPart(org.eclipse.ui.IEditorPart) IProject(org.eclipse.core.resources.IProject) Item(org.talend.core.model.properties.Item) JobScriptItem(org.talend.core.model.properties.JobScriptItem) RoutineItem(org.talend.core.model.properties.RoutineItem) SQLPatternItem(org.talend.core.model.properties.SQLPatternItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) BusinessProcessItem(org.talend.core.model.properties.BusinessProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) SystemException(org.talend.commons.exception.SystemException) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) ECodeLanguage(org.talend.core.language.ECodeLanguage)

Example 87 with ProcessItem

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

the class JavaProcessUtil method getChildrenModules.

static List<ModuleNeeded> getChildrenModules(final INode node, Set<ProcessItem> searchItems, boolean forMR) {
    List<ModuleNeeded> modulesNeeded = new ArrayList<ModuleNeeded>();
    if (node.getComponent().getName().equals("tRunJob")) {
        //$NON-NLS-1$
        //$NON-NLS-1$
        IElementParameter processIdparam = node.getElementParameter("PROCESS_TYPE_PROCESS");
        IElementParameter processVersionParam = node.getElementParameter(EParameterName.PROCESS_TYPE_VERSION.getName());
        ProcessItem processItem = null;
        if (processVersionParam != null) {
            processItem = ItemCacheManager.getProcessItem((String) processIdparam.getValue(), (String) processVersionParam.getValue());
        } else {
            processItem = ItemCacheManager.getProcessItem((String) processIdparam.getValue());
        }
        //$NON-NLS-1$
        String context = (String) node.getElementParameter("PROCESS_TYPE_CONTEXT").getValue();
        if (processItem != null && !searchItems.contains(processItem)) {
            boolean seperated = //$NON-NLS-1$
            getBooleanParamValue(node, "USE_INDEPENDENT_PROCESS") || //$NON-NLS-1$
            getBooleanParamValue(node, "USE_DYNAMIC_JOB");
            if (!seperated) {
                // avoid dead loop of method call
                searchItems.add(processItem);
                JobInfo subJobInfo = new JobInfo(processItem, context);
                IDesignerCoreService service = CorePlugin.getDefault().getDesignerCoreService();
                IProcess child = service.getProcessFromItem(subJobInfo.getProcessItem());
                getNeededModules(child, true, searchItems, modulesNeeded, forMR);
            }
        }
    }
    return modulesNeeded;
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) JobInfo(org.talend.core.model.process.JobInfo) ArrayList(java.util.ArrayList) IElementParameter(org.talend.core.model.process.IElementParameter) IDesignerCoreService(org.talend.designer.core.IDesignerCoreService) ModuleNeeded(org.talend.core.model.general.ModuleNeeded) IProcess(org.talend.core.model.process.IProcess)

Example 88 with ProcessItem

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

the class AbstractPublishJobAction method exportJobForOSGI.

private void exportJobForOSGI(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    File tmpJob = null;
    final ProcessItem processItem = (ProcessItem) node.getObject().getProperty().getItem();
    try {
        tmpJob = File.createTempFile("job", ".jar", null);
        jobScriptsManager = JobScriptsManagerFactory.createManagerInstance(JobScriptsManagerFactory.getDefaultExportChoiceMap(), processItem.getProcess().getDefaultContext(), JobScriptsManager.LAUNCHER_ALL, IProcessor.NO_STATISTICS, IProcessor.NO_TRACES, JobExportType.OSGI);
        // generate
        jobScriptsManager.setDestinationPath(tmpJob.getAbsolutePath());
        JobExportAction action = new JobExportAction(Collections.singletonList(node), jobVersion, bundleVersion, jobScriptsManager, System.getProperty("java.io.tmpdir"));
        action.run(monitor);
        if (!action.isBuildSuccessful()) {
            return;
        }
        monitor.beginTask("Deploy to Artifact Repository....", IProgressMonitor.UNKNOWN);
        FeaturesModel featuresModel = getFeatureModel(tmpJob);
        // [TESB-12036] add talend-data-mapper feature
        NodeType tHMapNode = EmfModelUtils.getComponentByName(processItem, THMAP_COMPONENT_NAME);
        if (tHMapNode != null) {
            featuresModel.addFeature(new FeatureModel(FeaturesModel.TALEND_DATA_MAPPER_FEATURE_NAME));
        }
        processModules(featuresModel, ((JobJavaScriptOSGIForESBManager) jobScriptsManager).getExcludedModuleNeededs());
        process(processItem, featuresModel, monitor);
    } catch (IOException e) {
        throw new InvocationTargetException(e);
    } finally {
        if (tmpJob != null && tmpJob.exists()) {
            tmpJob.delete();
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) FeaturesModel(org.talend.designer.publish.core.models.FeaturesModel) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) JobExportAction(org.talend.repository.ui.wizards.exportjob.action.JobExportAction) IOException(java.io.IOException) File(java.io.File) FeatureModel(org.talend.designer.publish.core.models.FeatureModel) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 89 with ProcessItem

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

the class AbstractPublishJobAction method exportJobForPOJO.

private void exportJobForPOJO(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    File tmpJob = null;
    try {
        tmpJob = File.createTempFile("item", ".zip", null);
        // jobScriptsManager.setDestinationPath(tmpJob.getAbsolutePath());
        // JobExportAction action = new JobExportAction(Collections.singletonList(node), jobVersion,
        // jobScriptsManager, null,
        // "job");
        // action.run(monitor);
        // if (!action.isBuildSuccessful()) {
        // return;
        // }
        // TDI-32861, because for publish job, so means, must be binaries
        exportChoiceMap.put(ExportChoice.binaries, true);
        exportChoiceMap.put(ExportChoice.includeLibs, true);
        exportChoiceMap.put(ExportChoice.addStatistics, true);
        ProcessItem processItem = (ProcessItem) node.getObject().getProperty().getItem();
        String contextName = (String) exportChoiceMap.get(ExportChoice.contextName);
        if (contextName == null) {
            contextName = processItem.getProcess().getDefaultContext();
        }
        BuildJobManager.getInstance().buildJob(tmpJob.getAbsolutePath(), processItem, jobVersion, contextName, exportChoiceMap, exportType, monitor);
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
            IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
            boolean hasError = service.checkExportProcess(new StructuredSelection(node), true);
            if (hasError) {
                return;
            }
        }
        monitor.beginTask("Deploy to Artifact Repository....", IProgressMonitor.UNKNOWN);
        FeaturesModel featuresModel = getFeatureModel(tmpJob);
        process(processItem, featuresModel, monitor);
    } catch (InterruptedException e) {
        throw e;
    } catch (Exception e) {
        throw new InvocationTargetException(e);
    } finally {
        if (tmpJob != null && tmpJob.exists()) {
            tmpJob.delete();
        }
    }
}
Also used : ProcessItem(org.talend.core.model.properties.ProcessItem) FeaturesModel(org.talend.designer.publish.core.models.FeaturesModel) IRunProcessService(org.talend.designer.runprocess.IRunProcessService) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) File(java.io.File) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 90 with ProcessItem

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

the class JobLaunchShortcut method launch.

/**
     * bqian Comment method "launch".
     * 
     * @param object
     * @param mode
     */
private void launch(Item item, String mode) {
    if (item instanceof ProcessItem) {
        ILaunchConfiguration config = findLaunchConfiguration((ProcessItem) item, mode);
        if (config != null) {
            IPreferenceStore debugUiStore = DebugUITools.getPreferenceStore();
            // boolean oldBuildBeforeLaunch = debugUiStore.getBoolean(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH);
            try {
                if (!Problems.buildWholeProject) {
                    // don't build auto, because will be in one Job, so can't set back the old value
                    debugUiStore.setValue(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH, false);
                    // FIXME, only for standard job, same as Problems.computeCompilationUnit
                    ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
                    if (itemType == null || !ERepositoryObjectType.PROCESS.equals(itemType)) {
                        try {
                            config.getFile().getProject().build(IncrementalProjectBuilder.INCREMENTAL_BUILD, null);
                        } catch (CoreException e) {
                            ExceptionHandler.process(e);
                        }
                    }
                }
                DebugUITools.launch(config, mode);
            } finally {
            // debugUiStore.setValue(IDebugUIConstants.PREF_BUILD_BEFORE_LAUNCH, oldBuildBeforeLaunch);
            }
        }
    }
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ProcessItem(org.talend.core.model.properties.ProcessItem) CoreException(org.eclipse.core.runtime.CoreException) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ERepositoryObjectType(org.talend.core.model.repository.ERepositoryObjectType)

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