Search in sources :

Example 1 with WsdlOperationContainer

use of org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperationContainer in project pentaho-kettle by pentaho.

the class WebServiceDialog method loadOperation.

private void loadOperation(String anOperationName) throws KettleException {
    wsdlOperation = null;
    inWsdlParamContainer = null;
    outWsdlParamContainer = null;
    if (wsdl != null) {
        for (Iterator<WsdlOperation> vItOperation = wsdl.getOperations().iterator(); vItOperation.hasNext() && wsdlOperation == null; ) {
            WsdlOperation vCurrentOperation = vItOperation.next();
            if (vCurrentOperation.getOperationQName().getLocalPart().equals(anOperationName)) {
                wsdlOperation = vCurrentOperation;
            }
        }
    }
    if (wsdlOperation != null) {
        // figure out the request name
        // 
        String request = "";
        WsdlOpParameterList parameters = wsdlOperation.getParameters();
        if (parameters != null && parameters.getOperation() != null && parameters.getOperation().getInput() != null && parameters.getOperation().getInput().getName() != null) {
            request = wsdlOperation.getParameters().getOperation().getInput().getName().toString();
        }
        wOperationRequest.setText(request);
        for (int cpt = 0; cpt < wsdlOperation.getParameters().size(); cpt++) {
            WsdlOpParameter param = wsdlOperation.getParameters().get(cpt);
            if (param.isArray()) {
                // setInFieldArgumentName(param.getName().getLocalPart());
                if (param.getItemXmlType() != null) {
                    ComplexType type = param.getItemComplexType();
                    if (type != null) {
                        for (Iterator<String> itrType = type.getElementNames().iterator(); itrType.hasNext(); ) {
                            String attributeName = itrType.next();
                            QName attributeType = type.getElementType(attributeName);
                            if (!WebServiceMeta.XSD_NS_URI.equals(attributeType.getNamespaceURI())) {
                                throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0007.UnsupporteOperation.ComplexType"));
                            }
                        }
                    }
                    if (ParameterMode.IN.equals(param.getMode()) || ParameterMode.INOUT.equals(param.getMode()) || ParameterMode.UNDEFINED.equals(param.getMode())) {
                        if (inWsdlParamContainer != null) {
                            throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0006.UnsupportedOperation.MultipleArrays"));
                        } else {
                            inWsdlParamContainer = new WsdlOpParameterContainer(param);
                        }
                    } else if (ParameterMode.OUT.equals(param.getMode()) || ParameterMode.INOUT.equals(param.getMode()) || ParameterMode.UNDEFINED.equals(param.getMode())) {
                        if (outWsdlParamContainer != null) {
                            throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0006.UnsupportedOperation.MultipleArrays"));
                        } else {
                            outWsdlParamContainer = new WsdlOpParameterContainer(param);
                        }
                    }
                }
            } else {
                if (ParameterMode.IN.equals(param.getMode()) || ParameterMode.INOUT.equals(param.getMode()) || ParameterMode.UNDEFINED.equals(param.getMode())) {
                    if (inWsdlParamContainer != null && !(inWsdlParamContainer instanceof WsdlOperationContainer)) {
                        throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0008.UnsupportedOperation.IncorrectParams"));
                    } else {
                        inWsdlParamContainer = new WsdlOperationContainer(wsdlOperation, param.getMode());
                    }
                } else if (ParameterMode.OUT.equals(param.getMode()) || ParameterMode.INOUT.equals(param.getMode()) || ParameterMode.UNDEFINED.equals(param.getMode())) {
                    if (outWsdlParamContainer != null && !(outWsdlParamContainer instanceof WsdlOperationContainer)) {
                        throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0008.UnsupportedOperation.IncorrectParams"));
                    } else {
                        outWsdlParamContainer = new WsdlOperationContainer(wsdlOperation, param.getMode());
                    }
                } else {
                    System.out.println("Parameter : " + param.getName().getLocalPart() + ", mode=" + param.getMode().toString() + ", is not considered");
                }
            }
        }
        if (wsdlOperation.getReturnType() != null) {
            outWsdlParamContainer = new WsdlOpParameterContainer((WsdlOpParameter) wsdlOperation.getReturnType());
            if (wsdlOperation.getReturnType().isArray()) {
                if (wsdlOperation.getReturnType().getItemXmlType() != null) {
                    ComplexType type = wsdlOperation.getReturnType().getItemComplexType();
                    if (type != null) {
                        for (Iterator<String> itrType = type.getElementNames().iterator(); itrType.hasNext(); ) {
                            String attributeName = itrType.next();
                            QName attributeType = type.getElementType(attributeName);
                            if (!WebServiceMeta.XSD_NS_URI.equals(attributeType.getNamespaceURI())) {
                                throw new KettleStepException(BaseMessages.getString(PKG, "WebServiceDialog.ERROR0007.UnsupportedOperation.ComplexType"));
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : WsdlOperation(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperation) WsdlOpParameterContainer(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameterContainer) WsdlOpParameterList(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameterList) KettleStepException(org.pentaho.di.core.exception.KettleStepException) WsdlOperationContainer(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperationContainer) QName(javax.xml.namespace.QName) WsdlOpParameter(org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameter) ComplexType(org.pentaho.di.trans.steps.webservices.wsdl.ComplexType)

Aggregations

QName (javax.xml.namespace.QName)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 ComplexType (org.pentaho.di.trans.steps.webservices.wsdl.ComplexType)1 WsdlOpParameter (org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameter)1 WsdlOpParameterContainer (org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameterContainer)1 WsdlOpParameterList (org.pentaho.di.trans.steps.webservices.wsdl.WsdlOpParameterList)1 WsdlOperation (org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperation)1 WsdlOperationContainer (org.pentaho.di.trans.steps.webservices.wsdl.WsdlOperationContainer)1