]> git.basschouten.com Git - openhab-addons.git/blob
d60002fa1c88d7bdf507448e8582eb3f629b5f17
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
7  * This program and the accompanying materials are made available under the
8  * terms of the Eclipse Public License 2.0 which is available at
9  * http://www.eclipse.org/legal/epl-2.0
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.ihc.internal.ws.datatypes;
14
15 import java.io.IOException;
16
17 import javax.xml.xpath.XPathExpressionException;
18
19 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
20
21 /**
22  * Class for WSProjectInfo complex type.
23  *
24  * @author Pauli Anttila - Initial contribution
25  */
26 public class WSProjectInfo {
27
28     private int visualMinorVersion;
29     private int visualMajorVersion;
30     private int projectMajorRevision;
31     private int projectMinorRevision;
32     private WSDate lastmodified;
33     private String projectNumber;
34     private String customerName;
35     private String installerName;
36
37     public WSProjectInfo() {
38     }
39
40     public WSProjectInfo(int visualMinorVersion, int visualMajorVersion, int projectMajorRevision,
41             int projectMinorRevision, WSDate lastmodified, String projectNumber, String customerName,
42             String installerName) {
43         this.visualMinorVersion = visualMinorVersion;
44         this.visualMajorVersion = visualMajorVersion;
45         this.projectMajorRevision = projectMajorRevision;
46         this.projectMinorRevision = projectMinorRevision;
47         this.lastmodified = lastmodified;
48         this.projectNumber = projectNumber;
49         this.customerName = customerName;
50         this.installerName = installerName;
51     }
52
53     /**
54      * Gets the visualMinorVersion value for this WSProjectInfo.
55      *
56      * @return visualMinorVersion
57      */
58     public int getVisualMinorVersion() {
59         return visualMinorVersion;
60     }
61
62     /**
63      * Sets the visualMinorVersion value for this WSProjectInfo.
64      *
65      * @param visualMinorVersion
66      */
67     public void setVisualMinorVersion(int visualMinorVersion) {
68         this.visualMinorVersion = visualMinorVersion;
69     }
70
71     /**
72      * Gets the visualMajorVersion value for this WSProjectInfo.
73      *
74      * @return visualMajorVersion
75      */
76     public int getVisualMajorVersion() {
77         return visualMajorVersion;
78     }
79
80     /**
81      * Sets the visualMajorVersion value for this WSProjectInfo.
82      *
83      * @param visualMajorVersion
84      */
85     public void setVisualMajorVersion(int visualMajorVersion) {
86         this.visualMajorVersion = visualMajorVersion;
87     }
88
89     /**
90      * Gets the projectMajorRevision value for this WSProjectInfo.
91      *
92      * @return projectMajorRevision
93      */
94     public int getProjectMajorRevision() {
95         return projectMajorRevision;
96     }
97
98     /**
99      * Sets the projectMajorRevision value for this WSProjectInfo.
100      *
101      * @param projectMajorRevision
102      */
103     public void setProjectMajorRevision(int projectMajorRevision) {
104         this.projectMajorRevision = projectMajorRevision;
105     }
106
107     /**
108      * Gets the projectMinorRevision value for this WSProjectInfo.
109      *
110      * @return projectMinorRevision
111      */
112     public int getProjectMinorRevision() {
113         return projectMinorRevision;
114     }
115
116     /**
117      * Sets the projectMinorRevision value for this WSProjectInfo.
118      *
119      * @param projectMinorRevision
120      */
121     public void setProjectMinorRevision(int projectMinorRevision) {
122         this.projectMinorRevision = projectMinorRevision;
123     }
124
125     /**
126      * Gets the lastmodified value for this WSProjectInfo.
127      *
128      * @return lastmodified
129      */
130     public WSDate getLastmodified() {
131         return lastmodified;
132     }
133
134     /**
135      * Sets the lastmodified value for this WSProjectInfo.
136      *
137      * @param lastmodified
138      */
139     public void setLastmodified(WSDate lastmodified) {
140         this.lastmodified = lastmodified;
141     }
142
143     /**
144      * Gets the projectNumber value for this WSProjectInfo.
145      *
146      * @return projectNumber
147      */
148     public java.lang.String getProjectNumber() {
149         return projectNumber;
150     }
151
152     /**
153      * Sets the projectNumber value for this WSProjectInfo.
154      *
155      * @param projectNumber
156      */
157     public void setProjectNumber(String projectNumber) {
158         this.projectNumber = projectNumber;
159     }
160
161     /**
162      * Gets the customerName value for this WSProjectInfo.
163      *
164      * @return customerName
165      */
166     public java.lang.String getCustomerName() {
167         return customerName;
168     }
169
170     /**
171      * Sets the customerName value for this WSProjectInfo.
172      *
173      * @param customerName
174      */
175     public void setCustomerName(String customerName) {
176         this.customerName = customerName;
177     }
178
179     /**
180      * Gets the installerName value for this WSProjectInfo.
181      *
182      * @return installerName
183      */
184     public java.lang.String getInstallerName() {
185         return installerName;
186     }
187
188     /**
189      * Sets the installerName value for this WSProjectInfo.
190      *
191      * @param installerName
192      */
193     public void setInstallerName(String installerName) {
194         this.installerName = installerName;
195     }
196
197     public WSProjectInfo parseXMLData(String data) throws IhcExecption {
198         try {
199             String value = XPathUtils.parseXMLValue(data,
200                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:visualMinorVersion");
201             setVisualMinorVersion(Integer.parseInt(value));
202
203             value = XPathUtils.parseXMLValue(data,
204                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:visualMajorVersion");
205             setVisualMajorVersion(Integer.parseInt(value));
206
207             value = XPathUtils.parseXMLValue(data,
208                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:projectMajorRevision");
209             setProjectMajorRevision(Integer.parseInt(value));
210
211             value = XPathUtils.parseXMLValue(data,
212                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:projectMinorRevision");
213             setProjectMinorRevision(Integer.parseInt(value));
214
215             WSDate lastmodified = new WSDate();
216
217             value = XPathUtils.parseXMLValue(data,
218                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:day");
219             lastmodified.setDay(Integer.parseInt(value));
220
221             value = XPathUtils.parseXMLValue(data,
222                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:monthWithJanuaryAsOne");
223             lastmodified.setMonthWithJanuaryAsOne(Integer.parseInt(value));
224
225             value = XPathUtils.parseXMLValue(data,
226                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:hours");
227             lastmodified.setHours(Integer.parseInt(value));
228
229             value = XPathUtils.parseXMLValue(data,
230                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:minutes");
231             lastmodified.setMinutes(Integer.parseInt(value));
232
233             value = XPathUtils.parseXMLValue(data,
234                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:seconds");
235             lastmodified.setSeconds(Integer.parseInt(value));
236
237             value = XPathUtils.parseXMLValue(data,
238                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:year");
239             lastmodified.setYear(Integer.parseInt(value));
240
241             setLastmodified(lastmodified);
242
243             value = XPathUtils.parseXMLValue(data,
244                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:projectNumber");
245             setProjectNumber(value);
246
247             value = XPathUtils.parseXMLValue(data,
248                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:customerName");
249             setCustomerName(value);
250
251             value = XPathUtils.parseXMLValue(data,
252                     "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:installerName");
253             setInstallerName(value);
254
255             return this;
256         } catch (IOException | XPathExpressionException | NumberFormatException e) {
257             throw new IhcExecption("Error occured during XML data parsing", e);
258         }
259     }
260
261     @Override
262     public String toString() {
263         return String.format(
264                 "[ visualMinorVersion=%d, visualMajorVersion=%d, projectMajorRevision=%d, projectMinorRevision=%d, lastmodified=%s, projectNumber=%s, customerName=%s, installerName=%s ]",
265                 visualMinorVersion, visualMajorVersion, projectMajorRevision, projectMinorRevision,
266                 lastmodified.getAsLocalDateTime(), projectNumber, customerName, installerName);
267     }
268 }