Add support for new individual measurements format version.
--HG-- branch : develop
This commit is contained in:
parent
ca90ceaada
commit
c8b43c56d2
|
@ -60,6 +60,7 @@
|
|||
<file>schema/individual_measurements/v0.3.2.xsd</file>
|
||||
<file>schema/individual_measurements/v0.3.3.xsd</file>
|
||||
<file>schema/individual_measurements/v0.4.0.xsd</file>
|
||||
<file>schema/individual_measurements/v0.5.0.xsd</file>
|
||||
<file>schema/label_template/v1.0.0.xsd</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
|
72
src/libs/ifc/schema/individual_measurements/v0.5.0.xsd
Normal file
72
src/libs/ifc/schema/individual_measurements/v0.5.0.xsd
Normal file
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
|
||||
<xs:element name="vit">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="version" type="formatVersion"/>
|
||||
<xs:element name="read-only" type="xs:boolean"/>
|
||||
<xs:element name="notes" type="xs:string" minOccurs="0" maxOccurs="1"/>
|
||||
<xs:element name="unit" type="units"/>
|
||||
<xs:element name="pm_system" type="psCode"/>
|
||||
<xs:element name="personal">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="customer" type="xs:string"/>
|
||||
<xs:element name="birth-date" type="xs:date"/>
|
||||
<xs:element name="gender" type="gender"/>
|
||||
<xs:element name="email" type="xs:string"/>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
<xs:element name="body-measurements">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="m" minOccurs="0" maxOccurs="unbounded">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="name" type="shortName" use="required"/>
|
||||
<xs:attribute name="value" type="xs:string" use="required"/>
|
||||
<xs:attribute name="full_name" type="xs:string"/>
|
||||
<xs:attribute name="description" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="template" type="xs:string"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:sequence>
|
||||
</xs:complexType>
|
||||
<xs:unique name="measurementName">
|
||||
<xs:selector xpath="body-measurements/m"/>
|
||||
<xs:field xpath="@name"/>
|
||||
</xs:unique>
|
||||
</xs:element>
|
||||
<xs:simpleType name="shortName">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="([^\p{Nd}\p{Zs}*/&|!<>^\-()–+−=?:;'\\"]){1,1}([^\p{Zs}*/&|!<>^\-()–+−=?:;\\"]){0,}"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="formatVersion">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="[0-9]{1,}\.[0-9]{1,}\.[0-9]{1,}"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="units">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="mm"/>
|
||||
<xs:enumeration value="cm"/>
|
||||
<xs:enumeration value="inch"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="gender">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:enumeration value="unknown"/>
|
||||
<xs:enumeration value="male"/>
|
||||
<xs:enumeration value="female"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
<xs:simpleType name="psCode">
|
||||
<xs:restriction base="xs:string">
|
||||
<xs:pattern value="(([0-9]|[1-4][0-9]|5[0-4])|998)"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:schema>
|
|
@ -54,8 +54,8 @@
|
|||
*/
|
||||
|
||||
const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0");
|
||||
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.4.0");
|
||||
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.4.0.xsd");
|
||||
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.0");
|
||||
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.0.xsd");
|
||||
|
||||
//VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
//VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
|
||||
|
@ -88,7 +88,8 @@ QString VVITConverter::XSDSchema(int ver) const
|
|||
std::make_pair(FORMAT_VERSION(0, 3, 1), QStringLiteral("://schema/individual_measurements/v0.3.1.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 3, 2), QStringLiteral("://schema/individual_measurements/v0.3.2.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 3, 3), QStringLiteral("://schema/individual_measurements/v0.3.3.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 4, 0), CurrentSchema),
|
||||
std::make_pair(FORMAT_VERSION(0, 4, 0), QStringLiteral("://schema/individual_measurements/v0.4.0.xsd")),
|
||||
std::make_pair(FORMAT_VERSION(0, 5, 0), CurrentSchema),
|
||||
};
|
||||
|
||||
if (schemas.contains(ver))
|
||||
|
@ -127,6 +128,10 @@ void VVITConverter::ApplyPatches()
|
|||
ValidateXML(XSDSchema(FORMAT_VERSION(0, 4, 0)), m_convertedFileName);
|
||||
V_FALLTHROUGH
|
||||
case (FORMAT_VERSION(0, 4, 0)):
|
||||
ToV0_5_0();
|
||||
ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0)), m_convertedFileName);
|
||||
V_FALLTHROUGH
|
||||
case (FORMAT_VERSION(0, 5, 0)):
|
||||
break;
|
||||
default:
|
||||
InvalidVersion(m_ver);
|
||||
|
@ -145,7 +150,7 @@ void VVITConverter::DowngradeToCurrentMaxVersion()
|
|||
bool VVITConverter::IsReadOnly() const
|
||||
{
|
||||
// Check if attribute read-only was not changed in file format
|
||||
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FORMAT_VERSION(0, 4, 0),
|
||||
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FORMAT_VERSION(0, 5, 0),
|
||||
"Check attribute read-only.");
|
||||
|
||||
// Possibly in future attribute read-only will change position etc.
|
||||
|
@ -430,3 +435,14 @@ void VVITConverter::ToV0_4_0()
|
|||
ConverCustomerNameToV0_4_0();
|
||||
Save();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
void VVITConverter::ToV0_5_0()
|
||||
{
|
||||
// TODO. Delete if minimal supported version is 0.5.0
|
||||
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 5, 0),
|
||||
"Time to refactor the code.");
|
||||
|
||||
SetVersion(QStringLiteral("0.5.0"));
|
||||
Save();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public:
|
|||
static const QString MeasurementMaxVerStr;
|
||||
static const QString CurrentSchema;
|
||||
static Q_DECL_CONSTEXPR const int MeasurementMinVer = FORMAT_VERSION(0, 2, 0);
|
||||
static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FORMAT_VERSION(0, 4, 0);
|
||||
static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FORMAT_VERSION(0, 5, 0);
|
||||
|
||||
protected:
|
||||
virtual int MinVer() const override;
|
||||
|
@ -81,6 +81,7 @@ private:
|
|||
void ToV0_3_2();
|
||||
void ToV0_3_3();
|
||||
void ToV0_4_0();
|
||||
void ToV0_5_0();
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
|
Loading…
Reference in New Issue
Block a user