Search in sources :

Example 1 with IMRProcessService

use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.

the class ChangeActivateStatusElementCommand method refreshMRStatus.

private void refreshMRStatus() {
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
        IMRProcessService mrService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
        if (mrService != null) {
            List<INode> mrNodeList = new ArrayList<INode>();
            for (Node node : nodeList) {
                if (node.isMapReduceStart() && !mrNodeList.contains(node)) {
                    mrNodeList.add(node);
                }
            }
            mrService.refreshMRStatus(mrNodeList);
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) IMRProcessService(org.talend.core.service.IMRProcessService) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList)

Example 2 with IMRProcessService

use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.

the class UpdateCheckResult method getCategory.

@Override
@SuppressWarnings("unchecked")
public String getCategory() {
    String category = null;
    if (getUpdateType() instanceof EUpdateItemType) {
        switch((EUpdateItemType) getUpdateType()) {
            case NODE_PROPERTY:
            case NODE_SCHEMA:
            case NODE_QUERY:
            case NODE_VALIDATION_RULE:
            case JOBLET_SCHEMA:
                if (getUpdateObject() != null) {
                    if (getUpdateObject() instanceof Node) {
                        Node node = (Node) getUpdateObject();
                        if (node.getUniqueName().equals(node.getLabel())) {
                            category = node.getUniqueName();
                        } else {
                            category = node.getLabel() + UpdateManagerUtils.addBrackets(node.getUniqueName());
                        }
                    }
                    if (getUpdateObject() instanceof NodeType) {
                        NodeType node = (NodeType) getUpdateObject();
                        String uniqueName = null;
                        for (ElementParameterType param : (List<ElementParameterType>) node.getElementParameter()) {
                            if (EParameterName.UNIQUE_NAME.getName().equals(param.getName())) {
                                uniqueName = param.getValue();
                                break;
                            }
                        }
                        if (uniqueName != null) {
                            category = uniqueName;
                        }
                    }
                }
                break;
            case JOB_PROPERTY_EXTRA:
            case JOB_PROPERTY_STATS_LOGS:
            case JOB_PROPERTY_HEADERFOOTER:
            case JOB_PROPERTY_MAPREDUCE:
                boolean isJoblet = false;
                boolean isMR = false;
                if (getUpdateObject() != null) {
                    if (getUpdateObject() instanceof org.talend.designer.core.ui.editor.process.Process) {
                        if (AbstractProcessProvider.isExtensionProcessForJoblet((IProcess) getUpdateObject())) {
                            isJoblet = true;
                        } else if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
                            IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
                            org.talend.core.model.properties.Item item = ((org.talend.designer.core.ui.editor.process.Process) getUpdateObject()).getProperty().getItem();
                            isMR = mrProcessService.isMapReduceItem(item);
                        }
                    }
                }
                if (isMR) {
                    //
                    category = JobSettingsView.VIEW_NAME_BATCH;
                } else if (isJoblet) {
                    // joblet
                    category = JobSettingsView.VIEW_NAME_JOBLET;
                } else {
                    category = JobSettingsView.getViewNameLable();
                }
                break;
            case JOB_PROPERTY_STORM:
                boolean isStreaming = false;
                if (getUpdateObject() != null && getUpdateObject() instanceof org.talend.designer.core.ui.editor.process.Process) {
                    if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
                        IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
                        org.talend.core.model.properties.Item item = ((org.talend.designer.core.ui.editor.process.Process) getUpdateObject()).getProperty().getItem();
                        isStreaming = streamingService.isStormItem(item);
                    }
                }
                if (isStreaming) {
                    //
                    category = JobSettingsView.VIEW_NAME_STREAMING;
                } else {
                    category = JobSettingsView.getViewNameLable();
                }
                break;
            case CONTEXT:
                // case JOBLET_CONTEXT:
                category = UpdatesConstants.CONTEXT;
                break;
            case CONTEXT_GROUP:
                category = UpdatesConstants.CONTEXT_GROUP;
                break;
            case JOBLET_RENAMED:
            case RELOAD:
            case JUNIT_RELOAD:
                if (getUpdateObject() != null && getUpdateObject() instanceof List) {
                    String display = UpdateManagerHelper.getCollectionsDisplay(getUpdateObject(), true);
                    if (display != null) {
                        category = display;
                    }
                } else if (getParameter() != null && getParameter() instanceof PropertyChangeEvent) {
                    PropertyChangeEvent event = (PropertyChangeEvent) getParameter();
                    // reload all compoennts.
                    if (event.getSource() != null && !(event.getSource() instanceof IProcess)) {
                        category = UpdatesConstants.COMPONENT;
                        break;
                    }
                } else {
                    category = UpdatesConstants.JOBLET;
                }
                break;
            default:
        }
    } else {
        category = UpdateManagerProviderDetector.INSTANCE.getDisplayCategory(this);
    }
    return category == null ? UpdatesConstants.EMPTY : category;
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) IMRProcessService(org.talend.core.service.IMRProcessService) Item(org.talend.core.model.properties.Item) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) IStormProcessService(org.talend.core.service.IStormProcessService) IProcess(org.talend.core.model.process.IProcess) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) Item(org.talend.core.model.properties.Item) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) List(java.util.List) IProcess(org.talend.core.model.process.IProcess)

Example 3 with IMRProcessService

use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.

the class UpdateContentProvider method getElements.

@Override
@SuppressWarnings("unchecked")
public Object[] getElements(Object inputElement) {
    List<Job> jobs = new ArrayList<Job>();
    if (inputElement instanceof Collection) {
        for (UpdateResult result : (List<UpdateResult>) inputElement) {
            String jobName = result.getJobInfor();
            if (jobName == null) {
                jobName = UpdatesConstants.EMPTY;
            }
            Job job = getJob(jobs, jobName);
            if (job == null) {
                job = new Job(jobName);
                Object job2 = result.getJob();
                if (job2 != null) {
                    if (job2 instanceof IProcess2) {
                        // ?? joblet
                        job.setJoblet(((IProcess2) job2).disableRunJobView());
                        job.setReadOnlyProcess(result.isReadOnlyProcess());
                        IProcess2 process = (IProcess2) job2;
                        org.talend.core.model.properties.Item processItem = process.getProperty().getItem();
                        job.setModelItem(processItem);
                        boolean isMRProcess = false;
                        if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
                            IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
                            isMRProcess = mrProcessService.isMapReduceItem(processItem);
                        }
                        boolean isStreamingProcess = false;
                        if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
                            IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
                            isStreamingProcess = streamingService.isStormItem(processItem);
                        }
                        if (isMRProcess) {
                            job.setMR(isMRProcess);
                        } else if (isStreamingProcess) {
                            job.setStreaming(isStreamingProcess);
                        } else if (processItem instanceof ProcessItem) {
                            job.setJoblet(false);
                            job.setMR(false);
                            job.setStreaming(false);
                            job.setSparkJoblet(false);
                            job.setSparkStreamingJoblet(false);
                        } else if (processItem instanceof JobletProcessItem) {
                            boolean isSpark = false;
                            boolean isSparkStreaming = false;
                            if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkJobletProviderService.class)) {
                                ISparkJobletProviderService sparkJobletService = (ISparkJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkJobletProviderService.class);
                                if (sparkJobletService != null && sparkJobletService.isSparkJobletItem(processItem)) {
                                    isSpark = true;
                                }
                            }
                            if (GlobalServiceRegister.getDefault().isServiceRegistered(ISparkStreamingJobletProviderService.class)) {
                                ISparkStreamingJobletProviderService sparkStreamingJobletService = (ISparkStreamingJobletProviderService) GlobalServiceRegister.getDefault().getService(ISparkStreamingJobletProviderService.class);
                                if (sparkStreamingJobletService != null && sparkStreamingJobletService.isSparkStreamingJobletItem(processItem)) {
                                    isSparkStreaming = true;
                                }
                            }
                            if (isSpark) {
                                job.setSparkJoblet(true);
                                job.setJoblet(false);
                            } else if (isSparkStreaming) {
                                job.setSparkStreamingJoblet(true);
                                job.setJoblet(false);
                            } else {
                                job.setJoblet(true);
                            }
                        }
                    }
                } else {
                    String itemId = result.getObjectId();
                    if (itemId != null) {
                        IProxyRepositoryFactory factory = ProxyRepositoryFactory.getInstance();
                        try {
                            IRepositoryViewObject repoViewObject = factory.getLastVersion(itemId);
                            if (repoViewObject != null) {
                                Property property = repoViewObject.getProperty();
                                if (property != null) {
                                    job.setModelItem(property.getItem());
                                }
                            }
                        } catch (PersistenceException e) {
                            CommonExceptionHandler.process(e, Priority.WARN);
                        }
                    }
                    job.setJoblet(result.isJoblet());
                    job.setMR(result.isMR());
                    job.setStreaming(result.isStreaming());
                    job.setSparkJoblet(result.isSparkJoblet());
                    job.setSparkStreamingJoblet(result.isSparkStreamingJoblet());
                }
                jobs.add(job);
            }
            Category category = job.getCategory(result.getCategory());
            if (category == null) {
                category = new Category(job, result.getCategory());
                // for icon
                category.setType(result.getUpdateType());
                if (result.getUpdateObject() instanceof Node) {
                    // for node icon
                    category.setNode(result.getUpdateObject());
                }
                if (result.getUpdateObject() instanceof NodeType) {
                    // for node icon
                    category.setNode(result.getUpdateObject());
                }
                if (result.getUpdateObject() instanceof List) {
                    // for node icon
                    List list = (List) result.getUpdateObject();
                    if (list.size() > 0) {
                        Object object = list.get(0);
                        if (object instanceof Node) {
                            category.setNode(object);
                        }
                    }
                }
                job.addCategory(category);
            }
            Item item = new Item(category, result);
            category.addItem(item);
        }
    }
    return jobs.toArray();
}
Also used : IMRProcessService(org.talend.core.service.IMRProcessService) IStormProcessService(org.talend.core.service.IStormProcessService) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ArrayList(java.util.ArrayList) List(java.util.List) Property(org.talend.core.model.properties.Property) UpdateResult(org.talend.core.model.update.UpdateResult) IProxyRepositoryFactory(org.talend.repository.model.IProxyRepositoryFactory) ISparkJobletProviderService(org.talend.core.ui.ISparkJobletProviderService) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ISparkStreamingJobletProviderService(org.talend.core.ui.ISparkStreamingJobletProviderService) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) PersistenceException(org.talend.commons.exception.PersistenceException) Collection(java.util.Collection) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Example 4 with IMRProcessService

use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.

the class HTMLDocGenerator method handleXMLFile.

/**
     * Generates the xml file base on an instance of <code>ExportFileResource</code> and the temporary folder path.
     * 
     * @param resource
     * @param tempFolderPath
     * @param version
     */
private void handleXMLFile(ExportFileResource resource, String tempFolderPath, String... version) throws Exception {
    Item item = resource.getItem();
    // Check if generate Job Extra / Stats&Logs Setting Info
    if (item instanceof ProcessItem) {
        if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
            IMRProcessService mrProcessService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
            generateExtraSetting = !mrProcessService.isMapReduceItem(item);
            generateStatsLogsSetting = generateExtraSetting;
        } else if (isRouteProcess(item)) {
            generateStatsLogsSetting = generateExtraSetting = !isRouteProcess(item);
        }
    } else if (item instanceof JobletProcessItem) {
        generateStatsLogsSetting = false;
    }
    targetConnectionMap = new HashMap<String, List>();
    sourceConnectionMap = new HashMap<String, List>();
    getSourceAndTargetConnection(item);
    Document document = DocumentHelper.createDocument();
    Element projectElement = generateProjectInfo(document);
    Element jobElement = generateJobInfo(item, projectElement, version);
    // This two element see feature 4162
    generateContextInfo(item, jobElement);
    generateJobSettingInfo(item, jobElement);
    List<List> allList = seperateNodes(item);
    if (allList == null || allList.size() != 3) {
        return;
    }
    List<INode> allComponentsList = allList.get(0);
    List<INode> internalNodeComponentsList = allList.get(1);
    List<INode> externalNodeComponentsList = allList.get(2);
    if (allComponentsList.size() > 0) {
        // Generates information for 'Component List' part in exported HTML file.
        generateAllComponentsSummaryInfo(item, jobElement, allComponentsList);
    }
    //$NON-NLS-1$
    Element internalNodeElement = jobElement.addElement("internalNodeComponents");
    //$NON-NLS-1$
    Element externalNodeElement = jobElement.addElement("externalNodeComponents");
    if (internalNodeComponentsList.size() > 0) {
        InternalNodeComponentHandler internalNodeComponentHandler = new InternalNodeComponentHandler(this.picFilePathMap, internalNodeElement, internalNodeComponentsList, this.sourceConnectionMap, this.targetConnectionMap, this.designerCoreService, this.repositoryConnectionItemMap, this.repositoryDBIdAndNameMap, externalNodeHTMLMap);
        // Generates internal node components information.
        internalNodeComponentHandler.generateComponentInfo();
    }
    if (externalNodeComponentsList.size() > 0) {
        ExternalNodeComponentHandler externalNodeComponentHandler = new ExternalNodeComponentHandler(this.picFilePathMap, externalNodeElement, externalNodeComponentsList, this.sourceConnectionMap, this.targetConnectionMap, this.designerCoreService, this.repositoryConnectionItemMap, this.repositoryDBIdAndNameMap, externalNodeHTMLMap);
        // Generates external node components(tMap etc.) information.
        externalNodeComponentHandler.generateComponentInfo();
    }
    // Generates all connection information(include internal node and external node).
    EList connectionList = null;
    if (item instanceof ProcessItem) {
        connectionList = ((ProcessItem) item).getProcess().getConnection();
    } else if (item instanceof JobletProcessItem) {
        connectionList = (((JobletProcessItem) item).getJobletProcess().getConnection());
    }
    if (connectionList != null && connectionList.size() != 0) {
        generateConnectionsInfo(jobElement, connectionList);
    }
    //$NON-NLS-1$
    String versionPath = "_";
    if (version != null && version.length == 1) {
        versionPath = versionPath + version[0];
    } else {
        versionPath = versionPath + item.getProperty().getVersion();
    }
    String filePath = tempFolderPath + File.separatorChar + item.getProperty().getLabel() + versionPath + IHTMLDocConstants.XML_FILE_SUFFIX;
    // This element see feature 4382
    if (item instanceof ProcessItem) {
        generateSourceCodeInfo((ProcessItem) item, jobElement);
    }
    XMLHandler.generateXMLFile(tempFolderPath, filePath, document);
}
Also used : INode(org.talend.core.model.process.INode) InternalNodeComponentHandler(org.talend.core.ui.documentation.generation.InternalNodeComponentHandler) IMRProcessService(org.talend.core.service.IMRProcessService) Element(org.dom4j.Element) Document(org.dom4j.Document) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) ProcessItem(org.talend.core.model.properties.ProcessItem) ContextItem(org.talend.core.model.properties.ContextItem) Item(org.talend.core.model.properties.Item) EList(org.eclipse.emf.common.util.EList) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ProcessItem(org.talend.core.model.properties.ProcessItem) JobletProcessItem(org.talend.core.model.properties.JobletProcessItem) ExternalNodeComponentHandler(org.talend.core.ui.documentation.generation.ExternalNodeComponentHandler) CSSRuleList(org.w3c.dom.css.CSSRuleList) ArrayList(java.util.ArrayList) List(java.util.List) NodeList(org.w3c.dom.NodeList) EList(org.eclipse.emf.common.util.EList)

Example 5 with IMRProcessService

use of org.talend.core.service.IMRProcessService in project tdi-studio-se by Talend.

the class ChangeActivateStatusSubjobCommand method refreshMRStatus.

private void refreshMRStatus() {
    Process process = (Process) node.getProcess();
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
        IMRProcessService mrService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
        if (mrService != null) {
            List<INode> mrNodeList = new ArrayList<INode>();
            for (INode node : process.getGraphicalNodes()) {
                if ((((Node) node).isMapReduceStart()) && !mrNodeList.contains(node)) {
                    mrNodeList.add(node);
                }
            }
            mrService.refreshMRStatus(mrNodeList);
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) IMRProcessService(org.talend.core.service.IMRProcessService) INode(org.talend.core.model.process.INode) Node(org.talend.designer.core.ui.editor.nodes.Node) ArrayList(java.util.ArrayList) Process(org.talend.designer.core.ui.editor.process.Process)

Aggregations

IMRProcessService (org.talend.core.service.IMRProcessService)8 INode (org.talend.core.model.process.INode)5 IStormProcessService (org.talend.core.service.IStormProcessService)5 Node (org.talend.designer.core.ui.editor.nodes.Node)5 ArrayList (java.util.ArrayList)4 Item (org.talend.core.model.properties.Item)4 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)4 ProcessItem (org.talend.core.model.properties.ProcessItem)4 List (java.util.List)3 IProcess2 (org.talend.core.model.process.IProcess2)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)3 PersistenceException (org.talend.commons.exception.PersistenceException)2 Property (org.talend.core.model.properties.Property)2 ElementParameterType (org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 Collection (java.util.Collection)1 Document (org.dom4j.Document)1 Element (org.dom4j.Element)1 CoreException (org.eclipse.core.runtime.CoreException)1