| 1 | |
|
| 2 | |
|
| 3 | |
|
| 4 | |
|
| 5 | |
package org.directdemocracyportal.democracy.model.world; |
| 6 | |
|
| 7 | |
import java.util.HashSet; |
| 8 | |
import java.util.Set; |
| 9 | |
|
| 10 | |
import javax.persistence.CascadeType; |
| 11 | |
import javax.persistence.Entity; |
| 12 | |
import javax.persistence.FetchType; |
| 13 | |
import javax.persistence.OneToMany; |
| 14 | |
import javax.persistence.OneToOne; |
| 15 | |
import javax.persistence.Transient; |
| 16 | |
|
| 17 | |
import org.directdemocracyportal.democracy.model.world.Vote.Position; |
| 18 | |
import org.hibernate.annotations.Cache; |
| 19 | |
import org.hibernate.annotations.CacheConcurrencyStrategy; |
| 20 | |
|
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
@Entity |
| 25 | |
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) |
| 26 | 1 | public class VoteResult extends Document |
| 27 | |
{ |
| 28 | |
|
| 29 | |
|
| 30 | |
private static final long serialVersionUID = 5477103732940234132L; |
| 31 | |
|
| 32 | |
|
| 33 | |
private Position finalPosition; |
| 34 | |
|
| 35 | |
|
| 36 | |
private String href; |
| 37 | |
|
| 38 | |
|
| 39 | |
private Issue issue; |
| 40 | |
|
| 41 | |
|
| 42 | 1 | private Set<Vote> votes= new HashSet<Vote>(); |
| 43 | |
|
| 44 | |
|
| 45 | |
|
| 46 | |
|
| 47 | |
|
| 48 | |
|
| 49 | |
public Position getFinalPosition() { |
| 50 | 0 | return finalPosition; |
| 51 | |
} |
| 52 | |
|
| 53 | |
|
| 54 | |
|
| 55 | |
|
| 56 | |
|
| 57 | |
|
| 58 | |
public void setFinalPosition(Position finalPosition) { |
| 59 | 0 | this.finalPosition = finalPosition; |
| 60 | 0 | } |
| 61 | |
|
| 62 | |
|
| 63 | |
|
| 64 | |
|
| 65 | |
|
| 66 | |
|
| 67 | |
public String getHref() { |
| 68 | 0 | return href; |
| 69 | |
} |
| 70 | |
|
| 71 | |
|
| 72 | |
|
| 73 | |
|
| 74 | |
|
| 75 | |
|
| 76 | |
public void setHref(String href) { |
| 77 | 0 | this.href = href; |
| 78 | 0 | } |
| 79 | |
|
| 80 | |
|
| 81 | |
|
| 82 | |
|
| 83 | |
|
| 84 | |
|
| 85 | |
@OneToOne(mappedBy = "voteResult") |
| 86 | |
public Issue getIssue() { |
| 87 | 0 | return issue; |
| 88 | |
} |
| 89 | |
|
| 90 | |
|
| 91 | |
|
| 92 | |
|
| 93 | |
|
| 94 | |
|
| 95 | |
public void setIssue(Issue issue) { |
| 96 | 0 | this.issue = issue; |
| 97 | 0 | } |
| 98 | |
|
| 99 | |
|
| 100 | |
|
| 101 | |
|
| 102 | |
|
| 103 | |
|
| 104 | |
@OneToMany(mappedBy = "voteResult", cascade = CascadeType.ALL, fetch = FetchType.LAZY) |
| 105 | |
public Set<Vote> getVotes() { |
| 106 | 0 | return votes; |
| 107 | |
} |
| 108 | |
|
| 109 | |
|
| 110 | |
|
| 111 | |
|
| 112 | |
|
| 113 | |
|
| 114 | |
public void setVotes(Set<Vote> votes) { |
| 115 | 0 | this.votes = votes; |
| 116 | 0 | } |
| 117 | |
|
| 118 | |
|
| 119 | |
|
| 120 | |
|
| 121 | |
|
| 122 | |
|
| 123 | |
|
| 124 | |
@Transient |
| 125 | |
public boolean containsVote(String name) { |
| 126 | 0 | for (Vote vote : votes) { |
| 127 | 0 | if (name.equals(vote.getName())) { |
| 128 | 0 | return true; |
| 129 | |
} |
| 130 | 0 | } |
| 131 | 0 | return false; |
| 132 | |
} |
| 133 | |
} |