| 1 | package tmcsim.cadmodels; |
|---|
| 2 | |
|---|
| 3 | import org.w3c.dom.Document; |
|---|
| 4 | import org.w3c.dom.Element; |
|---|
| 5 | import org.w3c.dom.Node; |
|---|
| 6 | |
|---|
| 7 | import tmcsim.common.ScriptException; |
|---|
| 8 | |
|---|
| 9 | /* |
|---|
| 10 | * The model object containing data for an entry in the IncidentSummary CAD Screen. |
|---|
| 11 | * |
|---|
| 12 | * @author |
|---|
| 13 | * @version |
|---|
| 14 | */ |
|---|
| 15 | public class IncidentSummaryModel_obj { |
|---|
| 16 | |
|---|
| 17 | private static enum XML_TAGS { |
|---|
| 18 | /** Log number. */ |
|---|
| 19 | LOG_NUMBER ("LOG_NUMBER"), |
|---|
| 20 | /** Log status. */ |
|---|
| 21 | LOG_STATUS ("LOG_STATUS"), |
|---|
| 22 | /** Log creation date. */ |
|---|
| 23 | DATE ("DATE"), |
|---|
| 24 | /** Log creation time. */ |
|---|
| 25 | TIME ("TIME"), |
|---|
| 26 | /** Log priority. */ |
|---|
| 27 | PRIORITY ("PRIORITY"), |
|---|
| 28 | /** Log type. */ |
|---|
| 29 | TYPE ("TYPE"), |
|---|
| 30 | /** Log beat area. */ |
|---|
| 31 | BEAT_AREA ("BEAT_AREA"), |
|---|
| 32 | /** Log location. */ |
|---|
| 33 | LOCATION ("LOCATION"), |
|---|
| 34 | /** Log beat assigned. */ |
|---|
| 35 | BEAT_ASSIGNED ("BEAT_ASSIGNED"); |
|---|
| 36 | |
|---|
| 37 | public String tag; |
|---|
| 38 | |
|---|
| 39 | private XML_TAGS(String t) { |
|---|
| 40 | tag = t; |
|---|
| 41 | } |
|---|
| 42 | } |
|---|
| 43 | |
|---|
| 44 | /** Unique log number */ |
|---|
| 45 | public Integer logNumber; |
|---|
| 46 | |
|---|
| 47 | /** Log status */ |
|---|
| 48 | public String logStatus; |
|---|
| 49 | |
|---|
| 50 | /** Log creation date */ |
|---|
| 51 | public String date; |
|---|
| 52 | |
|---|
| 53 | /** Log creation time */ |
|---|
| 54 | public String time; |
|---|
| 55 | |
|---|
| 56 | /** Log priority */ |
|---|
| 57 | public String priority; |
|---|
| 58 | |
|---|
| 59 | /** Log type */ |
|---|
| 60 | public String callType; |
|---|
| 61 | |
|---|
| 62 | /** Log beat area */ |
|---|
| 63 | public String beatArea; |
|---|
| 64 | |
|---|
| 65 | /** Log location */ |
|---|
| 66 | public String location; |
|---|
| 67 | |
|---|
| 68 | /** log beat assigned */ |
|---|
| 69 | public String beatAssigned; |
|---|
| 70 | |
|---|
| 71 | |
|---|
| 72 | /** |
|---|
| 73 | * Constructor. Initialize all model data to empty strings. |
|---|
| 74 | */ |
|---|
| 75 | public IncidentSummaryModel_obj() { |
|---|
| 76 | logNumber = new Integer(0); |
|---|
| 77 | logStatus = ""; |
|---|
| 78 | date = ""; |
|---|
| 79 | time = ""; |
|---|
| 80 | priority = ""; |
|---|
| 81 | callType = ""; |
|---|
| 82 | beatArea = ""; |
|---|
| 83 | location = ""; |
|---|
| 84 | beatAssigned = ""; |
|---|
| 85 | } |
|---|
| 86 | |
|---|
| 87 | /** |
|---|
| 88 | * Constructor. Initialize all model data to parameter data. |
|---|
| 89 | * |
|---|
| 90 | * @param newLogNumber Incident log number |
|---|
| 91 | * @param newLogStatus Incident log status |
|---|
| 92 | * @param newDate Incident creation date |
|---|
| 93 | * @param newTime Incident create time |
|---|
| 94 | * @param newPriority Incident priority |
|---|
| 95 | * @param newCallType Incident type |
|---|
| 96 | * @param newBeatArea Incident beat area |
|---|
| 97 | * @param newLocation Incident location |
|---|
| 98 | * @param newBeatAssigned Incident beat assigned |
|---|
| 99 | */ |
|---|
| 100 | public IncidentSummaryModel_obj(Integer newLogNumber, |
|---|
| 101 | String newLogStatus, |
|---|
| 102 | String newDate, |
|---|
| 103 | String newTime, |
|---|
| 104 | String newPriority, |
|---|
| 105 | String newCallType, |
|---|
| 106 | String newBeatArea, |
|---|
| 107 | String newLocation, |
|---|
| 108 | String newBeatAssigned) { |
|---|
| 109 | logNumber = newLogNumber; |
|---|
| 110 | logStatus = newLogStatus; |
|---|
| 111 | date = newDate; |
|---|
| 112 | time = newTime; |
|---|
| 113 | priority = newPriority; |
|---|
| 114 | callType = newCallType; |
|---|
| 115 | beatArea = newBeatArea; |
|---|
| 116 | location = newLocation; |
|---|
| 117 | beatAssigned = newBeatAssigned; |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | /** |
|---|
| 121 | * Constructor. Initialize all model data with IncidentInquiryHeader. |
|---|
| 122 | * |
|---|
| 123 | * @param newIncident IncidentInquiryHeader object containing data for |
|---|
| 124 | * IncidentSummery model. |
|---|
| 125 | */ |
|---|
| 126 | public IncidentSummaryModel_obj(IncidentInquiryHeader newIncident) { |
|---|
| 127 | logNumber = newIncident.logNumber; |
|---|
| 128 | logStatus = newIncident.logStatus; |
|---|
| 129 | date = newIncident.incidentDate; |
|---|
| 130 | time = newIncident.incidentTime; |
|---|
| 131 | priority = newIncident.priority; |
|---|
| 132 | callType = newIncident.type; |
|---|
| 133 | beatArea = newIncident.beat; |
|---|
| 134 | location = newIncident.fullLocation; |
|---|
| 135 | beatAssigned = newIncident.beat; |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | /** |
|---|
| 139 | * Constructor. Initialize all model data to data in parameter Node. |
|---|
| 140 | * |
|---|
| 141 | * @param theNode Node containing data for IncidentSummary model. |
|---|
| 142 | */ |
|---|
| 143 | public IncidentSummaryModel_obj(Node theNode) throws ScriptException { |
|---|
| 144 | |
|---|
| 145 | fromXML(theNode); |
|---|
| 146 | |
|---|
| 147 | } |
|---|
| 148 | |
|---|
| 149 | public void toXML(Element currElem) { |
|---|
| 150 | |
|---|
| 151 | Document theDoc = currElem.getOwnerDocument(); |
|---|
| 152 | Element tempElem = null; |
|---|
| 153 | |
|---|
| 154 | currElem.setAttribute(XML_TAGS.LOG_NUMBER.tag, logNumber.toString()); |
|---|
| 155 | |
|---|
| 156 | tempElem = theDoc.createElement(XML_TAGS.LOG_STATUS.tag); |
|---|
| 157 | tempElem.appendChild(theDoc.createTextNode(logStatus)); |
|---|
| 158 | currElem.appendChild(tempElem); |
|---|
| 159 | |
|---|
| 160 | tempElem = theDoc.createElement(XML_TAGS.DATE.tag); |
|---|
| 161 | tempElem.appendChild(theDoc.createTextNode(date)); |
|---|
| 162 | currElem.appendChild(tempElem); |
|---|
| 163 | |
|---|
| 164 | tempElem = theDoc.createElement(XML_TAGS.TIME.tag); |
|---|
| 165 | tempElem.appendChild(theDoc.createTextNode(time)); |
|---|
| 166 | currElem.appendChild(tempElem); |
|---|
| 167 | |
|---|
| 168 | tempElem = theDoc.createElement(XML_TAGS.PRIORITY.tag); |
|---|
| 169 | tempElem.appendChild(theDoc.createTextNode(priority)); |
|---|
| 170 | currElem.appendChild(tempElem); |
|---|
| 171 | |
|---|
| 172 | tempElem = theDoc.createElement(XML_TAGS.TYPE.tag); |
|---|
| 173 | tempElem.appendChild(theDoc.createTextNode(callType)); |
|---|
| 174 | currElem.appendChild(tempElem); |
|---|
| 175 | |
|---|
| 176 | tempElem = theDoc.createElement(XML_TAGS.BEAT_AREA.tag); |
|---|
| 177 | tempElem.appendChild(theDoc.createTextNode(beatArea)); |
|---|
| 178 | currElem.appendChild(tempElem); |
|---|
| 179 | |
|---|
| 180 | tempElem = theDoc.createElement(XML_TAGS.LOCATION.tag); |
|---|
| 181 | tempElem.appendChild(theDoc.createTextNode(location)); |
|---|
| 182 | currElem.appendChild(tempElem); |
|---|
| 183 | |
|---|
| 184 | tempElem = theDoc.createElement(XML_TAGS.BEAT_ASSIGNED.tag); |
|---|
| 185 | tempElem.appendChild(theDoc.createTextNode(beatAssigned)); |
|---|
| 186 | currElem.appendChild(tempElem); |
|---|
| 187 | |
|---|
| 188 | } |
|---|
| 189 | |
|---|
| 190 | |
|---|
| 191 | public void fromXML(Node modelNode) throws ScriptException { |
|---|
| 192 | |
|---|
| 193 | Node childNode = null; |
|---|
| 194 | |
|---|
| 195 | logNumber = Integer.parseInt(modelNode.getAttributes().getNamedItem( |
|---|
| 196 | XML_TAGS.LOG_NUMBER.tag).getNodeValue()); |
|---|
| 197 | |
|---|
| 198 | childNode = modelNode.getFirstChild(); |
|---|
| 199 | logStatus = childNode.getTextContent(); |
|---|
| 200 | |
|---|
| 201 | childNode = childNode.getNextSibling(); |
|---|
| 202 | date = childNode.getTextContent(); |
|---|
| 203 | |
|---|
| 204 | childNode = childNode.getNextSibling(); |
|---|
| 205 | time = childNode.getTextContent(); |
|---|
| 206 | |
|---|
| 207 | childNode = childNode.getNextSibling(); |
|---|
| 208 | priority = childNode.getTextContent(); |
|---|
| 209 | |
|---|
| 210 | childNode = childNode.getNextSibling(); |
|---|
| 211 | callType = childNode.getTextContent(); |
|---|
| 212 | |
|---|
| 213 | childNode = childNode.getNextSibling(); |
|---|
| 214 | beatArea = childNode.getTextContent(); |
|---|
| 215 | |
|---|
| 216 | childNode = childNode.getNextSibling(); |
|---|
| 217 | location = childNode.getTextContent(); |
|---|
| 218 | |
|---|
| 219 | childNode = childNode.getNextSibling(); |
|---|
| 220 | beatAssigned = childNode.getTextContent(); |
|---|
| 221 | |
|---|
| 222 | } |
|---|
| 223 | } |
|---|