Search in sources :

Example 1 with IStormProcessService

use of org.talend.core.service.IStormProcessService 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 2 with IStormProcessService

use of org.talend.core.service.IStormProcessService 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 3 with IStormProcessService

use of org.talend.core.service.IStormProcessService 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 4 with IStormProcessService

use of org.talend.core.service.IStormProcessService 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 5 with IStormProcessService

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

the class JavaProcessorUtilities method hasBatchOrStreamingSubProcess.

public static boolean hasBatchOrStreamingSubProcess(Item item, Set<String> testedItems) throws PersistenceException {
    if (testedItems.contains(item.getProperty().getId())) {
        return false;
    }
    testedItems.add(item.getProperty().getId());
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class)) {
        IMRProcessService batchService = (IMRProcessService) GlobalServiceRegister.getDefault().getService(IMRProcessService.class);
        if (batchService.isMapReduceItem(item)) {
            return true;
        }
    }
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
        IStormProcessService streamingService = (IStormProcessService) GlobalServiceRegister.getDefault().getService(IStormProcessService.class);
        if (streamingService.isStormItem(item)) {
            return true;
        }
    }
    if (GlobalServiceRegister.getDefault().isServiceRegistered(IMRProcessService.class) || GlobalServiceRegister.getDefault().isServiceRegistered(IStormProcessService.class)) {
        if (item != null && item.eClass() == PropertiesPackage.Literals.PROCESS_ITEM) {
            ProcessType processType = ((ProcessItem) item).getProcess();
            EList<NodeType> nodes = processType.getNode();
            for (NodeType node : nodes) {
                if ("tRunJob".equals(node.getComponentName())) {
                    //$NON-NLS-1$
                    EList<ElementParameterType> elementParameters = node.getElementParameter();
                    for (ElementParameterType param : elementParameters) {
                        if (param.getName() != null && "PROCESS:PROCESS_TYPE_PROCESS".equals(param.getName())) {
                            //$NON-NLS-1$
                            Object value = param.getValue();
                            if (value != null && !"".equals(value)) {
                                //$NON-NLS-1$
                                IRepositoryViewObject lastVersion = RunProcessPlugin.getDefault().getRepositoryService().getProxyRepositoryFactory().getLastVersion(value.toString());
                                if (lastVersion != null) {
                                    boolean hasBatchOrStreaming = hasBatchOrStreamingSubProcess(lastVersion.getProperty().getItem(), testedItems);
                                    if (hasBatchOrStreaming) {
                                        // only stop the loop once we checked every child
                                        return hasBatchOrStreaming;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    return false;
}
Also used : ElementParameterType(org.talend.designer.core.model.utils.emf.talendfile.ElementParameterType) ProcessType(org.talend.designer.core.model.utils.emf.talendfile.ProcessType) ProcessItem(org.talend.core.model.properties.ProcessItem) IMRProcessService(org.talend.core.service.IMRProcessService) IStormProcessService(org.talend.core.service.IStormProcessService) NodeType(org.talend.designer.core.model.utils.emf.talendfile.NodeType) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject)

Aggregations

IMRProcessService (org.talend.core.service.IMRProcessService)5 IStormProcessService (org.talend.core.service.IStormProcessService)5 IProcess2 (org.talend.core.model.process.IProcess2)3 Item (org.talend.core.model.properties.Item)3 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)3 ProcessItem (org.talend.core.model.properties.ProcessItem)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 NodeType (org.talend.designer.core.model.utils.emf.talendfile.NodeType)3 Node (org.talend.designer.core.ui.editor.nodes.Node)3 List (java.util.List)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 INode (org.talend.core.model.process.INode)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 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 CoreException (org.eclipse.core.runtime.CoreException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1