Search in sources :

Example 1 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)

Example 2 with ParameterInfo

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

the class ComponentBuilder method getParameterFromMessage.

private void getParameterFromMessage(OperationInfo operationInfo, Message msg, int manner) {
    // inOrOut = manner;
    List msgParts = msg.getOrderedParts(null);
    // msg.getQName();
    // Schema wsdlType = null;
    // XmlSchema xmlSchema = null;
    Iterator iter = msgParts.iterator();
    while (iter.hasNext()) {
        Part part = (Part) iter.next();
        String partName = part.getName();
        String partElement = null;
        String namespace = null;
        if (part.getElementName() != null) {
            partElement = part.getElementName().getLocalPart();
            namespace = part.getElementName().getNamespaceURI();
        } else if (part.getTypeName() != null) {
            partElement = part.getTypeName().getLocalPart();
            namespace = part.getTypeName().getNamespaceURI();
        }
        // add first parameter from message.
        ParameterInfo parameterRoot = new ParameterInfo();
        parameterRoot.setName(partName);
        parameterRoot.setNameSpace(namespace);
        if (manner == 1) {
            operationInfo.addInparameter(parameterRoot);
        } else {
            operationInfo.addOutparameter(parameterRoot);
        }
        // }
        if (allXmlSchemaElement.size() > 0) {
            buildParameterFromElements(partElement, parameterRoot, manner);
        } else if (allXmlSchemaType.size() > 0) {
            buileParameterFromTypes(namespace, partElement, parameterRoot, manner);
        }
        operationInfo.setWsdltype(wsdlTypes);
    }
}
Also used : Part(javax.wsdl.Part) Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)

Example 3 with ParameterInfo

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

the class ComponentBuilder method buildParameterFromCollection.

private void buildParameterFromCollection(XmlSchemaObjectCollection xmlSchemaObjectCollection, ParameterInfo parameter, int ioOrRecursion) {
    // XmlSchemaSequence xmlSchemaSequence = (XmlSchemaSequence) xmlSchemaParticle;
    // XmlSchemaObjectCollection xmlSchemaObjectCollection = xmlSchemaSequence.getItems();
    int count = xmlSchemaObjectCollection.getCount();
    for (int j = 0; j < count; j++) {
        XmlSchemaObject xmlSchemaObject = xmlSchemaObjectCollection.getItem(j);
        if (xmlSchemaObject instanceof XmlSchemaGroupBase) {
            XmlSchemaGroupBase xmlSchemaGroupBase = (XmlSchemaGroupBase) xmlSchemaObject;
            XmlSchemaObjectCollection items = xmlSchemaGroupBase.getItems();
            if (items != null) {
                buildParameterFromCollection(items, parameter, ioOrRecursion);
            }
        } else if (xmlSchemaObject instanceof XmlSchemaAny) {
            ParameterInfo parameterSon = new ParameterInfo();
            parameterSon.setName("_content_");
            parameterSon.setParent(parameter);
            parameter.getParameterInfos().add(parameterSon);
        } else if (xmlSchemaObject instanceof XmlSchemaElement) {
            XmlSchemaElement xmlSchemaElement = (XmlSchemaElement) xmlSchemaObject;
            String elementName = xmlSchemaElement.getName();
            ParameterInfo parameterSon = new ParameterInfo();
            parameterSon.setName(elementName);
            parameterSon.setParent(parameter);
            if (((XmlSchemaElement) xmlSchemaObject).getQName() != null) {
                parameterSon.setNameSpace(((XmlSchemaElement) xmlSchemaObject).getQName().getNamespaceURI());
            }
            Long min = xmlSchemaElement.getMinOccurs();
            Long max = xmlSchemaElement.getMaxOccurs();
            if (max - min > 1) {
                parameterSon.setArraySize(-1);
                parameterSon.setIndex("*");
            }
            parameter.getParameterInfos().add(parameterSon);
            Boolean isHave = false;
            if (!parametersName.isEmpty() && parameterSon.getName() != null) {
                for (int p = 0; p < parametersName.size(); p++) {
                    if (parameterSon.getName().equals(parametersName.get(p))) {
                        isHave = true;
                    }
                }
            }
            // }
            if (xmlSchemaElement.getSchemaTypeName() != null) {
                String elementTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
                String elementTypeNamespace = xmlSchemaElement.getSchemaTypeName().getNamespaceURI();
                if (elementTypeName != null && elementTypeName.equals("anyType")) {
                    parameterSon.setName(xmlSchemaElement.getName() + ":anyType");
                }
                parameterSon.setType(elementTypeName);
                parameterSon.setNameSpace(xmlSchemaElement.getQName().getNamespaceURI());
                if (!isHave && !WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
                    buileParameterFromTypes(elementTypeNamespace, elementTypeName, parameterSon, ioOrRecursion);
                }
            } else 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 childCollection = xmlSchemaGroupBase.getItems();
                        if (childCollection != null && !isHave) {
                            buildParameterFromCollection(childCollection, parameterSon, ioOrRecursion);
                        }
                    } else if (xmlSchemaElement.getSchemaTypeName() != null) {
                        String paraTypeName = xmlSchemaElement.getSchemaTypeName().getLocalPart();
                        String paraTypeNamespace = xmlSchemaElement.getSchemaTypeName().getNamespaceURI();
                        if (paraTypeName != null && !isHave) {
                            parameter.setType(paraTypeName);
                            buileParameterFromTypes(paraTypeNamespace, paraTypeName, parameterSon, ioOrRecursion);
                        }
                    }
                } else if (xmlSchemaElement.getSchemaType() instanceof XmlSchemaSimpleType) {
                    XmlSchemaSimpleType xmlSchemaSimpleType = (XmlSchemaSimpleType) xmlSchemaElement.getSchemaType();
                    String typeName = xmlSchemaSimpleType.getName();
                    if (typeName != null && typeName.equals("anyType")) {
                        ParameterInfo pSon = new ParameterInfo();
                        pSon.setName("anyType");
                        pSon.setParent(parameter);
                        parameter.getParameterInfos().add(pSon);
                    }
                    parameter.setType(typeName);
                }
            } else if (xmlSchemaElement.getRefName() != null) {
                String elementTypeName = xmlSchemaElement.getRefName().getLocalPart();
                if (!isHave && !WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
                    buildParameterFromElements(elementTypeName, parameterSon, ioOrRecursion);
                }
            }
        } else if (xmlSchemaObject instanceof XmlSchemaAttribute) {
            XmlSchemaAttribute xmlSchemaAttribute = (XmlSchemaAttribute) xmlSchemaObject;
            String elementName = xmlSchemaAttribute.getName();
            ParameterInfo parameterSon = new ParameterInfo();
            parameterSon.setName(elementName);
            parameterSon.setParent(parameter);
            parameter.getParameterInfos().add(parameterSon);
            Boolean isHave = false;
            if (!parametersName.isEmpty() && parameterSon.getName() != null) {
                for (int p = 0; p < parametersName.size(); p++) {
                    if (parameterSon.getName().equals(parametersName.get(p))) {
                        isHave = true;
                    }
                }
            }
            if (xmlSchemaAttribute.getSchemaTypeName() != null) {
                String elementTypeName = xmlSchemaAttribute.getSchemaTypeName().getLocalPart();
                String elementTypeNamespace = xmlSchemaAttribute.getSchemaTypeName().getNamespaceURI();
                parameterSon.setType(elementTypeName);
                if (!isHave && !WsdlTypeUtil.isJavaBasicType(elementTypeName)) {
                    buileParameterFromTypes(elementTypeNamespace, elementTypeName, parameterSon, ioOrRecursion);
                }
            } else if (xmlSchemaAttribute.getRefName() != null) {
                String refName = xmlSchemaAttribute.getRefName().getLocalPart();
                parameterSon.setType(refName);
                if (!isHave) {
                    buildParameterFromElements(refName, parameterSon, ioOrRecursion);
                }
            }
        }
    }
}
Also used : XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) XmlSchemaAny(org.apache.ws.commons.schema.XmlSchemaAny) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) XmlSchemaGroupBase(org.apache.ws.commons.schema.XmlSchemaGroupBase) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) XmlSchemaSimpleType(org.apache.ws.commons.schema.XmlSchemaSimpleType) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaObjectCollection(org.apache.ws.commons.schema.XmlSchemaObjectCollection)

Example 4 with ParameterInfo

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

the class DropTargetListenerForWebService method drop.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.swt.dnd.DropTargetListener#drop(org.eclipse.swt.dnd.DropTargetEvent)
     */
public void drop(DropTargetEvent event) {
    if (getTransfer().isSupportedType(event.currentDataType)) {
        // boolean canRemove = true;
        // Parameter pa = TableEntriesTransfer.getInstance().getParameter();
        Table draggableTable = (Table) draggableControl;
        Point point = new Point(event.x, event.y);
        int selevIndex = TableUtils.getItemIndexWhereInsertFromPosition(draggableTable, point);
        if (selevIndex < 0) {
            return;
        }
        TableItem tabitem = TableEntriesTransfer.getInstance().getTableItem();
        if (tabitem == null) {
            return;
        }
        ExtendedTableModel tabelModel = draggableControlView.getExtendedTableModel();
        if (tabelModel.getBeansList().size() == 0 || tabelModel.getBeansList().size() == selevIndex) {
            // }
            return;
        } else if (tabelModel.getBeansList().size() > 0) {
            if (tabelModel.getBeansList().size() < selevIndex) {
                return;
            }
            Object objData = tabelModel.getBeansList().get(selevIndex);
            if (objData instanceof InputMappingData) {
                InputMappingData inData = (InputMappingData) objData;
                IMetadataColumn inputColumn = null;
                if (tabitem.getData() instanceof IMetadataColumn) {
                    inputColumn = (IMetadataColumn) tabitem.getData();
                    List<IMetadataColumn> columnList = inData.getMetadataColumnList();
                    if (inData.getInputColumnValue() == null || "".equals(inData.getInputColumnValue())) {
                        inData.setInputColumnValue(connector.initInRoWName() + "." + inputColumn.getLabel());
                        columnList.add(inputColumn);
                    } else {
                        inData.setInputColumnValue(inData.getInputColumnValue() + " " + connector.initInRoWName() + "." + inputColumn.getLabel());
                        columnList.add(inputColumn);
                    }
                }
                tabelModel.remove(selevIndex);
                tabelModel.add(inData, selevIndex);
            } else if (objData instanceof OutPutMappingData) {
                OutPutMappingData outData = (OutPutMappingData) objData;
                if (tabitem.getData() instanceof ParameterInfo) {
                    ParameterInfo para = (ParameterInfo) tabitem.getData();
                    if (outData.getParameterName() == null || "".equals(outData.getParameterName())) {
                        if (para.getParent() != null) {
                            String name = new ParameterInfoUtil().getParentName(para);
                            outData.setParameterName(name);
                        } else {
                            outData.setParameterName(para.getName());
                        }
                    } else {
                        outData.setParameterName(outData.getParameterName() + " " + para.getName());
                    }
                    outData.getParameterList().add(para);
                // outData.setParameter(para);
                } else if (tabitem.getData() instanceof OutPutMappingData) {
                    if (((OutPutMappingData) tabitem.getData()).getParameter() instanceof ParameterInfo) {
                        ParameterInfo para = ((OutPutMappingData) tabitem.getData()).getParameter();
                        if (outData.getParameterName() == null || "".equals(outData.getParameterName())) {
                            if (para.getParent() != null) {
                                String name = "";
                                if (((OutPutMappingData) tabitem.getData()).getParameterName() != null) {
                                    name = ((OutPutMappingData) tabitem.getData()).getParameterName();
                                } else {
                                    name = new ParameterInfoUtil().getParentName(para);
                                }
                                outData.setParameterName(name);
                            } else {
                                outData.setParameterName(para.getName());
                            }
                        } else {
                            outData.setParameterName(outData.getParameterName() + " " + para.getName());
                        }
                        outData.getParameterList().add(para);
                    // outData.setParameter(para);
                    }
                }
                tabelModel.remove(selevIndex);
                tabelModel.add(outData, selevIndex);
            }
        }
        TableItem[] items = draggableTable.getSelection();
        if (items.length <= 0) {
            return;
        }
        TableItem itemTarget = items[0];
        itemTarget.setChecked(true);
        createLinks(itemTarget, tabitem, tabelModel.getName());
    }
}
Also used : Table(org.eclipse.swt.widgets.Table) InputMappingData(org.talend.designer.webservice.data.InputMappingData) OutPutMappingData(org.talend.designer.webservice.data.OutPutMappingData) TableItem(org.eclipse.swt.widgets.TableItem) Point(org.eclipse.swt.graphics.Point) IMetadataColumn(org.talend.core.model.metadata.IMetadataColumn) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) Point(org.eclipse.swt.graphics.Point) List(java.util.List) ParameterInfoUtil(org.talend.designer.webservice.ui.ParameterInfoUtil) ExtendedTableModel(org.talend.commons.ui.swt.extended.table.ExtendedTableModel)

Example 5 with ParameterInfo

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

the class ComponentBuilder method findExtendtion.

private void findExtendtion(XmlSchemaType xmlSchemaType, ParameterInfo parameterSon, int ioOrRecursion) {
    for (int i = 0; i < allXmlSchemaType.size(); i++) {
        XmlSchemaType type = allXmlSchemaType.get(i);
        if (type != null) {
            if (type instanceof XmlSchemaComplexType) {
                XmlSchemaComplexType xmlElementComplexType = (XmlSchemaComplexType) type;
                if (xmlElementComplexType.getContentModel() != null) {
                    Object obj = xmlElementComplexType.getContentModel().getContent();
                    if (obj instanceof XmlSchemaComplexContentExtension) {
                        XmlSchemaComplexContentExtension xscce = (XmlSchemaComplexContentExtension) obj;
                        if (xscce.getBaseTypeName().getLocalPart() != null && xmlSchemaType.getName().equals(xscce.getBaseTypeName().getLocalPart())) {
                            if (xmlElementComplexType.isAbstract()) {
                                findExtendtion(type, parameterSon, ioOrRecursion);
                                break;
                            } else {
                                if (!alldExtendtion.contains(type.getName())) {
                                    alldExtendtion.add(type.getName());
                                    ParameterInfo parameterType = new ParameterInfo();
                                    parameterType.setName(parameterSon.getName() + ".@type");
                                    boolean flag = false;
                                    for (int x = 0; x < parameterSon.getParameterInfos().size(); x++) {
                                        ParameterInfo info = parameterSon.getParameterInfos().get(x);
                                        if (info.getName().equals(parameterType.getName())) {
                                            flag = true;
                                        }
                                    }
                                    if (!flag) {
                                        parameterType.setParent(parameterSon);
                                        parameterSon.getParameterInfos().add(parameterType);
                                    }
                                    ParameterInfo parameterSubSon = new ParameterInfo();
                                    parameterSubSon.setName(type.getName());
                                    parameterSubSon.setParent(parameterSon);
                                    parameterSon.getParameterInfos().add(parameterSubSon);
                                    buileParameterFromTypes2(type.getName(), parameterSubSon, ioOrRecursion);
                                    parametersName.clear();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) ParameterInfo(org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

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