Search in sources :

Example 6 with ParameterInfo

use of org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo in project tdi-studio-se by Talend.

the class AllTypeDialog method buildParameterFromElements.

private void buildParameterFromElements(String partElement, ParameterInfo parameterRoot) {
    // XmlSchemaObjectTable elements = xmlSchema.getElements();
    Iterator elementsItr = allXmlSchemaElement.iterator();
    if (partElement != null) {
        while (elementsItr.hasNext()) {
            XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) elementsItr.next();
            if (partElement.equals(xmlSchemaElement.getName())) {
                // parameter.setName(partName);
                if (xmlSchemaElement.getSchemaType() != null) {
                    if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaComplexType) {
                        XmlSchemaComplexType xmlElementComplexType = (XmlSchemaComplexType) xmlSchemaElement.getSchemaType();
                        XmlSchemaParticle xmlSchemaParticle = xmlElementComplexType.getParticle();
                        if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                            XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                            XmlSchemaObjectCollection xmlSchemaObjectCollection = xmlSchemaGroupBase.getItems();
                            if (xmlSchemaObjectCollection != null) {
                                buildParameterFromCollection(xmlSchemaObjectCollection, parameterRoot);
                            }
                        } else if (xmlSchemaElement.getSchemaTypeName() != null) {
                            String paraTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
                            if (paraTypeName != null) {
                                parameterRoot.setType(paraTypeName);
                                buileParameterFromTypes(paraTypeName, parameterRoot);
                            }
                        }
                    } else if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaSimpleType) {
                        XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType) xmlSchemaElement.getSchemaType();
                        String typeName = xmlSchemaSimpleType.getName();
                        if (typeName != null && typeName.equals("anyType")) {
                            ParameterInfo parameterSon = new ParameterInfo();
                            parameterSon.setName(xmlSchemaElement.getName() + "(anyType)");
                            parameterSon.setParent(parameterRoot);
                            parameterRoot.getParameterInfos().add(parameterSon);
                        }
                        parameterRoot.setType(typeName);
                    }
                } else if (xmlSchemaElement.getSchemaTypeName() != null) {
                    String paraTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
                    if (paraTypeName != null) {
                        parameterRoot.setType(paraTypeName);
                        buileParameterFromTypes(paraTypeName, parameterRoot);
                    }
                }
            }
        }
    }
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) Iterator(java.util.Iterator) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection)

Example 7 with ParameterInfo

use of org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo in project tdi-studio-se by Talend.

the class AllTypeDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    Composite createDialogArea = (Composite) super.createDialogArea(parent);
    createDialogArea.setLayout(new FillLayout());
    SashForm baseCom = new SashForm(createDialogArea, SWT.VERTICAL | SWT.BORDER);
    baseCom.setLayout(new GridLayout(1, true));
    Group group1 = new Group(baseCom, SWT.None);
    group1.setText(Messages.getString("AllTypeDialog.Group1Text"));
    group1.setLayoutData(new GridData(GridData.FILL_BOTH));
    group1.setLayout(new FillLayout());
    Font font = new Font(Display.getCurrent(), "Arial", 43, 3);
    group1.setFont(font);
    font.dispose();
    Group group2 = new Group(baseCom, SWT.None);
    group2.setText(Messages.getString("AllTypeDialog.Group2Text"));
    group2.setLayoutData(new GridData(GridData.FILL_BOTH));
    font = new Font(Display.getCurrent(), "Arial", 43, 3);
    group2.setFont(font);
    group2.setLayout(new FillLayout());
    font.dispose();
    list = new List(group1, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    list.setItems(allXMLSchemaTypeName);
    treeViewer = new TreeViewer(group2, SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
    tree = treeViewer.getTree();
    tree.setHeaderVisible(false);
    tree.setLinesVisible(true);
    treeViewer.setContentProvider(new WebServiceTreeContentProvider());
    treeViewer.setLabelProvider(new AllTypeLabelProvider());
    treeViewer.setInput(null);
    treeViewer.refresh();
    list.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            String selection = list.getSelection()[0];
            if (selection.contains(COMPLEXTYPE)) {
                String[] split = selection.split(":");
                String complexTypeName = split[1];
                for (XmlSchemaType xmlSchemaType : allXmlSchemaType) {
                    if (xmlSchemaType.getName().equals(complexTypeName)) {
                        ParameterInfo parameterRoot = new ParameterInfo();
                        parameterRoot.setName("parameters");
                        ParameterInfo parameterSon = new ParameterInfo();
                        parameterSon.setName(complexTypeName);
                        parameterSon.setParent(parameterRoot);
                        parameterRoot.getParameterInfos().add(parameterSon);
                        XmlSchemaComplexType xmlElementComplexType = (XmlSchemaComplexType) xmlSchemaType;
                        XmlSchemaParticle xmlSchemaParticle = xmlElementComplexType.getParticle();
                        if (xmlSchemaParticle instanceof XmlSchemaGroupBase) {
                            XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaParticle;
                            XmlSchemaObjectCollection childCollection = xmlSchemaGroupBase.getItems();
                            if (childCollection != null) {
                                buildParameterFromCollection(childCollection, parameterSon);
                            }
                        }
                        treeViewer.setInput(parameterRoot);
                        treeViewer.refresh();
                        selectedParaInfo = parameterSon;
                    }
                }
            } else {
                treeViewer.setInput(null);
                treeViewer.refresh();
                selectedParaInfo = null;
            }
        }
    });
    return baseCom;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) TreeViewer(org.eclipse.jface.viewers.TreeViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) FillLayout(org.eclipse.swt.layout.FillLayout) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) Font(org.eclipse.swt.graphics.Font) SashForm(org.eclipse.swt.custom.SashForm) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) List(org.eclipse.swt.widgets.List) ArrayList(java.util.ArrayList) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) WebServiceTreeContentProvider(org.talend.designer.webservice.ui.tree.WebServiceTreeContentProvider) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection)

Example 8 with ParameterInfo

use of org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo 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)

Example 9 with ParameterInfo

use of org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo in project tdi-studio-se by Talend.

the class WSDLDiscoveryHelper method getAllChildren.

public List<ParameterInfo> getAllChildren(ParameterInfo para) {
    List<ParameterInfo> list = new ArrayList<ParameterInfo>();
    List<ParameterInfo> childList = para.getParameterInfos();
    for (ParameterInfo paraC : childList) {
        if (paraC.getParent().getParaFullName() != null) {
            paraC.setParaFullName(paraC.getParent().getParaFullName() + "." + paraC.getName());
        }
    }
    list.addAll(childList);
    for (ParameterInfo paraC : childList) {
        if (paraC.getParameterInfos().size() > 0) {
            list.addAll(getAllChildren(paraC));
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)

Example 10 with ParameterInfo

use of org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo in project tdi-studio-se by Talend.

the class ParameterInfoUtil method getParentName.

public String getParentName(ParameterInfo para) {
    if (currenIndexList != null) {
        if (!currenIndexList.isEmpty()) {
            return getParentName(para, 2);
        }
    }
    List<ParameterInfo> paraList = getAllParameterInfo(para);
    StringBuffer buffer = new StringBuffer();
    ParameterInfo nearArrayParent = null;
    goout: for (ParameterInfo pa : paraList) {
        if (pa.getArraySize() != 0) {
            nearArrayParent = pa;
            break goout;
        }
    }
    for (int i = paraList.size() - 1; i >= 0; i--) {
        ParameterInfo parentPara = paraList.get(i);
        if (parentPara == null) {
            continue;
        }
        buffer.append(parentPara.getName());
        if (nearArrayParent != null && parentPara == nearArrayParent) {
            if (para.getArraySize() == 0 && para.getParameterInfos().size() == 0 && getCurrentindex() != -1 && i != 0) {
                buffer.append("[" + getCurrentindex() + "]");
            } else if (para.getArraySize() != 0 && para.getParameterInfos().size() == 0 && getCurrentindex() != -1) {
                buffer.append("[" + getCurrentindex() + "]");
            } else if (para.getArraySize() != 0 && para.getParameterInfos().size() == 0 && getCurrentindex() == -1) {
                buffer.append("[*]");
            }
        }
        if (i != 0) {
            buffer.append(".");
        }
    // if (para.getArraySize() != 0) {
    // if (i == 0) {
    // buffer.append("[]");
    // }
    // }
    }
    return buffer.toString();
}
Also used : ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)

Aggregations

ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)26 ArrayList (java.util.ArrayList)12 List (java.util.List)8 XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)8 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)6 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)6 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)6 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)6 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)6 Iterator (java.util.Iterator)5 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)4 XmlSchemaAny (org.apache.ws.commons.schema.XmlSchemaAny)3 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)3 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)3 ParameterInfoUtil (org.talend.designer.webservice.ui.ParameterInfoUtil)3 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2 SashForm (org.eclipse.swt.custom.SashForm)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2