View Javadoc

1   /*
2    * Copyright  2004-2005 Stefan Reuter
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  package net.sf.asterisk.manager.event;
18  
19  /***
20   * A QueueMemberEvent is triggered in response to a QueueStatusAction and
21   * contains information about a member of a queue.<br>
22   * It is implemented in <code>apps/app_queue.c</code>
23   * 
24   * @see net.sf.asterisk.manager.action.QueueStatusAction
25   * @author srt
26   * @version $Id: QueueMemberEvent.java,v 1.4 2005/08/28 09:39:50 srt Exp $
27   */
28  public class QueueMemberEvent extends ResponseEvent
29  {
30      /***
31       * Serializable version identifier
32       */
33      private static final long serialVersionUID = -2293926744791895763L;
34      private String queue;
35      private String location;
36      private String membership;
37      private Integer penalty;
38      private Integer callsTaken;
39      private Long lastCall;
40      private Integer status;
41      private Boolean paused;
42  
43      /***
44       * @param source
45       */
46      public QueueMemberEvent(Object source)
47      {
48          super(source);
49      }
50  
51      /***
52       * Returns the name of the queue.
53       * 
54       * @return the name of the queue.
55       */
56      public String getQueue()
57      {
58          return queue;
59      }
60  
61      /***
62       * Sets the name of the queue.
63       * 
64       * @param queue the name of the queue.
65       */
66      public void setQueue(String queue)
67      {
68          this.queue = queue;
69      }
70  
71      /***
72       * Returns the name of the member's interface.<br>
73       * E.g. the channel name or agent group.
74       * 
75       * @return the name of the member's interface.
76       */
77      public String getLocation()
78      {
79          return location;
80      }
81  
82      /***
83       * Sets the name of the member's interface.
84       * 
85       * @param member the name of the member's interface.
86       */
87      public void setLocation(String location)
88      {
89          this.location = location;
90      }
91  
92      /***
93       * Returns if this member has been dynamically added by the QueueAdd command
94       * (in the dialplan or via the Manager API) or if this member is has been
95       * statically defined in <code>queues.conf</code>.
96       * 
97       * @return "dynamic" if the added member is a dynamic queue member, "static"
98       *         if the added member is a static queue member.
99       */
100     public String getMembership()
101     {
102         return membership;
103     }
104 
105     /***
106      * Sets if this member has been dynamically or statically added.
107      * 
108      * @param membership "dynamic" if the added member is a dynamic queue
109      *            member, "static" if the added member is a static queue member.
110      */
111     public void setMembership(String membership)
112     {
113         this.membership = membership;
114     }
115 
116     /***
117      * Returns the penalty for the added member. When calls are distributed
118      * members with higher penalties are considered last.
119      * 
120      * @return the penalty for the added member.
121      */
122     public Integer getPenalty()
123     {
124         return penalty;
125     }
126 
127     /***
128      * Sets the penalty for this member.
129      * 
130      * @param penalty the penalty for this member.
131      */
132     public void setPenalty(Integer penalty)
133     {
134         this.penalty = penalty;
135     }
136 
137     /***
138      * Returns the number of calls answered by the member.
139      * 
140      * @return the number of calls answered by the member.
141      */
142     public Integer getCallsTaken()
143     {
144         return callsTaken;
145     }
146 
147     /***
148      * Sets the number of calls answered by the added member.
149      * 
150      * @param callsTaken the number of calls answered by the added member.
151      */
152     public void setCallsTaken(Integer callsTaken)
153     {
154         this.callsTaken = callsTaken;
155     }
156 
157     /***
158      * Returns the time the last successful call answered by the added member
159      * was hungup.
160      * 
161      * @return the time (in seconds since 01/01/1970) the last successful call
162      *         answered by the added member was hungup.
163      */
164     public Long getLastCall()
165     {
166         return lastCall;
167     }
168 
169     /***
170      * Sets the time the last successful call answered by this member was
171      * hungup.
172      * 
173      * @param lastCall the time (in seconds since 01/01/1970) the last
174      *            successful call answered by the added member was hungup.
175      */
176     public void setLastCall(Long lastCall)
177     {
178         this.lastCall = lastCall;
179     }
180 
181     /***
182      * Returns the status of this queue member.<br>
183      * Available since Asterisk 1.2<br>
184      * Valid status codes are:
185      * <dl>
186      * <dt>AST_DEVICE_UNKNOWN (0)</dt>
187      * <dd>Queue member is available</dd>
188      * <dt>AST_DEVICE_NOT_INUSE (1)</dt>
189      * <dd>?</dd>
190      * <dt>AST_DEVICE_INUSE (2)</dt>
191      * <dd>?</dd>
192      * <dt>AST_DEVICE_BUSY (3)</dt>
193      * <dd>?</dd>
194      * <dt>AST_DEVICE_INVALID (4)</dt>
195      * <dd>?</dd>
196      * <dt>AST_DEVICE_UNAVAILABLE (5)</dt>
197      * <dd>?</dd>
198      * </dl>
199      * 
200      * @return the status of this queue member or <code>null</code> if this
201      *         attribute is not supported by your version of Asterisk.
202      * @since 0.2
203      */
204     public Integer getStatus()
205     {
206         return status;
207     }
208 
209     /***
210      * Sets the status of this queue member.
211      * 
212      * @param the status of this queue member
213      * @since 0.2
214      */
215     public void setStatus(Integer status)
216     {
217         this.status = status;
218     }
219 
220     /***
221      * Is this queue member paused (not accepting calls)?<br>
222      * Available since Asterisk 1.2.
223      * 
224      * @return <code>Boolean.TRUE</code> if this member has been paused,
225      *         <code>Boolean.FALSE</code> if not or <code>null</code> if
226      *         pausing is not supported by your version of Asterisk.
227      * @since 0.2
228      */
229     public Boolean getPaused()
230     {
231         return paused;
232     }
233 
234     /***
235      * Sets if this member has been paused.
236      * 
237      * @since 0.2
238      */
239     public void setPaused(Boolean paused)
240     {
241         this.paused = paused;
242     }
243 }