|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.gersteinlab.tyna.webapp.data.RDBDataStore
This class is the agent for accessing databases. It hides the subtle details about database access from the client classes, and also restrict the actions that can be taken by them.
| Field Summary | |
protected java.sql.Connection |
conn
The database connection. |
java.lang.String |
OWNED
Owned resource (networks/categories). |
java.lang.String |
PRIVATE
Private resource (networks/categories). |
java.lang.String |
PUBLIC_OR_OWNED
Public or owned resource (networks/categories). |
protected SecurityController |
sc
Security controller |
| Constructor Summary | |
RDBDataStore(javax.servlet.http.HttpSession session)
This method is used to get a connection to the database with configurations specified in the configuration file. |
|
| Method Summary | |
void |
close()
Close the connection. |
void |
commit()
Commit the current transaction. |
void |
deleteCategory(int id)
Delete a category from the database. |
void |
deleteNetwork(int id)
Delete a network from the database. |
void |
deleteNetworkByUser(int id)
Delete a network from the database based on the current user's privilege. |
boolean |
existUser(java.lang.String name)
Check if a user name is already in use. |
protected void |
finalize()
Free unfreed resources. |
Category |
getCategory(int id)
Get a category. |
Network |
getNetwork(int id)
Get a network. |
NetworkFormat |
getNetworkFormat(int id)
Get a network format. |
User |
getUser(java.lang.String name,
java.lang.String password)
Get the information of a user, based on the login name and password of the user. |
int |
insertCategory(Category category)
Insert a new category into the database. |
int |
insertNetwork(Network network)
Insert a new network into the database. |
int |
insertNetworkAttr(NetworkAttr networkAttr)
Insert a new network attribute into the database. |
int |
insertUser(User user,
java.lang.String password)
Insert a new user into the database. |
java.util.List |
listCategories(java.lang.String name,
java.lang.String listType,
java.lang.String order)
List categories. |
java.util.List |
listNetworkAttrs(int type,
java.lang.String order)
List network attributes of a network type. |
java.util.List |
listNetworkFormats()
List network formats. |
java.util.List |
listNetworks(java.lang.String name,
java.lang.String listType,
java.lang.String listNetworkType,
java.lang.String listNetworkAttrName,
java.lang.String listNetworkAttrValue,
java.lang.String order)
List networks. |
java.util.List |
listNetworkTypes(java.lang.String order)
List network types. |
void |
rollback()
Rollback the current transaction. |
void |
setAutoCommit(boolean autoCommit)
Set auto commit of the connection. |
| Methods inherited from class java.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public final java.lang.String PRIVATE
public final java.lang.String OWNED
public final java.lang.String PUBLIC_OR_OWNED
protected java.sql.Connection conn
protected SecurityController sc
| Constructor Detail |
public RDBDataStore(javax.servlet.http.HttpSession session)
throws ConfigException,
java.sql.SQLException
session - The current HTTP session
ConfigException - If there is any problem with the system configuration
java.sql.SQLException - If there is any problem with the database| Method Detail |
public void setAutoCommit(boolean autoCommit)
throws java.sql.SQLException
autoCommit - Whether to auto commit
java.sql.SQLException - If there is any problem in setting the auto commit flag
public void commit()
throws java.sql.SQLException
java.sql.SQLException - If there is any problem in committing the transaction
public void rollback()
throws java.sql.SQLException
java.sql.SQLException - If there is any problem in rolling back the transactionpublic void close()
public User getUser(java.lang.String name,
java.lang.String password)
throws java.sql.SQLException
name - The login name of the userpassword - The passoword of the user
java.sql.SQLException - If there is any problem in executing the query
public boolean existUser(java.lang.String name)
throws java.sql.SQLException
name - The login name of the user
java.sql.SQLException - If there is any problem in executing the query
public int insertUser(User user,
java.lang.String password)
throws java.sql.SQLException
user - The user to be insertedpassword - The password of the user
java.sql.SQLException - If there is any problem in executing the insertion
public java.util.List listNetworkFormats()
throws java.sql.SQLException
java.sql.SQLException - If there is any problem in executing the query
public NetworkFormat getNetworkFormat(int id)
throws java.sql.SQLException
id - The ID of the network format
java.sql.SQLException - If there is any problem in executing the query
public java.util.List listNetworks(java.lang.String name,
java.lang.String listType,
java.lang.String listNetworkType,
java.lang.String listNetworkAttrName,
java.lang.String listNetworkAttrValue,
java.lang.String order)
throws java.sql.SQLException
name - Name of user, null if not logged in.listType - List type:
PRIVATE for private ones (must be owned) only
OWNED for owned ones (public or private) only
PUBLIC_OR_OWNED for owned or publiclistNetworkType - Type of networks to list:
"" for all
ID of the specific network type otherwiselistNetworkAttrName - Attribute name of networks to list:
"" for not specified
Name of the specific network attribute otherwiselistNetworkAttrValue - Attribute value of networks to list:
"" for not specified
Value of the specific network attribute otherwiseorder - The ordering attribute
java.sql.SQLException - If there is any problem in executing the query
public Network getNetwork(int id)
throws java.sql.SQLException
id - The ID of the network
java.sql.SQLException - If there is any problem in executing the query
public int insertNetwork(Network network)
throws java.sql.SQLException
network - The network to be inserted
java.sql.SQLException - If there is any problem in executing the insertion
public void deleteNetwork(int id)
throws java.sql.SQLException
id - The ID of the network to be deleted
java.sql.SQLException - If there is any problem in executing the deletion
public void deleteNetworkByUser(int id)
throws java.sql.SQLException,
SecurityException
id - The ID of the network to be deleted
java.sql.SQLException - If there is any problem in executing the deletion
SecurityException - If the current user does not have the permission to delete the network
public java.util.List listNetworkTypes(java.lang.String order)
throws java.sql.SQLException
order - The ordering attribute
java.sql.SQLException - If there is any problem in executing the query
public java.util.List listNetworkAttrs(int type,
java.lang.String order)
throws java.sql.SQLException
type - The network typeorder - The ordering attribute
java.sql.SQLException - If there is any problem in executing the query
public int insertNetworkAttr(NetworkAttr networkAttr)
throws java.sql.SQLException
networkAttr - The network attribute to be inserted
java.sql.SQLException - If there is any problem in executing the insertion
public java.util.List listCategories(java.lang.String name,
java.lang.String listType,
java.lang.String order)
throws java.sql.SQLException
name - Owner of the owned networks. Null for excluding owned ones.listType - List type:
"private" for private ones (must be owned) only
"owned" for owned ones (public or private) only
"" for owned or publicorder - The ordering attribute
java.sql.SQLException - If there is any problem in executing the query
public Category getCategory(int id)
throws java.sql.SQLException
id - The ID of the category
java.sql.SQLException - If there is any problem in executing the query
public int insertCategory(Category category)
throws java.sql.SQLException
category - The category to be inserted
java.sql.SQLException - If there is any problem in executing the insertion
public void deleteCategory(int id)
throws java.sql.SQLException
id - The ID of the category to be deleted
java.sql.SQLException - If there is any problem in executing the deletionprotected void finalize()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||