View Javadoc

1   /**
2    * 
3    */
4   package de.tivsource.page.common.css;
5   
6   import java.util.Date;
7   import java.util.List;
8   import java.util.SortedSet;
9   
10  import javax.persistence.CascadeType;
11  import javax.persistence.Column;
12  import javax.persistence.Entity;
13  import javax.persistence.EnumType;
14  import javax.persistence.Enumerated;
15  import javax.persistence.FetchType;
16  import javax.persistence.Id;
17  import javax.persistence.ManyToMany;
18  import javax.persistence.OneToMany;
19  import javax.persistence.Table;
20  import javax.persistence.Temporal;
21  import javax.persistence.Version;
22  
23  import org.hibernate.annotations.SortNatural;
24  import org.hibernate.envers.Audited;
25  import org.hibernate.search.annotations.DocumentId;
26  
27  import de.tivsource.page.entity.enumeration.Language;
28  import de.tivsource.page.entity.pictureitem.PictureItem;
29  
30  /**
31   * @author Marc Michele
32   *
33   */
34  @Audited
35  @Entity
36  @Table(name = "CSSGroup")
37  public class CSSGroup implements Comparable<CSSGroup> {
38  
39      /**
40       * UUID der Klasse CSSGroup, diese ID ist einmalig über alle Objekte hinweg
41       * und sollte der bevorzugte weg sein auf bestimmtes Objekte zuzugreifen.
42       */
43      @Id
44      @DocumentId
45      @Column(name = "uuid", unique = true, length = 42)
46      private String uuid;
47  
48      private String name;
49  
50      private String description;
51  
52      @Enumerated(EnumType.STRING)
53      private Language language;
54  
55      /**
56       * Set mit den CSS-Dateien die zu der Gruppe gehören.
57       */
58      @ManyToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.EAGER, mappedBy = "groups", targetEntity = CSSFile.class)
59      @SortNatural
60      private SortedSet<CSSFile> files;
61  
62      @OneToMany(mappedBy = "cssGroup", cascade = { CascadeType.PERSIST, CascadeType.MERGE }, fetch = FetchType.LAZY)
63      private List<PictureItem> pictureItems;
64  
65      @Temporal(javax.persistence.TemporalType.TIMESTAMP)
66      private Date created;
67  
68      @Temporal(javax.persistence.TemporalType.TIMESTAMP)
69      private Date modified;
70  
71      private String modifiedBy;
72  
73      private String modifiedAddress;
74  
75      /**
76       * Versionsnummer für die Locking Strategie: optimistic-locking.
77       */
78      @Version
79      private Integer version;
80  
81      /**
82       * @return the uuid
83       */
84      public String getUuid() {
85          return uuid;
86      }
87  
88      /**
89       * @param uuid
90       *            the uuid to set
91       */
92      public void setUuid(String uuid) {
93          this.uuid = uuid;
94      }
95  
96      /**
97       * @return the name
98       */
99      public String getName() {
100         return name;
101     }
102 
103     /**
104      * @param name
105      *            the name to set
106      */
107     public void setName(String name) {
108         this.name = name;
109     }
110 
111     /**
112      * @return the description
113      */
114     public String getDescription() {
115         return description;
116     }
117 
118     /**
119      * @param description
120      *            the description to set
121      */
122     public void setDescription(String description) {
123         this.description = description;
124     }
125 
126     /**
127      * @return the language
128      */
129     public Language getLanguage() {
130         return language;
131     }
132 
133     /**
134      * @param language
135      *            the language to set
136      */
137     public void setLanguage(Language language) {
138         this.language = language;
139     }
140 
141     /**
142      * @return the files
143      */
144     public SortedSet<CSSFile> getFiles() {
145         return files;
146     }
147 
148     /**
149      * @param files
150      *            the files to set
151      */
152     public void setFiles(SortedSet<CSSFile> files) {
153         this.files = files;
154     }
155 
156     /**
157      * @return the pictureItems
158      */
159     public List<PictureItem> getPictureItems() {
160         return pictureItems;
161     }
162 
163     /**
164      * @param pictureItems the pictureItems to set
165      */
166     public void setPictureItems(List<PictureItem> pictureItems) {
167         this.pictureItems = pictureItems;
168     }
169 
170     /**
171      * @return the created
172      */
173     public Date getCreated() {
174         return created;
175     }
176 
177     /**
178      * @param created
179      *            the created to set
180      */
181     public void setCreated(Date created) {
182         this.created = created;
183     }
184 
185     /**
186      * @return the modified
187      */
188     public Date getModified() {
189         return modified;
190     }
191 
192     /**
193      * @param modified
194      *            the modified to set
195      */
196     public void setModified(Date modified) {
197         this.modified = modified;
198     }
199 
200     /**
201      * @return the modifiedBy
202      */
203     public String getModifiedBy() {
204         return modifiedBy;
205     }
206 
207     /**
208      * @param modifiedBy
209      *            the modifiedBy to set
210      */
211     public void setModifiedBy(String modifiedBy) {
212         this.modifiedBy = modifiedBy;
213     }
214 
215     /**
216      * @return the modifiedAddress
217      */
218     public String getModifiedAddress() {
219         return modifiedAddress;
220     }
221 
222     /**
223      * @param modifiedAddress
224      *            the modifiedAddress to set
225      */
226     public void setModifiedAddress(String modifiedAddress) {
227         this.modifiedAddress = modifiedAddress;
228     }
229 
230     /**
231      * @return the version
232      */
233     public Integer getVersion() {
234         return version;
235     }
236 
237     /**
238      * @param version
239      *            the version to set
240      */
241     public void setVersion(Integer version) {
242         this.version = version;
243     }
244 
245     /*
246      * (non-Javadoc)
247      * 
248      * @see java.lang.Comparable#compareTo(java.lang.Object)
249      */
250     @Override
251     public int compareTo(CSSGroup o) {
252         return o.name.compareTo(this.name);
253     }
254 
255 }// Ende class