4A Server -  2.0
 All Classes Namespaces Files Functions Variables Enumerator
SuggestionFeedback.java
Go to the documentation of this file.
1 /*
2  * Project: Server for annotations sharing
3  * Author: Ing. Jaroslav Dytrych idytrych@fit.vutbr.cz
4  * File: SuggestionFeedback.java
5  * Description: Class represents database entitiy that holds information about
6  * group suggestion feedback
7  */
8 
9 /**
10  * @file SuggestionFeedback.java
11  *
12  * @brief Class represents database entitiy that holds information about
13  * group suggestion feedback.
14  */
15 
16 package cz.vutbr.fit.knot.annotations.modules.suggestionManager;
17 
20 import java.io.Serializable;
21 import javax.persistence.Basic;
22 import javax.persistence.Column;
23 import javax.persistence.Entity;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.GenerationType;
26 import javax.persistence.Id;
27 import javax.persistence.JoinColumn;
28 import javax.persistence.ManyToOne;
29 import javax.persistence.NamedQueries;
30 import javax.persistence.NamedQuery;
31 import javax.persistence.Table;
32 import javax.validation.constraints.NotNull;
33 import javax.xml.bind.annotation.XmlRootElement;
34 
35 /**
36  * Class represents database entitiy that holds information about group suggestion
37  * feedback.
38  *
39  * @brief Represents database entitiy with suggestion feedback.
40  * feedback.
41  * @author Martin Petr (xpetrm05)
42  */
43 @Entity
44 @Table(name = "suggestionFeedback")
45 @XmlRootElement
46 @NamedQueries({
47  @NamedQuery(name = "SuggestionFeedback.findAll", query = "SELECT s FROM SuggestionFeedback s"),
48  @NamedQuery(name = "SuggestionFeedback.findById", query = "SELECT s FROM SuggestionFeedback s WHERE s.id = :id"),
49  @NamedQuery(name = "SuggestionFeedback.findByDoc", query = "SELECT s FROM SuggestionFeedback s WHERE s.groupId = :groupId AND s.suggestion.sourceDocumentId = :docId"),
50  @NamedQuery(name = "SuggestionFeedback.findByDocPos", query = "SELECT s FROM SuggestionFeedback s WHERE s.groupId = :groupId AND s.suggestion.sourceDocumentId = :docId AND s.suggestionId IS NOT NULL"),
51  @NamedQuery(name = "SuggestionFeedback.findByDocNeg", query = "SELECT s FROM SuggestionFeedback s WHERE s.groupId = :groupId AND s.suggestion.sourceDocumentId = :docId AND s.suggestionId IS NULL"),
52  @NamedQuery(name = "SuggestionFeedback.findBySuggestionId", query = "SELECT s FROM SuggestionFeedback s WHERE s.suggestionId = :suggestionId"),
53  @NamedQuery(name = "SuggestionFeedback.findByGroupId", query = "SELECT s FROM SuggestionFeedback s WHERE s.groupId = :groupId"),
54  @NamedQuery(name = "SuggestionFeedback.findByAnnot", query = "SELECT s FROM SuggestionFeedback s WHERE s.annotationId = :annotationId"),
55  @NamedQuery(name = "SuggestionFeedback.findByAnnotNotNull", query = "SELECT s FROM SuggestionFeedback s WHERE s.annotationId= :id AND s.suggestionId IS NOT NULL"),
56  @NamedQuery(name = "SuggestionFeedback.findByAnnotationId", query = "SELECT s FROM SuggestionFeedback s WHERE s.annotationId = :annotationId AND s.groupId = :groupId")})
57 public class SuggestionFeedback implements Serializable {
58  private static final long serialVersionUID = 1L;
59 
60  /** Id of suggestion feedback */
61  @Id
62  @GeneratedValue(strategy = GenerationType.IDENTITY)
63  @Basic(optional = false)
64  @Column(name = "id")
65  private Integer id;
66 
67  /** Id of suggestion that feedback belongs */
68  @Basic(optional = false)
69  @NotNull
70  @Column(name = "suggestionId", insertable=false, updatable=false)
71  private Integer suggestionId;
72 
73  /** Id of user group of suggestion */
74  @Basic(optional = false)
75  @NotNull
76  @Column(name = "groupId", insertable=false, updatable=false)
77  private Integer groupId;
78 
79  /** Id of corresponding annotation from suggestion if is suggestion approved */
80  @Column(name = "annotationId", insertable=false, updatable=false)
81  private Integer annotationId;
82 
83  /** Suggestion that feedback belongs */
84  @ManyToOne
85  @JoinColumn(name = "suggestionId", referencedColumnName = "id")
86  private Suggestion suggestion;
87 
88  /** User group of suggestion feedback */
89  @ManyToOne
90  @JoinColumn(name = "annotationId", referencedColumnName = "id")
91  private Annotation annot;
92 
93  /** Corresponding annotation from suggestion if is suggestion approved */
94  @ManyToOne
95  @JoinColumn(name = "groupId", referencedColumnName = "id")
96  private UserGroup group;
97 
98  /**
99  * Constructor
100  */
102  }
103 
104  /**
105  * Constructor
106  *
107  * @param id Id of suggestion feedback
108  */
109  public SuggestionFeedback(Integer id) {
110  this.id = id;
111  }
112 
113  /**
114  * Constructor
115  *
116  * @param id Id of suggestion feedback
117  * @param suggestionId Id of suggestion that feedback belongs
118  * @param groupId Id of user group of suggestion
119  */
120  public SuggestionFeedback(Integer id, Integer suggestionId, Integer groupId) {
121  this.id = id;
122  this.suggestionId = suggestionId;
123  this.groupId = groupId;
124  }
125 
126  /**
127  * Gets id of suggestion feedback
128  *
129  * @return id of suggestion feedback
130  */
131  public Integer getId() {
132  return id;
133  }
134 
135  /**
136  * Sets id of suggestion feedback
137  *
138  * @param id id of suggestion feedback
139  */
140  public void setId(Integer id) {
141  this.id = id;
142  }
143 
144  /**
145  * Gets id of suggestion that feedback belongs
146  *
147  * @return id of suggestion that feedback belongs
148  */
149  public Integer getSuggestionId() {
150  return suggestionId;
151  }
152 
153  /**
154  * Sets id of suggestion that feedback belongs
155  *
156  * @param suggestionId id of suggestion that feedback belongs
157  */
158  public void setSuggestionId(Integer suggestionId) {
159  this.suggestionId = suggestionId;
160  }
161 
162  /**
163  * Gets id of user group of suggestion
164  *
165  * @return id of user group of suggestion
166  */
167  public Integer getGroupId() {
168  return groupId;
169  }
170 
171  /**
172  * Sets id of user group of suggestion
173  *
174  * @param groupId id of user group of suggestion
175  */
176  public void setGroupId(Integer groupId) {
177  this.groupId = groupId;
178  }
179 
180  /**
181  * Gets id of corresponding annotation from suggestion if is suggestion approved
182  *
183  * @return id of corresponding annotation
184  */
185  public Integer getAnnotationId() {
186  return annotationId;
187  }
188 
189  /**
190  * Sets id of corresponding annotation from suggestion if is suggestion approved
191  *
192  * @param annotationId id of corresponding annotation
193  */
194  public void setAnnotationId(Integer annotationId) {
195  this.annotationId = annotationId;
196  }
197 
198  /**
199  * Gets suggestion that feedback belongs
200  *
201  * @return suggestion that feedback belongs
202  */
204  return suggestion;
205  }
206 
207  /**
208  * Sets suggestion that feedback belongs
209  *
210  * @param suggestion suggestion that feedback belongs
211  */
212  public void setSuggestion(Suggestion suggestion) {
213  this.suggestion = suggestion;
214  }
215 
216  /**
217  * Gets corresponding annotation of suggestion feedback
218  *
219  * @return corresponding annotation of suggestion feedback
220  */
221  public Annotation getAnnot() {
222  return annot;
223  }
224 
225  /**
226  * Sets corresponding annotation of suggestion feedback
227  *
228  * @param annot corresponding annotation of suggestion feedback
229  */
230  public void setAnnot(Annotation annot) {
231  this.annot = annot;
232  }
233 
234  /**
235  * Gets user group of suggestion feedback
236  *
237  * @return user group of suggestion feedback
238  */
239  public UserGroup getGroup() {
240  return group;
241  }
242 
243  /**
244  * Sets user group of suggestion feedback
245  *
246  * @param group user group of suggestion feedback
247  */
248  public void setGroup(UserGroup group) {
249  this.group = group;
250  }
251 
252  @Override
253  public int hashCode() {
254  int hash = 0;
255  hash += (id != null ? id.hashCode() : 0);
256  return hash;
257  }
258 
259  /**
260  * Compares this with other object and returns, whether objects are same type
261  * and have same id.
262  *
263  * @param object Object to compare with
264  * @return If object is same type and have same id, returns true, false otherwise
265  */
266  @Override
267  public boolean equals(Object object) {
268  if (!(object instanceof SuggestionFeedback)) {
269  return false;
270  }
271  SuggestionFeedback other = (SuggestionFeedback) object;
272  if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
273  return false;
274  }
275  return true;
276  }
277 
278  @Override
279  public String toString() {
280  return "cz.vutbr.fit.knot.annotations.modules.suggestionManager.SuggestionFeedback[ id=" + id + " ]";
281  }
282 
283 } // public class SuggestionFeedback
Class representing user group.
Definition: UserGroup.java:47
SuggestionFeedback(Integer id, Integer suggestionId, Integer groupId)
Class representing suggestion of annotation.
Definition: Suggestion.java:87
Represents database entitiy with suggestion feedback. feedback.