1
2
3
4
5 package org.directdemocracyportal.democracy.model.world;
6
7 import java.util.ArrayList;
8 import java.util.Date;
9 import java.util.List;
10
11 import javax.persistence.CascadeType;
12 import javax.persistence.Entity;
13 import javax.persistence.EnumType;
14 import javax.persistence.Enumerated;
15 import javax.persistence.FetchType;
16 import javax.persistence.OneToMany;
17 import javax.persistence.Temporal;
18 import javax.persistence.TemporalType;
19 import javax.persistence.Transient;
20
21 import org.hibernate.annotations.Cache;
22 import org.hibernate.annotations.CacheConcurrencyStrategy;
23
24 /***
25 * The Class Resolution.
26 */
27 @Entity
28 @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
29 public class Resolution extends Document
30 {
31
32 /*** The Constant serialVersionUID. */
33 private static final long serialVersionUID = 5477103732940234132L;
34
35 /*** The href. */
36 private String href;
37
38 /*** The resolution state. */
39 private ResolutionState resolutionState;
40
41 /*** The decided date. */
42 private Date decidedDate;
43
44 /*** The issues. */
45 private List<Issue> issues = new ArrayList<Issue>();
46
47 /***
48 * Gets the href.
49 *
50 * @return the href
51 */
52 public String getHref() {
53 return href;
54 }
55
56 /***
57 * Sets the href.
58 *
59 * @param href the new href
60 */
61 public void setHref(String href) {
62 this.href = href;
63 }
64
65 /***
66 * Gets the resolution state.
67 *
68 * @return the resolution state
69 */
70 @Enumerated(EnumType.STRING)
71 public ResolutionState getResolutionState() {
72 return resolutionState;
73 }
74
75 /***
76 * Sets the resolution state.
77 *
78 * @param resolutionState the new resolution state
79 */
80 public void setResolutionState(ResolutionState resolutionState) {
81 this.resolutionState = resolutionState;
82 }
83
84 /***
85 * Gets the decided date.
86 *
87 * @return the decided date
88 */
89 @Temporal(TemporalType.DATE)
90 public Date getDecidedDate() {
91 return decidedDate;
92 }
93
94 /***
95 * Sets the decided date.
96 *
97 * @param decidedDate the new decided date
98 */
99 public void setDecidedDate(Date decidedDate) {
100 this.decidedDate = decidedDate;
101 }
102
103
104 /***
105 * Gets the issues.
106 *
107 * @return the issues
108 */
109 @OneToMany(mappedBy = "resolution", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
110 public List<Issue> getIssues() {
111 return issues;
112 }
113
114 /***
115 * Sets the issues.
116 *
117 * @param issues the new issues
118 */
119 public void setIssues(List<Issue> issues) {
120 this.issues = issues;
121 }
122
123
124 /***
125 * The Enum ResolutionState.
126 */
127 public enum ResolutionState {
128
129 /*** The Created. */
130 Created,
131
132 /*** The Preparation. */
133 Preparation,
134
135 /*** The Public. */
136 Public,
137
138 /*** The Stayed. */
139 Stayed,
140
141 /*** The Decided. */
142 Decided,
143
144 /*** The Proccessed. */
145 Proccessed;
146
147 }
148
149 /***
150 * Contains issue.
151 *
152 * @param name the name
153 * @return true, if successful
154 */
155 @Transient
156 public boolean containsIssue(String name) {
157 for (Issue issue : issues) {
158 if (name.equals(issue.getName())) {
159 return true;
160 }
161 }
162 return false;
163 }
164
165 }