|
||||||||||
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
public class DbReadAccess
Purpose: A read only connection to the election database.
Constructor Summary | |
---|---|
DbReadAccess()
Constructor that uses the database connection values from the configuration file. |
|
DbReadAccess(String url,
String dbName,
String userName,
String password)
Constructor. |
Method Summary | |
---|---|
protected String |
fixString(String str)
Fix string that has illegal characters. |
Candidate |
getCandidate(int candidateNo)
Get candidate object in the database matching the candidate no. |
int |
getCandidateNo(Candidate candidate)
Get the unique candidate number of a candidate. |
Vector<Candidate> |
getCandidates()
Get all candidates in the database. |
List<SimpleConstituency> |
getConstituencies(Election election)
Fetch list of constituencies in an election. |
String |
getConstituency(int constituencyNo)
Get the constituency name for this constituency number. |
Constituency |
getConstituency(String constituencyName,
char type)
Get the constituency for this constituency name and type. |
Constituency |
getConstituency(String constituencyName,
String parent)
Get the unique constituency number for this constituency. |
ListModel |
getConstituencyList(String parent,
char type)
Get the list of constituencies for a particular parent. |
Election |
getElection(Date date,
String electionType)
Get the election details for a particular election. |
Election |
getElection(int electionNo)
Get the election details for a particular election. |
Vector<ResultKey> |
getElectionDates(Constituency constituency)
Get election dates that have taken place in this constituency. |
Vector<Election> |
getElections()
Get all elections in the database. |
Vector<Election> |
getElections(boolean includeByElections,
char type)
Get elections in the database. |
int |
getElectorate(int electionNo)
Get the total size of the electorate for this election. |
protected int |
getElectorate(String constituency,
int electionNo)
Get the size of the electorate for this contituency at this election. |
Election |
getLatestDate(Constituency constituency)
Get the election of the latest result for this constituency. |
Vector<Candidate> |
getLeaders(Election election)
Get list of leaders (as candidates) for this election. |
Vector<Candidate> |
getLeaders(Election election,
int constituencyNo)
Get list of leaders (as candidates) for this election and constituency. |
int |
getNextCandidateNo()
Get the next unique candidate number. |
int |
getNextConstituencyNo()
Get the next unique constituency number for this constituency. |
Result |
getNextResult(Result oldResult)
Gets the next result. |
int |
getNoOfCandidates()
Get number of candidates in the database. |
int |
getNoOfParties()
Get the number of parties in the database. |
Vector<Party> |
getParties()
Get all party objects in the database. |
Party |
getParty(String abbreviation)
Get the party from the abbreviation. |
String |
getPartyAbbreviation(String party)
Get the abbreviated party name from the full name. |
Result |
getPreviousResult(Result oldResult,
ResultKey key)
Gets the previous result. |
String |
getPreviousWinner(Result oldResult)
Gets the previous result by type (eg. |
String |
getRegion(String constituency)
Get the region that a constituency belongs to. |
ListModel |
getRegionList()
Get list of regions in database. |
Result |
getResult(ResultKey key)
Get a result for this constituency on this date. |
String |
getState()
Get the top level state name. |
int |
getVotesCast(Constituency constituency,
Election election)
Fetch the number of votes cast in a constituency for a particular election. |
protected boolean |
hasIllegalChar(String candidate)
Does this candidate string have illegal characters. |
boolean |
partyExists(String party,
boolean isAbbreviation)
Does this party exist in the database? |
boolean |
resultExists(Election election,
int candidateNo,
String constituency)
Check whether this result exists in the database. |
boolean |
resultExists(Election election,
String participant,
String constituency)
Check whether this result exists in the database. |
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 |
---|
tableExists |
Constructor Detail |
---|
public DbReadAccess(String url, String dbName, String userName, String password)
url
- The URL of this database connection.dbName
- The database name or catalogue.userName
- The database user name.password
- The database password.public DbReadAccess()
Method Detail |
---|
public String getState()
getState
in interface IConstituencyBrowsing
public ListModel getRegionList()
getRegionList
in interface IConstituencyBrowsing
public ListModel getConstituencyList(String parent, char type)
getConstituencyList
in interface IConstituencyBrowsing
parent
- The parent constituency.type
- The constituency type.
public String getRegion(String constituency)
constituency
- The constituency name.
public Result getResult(ResultKey key)
getResult
in interface IDbReadAccess
key
- The data that makes an election result unique.
public Result getPreviousResult(Result oldResult, ResultKey key)
getPreviousResult
in interface IDbReadAccess
oldResult
- The current result.key
- The data that makes an election result unique.
public String getPreviousWinner(Result oldResult)
oldResult
- The current result.
public Result getNextResult(Result oldResult)
getNextResult
in interface IDbReadAccess
oldResult
- The current result.
public Election getLatestDate(Constituency constituency)
getLatestDate
in interface IDbReadAccess
constituency
- The constituency reference
public Vector<Candidate> getCandidates()
getCandidates
in interface IDbReadAccess
public Candidate getCandidate(int candidateNo)
candidateNo
- The unique candidate no in the database.
public int getCandidateNo(Candidate candidate)
getCandidateNo
in interface IDbReadAccess
candidate
- The object containing candidate details.
public int getNextCandidateNo()
public int getNoOfCandidates()
getNoOfCandidates
in interface IDbReadAccess
public Vector<Party> getParties()
getParties
in interface IDbReadAccess
public String getPartyAbbreviation(String party)
getPartyAbbreviation
in interface IDbReadAccess
party
- The party's full name.
public Party getParty(String abbreviation)
getParty
in interface IDbReadAccess
abbreviation
- The abbreviated party name.
public int getNoOfParties()
getNoOfParties
in interface IDbReadAccess
public boolean partyExists(String party, boolean isAbbreviation)
partyExists
in interface IDbReadAccess
party
- The party name.isAbbreviation
- Whether the party name is abbreviated or full.
public Vector<ResultKey> getElectionDates(Constituency constituency)
getElectionDates
in interface IDbReadAccess
constituency
- The constituency reference.
public Vector<Election> getElections()
getElections
in interface IDbReadAccess
public Vector<Election> getElections(boolean includeByElections, char type)
getElections
in interface IDbReadAccess
includeByElections
- Should by-elections be included in the list?type
- The election type - Result.NATIONAL, Result.REGIONAL,
Result.COUNCIL, Result.CONSTITUENCY or Result.LOCAL
public Election getElection(int electionNo)
getElection
in interface IDbReadAccess
electionNo
- The unique election number.
public Election getElection(Date date, String electionType)
date
- The date of the election.electionType
- - Result.CONSTITUENCY, Result.REGIONAL or Result.LOCAL.
public boolean resultExists(Election election, int candidateNo, String constituency)
resultExists
in interface IDbReadAccess
election
- The election referencecandidateNo
- The unique candidate number.constituency
- The constituency name.
public boolean resultExists(Election election, String participant, String constituency)
resultExists
in interface IDbReadAccess
election
- The election reference.participant
- The unique candidate number.constituency
- The constituency name.
protected int getElectorate(String constituency, int electionNo)
constituency
- The constituency to search.electionNo
- The unique election number (from election table).
public int getElectorate(int electionNo)
getElectorate
in interface IDbReadAccess
electionNo
- The unique election number.
public int getVotesCast(Constituency constituency, Election election)
getVotesCast
in interface IDbReadAccess
constituency
- The constituency object.election
- The election object.
public Constituency getConstituency(String constituencyName, String parent)
getConstituency
in interface IDbReadAccess
constituencyName
- The constituency name.parent
- The constituency's parent name.
public Constituency getConstituency(String constituencyName, char type)
getConstituency
in interface IDbReadAccess
constituencyName
- The constituency name.type
- The constituency type.
public String getConstituency(int constituencyNo)
constituencyNo
- The constituency number on the database.
public List<SimpleConstituency> getConstituencies(Election election)
getConstituencies
in interface IDbReadAccess
election
- The election.
public int getNextConstituencyNo()
public Vector<Candidate> getLeaders(Election election)
getLeaders
in interface IDbReadAccess
election
- The election object.
public Vector<Candidate> getLeaders(Election election, int constituencyNo)
getLeaders
in interface IDbReadAccess
election
- The election object.constituencyNo
- The constituency identifier.
protected boolean hasIllegalChar(String candidate)
candidate
- The candidate name.
return True if this candidate name has an illegal character.protected String fixString(String str)
str
- The string containing the illegal char.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |