Package org.codehaus.enunciate.config

Examples of org.codehaus.enunciate.config.SchemaInfo$ImplicitSchemaElementComparator


    }
    else {
      throw new TemplateModelException("The isDefinedGlobally method must have a local element declaration or an implicit schema element as a parameter.");
    }

    SchemaInfo schemaInfo = getModel().getNamespacesToSchemas().get(namespace);
    if (schemaInfo != null) {
      for (RootElementDeclaration rootElementDeclaration : schemaInfo.getGlobalElements()) {
        if (rootElementDeclaration.getName().equals(name)) {
          return true;
        }
      }

      if (LocalElementDeclaration.class.isInstance(unwrapped)) {
        //local element declarations have to check implicit schema elements, too.
        for (ImplicitSchemaElement implicitSchemaElement : schemaInfo.getImplicitSchemaElements()) {
          if (implicitSchemaElement.getElementName().equals(name)) {
            return true;
          }
        }
      }
View Full Code Here


      for (WebMessage webMessage : webMethod.getMessages()) {
        for (WebMessagePart messagePart : webMessage.getParts()) {
          if (messagePart.isImplicitSchemaElement()) {
            ImplicitSchemaElement implicitElement = (ImplicitSchemaElement) messagePart;
            String particleNamespace = messagePart.getParticleQName().getNamespaceURI();
            SchemaInfo schemaInfo = namespacesToSchemas.get(particleNamespace);
            if (schemaInfo == null) {
              schemaInfo = new SchemaInfo();
              schemaInfo.setId(addNamespace(particleNamespace));
              schemaInfo.setNamespace(particleNamespace);
              namespacesToSchemas.put(particleNamespace, schemaInfo);
            }
            schemaInfo.getImplicitSchemaElements().add(implicitElement);
          }
        }
      }
    }
View Full Code Here

        add(typeDef.getSchema());

        String namespace = typeDef.getNamespace();
        String prefix = addNamespace(namespace);

        SchemaInfo schemaInfo = namespacesToSchemas.get(namespace);
        if (schemaInfo == null) {
          schemaInfo = new SchemaInfo();
          schemaInfo.setId(prefix);
          schemaInfo.setNamespace(namespace);
          namespacesToSchemas.put(namespace, schemaInfo);
        }
        schemaInfo.getTypeDefinitions().add(typeDef);

        REFERENCE_STACK.get().addFirst("\"see also\" annotation");
        addSeeAlsoTypeDefinitions(typeDef);
        REFERENCE_STACK.get().removeFirst();

        for (Element element : typeDef.getElements()) {
          if (includeReferencedClasses()) {
            REFERENCE_STACK.get().addFirst("accessor " + element.getSimpleName() + " of type definition " + typeDef.getQualifiedName());
            addReferencedTypeDefinitions(element);
            REFERENCE_STACK.get().removeFirst();
          }

          ImplicitSchemaElement implicitElement = getImplicitElement(element);
          if (implicitElement != null) {
            String implicitElementNamespace = element.isWrapped() ? element.getWrapperNamespace() : element.getNamespace();
            SchemaInfo referencedSchemaInfo = namespacesToSchemas.get(implicitElementNamespace);
            if (referencedSchemaInfo == null) {
              referencedSchemaInfo = new SchemaInfo();
              referencedSchemaInfo.setId(addNamespace(implicitElementNamespace));
              referencedSchemaInfo.setNamespace(implicitElementNamespace);
              namespacesToSchemas.put(implicitElementNamespace, referencedSchemaInfo);
            }
            referencedSchemaInfo.getImplicitSchemaElements().add(implicitElement);
          }
        }

        for (Attribute attribute : typeDef.getAttributes()) {
          if (includeReferencedClasses()) {
            REFERENCE_STACK.get().addFirst("accessor " + attribute.getSimpleName() + " of type definition " + typeDef.getQualifiedName());
            addReferencedTypeDefinitions(attribute);
            REFERENCE_STACK.get().removeFirst();
          }
          ImplicitSchemaAttribute implicitAttribute = getImplicitAttribute(attribute);
          if (implicitAttribute != null) {
            String implicitAttributeNamespace = attribute.getNamespace();
            SchemaInfo referencedSchemaInfo = namespacesToSchemas.get(implicitAttributeNamespace);
            if (referencedSchemaInfo == null) {
              referencedSchemaInfo = new SchemaInfo();
              referencedSchemaInfo.setId(addNamespace(implicitAttributeNamespace));
              referencedSchemaInfo.setNamespace(implicitAttributeNamespace);
              namespacesToSchemas.put(implicitAttributeNamespace, referencedSchemaInfo);
            }
            referencedSchemaInfo.getImplicitSchemaAttributes().add(implicitAttribute);
          }
        }

        if (typeDef.getAnyAttributeQNameEnumRef() != null) {
          REFERENCE_STACK.get().addFirst("qname enum ref on @XmlAnyAttribute of type definition " + typeDef.getQualifiedName());
View Full Code Here

      add(rootElement.getSchema());

      String namespace = rootElement.getNamespace();
      String prefix = addNamespace(namespace);

      SchemaInfo schemaInfo = namespacesToSchemas.get(namespace);
      if (schemaInfo == null) {
        schemaInfo = new SchemaInfo();
        schemaInfo.setId(prefix);
        schemaInfo.setNamespace(namespace);
        namespacesToSchemas.put(namespace, schemaInfo);
      }
      schemaInfo.getGlobalElements().add(rootElement);

      if (includeReferencedClasses()) {
        REFERENCE_STACK.get().addFirst("root element " + rootElement.getQualifiedName());
        addReferencedTypeDefinitions(rootElement);
        REFERENCE_STACK.get().removeFirst();
View Full Code Here

    add(registry.getSchema());

    String namespace = registry.getSchema().getNamespace();
    String prefix = addNamespace(namespace);

    SchemaInfo schemaInfo = namespacesToSchemas.get(namespace);
    if (schemaInfo == null) {
      schemaInfo = new SchemaInfo();
      schemaInfo.setId(prefix);
      schemaInfo.setNamespace(namespace);
      namespacesToSchemas.put(namespace, schemaInfo);
    }
    schemaInfo.getRegistries().add(registry);
    REFERENCE_STACK.get().addFirst("registry " + registry.getQualifiedName());
    addReferencedTypeDefinitions(registry);
    for (LocalElementDeclaration led : registry.getLocalElementDeclarations()) {
      REFERENCE_STACK.get().addFirst("method " + led.getSimpleName());
      add(led);
View Full Code Here

  public void add(LocalElementDeclaration led) {
    String namespace = led.getNamespace();
    String prefix = addNamespace(namespace);

    SchemaInfo schemaInfo = namespacesToSchemas.get(namespace);
    if (schemaInfo == null) {
      schemaInfo = new SchemaInfo();
      schemaInfo.setId(prefix);
      schemaInfo.setNamespace(namespace);
      namespacesToSchemas.put(namespace, schemaInfo);
    }
    schemaInfo.getLocalElementDeclarations().add(led);
    addReferencedTypeDefinitions(led);
  }
View Full Code Here

   */
  public void add(Schema schema) {
    String namespace = schema.getNamespace();
    String prefix = addNamespace(namespace);
    this.namespacesToPrefixes.putAll(schema.getSpecifiedNamespacePrefixes());
    SchemaInfo schemaInfo = namespacesToSchemas.get(namespace);
    if (schemaInfo == null) {
      schemaInfo = new SchemaInfo();
      schemaInfo.setId(prefix);
      schemaInfo.setNamespace(namespace);
      namespacesToSchemas.put(namespace, schemaInfo);
    }

    if (schema.getElementFormDefault() != XmlNsForm.UNSET) {
      for (Schema pckg : schemaInfo.getPackages()) {
        if ((pckg.getElementFormDefault() != null) && (schema.getElementFormDefault() != pckg.getElementFormDefault())) {
          throw new ValidationException(schema.getPosition(), schema.getQualifiedName() + ": inconsistent elementFormDefault declarations: " + pckg.getQualifiedName());
        }
      }
    }

    if (schema.getAttributeFormDefault() != XmlNsForm.UNSET) {
      for (Schema pckg : schemaInfo.getPackages()) {
        if ((pckg.getAttributeFormDefault() != null) && (schema.getAttributeFormDefault() != pckg.getAttributeFormDefault())) {
          throw new ValidationException(schema.getPosition(), schema.getQualifiedName() + ": inconsistent attributeFormDefault declarations: " + pckg.getQualifiedName());
        }
      }
    }

    schemaInfo.getPackages().add(schema);
  }
View Full Code Here

    TemplateModel from = (TemplateModel) list.get(0);
    Object unwrapped = BeansWrapper.getDefaultInstance().unwrap(from);
    Set<Facet> facets = new TreeSet<Facet>();
    if (SchemaInfo.class.isInstance(unwrapped)) {
      SchemaInfo info = (SchemaInfo) unwrapped;
      for (TypeDefinition typeDef : info.getTypeDefinitions()) {
        facets.addAll(typeDef.getFacets());
      }
      for (RootElementDeclaration element : info.getGlobalElements()) {
        facets.addAll(element.getFacets());
      }
    }
    else if (JsonSchemaInfo.class.isInstance(unwrapped)) {
      JsonSchemaInfo schema = (JsonSchemaInfo) unwrapped;
View Full Code Here

          wsdlInfo.setProperty("inlineSchema", inlineWSDLSchemas);
        }
      }

      for (SchemaConfig customConfig : this.schemaConfigs) {
        SchemaInfo schemaInfo = ns2schema.get(customConfig.getNamespace());

        if (schemaInfo != null) {
          if (customConfig.getUseFile() != null) {
            File useFile = getEnunciate().resolvePath(customConfig.getUseFile());
            if (!useFile.exists()) {
              throw new IllegalStateException("File " + useFile + " does not exist.");
            }
            schemaInfo.setProperty("filename", useFile.getName());
            schemaInfo.setProperty("location", useFile.getName());
            schemaInfo.setProperty("file", useFile);
          }

          if (customConfig.getFile() != null) {
            schemaInfo.setProperty("filename", customConfig.getFile());
            schemaInfo.setProperty("location", customConfig.getFile());
          }

          if (customConfig.getLocation() != null) {
            schemaInfo.setProperty("location", customConfig.getLocation());
          }

          if (customConfig.getJaxbBindingVersion() != null) {
            schemaInfo.setProperty("jaxbBindingVersion", customConfig.getJaxbBindingVersion());
          }

          if (customConfig.getAppinfo() != null) {
            schemaInfo.setProperty("appinfo", customConfig.getAppinfo());
          }
        }
      }

      for (WsdlConfig customConfig : this.wsdlConfigs) {
View Full Code Here

    int nsCount = model.getNamespacesToPrefixes().size();
    ComplexTypeDefinition typeDef1 = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.schema.BeanOne"));
    String targetNamespace = typeDef1.getNamespace();
    assertNull(model.findTypeDefinition(typeDef1));
    model.add(typeDef1);
    SchemaInfo schemaInfo = model.getNamespacesToSchemas().get(targetNamespace);
    assertNull("The element form default should not have been set.", schemaInfo.getElementFormDefault());
    assertNull("The attribute form default should not have been set.", schemaInfo.getAttributeFormDefault());
    assertNotNull("The model should have created a schema information associated with a new type definition.", schemaInfo);
    assertTrue(model.typeDefinitions.contains(typeDef1));
    assertNotNull(model.findTypeDefinition(typeDef1));
    assertEquals(targetNamespace, schemaInfo.getNamespace());

    nsCount += 1;
    assertEquals("There should have been one and only one new namespace added", nsCount, model.getNamespacesToPrefixes().size());

    ComplexTypeDefinition typeDef2 = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanOne"));
    targetNamespace = typeDef2.getNamespace();
    assertNull(model.findTypeDefinition(typeDef2));
    model.add(typeDef2);
    schemaInfo = model.getNamespacesToSchemas().get(targetNamespace);
    assertNotNull("The model should have created a schema information associated with a new type definition.", schemaInfo);
    assertTrue(model.typeDefinitions.contains(typeDef2));
    assertNotNull(model.findTypeDefinition(typeDef2));
    assertEquals(targetNamespace, schemaInfo.getNamespace());
    assertEquals("qualified", schemaInfo.getElementFormDefault());
    assertEquals("qualified", schemaInfo.getAttributeFormDefault());
    nsCount += 3;
    assertEquals("There should have been three new namespaces added, as specified in the package info for the schema.", nsCount, model.getNamespacesToPrefixes().size());

    ComplexTypeDefinition typeDef3 = new ComplexTypeDefinition((ClassDeclaration) getDeclaration("org.codehaus.enunciate.samples.anotherschema.BeanTwo"));
    targetNamespace = typeDef3.getNamespace();
    assertNull(model.findTypeDefinition(typeDef3));
    model.add(typeDef3);
    schemaInfo = model.getNamespacesToSchemas().get(targetNamespace);
    assertNotNull("The model should have created a schema information associated with a new type definition.", schemaInfo);
    assertTrue(model.typeDefinitions.contains(typeDef3));
    assertNotNull(model.findTypeDefinition(typeDef3));
    assertEquals(targetNamespace, schemaInfo.getNamespace());
    assertEquals("qualified", schemaInfo.getElementFormDefault());
    assertEquals("qualified", schemaInfo.getAttributeFormDefault());
    assertEquals("There should have been no new namespaces added.", nsCount, model.getNamespacesToPrefixes().size());

    assertEquals(3, model.typeDefinitions.size());
  }
View Full Code Here

TOP

Related Classes of org.codehaus.enunciate.config.SchemaInfo$ImplicitSchemaElementComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.