com.flickrrecsys.db
Class DbFavoritePhotos

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

public class DbFavoritePhotos
extends java.lang.Object

Connection to favourite photos

Author:
Hossein Ghodsi

Constructor Summary
DbFavoritePhotos(java.lang.String path)
          Constructor which gets the connection to the database
 
Method Summary
 boolean anyFpExistForAUser(java.lang.String nsid)
          Check if there is any favourite photo for nsid has already recorded
 boolean checkExistingContacts(java.lang.String nsid, java.lang.String ownerId)
          Check if the contacts has already added to the database
 void deleteUserFavo(java.lang.String nsid)
          Delete favourite photos
 int getFpid(java.lang.String nsid, java.lang.String ownerId)
          Get the favourite photo id
 int getFpidOcc(int fpid)
          Get occurrence
 java.util.Vector<FavoritePhotos> getRecConByFavoPhotos(java.lang.String nsid, int limit)
          Get recommended contact by favourite photos
 int insert(java.lang.String nsid, java.lang.String ownerId)
          Insert favourite photos
 void updateFreq(int fpid, int occ)
          Update number of photos have been favourite
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbFavoritePhotos

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

Parameters:
path -
Method Detail

insert

public int insert(java.lang.String nsid,
                  java.lang.String ownerId)
           throws java.sql.SQLException,
                  java.security.NoSuchAlgorithmException,
                  java.io.UnsupportedEncodingException
Insert favourite photos

Parameters:
nsid - user id from the flickr website
ownerId - user id from the flickr website
Returns:
get the record id of just added
Throws:
java.sql.SQLException
java.security.NoSuchAlgorithmException
java.io.UnsupportedEncodingException

checkExistingContacts

public boolean checkExistingContacts(java.lang.String nsid,
                                     java.lang.String ownerId)
                              throws java.sql.SQLException
Check if the contacts has already added to the database

Parameters:
nsid - user id from the flickr website
ownerId - user id from the flickr website
Returns:
true of false depending on whether the record has already found
Throws:
java.sql.SQLException

updateFreq

public void updateFreq(int fpid,
                       int occ)
                throws java.sql.SQLException
Update number of photos have been favourite

Parameters:
fpid - favourite photo id from the database
occ - number of time
Throws:
java.sql.SQLException

getFpid

public int getFpid(java.lang.String nsid,
                   java.lang.String ownerId)
            throws java.sql.SQLException
Get the favourite photo id

Parameters:
nsid - user id from the flickr website
ownerId - user id from the flickr website
Returns:
favourite photo id
Throws:
java.sql.SQLException

getFpidOcc

public int getFpidOcc(int fpid)
               throws java.sql.SQLException
Get occurrence

Parameters:
fpid - favourite photo id
Returns:
Occurrence
Throws:
java.sql.SQLException

deleteUserFavo

public void deleteUserFavo(java.lang.String nsid)
                    throws java.sql.SQLException
Delete favourite photos

Parameters:
nsid - user id from the flickr wesbite
Throws:
java.sql.SQLException

anyFpExistForAUser

public boolean anyFpExistForAUser(java.lang.String nsid)
                           throws java.sql.SQLException
Check if there is any favourite photo for nsid has already recorded

Parameters:
nsid - user id from the flickr website
Returns:
true or false
Throws:
java.sql.SQLException

getRecConByFavoPhotos

public java.util.Vector<FavoritePhotos> getRecConByFavoPhotos(java.lang.String nsid,
                                                              int limit)
                                                       throws java.sql.SQLException
Get recommended contact by favourite photos

Parameters:
nsid - user id from the flickr account
limit - number of returns
Returns:
a vector of Favourite Photos
Throws:
java.sql.SQLException