org.gswing.framework.services
Interface IDbReadAccess

All Superinterfaces:
IConstituencyBrowsing
All Known Subinterfaces:
IDbWriteAccess
All Known Implementing Classes:
DbReadAccess, DbWriteAccess

public interface IDbReadAccess
extends IConstituencyBrowsing

Database read access object.


Method Summary
 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 all constituencies taking part in particular election.
 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.
 Election getElection(int electionNo)
          Get the election details for a particular election.
 Vector getElectionDates(Constituency constituency)
          Get election dates that have taken place in this constituency.
 Vector<Election> getElections()
          Get all elections in the database.
 Vector getElections(boolean includeByElections, char type)
          Get all elections in the database.
 int getElectorate(int electionNo)
          Get the total size of the electorate for this election.
 Election getLatestDate(Constituency constituency)
          Get the election of the latest result for this constituency.
 Vector getLeaders(Election election)
          Get list of leaders (as candidates) for this election.
 Vector getLeaders(Election election, int constituencyNo)
          Get list of leaders (as candidates) for a local election.
 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 name from an abbreviation.
 String getPartyAbbreviation(String party)
          Get the abbreviated party name from the full name.
 Result getPreviousResult(Result oldResult, ResultKey key)
          Gets the previous result.
 Result getResult(ResultKey key)
          Get a result for this constituency on this date.
 int getVotesCast(Constituency constituency, Election election)
          Fetch the number of votes cast in a constituency for a particular election.
 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.
 boolean tableExists(String tableName)
          Check whether a particular table exists in this database.
 
Methods inherited from interface org.gswing.components.common.gui.IConstituencyBrowsing
getConstituencyList, getRegionList, getState
 

Method Detail

getCandidates

Vector<Candidate> getCandidates()
Get all candidates in the database.

Returns:
A Vector of Candidates sorted by surname.

getConstituency

Constituency getConstituency(String constituencyName,
                             char type)
Get the constituency for this constituency name and type.

Parameters:
constituencyName - The constituency name.
type - The constituency type.
Returns:
The constituency reference. If this constituency doesn't exist return null.

getConstituency

Constituency getConstituency(String constituencyName,
                             String parent)
Get the unique constituency number for this constituency.

Parameters:
constituencyName - The constituency name.
parent - The constituency's parent name.
Returns:
The unique constituency number or id. If this constituency doesn't exist return null.

getConstituencies

List<SimpleConstituency> getConstituencies(Election election)
Fetch all constituencies taking part in particular election.

Parameters:
election - The election object.
Returns:
All constituencies in an election.

getCandidateNo

int getCandidateNo(Candidate candidate)
Get the unique candidate number of a candidate.

Parameters:
candidate - The object containing candidate details.
Returns:
The unique candidate number. If no candidate exists return -1.

getElection

Election getElection(int electionNo)
Get the election details for a particular election.

Parameters:
electionNo - The unique election number.
Returns:
The election data.

getElectionDates

Vector getElectionDates(Constituency constituency)
Get election dates that have taken place in this constituency.

Parameters:
constituency - The constituency reference.
Returns:
A sorted vector of dates.

getElections

Vector getElections(boolean includeByElections,
                    char type)
Get all elections in the database.

Parameters:
includeByElections - Should by-elections be included in list.
type - The election type - Result.NATIONAL, Result.REGIONAL, Result.COUNCIL, Result.CONSTITUENCY or Result.LOCAL
Returns:
Vector of elections sorted by date.

getElections

Vector<Election> getElections()
Get all elections in the database.

Returns:
Vector of elections sorted by date.

getElectorate

int getElectorate(int electionNo)
Get the total size of the electorate for this election.

Parameters:
electionNo - The unique election number.
Returns:
Total of eligible votes from all constituencies.

getLatestDate

Election getLatestDate(Constituency constituency)
Get the election of the latest result for this constituency.

Parameters:
constituency - The constituency reference
Returns:
The latest election reference.

getLeaders

Vector getLeaders(Election election)
Get list of leaders (as candidates) for this election.

Parameters:
election - The election object.
Returns:
Vector of party leaders.

getLeaders

Vector getLeaders(Election election,
                  int constituencyNo)
Get list of leaders (as candidates) for a local election.

Parameters:
election - The election object.
constituencyNo - The constituency no of council.
Returns:
Vector of party leaders.

getNextResult

Result getNextResult(Result oldResult)
Gets the next result. If this returns null then there is no next.

Parameters:
oldResult - The current result.
Returns:
The next result.

getNoOfCandidates

int getNoOfCandidates()
Get number of candidates in the database.

Returns:
The number of candidates in the database.

getNoOfParties

int getNoOfParties()
Get the number of parties in the database.

Returns:
The number of parties.

getParties

Vector<Party> getParties()
Get all party objects in the database.

Returns:
A vector of abbreviated party names.

getPartyAbbreviation

String getPartyAbbreviation(String party)
Get the abbreviated party name from the full name.

Parameters:
party - The party's full name.
Returns:
The abbreviated party name.

getParty

Party getParty(String abbreviation)
Get the party name from an abbreviation.

Parameters:
abbreviation - The party's abbreviation.
Returns:
The party object.

getPreviousResult

Result getPreviousResult(Result oldResult,
                         ResultKey key)
Gets the previous result. If this returns null then there is no previous.

Parameters:
oldResult - The current result.
key - The data that makes an election result unique.
Returns:
The previous result.

getResult

Result getResult(ResultKey key)
Get a result for this constituency on this date.

Parameters:
key - The data that makes an election result unique.
Returns:
The result object.

getVotesCast

int getVotesCast(Constituency constituency,
                 Election election)
Fetch the number of votes cast in a constituency for a particular election.

Parameters:
constituency - The constituency object.
election - The election object.
Returns:
The number of votes case or -1 if there is no result.

partyExists

boolean partyExists(String party,
                    boolean isAbbreviation)
Does this party exist in the database?

Parameters:
party - The party name.
isAbbreviation - Whether the party name is abbreviated or full.
Returns:
True if the party exists in the database.

resultExists

boolean resultExists(Election election,
                     int candidateNo,
                     String constituency)
Check whether this result exists in the database.

Parameters:
election - The election reference
candidateNo - The unique candidate number.
constituency - The constituency name.
Returns:
True if the result exists.

resultExists

boolean resultExists(Election election,
                     String participant,
                     String constituency)
Check whether this result exists in the database.

Parameters:
election - The election reference.
participant - The election participant.
constituency - The constituency name.
Returns:
True if the result exists.

tableExists

boolean tableExists(String tableName)
Check whether a particular table exists in this database.

Parameters:
tableName - The name of the table to check.
Returns:
Whether this table exists.


Copyright © 2008. All Rights Reserved.