View Javadoc

1   package org.gnomekr.potron.data;
2   
3   import java.io.Serializable;
4   import java.util.Date;
5   import java.util.List;
6   import java.util.Set;
7   
8   import org.apache.commons.lang.builder.EqualsBuilder;
9   import org.apache.commons.lang.builder.HashCodeBuilder;
10  import org.apache.commons.lang.builder.ToStringBuilder;
11  
12  /***
13   * Template.java
14   * @author Xavier Cho
15   * @version $Revision 1.1 $ $Date: 2005/07/21 10:04:42 $
16   * @hibernate.class
17   *          table = "POTRON_TEMPLATE"
18   *          lazy = "true"
19   * @hibernate.cache usage = "nonstrict-read-write"
20   */
21  public class Template implements Serializable {
22  
23      private static final long serialVersionUID = 183646233934599284L;
24  
25      private long id = -1;
26      private String name;
27      private Date registeredDate;
28      private String comment;
29      private String description;
30      private Project project;
31      private List<Header> headers;
32      private Set<Translation> translations;
33      private List<Entry> entries;
34  
35      public Template() {
36      }
37  
38      /***
39       * @param id
40       */
41      public Template(long id) {
42          this.id = id;
43      }
44  
45      /***
46       * @return
47       * @hibernate.id
48       *          column = "template_id"
49       *          length = "20"
50       *          unsaved-value = "-1"
51       *          generator-class = "native"
52       * @hibernate.generator-param
53       *          name = "sequence"
54       *          value = "POTRON_SEQ_TEMPLATE"
55       */
56      public long getId() {
57          return id;
58      }
59  
60      /***
61       * @return
62       * @hibernate.property
63       *          column = "name"
64       *          length = "40"
65       *          update = "true"
66       *          not-null = "true"
67       */
68      public String getName() {
69          return name;
70      }
71  
72      /***
73       * @return
74       * @hibernate.property
75       *          column = "description"
76       *          length = "800"
77       *          update = "true"
78       *          not-null = "false"
79       */
80      public String getDescription() {
81          return description;
82      }
83  
84      /***
85       * @return
86       * @hibernate.property
87       *          column = "comment"
88       *          type = "text"
89       *          update = "true"
90       *          not-null = "false"
91       */
92      public String getComment() {
93          return comment;
94      }
95  
96      /***
97       * @return
98       * @hibernate.property
99       *          column = "reg_date"
100      *          update = "false"
101      *          not-null = "true"
102      */
103     public Date getRegisteredDate() {
104         return registeredDate;
105     }
106 
107     /***
108      * @return
109      * @hibernate.many-to-one
110      *          class = "org.gnomekr.potron.data.Project"
111      *          column = "project_id"
112      *          not-null = "true"
113      */
114     public Project getProject() {
115         return project;
116     }
117 
118     /***
119      * @return
120      * @hibernate.collection-key
121      *          column = "template_id"
122      *@hibernate.collection-index
123      *          column = "header_index"
124      *          type = "int"
125      *          length = "10"
126      *@hibernate.collection-composite-element
127      *          class = "org.gnomekr.potron.data.Header"
128      * @hibernate.list
129      *          table = "POTRON_TEMPL_HEADER"
130      *          lazy = "true"
131      *          cascade = "all-delete-orphan"
132      */
133     public List<Header> getHeaders() {
134         return headers;
135     }
136 
137     /***
138      * @return
139      * @hibernate.collection-one-to-many
140      *          class = "org.gnomekr.potron.data.Translation"
141      * @hibernate.collection-key
142      *          column = "template_id"
143      * @hibernate.set
144      *          lazy = "true"
145      *          inverse = "true"
146      *          order-by = "trans_id"
147      *          cascade = "all-delete-orphan"
148      */
149     public Set<Translation> getTranslations() {
150         return translations;
151     }
152 
153     /***
154      * @return Returns the entries.
155      * @hibernate.collection-one-to-many
156      *          class = "org.gnomekr.potron.data.Entry"
157      * @hibernate.collection-key
158      *          column = "template_id"
159      * @hibernate.collection-index
160      *          column = "entry_index"
161      *          type = "int"
162      *          length = "10"
163      * @hibernate.list
164      *          lazy = "true"
165      *          order-by = "entry_id"
166      *          cascade = "all-delete-orphan"
167      */
168     public List<Entry> getEntries() {
169         return entries;
170     }
171 
172     /***
173      * @param description The description to set.
174      */
175     public void setDescription(String description) {
176         this.description = description;
177     }
178 
179     /***
180      * @param comment The comment to set.
181      */
182     public void setComment(String comment) {
183         this.comment = comment;
184     }
185 
186     /***
187      * @param id The id to set.
188      */
189     public void setId(long id) {
190         this.id = id;
191     }
192 
193     /***
194      * @param name The name to set.
195      */
196     public void setName(String name) {
197         this.name = name;
198     }
199 
200     /***
201      * @param registeredDate The registeredDate to set.
202      */
203     public void setRegisteredDate(Date registeredDate) {
204         this.registeredDate = registeredDate;
205     }
206 
207     /***
208      * @param registeredDate The project to set.
209      */
210     public void setProject(Project project) {
211         this.project = project;
212     }
213 
214     /***
215      * @param entries The entries to set.
216      */
217     public void setEntries(List<Entry> entries) {
218         this.entries = entries;
219     }
220 
221     /***
222      * @param headers The headers to set.
223      */
224     public void setHeaders(List<Header> headers) {
225         this.headers = headers;
226     }
227 
228     /***
229      * @param translations The translations to set.
230      */
231     public void setTranslations(Set<Translation> translations) {
232         this.translations = translations;
233     }
234 
235     /***
236      * @see java.lang.Object#equals(java.lang.Object)
237      */
238     public boolean equals(final Object object) {
239         if (object instanceof Template) {
240             Template template = (Template) object;
241 
242             EqualsBuilder builder = new EqualsBuilder();
243             builder.append(id, template.getId());
244             builder.append(name, template.getName());
245             builder.append(description, template.getDescription());
246 
247             return builder.isEquals();
248         }
249 
250         return false;
251     }
252 
253     /***
254      * @see java.lang.Object#toString()
255      */
256     public String toString() {
257         ToStringBuilder builder = new ToStringBuilder(this);
258         builder.append("id", id);
259         builder.append("name", name);
260         builder.append("registeredDate", registeredDate);
261 
262         return builder.toString();
263     }
264 
265     /***
266      * @see java.lang.Object#hashCode()
267      */
268     public int hashCode() {
269         HashCodeBuilder builder = new HashCodeBuilder();
270         builder.append(id);
271         builder.append(name);
272         builder.append(description);
273 
274         return builder.toHashCode();
275     }
276 }