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  package org.opencastproject.scheduler.impl.persistence;
22  
23  import java.util.Date;
24  
25  import javax.persistence.Column;
26  import javax.persistence.Entity;
27  import javax.persistence.Id;
28  import javax.persistence.IdClass;
29  import javax.persistence.Index;
30  import javax.persistence.Lob;
31  import javax.persistence.NamedQueries;
32  import javax.persistence.NamedQuery;
33  import javax.persistence.Table;
34  import javax.persistence.Temporal;
35  import javax.persistence.TemporalType;
36  
37  /**
38   * Entity object for storing extended scheduled event information in persistence storage.
39   */
40  @IdClass(EventIdPK.class)
41  @Entity(name = "ExtendedEvent")
42  @NamedQueries({
43      @NamedQuery(
44          name = "ExtendedEvent.findAll",
45          query = "SELECT e FROM ExtendedEvent e WHERE e.organization = :org"
46      ),
47      @NamedQuery(
48          name = "ExtendedEvent.countAll",
49          query = "SELECT COUNT(e) FROM ExtendedEvent e"
50      ),
51      @NamedQuery(
52          name = "ExtendedEvent.findEvents",
53          query = "SELECT e.mediaPackageId FROM ExtendedEvent e WHERE e.organization = :org AND e.captureAgentId = :ca "
54              + "AND e.startDate < :end AND e.endDate > :start ORDER BY e.startDate ASC"
55      ),
56      @NamedQuery(
57          name = "ExtendedEvent.searchEventsCA",
58          query = "SELECT e FROM ExtendedEvent e WHERE e.organization = :org AND e.captureAgentId = :ca "
59              + "AND e.startDate >= :startFrom AND e.startDate < :startTo "
60              + "AND e.endDate >= :endFrom AND e.endDate < :endTo ORDER BY e.startDate ASC"
61      ),
62      @NamedQuery(
63          name = "ExtendedEvent.searchEvents",
64          query = "SELECT e FROM ExtendedEvent e WHERE e.organization = :org "
65              + "AND e.startDate >= :startFrom AND e.startDate < :startTo "
66              + "AND e.endDate >= :endFrom AND e.endDate < :endTo ORDER BY e.startDate ASC"
67      ),
68      @NamedQuery(
69          name = "ExtendedEvent.knownRecordings",
70          query = "SELECT e FROM ExtendedEvent e WHERE e.organization = :org "
71              + "AND e.recordingState IS NOT NULL AND e.recordingLastHeard IS NOT NULL"
72      )
73  })
74  @Table(name = "oc_scheduled_extended_event", indexes = {
75      @Index(name = "IX_oc_scheduled_extended_event_organization", columnList = ("organization")),
76      @Index(name = "IX_oc_scheduled_extended_event_capture_agent_id", columnList = ("capture_agent_id")),
77      @Index(name = "IX_oc_scheduled_extended_event_dates", columnList = ("start_date, end_date"))
78  })
79  public class ExtendedEventDto {
80  
81    /** Event ID, primary key */
82    @Id
83    @Column(name = "mediapackage_id", length = 128)
84    private String mediaPackageId;
85  
86    /** Organization id, primary key */
87    @Id
88    @Column(name = "organization", length = 128)
89    private String organization;
90  
91    /** Capture agent id */
92    @Column(name = "capture_agent_id", nullable = false, length = 128)
93    private String captureAgentId;
94  
95    /** recording start date */
96    @Column(name = "start_date", nullable = false)
97    @Temporal(TemporalType.TIMESTAMP)
98    private Date startDate;
99  
100   /** recording end date */
101   @Column(name = "end_date", nullable = false)
102   @Temporal(TemporalType.TIMESTAMP)
103   private Date endDate;
104 
105   /** source */
106   @Column(name = "source")
107   private String source;
108 
109   /** recording state */
110   @Column(name = "recording_state")
111   private String recordingState;
112 
113   /** recording last heard */
114   @Column(name = "recording_last_heard")
115   private Long recordingLastHeard;
116 
117   /** presenters */
118   @Lob
119   @Column(name = "presenters")
120   private String presenters;
121 
122   /** last modified date */
123   @Column(name = "last_modified_date")
124   @Temporal(TemporalType.TIMESTAMP)
125   private Date lastModifiedDate;
126 
127   /** capture agent properties */
128   @Lob
129   @Column(name = "capture_agent_properties")
130   private String captureAgentProperties;
131 
132   /** workflow properties */
133   @Lob
134   @Column(name = "workflow_properties")
135   private String workflowProperties;
136 
137   @Column(name = "checksum", length = 64)
138   private String checksum;
139 
140   /**
141    * Default constructor without any import.
142    */
143   public ExtendedEventDto() {
144   }
145 
146   public String getMediaPackageId() {
147     return mediaPackageId;
148   }
149 
150   public void setMediaPackageId(String mediaPackageId) {
151     this.mediaPackageId = mediaPackageId;
152   }
153 
154   public String getOrganization() {
155     return organization;
156   }
157 
158   public void setOrganization(String organization) {
159     this.organization = organization;
160   }
161 
162   public String getCaptureAgentId() {
163     return captureAgentId;
164   }
165 
166   public void setCaptureAgentId(String captureAgentId) {
167     this.captureAgentId = captureAgentId;
168   }
169 
170   public Date getStartDate() {
171     return startDate;
172   }
173 
174   public void setStartDate(Date startDate) {
175     this.startDate = startDate;
176   }
177 
178   public Date getEndDate() {
179     return endDate;
180   }
181 
182   public void setEndDate(Date endDate) {
183     this.endDate = endDate;
184   }
185 
186   public String getSource() {
187     return source;
188   }
189 
190   public void setSource(String source) {
191     this.source = source;
192   }
193 
194   public String getRecordingState() {
195     return recordingState;
196   }
197 
198   public void setRecordingState(String recordingState) {
199     this.recordingState = recordingState;
200   }
201 
202   public Long getRecordingLastHeard() {
203     return recordingLastHeard;
204   }
205 
206   public void setRecordingLastHeard(Long recordingLastHeard) {
207     this.recordingLastHeard = recordingLastHeard;
208   }
209 
210   public String getPresenters() {
211     return presenters;
212   }
213 
214   public void setPresenters(String presenters) {
215     this.presenters = presenters;
216   }
217 
218   public Date getLastModifiedDate() {
219     return lastModifiedDate;
220   }
221 
222   public void setLastModifiedDate(Date lastModifiedDate) {
223     this.lastModifiedDate = lastModifiedDate;
224   }
225 
226   public String getChecksum() {
227     return checksum;
228   }
229 
230   public void setChecksum(String checksum) {
231     this.checksum = checksum;
232   }
233 
234   public String getCaptureAgentProperties() {
235     return captureAgentProperties;
236   }
237 
238   public void setCaptureAgentProperties(String captureAgentProperties) {
239     this.captureAgentProperties = captureAgentProperties;
240   }
241 
242   public String getWorkflowProperties() {
243     return workflowProperties;
244   }
245 
246   public void setWorkflowProperties(String workflowProperties) {
247     this.workflowProperties = workflowProperties;
248   }
249 }