2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.ihc.internal.ws.datatypes;
15 import java.io.IOException;
17 import javax.xml.xpath.XPathExpressionException;
19 import org.openhab.binding.ihc.internal.ws.exeptions.IhcExecption;
22 * Class for WSProjectInfo complex type.
24 * @author Pauli Anttila - Initial contribution
26 public class WSProjectInfo {
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;
37 public WSProjectInfo() {
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;
54 * Gets the visualMinorVersion value for this WSProjectInfo.
56 * @return visualMinorVersion
58 public int getVisualMinorVersion() {
59 return visualMinorVersion;
63 * Sets the visualMinorVersion value for this WSProjectInfo.
65 * @param visualMinorVersion
67 public void setVisualMinorVersion(int visualMinorVersion) {
68 this.visualMinorVersion = visualMinorVersion;
72 * Gets the visualMajorVersion value for this WSProjectInfo.
74 * @return visualMajorVersion
76 public int getVisualMajorVersion() {
77 return visualMajorVersion;
81 * Sets the visualMajorVersion value for this WSProjectInfo.
83 * @param visualMajorVersion
85 public void setVisualMajorVersion(int visualMajorVersion) {
86 this.visualMajorVersion = visualMajorVersion;
90 * Gets the projectMajorRevision value for this WSProjectInfo.
92 * @return projectMajorRevision
94 public int getProjectMajorRevision() {
95 return projectMajorRevision;
99 * Sets the projectMajorRevision value for this WSProjectInfo.
101 * @param projectMajorRevision
103 public void setProjectMajorRevision(int projectMajorRevision) {
104 this.projectMajorRevision = projectMajorRevision;
108 * Gets the projectMinorRevision value for this WSProjectInfo.
110 * @return projectMinorRevision
112 public int getProjectMinorRevision() {
113 return projectMinorRevision;
117 * Sets the projectMinorRevision value for this WSProjectInfo.
119 * @param projectMinorRevision
121 public void setProjectMinorRevision(int projectMinorRevision) {
122 this.projectMinorRevision = projectMinorRevision;
126 * Gets the lastmodified value for this WSProjectInfo.
128 * @return lastmodified
130 public WSDate getLastmodified() {
135 * Sets the lastmodified value for this WSProjectInfo.
137 * @param lastmodified
139 public void setLastmodified(WSDate lastmodified) {
140 this.lastmodified = lastmodified;
144 * Gets the projectNumber value for this WSProjectInfo.
146 * @return projectNumber
148 public java.lang.String getProjectNumber() {
149 return projectNumber;
153 * Sets the projectNumber value for this WSProjectInfo.
155 * @param projectNumber
157 public void setProjectNumber(String projectNumber) {
158 this.projectNumber = projectNumber;
162 * Gets the customerName value for this WSProjectInfo.
164 * @return customerName
166 public java.lang.String getCustomerName() {
171 * Sets the customerName value for this WSProjectInfo.
173 * @param customerName
175 public void setCustomerName(String customerName) {
176 this.customerName = customerName;
180 * Gets the installerName value for this WSProjectInfo.
182 * @return installerName
184 public java.lang.String getInstallerName() {
185 return installerName;
189 * Sets the installerName value for this WSProjectInfo.
191 * @param installerName
193 public void setInstallerName(String installerName) {
194 this.installerName = installerName;
197 public WSProjectInfo parseXMLData(String data) throws IhcExecption {
199 String value = XPathUtils.parseXMLValue(data,
200 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:visualMinorVersion");
201 setVisualMinorVersion(Integer.parseInt(value));
203 value = XPathUtils.parseXMLValue(data,
204 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:visualMajorVersion");
205 setVisualMajorVersion(Integer.parseInt(value));
207 value = XPathUtils.parseXMLValue(data,
208 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:projectMajorRevision");
209 setProjectMajorRevision(Integer.parseInt(value));
211 value = XPathUtils.parseXMLValue(data,
212 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:projectMinorRevision");
213 setProjectMinorRevision(Integer.parseInt(value));
215 WSDate lastmodified = new WSDate();
217 value = XPathUtils.parseXMLValue(data,
218 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:day");
219 lastmodified.setDay(Integer.parseInt(value));
221 value = XPathUtils.parseXMLValue(data,
222 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:monthWithJanuaryAsOne");
223 lastmodified.setMonthWithJanuaryAsOne(Integer.parseInt(value));
225 value = XPathUtils.parseXMLValue(data,
226 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:hours");
227 lastmodified.setHours(Integer.parseInt(value));
229 value = XPathUtils.parseXMLValue(data,
230 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:minutes");
231 lastmodified.setMinutes(Integer.parseInt(value));
233 value = XPathUtils.parseXMLValue(data,
234 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:seconds");
235 lastmodified.setSeconds(Integer.parseInt(value));
237 value = XPathUtils.parseXMLValue(data,
238 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:lastmodified/ns1:year");
239 lastmodified.setYear(Integer.parseInt(value));
241 setLastmodified(lastmodified);
243 value = XPathUtils.parseXMLValue(data,
244 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:projectNumber");
245 setProjectNumber(value);
247 value = XPathUtils.parseXMLValue(data,
248 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:customerName");
249 setCustomerName(value);
251 value = XPathUtils.parseXMLValue(data,
252 "/SOAP-ENV:Envelope/SOAP-ENV:Body/ns1:getProjectInfo1/ns1:installerName");
253 setInstallerName(value);
256 } catch (IOException | XPathExpressionException | NumberFormatException e) {
257 throw new IhcExecption("Error occured during XML data parsing", e);
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);