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.event;
019    
020    import java.io.Serializable;
021    import java.util.Date;
022    
023    import org.apache.oozie.AppType;
024    
025    /**
026     * An abstract implementation of the Event interface, related to
027     * notification events after job status changes
028     */
029    public abstract class JobEvent extends Event implements Serializable {
030    
031        private static final long serialVersionUID = 1L;
032    
033        /**
034         * Coarse-grained status of the job event
035         */
036        public static enum EventStatus {
037            WAITING, STARTED, SUCCESS, SUSPEND, FAILURE
038        }
039    
040        private String id;
041        private String parentId;
042        private String user;
043        private AppType appType;
044        private String appName;
045        private EventStatus eventStatus;
046        private Date startTime;
047        private Date endTime;
048    
049        public JobEvent(String id, String parentId, String user, AppType appType, String appName) {
050            super(MessageType.JOB);
051            this.id = id;
052            this.parentId = parentId;
053            this.user = user;
054            this.appType = appType;
055            this.appName = appName;
056        }
057    
058        public String getId() {
059            return id;
060        }
061    
062        public void setId(String id) {
063            this.id = id;
064        }
065    
066        public String getParentId() {
067            return parentId;
068        }
069    
070        public void setParentId(String id) {
071            parentId = id;
072        }
073    
074        /**
075         * Get the AppType of the event
076         *
077         * @return AppType
078         */
079        public AppType getAppType() {
080            return appType;
081        }
082    
083        public void setAppType(AppType type) {
084            appType = type;
085        }
086    
087        /**
088         * Get the app-name of the job generating this event
089         *
090         * @return String app-name
091         */
092        public String getAppName() {
093            return appName;
094        }
095    
096        public void setAppName(String name) {
097            appName = name;
098        }
099    
100        /**
101         * Get user name
102         *
103         * @return user
104         */
105        public String getUser() {
106            return user;
107        }
108    
109        public void setUser(String euser) {
110            user = euser;
111        }
112    
113        /**
114         * Get the coarse status
115         *
116         * @return EventStatus
117         */
118        public EventStatus getEventStatus() {
119            return eventStatus;
120        }
121    
122        public void setEventStatus(EventStatus eStatus) {
123            eventStatus = eStatus;
124        }
125    
126    
127        public Date getStartTime() {
128            return startTime;
129        }
130    
131        public void setStartTime(Date time) {
132            startTime = time;
133        }
134    
135        public Date getEndTime() {
136            return endTime;
137        }
138    
139        public void setEndTime(Date time) {
140            endTime = time;
141        }
142    
143        @Override
144        public String toString() {
145            return "ID: " + getId() + ", MsgType:" + getMsgType() + ", AppType: " + getAppType() + ", Appname: "
146                    + getAppName() + ", Status: " + getEventStatus();
147        }
148    
149    }