View Javadoc
1   /*
2    * Licensed to The Apereo Foundation under one or more contributor license
3    * agreements. See the NOTICE file distributed with this work for additional
4    * information regarding copyright ownership.
5    *
6    *
7    * The Apereo Foundation licenses this file to you under the Educational
8    * Community License, Version 2.0 (the "License"); you may not use this file
9    * except in compliance with the License. You may obtain a copy of the License
10   * at:
11   *
12   *   http://opensource.org/licenses/ecl2.txt
13   *
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   *
20   */
21  
22  package org.opencastproject.themes.persistence;
23  
24  import org.opencastproject.security.api.User;
25  import org.opencastproject.security.api.UserDirectoryService;
26  import org.opencastproject.themes.Theme;
27  import org.opencastproject.util.data.Option;
28  
29  import java.util.Date;
30  
31  import javax.persistence.Access;
32  import javax.persistence.AccessType;
33  import javax.persistence.Column;
34  import javax.persistence.Entity;
35  import javax.persistence.GeneratedValue;
36  import javax.persistence.Id;
37  import javax.persistence.NamedQueries;
38  import javax.persistence.NamedQuery;
39  import javax.persistence.Table;
40  import javax.persistence.Temporal;
41  import javax.persistence.TemporalType;
42  
43  /** Entity object for themes. */
44  @Entity(name = "Themes")
45  @Access(AccessType.FIELD)
46  @Table(name = "oc_themes")
47  @NamedQueries({
48      @NamedQuery(name = "Themes.count", query = "SELECT COUNT(t) FROM Themes t WHERE t.organization = :org"),
49      @NamedQuery(name = "Themes.findById", query = "SELECT t FROM Themes t WHERE t.id = :id AND t.organization = :org"),
50      @NamedQuery(name = "Themes.findByOrg", query = "SELECT t FROM Themes t WHERE t.organization = :org"),
51      @NamedQuery(
52          name = "Themes.findByUserName",
53          query = "SELECT t FROM Themes t WHERE t.username = :username AND t.organization = :org"
54      ),
55      @NamedQuery(name = "Themes.clear", query = "DELETE FROM Themes t WHERE t.organization = :org")
56  })
57  public class ThemeDto {
58  
59    @Id
60    @GeneratedValue
61    @Column(name = "id", nullable = false)
62    private long id;
63  
64    @Column(name = "organization", nullable = false, length = 128)
65    private String organization;
66  
67    @Column(name = "creation_date", nullable = false)
68    @Temporal(TemporalType.TIMESTAMP)
69    private Date creationDate;
70  
71    @Column(name = "isDefault", nullable = false)
72    private boolean isDefault = false;
73  
74    @Column(name = "username", nullable = false, length = 128)
75    private String username;
76  
77    @Column(name = "name", nullable = false)
78    private String name;
79  
80    @Column(name = "description")
81    private String description;
82  
83    @Column(name = "bumper_active", nullable = false)
84    private boolean bumperActive = false;
85  
86    @Column(name = "bumper_file", length = 128)
87    private String bumperFile;
88  
89    @Column(name = "trailer_active", nullable = false)
90    private boolean trailerActive = false;
91  
92    @Column(name = "trailer_file", length = 128)
93    private String trailerFile;
94  
95    @Column(name = "title_slide_active", nullable = false)
96    private boolean titleSlideActive = false;
97  
98    @Column(name = "title_slide_metadata")
99    private String titleSlideMetadata;
100 
101   @Column(name = "title_slide_background", length = 128)
102   private String titleSlideBackground;
103 
104   @Column(name = "license_slide_active", nullable = false)
105   private boolean licenseSlideActive = false;
106 
107   @Column(name = "license_slide_background", length = 128)
108   private String licenseSlideBackground;
109 
110   @Column(name = "license_slide_description")
111   private String licenseSlideDescription;
112 
113   @Column(name = "watermark_active", nullable = false)
114   private boolean watermarkActive = false;
115 
116   @Column(name = "watermark_file", length = 128)
117   private String watermarkFile;
118 
119   @Column(name = "watermark_position")
120   private String watermarkPosition;
121 
122   /** Default constructor */
123   public ThemeDto() {
124   }
125 
126   /**
127    * @return the business object model of this theme
128    */
129   public Theme toTheme(UserDirectoryService userDirectoryService) {
130     User creator = userDirectoryService.loadUser(username);
131     return new Theme(Option.some(id), creationDate, isDefault, creator, name, description, bumperActive, bumperFile,
132             trailerActive, trailerFile, titleSlideActive, titleSlideMetadata, titleSlideBackground, licenseSlideActive,
133             licenseSlideBackground, licenseSlideDescription, watermarkActive, watermarkFile, watermarkPosition);
134   }
135 
136   public long getId() {
137     return id;
138   }
139 
140   public void setId(long id) {
141     this.id = id;
142   }
143 
144   public String getUsername() {
145     return username;
146   }
147 
148   public void setUsername(String username) {
149     this.username = username;
150   }
151 
152   public String getOrganization() {
153     return organization;
154   }
155 
156   public void setOrganization(String organization) {
157     this.organization = organization;
158   }
159 
160   public Date getCreationDate() {
161     return creationDate;
162   }
163 
164   public void setCreationDate(Date creationDate) {
165     this.creationDate = creationDate;
166   }
167 
168   public String getName() {
169     return name;
170   }
171 
172   public void setName(String name) {
173     this.name = name;
174   }
175 
176   public boolean isDefault() {
177     return isDefault;
178   }
179 
180   public void setDefault(boolean isDefault) {
181     this.isDefault = isDefault;
182   }
183 
184   public String getDescription() {
185     return description;
186   }
187 
188   public void setDescription(String description) {
189     this.description = description;
190   }
191 
192   public boolean isBumperActive() {
193     return bumperActive;
194   }
195 
196   public void setBumperActive(boolean bumperActive) {
197     this.bumperActive = bumperActive;
198   }
199 
200   public String getBumperFile() {
201     return bumperFile;
202   }
203 
204   public void setBumperFile(String bumperFile) {
205     this.bumperFile = bumperFile;
206   }
207 
208   public boolean isTrailerActive() {
209     return trailerActive;
210   }
211 
212   public void setTrailerActive(boolean trailerActive) {
213     this.trailerActive = trailerActive;
214   }
215 
216   public String getTrailerFile() {
217     return trailerFile;
218   }
219 
220   public void setTrailerFile(String trailerFile) {
221     this.trailerFile = trailerFile;
222   }
223 
224   public boolean isTitleSlideActive() {
225     return titleSlideActive;
226   }
227 
228   public void setTitleSlideActive(boolean titleSlideActive) {
229     this.titleSlideActive = titleSlideActive;
230   }
231 
232   public String getTitleSlideBackground() {
233     return titleSlideBackground;
234   }
235 
236   public void setTitleSlideBackground(String titleSlideBackground) {
237     this.titleSlideBackground = titleSlideBackground;
238   }
239 
240   public String getTitleSlideMetadata() {
241     return titleSlideMetadata;
242   }
243 
244   public void setTitleSlideMetadata(String titleSlideMetadata) {
245     this.titleSlideMetadata = titleSlideMetadata;
246   }
247 
248   public boolean isLicenseSlideActive() {
249     return licenseSlideActive;
250   }
251 
252   public void setLicenseSlideActive(boolean licenseSlideActive) {
253     this.licenseSlideActive = licenseSlideActive;
254   }
255 
256   public String getLicenseSlideBackground() {
257     return licenseSlideBackground;
258   }
259 
260   public void setLicenseSlideBackground(String licenseSlideBackground) {
261     this.licenseSlideBackground = licenseSlideBackground;
262   }
263 
264   public String getLicenseSlideDescription() {
265     return licenseSlideDescription;
266   }
267 
268   public void setLicenseSlideDescription(String licenseSlideDescription) {
269     this.licenseSlideDescription = licenseSlideDescription;
270   }
271 
272   public boolean isWatermarkActive() {
273     return watermarkActive;
274   }
275 
276   public void setWatermarkActive(boolean watermarkActive) {
277     this.watermarkActive = watermarkActive;
278   }
279 
280   public String getWatermarkFile() {
281     return watermarkFile;
282   }
283 
284   public void setWatermarkFile(String watermarkFile) {
285     this.watermarkFile = watermarkFile;
286   }
287 
288   public String getWatermarkPosition() {
289     return watermarkPosition;
290   }
291 
292   public void setWatermarkPosition(String watermarkPosition) {
293     this.watermarkPosition = watermarkPosition;
294   }
295 
296 }