com.flickrrecsys.db
Class DbUserGroups

java.lang.Object
  extended by com.flickrrecsys.db.DbUserGroups

public class DbUserGroups
extends java.lang.Object

Connecting to user group table

Author:
Hossein Ghodsi

Constructor Summary
DbUserGroups(java.lang.String path)
          Constructor which gets the connection to the database
 
Method Summary
 boolean alreadyExist(java.lang.String nsid, int gid)
          Check if the combination of user id and local group id exists in the database
 boolean anyGroupsExistForAUser(java.lang.String nsid)
          Check if nsid has joined any groups
 void delete(java.lang.String nsid)
          Delete joined groups by nsid
 java.util.Vector<java.lang.String> getChosenGroupsByNsid(java.lang.String nsid)
          Get groups already selected as most frequently used
 java.util.Vector<Group> getChosenGroupsByNsidForList(java.lang.String nsid)
          Get list of groups flagged as most frequently used
 java.util.Vector<Group> getNotChosenGroupsByNsid(java.lang.String nsid)
          Get groups which have not yet been chosen as frequently used
 java.lang.String getNumberOfGroups(java.lang.String nsid)
          Total number of groups already selected as most frequently used
 void insert(java.lang.String nsid, int gid)
          Insert user groups
 void updateFreqUsed(java.lang.String freqUsed, int gid, java.lang.String nsid)
          Update the list of frequently used
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbUserGroups

public DbUserGroups(java.lang.String path)
Constructor which gets the connection to the database

Parameters:
path - to where the database details are
Method Detail

insert

public void insert(java.lang.String nsid,
                   int gid)
            throws java.sql.SQLException,
                   java.security.NoSuchAlgorithmException,
                   java.io.UnsupportedEncodingException
Insert user groups

Parameters:
nsid - user id from flickr wbesite
gid - local group id
Throws:
java.sql.SQLException
java.security.NoSuchAlgorithmException
java.io.UnsupportedEncodingException

alreadyExist

public boolean alreadyExist(java.lang.String nsid,
                            int gid)
                     throws java.sql.SQLException
Check if the combination of user id and local group id exists in the database

Parameters:
nsid - user id from Flickr website
gid - group id
Returns:
true/false
Throws:
java.sql.SQLException

delete

public void delete(java.lang.String nsid)
            throws java.sql.SQLException
Delete joined groups by nsid

Parameters:
nsid - user id from Flickr wbesite
Throws:
java.sql.SQLException

anyGroupsExistForAUser

public boolean anyGroupsExistForAUser(java.lang.String nsid)
                               throws java.sql.SQLException
Check if nsid has joined any groups

Parameters:
nsid - user id from Flickr website
Returns:
true/false
Throws:
java.sql.SQLException

getChosenGroupsByNsid

public java.util.Vector<java.lang.String> getChosenGroupsByNsid(java.lang.String nsid)
                                                         throws java.sql.SQLException
Get groups already selected as most frequently used

Parameters:
nsid - user id from Flickr website
Returns:
list of all groups
Throws:
java.sql.SQLException

getNotChosenGroupsByNsid

public java.util.Vector<Group> getNotChosenGroupsByNsid(java.lang.String nsid)
                                                 throws java.sql.SQLException
Get groups which have not yet been chosen as frequently used

Parameters:
nsid - user id from flickr website
Returns:
list of groups have not yet been chosen as most frequently used
Throws:
java.sql.SQLException

getChosenGroupsByNsidForList

public java.util.Vector<Group> getChosenGroupsByNsidForList(java.lang.String nsid)
                                                     throws java.sql.SQLException
Get list of groups flagged as most frequently used

Parameters:
nsid - user id from flickr website
Returns:
vector of groups
Throws:
java.sql.SQLException

getNumberOfGroups

public java.lang.String getNumberOfGroups(java.lang.String nsid)
                                   throws java.sql.SQLException
Total number of groups already selected as most frequently used

Parameters:
nsid - user id from the flickr website
Returns:
number of groups
Throws:
java.sql.SQLException

updateFreqUsed

public void updateFreqUsed(java.lang.String freqUsed,
                           int gid,
                           java.lang.String nsid)
                    throws java.sql.SQLException
Update the list of frequently used

Parameters:
freqUsed - 0 if not frequently used, 1 if frequently used
gid - local group id
nsid - user id from Flickr website
Throws:
java.sql.SQLException