001    /**
002     * Licensed to the Apache Software Foundation (ASF) under one
003     * or more contributor license agreements.  See the NOTICE file
004     * distributed with this work for additional information
005     * regarding copyright ownership.  The ASF licenses this file
006     * to you under the Apache License, Version 2.0 (the
007     * "License"); you may not use this file except in compliance
008     * with the License.  You may obtain a copy of the License at
009     * 
010     *      http://www.apache.org/licenses/LICENSE-2.0
011     * 
012     * Unless required by applicable law or agreed to in writing, software
013     * distributed under the License is distributed on an "AS IS" BASIS,
014     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015     * See the License for the specific language governing permissions and
016     * limitations under the License.
017     */
018    package org.apache.oozie.client.rest;
019    
020    import java.util.Date;
021    
022    import javax.persistence.Basic;
023    import javax.persistence.Column;
024    import javax.persistence.DiscriminatorColumn;
025    import javax.persistence.DiscriminatorType;
026    import javax.persistence.Entity;
027    import javax.persistence.GeneratedValue;
028    import javax.persistence.GenerationType;
029    import javax.persistence.Id;
030    import javax.persistence.Lob;
031    import javax.persistence.SequenceGenerator;
032    import javax.persistence.Table;
033    import javax.persistence.Transient;
034    
035    import org.apache.oozie.client.SLAEvent;
036    import org.json.simple.JSONObject;
037    
038    @Entity
039    @Table(name = "SLA_EVENTS")
040    @DiscriminatorColumn(name = "bean_type", discriminatorType = DiscriminatorType.STRING)
041    public class JsonSLAEvent implements SLAEvent, JsonBean {
042        // Primary key
043        @Id
044        @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "EVENT_SEQ")
045        @SequenceGenerator(name = "EVENT_SEQ", sequenceName = "EVENT_SEQ", initialValue = 1, allocationSize = 50)
046        private long event_id;
047    
048        @Basic
049        @Column(name = "sla_id")
050        private String slaId;
051    
052        @Transient
053        private SlaAppType appType = null;
054    
055        @Basic
056        @Column(name = "app_name")
057        private String appName = null;
058    
059        @Basic
060        @Column(name = "user_name")
061        private String user = null;
062    
063        @Basic
064        @Column(name = "group_name")
065        private String groupName = null;
066    
067        @Basic
068        @Column(name = "parent_client_id")
069        private String parentClientId = null;
070    
071        @Basic
072        @Column(name = "parent_sla_id")
073        private String parentSlaId = null;
074    
075        @Transient
076        private Date expectedStart = null;
077    
078        @Transient
079        private Date expectedEnd = null;
080    
081        @Transient
082        private Date statusTimestamp = null;
083    
084        @Column(name = "notification_msg")
085        @Lob
086        private String notificationMsg = null;
087    
088        @Basic
089        @Column(name = "alert_contact")
090        private String alertContact = null;
091    
092        @Basic
093        @Column(name = "dev_contact")
094        private String devContact = null;
095    
096        @Basic
097        @Column(name = "qa_contact")
098        private String qaContact = null;
099    
100        @Basic
101        @Column(name = "se_contact")
102        private String seContact = null;
103    
104        @Basic
105        @Column(name = "alert_frequency")
106        private String alertFrequency = null;
107    
108        @Basic
109        @Column(name = "alert_percentage")
110        private String alertPercentage = null;
111    
112        @Column(name = "upstream_apps")
113        @Lob
114        private String upstreamApps = null;
115    
116        @Transient
117        private Status jobStatus = null;
118    
119        @Column(name = "job_data")
120        @Lob
121        private String jobData = null;
122    
123        public long getEvent_id() {
124            return event_id;
125        }
126    
127        public void setEvent_id(long id) {
128            this.event_id = id;
129        }
130    
131        public String getSlaId() {
132            return slaId;
133        }
134    
135        public void setSlaId(String slaId) {
136            this.slaId = slaId;
137        }
138    
139        /*
140         * public String getClientId() { return clientId; }
141         *
142         * public void setClientId(String clientId) { this.clientId = clientId; }
143         */
144        public SlaAppType getAppType() {
145            return appType;
146        }
147    
148        public void setAppType(SlaAppType appType) {
149            this.appType = appType;
150        }
151    
152        public String getAppName() {
153            return appName;
154        }
155    
156        public void setAppName(String appName) {
157            this.appName = appName;
158        }
159    
160        public String getUser() {
161            return user;
162        }
163    
164        public void setUser(String user) {
165            this.user = user;
166        }
167    
168        public String getGroupName() {
169            return groupName;
170        }
171    
172        public void setGroupName(String groupName) {
173            this.groupName = groupName;
174        }
175    
176        public String getParentClientId() {
177            return parentClientId;
178        }
179    
180        public void setParentClientId(String parentClientId) {
181            this.parentClientId = parentClientId;
182        }
183    
184        public String getParentSlaId() {
185            return parentSlaId;
186        }
187    
188        public void setParentSlaId(String parentSlaId) {
189            this.parentSlaId = parentSlaId;
190        }
191    
192        public Date getExpectedStart() {
193            return expectedStart;
194        }
195    
196        public void setExpectedStart(Date expectedStart) {
197            this.expectedStart = expectedStart;
198        }
199    
200        public Date getExpectedEnd() {
201            return expectedEnd;
202        }
203    
204        public void setExpectedEnd(Date expectedEnd) {
205            this.expectedEnd = expectedEnd;
206        }
207    
208        public Date getStatusTimestamp() {
209            return statusTimestamp;
210        }
211    
212        public void setStatusTimestamp(Date statusTimestamp) {
213            this.statusTimestamp = statusTimestamp;
214        }
215    
216        public String getNotificationMsg() {
217            return notificationMsg;
218        }
219    
220        public void setNotificationMsg(String notificationMsg) {
221            this.notificationMsg = notificationMsg;
222        }
223    
224        public String getAlertContact() {
225            return alertContact;
226        }
227    
228        public void setAlertContact(String alertContact) {
229            this.alertContact = alertContact;
230        }
231    
232        public String getDevContact() {
233            return devContact;
234        }
235    
236        public void setDevContact(String devContact) {
237            this.devContact = devContact;
238        }
239    
240        public String getQaContact() {
241            return qaContact;
242        }
243    
244        public void setQaContact(String qaContact) {
245            this.qaContact = qaContact;
246        }
247    
248        public String getSeContact() {
249            return seContact;
250        }
251    
252        public void setSeContact(String seContact) {
253            this.seContact = seContact;
254        }
255    
256        public String getAlertFrequency() {
257            return alertFrequency;
258        }
259    
260        public void setAlertFrequency(String alertFrequency) {
261            this.alertFrequency = alertFrequency;
262        }
263    
264        public String getAlertPercentage() {
265            return alertPercentage;
266        }
267    
268        public void setAlertPercentage(String alertPercentage) {
269            this.alertPercentage = alertPercentage;
270        }
271    
272        public String getUpstreamApps() {
273            return upstreamApps;
274        }
275    
276        public void setUpstreamApps(String upstreamApps) {
277            this.upstreamApps = upstreamApps;
278        }
279    
280        public Status getJobStatus() {
281            return jobStatus;
282        }
283    
284        public void setJobStatus(Status jobStatus) {
285            this.jobStatus = jobStatus;
286        }
287    
288        public String getJobData() {
289            return jobData;
290        }
291    
292        public void setJobData(String jobData) {
293            this.jobData = jobData;
294        }
295    
296        @Override
297        public JSONObject toJSONObject() {
298            // TODO Auto-generated method stub
299            return null;
300        }
301    
302        public JsonSLAEvent() {
303    
304        }
305    
306        @SuppressWarnings("unchecked")
307        public JsonSLAEvent(JSONObject json) {
308    
309        }
310    
311    }