Search in sources :

Example 21 with IConnection

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

the class MultiFOXManager method initModel.

public void initModel() {
    int i = 0;
    List<? extends IConnection> incomingConnections = NodeUtil.getIncomingConnections(foxComponent, IConnectionCategory.FLOW);
    for (IConnection connection : incomingConnections) {
        IMetadataTable metadataTable = connection.getMetadataTable();
        metadataTable.setLabel(connection.getUniqueName());
        treeData = new ArrayList<FOXTreeNode>();
        if (// the first schema as current
        i == 0)
            currentSchema = metadataTable.getLabel();
        FOXTreeNode rootNode = null;
        FOXTreeNode current = null;
        FOXTreeNode temp = null;
        FOXTreeNode mainNode = null;
        String mainPath = null;
        String currentPath = null;
        String defaultValue = null;
        int nodeOrder = 0;
        boolean haveOrder = true;
        //$NON-NLS-1$
        String schemaId = metadataTable.getLabel() + ":";
        // build root tree
        List<Map<String, String>> rootTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.ROOT);
        if (rootTable != null) {
            for (Map<String, String> rootMap : rootTable) {
                String newPath = rootMap.get(FileOutputXMLComponent.PATH);
                String columnName = rootMap.get(FileOutputXMLComponent.COLUMN);
                defaultValue = rootMap.get(FileOutputXMLComponent.VALUE);
                String orderValue = rootMap.get(FileOutputXMLComponent.ORDER);
                if (orderValue == null || "".equals(orderValue)) {
                    haveOrder = false;
                }
                if (haveOrder) {
                    nodeOrder = Integer.valueOf(rootMap.get(FileOutputXMLComponent.ORDER)).intValue();
                }
                //$NON-NLS-1$
                String flag = columnName + ":";
                if (columnName != null && columnName.length() > 0 && !flag.startsWith(metadataTable.getLabel() + ":")) {
                    //$NON-NLS-1$
                    continue;
                }
                if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
                    //$NON-NLS-1$
                    temp = new Attribute(newPath);
                    temp.setDefaultValue(defaultValue);
                    temp.setAttribute(true);
                    current.addChild(temp);
                } else if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
                    //$NON-NLS-1$
                    temp = new NameSpaceNode(newPath);
                    temp.setDefaultValue(defaultValue);
                    temp.setNameSpace(true);
                    current.addChild(temp);
                } else {
                    temp = addElement(current, currentPath, newPath, defaultValue);
                    if (rootNode == null) {
                        rootNode = temp;
                    }
                    if (rootMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
                        //$NON-NLS-1$
                        temp.setMain(true);
                        mainNode = temp;
                        mainPath = newPath;
                    }
                    current = temp;
                    currentPath = newPath;
                }
                if (haveOrder) {
                    temp.setOrder(nodeOrder);
                }
                temp.setRow(metadataTable.getLabel());
                if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
                    //$NON-NLS-1$
                    columnName = columnName.replace(schemaId, "");
                    temp.setColumn(metadataTable.getColumn(columnName));
                    temp.setTable(metadataTable);
                }
            }
        }
        // build group tree
        current = mainNode;
        currentPath = mainPath;
        boolean isFirst = true;
        List<Map<String, String>> groupTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.GROUP);
        if (groupTable != null) {
            for (Map<String, String> groupMap : groupTable) {
                String newPath = groupMap.get(FileOutputXMLComponent.PATH);
                String columnName = groupMap.get(FileOutputXMLComponent.COLUMN);
                defaultValue = groupMap.get(FileOutputXMLComponent.VALUE);
                String orderValue = groupMap.get(FileOutputXMLComponent.ORDER);
                if (orderValue == null || "".equals(orderValue)) {
                    haveOrder = false;
                }
                if (haveOrder) {
                    nodeOrder = Integer.valueOf(groupMap.get(FileOutputXMLComponent.ORDER)).intValue();
                }
                //$NON-NLS-1$
                String flag = columnName + ":";
                if (columnName != null && columnName.length() > 0 && !flag.startsWith(metadataTable.getLabel() + ":")) {
                    //$NON-NLS-1$
                    continue;
                }
                if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
                    //$NON-NLS-1$
                    temp = new Attribute(newPath);
                    temp.setDefaultValue(defaultValue);
                    temp.setAttribute(true);
                    current.addChild(temp);
                } else if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
                    //$NON-NLS-1$
                    temp = new NameSpaceNode(newPath);
                    temp.setDefaultValue(defaultValue);
                    temp.setNameSpace(true);
                    current.addChild(temp);
                } else {
                    temp = this.addElement(current, currentPath, newPath, defaultValue);
                    if (groupMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
                        //$NON-NLS-1$
                        temp.setMain(true);
                        mainNode = temp;
                        mainPath = newPath;
                    }
                    if (isFirst) {
                        temp.setGroup(true);
                        isFirst = false;
                    }
                    current = temp;
                    currentPath = newPath;
                }
                if (haveOrder) {
                    temp.setOrder(nodeOrder);
                }
                temp.setRow(metadataTable.getLabel());
                if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
                    //$NON-NLS-1$
                    columnName = columnName.replace(schemaId, "");
                    temp.setColumn(metadataTable.getColumn(columnName));
                    temp.setTable(metadataTable);
                }
            }
        }
        // build loop tree
        current = mainNode;
        currentPath = mainPath;
        isFirst = true;
        List<Map<String, String>> loopTable = (List<Map<String, String>>) foxComponent.getTableList(FileOutputXMLComponent.LOOP);
        if (loopTable != null) {
            for (Map<String, String> loopMap : loopTable) {
                String newPath = loopMap.get(FileOutputXMLComponent.PATH);
                String columnName = loopMap.get(FileOutputXMLComponent.COLUMN);
                defaultValue = loopMap.get(FileOutputXMLComponent.VALUE);
                String orderValue = loopMap.get(FileOutputXMLComponent.ORDER);
                if (orderValue == null || "".equals(orderValue)) {
                    haveOrder = false;
                }
                if (haveOrder) {
                    nodeOrder = Integer.valueOf(loopMap.get(FileOutputXMLComponent.ORDER)).intValue();
                }
                //$NON-NLS-1$
                String flag = columnName + ":";
                if (columnName != null && columnName.length() > 0 && !flag.startsWith(metadataTable.getLabel() + ":")) {
                    //$NON-NLS-1$
                    continue;
                }
                if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("attri")) {
                    //$NON-NLS-1$
                    temp = new Attribute(newPath);
                    temp.setDefaultValue(defaultValue);
                    temp.setAttribute(true);
                    current.addChild(temp);
                } else if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("ns")) {
                    //$NON-NLS-1$
                    temp = new NameSpaceNode(newPath);
                    temp.setDefaultValue(defaultValue);
                    temp.setNameSpace(true);
                    current.addChild(temp);
                } else {
                    temp = this.addElement(current, currentPath, newPath, defaultValue);
                    if (loopMap.get(FileOutputXMLComponent.ATTRIBUTE).equals("main")) {
                        //$NON-NLS-1$
                        temp.setMain(true);
                    }
                    if (isFirst) {
                        temp.setLoop(true);
                        isFirst = false;
                    }
                    current = temp;
                    currentPath = newPath;
                }
                if (haveOrder) {
                    temp.setOrder(nodeOrder);
                }
                temp.setRow(metadataTable.getLabel());
                if (columnName != null && columnName.length() > 0 && columnName.startsWith(schemaId)) {
                    //$NON-NLS-1$
                    columnName = columnName.replace(schemaId, "");
                    temp.setColumn(metadataTable.getColumn(columnName));
                    temp.setTable(metadataTable);
                }
            }
            if (rootNode == null) {
                //$NON-NLS-1$
                rootNode = new Element("rootTag");
            }
            rootNode.setParent(null);
            if (haveOrder) {
                orderNode(rootNode);
            }
            treeData.add(rootNode);
            rootNode.setRow(metadataTable.getLabel());
            contents.put(metadataTable.getLabel(), treeData);
            i++;
        }
    }
}
Also used : FOXTreeNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.FOXTreeNode) Attribute(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Attribute) Element(org.talend.metadata.managment.ui.wizard.metadata.xml.node.Element) IConnection(org.talend.core.model.process.IConnection) IMetadataTable(org.talend.core.model.metadata.IMetadataTable) NameSpaceNode(org.talend.metadata.managment.ui.wizard.metadata.xml.node.NameSpaceNode) ArrayList(java.util.ArrayList) List(java.util.List) HashMap(java.util.HashMap) Map(java.util.Map)

Example 22 with IConnection

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

the class FOXUI method initSchemaTable.

protected void initSchemaTable() {
    // if (!externalNode.istWriteXMLField()) {
    // INode originalNode = this.externalNode.getOriginalNode();
    // IMetadataTable metadataTable = null;
    // if (originalNode != null && originalNode.getIncomingConnections().size() > 0) {
    // metadataTable = originalNode.getIncomingConnections().get(0).getMetadataTable();
    // } else {
    // metadataTable = this.externalNode.getMetadataList().get(0);
    // }
    //
    // if (metadataTable != null) {
    // List<IMetadataColumn> columnList = metadataTable.getListColumns();
    // schemaViewer.setInput(columnList);
    // } else {
    // schemaViewer.setInput(new ArrayList<IMetadataColumn>());
    // }
    //
    // } else {
    IConnection inConn = null;
    for (IConnection conn : externalNode.getIncomingConnections()) {
        if ((conn.getLineStyle().equals(EConnectionType.FLOW_MAIN)) || (conn.getLineStyle().equals(EConnectionType.FLOW_REF)) || (conn.getLineStyle().equals(EConnectionType.FLOW_MERGE))) {
            inConn = conn;
            break;
        }
    }
    if (inConn != null) {
        List<IMetadataColumn> columnList = inConn.getMetadataTable().getListColumns();
        schemaViewer.setInput(columnList);
    } else {
        schemaViewer.setInput(new ArrayList<IMetadataColumn>());
    }
// }
}
Also used : IConnection(org.talend.core.model.process.IConnection) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn)

Example 23 with IConnection

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

the class TraceConnectionsManager method init.

public synchronized void init() {
    connsMap = new HashMap<String, IConnection>();
    shadowConnsMap = new HashMap<String, IConnection[]>();
    jobletNonShadowConnsMap = new HashMap<String, IConnection[]>();
    if (process != null) {
        Set<IConnection> allShadowConnections = new HashSet<IConnection>();
        // collect from graphical connections
        Iterator<? extends INode> nodeIterator = process.getGraphicalNodes().iterator();
        while (nodeIterator.hasNext()) {
            INode node = nodeIterator.next();
            if (node.isActivate()) {
                // all output connections
                Iterator<? extends IConnection> connIterator = node.getOutgoingConnections().iterator();
                while (connIterator.hasNext()) {
                    IConnection conn = connIterator.next();
                    String connectionUnifiedName = ConnectionUtil.getConnectionUnifiedName(conn);
                    // because the route if not data, so only check all connection with unique name
                    if (/* isDataConnection(conn) && */
                    isUniqueNameConn(conn) && !connsMap.containsKey(connectionUnifiedName)) {
                        connsMap.put(connectionUnifiedName, conn);
                        IConnection[] shadowConnections = getShadowConnections(conn);
                        if (shadowConnections != null) {
                            shadowConnsMap.put(connectionUnifiedName, shadowConnections);
                            allShadowConnections.addAll(Arrays.asList(shadowConnections));
                        }
                    }
                }
                // for Joblet
                if (jobletService != null && jobletService.isJobletComponent(node)) {
                    /*
                         * find the non-shadow connections in the joblet when this joblet is expaned. if it's not
                         * expanded, should be return null or empty.
                         */
                    IConnection[] jobletConnections = jobletService.getNonShadowDataConnections(node);
                    if (jobletConnections != null) {
                        jobletNonShadowConnsMap.put(node.getUniqueName(), jobletConnections);
                        for (IConnection conn : jobletConnections) {
                            // if shadow, it has been recoded in shadow list.
                            if (!allShadowConnections.contains(conn)) {
                                String jobletConnUnifiedName = ConnectionUtil.getConnectionUnifiedName(conn);
                                connsMap.put(jobletConnUnifiedName, conn);
                                // find shadow connections for inner joblet connection.
                                IConnection[] shadowConnections = getShadowConnections(conn);
                                if (shadowConnections != null) {
                                    shadowConnsMap.put(jobletConnUnifiedName, shadowConnections);
                                    allShadowConnections.addAll(Arrays.asList(shadowConnections));
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : INode(org.talend.core.model.process.INode) IConnection(org.talend.core.model.process.IConnection) HashSet(java.util.HashSet)

Example 24 with IConnection

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

the class XMLMapperHelper method hasDocumentInMainInput.

private static boolean hasDocumentInMainInput(final INode xmlMapperNode) {
    boolean hasDocumentInMainInput = false;
    List<? extends IConnection> inConnections = (List<? extends IConnection>) xmlMapperNode.getIncomingConnections();
    XmlMapData xmlMapData = (XmlMapData) ElementParameterParser.getObjectValueXMLTree(xmlMapperNode);
    if (xmlMapData != null && inConnections != null && inConnections.size() > 0) {
        List<InputXmlTree> inputTables = xmlMapData.getInputTrees();
        HashMap<String, IConnection> hNameToConnection = new HashMap<String, IConnection>();
        for (IConnection connection : inConnections) {
            hNameToConnection.put(connection.getName(), connection);
        }
        for (InputXmlTree inputTable : inputTables) {
            String tableName = inputTable.getName();
            IConnection connection = hNameToConnection.get(tableName);
            if (connection == null) {
                continue;
            }
            if (!(inputTable.isLookup())) {
                for (TreeNode node : inputTable.getNodes()) {
                    if ("id_Document".equals(node.getType())) {
                        hasDocumentInMainInput = true;
                        break;
                    }
                }
            }
        }
    }
    return hasDocumentInMainInput;
}
Also used : InputXmlTree(org.talend.designer.xmlmap.model.emf.xmlmap.InputXmlTree) HashMap(java.util.HashMap) OutputTreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.OutputTreeNode) TreeNode(org.talend.designer.xmlmap.model.emf.xmlmap.TreeNode) EList(org.eclipse.emf.common.util.EList) ArrayList(java.util.ArrayList) List(java.util.List) IConnection(org.talend.core.model.process.IConnection) XmlMapData(org.talend.designer.xmlmap.model.emf.xmlmap.XmlMapData)

Example 25 with IConnection

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

the class PropertyChangeCommand method execute.

@Override
public void execute() {
    IElementParameter currentParam = elem.getElementParameter(propName);
    changeMetadataCommands.clear();
    oldElementValues.clear();
    if (currentParam == null) {
        return;
    }
    if (currentParam instanceof ElementParameter) {
        ((ElementParameter) currentParam).setTaggedValue(UpdatesConstants.CHANGED_BY_USER, true);
    }
    if (currentParam.isRepositoryValueUsed()) {
        if (currentParam.getFieldType() == EParameterFieldType.MEMO_SQL) {
            Object queryStoreValue = elem.getPropertyValue(EParameterName.QUERYSTORE_TYPE.getName());
            if (!EmfComponent.BUILTIN.equals(queryStoreValue) || !EmfComponent.TNS_FILE.equals(queryStoreValue)) {
                elem.setPropertyValue(EParameterName.QUERYSTORE_TYPE.getName(), EmfComponent.BUILTIN);
            }
            currentParam.setRepositoryValueUsed(false);
        } else {
            toUpdate = true;
            Object value = elem.getPropertyValue(propName);
            if (value == null || (!value.toString().endsWith("xsd") && !value.toString().endsWith("xsd\""))) {
                elem.setPropertyValue(propertyTypeName, EmfComponent.BUILTIN);
            }
            for (IElementParameter param : elem.getElementParameters()) {
                if (param.getRepositoryProperty() == null || param.getRepositoryProperty().equals(currentParam.getName())) {
                    param.setRepositoryValueUsed(false);
                }
            }
        }
        repositoryValueWasUsed = true;
    } else {
        repositoryValueWasUsed = false;
    }
    oldValue = elem.getPropertyValue(propName);
    elem.setPropertyValue(propName, newValue);
    if (currentParam.getFieldType().equals(EParameterFieldType.CONNECTION_LIST) && currentParam.getContext() != null && (elem instanceof Node)) {
        String connParaname = currentParam.getContext() + ":" + currentParam.getName();
        if (connParaname.equals(propName)) {
            IConnection selectedConn = null;
            for (IConnection conn : ((Node) elem).getIncomingConnections()) {
                if (conn.getUniqueName().equals(newValue)) {
                    selectedConn = conn;
                    break;
                }
            }
            if (selectedConn != null && getTakeSchema()) {
                ((Node) selectedConn.getSource()).takeSchemaFrom((Node) elem, currentParam.getContext());
            }
        }
    }
    if ("ELT_TABLE_NAME".equals(propName) || "ELT_SCHEMA_NAME".equals(propName)) {
        //$NON-NLS-1$ //$NON-NLS-2$
        //$NON-NLS-1$
        String oldELTValue = "";
        //$NON-NLS-1$
        String newELTValue = "";
        String oldParamValue = TalendQuoteUtils.removeQuotes((String) oldValue);
        String newParamValue = TalendQuoteUtils.removeQuotes((String) newValue);
        if ("ELT_TABLE_NAME".equals(propName)) {
            //$NON-NLS-1$
            //$NON-NLS-1$
            String schemaName = TalendQuoteUtils.removeQuotes((String) elem.getPropertyValue("ELT_SCHEMA_NAME"));
            if (schemaName == null || "".equals(schemaName.trim())) {
                //$NON-NLS-1$
                oldELTValue = oldParamValue;
                newELTValue = newParamValue;
            } else {
                //$NON-NLS-1$
                oldELTValue = schemaName + "." + oldParamValue;
                //$NON-NLS-1$
                newELTValue = schemaName + "." + newParamValue;
            }
        } else {
            //$NON-NLS-1$
            String tableName = TalendQuoteUtils.removeQuotes((String) elem.getPropertyValue("ELT_TABLE_NAME"));
            if (oldParamValue != null && !"".equals(oldParamValue.trim())) {
                //$NON-NLS-1$
                oldELTValue = oldParamValue + ".";
            }
            if (newParamValue != null && !"".equals(newParamValue.trim())) {
                //$NON-NLS-1$
                newELTValue = newParamValue + ".";
            }
            // $NON-NLS-1$
            oldELTValue = oldELTValue + tableName;
            // $NON-NLS-1$
            newELTValue = newELTValue + tableName;
        }
        List<? extends IConnection> connections = ((Node) elem).getOutgoingConnections();
        for (IConnection connection : connections) {
            INode targetNode = connection.getTarget();
            String componentName = targetNode.getComponent().getName();
            if (componentName.matches("tELT.+Map")) {
                //$NON-NLS-1$
                if (GlobalServiceRegister.getDefault().isServiceRegistered(IDbMapDesignerService.class)) {
                    IDbMapDesignerService service = (IDbMapDesignerService) GlobalServiceRegister.getDefault().getService(IDbMapDesignerService.class);
                    updateELTMapComponentCommand = service.getUpdateELTMapComponentCommand(targetNode, connection, oldELTValue, newELTValue);
                    updateELTMapComponentCommand.execute();
                }
            }
        }
    }
    // add for bug TDI-26632 by fwang in 11 July, 2013. can't edit parameters if use repository connection.
    IElementParameter propertyTypeParam = elem.getElementParameter(EParameterName.PROPERTY_TYPE.getName());
    IElementParameter repositoryTypeParam = elem.getElementParameter(EParameterName.REPOSITORY_PROPERTY_TYPE.getName());
    if (("USE_EXISTING_CONNECTION").equals(propName) && elem instanceof Node && propertyTypeParam != null && "REPOSITORY".equals(propertyTypeParam.getValue()) && repositoryTypeParam != null && !("").equals(repositoryTypeParam.getValue())) {
        Node node = (Node) elem;
        for (IElementParameter param : node.getElementParameters()) {
            String repositoryValue = param.getRepositoryValue();
            if ((repositoryValue != null) && (!param.getName().equals(EParameterName.PROPERTY_TYPE.getName())) && param.getFieldType() != EParameterFieldType.MEMO_SQL && !("tMDMReceive".equals(node.getComponent().getName()) && "XPATH_PREFIX".equals(//$NON-NLS-1$ //$NON-NLS-2$
            param.getRepositoryValue())) && !("tSAPOutput".equals(node.getComponent().getName()) && param.getName().equals(UpdatesConstants.MAPPING)) && !("tFileInputEBCDIC".equals(node.getComponent().getName()) && "DATA_FILE".equals(repositoryValue))) {
                param.setRepositoryValueUsed(true);
                if (!(EParameterName.DB_VERSION.getName()).equals(param.getName())) {
                    param.setReadOnly(true);
                }
            }
        }
    }
    // feature 19312
    if (propName.contains(EParameterName.USE_DYNAMIC_JOB.getName()) && newValue.equals(false)) {
        IElementParameter processParam = elem.getElementParameter(EParameterName.PROCESS.getName());
        IElementParameter processTypeParameter = elem.getElementParameter(EParameterName.PROCESS_TYPE_PROCESS.getName());
        //$NON-NLS-1$
        final String parentName = processParam.getName() + ":";
        //$NON-NLS-1$
        elem.setPropertyValue(parentName + processTypeParameter.getName(), "");
        //$NON-NLS-1$
        elem.setPropertyValue(processParam.getName(), "");
    }
    if (propName.contains(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
        boolean isSelectUseDynamic = false;
        IElementParameter useDynamicJobParameter = elem.getElementParameter(EParameterName.USE_DYNAMIC_JOB.getName());
        if (useDynamicJobParameter != null && useDynamicJobParameter instanceof IElementParameter) {
            Object useDynamicJobValue = useDynamicJobParameter.getValue();
            if (useDynamicJobValue != null && useDynamicJobValue instanceof Boolean) {
                isSelectUseDynamic = (Boolean) useDynamicJobValue;
            }
        }
        if (isSelectUseDynamic) {
            StringBuffer labels = new StringBuffer("");
            if (newValue != null) {
                String[] strValues = newValue.toString().split(";");
                for (int i = 0; i < strValues.length; i++) {
                    String strValue = strValues[i];
                    // newValue is the id of the job
                    ProcessItem processItem = ItemCacheManager.getProcessItem(strValue);
                    if (processItem != null) {
                        String label = processItem.getProperty().getLabel();
                        if (i > 0) {
                            labels.append(";");
                        }
                        labels.append(label);
                    }
                }
            }
            currentParam.getParentParameter().setValue(labels.toString());
        } else {
            // newValue is the id of the job
            ProcessItem processItem = ItemCacheManager.getProcessItem((String) newValue);
            if (processItem != null) {
                currentParam.getParentParameter().setValue(processItem.getProperty().getLabel());
            }
        }
    }
    if (propName.contains(EParameterName.PROCESS_TYPE_VERSION.getName())) {
        // newValue is the id of the job
        // hywang add for feature 6549
        // 1.to see current component if is a jobletComponent by "elem"
        boolean isJobletComponent = false;
        // Node jobletNode = null;
        IJobletProviderService service = null;
        if (PluginChecker.isJobLetPluginLoaded()) {
            service = (IJobletProviderService) GlobalServiceRegister.getDefault().getService(IJobletProviderService.class);
        }
        if (elem instanceof Node) {
            // jobletNode = (Node) elem;
            if (service != null) {
                isJobletComponent = service.isJobletComponent((Node) elem);
            }
        }
        if (isJobletComponent) {
            // 2.if it is a jobletcomponent,reload the component by the version
            String id = service.getJobletComponentItem((Node) elem).getId();
            String version = (String) newValue;
            IComponent newComponent = service.setPropertyForJobletComponent(id, version);
            reloadNode((Node) elem, newComponent);
        } else {
            IElementParameter processIdParam = currentParam.getParentParameter().getChildParameters().get(EParameterName.PROCESS_TYPE_PROCESS.getName());
            ProcessItem processItem = ItemCacheManager.getProcessItem((String) processIdParam.getValue(), (String) newValue);
            if (processItem != null) {
                currentParam.getParentParameter().setValue(processItem.getProperty().getLabel());
            }
        }
    }
    if (propName.contains(EParameterName.PROCESS_TYPE_CONTEXT.getName())) {
        if (elem instanceof Node) {
            Node node = (Node) elem;
            List<IContext> listContext = node.getProcess().getContextManager().getListContext();
            List<String> values = new ArrayList<String>();
            for (IContext context : listContext) {
                values.add(context.getName());
            }
            currentParam.setListItemsDisplayName(values.toArray(new String[0]));
            currentParam.setListItemsValue(values.toArray(new String[0]));
            currentParam.setValue(newValue);
        }
    }
    if (propName.equals(EParameterName.VALIDATION_RULES.getName())) {
        if (elem instanceof INode) {
            ValidationRulesUtil.createRejectConnector((INode) elem);
            ValidationRulesUtil.updateRejectMetatable((INode) elem, null);
            if (newValue != null && (!(Boolean) newValue)) {
                ValidationRulesUtil.removeRejectConnector((INode) elem);
                ValidationRulesUtil.removeRejectConnection((INode) elem);
            }
        }
    }
    String dbType = "";
    if (newValue instanceof String) {
        dbType = (String) newValue;
    }
    IElementParameter schemaParameter = null;
    if (propName.equals(EParameterName.DB_TYPE.getName())) {
        IElementParameter elementParameter = elem.getElementParameter(EParameterName.DB_VERSION.getName());
        schemaParameter = elem.getElementParameter(EParameterName.SCHEMA_DB.getName());
        JobSettingVersionUtil.setDbVersion(elementParameter, dbType, true);
        DesignerUtilities.setSchemaDB(schemaParameter, newValue);
    } else if (propName.equals(JobSettingsConstants.getExtraParameterName(EParameterName.DB_TYPE.getName()))) {
        IElementParameter elementParameter = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.DB_VERSION.getName()));
        schemaParameter = elem.getElementParameter(JobSettingsConstants.getExtraParameterName(EParameterName.SCHEMA_DB.getName()));
        JobSettingVersionUtil.setDbVersion(elementParameter, dbType, true);
        DesignerUtilities.setSchemaDB(schemaParameter, newValue);
    }
    // Some DB not need fill the schema parameter for the JobSetting View "Extra" ,"Stats&Logs"
    if (schemaParameter != null && !schemaParameter.isShow(elem.getElementParameters()) && !schemaParameter.getValue().equals("")) {
        schemaParameter.setValue("");
    }
    if (!toUpdate && (currentParam.getFieldType().equals(EParameterFieldType.RADIO) || currentParam.getFieldType().equals(EParameterFieldType.CLOSED_LIST) || currentParam.getFieldType().equals(EParameterFieldType.OPENED_LIST) || currentParam.getFieldType().equals(EParameterFieldType.CHECK) || currentParam.getFieldType().equals(EParameterFieldType.AS400_CHECK) || currentParam.getFieldType().equals(EParameterFieldType.COMPONENT_LIST))) {
        toUpdate = false;
        setDefaultValues(currentParam, elem);
    }
    if (currentParam.getName().equals(EParameterName.PROCESS_TYPE_PROCESS.getName())) {
        toUpdate = true;
    }
    if (toUpdate) {
        elem.setPropertyValue(updataComponentParamName, Boolean.TRUE);
    }
    // see bug 9151:100% CPU when typing text.
    if (getNewValue() instanceof String && elem instanceof INode) {
        INode curNode = (INode) elem;
        String uniqueName = curNode.getUniqueName();
        IProcess process = curNode.getProcess();
        if (process != null && process instanceof IProcess2) {
            IProcess2 process2 = (IProcess2) process;
            List<? extends INode> generatingNodes = null;
            if (process2.isProcessModified()) {
                process2.setProcessModified(false);
                generatingNodes = process2.getGeneratingNodes();
                if (generatingNodes != null) {
                    for (INode genNode : new ArrayList<INode>(generatingNodes)) {
                        if (genNode.getUniqueName().equals(uniqueName)) {
                            IElementParameter genParam = genNode.getElementParameter(propName);
                            if (genParam != null) {
                                genParam.setValue(newValue);
                                break;
                            }
                        }
                    }
                }
                process2.setProcessModified(true);
                codeViewUpdater.startIfExecutable(elem);
            }
        }
    }
    updateRelativeNodesIfNeeded(currentParam);
    checkProcess.startIfExecutable(elem);
    // See feature 3902
    if (needUpdateMonitorConnection()) {
        ((Connection) elem).setMonitorConnection((Boolean) currentParam.getValue());
    }
    refreshMR(propName);
}
Also used : INode(org.talend.core.model.process.INode) IContext(org.talend.core.model.process.IContext) IComponent(org.talend.core.model.components.IComponent) Node(org.talend.designer.core.ui.editor.nodes.Node) IGraphicalNode(org.talend.core.ui.process.IGraphicalNode) INode(org.talend.core.model.process.INode) ArrayList(java.util.ArrayList) IConnection(org.talend.core.model.process.IConnection) IElementParameter(org.talend.core.model.process.IElementParameter) ElementParameter(org.talend.designer.core.model.components.ElementParameter) IElementParameter(org.talend.core.model.process.IElementParameter) IProcess(org.talend.core.model.process.IProcess) IConnection(org.talend.core.model.process.IConnection) Connection(org.talend.designer.core.ui.editor.connections.Connection) IDbMapDesignerService(org.talend.designer.core.IDbMapDesignerService) IJobletProviderService(org.talend.core.ui.IJobletProviderService) ProcessItem(org.talend.core.model.properties.ProcessItem) IProcess2(org.talend.core.model.process.IProcess2)

Aggregations

IConnection (org.talend.core.model.process.IConnection)149 ArrayList (java.util.ArrayList)79 INode (org.talend.core.model.process.INode)63 List (java.util.List)60 IMetadataTable (org.talend.core.model.metadata.IMetadataTable)57 Node (org.talend.designer.core.ui.editor.nodes.Node)47 HashMap (java.util.HashMap)36 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)33 IElementParameter (org.talend.core.model.process.IElementParameter)31 Map (java.util.Map)25 Connection (org.talend.designer.core.ui.editor.connections.Connection)25 INodeConnector (org.talend.core.model.process.INodeConnector)24 Point (org.eclipse.swt.graphics.Point)13 Process (org.talend.designer.core.ui.editor.process.Process)13 IJobletProviderService (org.talend.core.ui.IJobletProviderService)12 HashSet (java.util.HashSet)11 MetadataTable (org.talend.core.model.metadata.MetadataTable)10 IProcess (org.talend.core.model.process.IProcess)10 ChangeMetadataCommand (org.talend.designer.core.ui.editor.cmd.ChangeMetadataCommand)9 IExternalNode (org.talend.core.model.process.IExternalNode)8