public Structure HarvestExtensionDefn(Profile.ProfileExtensionDefnComponent source)
        {
            Structure target = new Structure();

            target.Name = source.Code;
            Element element = new Element();

            element.Name = source.Code;
            HarvestElementDefinition(source.Definition, element);

            target.Elements.Add(element);
            return(target);
        }
        private void generateExtension(Profile profile, Profile.ProfileExtensionDefnComponent e)
        {
            write("  <tr><td colspan=\"2\" class=\"structure\"><a name=\"extension." + e.Code + "\"> </a><b>Extension " + e.Code + "</b></td></tr>\r\n");
            generateElementInner(profile, e.Definition);

            // DSTU2
            //       if (e.Element.size() > 1) {
            //for (int i = 1; i < e.Element.size(); i++) {
            //  ElementComponent ec = e.Element.get(i);
            //  write("  <tr><td colspan=\"2\" class=\"structure\"><a name=\"extension."+ec.getPath+"\"> </a><b>&nbsp;"+ec.getPath+"</b></td></tr>\r\n");
            //  generateElementInner(profile, ec.Definition);
            //      }
        }
        private String describeExtensionContext(Profile.ProfileExtensionDefnComponent ext)
        {
            switch (ext.ContextType)
            {
            case Profile.ExtensionContext.Datatype:
                return("Use on data type: " + ext.DescribeContext());

            case Profile.ExtensionContext.Extension:
                return("Use on extension: " + ext.DescribeContext());

            case Profile.ExtensionContext.Resource:
                return("Use on resource: " + ext.DescribeContext());

            case Profile.ExtensionContext.Mapping:
                return("Use where element has mapping: " + ext.DescribeContext());
            }

            return(null);
        }
        private void genExtension(List <Row> rows, Profile profile, Profile.ProfileExtensionDefnComponent ext, bool root)
        {
            var r = new  Row();

            rows.Add(r);
            r.setAnchor(ext.Code);

            r.setIcon("icon_extension_simple.png");     // DSTU1
            //if (ext.getChildren().isEmpty())    // DSTU2
            //  r.setIcon("icon_extension_simple.png");
            //else
            //r.setIcon("icon_extension_complex.png");

            var extensionUrl = _pkp.GetLinkForExtensionDefinition(profile, ext);

            r.getCells().Add(new  Cell(null, null, ext.Code, null, null));
            r.getCells().Add(new  Cell(null, null, ext.Definition.DescribeCardinality(), null, null));   //TODO: create rendering extension
            r.getCells().Add(new  Cell(null, null, ext.Definition.DescribeTypeCode(), null, null));      //TODO: create rendering extension
            //    r.getCells().add(gen.new Cell(null, null, ext.getDefinition().getShortDefn(), null, null));
            //    if (root)
            //      r.getCells().add(gen.new Cell(null, null, describeExtensionContext(ext), null, null));
            //    else
            //      r.getCells().add(gen.new Cell());
            if (root)
            {
                r.getCells().Add(new  Cell(null, null, ext.Definition.Short, null, null)
                                 .addPiece(new  Piece("br"))
                                 .addPiece(new  Piece(null, describeExtensionContext(ext), null)));
            }
            else
            {
                r.getCells().Add(new  Cell(null, null, ext.Definition.Short, null, null));
            }

            //foreach (var child in ext.Children)    // DSTU2
            //{
            //  genExtension(gen, r.getSubRows(), child, false);
            //}
        }
 internal string GetLinkForExtensionDefinition(Profile profile, Profile.ProfileExtensionDefnComponent extension)
 {
     return(GetLinkForExtensionDefinition(profile, extension.Code));
 }
 public static string DescribeContext(this Profile.ProfileExtensionDefnComponent ext)
 {
     return(String.Join(", ", ext.Context));
 }
示例#7
0
        private void genElement(String defPath, HierarchicalTableGenerator gen, List <Row> rows, ElementNavigator nav,
                                Profile profile, bool showMissing, String profileUrl, String profileBaseFileName)
        {
            var element = nav.Current;

            if (onlyInformationIsMapping(nav.Structure.Element, element))
            {
                return;                                                           // we don't even show it in this case
            }
            Row row = new Row();

            row.setAnchor(element.Path);
            String s = element.GetNameFromPath();

            bool hasDef = element.Definition != null;
            bool ext    = false;

            if (s == "extension" || s == "modifierExtension")
            {
                row.setIcon("icon_extension_simple.png");
                ext = true;
            }
            else if (!hasDef || element.Definition.Type == null || element.Definition.Type.Count == 0)
            {
                row.setIcon("icon_element.gif");
            }
            else if (hasDef && element.Definition.Type.Count > 1)
            {
                if (allTypesAre(element.Definition.Type, "ResourceReference"))
                {
                    row.setIcon("icon_reference.png");
                }
                else
                {
                    row.setIcon("icon_choice.gif");
                }
            }
            else if (hasDef && element.Definition.Type[0].Code.StartsWith("@"))
            {
                //TODO: That's not a legal code, will this ever appear?
                //I am pretty sure this depends on ElementDefn.NameReference
                row.setIcon("icon_reuse.png");
            }
            else if (hasDef && _pkp.isPrimitive(element.Definition.Type[0].Code))
            {
                row.setIcon("icon_primitive.png");
            }
            else if (hasDef && _pkp.isReference(element.Definition.Type[0].Code))
            {
                row.setIcon("icon_reference.png");
            }
            else if (hasDef && _pkp.isDataType(element.Definition.Type[0].Code))
            {
                row.setIcon("icon_datatype.gif");
            }
            else
            {
                row.setIcon("icon_resource.png");
            }

            String        reference = defPath == null ? null : defPath + makePathLink(element);
            UnusedTracker used      = new UnusedTracker();

            used.used = true;

            Cell left = new Cell(null, reference, s, !hasDef ? null : element.Definition.Formal, null);

            row.getCells().Add(left);

            if (ext)
            {
                // If this element (row) in the table is an extension...
                if (element.Definition != null && element.Definition.Type.Count == 1 && element.Definition.Type[0].Profile != null)
                {
                    Profile.ProfileExtensionDefnComponent extDefn = _pkp.getExtensionDefinition(profile, element.Definition.Type[0].Profile);

                    if (extDefn == null)
                    {
                        row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null));
                        row.getCells().Add(new Cell(null, null, "?? " + element.Definition.Type[0].Profile, null, null));
                        generateDescription(gen, row, element, null, used.used, profileUrl, element.Definition.Type[0].Profile, profile);
                    }
                    else
                    {
                        row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, extDefn.Definition, used), null, null));
                        genTypes(gen, row, extDefn.Definition, profileBaseFileName, profile);
                        generateDescription(gen, row, element, extDefn.Definition, used.used, profileUrl, element.Definition.Type[0].Profile, profile);
                    }
                }
                else if (element.Definition != null)
                {
                    row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null));
                    genTypes(gen, row, element.Definition, profileBaseFileName, profile);
                    generateDescription(gen, row, element, null, used.used, null, null, profile);
                }
                else
                {
                    row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null));
                    row.getCells().Add(new Cell());
                    generateDescription(gen, row, element, null, used.used, null, null, profile);
                }
            }
            else
            {
                row.getCells().Add(new Cell(null, null, !hasDef ? null : describeCardinality(element.Definition, null, used), null, null));

                if (element.Definition != null)
                {
                    genTypes(gen, row, element.Definition, profileBaseFileName, profile);
                }
                else
                {
                    row.getCells().Add(new Cell());
                }

                generateDescription(gen, row, element, null, used.used, null, null, profile);
            }

            if (element.Slicing != null)
            {
                row.setIcon("icon_slice.png");
                row.getCells()[2].getPieces().Clear();

                foreach (Cell cell in row.getCells())
                {
                    foreach (Piece p in cell.getPieces())
                    {
                        p.addStyle("font-style: italic");
                    }
                }
            }

            if (used.used || showMissing)
            {
                rows.Add(row);
            }

            if (!used.used)
            {
                foreach (Cell cell in row.getCells())
                {
                    foreach (Piece p in cell.getPieces())
                    {
                        p.setStyle("text-decoration:line-through");
                        p.setReference(null);
                    }
                }
            }
            else
            {
                if (nav.MoveToFirstChild())
                {
                    do
                    {
                        genElement(defPath, gen, row.getSubRows(), nav, profile, showMissing, profileUrl, profileBaseFileName);
                    } while (nav.MoveToNext());

                    nav.MoveToParent();
                }
            }
        }