View Javadoc

1   /*
2    *  Copyright 2004-2006 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 org.asteriskjava.manager.event;
18  
19  /***
20   * A QueueMemberEvent is triggered in response to a QueueStatusAction and
21   * contains information about a member of a queue.
22   * <p>
23   * It is implemented in <code>apps/app_queue.c</code>
24   * 
25   * @see org.asteriskjava.manager.action.QueueStatusAction
26   * @author srt
27   * @version $Id: QueueMemberEvent.java 628 2007-03-25 00:12:17Z msmith $
28   */
29  public class QueueMemberEvent extends ResponseEvent
30  {
31      public static final int AST_DEVICE_UNKNOWN = 0;
32  
33      /***
34       * Queue member is available
35       */
36      public static final int AST_DEVICE_NOT_INUSE = 1;
37      public static final int AST_DEVICE_INUSE = 2;
38      public static final int AST_DEVICE_BUSY = 3;
39      public static final int AST_DEVICE_INVALID = 4;
40      public static final int AST_DEVICE_UNAVAILABLE = 5;
41  
42      /***
43       * Serializable version identifier
44       */
45      private static final long serialVersionUID = -2293926744791895763L;
46      private String queue;
47      private String location;
48      private String membership;
49      private String memberName;
50      private Integer penalty;
51      private Integer callsTaken;
52      private Long lastCall;
53      private Integer status;
54      private Boolean paused;
55  
56      /***
57       * @param source
58       */
59      public QueueMemberEvent(Object source)
60      {
61          super(source);
62      }
63  
64      /***
65       * Returns the name of the queue.
66       * 
67       * @return the name of the queue.
68       */
69      public String getQueue()
70      {
71          return queue;
72      }
73  
74      /***
75       * Sets the name of the queue.
76       * 
77       * @param queue the name of the queue.
78       */
79      public void setQueue(String queue)
80      {
81          this.queue = queue;
82      }
83  
84      /***
85       * Returns the name of the member's interface.
86       * <p>
87       * E.g. the channel name or agent group (for example "Agent/@1").
88       * 
89       * @return the name of the member's interface.
90       */
91      public String getLocation()
92      {
93          return location;
94      }
95  
96      /***
97       * Sets the name of the member's interface.
98       * 
99       * @param member the name of the member's interface.
100      */
101     public void setLocation(String location)
102     {
103         this.location = location;
104     }
105 
106     /***
107      * Returns if this member has been dynamically added by the QueueAdd command
108      * (in the dialplan or via the Manager API) or if this member is has been
109      * statically defined in <code>queues.conf</code>.
110      * 
111      * @return "dynamic" if the added member is a dynamic queue member, "static"
112      *         if the added member is a static queue member.
113      */
114     public String getMembership()
115     {
116         return membership;
117     }
118 
119     /***
120      * Convenience method that checks whether this member has been statically
121      * defined in <code>queues.conf</code>.
122      * 
123      * @return <code>true</code> if this member has been statically defined in
124      *         <code>queues.conf</code>, <code>false</code> otherwise.
125      * @since 0.3
126      */
127     public boolean isStatic()
128     {
129         return membership != null && "static".equals(membership);
130     }
131 
132     /***
133      * Convenience method that checks whether this member has been dynamically
134      * added by the QueueAdd command.
135      * 
136      * @return <code>true</code> if this member has been dynamically added by
137      *         the QueueAdd command, <code>false</code> otherwise.
138      * @since 0.3
139      */
140     public boolean isDynamic()
141     {
142         return membership != null && "dynamic".equals(membership);
143     }
144 
145     /***
146      * Sets if this member has been dynamically or statically added.
147      * 
148      * @param membership "dynamic" if the added member is a dynamic queue
149      *            member, "static" if the added member is a static queue member.
150      */
151     public void setMembership(String membership)
152     {
153         this.membership = membership;
154     }
155 
156     /***
157      * Returns the penalty for the added member. When calls are distributed
158      * members with higher penalties are considered last.
159      * 
160      * @return the penalty for the added member.
161      */
162     public Integer getPenalty()
163     {
164         return penalty;
165     }
166 
167     /***
168      * Sets the penalty for this member.
169      * 
170      * @param penalty the penalty for this member.
171      */
172     public void setPenalty(Integer penalty)
173     {
174         this.penalty = penalty;
175     }
176 
177     /***
178      * Returns the number of calls answered by the member.
179      * 
180      * @return the number of calls answered by the member.
181      */
182     public Integer getCallsTaken()
183     {
184         return callsTaken;
185     }
186 
187     /***
188      * Sets the number of calls answered by the added member.
189      * 
190      * @param callsTaken the number of calls answered by the added member.
191      */
192     public void setCallsTaken(Integer callsTaken)
193     {
194         this.callsTaken = callsTaken;
195     }
196 
197     /***
198      * Returns the time the last successful call answered by the added member
199      * was hungup.
200      * 
201      * @return the time (in seconds since 01/01/1970) the last successful call
202      *         answered by the added member was hungup.
203      */
204     public Long getLastCall()
205     {
206         return lastCall;
207     }
208 
209     /***
210      * Sets the time the last successful call answered by this member was
211      * hungup.
212      * 
213      * @param lastCall the time (in seconds since 01/01/1970) the last
214      *            successful call answered by the added member was hungup.
215      */
216     public void setLastCall(Long lastCall)
217     {
218         this.lastCall = lastCall;
219     }
220 
221     /***
222      * Returns the status of this queue member.
223      * <p>
224      * Available since Asterisk 1.2
225      * <p>
226      * Valid status codes are:
227      * <dl>
228      * <dt>AST_DEVICE_UNKNOWN (0)</dt>
229      * <dd>Queue member is available</dd>
230      * <dt>AST_DEVICE_NOT_INUSE (1)</dt>
231      * <dd>?</dd>
232      * <dt>AST_DEVICE_INUSE (2)</dt>
233      * <dd>?</dd>
234      * <dt>AST_DEVICE_BUSY (3)</dt>
235      * <dd>?</dd>
236      * <dt>AST_DEVICE_INVALID (4)</dt>
237      * <dd>?</dd>
238      * <dt>AST_DEVICE_UNAVAILABLE (5)</dt>
239      * <dd>?</dd>
240      * </dl>
241      * 
242      * @return the status of this queue member or <code>null</code> if this
243      *         attribute is not supported by your version of Asterisk.
244      * @since 0.2
245      */
246     public Integer getStatus()
247     {
248         return status;
249     }
250 
251     /***
252      * Sets the status of this queue member.
253      * 
254      * @param the status of this queue member
255      * @since 0.2
256      */
257     public void setStatus(Integer status)
258     {
259         this.status = status;
260     }
261 
262     /***
263      * Is this queue member paused (not accepting calls)?
264      * <p>
265      * Available since Asterisk 1.2.
266      * 
267      * @return <code>Boolean.TRUE</code> if this member has been paused,
268      *         <code>Boolean.FALSE</code> if not or <code>null</code> if
269      *         pausing is not supported by your version of Asterisk.
270      * @since 0.2
271      */
272     public Boolean getPaused()
273     {
274         return paused;
275     }
276 
277     /***
278      * Sets if this member has been paused.
279      * 
280      * @since 0.2
281      */
282     public void setPaused(Boolean paused)
283     {
284         this.paused = paused;
285     }
286 
287     /***
288      * @return the member name supplied for logging when the member is added
289      */
290     public String getMemberName()
291     {
292         return memberName;
293     }
294 
295     /***
296      * @param memberName the member name supplied for logging when the member is added
297      */
298     public void setMemberName(String memberName)
299     {
300         this.memberName = memberName;
301     }
302 }