Search in sources :

Example 1 with XmlSchemaAppInfo

use of org.apache.ws.commons.schema.XmlSchemaAppInfo in project cxf by apache.

the class WSDLToCorbaBinding method addCorbaElements.

private void addCorbaElements(CorbaType corbaTypeImpl, XmlSchema xmlSchemaTypes) throws Exception {
    Map<QName, XmlSchemaElement> elements = xmlSchemaTypes.getElements();
    for (XmlSchemaElement el : elements.values()) {
        QName elName = el.getQName();
        XmlSchemaType schemaType = el.getSchemaType();
        if (elName == null) {
            elName = el.getRef().getTargetQName();
            schemaType = helper.getSchemaType(elName);
        }
        boolean anonymous = false;
        if (schemaType == null) {
            anonymous = true;
        } else {
            anonymous = WSDLTypes.isAnonymous(schemaType.getName());
        }
        if (schemaType != null) {
            XmlSchemaAnnotation annotation = null;
            if (el.getAnnotation() != null) {
                annotation = el.getAnnotation();
            }
            // this situation won't be handled. REVISIT.
            if (annotation != null) {
                XmlSchemaAppInfo appInfo = null;
                for (XmlSchemaAnnotationItem ann : annotation.getItems()) {
                    if (ann instanceof XmlSchemaAppInfo) {
                        appInfo = (XmlSchemaAppInfo) ann;
                        break;
                    }
                }
                if (appInfo != null) {
                    NodeList nlist = appInfo.getMarkup();
                    Node node = nlist.item(0);
                    String info = node.getNodeValue();
                    info = info.trim();
                    String annotationBindingName = "";
                    if ("corba:binding=".equals(info.substring(0, 14))) {
                        annotationBindingName = info.substring(14);
                    }
                    if (bindingName.equals(annotationBindingName)) {
                        annotation = null;
                    }
                }
            }
            corbaTypeImpl = helper.convertSchemaToCorbaType(schemaType, elName, schemaType, annotation, anonymous);
            if (el.isNillable()) {
                QName uname = helper.createQNameCorbaNamespace(corbaTypeImpl.getQName().getLocalPart() + "_nil");
                boolean isQualified = corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified();
                corbaTypeImpl = helper.createNillableUnion(uname, helper.checkPrefix(elName), helper.checkPrefix(corbaTypeImpl.getQName()), isQualified);
            }
            if (corbaTypeImpl != null && !helper.isDuplicate(corbaTypeImpl)) {
                typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
            }
        }
    }
}
Also used : XmlSchemaAnnotationItem(org.apache.ws.commons.schema.XmlSchemaAnnotationItem) XmlSchemaAnnotation(org.apache.ws.commons.schema.XmlSchemaAnnotation) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo)

Example 2 with XmlSchemaAppInfo

use of org.apache.ws.commons.schema.XmlSchemaAppInfo in project hale by halestudio.

the class XmlSchemaReader method setMetadata.

/**
 * Set the metadata for a definition
 *
 * @param definition the definition
 * @param annotated the XML annotated object
 * @param schemaLocation the schema location
 */
public static void setMetadata(AbstractDefinition<?> definition, XmlSchemaAnnotated annotated, String schemaLocation) {
    definition.setDescription(XMLSchemaIO.getDescription(annotated));
    List<XmlSchemaAppInfo> appInfo = XMLSchemaIO.getAppInfo(annotated);
    if (appInfo != null) {
        XmlAppInfo constraint = new XmlAppInfo(appInfo);
        if (definition instanceof DefaultPropertyDefinition) {
            ((DefaultPropertyDefinition) definition).setConstraint(constraint);
        } else if (definition instanceof DefaultGroupPropertyDefinition) {
            ((DefaultGroupPropertyDefinition) definition).setConstraint(constraint);
        } else if (definition instanceof DefaultTypeDefinition) {
            ((DefaultTypeDefinition) definition).setConstraint(constraint);
        }
    }
    definition.setLocation(createLocationURI(schemaLocation, annotated));
}
Also used : DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) DefaultPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition) DefaultGroupPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultGroupPropertyDefinition) XmlAppInfo(eu.esdihumboldt.hale.io.xsd.constraint.XmlAppInfo) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo)

Example 3 with XmlSchemaAppInfo

use of org.apache.ws.commons.schema.XmlSchemaAppInfo in project hale by halestudio.

the class XmlSchemaReader method setMetadata.

/**
 * Set the metadata for a definition
 *
 * @param definition the definition
 * @param annotated the XML annotated object
 * @param schemaLocation the schema location
 * @param index the XML index
 */
public static void setMetadata(AbstractDefinition<?> definition, XmlSchemaAnnotated annotated, String schemaLocation, XmlIndex index) {
    definition.setDescription(XMLSchemaIO.getDescription(annotated));
    List<XmlSchemaAppInfo> appInfo = XMLSchemaIO.getAppInfo(annotated);
    if (appInfo != null) {
        XmlAppInfo constraint = new XmlAppInfo(appInfo);
        if (definition instanceof DefaultPropertyDefinition) {
            ((DefaultPropertyDefinition) definition).setConstraint(constraint);
        } else if (definition instanceof DefaultGroupPropertyDefinition) {
            ((DefaultGroupPropertyDefinition) definition).setConstraint(constraint);
        } else if (definition instanceof DefaultTypeDefinition) {
            ((DefaultTypeDefinition) definition).setConstraint(constraint);
        }
        if (definition instanceof ChildDefinition<?>) {
            handleAppInfoTargetElement(appInfo, (ChildDefinition<?>) definition, index);
        }
    }
    definition.setLocation(createLocationURI(schemaLocation, annotated));
}
Also used : DefaultTypeDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition) DefaultPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition) DefaultGroupPropertyDefinition(eu.esdihumboldt.hale.common.schema.model.impl.DefaultGroupPropertyDefinition) ChildDefinition(eu.esdihumboldt.hale.common.schema.model.ChildDefinition) XmlAppInfo(eu.esdihumboldt.hale.io.xsd.constraint.XmlAppInfo) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo)

Example 4 with XmlSchemaAppInfo

use of org.apache.ws.commons.schema.XmlSchemaAppInfo in project cxf by apache.

the class WSDLToCorbaBinding method addCorbaElements.

private void addCorbaElements(XmlSchema xmlSchemaTypes) throws Exception {
    Map<QName, XmlSchemaElement> elements = xmlSchemaTypes.getElements();
    for (XmlSchemaElement el : elements.values()) {
        QName elName = el.getQName();
        XmlSchemaType schemaType = el.getSchemaType();
        if (elName == null) {
            elName = el.getRef().getTargetQName();
            schemaType = helper.getSchemaType(elName);
        }
        boolean anonymous;
        if (schemaType == null) {
            anonymous = true;
        } else {
            anonymous = WSDLTypes.isAnonymous(schemaType.getName());
        }
        if (schemaType != null) {
            XmlSchemaAnnotation annotation = null;
            if (el.getAnnotation() != null) {
                annotation = el.getAnnotation();
            }
            // this situation won't be handled. REVISIT.
            if (annotation != null) {
                XmlSchemaAppInfo appInfo = null;
                for (XmlSchemaAnnotationItem ann : annotation.getItems()) {
                    if (ann instanceof XmlSchemaAppInfo) {
                        appInfo = (XmlSchemaAppInfo) ann;
                        break;
                    }
                }
                if (appInfo != null) {
                    NodeList nlist = appInfo.getMarkup();
                    Node node = nlist.item(0);
                    String info = node.getNodeValue();
                    info = info.trim();
                    String annotationBindingName = "";
                    if ("corba:binding=".equals(info.substring(0, 14))) {
                        annotationBindingName = info.substring(14);
                    }
                    if (bindingName.equals(annotationBindingName)) {
                        annotation = null;
                    }
                }
            }
            CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(schemaType, elName, schemaType, annotation, anonymous);
            if (el.isNillable()) {
                QName uname = helper.createQNameCorbaNamespace(corbaTypeImpl.getQName().getLocalPart() + "_nil");
                boolean isQualified = corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified();
                corbaTypeImpl = helper.createNillableUnion(uname, helper.checkPrefix(elName), helper.checkPrefix(corbaTypeImpl.getQName()), isQualified);
            }
            if (corbaTypeImpl != null && !helper.isDuplicate(corbaTypeImpl)) {
                typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
            }
        }
    }
}
Also used : XmlSchemaAnnotationItem(org.apache.ws.commons.schema.XmlSchemaAnnotationItem) XmlSchemaAnnotation(org.apache.ws.commons.schema.XmlSchemaAnnotation) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo)

Example 5 with XmlSchemaAppInfo

use of org.apache.ws.commons.schema.XmlSchemaAppInfo in project cxf by apache.

the class WSDLTypes method processObject.

public static CorbaType processObject(Definition definition, XmlSchemaComplexType complex, XmlSchemaAnnotation annotation, QName typeName, QName defaultName, String idlNamespace) throws Exception {
    CorbaType corbaTypeImpl = null;
    if (annotation != null) {
        for (XmlSchemaAnnotationItem item : annotation.getItems()) {
            XmlSchemaAppInfo appInfo = (XmlSchemaAppInfo) item;
            if (appInfo != null) {
                NodeList nlist = appInfo.getMarkup();
                Node node = nlist.item(0);
                String info = node.getNodeValue();
                info = info.trim();
                if ("corba:binding=".equals(info.substring(0, 14))) {
                    String bindingName = info.substring(14);
                    QName bqname = new QName(definition.getTargetNamespace(), bindingName);
                    // Check if the Binding with name already exists
                    Binding binding = null;
                    if (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
                        binding = definition.getBinding(bqname);
                    }
                    if (binding != null) {
                        org.apache.cxf.binding.corba.wsdl.Object obj = new org.apache.cxf.binding.corba.wsdl.Object();
                        PortType portT = binding.getPortType();
                        QName name = new QName(idlNamespace, portT.getQName().getLocalPart(), definition.getPrefix(idlNamespace));
                        obj.setName(name.getLocalPart());
                        obj.setQName(name);
                        QName bName = binding.getQName();
                        obj.setBinding(bName);
                        // get the repository id of the binding.
                        String repId = null;
                        Iterator<?> bindIter = binding.getExtensibilityElements().iterator();
                        while (bindIter.hasNext()) {
                            BindingType type = (BindingType) bindIter.next();
                            repId = type.getRepositoryID();
                        }
                        obj.setRepositoryID(repId);
                        obj.setType(typeName);
                        corbaTypeImpl = obj;
                    } else {
                        // if (isVerboseOn()) {
                        System.out.println("Could not find binding for: " + bqname);
                    // }
                    }
                }
            }
        }
    }
    if (corbaTypeImpl == null) {
        org.apache.cxf.binding.corba.wsdl.Object obj = new org.apache.cxf.binding.corba.wsdl.Object();
        QName name = new QName(idlNamespace, "CORBA.Object", definition.getPrefix(idlNamespace));
        obj.setName(name.getLocalPart());
        obj.setQName(name);
        obj.setRepositoryID("IDL:omg.org/CORBA/Object/1.0");
        obj.setType(typeName);
        corbaTypeImpl = obj;
    }
    return corbaTypeImpl;
}
Also used : Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) XmlSchemaAnnotationItem(org.apache.ws.commons.schema.XmlSchemaAnnotationItem) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo) PortType(javax.wsdl.PortType)

Aggregations

XmlSchemaAppInfo (org.apache.ws.commons.schema.XmlSchemaAppInfo)7 QName (javax.xml.namespace.QName)4 Node (org.w3c.dom.Node)4 DefaultGroupPropertyDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultGroupPropertyDefinition)3 DefaultPropertyDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultPropertyDefinition)3 XmlSchemaAnnotation (org.apache.ws.commons.schema.XmlSchemaAnnotation)3 XmlSchemaAnnotationItem (org.apache.ws.commons.schema.XmlSchemaAnnotationItem)3 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)3 NodeList (org.w3c.dom.NodeList)3 DefaultTypeDefinition (eu.esdihumboldt.hale.common.schema.model.impl.DefaultTypeDefinition)2 XmlAppInfo (eu.esdihumboldt.hale.io.xsd.constraint.XmlAppInfo)2 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)2 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)2 ChildDefinition (eu.esdihumboldt.hale.common.schema.model.ChildDefinition)1 XmlElementReferenceProperty (eu.esdihumboldt.hale.io.xsd.reader.internal.XmlElementReferenceProperty)1 ElementReferenceProperty (eu.esdihumboldt.hale.io.xsd.reader.internal.constraint.ElementReferenceProperty)1 TObjectIntHashMap (gnu.trove.TObjectIntHashMap)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Binding (javax.wsdl.Binding)1