Skip to content

Commit

Permalink
Added ReadOnlyProperty annotation to Assertion attributes.
Browse files Browse the repository at this point in the history
  • Loading branch information
michelleblom committed Apr 19, 2024
1 parent 8e72ffc commit 9174d1c
Showing 1 changed file with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ the raire assertion generation engine (https://github.com/DemocracyDevelopers/ra
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.annotation.ReadOnlyProperty;

/**
* RAIRE generates a set of assertions for a given IRV contest. The different types of assertion
Expand All @@ -48,34 +49,40 @@ public abstract class Assertion {
@Id
@Column(updatable = false, nullable = false)
@GeneratedValue(strategy = GenerationType.IDENTITY)
@ReadOnlyProperty
private long id;

/**
* Version. Used for optimistic locking.
*/
@Version
@Column(name = "version", updatable = false, nullable = false)
@ReadOnlyProperty
private long version;

/**
* Name of the contest for which this Assertion was generated.
*/
@Column(name = "contest_name", updatable = false, nullable = false)
@ReadOnlyProperty
protected String contestName;

@Column(name = "winner", updatable = false, nullable = false)
@ReadOnlyProperty
protected String winner;

/**
* Loser of the Assertion (a candidate in the contest).
*/
@Column(name = "loser", updatable = false, nullable = false)
@ReadOnlyProperty
protected String loser;

/**
* Assertion margin (note: this is not the *diluted* margin).
*/
@Column(name = "margin", updatable = false, nullable = false)
@ReadOnlyProperty
protected int margin;

/**
Expand All @@ -84,6 +91,7 @@ public abstract class Assertion {
* of ballots. For example, one method may be: difficulty = 1 / assertion margin).
*/
@Column(name = "difficulty", updatable = false, nullable = false)
@ReadOnlyProperty
protected double difficulty;

/**
Expand All @@ -93,13 +101,15 @@ public abstract class Assertion {
@ElementCollection(fetch = FetchType.EAGER)
@CollectionTable(name = "assertion_assumed_continuing", joinColumns = @JoinColumn(name = "id"))
@Column(updatable = false, nullable = false)
@ReadOnlyProperty
protected List<String> assumedContinuing = new ArrayList<>();

/**
* Diluted margin for the Assertion. This is equal to the assertion margin divided by the
* number of ballots in the relevant auditing universe.
*/
@Column(name = "diluted_margin", updatable = false, nullable = false)
@ReadOnlyProperty
protected double dilutedMargin;

/**
Expand All @@ -111,26 +121,30 @@ public abstract class Assertion {
@CollectionTable(name = "assertion_discrepancies", joinColumns = @JoinColumn(name = "id"))
@MapKeyColumn(name = "cvr_id")
@Column(name = "discrepancy", updatable = false, nullable = false)
@ReadOnlyProperty
protected Map<Long,Integer> cvrDiscrepancy = new HashMap<>();

/**
* The expected number of samples to audit overall for the Assertion, assuming overstatements
* continue at the current rate experienced in the audit.
*/
@Column(name = "estimated_samples_to_audit", updatable = false, nullable = false)
@ReadOnlyProperty
protected int estimatedSamplesToAudit = 0;

/**
* The expected number of samples to audit overall for the Assertion, assuming no further
* overstatements will be encountered in the audit.
*/
@Column(name = "optimistic_samples_to_audit", updatable = false, nullable = false)
@ReadOnlyProperty
protected int optimisticSamplesToAudit = 0;

/**
* The two-vote understatements recorded against the Assertion.
*/
@Column(name = "two_vote_under_count", updatable = false, nullable = false)
@ReadOnlyProperty
protected int twoVoteUnderCount = 0;

/**
Expand All @@ -143,26 +157,30 @@ public abstract class Assertion {
* The one-vote overstatements recorded against the Assertion.
*/
@Column(name = "one_vote_over_count", updatable = false, nullable = false)
@ReadOnlyProperty
protected int oneVoteOverCount = 0;

/**
* The two-vote overstatements recorded against the Assertion.
*/
@Column(name = "two_vote_over_count", updatable = false, nullable = false)
@ReadOnlyProperty
protected int twoVoteOverCount = 0;

/**
* Discrepancies recorded against the Assertion that are neither understatements nor
* overstatements.
*/
@Column(name = "other_count", updatable = false, nullable = false)
@ReadOnlyProperty
protected int otherCount = 0;

/**
* Current risk measurement recorded against the Assertion. It is initialized to 1, as prior
* to an audit starting, and without additional information, we assume maximum risk.
*/
@Column(name = "current_risk", updatable = false, nullable = false)
@ReadOnlyProperty
protected BigDecimal currentRisk = new BigDecimal("1.00");

/**
Expand Down

0 comments on commit 9174d1c

Please sign in to comment.