Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
VoteResult |
|
| 1.3333333333333333;1.333 |
1 | /* | |
2 | Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. | |
3 | $Id | |
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 | * The Class VoteResult. | |
23 | */ | |
24 | @Entity | |
25 | @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE) | |
26 | 1 | public class VoteResult extends Document |
27 | { | |
28 | ||
29 | /** The Constant serialVersionUID. */ | |
30 | private static final long serialVersionUID = 5477103732940234132L; | |
31 | ||
32 | /** The final position. */ | |
33 | private Position finalPosition; | |
34 | ||
35 | /** The href. */ | |
36 | private String href; | |
37 | ||
38 | /** The issue. */ | |
39 | private Issue issue; | |
40 | ||
41 | /** The votes. */ | |
42 | 1 | private Set<Vote> votes= new HashSet<Vote>(); |
43 | ||
44 | /** | |
45 | * Gets the final position. | |
46 | * | |
47 | * @return the final position | |
48 | */ | |
49 | public Position getFinalPosition() { | |
50 | 0 | return finalPosition; |
51 | } | |
52 | ||
53 | /** | |
54 | * Sets the final position. | |
55 | * | |
56 | * @param finalPosition the new final position | |
57 | */ | |
58 | public void setFinalPosition(Position finalPosition) { | |
59 | 0 | this.finalPosition = finalPosition; |
60 | 0 | } |
61 | ||
62 | /** | |
63 | * Gets the href. | |
64 | * | |
65 | * @return the href | |
66 | */ | |
67 | public String getHref() { | |
68 | 0 | return href; |
69 | } | |
70 | ||
71 | /** | |
72 | * Sets the href. | |
73 | * | |
74 | * @param href the new href | |
75 | */ | |
76 | public void setHref(String href) { | |
77 | 0 | this.href = href; |
78 | 0 | } |
79 | ||
80 | /** | |
81 | * Gets the issue. | |
82 | * | |
83 | * @return the issue | |
84 | */ | |
85 | @OneToOne(mappedBy = "voteResult") | |
86 | public Issue getIssue() { | |
87 | 0 | return issue; |
88 | } | |
89 | ||
90 | /** | |
91 | * Sets the issue. | |
92 | * | |
93 | * @param issue the new issue | |
94 | */ | |
95 | public void setIssue(Issue issue) { | |
96 | 0 | this.issue = issue; |
97 | 0 | } |
98 | ||
99 | /** | |
100 | * Gets the votes. | |
101 | * | |
102 | * @return the votes | |
103 | */ | |
104 | @OneToMany(mappedBy = "voteResult", cascade = CascadeType.ALL, fetch = FetchType.LAZY) | |
105 | public Set<Vote> getVotes() { | |
106 | 0 | return votes; |
107 | } | |
108 | ||
109 | /** | |
110 | * Sets the votes. | |
111 | * | |
112 | * @param votes the new votes | |
113 | */ | |
114 | public void setVotes(Set<Vote> votes) { | |
115 | 0 | this.votes = votes; |
116 | 0 | } |
117 | ||
118 | /** | |
119 | * Contains vote. | |
120 | * | |
121 | * @param name the name | |
122 | * @return true, if successful | |
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 | } |