server
Class DatabaseConnect

java.lang.Object
  extended by server.DatabaseConnect

public class DatabaseConnect
extends java.lang.Object

this class is responsible for the database connect and executes sql queries


Constructor Summary
DatabaseConnect()
           
 
Method Summary
 boolean addInteract(long fromUser, long toUser)
          method which logs who contacts who
 boolean addToContactList(long addUserId, long userId)
          method which adds a user to another users contact list
 boolean changePreferences(UserVerification userver, StandardUser user)
          updating the user preferences like changing nickname, changing email ...
 boolean checkIfInteractionUserHasVoted(long interactionUserUserId, long itemId)
          method checks a interaction user (i have chatted with) has voted for the same item
 boolean checkIfUserIsOwner(long userId, long moduleId)
          This method checks if a user is the owner of a module
 boolean checkLogin(UserVerification userver)
          method which checks if the userlogin (username and password) is correct
 boolean checkPowerUserRequirements(long userId)
          check if user is ready to become a power user or reject if the user does not fulfill the requirements to be a power user requirements to be a PowerUser: - vote 3 times a day or - vote 12 times a week or - vote 30 times a month or else - be a StandardUser
 boolean close()
          method to close an existing database connection
 long createAccount(StandardUser user)
          method to create a new useraccount
 boolean createModule(java.lang.String name, java.lang.String language, java.lang.String description, java.lang.String question, long ownerid)
          method to create a new module
 boolean deleteContact(long deleteUserId, long userId)
          Method to delete a contact from the power user contactlist
 boolean deleteModule(long moduleId)
          deletes a specified module
 boolean deleteSubscription(long userId)
          deletes all subscribed modules of a specified user (long userId)
 boolean deleteSubscription(long userId, long moduleId)
          deletes a module subscription (long moduleId) of a specified user (long userId)
 boolean editOwnModule(long ownerid, long moduleId, java.lang.String name, java.lang.String language, java.lang.String description, java.lang.String question)
          method for a user to edit his own modules
 java.util.Vector<Item> getAllModuleItems(long moduleId)
           
 java.util.Vector<StandardUser> getContactListStandardUser(long userId)
           
 java.util.Vector<java.lang.Integer> getContactListUserIds(long userId)
           
 java.util.Vector<java.lang.Integer> getInteractionUserId(long userId, java.lang.String startDate, java.lang.String endDate)
          get interaction user ids for a specified time range
 java.util.Vector<StandardUser> getInteractionUsers(Item item, long userId)
          gets possible users for interaction (chat)
 java.util.Vector<Module> getModules(java.lang.String lang)
          get all modules of the same language
 java.util.Vector<Module> getOwnModules(long userId)
          returns modules, that the user from Userverification has created
 java.util.Vector<Item> getPersonalizedToplist(long userId, long moduleId)
          simple toplist like the getToplist method with the following difference this toplist is only for PowerUsers. the ranking of the items of the toplist is different it will be checked if the PowerUser who requests the PersonalizedToplist has interacted with another user who has voted for this item. if this condition is true the item will be ranked higher.
 PowerUser getPowerUser(UserVerification userver)
          method which returns a PowerUser object if a user is a PowerUser
 java.util.ArrayList<java.lang.String> getSpamwords()
           
 StandardUser getStandardUser(UserVerification userver)
           
 StandardUser getStandardUserByUserId(long userId)
           
 java.util.Vector<Module> getSubscribedModules(long userId)
          getting all subscribed modules for a specified userId
 java.util.Vector<Item> getToplist(long moduleId)
          method which returns a vector with all items for a specified module sorted by votes (toplist) this toplist shows the DAILY ranking of the items!
 java.util.Vector<Item> getToplistDuration(long moduleId, int days)
          method which returns a vector with all items for a specified module sorted by votes (toplist) this toplist shows the ranking of the items in a specific time range (int days) including today
 int getUserType(UserVerification userver)
          method which gets the user type
 boolean hasVotedForItem(long userId, long itemId)
           
 boolean insertSubscribedModules(long moduleId, long userId)
          add new subscribed modules (update)
 boolean open()
          method to open a new database connection
 boolean setChoice(long userId, long itemId)
          vote for items of a module
 boolean setChoice(long userId, long moduleId, java.lang.String newItemName, java.lang.String url)
          vote for items of a module while creating a new item
 boolean updateUserTypeFlag(long userId, int userType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DatabaseConnect

public DatabaseConnect()
Method Detail

open

public boolean open()
             throws java.lang.Throwable
method to open a new database connection

Returns:
returns if the connection to the database was successfull
Throws:
java.lang.Throwable

close

public boolean close()
method to close an existing database connection

Returns:
returns true if the connection to the database has been closed successfully

createAccount

public long createAccount(StandardUser user)
                   throws java.lang.Throwable
method to create a new useraccount

Parameters:
user -
Returns:
returns true if the account was created successfully
Throws:
java.lang.Throwable

createModule

public boolean createModule(java.lang.String name,
                            java.lang.String language,
                            java.lang.String description,
                            java.lang.String question,
                            long ownerid)
                     throws java.lang.Throwable
method to create a new module

Parameters:
name - of the module
question - for the module
description - for the module
Returns:
returns true if the module was created successfully
Throws:
java.lang.Throwable

setChoice

public boolean setChoice(long userId,
                         long itemId)
                  throws java.lang.Throwable
vote for items of a module

Parameters:
userId -
itemId -
Returns:
true if successfull
Throws:
java.lang.Throwable

setChoice

public boolean setChoice(long userId,
                         long moduleId,
                         java.lang.String newItemName,
                         java.lang.String url)
                  throws java.lang.Throwable
vote for items of a module while creating a new item

Parameters:
userId -
moduleId -
newItemName -
url -
Returns:
true if successfull
Throws:
java.lang.Throwable

addInteract

public boolean addInteract(long fromUser,
                           long toUser)
                    throws java.lang.Throwable
method which logs who contacts who

Parameters:
fromUser -
toUser -
Returns:
true if successfull
Throws:
java.lang.Throwable

addToContactList

public boolean addToContactList(long addUserId,
                                long userId)
                         throws java.lang.Throwable
method which adds a user to another users contact list

Parameters:
addUserId -
userId -
Returns:
true if successfull
Throws:
java.lang.Throwable

insertSubscribedModules

public boolean insertSubscribedModules(long moduleId,
                                       long userId)
add new subscribed modules (update)

Parameters:
moduleId -
userId -
Returns:
true if successfull

checkLogin

public boolean checkLogin(UserVerification userver)
                   throws java.lang.Throwable
method which checks if the userlogin (username and password) is correct

Parameters:
userver -
Returns:
true if username and password are correct else false
Throws:
java.lang.Throwable

getUserType

public int getUserType(UserVerification userver)
                throws java.lang.Throwable
method which gets the user type

Parameters:
userver -
Returns:
0 error, 1 StandardUser, 2 PowerUser
Throws:
java.lang.Throwable

getStandardUser

public StandardUser getStandardUser(UserVerification userver)
                             throws java.lang.Throwable
Parameters:
userver -
Returns:
returns a StandardUser object with all the settings for a specified user stored in the database
Throws:
java.lang.Throwable

getPowerUser

public PowerUser getPowerUser(UserVerification userver)
                       throws java.lang.Throwable
method which returns a PowerUser object if a user is a PowerUser

Parameters:
userver -
Returns:
PowerUser object
Throws:
java.lang.Throwable

getStandardUserByUserId

public StandardUser getStandardUserByUserId(long userId)
                                     throws java.lang.Throwable
Parameters:
userId -
Returns:
returns a StandardUser object with all the settings for a specified user stored in the database
Throws:
java.lang.Throwable

getToplist

public java.util.Vector<Item> getToplist(long moduleId)
                                  throws java.lang.Throwable
method which returns a vector with all items for a specified module sorted by votes (toplist) this toplist shows the DAILY ranking of the items! example: somebody requests a toplist at 2007-02-15 22:15:00 the result toplist will be in the range from 2007-02-14 22:15:00 to 2007-02-15 22:15:00 (last 24 hours)

Parameters:
moduleId -
Returns:
vector with all items for a specified module sorted by votes
Throws:
java.lang.Throwable

getToplistDuration

public java.util.Vector<Item> getToplistDuration(long moduleId,
                                                 int days)
                                          throws java.lang.Throwable
method which returns a vector with all items for a specified module sorted by votes (toplist) this toplist shows the ranking of the items in a specific time range (int days) including today

Parameters:
moduleId -
days -
Returns:
vector with all items for a specified module sorted by votes. toplist shows the ranking of the items in a specific time range
Throws:
java.lang.Throwable

getPersonalizedToplist

public java.util.Vector<Item> getPersonalizedToplist(long userId,
                                                     long moduleId)
                                              throws java.lang.Throwable
simple toplist like the getToplist method with the following difference this toplist is only for PowerUsers. the ranking of the items of the toplist is different it will be checked if the PowerUser who requests the PersonalizedToplist has interacted with another user who has voted for this item. if this condition is true the item will be ranked higher. that means normal votes + 5. if the PowerUser who requests the PersonalizedToplist has another user who has voted for this item in his contactlist the item will be ranked votes + 20 same in GERMAN: ================= normale topliste wie methode getToplist mit dem unterschied nur für PowerUser. es wird geprueft, ob mit benutzern, die für ein in der topliste vorhandenes item gevoted haben interagiert (gechatted) wurde. wenn gechatted wurde, wird dieses item auch wenn es moeglicherweise weniger votes hat, hoeher gerankt (wenn interagiert wurde werden 5 votes dazugezaehlt --> hoeheres ranking). wenn man nicht nur gechatted hat sondern einen anderen benutzer, der fuer dieses item gevoted hat, sogar in seiner contactlist hat, wird das item noch hoeher gerankt (20 votes dazugezählt).

Parameters:
moduleId -
Returns:
list with items personally arranged
Throws:
java.lang.Throwable

getInteractionUserId

public java.util.Vector<java.lang.Integer> getInteractionUserId(long userId,
                                                                java.lang.String startDate,
                                                                java.lang.String endDate)
                                                         throws java.lang.Throwable
get interaction user ids for a specified time range

Parameters:
userId -
startDate -
endDate -
Returns:
Vector with interaction user ids for a specified time range
Throws:
java.lang.Throwable

checkIfInteractionUserHasVoted

public boolean checkIfInteractionUserHasVoted(long interactionUserUserId,
                                              long itemId)
                                       throws java.lang.Throwable
method checks a interaction user (i have chatted with) has voted for the same item

Parameters:
interactionUserUserId -
itemId -
Returns:
true if interaction user (i have chatted with) has voted for the same item
Throws:
java.lang.Throwable

getSubscribedModules

public java.util.Vector<Module> getSubscribedModules(long userId)
                                              throws java.lang.Throwable
getting all subscribed modules for a specified userId

Parameters:
userId -
Returns:
Vector with all subscribed modules for a specified userId
Throws:
java.lang.Throwable

getModules

public java.util.Vector<Module> getModules(java.lang.String lang)
                                    throws java.lang.Throwable
get all modules of the same language

Parameters:
lang -
Returns:
get all modules of the same language
Throws:
java.lang.Throwable

getOwnModules

public java.util.Vector<Module> getOwnModules(long userId)
                                       throws java.lang.Throwable
returns modules, that the user from Userverification has created

Parameters:
userId -
Returns:
returns modules, that the user from Userverification has created
Throws:
java.lang.Throwable

hasVotedForItem

public boolean hasVotedForItem(long userId,
                               long itemId)
                        throws java.lang.Throwable
Parameters:
userId -
Returns:
get modules, for which the user can choose an item (if not already chosen --> one per day)
Throws:
java.lang.Throwable

getAllModuleItems

public java.util.Vector<Item> getAllModuleItems(long moduleId)
                                         throws java.lang.Throwable
Parameters:
moduleId -
Returns:
Vector with all items of a specified module (moduleId)
Throws:
java.lang.Throwable

getContactListUserIds

public java.util.Vector<java.lang.Integer> getContactListUserIds(long userId)
                                                          throws java.lang.Throwable
Parameters:
userId -
Returns:
Vector with all userIds of a users contactlist
Throws:
java.lang.Throwable

getContactListStandardUser

public java.util.Vector<StandardUser> getContactListStandardUser(long userId)
                                                          throws java.lang.Throwable
Parameters:
userId -
Returns:
returns the StandardUser objects for all contacts on the contactlist of a power user
Throws:
java.lang.Throwable

checkIfUserIsOwner

public boolean checkIfUserIsOwner(long userId,
                                  long moduleId)
                           throws java.lang.Throwable
This method checks if a user is the owner of a module

Parameters:
userId -
moduleId -
Returns:
true if owner else false
Throws:
java.lang.Throwable

checkPowerUserRequirements

public boolean checkPowerUserRequirements(long userId)
                                   throws java.lang.Throwable
check if user is ready to become a power user or reject if the user does not fulfill the requirements to be a power user requirements to be a PowerUser: - vote 3 times a day or - vote 12 times a week or - vote 30 times a month or else - be a StandardUser

Parameters:
userId -
Returns:
true if condition fulfilled
Throws:
java.lang.Throwable

getSpamwords

public java.util.ArrayList<java.lang.String> getSpamwords()
                                                   throws java.lang.Throwable
Returns:
ArrayList with all spamwords (bad words) for the spamfilter
Throws:
java.lang.Throwable

changePreferences

public boolean changePreferences(UserVerification userver,
                                 StandardUser user)
                          throws java.lang.Throwable
updating the user preferences like changing nickname, changing email ...

Parameters:
user -
Returns:
state if preferences have been change successfully
Throws:
java.lang.Throwable

editOwnModule

public boolean editOwnModule(long ownerid,
                             long moduleId,
                             java.lang.String name,
                             java.lang.String language,
                             java.lang.String description,
                             java.lang.String question)
method for a user to edit his own modules

Parameters:
ownerid -
moduleId -
name -
language -
description -
question -
Returns:
true if module updated successfully

updateUserTypeFlag

public boolean updateUserTypeFlag(long userId,
                                  int userType)
                           throws java.lang.Throwable
Parameters:
userType - 1 = StandardUser, 2 = PowerUser
Returns:
true if successfull
Throws:
java.lang.Throwable

deleteModule

public boolean deleteModule(long moduleId)
                     throws java.lang.Throwable
deletes a specified module

Parameters:
moduleId -
Returns:
true if successfully deleted
Throws:
java.lang.Throwable

deleteContact

public boolean deleteContact(long deleteUserId,
                             long userId)
                      throws java.lang.Throwable
Method to delete a contact from the power user contactlist

Parameters:
deleteUserId -
userId -
Returns:
true if successfully deleted
Throws:
java.lang.Throwable

deleteSubscription

public boolean deleteSubscription(long userId,
                                  long moduleId)
                           throws java.lang.Throwable
deletes a module subscription (long moduleId) of a specified user (long userId)

Parameters:
userId -
moduleId -
Returns:
true if successfully deleted
Throws:
java.lang.Throwable

deleteSubscription

public boolean deleteSubscription(long userId)
                           throws java.lang.Throwable
deletes all subscribed modules of a specified user (long userId)

Parameters:
userId -
Returns:
true if successfully deleted
Throws:
java.lang.Throwable

getInteractionUsers

public java.util.Vector<StandardUser> getInteractionUsers(Item item,
                                                          long userId)
                                                   throws java.lang.Throwable
gets possible users for interaction (chat)

Parameters:
item -
userId -
Returns:
Vector with possible users for interaction (chat)
Throws:
java.lang.Throwable