|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.gswing.components.common.db.DbAccess
org.gswing.components.common.db.DbReadAccess
org.gswing.components.input.DbWriteAccess
public class DbWriteAccess
Purpose: Provides write access to the database.
Field Summary |
---|
Fields inherited from interface org.gswing.framework.services.IDbWriteAccess |
---|
ALREADY_EXISTS, FAILED, NO_DATA, SUCCESS |
Constructor Summary | |
---|---|
DbWriteAccess(String url,
String dbName,
String userName,
String password)
Constructor. |
Method Summary | |
---|---|
void |
createIndex(DbTable table,
String column)
Create index on a table column. |
boolean |
createTable(DbTable table)
Create a new table in the database. |
boolean |
deleteConstituency(String constituencyName,
char type,
String parentName)
Delete a constituency from the database. |
boolean |
insertCandidate(Candidate candidate)
Insert a new Candidate into the database. |
boolean |
insertConstituency(String constituencyName,
char type,
String parentName)
Insert a new constituency into the database. |
boolean |
insertConstituency(String constituencyName,
char type,
String parentName,
boolean isState)
Insert a new constituency into the database. |
boolean |
insertElection(Election election)
Insert a new Election into the database. |
int |
insertElectorate(Constituency constituency,
int electionNo,
int electorate)
Insert the electorate size into the database. |
boolean |
insertParty(String abbreviation,
String name)
Insert a new Party into the database. |
boolean |
insertParty(String abbreviation,
String name,
URL homePage)
Insert a new Party into the database. |
boolean |
insertPartyLeader(Election election,
Candidate candidate,
Constituency constituency)
Insert a new party leader into the database. |
boolean |
insertResult(Vector votes)
Insert a Vector of results into the database. |
boolean |
renameConstituency(String constituencyName,
String newName,
char type,
String parentName)
Rename a constituency in the database. |
int |
updateElectorate(Constituency constituency,
int electionNo,
int electorate)
Update the electorate size into the database. |
boolean |
updateParty(String abbreviation,
String name,
URL homePage)
Update the party's details |
Methods inherited from class org.gswing.components.common.db.DbReadAccess |
---|
fixString, getCandidate, getCandidateNo, getCandidates, getConstituencies, getConstituency, getConstituency, getConstituency, getConstituencyList, getElection, getElection, getElectionDates, getElections, getElections, getElectorate, getElectorate, getLatestDate, getLeaders, getLeaders, getNextCandidateNo, getNextConstituencyNo, getNextResult, getNoOfCandidates, getNoOfParties, getParties, getParty, getPartyAbbreviation, getPreviousResult, getPreviousWinner, getRegion, getRegionList, getResult, getState, getVotesCast, hasIllegalChar, partyExists, resultExists, resultExists |
Methods inherited from class org.gswing.components.common.db.DbAccess |
---|
closeConnection, createStatement, getConnection, getDatabaseName, getNumberOfTables, getPassword, getTableList, hasValidConnection, isConnected, setDriverClassName, setPassword, tableExists |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.gswing.framework.services.IDbReadAccess |
---|
getCandidateNo, getCandidates, getConstituencies, getConstituency, getConstituency, getElection, getElectionDates, getElections, getElections, getElectorate, getLatestDate, getLeaders, getLeaders, getNextResult, getNoOfCandidates, getNoOfParties, getParties, getParty, getPartyAbbreviation, getPreviousResult, getResult, getVotesCast, partyExists, resultExists, resultExists, tableExists |
Methods inherited from interface org.gswing.components.common.gui.IConstituencyBrowsing |
---|
getConstituencyList, getRegionList, getState |
Constructor Detail |
---|
public DbWriteAccess(String url, String dbName, String userName, String password)
url
- The URL of the database.dbName
- The name of the database.userName
- The user name of the database user.password
- The password of the database.Method Detail |
---|
public boolean insertResult(Vector votes)
insertResult
in interface IDbWriteAccess
votes
- A Vector of vote objects.
public int insertElectorate(Constituency constituency, int electionNo, int electorate)
IDbWriteAccess
insertElectorate
in interface IDbWriteAccess
constituency
- The constituency reference.electionNo
- The unique election id.electorate
- The size of electorate for this constituency.
SUCCESS <\code> if electorate inserted successully,
FAILED <\code> if something went wrong and ALREADY_EXISTS
if
the result already exits.
public int updateElectorate(Constituency constituency, int electionNo, int electorate)
IDbWriteAccess
updateElectorate
in interface IDbWriteAccess
constituency
- The constituency reference.electionNo
- The unique election id.electorate
- The size of electorate for this constituency.
public boolean createTable(DbTable table)
createTable
in interface IDbWriteAccess
table
- The table to create in the database.
public void createIndex(DbTable table, String column)
createIndex
in interface IDbWriteAccess
table
- The table to create the index on.column
- The column to create the index on.public boolean insertElection(Election election)
insertElection
in interface IDbWriteAccess
election
- The election to insert.public boolean insertConstituency(String constituencyName, char type, String parentName)
insertConstituency
in interface IDbWriteAccess
constituencyName
- The constituency to insert.type
- The constituency type - Result.NATIONAL, REGIONAL,
COUNCIL, CONSTITUENCY or LOCAL
parentName
- The constituency's parent. (E.g. National is parent of
Regional, Regional is parent of Constituency, Regional is parent of Council
and Council is the parent of Local)
public boolean insertConstituency(String constituencyName, char type, String parentName, boolean isState)
insertConstituency
in interface IDbWriteAccess
constituencyName
- The constituency to insert.type
- The constituency type - Result.NATIONAL, REGIONAL,
COUNCIL, CONSTITUENCY or LOCAL
parentName
- The constituency's parent. (E.g. National is parent of
Regional, Regional is parent of Constituency, Regional is parent of Council
and Council is the parent of Local)isState
- Is this constituency the top level state / nation?
public boolean insertCandidate(Candidate candidate)
insertCandidate
in interface IDbWriteAccess
candidate
- The candidate to be inserted.
public boolean insertParty(String abbreviation, String name)
insertParty
in interface IDbWriteAccess
abbreviation
- The candidate to be inserted.name
- Party name.
public boolean insertParty(String abbreviation, String name, URL homePage)
insertParty
in interface IDbWriteAccess
abbreviation
- The candidate to be inserted.name
- Party name.homePage
- The home page of the party.
public boolean updateParty(String abbreviation, String name, URL homePage)
abbreviation
- The candidate to be inserted.name
- Party name.homePage
- The home page of the party.
public boolean insertPartyLeader(Election election, Candidate candidate, Constituency constituency)
insertPartyLeader
in interface IDbWriteAccess
election
- The election reference.candidate
- The candidate to be inserted.constituency
- The constituency object. Used in local elections.
public boolean deleteConstituency(String constituencyName, char type, String parentName)
IDbWriteAccess
deleteConstituency
in interface IDbWriteAccess
constituencyName
- The constituency name.type
- The constituency type - Result.NATIONAL, REGIONAL,
COUNCIL, CONSTITUENCY or LOCAL
parentName
- The constituency's parent. (E.g. National is parent of
Regional, Regional is parent of Constituency, Regional is parent of Council
and Council is the parent of Local)
public boolean renameConstituency(String constituencyName, String newName, char type, String parentName)
IDbWriteAccess
renameConstituency
in interface IDbWriteAccess
constituencyName
- The old constituency name.newName
- The new constituency name.type
- The constituency type - Result.NATIONAL, REGIONAL,
COUNCIL, CONSTITUENCY or LOCAL
parentName
- The constituency's parent. (E.g. National is parent of
Regional, Regional is parent of Constituency, Regional is parent of Council
and Council is the parent of Local)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |