Examples of StructureElement


Examples of ca.uhn.fhir.model.dstu.resource.Profile.StructureElement

   
    fillExtensions(theStruct, path, def.getExtensionsNonModifier(), "extension", false);
    fillExtensions(theStruct, path, def.getExtensionsModifier(), "modifierExtension", true);

    if (def.getChildType() == ChildTypeEnum.RESOURCE) {
      StructureElement narrative = theStruct.addElement();
      narrative.setName("text");
      narrative.setPath(join(path, '.') + ".text");
      narrative.getDefinition().addType().setCode(DataTypeEnum.NARRATIVE);
      narrative.getDefinition().setIsModifier(false);
      narrative.getDefinition().setMin(0);
      narrative.getDefinition().setMax("1");

      StructureElement contained = theStruct.addElement();
      contained.setName("contained");
      contained.setPath(join(path, '.') + ".contained");
      contained.getDefinition().addType().getCode().setValue("Resource");
      contained.getDefinition().setIsModifier(false);
      contained.getDefinition().setMin(0);
      contained.getDefinition().setMax("1");
    }

    if (def instanceof BaseRuntimeElementCompositeDefinition) {
      BaseRuntimeElementCompositeDefinition<?> cdef = ((BaseRuntimeElementCompositeDefinition<?>) def);
      for (BaseRuntimeChildDefinition nextChild : cdef.getChildren()) {
        if (nextChild instanceof RuntimeChildUndeclaredExtensionDefinition) {
          continue;
        }

        BaseRuntimeDeclaredChildDefinition child = (BaseRuntimeDeclaredChildDefinition) nextChild;
        StructureElement elem = theStruct.addElement();
        fillMinAndMaxAndDefinitions(child, elem);

        if (child instanceof RuntimeChildResourceBlockDefinition) {
          RuntimeResourceBlockDefinition nextDef = (RuntimeResourceBlockDefinition) child.getSingleChildOrThrow();
          fillProfile(theStruct, elem, nextDef, path, child);
View Full Code Here

Examples of ca.uhn.fhir.model.dstu.resource.Profile.StructureElement

    path.pollLast();
  }

  private void fillExtensions(Structure theStruct, LinkedList<String> path, List<RuntimeChildDeclaredExtensionDefinition> extList, String elementName, boolean theIsModifier) {
    if (extList.size() > 0) {
      StructureElement extSlice = theStruct.addElement();
      extSlice.setName(elementName);
      extSlice.setPath(join(path, '.') + '.' + elementName);
      extSlice.getSlicing().getDiscriminator().setValue("url");
      extSlice.getSlicing().setOrdered(false);
      extSlice.getSlicing().setRules(SlicingRulesEnum.OPEN);
      extSlice.getDefinition().addType().setCode(DataTypeEnum.EXTENSION);

      for (RuntimeChildDeclaredExtensionDefinition nextExt : extList) {
        StructureElement nextProfileExt = theStruct.addElement();
        nextProfileExt.getDefinition().setIsModifier(theIsModifier);
        nextProfileExt.setName(extSlice.getName());
        nextProfileExt.setPath(extSlice.getPath());
        fillMinAndMaxAndDefinitions(nextExt, nextProfileExt);
        StructureElementDefinitionType type = nextProfileExt.getDefinition().addType();
        type.setCode(DataTypeEnum.EXTENSION);
        if (nextExt.isDefinedLocally()) {
          type.setProfile(nextExt.getExtensionUrl().substring(nextExt.getExtensionUrl().indexOf('#')));
        } else {
          type.setProfile(nextExt.getExtensionUrl());
        }
      }
    } else {
      StructureElement extSlice = theStruct.addElement();
      extSlice.setName(elementName);
      extSlice.setPath(join(path, '.') + '.' + elementName);
      extSlice.getDefinition().setIsModifier(theIsModifier);
      extSlice.getDefinition().addType().setCode(DataTypeEnum.EXTENSION);
      extSlice.getDefinition().setMin(0);
      extSlice.getDefinition().setMax("*");
    }
  }
 
View Full Code Here

Examples of ca.uhn.fhir.model.dstu.resource.Profile.StructureElement

    // Scan for children
    retVal.setName(getName());
    Structure struct = retVal.addStructure();
    LinkedList<String> path = new LinkedList<String>();

    StructureElement element = struct.addElement();
    element.getDefinition().setMin(1);
    element.getDefinition().setMax("1");

    fillProfile(struct, element, def, path, null);

    retVal.getStructure().get(0).getElement().get(0).getDefinition().addType().getCode().setValue("Resource");
View Full Code Here

Examples of ca.uhn.fhir.model.dstu.resource.Profile.StructureElement

    theElement.setPath(StringUtils.join(path, '.'));
  }

  private void fillExtensions(Structure theStruct, LinkedList<String> path, List<RuntimeChildDeclaredExtensionDefinition> extList, String elementName, boolean theIsModifier) {
    if (extList.size() > 0) {
      StructureElement extSlice = theStruct.addElement();
      extSlice.setName(elementName);
      extSlice.setPath(join(path, '.') + '.' + elementName);
      extSlice.getSlicing().getDiscriminator().setValue("url");
      extSlice.getSlicing().setOrdered(false);
      extSlice.getSlicing().setRules(SlicingRulesEnum.OPEN);
      extSlice.getDefinition().addType().setCode(DataTypeEnum.EXTENSION);

      for (RuntimeChildDeclaredExtensionDefinition nextExt : extList) {
        StructureElement nextProfileExt = theStruct.addElement();
        nextProfileExt.getDefinition().setIsModifier(theIsModifier);
        nextProfileExt.setName(extSlice.getName());
        nextProfileExt.setPath(extSlice.getPath());
        fillMinAndMaxAndDefinitions(nextExt, nextProfileExt);
        StructureElementDefinitionType type = nextProfileExt.getDefinition().addType();
        type.setCode(DataTypeEnum.EXTENSION);
        if (nextExt.isDefinedLocally()) {
          type.setProfile(nextExt.getExtensionUrl().substring(nextExt.getExtensionUrl().indexOf('#')));
        } else {
          type.setProfile(nextExt.getExtensionUrl());
        }
      }
    } else {
      StructureElement extSlice = theStruct.addElement();
      extSlice.setName(elementName);
      extSlice.setPath(join(path, '.') + '.' + elementName);
      extSlice.getDefinition().setIsModifier(theIsModifier);
      extSlice.getDefinition().addType().setCode(DataTypeEnum.EXTENSION);
      extSlice.getDefinition().setMin(0);
      extSlice.getDefinition().setMax("*");
    }
  }
 
View Full Code Here

Examples of ca.uhn.fhir.model.dstu.resource.Profile.StructureElement

    fillExtensions(theStruct, path, def.getExtensionsNonModifier(), "extension", false);
    fillExtensions(theStruct, path, def.getExtensionsModifier(), "modifierExtension", true);

    if (def.getChildType() == ChildTypeEnum.RESOURCE) {
      StructureElement narrative = theStruct.addElement();
      narrative.setName("text");
      narrative.setPath(join(path, '.') + ".text");
      narrative.getDefinition().addType().setCode(DataTypeEnum.NARRATIVE);
      narrative.getDefinition().setIsModifier(false);
      narrative.getDefinition().setMin(0);
      narrative.getDefinition().setMax("1");

      StructureElement contained = theStruct.addElement();
      contained.setName("contained");
      contained.setPath(join(path, '.') + ".contained");
      contained.getDefinition().addType().getCode().setValue("Resource");
      contained.getDefinition().setIsModifier(false);
      contained.getDefinition().setMin(0);
      contained.getDefinition().setMax("1");
    }

    if (def instanceof BaseRuntimeElementCompositeDefinition) {
      BaseRuntimeElementCompositeDefinition<?> cdef = ((BaseRuntimeElementCompositeDefinition<?>) def);
      for (BaseRuntimeChildDefinition nextChild : cdef.getChildren()) {
        if (nextChild instanceof RuntimeChildUndeclaredExtensionDefinition) {
          continue;
        }

        BaseRuntimeDeclaredChildDefinition child = (BaseRuntimeDeclaredChildDefinition) nextChild;
        StructureElement elem = theStruct.addElement();
        fillMinAndMaxAndDefinitions(child, elem);

        if (child instanceof RuntimeChildResourceBlockDefinition) {
          RuntimeResourceBlockDefinition nextDef = (RuntimeResourceBlockDefinition) child.getSingleChildOrThrow();
          fillProfile(theStruct, elem, nextDef, path, child);
View Full Code Here

Examples of org.jibx.binding.model.StructureElement

                    contain.addChild(value);
                   
                } else if (m_mappedNames.get(tname) != null) {
                   
                    // use mapping definition for class
                    StructureElement structure = new StructureElement();
                    structure.setUsageName("optional");
                    structure.setFieldName(fname);
                    if (((String)m_mappedNames.get(tname)).length() == 0) {
                       
                        // add a name for reference to abstract mapping
                        structure.setName(elementName(tname));
                    }
                    contain.addChild(structure);
                    if (m_verbose) {
                        nestingIndent(System.out);
                        System.out.println("referenced existing binding for " +
                            tname);
                    }
                   
                } else if (simple) {
                   
                    // define a simple value
                    ValueElement value = new ValueElement();
                    value.setFieldName(fname);
                    value.setName(valueName(fname));
                    if (object) {
                        value.setUsageName("optional");
                    }
                    if (!attribute) {
                        value.setStyleName("element");
                    }
                    contain.addChild(value);
                   
                } else if (tname.endsWith("[]")) {
                   
                    // array, check if item type has a mapping
                    String bname = tname.substring(0, tname.length()-2);
                    if (m_mappedNames.get(bname) == null) {
                       
                        // no mapping, use collection with inline structure
                        // TODO: fill it in
                        throw new JiBXException("Base element type " + bname +
                            " must be mapped");
                       
                    } else {
                       
                        // mapping for type, use simple collection
                        CollectionElement collection = new CollectionElement();
                        collection.setUsageName("optional");
                        collection.setFieldName(fname);
                        contain.addChild(collection);
                    }
                   
                } else {
                   
                    // no defined handling, check for collection vs. structure
                    ClassFile pcf = ClassCache.requireClassFile(tname);
                    StructureElementBase element;
                    if (pcf.isImplements("Ljava/util/List;")) {
                       
                        // create a collection for list subclass
                        System.err.println("Warning: field " + fname +
                            " requires mapped implementation of item classes");
                        element = new CollectionElement();
                        element.setComment(" add details of collection items " +
                            "to complete binding definition ");
                        element.setFieldName(fname);
                       
                        // specify factory method if just typed as interface
                        if ("java.util.List".equals(tname)) {
                            element.setFactoryName
                                ("org.jibx.runtime.Utility.arrayListFactory");
                        }
                       
                    } else if (pcf.isInterface() ||
                        m_ignoreNames.contains(tname)) {
                       
                        // create mapping reference with warning for interface
                        nestingIndent(System.err);
                        System.err.println("Warning: reference to interface " +
                            "or abstract class " + tname +
                            " requires mapped implementation");
                        element = new StructureElement();
                        element.setFieldName(fname);
                       
                    } else {
                       
                        // handle other types of structures directly
View Full Code Here

Examples of org.jibx.binding.model.StructureElement

                        contain.addChild(value);
                       
                    } else if (m_mappedNames.get(tname) != null) {
                       
                        // use mapping definition for class
                        StructureElement structure = new StructureElement();
                        structure.setUsageName("optional");
                        structure.setGetName(gname);
                        structure.setSetName(sname);
                        if (((String)m_mappedNames.get(tname)).length() == 0) {
                           
                            // add a name for reference to abstract mapping
                            structure.setName(elementName(tname));
                        }
                        contain.addChild(structure);
                        if (m_verbose) {
                            nestingIndent(System.out);
                            System.out.println
                                ("referenced existing binding for " + tname);
                        }
                       
                    } else if (tname.endsWith("[]")) {
                       
                        // array, only supported for mapped base type
                        String bname = tname.substring(0, tname.length()-2);
                        if (m_mappedNames.get(bname) == null) {
                            throw new JiBXException("Base element type " +
                                bname + " must be mapped");
                        } else {
                            StructureElement structure = new StructureElement();
                            structure.setUsageName("optional");
                            structure.setGetName(gname);
                            structure.setSetName(sname);
                            structure.setMarshallerName
                                ("org.jibx.extras.TypedArrayMapper");
                            structure.setUnmarshallerName
                                ("org.jibx.extras.TypedArrayMapper");
                            contain.addChild(structure);
                        }
                       
                    } else {
                       
                        // no defined handling, check collection vs. structure
                        ClassFile pcf = ClassCache.requireClassFile(tname);
                        StructureElementBase element;
                        if (pcf.isImplements("Ljava/util/List;")) {
                           
                            // create a collection for list subclass
                            System.err.println("Warning: property " + pname +
                                " requires mapped implementation of item " +
                                "classes");
                            element = new CollectionElement();
                            element.setComment(" add details of collection " +
                                "items to complete binding definition ");
                            element.setGetName(gname);
                            element.setSetName(sname);
                           
                            // specify factory method if just typed as interface
                            if ("java.util.List".equals(tname)) {
                                element.setFactoryName("org.jibx.runtime." +
                                    "Utility.arrayListFactory");
                            }
                           
                        } else if (pcf.isInterface() ||
                            m_ignoreNames.contains(tname)) {
                           
                            // mapping reference with warning for interface
                            nestingIndent(System.err);
                            System.err.println("Warning: reference to " +
                                "interface or abstract class " + tname +
                                " requires mapped implementation");
                            element = new StructureElement();
                            element.setGetName(gname);
                            element.setSetName(sname);
                           
                        } else {
                           
View Full Code Here

Examples of org.jibx.binding.model.StructureElement

        ClassFile sf = cf.getSuperFile();
        String sname = sf.getName();
        if (!"java.lang.Object".equals(sname) &&
            !m_ignoreNames.contains(sname)) {
            if (m_mappedNames.get(sname) != null) {
                StructureElement structure = new StructureElement();
                structure.setMapAsName(sname);
                structure.setName(elementName(sname));
                contain.addChild(structure);
            } else if (m_beanNames.get(sname) != null) {
                defineProperties(sf, (ArrayList)m_beanNames.get(sname),
                    false, contain);
            } else if (sf.getRawClass().getFields().length > 0) {
View Full Code Here

Examples of org.jibx.binding.model.StructureElement

                cname + "; consider adding to mapping list");
        } else {
            m_structureNames.add(cname);
        }
        m_structureStack.push(cname);
        StructureElement element = new StructureElement();
        element.setFieldName(fname);
        element.setName(valueName(fname));
        defineStructure(cf, element);
        if (element.children().isEmpty()) {
            throw new JiBXException("No content found for class " + cname);
        }
        m_structureStack.pop();
        if (m_verbose) {
            nestingIndent(System.out);
View Full Code Here

Examples of org.jibx.binding.model.StructureElement

        assertEquals("mapped class", mapping.getClassName(), "org.jibx.binding.generator.DataClass1");
        assertEquals("default element name", "dataClass1", mapping.getName());
        assertEquals("mapped items", 1, mapping.children().size());
        child = mapping.children().get(0);
        assertTrue("child type", child instanceof StructureElement);
        StructureElement struct = (StructureElement)child;
        assertEquals("mapping reference structure content", 0, struct.children().size());
        qname = struct.getMapAsQName();
        assertNotNull("type name", qname);
        assertEquals("reference type name", "dataClass1", qname.getName());
        assertEquals("reference type namespace", "http://jibx.org/binding/generator", qname.getUri());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.