Search in sources :

Example 1 with UpdateResult

use of org.talend.core.model.update.UpdateResult in project tdi-studio-se by Talend.

the class UpdateManagerUtils method refreshRelatedViewers.

/**
     * 
     * ggu Comment method "refreshViewers".
     */
@SuppressWarnings("unchecked")
private static void refreshRelatedViewers(List results) {
    boolean context = false;
    boolean jobSetting = false;
    boolean componentSettings = false;
    boolean palette = false;
    for (UpdateResult result : (List<UpdateResult>) results) {
        // if (!result.isChecked()) {
        // continue;
        // }
        IUpdateItemType updateType = result.getUpdateType();
        if (updateType != null) {
            if (EUpdateItemType.CONTEXT.equals(updateType)) {
                if (result.isJoblet() && !result.isChecked()) {
                    continue;
                }
                context = true;
            } else if (EUpdateItemType.JOB_PROPERTY_EXTRA.equals(updateType) || EUpdateItemType.JOB_PROPERTY_STATS_LOGS.equals(updateType) || EUpdateItemType.JOB_PROPERTY_HEADERFOOTER.equals(updateType)) {
                jobSetting = true;
            } else if (EUpdateItemType.NODE_PROPERTY.equals(updateType) || EUpdateItemType.NODE_QUERY.equals(updateType) || EUpdateItemType.NODE_SCHEMA.equals(updateType)) {
                componentSettings = true;
            } else if (EUpdateItemType.RELOAD.equals(updateType) || EUpdateItemType.JOBLET_RENAMED.equals(updateType) || EUpdateItemType.JOBLET_SCHEMA.equals(updateType)) {
                if (result.isJoblet() && !result.isChecked()) {
                    continue;
                }
                palette = true;
            }
        }
    }
    // recheck from the providers
    Set<String> viewIds = UpdateManagerProviderDetector.INSTANCE.needRefreshRelatedViews(results);
    // context
    if (!context) {
        context = viewIds.contains(AbstractContextView.CTX_ID_DESIGNER);
    }
    if (context) {
        Contexts.switchToCurContextsView();
    }
    // jobsetting
    if (!jobSetting) {
        jobSetting = viewIds.contains(JobSettingsView.ID);
    }
    if (jobSetting) {
        JobSettings.switchToCurJobSettingsView();
    }
    // component setting
    if (!componentSettings) {
        componentSettings = viewIds.contains(ComponentSettingsView.ID);
    }
    if (componentSettings) {
        ComponentSettings.switchToCurComponentSettingsView();
    }
    // }
    if (palette) {
        ComponentPaletteUtilities.updatePalette();
    }
}
Also used : List(java.util.List) ArrayList(java.util.ArrayList) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) UpdateResult(org.talend.core.model.update.UpdateResult)

Example 2 with UpdateResult

use of org.talend.core.model.update.UpdateResult in project tdi-studio-se by Talend.

the class UpdateViewerHelper method checkUpdateStatus.

public void checkUpdateStatus() {
    List<UpdateResult> inputElements = updateDialog.getInputElements();
    if (inputElements != null) {
        for (UpdateResult result : inputElements) {
            if (result.isReadOnlyProcess()) {
                updateDialog.updateReadOnlyJobWarnMessage();
                return;
            }
            if (!result.isChecked() && (result.getResultType() == EUpdateResult.UPDATE || result.getResultType() == EUpdateResult.DELETE)) {
                updateDialog.updateWarnMessage();
                return;
            }
        }
    }
    updateDialog.updateNomarlMessage();
}
Also used : EUpdateResult(org.talend.core.model.update.EUpdateResult) UpdateResult(org.talend.core.model.update.UpdateResult)

Example 3 with UpdateResult

use of org.talend.core.model.update.UpdateResult in project tdi-studio-se by Talend.

the class UpdateViewerHelper method refreshSelectButton.

/**
     * 
     * ggu Comment method "refreshSelectButton".
     * 
     * refresh the label of select button.
     */
@SuppressWarnings("restriction")
public void refreshSelectButton() {
    List<UpdateResult> inputElements = updateDialog.getInputElements();
    if (inputElements == null) {
        return;
    }
    int num = 0;
    for (UpdateResult result : inputElements) {
        if (result.isChecked()) {
            num++;
        }
    }
    if (num == inputElements.size()) {
        // updateDialog.setSelectButtonLabel(WorkbenchMessages.SelectionDialog_deselectLabel);
        //$NON-NLS-1$
        updateDialog.setSelectButtonLabel(Messages.getString("WorkbenchMessages.SelectionDialog_deselectLabel"));
    } else {
        // updateDialog.setSelectButtonLabel(WorkbenchMessages.SelectionDialog_selectLabel);
        //$NON-NLS-1$
        updateDialog.setSelectButtonLabel(Messages.getString("WorkbenchMessages.SelectionDialog_selectLabel"));
    }
}
Also used : EUpdateResult(org.talend.core.model.update.EUpdateResult) UpdateResult(org.talend.core.model.update.UpdateResult)

Example 4 with UpdateResult

use of org.talend.core.model.update.UpdateResult 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 5 with UpdateResult

use of org.talend.core.model.update.UpdateResult in project tdi-studio-se by Talend.

the class RepositoryUpdateTest method launchRepositoryUpdateOnNode.

/**
     * DOC nrousseau Comment method "updateNode".
     * @param id
     * @param process
     * @param node
     * @throws PersistenceException
     */
private void launchRepositoryUpdateOnNode(String id, Process process, Node node) throws PersistenceException {
    GenericConnectionItem connectionItem;
    IRepositoryViewObject object;
    object = ProxyRepositoryFactory.getInstance().getLastVersion(id);
    connectionItem = (GenericConnectionItem) object.getProperty().getItem();
    Assert.assertEquals(1, SchemaUtils.getMetadataTables(connectionItem.getConnection(), SubContainer.class).size());
    UpdateResult ur = createUpdateResult(node);
    ur.setResult(EUpdateItemType.NODE_PROPERTY, EUpdateResult.UPDATE, connectionItem);
    ur.setJob(process);
    UpdateNodeParameterCommand cmd = new UpdateNodeParameterCommand(ur);
    cmd.execute();
}
Also used : UpdateNodeParameterCommand(org.talend.designer.core.ui.editor.update.cmd.UpdateNodeParameterCommand) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) GenericConnectionItem(org.talend.repository.generic.model.genericMetadata.GenericConnectionItem) UpdateResult(org.talend.core.model.update.UpdateResult) EUpdateResult(org.talend.core.model.update.EUpdateResult)

Aggregations

UpdateResult (org.talend.core.model.update.UpdateResult)10 EUpdateResult (org.talend.core.model.update.EUpdateResult)5 ArrayList (java.util.ArrayList)4 List (java.util.List)4 IProcess2 (org.talend.core.model.process.IProcess2)4 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 HashMap (java.util.HashMap)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 JobletProcessItem (org.talend.core.model.properties.JobletProcessItem)2 ProcessItem (org.talend.core.model.properties.ProcessItem)2 IUpdateItemType (org.talend.core.model.update.IUpdateItemType)2 IOException (java.io.IOException)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IWorkspaceRunnable (org.eclipse.core.resources.IWorkspaceRunnable)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1