Search in sources :

Example 6 with Struct

use of org.apache.cxf.binding.corba.wsdl.Struct in project cxf by apache.

the class WSDLToCorbaBindingTest method assertMixedArraysMappingDifficultSequences.

/**
 * @param typeMap
 */
private void assertMixedArraysMappingDifficultSequences(CorbaTypeMap typeMap) {
    String corbaTm = "http://schemas.apache.org/idl/anon.idl/corba/typemap/";
    // p9 is unwrapped, so there's "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequenceArray" type
    // registered and "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence" as type of the element
    // which is Struct
    Sequence p9 = (Sequence) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequenceArray");
    assertEquals(new QName("", "p9-anonymous-unwrapped-non-primitive-sequence"), p9.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence"), p9.getElemtype());
    assertFalse(p9.isQualified());
    assertFalse(p9.isWrapped());
    Struct p9item = (Struct) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence");
    assertEquals(1, p9item.getMember().size());
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p9item.getMember().get(0).getIdltype());
    assertEquals("item", p9item.getMember().get(0).getName());
    Sequence p9q = (Sequence) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence-qArray");
    assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "p9-anonymous-unwrapped-non-primitive-sequence-q"), p9q.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence-q"), p9q.getElemtype());
    assertTrue(p9q.isQualified());
    assertFalse(p9q.isWrapped());
    Struct p9qitem = (Struct) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence-q");
    assertEquals(1, p9qitem.getMember().size());
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p9qitem.getMember().get(0).getIdltype());
    assertEquals("item", p9qitem.getMember().get(0).getName());
    // p10 is wrapped, so there's no "MixedArrayType.p10-anonymous-wrapped-non-primitive-sequenceArray"
    Anonsequence p10 = (Anonsequence) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequenceType");
    assertEquals(new QName("", "item"), p10.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence.item"), p10.getElemtype());
    assertFalse(p10.isQualified());
    assertTrue(p10.isWrapped());
    Struct p10item = (Struct) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence.item");
    assertEquals(p10item.getMember().size(), 1);
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p10item.getMember().get(0).getIdltype());
    assertEquals("item", p10item.getMember().get(0).getName());
    assertFalse(p10item.getMember().get(0).isSetQualified());
    Anonsequence p10q = (Anonsequence) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence-qType");
    assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "item"), p10q.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence-q.item"), p10q.getElemtype());
    assertTrue(p10q.isQualified());
    assertTrue(p10q.isWrapped());
    Struct p10qitem = (Struct) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence-q.item");
    assertEquals(p10qitem.getMember().size(), 1);
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p10qitem.getMember().get(0).getIdltype());
    assertEquals("item", p10qitem.getMember().get(0).getName());
    assertTrue(p10qitem.getMember().get(0).isQualified());
}
Also used : QName(javax.xml.namespace.QName) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence) Struct(org.apache.cxf.binding.corba.wsdl.Struct)

Example 7 with Struct

use of org.apache.cxf.binding.corba.wsdl.Struct in project cxf by apache.

the class WSDLToCorbaBindingTest method assertMixedArraysMappingDifficultArrays.

/**
 * @param typeMap
 */
private void assertMixedArraysMappingDifficultArrays(CorbaTypeMap typeMap) {
    String corbaTm = "http://schemas.apache.org/idl/anon.idl/corba/typemap/";
    // p11 is unwrapped, so the same case as p9
    Array p11 = (Array) typeMap.getType("MixedArrayType.p11-anonymous-unwrapped-non-primitive-arrayArray");
    assertEquals(new QName("", "p11-anonymous-unwrapped-non-primitive-array"), p11.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p11-anonymous-unwrapped-non-primitive-array"), p11.getElemtype());
    assertFalse(p11.isQualified());
    assertFalse(p11.isWrapped());
    Struct p11item = (Struct) typeMap.getType("MixedArrayType.p11-anonymous-unwrapped-non-primitive-array");
    assertEquals(1, p11item.getMember().size());
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p11item.getMember().get(0).getIdltype());
    assertEquals("item", p11item.getMember().get(0).getName());
    Array p11q = (Array) typeMap.getType("MixedArrayType.p11-anonymous-unwrapped-non-primitive-array-qArray");
    assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "p11-anonymous-unwrapped-non-primitive-array-q"), p11q.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p11-anonymous-unwrapped-non-primitive-array-q"), p11q.getElemtype());
    assertTrue(p11q.isQualified());
    assertFalse(p11q.isWrapped());
    Struct p11qitem = (Struct) typeMap.getType("MixedArrayType.p11-anonymous-unwrapped-non-primitive-array-q");
    assertEquals(1, p11qitem.getMember().size());
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p11qitem.getMember().get(0).getIdltype());
    assertEquals("item", p11qitem.getMember().get(0).getName());
    // p12 us wrapped - see p10
    Anonarray p12 = (Anonarray) typeMap.getType("MixedArrayType.p12-anonymous-wrapped-non-primitive-arrayType");
    assertEquals(new QName("", "item"), p12.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p12-anonymous-wrapped-non-primitive-array.item"), p12.getElemtype());
    assertFalse(p12.isQualified());
    assertTrue(p12.isWrapped());
    Struct p12item = (Struct) typeMap.getType("MixedArrayType.p12-anonymous-wrapped-non-primitive-array.item");
    assertEquals(p12item.getMember().size(), 1);
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p12item.getMember().get(0).getIdltype());
    assertEquals("item", p12item.getMember().get(0).getName());
    assertFalse(p12item.getMember().get(0).isSetQualified());
    Anonarray p12q = (Anonarray) typeMap.getType("MixedArrayType.p12-anonymous-wrapped-non-primitive-array-qType");
    assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "item"), p12q.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p12-anonymous-wrapped-non-primitive-array-q.item"), p12q.getElemtype());
    assertTrue(p12q.isQualified());
    assertTrue(p12q.isWrapped());
    Struct p12qitem = (Struct) typeMap.getType("MixedArrayType.p12-anonymous-wrapped-non-primitive-array-q.item");
    assertEquals(p12qitem.getMember().size(), 1);
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p12qitem.getMember().get(0).getIdltype());
    assertEquals("item", p12qitem.getMember().get(0).getName());
    assertTrue(p12qitem.getMember().get(0).isQualified());
}
Also used : Array(org.apache.cxf.binding.corba.wsdl.Array) QName(javax.xml.namespace.QName) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) Struct(org.apache.cxf.binding.corba.wsdl.Struct)

Example 8 with Struct

use of org.apache.cxf.binding.corba.wsdl.Struct in project cxf by apache.

the class StructVisitor method visitDeclaredStruct.

public void visitDeclaredStruct(AST identifierNode) {
    Scope structScope = new Scope(getScope(), identifierNode);
    // xmlschema:struct
    XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema, true);
    complexType.setName(mapper.mapToQName(structScope));
    XmlSchemaSequence sequence = new XmlSchemaSequence();
    complexType.setParticle(sequence);
    // corba:struct
    Struct struct = new Struct();
    struct.setQName(new QName(typeMap.getTargetNamespace(), structScope.toString()));
    struct.setType(complexType.getQName());
    struct.setRepositoryID(structScope.toIDLRepositoryID());
    boolean recursiveAdd = addRecursiveScopedName(identifierNode);
    // struct members
    visitStructMembers(identifierNode, struct, sequence, structScope);
    if (recursiveAdd) {
        removeRecursiveScopedName(identifierNode);
    }
    // add corbaType
    typeMap.getStructOrExceptionOrUnion().add(struct);
    // REVISIT: are there assignment needed?
    setSchemaType(complexType);
    setCorbaType(struct);
    // Need to check if the struct was forward declared
    processForwardStructActions(structScope);
    // Once we've finished declaring the struct, we should make sure it has been removed from
    // the list of scopedNames so that we inidicate that is no longer simply forward declared.
    scopedNames.remove(structScope);
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) QName(javax.xml.namespace.QName) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) Struct(org.apache.cxf.binding.corba.wsdl.Struct)

Example 9 with Struct

use of org.apache.cxf.binding.corba.wsdl.Struct in project cxf by apache.

the class WSDLToCorbaHelper method isDuplicateException.

protected CorbaType isDuplicateException(CorbaType corbaTypeImpl) {
    CorbaType duplicate = null;
    String corbaName = corbaTypeImpl.getName();
    String corbaType = corbaTypeImpl.getType().getLocalPart();
    if (!typeMappingType.getStructOrExceptionOrUnion().isEmpty()) {
        Iterator<CorbaType> i = typeMappingType.getStructOrExceptionOrUnion().iterator();
        while (i.hasNext()) {
            CorbaType type = i.next();
            if (corbaName.equals(type.getName()) && corbaType.equals(type.getType().getLocalPart()) && type instanceof Struct) {
                return type;
            }
        }
    }
    return duplicate;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Struct(org.apache.cxf.binding.corba.wsdl.Struct)

Example 10 with Struct

use of org.apache.cxf.binding.corba.wsdl.Struct in project cxf by apache.

the class WSDLToCorbaHelper method processSequenceType.

protected CorbaType processSequenceType(XmlSchemaSequence seq, QName defaultName, QName schemaTypeName) throws Exception {
    CorbaType type = null;
    QName seqName = null;
    if (schemaTypeName == null) {
        seqName = createQNameCorbaNamespace(defaultName.getLocalPart() + "SequenceStruct");
    } else {
        seqName = createQNameCorbaNamespace(schemaTypeName.getLocalPart() + "SequenceStruct");
    }
    schemaTypeName = checkPrefix(schemaTypeName);
    Struct struct = new Struct();
    struct.setName(seqName.getLocalPart());
    struct.setQName(seqName);
    struct.setRepositoryID(REPO_STRING + seqName.getLocalPart().replace('.', '/') + IDL_VERSION);
    struct.setType(schemaTypeName);
    List<MemberType> members = processContainerAsMembers(seq, defaultName, schemaTypeName);
    for (MemberType memberType : members) {
        struct.getMember().add(memberType);
    }
    type = struct;
    if (seq.getMaxOccurs() != 1 || seq.getMinOccurs() != 1) {
        QName name = createQNameTargetNamespace(type.getQName().getLocalPart() + "Array");
        CorbaType atype = createArray(name, type.getQName(), type.getQName(), seq.getMaxOccurs(), seq.getMinOccurs(), false);
        if (atype != null && !isDuplicate(atype)) {
            typeMappingType.getStructOrExceptionOrUnion().add(atype);
        }
    }
    if ((struct != null) && (struct.getMember().isEmpty())) {
        String msgStr = "Cannot create CORBA Struct" + struct.getName() + "from container with no members";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    return type;
}
Also used : QName(javax.xml.namespace.QName) Struct(org.apache.cxf.binding.corba.wsdl.Struct) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType)

Aggregations

Struct (org.apache.cxf.binding.corba.wsdl.Struct)17 QName (javax.xml.namespace.QName)13 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)9 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)7 Test (org.junit.Test)6 Union (org.apache.cxf.binding.corba.wsdl.Union)4 StructMember (org.omg.CORBA.StructMember)4 TypeCode (org.omg.CORBA.TypeCode)4 File (java.io.File)3 Definition (javax.wsdl.Definition)3 Array (org.apache.cxf.binding.corba.wsdl.Array)3 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)3 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)3 WSDLToIDLAction (org.apache.cxf.tools.corba.processors.wsdl.WSDLToIDLAction)3 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)2 CorbaStructHandler (org.apache.cxf.binding.corba.types.CorbaStructHandler)2 Alias (org.apache.cxf.binding.corba.wsdl.Alias)2 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)2 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)2 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)2