source: tmcsimulator/trunk/src/tmcsim/cadmodels/IncidentInquiryModel.java @ 2

Revision 2, 4.9 KB checked in by jdalbey, 10 years ago (diff)

Initial Import of project files

Line 
1package tmcsim.cadmodels;
2
3import org.w3c.dom.Document;
4import org.w3c.dom.Element;
5import org.w3c.dom.Node;
6
7import tmcsim.common.ScriptException;
8import tmcsim.common.CADEnums.CADScreenNum;
9import tmcsim.common.CADEnums.CADScreenType;
10import tmcsim.common.CADProtocol.CAD_COMMANDS;
11
12
13/**
14 * IncidentInquiryModel is a CADScreenModel object containing data that is
15 * displayed in the IncidentInquiry CAD Screen.  The addModelObject() method
16 * is used to update the model data with new information.<br/>
17 * <br/>
18 * This element parses and creates the following XML schema in its toXML() and
19 * fromXML() methods.  The ROOT element is the parameter for those methods. 
20 * See the class description for the CADScreenModel and
21 * IncidentInquiryModel_obj Objects for their XML schema.<br/>
22 * <ROOT>
23 *    <INCIDENT_INQUIRY>
24 *       <BASE_MODEL_INFO/>
25 *       ... IncidentInquiryModel_obj ...
26 *    </INCIDENT_INQUIRY>
27 * </ROOT>
28 *
29 * @see IncidentInquiryModel_obj
30 * @see CADScreenModel
31 * @author Matthew Cechini
32 * @version
33 */
34public class IncidentInquiryModel extends CADScreenModel {
35
36    /** Object containing model data. */
37    private IncidentInquiryModel_obj theModelObj = null;   
38   
39    /**
40     * Constructor. Initialize the model data and set the log number.
41     * This constructor is used when creating an IncidentInquiry
42     * model object where the source is the script.
43     *
44     * @param num CADScreen number for this model object.
45     * @param logNum Unique log number for this model object.
46     */
47    public IncidentInquiryModel(CADScreenNum num, Integer logNum) {
48        super(CADScreenType.II_INCIDENT_INQUIRY, num);
49       
50        theModelObj = new IncidentInquiryModel_obj();
51        theModelObj.setLogNumber(logNum);
52    }
53   
54    /**
55     * Constructor. Initialize the model data and set the log number.
56     * This constructor is used when creating an IncidentInquiry
57     * model object where the source is a CAD position.
58     *
59     * @param CADPostion CAD Position number for where data originated.
60     * @param num CADScreen number for this model object.
61     * @param logNum Unique log number for this model object.
62     */   
63    public IncidentInquiryModel(int CADPosition, CADScreenNum num, Integer logNum) {
64        super(CADScreenType.II_INCIDENT_INQUIRY, num);
65       
66        theModelObj = new IncidentInquiryModel_obj(CADPosition);
67        theModelObj.setLogNumber(logNum);
68    }   
69   
70    /**
71     * Constructor. Initialize the model data from the parameter Node.
72     *
73     * @param newNode Node containing model data.
74     * @throws ScriptException if there is an error in parsing the Node.
75     */   
76    public IncidentInquiryModel(Node newNode) throws ScriptException {
77        super(CADScreenType.II_INCIDENT_INQUIRY, CADScreenNum.ONE);
78       
79        fromXML(newNode);   
80    }
81   
82    /**
83     * Updates the private IncidentInquiryModel_obj object with the parameter.
84     *
85     * @param iimo An IncidentInquiryModel_obj object to be added
86     */
87    public void addModelObject(Object iimo) {                       
88        theModelObj.update((IncidentInquiryModel_obj)iimo);     
89    }                   
90   
91    /**
92     * Returns the private IncidentInquiryModel object.
93     *
94     * @return The model's data object.
95     */
96    public IncidentInquiryModel_obj getModelObject() {       
97        return theModelObj; 
98    } 
99   
100    /**
101     * Sets the model object's log number.
102     *
103     * @param newLogNumber The new log number.
104     */
105    public void setLogNumber(Integer newlogNumber) {
106        theModelObj.setLogNumber(newlogNumber);
107    }   
108   
109    /**
110     * Gets the unique log number for this model's data.
111     *
112     * @return Integer log number.
113     */
114    public Integer getLogNumber() {
115        return theModelObj.getLogNumber();
116    }   
117   
118    /**
119     * Compares a parameter IncidentInquiry model object's log number against
120     * this object's log number.
121     *
122     * @param iimo Model object whose log number will be compared with
123     *             this object's log number.
124     * @return true if log numbers match, false if not.
125     */
126    public boolean logNumMatches(IncidentInquiryModel_obj iimo) {
127        return iimo.getHeader().logNumber.equals(getLogNumber());
128    }
129       
130    public void toXML(Element currElem) {
131       
132        Document theDoc = currElem.getOwnerDocument();
133       
134        Element modelElem = theDoc.createElement(CAD_COMMANDS.INCIDENT_INQUIRY.fullName);
135       
136        baseToXML(modelElem);
137       
138        theModelObj.toXML(modelElem);
139               
140        currElem.appendChild(modelElem);
141   
142    }   
143   
144    public void fromXML(Node modelNode) throws ScriptException {   
145       
146        theModelObj = new IncidentInquiryModel_obj();
147       
148        modelNode = modelNode.getFirstChild();
149       
150        baseFromXML(modelNode);     
151       
152        modelNode = modelNode.getNextSibling();
153       
154        theModelObj.fromXML(modelNode);
155       
156    }   
157   
158
159}
Note: See TracBrowser for help on using the repository browser.