votorola.a.election
Class Election

java.lang.Object
  extended by ElectoralService
      extended by Election
All Implemented Interfaces:
InputStore

@ThreadRestricted(value="holds lock()")
public final class Election
extends ElectoralService
implements InputStore

A delegate cascade election, provided as a formal electoral service.

See Also:
../design.xht#Elections

Nested Class Summary
static class Election.ConfigurationContext
          A context for configuring an election.
 
Field Summary
 
Fields inherited from class ElectoralService
configurationContext, lock, name, serviceEmail, subserverRun
 
Method Summary
(package private)  File configurationDirectory()
          The directory containing this election's configuration files.
 File configurationFile()
          The primary configuration file for this electoral service.
(package private)  Database countDatabase()
          Database for mounting the relational parts of this election's counts -- a reference to a shared instance (not thread safe).
 Count countToReport()
          Returns the current count to report, if any.
 Exception dispatch(String[] argArray, CommandResponder.Session commandSession)
          Looks up the responder of the specified command, and sends the command to it.
(package private)  long electorateSize()
          The estimated size of the electorate for this election, if known.
(package private)  String electorateSizeExplanation()
          An explanation of the estimate of the size of the electorate, for the information of users.
(package private)  JavaScriptIncluder eligibilityScript()
          The script for testing the eligibility of a voter.
(package private)  ActivityEvent newChangeEventOrNull(Vote oldVote, Vote newVote)
          Returns a newly constructed event to record the change that occured between oldVote and newVote; or null, if no significant change occured.
static Election newElection(ElectoralSubserver.Run run, JavaScriptIncluder s)
          Constructs an Election.
 RegionalElectionNode regionalNode()
           
 String snapshotOutputStoreFilebase()
          Path to the base directory of the snapshot output store, for this electoral service.
 String summaryDescription()
          A brief description of this service, in sentence form.
 String title()
          Title of this election, in title case.
 VoterInputTable voterInputTable()
          The relational store of voter input, for this service.
 
Methods inherited from class ElectoralService
dispatch, ensureSchema, equals, help, helpA, helpB, helpC, init, lock, name, responderByClassName, responderForCommand, responders, serviceEmail, subserverRun, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

newElection

@ThreadSafe
public static Election newElection(ElectoralSubserver.Run run,
                                              JavaScriptIncluder s)
                            throws IOException,
                                   ScriptException,
                                   SQLException
Constructs an Election.

Parameters:
s - the compiled configuration script
Throws:
IOException
ScriptException
SQLException

configurationDirectory

@ThreadSafe
File configurationDirectory()
The directory containing this election's configuration files.


countDatabase

@ThreadSafe
Database countDatabase()
Database for mounting the relational parts of this election's counts -- a reference to a shared instance (not thread safe).

Although this method is thread safe, the object it returns is not; it has its own thread-saftety restrictions, q.v.

See Also:
countToReport(), Election.ConfigurationContext.countDatabase()

countToReport

public Count countToReport()
                    throws IOException
Returns the current count to report, if any.

Returns:
count, or null if none to report
Throws:
IOException

electorateSize

@ThreadSafe
long electorateSize()
The estimated size of the electorate for this election, if known. This a best guess of the number of people who would be eligible, if they chose to vote. It might be the population size of the district, or it might be something less; it depends on the eligibility criteria of the election.

Returns:
estimated size of the electorate; or zero, if unknown
See Also:
Election.ConfigurationContext.setElectorateSize(long)

electorateSizeExplanation

@ThreadSafe
String electorateSizeExplanation()
An explanation of the estimate of the size of the electorate, for the information of users. For example:
"population of Ward 6 (2008 census)"

See Also:
Election.ConfigurationContext.setElectorateSizeExplanation(String)

eligibilityScript

JavaScriptIncluder eligibilityScript()
The script for testing the eligibility of a voter. This script defines the electorate. The language is JavaScript. There are restrictions on the character encoding.

See Also:
eligibility.js (example script), ../manual.xht#eligibility-script, Election.ConfigurationContext.setEligibilityScriptPath(String)

newChangeEventOrNull

ActivityEvent newChangeEventOrNull(Vote oldVote,
                                   Vote newVote)
Returns a newly constructed event to record the change that occured between oldVote and newVote; or null, if no significant change occured.


regionalNode

public RegionalElectionNode regionalNode()

configurationFile

@ThreadSafe
public File configurationFile()
Description copied from class: ElectoralService
The primary configuration file for this electoral service. For an ordinary (non-meta) service, it is typically located at:
votorola-directory/services/service-name/service.js

The language is JavaScript. There are restrictions on the character encoding.

Specified by:
configurationFile in class ElectoralService

dispatch

public Exception dispatch(String[] argArray,
                          CommandResponder.Session commandSession)
Description copied from class: ElectoralService
Looks up the responder of the specified command, and sends the command to it. Or, if the look-up fails, replies that the command is unrecognized.

Overrides:
dispatch in class ElectoralService
Parameters:
argArray - an array containing the command name and arguments, per CommandResponder.respond(argv,session)
Returns:
any soft exception, per CommandResponder.respond(argv,session); or null if none occured
See Also:
CommandResponder.respond(String[],CommandResponder.Session)

summaryDescription

@ThreadSafe
public String summaryDescription()
Description copied from class: ElectoralService
A brief description of this service, in sentence form. It is intended for display, for example, as an introductory paragraph.

Specified by:
summaryDescription in class ElectoralService
See Also:
Election.ConfigurationContext.setSummaryDescription(String)

title

@ThreadSafe
public String title()
Title of this election, in title case. This is generally the informal, local name of the office, legislative bill, policy, or whatever is at stake in the election. Example titles are:

Mayor

Municipal Tax Share (a bill)

Foreign Policy

Specified by:
title in class ElectoralService
See Also:
Election.ConfigurationContext.setTitle(String)

snapshotOutputStoreFilebase

@ThreadSafe
public String snapshotOutputStoreFilebase()
Description copied from interface: InputStore
Path to the base directory of the snapshot output store, for this electoral service. The snapshot output store contains a series of snapshots, copied from the service's input store. It may also contain additional data, derived from the snapshot, such as mounted counts or voter lists.

Multiple services may share the same base directory. The output files for this particular service will be stored in a subdirectory named after the service: snapshotOutputStoreFilebase/service-name.

Specified by:
snapshotOutputStoreFilebase in interface InputStore

voterInputTable

@ThreadSafe
public VoterInputTable voterInputTable()
Description copied from interface: InputStore
The relational store of voter input, for this service. It is a table named "service-name", stored in the service's voter-input database.

Specified by:
voterInputTable in interface InputStore
See Also:
Election.ConfigurationContext.voterInputDatabase()