001: /*
002: * Copyright 2005 Joe Walker
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016: package org.getahead.dwrdemo.ticketcenter;
017:
018: import java.util.Date;
019:
020: import org.directwebremoting.Security;
021:
022: /**
023: * @author Joe Walker [joe at getahead dot ltd dot uk]
024: */
025: public class Call {
026: private Date callStarted = new Date();
027:
028: private String notes = "";
029:
030: private boolean super visorAlert = false;
031:
032: private String name;
033:
034: private String address;
035:
036: private String phoneNumber;
037:
038: private int id;
039:
040: private String handlerId;
041:
042: /**
043: * @return the callStarted
044: */
045: public Date getCallStarted() {
046: return callStarted;
047: }
048:
049: /**
050: * @param callStarted the callStarted to set
051: */
052: @SuppressWarnings({"AssignmentToDateFieldFromParameter"})
053: public void setCallStarted(Date callStarted) {
054: this .callStarted = callStarted;
055: }
056:
057: /**
058: * @return A descriptive strong of roughly how long is it since the call started.
059: */
060: public String getWaitTime() {
061: long timePlain = new Date().getTime() - callStarted.getTime();
062: int time = 10000 * Math.round(timePlain / 10000);
063: return "" + time;
064: }
065:
066: /**
067: * @return the notes
068: */
069: public String getNotes() {
070: return notes;
071: }
072:
073: /**
074: * @param notes the notes to set
075: */
076: public void setNotes(String notes) {
077: this .notes = notes;
078: }
079:
080: /**
081: * @return the supervisorAlert
082: */
083: public boolean isSupervisorAlert() {
084: return super visorAlert;
085: }
086:
087: /**
088: * @param supervisorAlert the supervisorAlert to set
089: */
090: public void setSupervisorAlert(boolean super visorAlert) {
091: this .super visorAlert = super visorAlert;
092: }
093:
094: /**
095: * @return the address
096: */
097: public String getAddress() {
098: return address;
099: }
100:
101: /**
102: * @param address the address to set
103: */
104: public void setAddress(String address) {
105: this .address = Security.escapeHtml(address);
106: }
107:
108: /**
109: * @return the id
110: */
111: public int getId() {
112: return id;
113: }
114:
115: /**
116: * @param id the id to set
117: */
118: public void setId(int id) {
119: this .id = id;
120: }
121:
122: /**
123: * @return the name
124: */
125: public String getName() {
126: return name;
127: }
128:
129: /**
130: * @param name the name to set
131: */
132: public void setName(String name) {
133: this .name = Security.escapeHtml(name);
134: }
135:
136: /**
137: * @return the phoneNumber
138: */
139: public String getPhoneNumber() {
140: return phoneNumber;
141: }
142:
143: /**
144: * @param phoneNumber the phoneNumber to set
145: */
146: public void setPhoneNumber(String phoneNumber) {
147: this .phoneNumber = phoneNumber;
148: }
149:
150: /**
151: * @return the handlerId
152: */
153: protected String getHandlerId() {
154: return handlerId;
155: }
156:
157: /**
158: * @param handlerId the handlerIdId to set
159: */
160: protected void setHandlerId(String handlerId) {
161: this .handlerId = handlerId;
162: }
163:
164: /**
165: * @return true if this call has a handler
166: */
167: public boolean isHandled() {
168: return handlerId != null;
169: }
170:
171: /* (non-Javadoc)
172: * @see java.lang.Object#equals(java.lang.Object)
173: */
174: @Override
175: public boolean equals(Object obj) {
176: if (obj == null) {
177: return false;
178: }
179:
180: if (obj == this ) {
181: return true;
182: }
183:
184: if (!this .getClass().equals(obj.getClass())) {
185: return false;
186: }
187:
188: Call that = (Call) obj;
189:
190: if (this .id != that.id) {
191: return false;
192: }
193:
194: return true;
195: }
196:
197: /* (non-Javadoc)
198: * @see java.lang.Object#hashCode()
199: */
200: @Override
201: public int hashCode() {
202: return 5924 + id;
203: }
204:
205: /* (non-Javadoc)
206: * @see java.lang.Object#toString()
207: */
208: @Override
209: public String toString() {
210: return "Person[id=" + id + ",name=" + name + "]";
211: }
212: }
|