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();
}
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);
}
}
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);
}
}
}
}
}
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());
}
}
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();
}
}
}
}
}
}
}
}
}
Aggregations