Class Tag

java.lang.Object
com.erudika.para.core.Tag
All Implemented Interfaces:
Linkable, ParaObject, Votable, Serializable

public class Tag extends Object implements ParaObject
A tag. Must not be null or empty.
Author:
Alex Bogdanovski [[email protected]]
See Also:
  • Constructor Details

    • Tag

      public Tag()
      No-args constructor.
    • Tag

      public Tag(String id)
      Default constructor.
      Parameters:
      id - the tag name
  • Method Details

    • setId

      public final void setId(String id)
      Description copied from interface: ParaObject
      Sets a new id. Must not be null or empty.
      Specified by:
      setId in interface ParaObject
      Parameters:
      id - the new id
    • getObjectURI

      public String getObjectURI()
      Description copied from interface: ParaObject
      The URI of this object. For example: /users/123
      Specified by:
      getObjectURI in interface ParaObject
      Returns:
      the URI
      See Also:
    • getCount

      public Integer getCount()
      The number of objects tagged with this tag.
      Returns:
      the number of times this tag is used
    • setCount

      public void setCount(Integer count)
      Sets the number of objects tagged with this tag.
      Parameters:
      count - a new count
    • getTag

      public String getTag()
      The tag value.
      Returns:
      the tag itself
    • setTag

      public void setTag(String tag)
      Sets the tag value.
      Parameters:
      tag - a tag. Must not be null or empty.
    • getDescription

      public String getDescription()
      Some description text for this tag.
      Returns:
      description
    • setDescription

      public void setDescription(String description)
      Sets the description for the tag.
      Parameters:
      description - some text
    • incrementCount

      public void incrementCount()
      Increments the count when a new object is tagged.
    • decrementCount

      public void decrementCount()
      Decrements the count when a new object is untagged.
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getId

      public final String getId()
      Returns the object ID.
      Specified by:
      getId in interface ParaObject
      Returns:
      the id
    • getType

      public final String getType()
      Returns the object type.
      Specified by:
      getType in interface ParaObject
      Returns:
      the type
    • setType

      public final void setType(String type)
      Sets the object type.
      Specified by:
      setType in interface ParaObject
      Parameters:
      type - the type
    • getAppid

      public String getAppid()
      Returns the app identifier.
      Specified by:
      getAppid in interface ParaObject
      Returns:
      the appid
    • setAppid

      public void setAppid(String appid)
      Sets the app identifier.
      Specified by:
      setAppid in interface ParaObject
      Parameters:
      appid - the appid
    • getTags

      public List<String> getTags()
      Returns the tags.
      Specified by:
      getTags in interface ParaObject
      Returns:
      the tags
      See Also:
    • setTags

      public void setTags(List<String> tags)
      Sets the tags.
      Specified by:
      setTags in interface ParaObject
      Parameters:
      tags - the tags
    • getStored

      public Boolean getStored()
      Returns true if the object is stored in the database.
      Specified by:
      getStored in interface ParaObject
      Returns:
      true if stored
    • setStored

      public void setStored(Boolean stored)
      Sets the stored flag.
      Specified by:
      setStored in interface ParaObject
      Parameters:
      stored - the stored flag
    • getIndexed

      public Boolean getIndexed()
      Returns true if the object is indexed.
      Specified by:
      getIndexed in interface ParaObject
      Returns:
      true if indexed
    • setIndexed

      public void setIndexed(Boolean indexed)
      Sets the indexed flag.
      Specified by:
      setIndexed in interface ParaObject
      Parameters:
      indexed - the indexed flag
    • getCached

      public Boolean getCached()
      Returns true if the object is cached.
      Specified by:
      getCached in interface ParaObject
      Returns:
      true if cached
    • setCached

      public void setCached(Boolean cached)
      Sets the cached flag.
      Specified by:
      setCached in interface ParaObject
      Parameters:
      cached - the cached flag
    • getTimestamp

      public Long getTimestamp()
      Returns the timestamp.
      Specified by:
      getTimestamp in interface ParaObject
      Returns:
      the timestamp
    • setTimestamp

      public void setTimestamp(Long timestamp)
      Sets the timestamp.
      Specified by:
      setTimestamp in interface ParaObject
      Parameters:
      timestamp - the timestamp
    • getCreatorid

      public String getCreatorid()
      Returns the creator ID.
      Specified by:
      getCreatorid in interface ParaObject
      Returns:
      the creatorid
    • setCreatorid

      public void setCreatorid(String creatorid)
      Sets the creator ID.
      Specified by:
      setCreatorid in interface ParaObject
      Parameters:
      creatorid - the creatorid
    • getName

      public final String getName()
      Returns the object name.
      Specified by:
      getName in interface ParaObject
      Returns:
      the name
    • setName

      public final void setName(String name)
      Sets the object name.
      Specified by:
      setName in interface ParaObject
      Parameters:
      name - the name
    • getPlural

      public String getPlural()
      Returns the plural form of the object type.
      Specified by:
      getPlural in interface ParaObject
      Returns:
      the plural name
    • getParentid

      public String getParentid()
      Returns the parent ID.
      Specified by:
      getParentid in interface ParaObject
      Returns:
      the parentid
    • setParentid

      public void setParentid(String parentid)
      Sets the parent ID.
      Specified by:
      setParentid in interface ParaObject
      Parameters:
      parentid - the parentid
    • getUpdated

      public Long getUpdated()
      Returns the updated timestamp.
      Specified by:
      getUpdated in interface ParaObject
      Returns:
      the updated timestamp
    • setUpdated

      public void setUpdated(Long updated)
      Sets the updated timestamp.
      Specified by:
      setUpdated in interface ParaObject
      Parameters:
      updated - the updated timestamp
    • create

      public String create()
      Persists the object to the database.
      Specified by:
      create in interface ParaObject
      Returns:
      the object ID
      See Also:
    • update

      public void update()
      Updates the object in the database.
      Specified by:
      update in interface ParaObject
      See Also:
    • delete

      public void delete()
      Deletes the object from the database.
      Specified by:
      delete in interface ParaObject
      See Also:
    • exists

      public boolean exists()
      Returns true if the object exists in the database.
      Specified by:
      exists in interface ParaObject
      Returns:
      true if exists
      See Also:
    • voteUp

      public boolean voteUp(String userid)
      Votes up for the object.
      Specified by:
      voteUp in interface Votable
      Parameters:
      userid - the voter ID
      Returns:
      true if successful
    • voteDown

      public boolean voteDown(String userid)
      Votes down for the object.
      Specified by:
      voteDown in interface Votable
      Parameters:
      userid - the voter ID
      Returns:
      true if successful
    • getVotes

      public Integer getVotes()
      Returns the number of votes.
      Specified by:
      getVotes in interface Votable
      Returns:
      the votes
    • setVotes

      public void setVotes(Integer votes)
      Sets the number of votes.
      Specified by:
      setVotes in interface Votable
      Parameters:
      votes - the votes
    • getVersion

      public Long getVersion()
      Returns the version of the object.
      Specified by:
      getVersion in interface ParaObject
      Returns:
      the version
    • setVersion

      public void setVersion(Long version)
      Sets the version of the object.
      Specified by:
      setVersion in interface ParaObject
      Parameters:
      version - the version
    • countLinks

      public Long countLinks(String type2)
      Counts the number of links to other objects of a certain type.
      Specified by:
      countLinks in interface Linkable
      Parameters:
      type2 - the other type
      Returns:
      the number of links
    • getLinks

      public List<Linker> getLinks(String type2, Pager... pager)
      Returns a list of links to other objects of a certain type.
      Specified by:
      getLinks in interface Linkable
      Parameters:
      type2 - the other type
      pager - a pager
      Returns:
      a list of links
    • getLinkedObjects

      public <P extends ParaObject> List<P> getLinkedObjects(String type, Pager... pager)
      Returns a list of linked objects of a certain type.
      Specified by:
      getLinkedObjects in interface Linkable
      Type Parameters:
      P - the type of linked objects
      Parameters:
      type - the other type
      pager - a pager
      Returns:
      a list of linked objects
    • findLinkedObjects

      public <P extends ParaObject> List<P> findLinkedObjects(String type, String field, String query, Pager... pager)
      Finds linked objects of a certain type that match a specific field and query.
      Specified by:
      findLinkedObjects in interface Linkable
      Type Parameters:
      P - the type of linked objects
      Parameters:
      type - the other type
      field - the field to search in
      query - the search query
      pager - a pager
      Returns:
      a list of linked objects
    • isLinked

      public boolean isLinked(String type2, String id2)
      Returns true if the object is linked to another object of a certain type and ID.
      Specified by:
      isLinked in interface Linkable
      Parameters:
      type2 - the other type
      id2 - the other ID
      Returns:
      true if linked
    • isLinked

      public boolean isLinked(ParaObject toObj)
      Returns true if the object is linked to another object.
      Specified by:
      isLinked in interface Linkable
      Parameters:
      toObj - the other object
      Returns:
      true if linked
    • link

      public String link(String id2)
      Links the object to another object of a certain type and ID.
      Specified by:
      link in interface Linkable
      Parameters:
      id2 - the other ID
      Returns:
      the link ID
    • unlink

      public void unlink(String type, String id2)
      Unlinks the object from another object of a certain type and ID.
      Specified by:
      unlink in interface Linkable
      Parameters:
      type - the other type
      id2 - the other ID
    • unlinkAll

      public void unlinkAll()
      Unlinks the object from all other objects.
      Specified by:
      unlinkAll in interface Linkable
    • countChildren

      public Long countChildren(String type)
      Counts the number of children of a certain type.
      Specified by:
      countChildren in interface Linkable
      Parameters:
      type - the child type
      Returns:
      the number of children
    • getChildren

      public <P extends ParaObject> List<P> getChildren(String type, Pager... pager)
      Returns a list of children of a certain type.
      Specified by:
      getChildren in interface Linkable
      Type Parameters:
      P - the type of children
      Parameters:
      type - the child type
      pager - a pager
      Returns:
      a list of children
    • getChildren

      public <P extends ParaObject> List<P> getChildren(String type, String field, String term, Pager... pager)
      Returns a list of children of a certain type that match a specific field and term.
      Specified by:
      getChildren in interface Linkable
      Type Parameters:
      P - the type of children
      Parameters:
      type - the child type
      field - the field to search in
      term - the search term
      pager - a pager
      Returns:
      a list of children
    • findChildren

      public <P extends ParaObject> List<P> findChildren(String type, String query, Pager... pager)
      Finds children of a certain type that match a specific query.
      Specified by:
      findChildren in interface Linkable
      Type Parameters:
      P - the type of children
      Parameters:
      type - the child type
      query - the search query
      pager - a pager
      Returns:
      a list of children
    • deleteChildren

      public void deleteChildren(String type)
      Deletes all children of a certain type.
      Specified by:
      deleteChildren in interface Linkable
      Parameters:
      type - the child type
    • toString

      public String toString()
      Returns a JSON string representation of this object.
      Overrides:
      toString in class Object
      Returns:
      JSON string