forked from cdosco/colorado-rla
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
190 changed files
with
35,824 additions
and
0 deletions.
There are no files selected for viewing
654 changes: 654 additions & 0 deletions
654
server/eclipse-project/src/main/java/us/us/freeandfair/corla/Main.java
Large diffs are not rendered by default.
Oops, something went wrong.
71 changes: 71 additions & 0 deletions
71
server/eclipse-project/src/main/java/us/us/freeandfair/corla/asm/ASMEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Free & Fair Colorado RLA System | ||
* | ||
* @title ColoradoRLA | ||
* @created Aug 8, 2017 | ||
* @copyright 2017 Colorado Department of State | ||
* @license SPDX-License-Identifier: AGPL-3.0-or-later | ||
* @creator Joseph R. Kiniry <[email protected]> | ||
* @description A system to assist in conducting statewide risk-limiting audits. | ||
*/ | ||
|
||
package us.freeandfair.corla.asm; | ||
|
||
/** | ||
* The events of the Abstract State Machine (ASM) of the Colorado RLA Tool. | ||
* @trace asm.asm_event | ||
* @author Joseph R. Kiniry <[email protected]> | ||
* @version 1.0.0 | ||
*/ | ||
public interface ASMEvent extends Event { | ||
/** | ||
* The Department of State Dashboard's events. | ||
* @trace asm.department_of_state_dashboard_event | ||
*/ | ||
enum DoSDashboardEvent implements ASMEvent { | ||
PARTIAL_AUDIT_INFO_EVENT, // public inbound event | ||
COMPLETE_AUDIT_INFO_EVENT, // public inbound event | ||
DOS_START_ROUND_EVENT, // public inbound event | ||
DOS_ROUND_COMPLETE_EVENT, // private internal event | ||
AUDIT_EVENT, // private internal event | ||
DOS_COUNTY_AUDIT_COMPLETE_EVENT, // private internal event | ||
DOS_AUDIT_COMPLETE_EVENT, // private internal event | ||
PUBLISH_AUDIT_REPORT_EVENT // public inbound event | ||
} | ||
|
||
/** | ||
* The County Dashboard's events. | ||
* @trace asm.county_dashboard_event | ||
*/ | ||
enum CountyDashboardEvent implements ASMEvent { | ||
IMPORT_BALLOT_MANIFEST_EVENT, // public inbound event | ||
IMPORT_CVRS_EVENT, // public inbound event | ||
DELETE_BALLOT_MANIFEST_EVENT, // public inbound event | ||
DELETE_CVRS_EVENT, // public inbound event | ||
CVR_IMPORT_SUCCESS_EVENT, // private internal event | ||
CVR_IMPORT_FAILURE_EVENT, // private internal event | ||
COUNTY_START_AUDIT_EVENT, // private internal event | ||
COUNTY_AUDIT_COMPLETE_EVENT // private internal event | ||
} | ||
|
||
/** | ||
* The Audit Board Dashboard's events. | ||
* @trace asm.audit_board_dashboard_event | ||
*/ | ||
enum AuditBoardDashboardEvent implements ASMEvent { | ||
COUNTY_DEADLINE_MISSED_EVENT, // private internal event | ||
NO_CONTESTS_TO_AUDIT_EVENT, // private internal event | ||
REPORT_MARKINGS_EVENT, // public inbound event | ||
REPORT_BALLOT_NOT_FOUND_EVENT, // public inbound event | ||
SUBMIT_AUDIT_INVESTIGATION_REPORT_EVENT, // public inbound event | ||
SUBMIT_INTERMEDIATE_AUDIT_REPORT_EVENT, // public inbound event | ||
SIGN_OUT_AUDIT_BOARD_EVENT, // public inbound event | ||
SIGN_IN_AUDIT_BOARD_EVENT, // public inbound event | ||
ROUND_START_EVENT, // private internal event | ||
ROUND_COMPLETE_EVENT, // private internal event | ||
ROUND_SIGN_OFF_EVENT, // public inbound event | ||
RISK_LIMIT_ACHIEVED_EVENT, // private internal event | ||
ABORT_AUDIT_EVENT, // public inbound event | ||
BALLOTS_EXHAUSTED_EVENT // private internal event | ||
} | ||
} |
147 changes: 147 additions & 0 deletions
147
...eclipse-project/src/main/java/us/us/freeandfair/corla/asm/ASMEventToEndpointRelation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
/* | ||
* Free & Fair Colorado RLA System | ||
* | ||
* @title ColoradoRLA | ||
* @created Aug 8, 2017 | ||
* @copyright 2017 Colorado Department of State | ||
* @license SPDX-License-Identifier: AGPL-3.0-or-later | ||
* @creator Joseph R. Kiniry <[email protected]> | ||
* @description A system to assist in conducting statewide risk-limiting audits. | ||
*/ | ||
|
||
package us.freeandfair.corla.asm; | ||
|
||
import static us.freeandfair.corla.asm.ASMEvent.AuditBoardDashboardEvent.*; | ||
import static us.freeandfair.corla.asm.ASMEvent.CountyDashboardEvent.*; | ||
import static us.freeandfair.corla.asm.ASMEvent.DoSDashboardEvent.*; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import us.freeandfair.corla.endpoint.Endpoint; | ||
import us.freeandfair.corla.util.Pair; | ||
|
||
/** | ||
* @description The mapping between ASM events and server endpoints. | ||
* @trace asm.ui_to_asm_event_relation | ||
* @author Joseph R. Kiniry <[email protected]> | ||
* @version 1.0.0 | ||
* @todo kiniry Introduce AbstractRelation parent class. | ||
* @todo dmz use an entity instead of Pair<> to enable persistence | ||
*/ | ||
@SuppressWarnings("PMD.TooManyStaticImports") | ||
public class ASMEventToEndpointRelation { | ||
/** | ||
* A constant encoding that we have not yet implemented a particular | ||
* endpoint. | ||
*/ | ||
public static final String UNIMPLEMENTED = "UNIMPLEMENTED"; | ||
|
||
/** | ||
* The relation encoded via a set of pairs. | ||
*/ | ||
private final Set<Pair<ASMEvent, String>> my_relation = | ||
new HashSet<Pair<ASMEvent, String>>(); | ||
|
||
/** | ||
* Create an instance of this relation, which contains the full set | ||
* of public ASM events and Endpoints. | ||
* @design kiniry This should probably be refactored as a singleton. | ||
*/ | ||
public ASMEventToEndpointRelation() { | ||
addDoSDashboardPairs(); | ||
addCountyDashboardPairs(); | ||
addAuditBoardDashboardPairs(); | ||
} | ||
|
||
private void addDoSDashboardPairs() { | ||
// All Department of State Dashboard pairs. | ||
my_relation.add(new Pair<ASMEvent, String>( | ||
PARTIAL_AUDIT_INFO_EVENT, | ||
UNIMPLEMENTED)); | ||
my_relation.add(new Pair<ASMEvent, String>( | ||
DOS_START_ROUND_EVENT, | ||
UNIMPLEMENTED)); | ||
my_relation.add(new Pair<ASMEvent, String>( | ||
PUBLISH_AUDIT_REPORT_EVENT, | ||
UNIMPLEMENTED)); | ||
} | ||
|
||
private void addCountyDashboardPairs() { | ||
// All County Dashboard pairs. | ||
my_relation.add(new Pair<ASMEvent, String>( | ||
IMPORT_BALLOT_MANIFEST_EVENT, | ||
"BallotManifestUpload")); | ||
my_relation.add(new Pair<ASMEvent, String>( | ||
IMPORT_CVRS_EVENT, | ||
UNIMPLEMENTED)); | ||
my_relation.add(new Pair<ASMEvent, String>( | ||
COUNTY_START_AUDIT_EVENT, | ||
UNIMPLEMENTED)); | ||
} | ||
|
||
private void addAuditBoardDashboardPairs() { | ||
// All Audit Board Dashboard pairs. | ||
my_relation.add(new Pair<ASMEvent, String>( | ||
REPORT_MARKINGS_EVENT, | ||
UNIMPLEMENTED)); | ||
my_relation.add(new Pair<ASMEvent, String>( | ||
REPORT_BALLOT_NOT_FOUND_EVENT, | ||
UNIMPLEMENTED)); | ||
my_relation.add(new Pair<ASMEvent, String>( | ||
SUBMIT_AUDIT_INVESTIGATION_REPORT_EVENT, | ||
UNIMPLEMENTED)); | ||
my_relation.add(new Pair<ASMEvent, String>( | ||
SUBMIT_INTERMEDIATE_AUDIT_REPORT_EVENT, | ||
UNIMPLEMENTED)); | ||
} | ||
|
||
/** | ||
* Is a_pair a member of this relation? | ||
* @param a_pair the UIEvent/ASMEvent pair to check. | ||
*/ | ||
public boolean member(final ASMEvent an_ae, final Endpoint an_e) { | ||
return my_relation.contains(new Pair<ASMEvent, Endpoint>(an_ae, an_e)); | ||
} | ||
|
||
// @todo kiniry Do we need these arrows anymore, especially given | ||
// that relations are not 1-1? | ||
|
||
/** | ||
* Follow the relation from left to right. | ||
* @param a_ae the ASM event to lookup. | ||
* @return the endpoints corresponding to 'a_ae', or null if no such | ||
* endpoints exists. | ||
*/ | ||
public Set<String> rightArrow(final ASMEvent a_ae) { | ||
// iterate over all elements in the map and, for each one whose | ||
// left element matches a_ae, include the right element in the | ||
// resulting set. | ||
final Set<String> result = new HashSet<String>(); | ||
for (final Pair<ASMEvent, String> p : my_relation) { | ||
if (p.first().equals(a_ae)) { | ||
result.add(p.second()); | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
/** | ||
* Follow the relation from right to left. | ||
* @param an_endpoint the endpoint to lookup. | ||
* @return the ASM events corresponding to 'an_endpoint', or null if | ||
* no such events exists. | ||
*/ | ||
public Set<ASMEvent> leftArrow(final String an_endpoint) { | ||
// iterate over all elements in the map and, for each one whose | ||
// right element matches an_ae, include the left element in the | ||
// resulting set. | ||
final Set<ASMEvent> result = new HashSet<ASMEvent>(); | ||
for (final Pair<ASMEvent, String> p : my_relation) { | ||
if (p.second().equals(an_endpoint)) { | ||
result.add(p.first()); | ||
} | ||
} | ||
return result; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
server/eclipse-project/src/main/java/us/us/freeandfair/corla/asm/ASMState.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/* | ||
* Free & Fair Colorado RLA System | ||
* | ||
* @title ColoradoRLA | ||
* @created Aug 8, 2017 | ||
* @copyright 2017 Colorado Department of State | ||
* @license SPDX-License-Identifier: AGPL-3.0-or-later | ||
* @creator Joseph R. Kiniry <[email protected]> | ||
* @description A system to assist in conducting statewide risk-limiting audits. | ||
*/ | ||
|
||
package us.freeandfair.corla.asm; | ||
|
||
/** | ||
* The states of the Abstract State Machine (ASM) of the Colorado RLA Tool. | ||
* @trace asm.asm_state | ||
* @author Joseph R. Kiniry <[email protected]> | ||
* @version 1.0.0 | ||
*/ | ||
public interface ASMState { | ||
/** | ||
* The Department of State Dashboard's states. | ||
* @trace asm.department_of_state_dashboard_state | ||
*/ | ||
enum DoSDashboardState implements ASMState { | ||
DOS_INITIAL_STATE, | ||
PARTIAL_AUDIT_INFO_SET, | ||
COMPLETE_AUDIT_INFO_SET, | ||
RANDOM_SEED_PUBLISHED, | ||
DOS_AUDIT_ONGOING, | ||
DOS_ROUND_COMPLETE, | ||
DOS_AUDIT_COMPLETE, | ||
AUDIT_RESULTS_PUBLISHED | ||
} | ||
|
||
/** | ||
* The County Dashboard's states. | ||
* @trace asm.county_dashboard_state | ||
*/ | ||
enum CountyDashboardState implements ASMState { | ||
COUNTY_INITIAL_STATE, | ||
BALLOT_MANIFEST_OK, | ||
CVRS_IMPORTING, | ||
CVRS_OK, | ||
BALLOT_MANIFEST_OK_AND_CVRS_IMPORTING, | ||
BALLOT_MANIFEST_AND_CVRS_OK, | ||
COUNTY_AUDIT_UNDERWAY, | ||
COUNTY_AUDIT_COMPLETE, | ||
DEADLINE_MISSED | ||
} | ||
|
||
/** | ||
* The Audit Board Dashboard's states. | ||
* @trace asm.audit_board_dashboard_state | ||
*/ | ||
enum AuditBoardDashboardState implements ASMState { | ||
AUDIT_INITIAL_STATE, | ||
WAITING_FOR_ROUND_START, | ||
WAITING_FOR_ROUND_START_NO_AUDIT_BOARD, | ||
ROUND_IN_PROGRESS, | ||
ROUND_IN_PROGRESS_NO_AUDIT_BOARD, | ||
WAITING_FOR_ROUND_SIGN_OFF, | ||
WAITING_FOR_ROUND_SIGN_OFF_NO_AUDIT_BOARD, | ||
AUDIT_COMPLETE, | ||
UNABLE_TO_AUDIT, | ||
AUDIT_ABORTED | ||
} | ||
} |
Oops, something went wrong.