예제 #1
0
 private void addCrossImports(XmlSchema schema, XmlSchemaSequence sequence) {
   for (XmlSchemaSequenceMember seqMember : sequence.getItems()) {
     if (seqMember instanceof XmlSchemaElement) {
       addElementCrossImportsElement(schema, (XmlSchemaElement) seqMember);
     }
   }
 }
예제 #2
0
  private void visitStructMembers(
      AST identifierNode, Struct struct, XmlSchemaSequence sequence, Scope structScope) {
    AST memberTypeNode = identifierNode.getNextSibling();
    while (memberTypeNode != null) {
      AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);

      XmlSchemaType schemaType = null;
      CorbaTypeImpl corbaType = null;
      Scope fqName = null;
      try {
        TypesVisitor visitor = new TypesVisitor(structScope, definition, schema, wsdlVisitor, null);
        visitor.visit(memberTypeNode);
        schemaType = visitor.getSchemaType();
        corbaType = visitor.getCorbaType();
        fqName = visitor.getFullyQualifiedName();
      } catch (Exception ex) {
        throw new RuntimeException(ex);
      }

      // Handle multiple struct member declarators
      // <declarators> :== <declarator> { "," <declarator> }*
      //
      // A multiple declarator must be an identifier (i.e. of type IDENT)
      // and cannot be a previous declared (or forward declared) type
      // (hence the ScopedNameVisitor.accept() call).
      while (memberNode != null
          && memberNode.getType() == IDLTokenTypes.IDENT
          && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor)) {

        XmlSchemaType memberSchemaType = schemaType;
        CorbaTypeImpl memberCorbaType = corbaType;
        // needed for anonymous arrays in structs
        if (ArrayVisitor.accept(memberNode)) {
          Scope anonScope = new Scope(structScope, TypesUtils.getCorbaTypeNameNode(memberTypeNode));
          ArrayVisitor arrayVisitor =
              new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fqName);
          arrayVisitor.setSchemaType(schemaType);
          arrayVisitor.setCorbaType(corbaType);
          arrayVisitor.visit(memberNode);
          memberSchemaType = arrayVisitor.getSchemaType();
          memberCorbaType = arrayVisitor.getCorbaType();
          fqName = arrayVisitor.getFullyQualifiedName();
        }

        XmlSchemaElement member = createXmlSchemaElement(memberNode, memberSchemaType, fqName);
        sequence.getItems().add(member);
        MemberType memberType = createMemberType(memberNode, memberCorbaType, fqName);
        struct.getMember().add(memberType);

        memberNode = memberNode.getNextSibling();
      }

      memberTypeNode = memberNode;
    }
  }
예제 #3
0
 private void processXmlSchemaParticle(XmlSchemaParticle particle) {
   XmlSchemaSequence schemaSequence;
   if (particle instanceof XmlSchemaSequence) {
     schemaSequence = (XmlSchemaSequence) particle;
     List<XmlSchemaSequenceMember> schemaObjectCollection = schemaSequence.getItems();
     Iterator<XmlSchemaSequenceMember> iterator = schemaObjectCollection.iterator();
     while (iterator.hasNext()) {
       Object element = iterator.next();
       if (element instanceof XmlSchemaElement) {
         XmlSchemaElement innerElement = ((XmlSchemaElement) element);
         XmlSchemaType innerEleType = innerElement.getSchemaType();
         if (innerEleType instanceof XmlSchemaComplexType) {
           processComplexType(innerElement);
         } else if (innerEleType instanceof XmlSchemaSimpleType) {
           processSimpleType(innerElement);
         } else if (innerEleType == null) {
           // Check if this is the GML location Property
           processGmlType(innerElement);
         }
       }
     }
   }
 }
  private void parseParticle(
      XmlSchemaParticle particle, NeutralSchema complexSchema, XmlSchema schema) {

    if (particle != null) {
      if (particle instanceof XmlSchemaElement) {
        XmlSchemaElement element = (XmlSchemaElement) particle;

        NeutralSchema elementSchema = parseElement(element, schema);

        String elementName = element.getName();

        // Required Elements
        if (!element.isNillable() && (element.getMinOccurs() > 0)) {
          AppInfo info = elementSchema.getAppInfo();
          if (info == null) {
            info = new AppInfo(null);
          }
          info.put(REQUIRED_USE.getValue(), "true");
          elementSchema.addAnnotation(info);
        }

        // Update Neutral Schema Field
        complexSchema.addField(elementName, elementSchema);

        // DE840 address.addressLines were not being encrypted
        for (Map.Entry<String, NeutralSchema> entry : elementSchema.getFields().entrySet()) {
          String fieldName = entry.getKey();
          NeutralSchema fieldSchema = entry.getValue();
          fieldSchema.inheritAnnotations(complexSchema.getAppInfo());
        }

      } else if (particle instanceof XmlSchemaSequence) {
        XmlSchemaSequence schemaSequence = (XmlSchemaSequence) particle;
        for (int i = 0; i < schemaSequence.getItems().getCount(); i++) {
          XmlSchemaObject item = schemaSequence.getItems().getItem(i);
          if (item instanceof XmlSchemaParticle) {
            parseParticle((XmlSchemaParticle) item, complexSchema, schema);
          } else {
            throw new RuntimeException(
                "Unsupported XmlSchemaSequence item: " + item.getClass().getCanonicalName());
          }
        }
      } else if (particle instanceof XmlSchemaChoice) {

        XmlSchemaChoice xmlSchemaChoice = (XmlSchemaChoice) particle;

        ChoiceSchema choiceSchema =
            (ChoiceSchema) getSchemaFactory().createSchema(NeutralSchemaType.CHOICE.name());

        choiceSchema.setMinOccurs(xmlSchemaChoice.getMinOccurs());
        choiceSchema.setMaxOccurs(xmlSchemaChoice.getMaxOccurs());

        XmlSchemaObjectCollection choices = xmlSchemaChoice.getItems();
        for (int i = 0; i < choices.getCount(); ++i) {
          XmlSchemaObject item = xmlSchemaChoice.getItems().getItem(i);
          if (item instanceof XmlSchemaParticle) {
            parseParticle((XmlSchemaParticle) item, choiceSchema, schema);
          }
        }

        complexSchema.addField("choice_" + choiceCount++, choiceSchema);

      } else {
        throw new RuntimeException(
            "Unsupported XmlSchemaParticle item: " + particle.getClass().getCanonicalName());
      }
    }
  }