Search in sources :

Example 1 with WebServiceExpressionParser

use of org.talend.designer.webservice.ui.WebServiceExpressionParser in project tdi-studio-se by Talend.

the class WebServiceTableLiner method onXPathValueChanged.

public void onXPathValueChanged(Table sourceTable, Table targetTable, String oldValue, String newValue, String inComeName, int itemIndex) {
    TableItem tabletraItem = targetTable.getItem(itemIndex);
    boolean needAddLink = true;
    TableItem[] items = sourceTable.getItems();
    List<TableItem> itemList = new ArrayList<TableItem>();
    for (int i = 0; i < items.length; i++) {
        String columnLabel = null;
        IMetadataColumn column = null;
        ParameterInfo parame = null;
        if (items[i].getData() instanceof IMetadataColumn) {
            column = (IMetadataColumn) items[i].getData();
            columnLabel = column.getLabel();
        } else // }
        if (items[i].getData() instanceof OutPutMappingData) {
            parame = ((OutPutMappingData) items[i].getData()).getParameter();
            if (!parame.getParameterInfos().isEmpty()) {
                continue;
            }
            // columnLabel = parame.getName();
            columnLabel = ((OutPutMappingData) items[i].getData()).getParameterName();
            int m = columnLabel.lastIndexOf(".");
            columnLabel = columnLabel.substring(m + 1);
        }
        if (newValue.contains(columnLabel)) {
            // if (!pattern(columnLabel, newValue)) {
            if (inComeName != null) {
                WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*");
                Map<String, String> itemNamemap = webParser.parseInTableEntryLocations(newValue);
                Set<Entry<String, String>> set = itemNamemap.entrySet();
                Iterator<Entry<String, String>> ite = set.iterator();
                while (ite.hasNext()) {
                    Entry<String, String> entry = ite.next();
                    String columnValue = entry.getKey();
                    String rowValue = entry.getValue();
                    if (!isPatternWord(inComeName + "." + columnLabel, rowValue + "." + columnValue)) {
                        linksManager.removeLinksFromDataItem2(tabletraItem.getData());
                        if (tabletraItem.getData() instanceof InputMappingData) {
                            InputMappingData data = (InputMappingData) tabletraItem.getData();
                            List<IMetadataColumn> list = data.getMetadataColumnList();
                            if (column != null) {
                                list.remove(column);
                            }
                        }
                        needAddLink = false;
                        for (TableItem item : itemList) {
                            addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "INPUTMAPPING");
                        }
                        getBackgroundRefresher().refreshBackground();
                    // return;
                    }
                }
            } else {
                WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*\\w+(\\[\\d+?\\])?\\s*");
                Set<String> set = webParser.parseOutTableEntryLocations(newValue);
                Iterator<String> ite = set.iterator();
                while (ite.hasNext()) {
                    String columnValue = ite.next();
                    // if (columnValue.equals(columnLabel)) {
                    if (!isPatternWord(columnLabel, columnValue)) {
                        linksManager.removeLinksFromDataItem2(tabletraItem.getData());
                        OutPutMappingData data = (OutPutMappingData) tabletraItem.getData();
                        if (parame != null) {
                            data.getParameterList().remove(parame);
                        }
                        needAddLink = false;
                        for (TableItem item : itemList) {
                            addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "OUTPUTMAPPING");
                        }
                        getBackgroundRefresher().refreshBackground();
                    // return;
                    // }
                    }
                }
            }
            if (true) {
                // if (!mark) {
                if (inComeName != null) {
                    WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*(\\w+)\\s*\\.\\s*(\\w+)\\s*");
                    Map<String, String> itemNamemap = webParser.parseInTableEntryLocations(newValue);
                    Set<Entry<String, String>> set = itemNamemap.entrySet();
                    Iterator<Entry<String, String>> ite = set.iterator();
                    while (ite.hasNext()) {
                        Entry<String, String> entry = ite.next();
                        String columnValue = entry.getKey();
                        String rowValue = entry.getValue();
                        if (isPatternWord(inComeName + "." + columnLabel, rowValue + "." + columnValue)) {
                            itemList.add(items[i]);
                            addLinks(items[i], items[i].getData(), targetTable, tabletraItem.getData(), "INPUTMAPPING");
                            getBackgroundRefresher().refreshBackground();
                            if (tabletraItem.getData() instanceof InputMappingData) {
                                InputMappingData data = (InputMappingData) tabletraItem.getData();
                                List<IMetadataColumn> list = data.getMetadataColumnList();
                                if (column != null && !list.contains(column)) {
                                    list.add(column);
                                }
                            }
                        }
                    }
                } else {
                    WebServiceExpressionParser webParser = new WebServiceExpressionParser("\\s*\\w+(\\[\\d+?\\])?\\s*");
                    Set<String> set = webParser.parseOutTableEntryLocations(newValue);
                    Iterator<String> ite = set.iterator();
                    while (ite.hasNext()) {
                        String columnValue = ite.next();
                        if (isPatternWord(columnLabel, columnValue)) {
                            itemList.add(items[i]);
                            addLinks(items[i], items[i].getData(), targetTable, tabletraItem.getData(), "OUTPUTMAPPING");
                            getBackgroundRefresher().refreshBackground();
                        }
                    }
                }
            }
        } else if (oldValue.contains(columnLabel)) {
            linksManager.removeLinksFromDataItem2(tabletraItem.getData());
            if (tabletraItem.getData() instanceof InputMappingData) {
                InputMappingData data = (InputMappingData) tabletraItem.getData();
                List<IMetadataColumn> list = data.getMetadataColumnList();
                if (column != null) {
                    list.remove(column);
                }
            } else if (tabletraItem.getData() instanceof OutPutMappingData) {
                OutPutMappingData data = (OutPutMappingData) tabletraItem.getData();
                if (parame != null) {
                    data.getParameterList().remove(parame);
                }
            }
            for (TableItem item : itemList) {
                if (inComeName != null) {
                    addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "INPUTMAPPING");
                } else {
                    addLinks(item, item.getData(), targetTable, tabletraItem.getData(), "OUTPUTMAPPING");
                }
            }
            getBackgroundRefresher().refreshBackground();
        }
    }
// createFieldLinks(newValue, tableItem, null);
}
Also used : OutPutMappingData(org.talend.designer.webservice.data.OutPutMappingData) InputMappingData(org.talend.designer.webservice.data.InputMappingData) TableItem(org.eclipse.swt.widgets.TableItem) ArrayList(java.util.ArrayList) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) Point(org.eclipse.swt.graphics.Point) Entry(java.util.Map.Entry) WebServiceExpressionParser(org.talend.designer.webservice.ui.WebServiceExpressionParser) ArrayList(java.util.ArrayList) List(java.util.List)

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 Entry (java.util.Map.Entry)1 Point (org.eclipse.swt.graphics.Point)1 TableItem (org.eclipse.swt.widgets.TableItem)1 IMetadataColumn (org.talend.core.model.metadata.IMetadataColumn)1 InputMappingData (org.talend.designer.webservice.data.InputMappingData)1 OutPutMappingData (org.talend.designer.webservice.data.OutPutMappingData)1 WebServiceExpressionParser (org.talend.designer.webservice.ui.WebServiceExpressionParser)1 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)1