org.gswing.framework.services
Interface IDbWriteAccess

All Superinterfaces:
IConstituencyBrowsing, IDbReadAccess
All Known Implementing Classes:
DbWriteAccess

public interface IDbWriteAccess
extends IDbReadAccess

Database read access object.


Field Summary
static int ALREADY_EXISTS
          Result already exists.
static int FAILED
          Unsuccessful write status.
static int NO_DATA
          Query/ update returned no data.
static int SUCCESS
          Successful write status.
 
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 url)
          Insert a new Party into the database.
 boolean insertPartyLeader(Election election, Candidate candidate, Constituency constituency)
          Insert a party leader.
 boolean insertResult(Vector votes)
          Insert a Vector of results into the database.
 boolean renameConstituency(String constituencyName, String newConstituencyName, 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.
 
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
 

Field Detail

SUCCESS

static final int SUCCESS
Successful write status.

See Also:
Constant Field Values

NO_DATA

static final int NO_DATA
Query/ update returned no data.

See Also:
Constant Field Values

FAILED

static final int FAILED
Unsuccessful write status.

See Also:
Constant Field Values

ALREADY_EXISTS

static final int ALREADY_EXISTS
Result already exists.

See Also:
Constant Field Values
Method Detail

createIndex

void createIndex(DbTable table,
                 String column)
Create index on a table column.

Parameters:
table - The table to create the index on.
column - The column to create the index on.

createTable

boolean createTable(DbTable table)
Create a new table in the database.

Parameters:
table - The table to create in the database.
Returns:
True if the table is successfully created.

insertCandidate

boolean insertCandidate(Candidate candidate)
Insert a new Candidate into the database.

Parameters:
candidate - The candidate to be inserted.
Returns:
True if the candidate was inserted.

insertConstituency

boolean insertConstituency(String constituencyName,
                           char type,
                           String parentName)
Insert a new constituency into the database.

Parameters:
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)
Returns:
True if the constituency was inserted.

insertConstituency

boolean insertConstituency(String constituencyName,
                           char type,
                           String parentName,
                           boolean isState)
Insert a new constituency into the database.

Parameters:
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?
Returns:
True if the constituency was inserted.

insertElection

boolean insertElection(Election election)
Insert a new Election into the database.

Parameters:
election - The election to insert.

insertElectorate

int insertElectorate(Constituency constituency,
                     int electionNo,
                     int electorate)
Insert the electorate size into the database.

Parameters:
constituency - The constituency reference.
electionNo - The unique election id.
electorate - The size of electorate for this constituency.
Returns:
SUCCESS <\code> if electorate inserted successully, FAILED <\code> if something went wrong and ALREADY_EXISTS if the result already exits.

updateElectorate

int updateElectorate(Constituency constituency,
                     int electionNo,
                     int electorate)
Update the electorate size into the database.

Parameters:
constituency - The constituency reference.
electionNo - The unique election id.
electorate - The size of electorate for this constituency.
Returns:
True if the electorate was successfully updated.

insertParty

boolean insertParty(String abbreviation,
                    String name,
                    URL url)
Insert a new Party into the database.

Parameters:
abbreviation - The candidate to be inserted.
name - Party name.
url - The party's home page.
Returns:
True if the candidate was inserted.

insertParty

boolean insertParty(String abbreviation,
                    String name)
Insert a new Party into the database.

Parameters:
abbreviation - The candidate to be inserted.
name - Party name.
Returns:
True if the candidate was inserted.

insertPartyLeader

boolean insertPartyLeader(Election election,
                          Candidate candidate,
                          Constituency constituency)
Insert a party leader.

Parameters:
election - The election.
candidate - The leader as a candidate.
constituency - The constituency object.
Returns:
True if leader was inserted successfully.

insertResult

boolean insertResult(Vector votes)
Insert a Vector of results into the database.

Parameters:
votes - A Vector of vote objects.
Returns:
True if all votes were inserted successfully.

deleteConstituency

boolean deleteConstituency(String constituencyName,
                           char type,
                           String parentName)
Delete a constituency from the database.

Parameters:
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)
Returns:
True if the constituency was deleted.

renameConstituency

boolean renameConstituency(String constituencyName,
                           String newConstituencyName,
                           char type,
                           String parentName)
Rename a constituency in the database.

Parameters:
constituencyName - The old constituency name.
newConstituencyName - 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)
Returns:
True if the constituency was renamed.


Copyright © 2008. All Rights Reserved.