Added regatta schema.

RaceServer now creates an XMLMessage when the race's RegattaDataSource changes.
#story[1188]
main
fjc40 8 years ago
parent ec58f0c847
commit 298fcd03dc

@ -112,7 +112,20 @@ public class RaceServer {
* Checks if the regatta data source has changed, and if it has, updates LatestMessages' regatta xml message.
*/
private void updateRegattaXMLFile() {
if (regattaXMLSeqNumber != race.getRegattaDataSource().getSequenceNumber()) {
regattaXMLSeqNumber = race.getRegattaDataSource().getSequenceNumber();
try {
String regattaXMLString = RegattaDataSourceToXML.toString(race.getRegattaDataSource());
XMLMessage message = createXMLMessage(regattaXMLString, XMLMessageType.REGATTA);
latestMessages.setXMLMessage(message);
} catch (JAXBException e) {
Logger.getGlobal().log(Level.WARNING, "Could not serialise: " + race.getRegattaDataSource(), e);
}
}
}
/**

@ -0,0 +1,47 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2017.09.01 at 10:37:23 PM NZST
//
package shared.xml.regatta;
import javax.xml.bind.annotation.XmlRegistry;
/**
* This object contains factory methods for each
* Java content interface and Java element interface
* generated in the aaa package.
* <p>An ObjectFactory allows you to programatically
* construct new instances of the Java representation
* for XML content. The Java representation of XML
* content can consist of schema derived interfaces
* and classes representing the binding of schema
* type definitions, element declarations and model
* groups. Factory methods for each of these are
* provided in this class.
*
*/
@XmlRegistry
public class ObjectFactory {
/**
* Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: aaa
*
*/
public ObjectFactory() {
}
/**
* Create an instance of {@link RegattaConfig }
*
*/
public RegattaConfig createRegattaConfig() {
return new RegattaConfig();
}
}

@ -0,0 +1,219 @@
//
// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.8-b130911.1802
// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
// Any modifications to this file will be lost upon recompilation of the source schema.
// Generated on: 2017.09.01 at 10:37:23 PM NZST
//
package shared.xml.regatta;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for anonymous complex type.
*
* <p>The following schema fragment specifies the expected content contained within this class.
*
* <pre>
* &lt;complexType>
* &lt;complexContent>
* &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
* &lt;sequence>
* &lt;element name="RegattaID" type="{http://www.w3.org/2001/XMLSchema}int"/>
* &lt;element name="RegattaName" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="CourseName" type="{http://www.w3.org/2001/XMLSchema}string"/>
* &lt;element name="CentralLatitude" type="{http://www.w3.org/2001/XMLSchema}double"/>
* &lt;element name="CentralLongitude" type="{http://www.w3.org/2001/XMLSchema}double"/>
* &lt;element name="CentralAltitude" type="{http://www.w3.org/2001/XMLSchema}double"/>
* &lt;element name="UtcOffset" type="{http://www.w3.org/2001/XMLSchema}double"/>
* &lt;element name="MagneticVariation" type="{http://www.w3.org/2001/XMLSchema}double"/>
* &lt;/sequence>
* &lt;/restriction>
* &lt;/complexContent>
* &lt;/complexType>
* </pre>
*
*
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"regattaID",
"regattaName",
"courseName",
"centralLatitude",
"centralLongitude",
"centralAltitude",
"utcOffset",
"magneticVariation"
})
@XmlRootElement(name = "RegattaConfig")
public class RegattaConfig {
@XmlElement(name = "RegattaID")
protected int regattaID;
@XmlElement(name = "RegattaName", required = true)
protected String regattaName;
@XmlElement(name = "CourseName", required = true)
protected String courseName;
@XmlElement(name = "CentralLatitude")
protected double centralLatitude;
@XmlElement(name = "CentralLongitude")
protected double centralLongitude;
@XmlElement(name = "CentralAltitude")
protected double centralAltitude;
@XmlElement(name = "UtcOffset")
protected double utcOffset;
@XmlElement(name = "MagneticVariation")
protected double magneticVariation;
/**
* Gets the value of the regattaID property.
*
*/
public int getRegattaID() {
return regattaID;
}
/**
* Sets the value of the regattaID property.
*
*/
public void setRegattaID(int value) {
this.regattaID = value;
}
/**
* Gets the value of the regattaName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getRegattaName() {
return regattaName;
}
/**
* Sets the value of the regattaName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setRegattaName(String value) {
this.regattaName = value;
}
/**
* Gets the value of the courseName property.
*
* @return
* possible object is
* {@link String }
*
*/
public String getCourseName() {
return courseName;
}
/**
* Sets the value of the courseName property.
*
* @param value
* allowed object is
* {@link String }
*
*/
public void setCourseName(String value) {
this.courseName = value;
}
/**
* Gets the value of the centralLatitude property.
*
*/
public double getCentralLatitude() {
return centralLatitude;
}
/**
* Sets the value of the centralLatitude property.
*
*/
public void setCentralLatitude(double value) {
this.centralLatitude = value;
}
/**
* Gets the value of the centralLongitude property.
*
*/
public double getCentralLongitude() {
return centralLongitude;
}
/**
* Sets the value of the centralLongitude property.
*
*/
public void setCentralLongitude(double value) {
this.centralLongitude = value;
}
/**
* Gets the value of the centralAltitude property.
*
*/
public double getCentralAltitude() {
return centralAltitude;
}
/**
* Sets the value of the centralAltitude property.
*
*/
public void setCentralAltitude(double value) {
this.centralAltitude = value;
}
/**
* Gets the value of the utcOffset property.
*
*/
public double getUtcOffset() {
return utcOffset;
}
/**
* Sets the value of the utcOffset property.
*
*/
public void setUtcOffset(double value) {
this.utcOffset = value;
}
/**
* Gets the value of the magneticVariation property.
*
*/
public double getMagneticVariation() {
return magneticVariation;
}
/**
* Sets the value of the magneticVariation property.
*
*/
public void setMagneticVariation(double value) {
this.magneticVariation = value;
}
}

@ -0,0 +1,54 @@
package shared.xml.regatta;
import shared.dataInput.RegattaDataSource;
import shared.xml.Race.XMLRace;
import shared.xml.XMLUtilities;
import javax.xml.bind.JAXBException;
/**
* Has functions to convert a {@link shared.dataInput.RegattaDataSource} to an {@link RegattaConfig} object.
*/
public class RegattaDataSourceToXML {
/**
* Converts a regatta data source to an XMLRace object.
* @param regattaDataSource The data source to convert.
* @return The XMLRace file.
*/
public static RegattaConfig toXML(RegattaDataSource regattaDataSource) {
RegattaConfig regatta = new RegattaConfig();
regatta.setCentralAltitude(regattaDataSource.getCentralAltitude());
regatta.setCentralLatitude(regattaDataSource.getCentralLatitude());
regatta.setCentralLongitude(regattaDataSource.getCentralLongitude());
regatta.setCourseName(regattaDataSource.getCourseName());
regatta.setRegattaName(regattaDataSource.getRegattaName());
regatta.setMagneticVariation(regattaDataSource.getMagneticVariation());
regatta.setRegattaID(regattaDataSource.getRegattaID());
regatta.setUtcOffset(regattaDataSource.getUtcOffset());
return regatta;
}
/**
* Converts a regatta data source to an xml string.
* @param regattaDataSource Data source to convert.
* @return String containing xml file.
* @throws JAXBException Thrown if it cannot be converted.
*/
public static String toString(RegattaDataSource regattaDataSource) throws JAXBException {
RegattaConfig regatta = toXML(regattaDataSource);
return XMLUtilities.classToXML(regatta);
}
}

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="RegattaConfig">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:int" name="RegattaID" minOccurs="1"/>
<xs:element type="xs:string" name="RegattaName" minOccurs="1"/>
<xs:element type="xs:string" name="CourseName" minOccurs="1"/>
<xs:element name="CentralLatitude" type="xs:double" minOccurs="1"/>
<xs:element name="CentralLongitude" type="xs:double" minOccurs="1"/>
<xs:element name="CentralAltitude" type="xs:double" minOccurs="1"/>
<xs:element type="xs:double" name="UtcOffset" minOccurs="1"/>
<xs:element name="MagneticVariation" type="xs:double" minOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Loading…
Cancel
Save