Class TagService


  • @Singleton
    public class TagService
    extends Object
    Manages the relations between Windup tags and provides API to query these relations.
    Author:
    Ondrej Zizka, ozizka at redhat.com
    • Constructor Detail

      • TagService

        public TagService()
    • Method Detail

      • readTags

        public void readTags​(InputStream tagsXML)
        Read the tag structure from the provided stream.
      • getPrimeTags

        public List<Tag> getPrimeTags()
        Gets all tags that are "prime" tags.
      • getRootTags

        public List<Tag> getRootTags()
        Returns the tags that were root in the definition files. These serve as entry point shortcuts when browsing the graph. We could reduce this to just fewer as the root tags may be connected through parents="...".
      • findTag

        public Tag findTag​(String tagName)
        Returns the Tag with the provided name.
      • getTag

        public Tag getTag​(String tagName)
      • getOrCreateTag

        public Tag getOrCreateTag​(String tagName,
                                  boolean isRef)
        Gets the Tag with the given name or creates a new Tag if one does not already exist.
        Parameters:
        isRef - True if the given tag name is a reference, in which case it should already exist.
      • getAncestorTags

        public Set<Tag> getAncestorTags​(Tag tag)
        Returns all tags that designate this tag. E.g., for "tesla-model3", this would return "car", "vehicle", "vendor-tesla" etc.
      • getDescendantTags

        public Set<Tag> getDescendantTags​(Tag tag)
        Returns all tags that are designated by this tag. E.g., for "vehicle", this would return "ship", "car", "tesla-model3", "bike", etc.
      • isUnderTag

        public boolean isUnderTag​(String superTagName,
                                  String subTagName)
        Convenience method, calls this.isUnderTag(Tag superTag, Tag subTag).
      • isUnderTag

        public boolean isUnderTag​(Tag superTag,
                                  Tag subTag)
        Returns:
        true if the subTag is contained directly or indirectly in the superTag.
      • writeTagsToJavaScript

        public void writeTagsToJavaScript​(Writer writer)
                                   throws IOException
        Writes the JavaScript code describing the tags as Tag classes to given writer.
        Throws:
        IOException