Search in sources :

Example 96 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class AbstractTalendEditor method doSave.

@Override
public void doSave(IProgressMonitor monitor) {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    //$NON-NLS-1$
    monitor.beginTask("begin save job...", 100);
    monitor.worked(10);
    savePreviewPictures();
    // generate the MR infor parameter.
    try {
        boolean isStormServiceRegistered = GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class);
        boolean isMRServiceRegistered = GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class);
        if (isStormServiceRegistered || isMRServiceRegistered) {
            IProcess2 process = getProcess();
            if (process != null) {
                IRepositoryViewObject repoObjectView = DesignerPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getLastVersion(process.getId());
                if (repoObjectView != null && repoObjectView.getProperty() != null) {
                    Item currentItem = repoObjectView.getProperty().getItem();
                    if (isMRServiceRegistered) {
                        IMRProcessService mrService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
                        if (mrService.isMapReduceItem(currentItem)) {
                            // We make sure that the current item is a Batch item before generating the M/R
                            // information parameters.
                            mrService.generateMRInfosParameter(process);
                        }
                    }
                    if (isStormServiceRegistered) {
                        IStormProcessService stormService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
                        if (stormService.isStormItem(currentItem)) {
                            // We make sure that the current item is a Streaming item before generating the Spark
                            // Streaming information parameters.
                            stormService.generateSparkStreamingInfosParameter(process);
                        }
                    }
                }
            }
        }
    } catch (PersistenceException e) {
        e.printStackTrace();
    }
    try {
        if (getEditorInput() instanceof JobEditorInput) {
            boolean saved = ((JobEditorInput) getEditorInput()).saveProcess(new SubProgressMonitor(monitor, 80), null);
            if (!saved) {
                monitor.setCanceled(true);
                throw new InterruptedException();
            }
        }
        getCommandStack().markSaveLocation();
        setDirty(false);
        boolean isneedReload = false;
        for (int i = 0; i < getProcess().getGraphicalNodes().size(); i++) {
            Node node = (Node) getProcess().getGraphicalNodes().get(i);
            if (node.isNeedloadLib()) {
                isneedReload = true;
                node.setNeedLoadLib(false);
            }
        }
        if (isneedReload) {
            // / See bug 4821
            ((ILibrariesService) GlobalServiceRegister.getDefault().getService(ILibrariesService.class)).updateModulesNeededForCurrentJob(getProcess());
        }
        monitor.worked(10);
    } catch (Exception e) {
        // e.printStackTrace();
        ExceptionHandler.process(e);
        monitor.setCanceled(true);
    } finally {
        monitor.done();
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ILibrariesService(org.talend.core.model.general.ILibrariesService) IMRProcessService(org.talend.core.service.IMRProcessService) IStormProcessService(org.talend.core.service.IStormProcessService) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) MapperExternalNode(org.talend.core.model.process.node.MapperExternalNode) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) Point(org.eclipse.draw2d.geometry.Point) CoreException(org.eclipse.core.runtime.CoreException) PersistenceException(org.talend.commons.exception.PersistenceException) JobEditorInput(org.talend.core.ui.editor.JobEditorInput) IContributionItem(org.eclipse.jface.action.IContributionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 97 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class JobletUtil method isRed.

public boolean isRed(AbstractJobletContainer jobletContainer) {
    IProcess2 jobletProcess = (IProcess2) jobletContainer.getNode().getComponent().getProcess();
    if (jobletProcess == null) {
        return false;
    }
    ERepositoryStatus status = ProxyRepositoryFactory.getInstance().getStatus(jobletProcess.getProperty().getItem());
    if (status == ERepositoryStatus.LOCK_BY_OTHER) {
        return true;
    }
    IEditorPart[] editors = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getDirtyEditors();
    if (editors.length <= 0) {
        return false;
    }
    for (IEditorPart editor : editors) {
        if (editor.getEditorInput() instanceof RepositoryEditorInput) {
            RepositoryEditorInput editorInput = (RepositoryEditorInput) editor.getEditorInput();
            String jobletId = editorInput.getId();
            if (jobletId.equals(jobletProcess.getId())) {
                return true;
            }
        }
    }
    return false;
}
Also used : ERepositoryStatus(org.talend.commons.runtime.model.repository.ERepositoryStatus) RepositoryEditorInput(org.talend.core.repository.ui.editor.RepositoryEditorInput) IProcess2(org.talend.core.model.process.IProcess2) IEditorPart(org.eclipse.ui.IEditorPart)

Example 98 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class PropertiesTableEditorModel method refreshMR.

private void refreshMR() {
    if (element instanceof Node) {
        Node node = (Node) element;
        if (!node.isMapReduce()) {
            return;
        }
        if (this.elemParameter == null) {
            return;
        }
        if (!this.elemParameter.getName().equals("MAP_ONLY") && !this.elemParameter.getName().equals(EParameterName.GROUPBYS.getName())) {
            return;
        }
        ((IProcess2) node.getProcess()).getGeneratingNodes();
        ((IProcess2) node.getProcess()).setMRData();
        node.refreshNodeContainer();
    }
}
Also used : Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IProcess2(org.talend.core.model.process.IProcess2)

Example 99 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class UpdateCheckResult method updateJobInfor.

@Override
protected void updateJobInfor() {
    if (getJob() != null) {
        String jobInfor = null;
        if (getJob() instanceof IProcess2) {
            Property property = ((IProcess2) getJob()).getProperty();
            jobInfor = RepositoryUpdateManager.getUpdateJobInfor(property);
            org.talend.core.model.properties.Item item = property.getItem();
            if (item instanceof JobletProcessItem) {
                handleJoblet(item);
            } else if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
                IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
                isMR = mrProcessService.isMapReduceItem(item);
            }
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
                IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
                isStreaming = streamingService.isStormItem(item);
            }
        }
        if (getJob() instanceof org.talend.core.model.properties.Item) {
            jobInfor = RepositoryUpdateManager.getUpdateJobInfor(((org.talend.core.model.properties.Item) getJob()).getProperty());
            if (getJob() instanceof JobletProcessItem) {
                handleJoblet((JobletProcessItem) getJob());
            } else if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
                IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
                isMR = mrProcessService.isMapReduceItem((org.talend.core.model.properties.Item) getJob());
            }
            if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
                IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
                isStreaming = streamingService.isStormItem((org.talend.core.model.properties.Item) getJob());
            }
        }
        String others = null;
        if (isFromItem()) {
            // update item
            others = UpdatesConstants.START;
        }
        if (jobInfor != null) {
            this.jobInfor = jobInfor + UpdatesConstants.SPACE + UpdateManagerUtils.addBrackets(others);
            return;
        }
    }
}
Also used : Item(org.talend.core.model.properties.Item) IMRProcessService(org.talend.core.service.IMRProcessService) IStormProcessService(org.talend.core.service.IStormProcessService) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) IProcess2(org.talend.core.model.process.IProcess2) Property(org.talend.core.model.properties.Property)

Example 100 with IProcess2

use of org.talend.core.model.process.IProcess2 in project tdi-studio-se by Talend.

the class ProcessComposite method exec.

public void exec() {
    setHideconsoleLine(false);
    if (getProcessContext() == null) {
        return;
    }
    if (getProcessContext().getProcess() instanceof IProcess2) {
        ReplaceNodesInProcessProvider.beforeRunJobInGUI(getProcessContext().getProcess());
    }
    CorePlugin.getDefault().getRunProcessService().saveJobBeforeRun(getProcessContext().getProcess());
    if (processContext.isClearBeforeExec()) {
        processContext.clearMessages();
    }
    // processContext.
    // if (processContext.isWatchAllowed()) {
    // processContext.switchTime();
    // }
    processContext.setMonitorTrace(false);
    processContext.setWatchAllowed(processManager.getExecTime());
    processContext.setMonitorPerf(processManager.getStat());
    // processContext.setMonitorTrace(traceBtn.getSelection());
    /* check and save should be execute before processContext.exec,or it will cause dirty problem,bug 16791 */
    checkSaveBeforeRunSelection();
    processContext.setSelectedContext(processManager.getSelectContext());
    processContext.exec(processManager.getProcessShell());
    processContext.cleanWorkingDirectory();
    ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager();
    ILaunch[] launches = manager.getLaunches();
    manager.removeLaunches(launches);
}
Also used : IProcess2(org.talend.core.model.process.IProcess2) ILaunch(org.eclipse.debug.core.ILaunch) ILaunchManager(org.eclipse.debug.core.ILaunchManager)

Aggregations

IProcess2 (org.talend.core.model.process.IProcess2)115 INode (org.talend.core.model.process.INode)31 Node (org.talend.designer.core.ui.editor.nodes.Node)31 ArrayList (java.util.ArrayList)30 ProcessItem (org.talend.core.model.properties.ProcessItem)30 Item (org.talend.core.model.properties.Item)28 IProcess (org.talend.core.model.process.IProcess)24 PersistenceException (org.talend.commons.exception.PersistenceException)22 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)21 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)19 List (java.util.List)17 IElementParameter (org.talend.core.model.process.IElementParameter)15 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)14 Property (org.talend.core.model.properties.Property)14 CoreException (org.eclipse.core.runtime.CoreException)12 IConnection (org.talend.core.model.process.IConnection)11 HashSet (java.util.HashSet)10 IEditorReference (org.eclipse.ui.IEditorReference)10 IProxyRepositoryFactory (org.talend.repository.model.IProxyRepositoryFactory)10 InvocationTargetException (java.lang.reflect.InvocationTargetException)7