org.wso2.carbon.registry.core.jdbc.dao
Class JDBCTagsVersionDAO

java.lang.Object
  extended by org.wso2.carbon.registry.core.jdbc.dao.JDBCTagsDAO
      extended by org.wso2.carbon.registry.core.jdbc.dao.JDBCTagsVersionDAO
All Implemented Interfaces:
TagsDAO

public class JDBCTagsVersionDAO
extends JDBCTagsDAO
implements TagsDAO

An extension of JDBCTagsDAO implements TagsDAO to store tags on a JDBC-based database, when versioning for tags has been enabled.


Field Summary
 
Fields inherited from class org.wso2.carbon.registry.core.jdbc.dao.JDBCTagsDAO
ADD_TAG_LOCK
 
Constructor Summary
JDBCTagsVersionDAO(DAOManager daoManager)
          Default constructor
 
Method Summary
 void addTagging(java.lang.String tagName, ResourceImpl resource, java.lang.String userID)
          Method to persist a tag.
 void addTaggings(ResourceImpl resource, TaggingDO[] taggingDOs)
          Method to persist tags.
 void copyTags(ResourceImpl fromResource, ResourceImpl toResource)
          Method to copy tags.
 java.util.List getPathsWithAnyTag(java.lang.String[] tags)
          Method to obtain the list of paths having any of the given tags.
 ResourceImpl getResourceWithMinimumData(java.lang.String path)
          Gets the resource with sufficient data to differentiate it from another resource.
 long getTagCount(ResourceImpl resourceImpl, java.lang.String tag)
          Method to get the number of tags added to the given resource, by the given name.
 java.util.List<TaggingDO> getTagDOs(ResourceImpl resourceImpl)
          Method to get the data objects of tags added to the given resource.
 TaggingDO getTagging(long taggingID)
          Method to get a tagging by the given id.
 TaggingDO[] getTagging(ResourceImpl resource)
          Method to get all taggings added to a given resource.
 TaggingDO[] getTagging(ResourceImpl resource, java.lang.String tag, java.lang.String userID)
          Method to get a tagging added to a given resource by the given user.
 java.lang.String[] getTags(ResourceImpl resourceImpl)
          Method to get the names of tags added to the given resource.
 Tag[] getTagsWithCount(ResourceImpl resourceImpl)
          Method to get tags added to the given resource, along with the count.
 void moveTagPaths(ResourceIDImpl source, ResourceIDImpl target)
          Method to move tag paths.
 void moveTags(ResourceIDImpl source, ResourceIDImpl target)
          Method to move tags.
 boolean taggingExists(java.lang.String tagName, ResourceImpl resourceImpl, java.lang.String userID)
          Method to determine whether the given tag exists.
 
Methods inherited from class org.wso2.carbon.registry.core.jdbc.dao.JDBCTagsDAO
getPathsWithTag, removeTags, removeTags, removeTags
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.wso2.carbon.registry.core.dao.TagsDAO
removeTags, removeTags, removeTags
 

Constructor Detail

JDBCTagsVersionDAO

public JDBCTagsVersionDAO(DAOManager daoManager)
Default constructor

Parameters:
daoManager - instance of the data access object manager.
Method Detail

addTagging

public void addTagging(java.lang.String tagName,
                       ResourceImpl resource,
                       java.lang.String userID)
                throws RegistryException
Method to persist a tag.

Specified by:
addTagging in interface TagsDAO
Overrides:
addTagging in class JDBCTagsDAO
Parameters:
resource - the resource
userID - the id of the user who added the tag.
tagName - the name of tag to be persisted.
Throws:
RegistryException - if some error occurs while adding a tag

addTaggings

public void addTaggings(ResourceImpl resource,
                        TaggingDO[] taggingDOs)
                 throws RegistryException
Method to persist tags.

Specified by:
addTaggings in interface TagsDAO
Overrides:
addTaggings in class JDBCTagsDAO
Parameters:
resource - the resource
taggingDOs - the tags to be persisted.
Throws:
RegistryException - if some error occurs while adding tags

copyTags

public void copyTags(ResourceImpl fromResource,
                     ResourceImpl toResource)
              throws RegistryException
Method to copy tags.

Specified by:
copyTags in interface TagsDAO
Overrides:
copyTags in class JDBCTagsDAO
Parameters:
fromResource - the source resource.
toResource - the target resource.
Throws:
RegistryException - if some error occurs while copying tags

taggingExists

public boolean taggingExists(java.lang.String tagName,
                             ResourceImpl resourceImpl,
                             java.lang.String userID)
                      throws RegistryException
Method to determine whether the given tag exists.

Specified by:
taggingExists in interface TagsDAO
Overrides:
taggingExists in class JDBCTagsDAO
Parameters:
resourceImpl - the resource
userID - the id of the user who added the tag.
tagName - the name of tag to be persisted.
Returns:
whether the given tag exists.
Throws:
RegistryException - if some error occurs while checking whether a tag exists.

getTags

public java.lang.String[] getTags(ResourceImpl resourceImpl)
                           throws RegistryException
Method to get the names of tags added to the given resource.

Specified by:
getTags in interface TagsDAO
Overrides:
getTags in class JDBCTagsDAO
Parameters:
resourceImpl - the resource.
Returns:
array of tag names.
Throws:
RegistryException - if an error occurs while getting the tag names.

getTagDOs

public java.util.List<TaggingDO> getTagDOs(ResourceImpl resourceImpl)
                                    throws RegistryException
Method to get the data objects of tags added to the given resource.

Specified by:
getTagDOs in interface TagsDAO
Overrides:
getTagDOs in class JDBCTagsDAO
Parameters:
resourceImpl - the resource.
Returns:
list of tagging data objects.
Throws:
RegistryException - if an error occurs while getting the tagging data objects.

getPathsWithAnyTag

public java.util.List getPathsWithAnyTag(java.lang.String[] tags)
                                  throws RegistryException
Method to obtain the list of paths having any of the given tags.

Specified by:
getPathsWithAnyTag in interface TagsDAO
Overrides:
getPathsWithAnyTag in class JDBCTagsDAO
Parameters:
tags - the tags.
Returns:
a list of paths.
Throws:
RegistryException - if an error occurs.

getTagCount

public long getTagCount(ResourceImpl resourceImpl,
                        java.lang.String tag)
                 throws RegistryException
Method to get the number of tags added to the given resource, by the given name.

Specified by:
getTagCount in interface TagsDAO
Overrides:
getTagCount in class JDBCTagsDAO
Parameters:
resourceImpl - the resource.
tag - the tag name
Returns:
the number of tags.
Throws:
RegistryException - if an error occurred while getting the number of tags.

getTagsWithCount

public Tag[] getTagsWithCount(ResourceImpl resourceImpl)
                       throws RegistryException
Method to get tags added to the given resource, along with the count.

Specified by:
getTagsWithCount in interface TagsDAO
Overrides:
getTagsWithCount in class JDBCTagsDAO
Parameters:
resourceImpl - the resource.
Returns:
an array of tags (with counts).
Throws:
RegistryException - if an error occurred while getting tags.

getTagging

public TaggingDO[] getTagging(ResourceImpl resource,
                              java.lang.String tag,
                              java.lang.String userID)
                       throws RegistryException
Method to get a tagging added to a given resource by the given user.

Specified by:
getTagging in interface TagsDAO
Overrides:
getTagging in class JDBCTagsDAO
Parameters:
resource - the resource.
tag - the name of the tag.
userID - the id of the user who added the tagging.
Returns:
the tagging data objects.
Throws:
RegistryException - if an error occurs while getting the tagging.

getTagging

public TaggingDO[] getTagging(ResourceImpl resource)
                       throws RegistryException
Method to get all taggings added to a given resource.

Specified by:
getTagging in interface TagsDAO
Overrides:
getTagging in class JDBCTagsDAO
Parameters:
resource - the resource.
Returns:
the tagging data objects.
Throws:
RegistryException - if an error occurs while getting the taggings.

getTagging

public TaggingDO getTagging(long taggingID)
                     throws RegistryException
Method to get a tagging by the given id.

Specified by:
getTagging in interface TagsDAO
Overrides:
getTagging in class JDBCTagsDAO
Parameters:
taggingID - the id of the tagging.
Returns:
the tagging data object.
Throws:
RegistryException - if an error occurs while getting the tagging.

getResourceWithMinimumData

public ResourceImpl getResourceWithMinimumData(java.lang.String path)
                                        throws RegistryException
Gets the resource with sufficient data to differentiate it from another resource. This would populate a ResourceImpl with the path, name and path identifier of a resource.

Specified by:
getResourceWithMinimumData in interface TagsDAO
Overrides:
getResourceWithMinimumData in class JDBCTagsDAO
Parameters:
path - the path of the resource.
Returns:
the resource with minimum data.
Throws:
RegistryException - if an error occurs while retrieving resource data.

moveTags

public void moveTags(ResourceIDImpl source,
                     ResourceIDImpl target)
              throws RegistryException
Method to move tags. This function is not applicable to versioned resources.

Specified by:
moveTags in interface TagsDAO
Overrides:
moveTags in class JDBCTagsDAO
Parameters:
source - the source resource.
target - the target resource.
Throws:
RegistryException - if some error occurs while moving tags

moveTagPaths

public void moveTagPaths(ResourceIDImpl source,
                         ResourceIDImpl target)
                  throws RegistryException
Method to move tag paths. This function is not applicable to versioned resources.

Specified by:
moveTagPaths in interface TagsDAO
Overrides:
moveTagPaths in class JDBCTagsDAO
Parameters:
source - the source resource.
target - the target resource.
Throws:
RegistryException - if some error occurs while moving tag paths


Copyright © 2011 WSO2 Inc. All Rights Reserved.