Search in sources :

Example 1 with EUpdateItemType

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

the class UpdateNodeParameterCommand method execute.

@Override
public void execute() {
    if (result == null) {
        return;
    }
    Object updateObject = result.getUpdateObject();
    if (updateObject == null || (!(updateObject instanceof Node)) || (!(result.getJob() instanceof IProcess))) {
        return;
    }
    // instance of node before might not be good (loaded while check updates needed)
    // so get the instance of the node of the current job in this object.
    IProcess process = (IProcess) result.getJob();
    for (INode node : process.getGraphicalNodes()) {
        if (node.getUniqueName().equals(((Node) updateObject).getUniqueName())) {
            updateObject = node;
            result.setUpdateObject(updateObject);
            break;
        }
    }
    IUpdateItemType updateType = result.getUpdateType();
    if (updateType instanceof EUpdateItemType) {
        switch((EUpdateItemType) updateType) {
            case NODE_PROPERTY:
                updateProperty();
                break;
            case NODE_SCHEMA:
                updateSchema();
                break;
            case NODE_QUERY:
                updateQuery();
                break;
            case NODE_SAP_FUNCTION:
                updateSAPParameters();
                break;
            case NODE_SAP_IDOC:
                updateSAPIDocParameters();
                break;
            case NODE_VALIDATION_RULE:
                updateValidationRule();
                break;
            default:
                return;
        }
    }
    // else { // for extension
    Node node = (Node) updateObject;
    if (node.getProcess() instanceof IProcess2) {
        PropertyChangeCommand pcc = new PropertyChangeCommand(node, EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
        boolean executed = false;
        if (process instanceof IGEFProcess) {
            IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
            if (designerCoreUIService != null) {
                executed = designerCoreUIService.executeCommand((IGEFProcess) process, pcc);
            }
        }
        if (!executed) {
            pcc.execute();
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) PropertyChangeCommand(org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand) Node(org.talend.designer.core.ui.editor.nodes.Node) IExternalNode(org.talend.core.model.process.IExternalNode) INode(org.talend.core.model.process.INode) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) IDesignerCoreUIService(org.talend.core.ui.services.IDesignerCoreUIService) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) IProcess(org.talend.core.model.process.IProcess) IGEFProcess(org.talend.core.ui.process.IGEFProcess)

Example 2 with EUpdateItemType

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

the class UpdateJobletNodeCommand method execute.

/**
     * this function is moved from the method updateGraphicalNodes.
     */
@SuppressWarnings("unchecked")
@Override
public void execute() {
    Object job = result.getJob();
    if (job == null) {
        return;
    }
    if (job instanceof Process) {
        Process process = (Process) job;
        Object parameter = result.getParameter();
        // update property change events
        if (parameter instanceof PropertyChangeEvent) {
            PropertyChangeEvent evt = (PropertyChangeEvent) parameter;
            updatePropertyChangeEvents(process, evt);
        } else {
            //
            IUpdateItemType updateType = result.getUpdateType();
            if (updateType instanceof EUpdateItemType) {
                switch((EUpdateItemType) updateType) {
                    case JOBLET_RENAMED:
                        if (!(parameter instanceof List)) {
                            return;
                        }
                        List<Object> params = (List<Object>) parameter;
                        if (params.size() != 3) {
                            return;
                        }
                        final String oldName = (String) params.get(1);
                        final String newName = (String) params.get(2);
                        updateRenaming(process, oldName, newName);
                        break;
                    case RELOAD:
                        List<Node> jobletNodes = (List<Node>) result.getUpdateObject();
                        if (jobletNodes != null && !jobletNodes.isEmpty()) {
                            for (Node node : jobletNodes) {
                                IComponent newComponent = ComponentsFactoryProvider.getInstance().get(node.getComponent().getName(), process.getComponentsType());
                                if (newComponent == null) {
                                    continue;
                                }
                                // node loaded is from loading in the check.
                                // need to get the instance from process, or this process will be done with wrong
                                // instance
                                // of node.
                                Node currentNode = getOriginalNodeFromProcess(node);
                                boolean neesPro = needPropagate(currentNode);
                                if (currentNode.isJoblet() || currentNode.isMapReduce()) {
                                    // maybe no need modify
                                    List<IElementParameter> tempList = new ArrayList<IElementParameter>(currentNode.getElementParameters());
                                    if (result.isNeedReloadJoblet()) {
                                        reloadNode(currentNode, newComponent);
                                    }
                                    if (currentNode.getNodeContainer() instanceof AbstractJobletContainer) {
                                        for (IElementParameter para : tempList) {
                                            currentNode.getElementParameter(para.getName()).setValue(para.getValue());
                                        }
                                        ((AbstractJobletContainer) currentNode.getNodeContainer()).updateJobletNodes(true);
                                    }
                                } else {
                                    reloadNode(currentNode, newComponent);
                                }
                                propagate(currentNode, neesPro);
                            }
                            process.checkProcess();
                        }
                        break;
                    case JOBLET_SCHEMA:
                        updateSchema(process, (Node) result.getUpdateObject());
                        break;
                    default:
                }
            }
        // else { // for extension
        }
    }
}
Also used : PropertyChangeEvent(java.beans.PropertyChangeEvent) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) IProcess(org.talend.core.model.process.IProcess) Process(org.talend.designer.core.ui.editor.process.Process) AbstractJobletContainer(org.talend.designer.core.ui.editor.jobletcontainer.AbstractJobletContainer) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) IElementParameter(org.talend.core.model.process.IElementParameter) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with EUpdateItemType

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

the class UpdateMainParameterCommand method execute.

@Override
public void execute() {
    if (result == null) {
        return;
    }
    Object job = result.getJob();
    if (job == null) {
        return;
    }
    if (job instanceof IProcess2) {
        Process process = (Process) job;
        EComponentCategory category = null;
        IUpdateItemType updateType = result.getUpdateType();
        if (updateType instanceof EUpdateItemType) {
            switch((EUpdateItemType) updateType) {
                case JOB_PROPERTY_EXTRA:
                    category = EComponentCategory.EXTRA;
                    break;
                case JOB_PROPERTY_STATS_LOGS:
                    category = EComponentCategory.STATSANDLOGS;
                    break;
                case JOB_PROPERTY_HEADERFOOTER:
                    category = EComponentCategory.HEADERFOOTER;
                    break;
                case JOB_PROPERTY_STORM:
                    if (ComponentCategory.CATEGORY_4_SPARKSTREAMING.getName().equals(process.getComponentsType())) {
                        category = EComponentCategory.SPARK_JOB_CONFIG;
                    }
                    break;
                case JOB_PROPERTY_MAPREDUCE:
                    if (ComponentCategory.CATEGORY_4_MAPREDUCE.getName().equals(process.getComponentsType())) {
                        category = EComponentCategory.MAPREDUCE_JOB_CONFIG_FOR_HADOOP;
                    } else if (ComponentCategory.CATEGORY_4_SPARK.getName().equals(process.getComponentsType())) {
                        category = EComponentCategory.SPARK_JOB_CONFIG;
                    }
                    break;
                default:
            }
            if (category == EComponentCategory.HEADERFOOTER) {
                if (result.getResultType() == EUpdateResult.UPDATE) {
                    if (result.isChecked()) {
                        for (IElementParameter param : process.getElementParameters()) {
                            if (param.getCategory() == EComponentCategory.HEADERFOOTER) {
                                IElementParameter headerIDParameter = process.getElementParameter(EParameterName.HEADERFOOTER_HEADERID.getName());
                                if (headerIDParameter != null) {
                                    IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById((String) headerIDParameter.getValue());
                                    HeaderFooterConnection repositoryConnection = null;
                                    if (lastVersion != null) {
                                        final Item item = lastVersion.getProperty().getItem();
                                        if (item != null && item instanceof ConnectionItem) {
                                            repositoryConnection = (HeaderFooterConnection) ((HeaderFooterConnectionItem) item).getConnection();
                                            if (repositoryConnection != null) {
                                                Boolean isHeader = repositoryConnection.isIsHeader();
                                                String libraries = repositoryConnection.getLibraries();
                                                String mainCode = repositoryConnection.getMainCode();
                                                String imports = repositoryConnection.getImports();
                                                process.getElementParameter(EParameterName.HEADER_ENABLED.getName()).setValue(isHeader);
                                                process.getElementParameter(EParameterName.HEADER_LIBRARY.getName()).setValue(libraries);
                                                process.getElementParameter(EParameterName.HEADER_CODE.getName()).setValue(mainCode);
                                                process.getElementParameter(EParameterName.HEADER_IMPORT.getName()).setValue(imports);
                                            }
                                        }
                                    }
                                }
                                IElementParameter footerIDParameter = process.getElementParameter(EParameterName.HEADERFOOTER_FOOTERID.getName());
                                if (footerIDParameter != null) {
                                    IRepositoryViewObject lastVersion = UpdateRepositoryUtils.getRepositoryObjectById((String) footerIDParameter.getValue());
                                    HeaderFooterConnection repositoryConnection = null;
                                    if (lastVersion != null) {
                                        final Item item = lastVersion.getProperty().getItem();
                                        if (item != null && item instanceof ConnectionItem) {
                                            repositoryConnection = (HeaderFooterConnection) ((HeaderFooterConnectionItem) item).getConnection();
                                            if (repositoryConnection != null) {
                                                Boolean isHeader = repositoryConnection.isIsHeader();
                                                String libraries = repositoryConnection.getLibraries();
                                                String mainCode = repositoryConnection.getMainCode();
                                                String imports = repositoryConnection.getImports();
                                                process.getElementParameter(EParameterName.FOOTER_ENABLED.getName()).setValue(!isHeader);
                                                process.getElementParameter(EParameterName.FOOTER_LIBRARY.getName()).setValue(libraries);
                                                process.getElementParameter(EParameterName.FOOTER_CODE.getName()).setValue(mainCode);
                                                process.getElementParameter(EParameterName.FOOTER_IMPORT.getName()).setValue(imports);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            } else if (category != null) {
                boolean repository = false;
                if (result.getResultType() == EUpdateResult.UPDATE) {
                    // upgrade from repository
                    if (result.isChecked()) {
                        IElementParameter property = process.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, category);
                        if (property != null) {
                            Map<String, IElementParameter> childParameters = property.getChildParameters();
                            if (childParameters != null) {
                                IElementParameter elementParameter = childParameters.get(EParameterName.PROPERTY_TYPE.getName());
                                // is repository
                                if (elementParameter != null && EmfComponent.REPOSITORY.equals(elementParameter.getValue())) {
                                    for (IElementParameter param : process.getElementParameters()) {
                                        if (param.getCategory() != category) {
                                            continue;
                                        }
                                        String repositoryValue = param.getRepositoryValue();
                                        if (param.isShow(process.getElementParameters()) && (repositoryValue != null) && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName()))) {
                                            Object objectValue = RepositoryToComponentProperty.getValue((org.talend.core.model.metadata.builder.connection.Connection) result.getParameter(), repositoryValue, null);
                                            if (objectValue != null) {
                                                if (param.getFieldType().equals(EParameterFieldType.CLOSED_LIST) && repositoryValue.equals(UpdatesConstants.TYPE)) {
                                                    boolean found = false;
                                                    String[] items = param.getListRepositoryItems();
                                                    for (int i = 0; (i < items.length) && (!found); i++) {
                                                        if (objectValue.equals(items[i])) {
                                                            found = true;
                                                            process.setPropertyValue(param.getName(), param.getListItemsValue()[i]);
                                                        }
                                                    }
                                                } else if (EParameterName.HADOOP_ADVANCED_PROPERTIES.getName().equals(param.getName()) || EParameterName.SPARK_ADVANCED_PROPERTIES.getName().equals(param.getName())) {
                                                    List<Map> list = (ArrayList) param.getValue();
                                                    for (Map map : list) {
                                                        if (map.get("BUILDIN") != null && map.get("BUILDIN").equals("TRUE")) {
                                                            if (objectValue instanceof List) {
                                                                ((List) objectValue).add(map);
                                                            }
                                                        }
                                                    }
                                                    process.setPropertyValue(param.getName(), objectValue);
                                                } else {
                                                    process.setPropertyValue(param.getName(), objectValue);
                                                }
                                                param.setRepositoryValueUsed(true);
                                                param.setReadOnly(true);
                                                repository = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                IElementParameter property = process.getElementParameterFromField(EParameterFieldType.PROPERTY_TYPE, category);
                Map<String, IElementParameter> childParameters = null;
                if (property != null) {
                    childParameters = property.getChildParameters();
                }
                if (!repository) {
                    if (childParameters != null) {
                        IElementParameter elementParameter = childParameters.get(EParameterName.PROPERTY_TYPE.getName());
                        elementParameter.setValue(EmfComponent.BUILTIN);
                    }
                    // built-in
                    IElementParameter dbTypeParam = null;
                    IElementParameter impliciteDbType = null;
                    for (IElementParameter param : process.getElementParameters()) {
                        if (param.getCategory() != category) {
                            continue;
                        }
                        String repositoryValue = param.getRepositoryValue();
                        if (param.isShow(process.getElementParameters()) && (repositoryValue != null)) {
                            // for mysql db verion
                            if (EParameterName.DB_TYPE.getName().equals(param.getName()) && "TYPE".equals(repositoryValue)) {
                                dbTypeParam = param;
                            }
                            if ("DB_TYPE_IMPLICIT_CONTEXT".equals(param.getName()) && "TYPE".equals(repositoryValue)) {
                                impliciteDbType = param;
                            }
                            if (EParameterName.DB_VERSION.getName().equals(repositoryValue) && dbTypeParam != null && dbTypeParam.getValue() != null) {
                                final int indexOfItem = dbTypeParam.getIndexOfItemFromList(dbTypeParam.getValue().toString());
                                String dbType = dbTypeParam.getListItemsDisplayCodeName()[indexOfItem];
                                setDBVersionForMysql(param, dbType);
                            } else if (EParameterName.DB_VERSION.getName().equals(repositoryValue) && impliciteDbType != null && impliciteDbType.getValue() != null) {
                                final int indexOfItem = impliciteDbType.getIndexOfItemFromList(impliciteDbType.getValue().toString());
                                String dbType = impliciteDbType.getListItemsDisplayCodeName()[indexOfItem];
                                setDBVersionForMysql(param, dbType);
                            }
                            param.setRepositoryValueUsed(false);
                            param.setReadOnly(false);
                        }
                    }
                } else {
                    if (childParameters != null) {
                        IElementParameter elementParameter = childParameters.get(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
                        ConnectionItem connItem = UpdateRepositoryUtils.getConnectionItemByItemId((String) elementParameter.getValue());
                        ConnectionContextHelper.addContextForProcessParameter(process, connItem, category, false);
                    }
                }
            }
        }
    // else { // for extension
    }
}
Also used : HeaderFooterConnectionItem(org.talend.core.model.properties.HeaderFooterConnectionItem) HeaderFooterConnectionItem(org.talend.core.model.properties.HeaderFooterConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) HeaderFooterConnection(org.talend.core.model.metadata.builder.connection.HeaderFooterConnection) ArrayList(java.util.ArrayList) Process(org.talend.designer.core.ui.editor.process.Process) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) HeaderFooterConnectionItem(org.talend.core.model.properties.HeaderFooterConnectionItem) ConnectionItem(org.talend.core.model.properties.ConnectionItem) Item(org.talend.core.model.properties.Item) IProcess2(org.talend.core.model.process.IProcess2) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IElementParameter(org.talend.core.model.process.IElementParameter) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) HeaderFooterConnection(org.talend.core.model.metadata.builder.connection.HeaderFooterConnection) ArrayList(java.util.ArrayList) List(java.util.List) Map(java.util.Map) EComponentCategory(org.talend.core.model.process.EComponentCategory)

Example 4 with EUpdateItemType

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

the class UpdateCheckResult method getName.

@Override
@SuppressWarnings("unchecked")
public String getName() {
    IUpdateItemType updateType = getUpdateType();
    String displayName = updateType.getDisplayLabel();
    if (updateType instanceof EUpdateItemType) {
        switch((EUpdateItemType) updateType) {
            case NODE_SCHEMA:
                if (getResultType() == EUpdateResult.RENAME) {
                    List<Object> param = (List<Object>) getParameter();
                    String[] oldSourceIdAndChildName = UpdateManagerUtils.getSourceIdAndChildName((String) param.get(1));
                    String[] newSourceIdAndChildName = UpdateManagerUtils.getSourceIdAndChildName((String) param.get(2));
                    String display = UpdateManagerHelper.getRenamedDisplay(oldSourceIdAndChildName[1], newSourceIdAndChildName[1]);
                    if (display != null) {
                        displayName = display;
                    }
                } else if (getResultType() == EUpdateResult.DELETE) {
                    // table delete by deselect
                    List<Object> param = (List<Object>) getParameter();
                    String tableDeleted = (String) param.get(0);
                    EUpdateResult status = (EUpdateResult) param.get(1);
                    String display = getDeleteOrReloadDisplay(tableDeleted, status);
                    if (display != null) {
                        displayName = display;
                    }
                } else if (getResultType() == EUpdateResult.RELOAD) {
                    // table reload by deselect and reselect
                    List<Object> param = (List<Object>) getParameter();
                    String tableReload = (String) param.get(0);
                    EUpdateResult status = (EUpdateResult) param.get(1);
                    String display = getDeleteOrReloadDisplay(tableReload, status);
                    if (display != null) {
                        displayName = display;
                    }
                } else {
                    if (getUpdateObject() instanceof INode && getParameter() instanceof List && PluginChecker.isEBCDICPluginLoaded()) {
                        IEBCDICProviderService service = (IEBCDICProviderService) GlobalServiceRegister.getDefault().getService(IEBCDICProviderService.class);
                        if (service != null && service.isEbcdicNode((INode) getUpdateObject())) {
                            List<Object> paramObjs = (List<Object>) getParameter();
                            if (paramObjs.size() >= 2) {
                                Object schemaName = paramObjs.get(1);
                                if (schemaName instanceof String) {
                                    displayName = displayName + UpdateManagerUtils.addBrackets((String) schemaName);
                                }
                            }
                        }
                    }
                }
                break;
            case NODE_PROPERTY:
            case NODE_QUERY:
            case JOBLET_SCHEMA:
            case NODE_VALIDATION_RULE:
                break;
            case JOB_PROPERTY_EXTRA:
                displayName = displayName + UpdateManagerUtils.addBrackets(EComponentCategory.EXTRA.getTitle());
                break;
            case JOB_PROPERTY_STATS_LOGS:
                displayName = displayName + UpdateManagerUtils.addBrackets(EComponentCategory.STATSANDLOGS.getTitle());
                break;
            case JOB_PROPERTY_HEADERFOOTER:
                displayName = displayName + UpdateManagerUtils.addBrackets(EComponentCategory.HEADERFOOTER.getTitle());
                break;
            case CONTEXT_GROUP:
                if (getUpdateObject() != null && getUpdateObject() instanceof IContext) {
                    displayName = ((IContext) getUpdateObject()).getName();
                }
                break;
            case CONTEXT:
                // case JOBLET_CONTEXT:
                {
                    String display = null;
                    switch(getResultType()) {
                        case RENAME:
                            List<Object> param = (List<Object>) getParameter();
                            display = UpdateManagerHelper.getRenamedDisplay((String) param.get(1), (String) param.get(2));
                            break;
                        default:
                            if (getUpdateObject() instanceof Collection) {
                                display = UpdateManagerHelper.getCollectionsDisplay(getUpdateObject(), false);
                            }
                            break;
                    }
                    if (display != null) {
                        displayName = display;
                    }
                    break;
                }
            case JOBLET_RENAMED:
                {
                    List<Object> param = (List<Object>) getParameter();
                    String display = UpdateManagerHelper.getRenamedDisplay((String) param.get(1), (String) param.get(2));
                    if (display != null) {
                        displayName = display;
                    }
                    break;
                }
            case RELOAD:
            case JUNIT_RELOAD:
                if (getParameter() != null && getParameter() instanceof PropertyChangeEvent) {
                    PropertyChangeEvent event = (PropertyChangeEvent) getParameter();
                    // reload all compoennts.
                    if (event.getSource() != null && !(event.getSource() instanceof IProcess)) {
                        displayName = updateType.getDisplayLabel();
                        break;
                    }
                }
                break;
            default:
        }
        return displayName;
    } else {
        return UpdateManagerProviderDetector.INSTANCE.getResultName(this);
    }
}
Also used : EUpdateResult(org.talend.core.model.update.EUpdateResult) INode(org.talend.core.model.process.INode) PropertyChangeEvent(java.beans.PropertyChangeEvent) IContext(org.talend.core.model.process.IContext) EUpdateItemType(org.talend.core.model.update.EUpdateItemType) IEBCDICProviderService(org.talend.core.service.IEBCDICProviderService) Collection(java.util.Collection) IUpdateItemType(org.talend.core.model.update.IUpdateItemType) List(java.util.List) IProcess(org.talend.core.model.process.IProcess)

Example 5 with EUpdateItemType

use of org.talend.core.model.update.EUpdateItemType 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)

Aggregations

EUpdateItemType (org.talend.core.model.update.EUpdateItemType)9 IUpdateItemType (org.talend.core.model.update.IUpdateItemType)8 List (java.util.List)6 INode (org.talend.core.model.process.INode)5 IProcess (org.talend.core.model.process.IProcess)5 Node (org.talend.designer.core.ui.editor.nodes.Node)5 IProcess2 (org.talend.core.model.process.IProcess2)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)3 IElementParameter (org.talend.core.model.process.IElementParameter)3 Item (org.talend.core.model.properties.Item)3 IRepositoryViewObject (org.talend.core.model.repository.IRepositoryViewObject)3 IGEFProcess (org.talend.core.ui.process.IGEFProcess)3 IDesignerCoreUIService (org.talend.core.ui.services.IDesignerCoreUIService)3 ArrayList (java.util.ArrayList)2 PropertyChangeCommand (org.talend.designer.core.ui.editor.cmd.PropertyChangeCommand)2 Process (org.talend.designer.core.ui.editor.process.Process)2 Collection (java.util.Collection)1 Map (java.util.Map)1 Path (org.eclipse.core.runtime.Path)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1