Update individual measurements schema.

Added special units attribute.
This commit is contained in:
Roman Telezhynskyi 2020-10-03 17:21:17 +03:00
parent 16ce597a37
commit a8ddcc56cc
4 changed files with 96 additions and 5 deletions

View File

@ -73,6 +73,7 @@
<file>schema/individual_measurements/v0.3.3.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.4.0.xsd</file>
<file>schema/individual_measurements/v0.5.0.xsd</file> <file>schema/individual_measurements/v0.5.0.xsd</file>
<file>schema/individual_measurements/v0.5.1.xsd</file>
<file>schema/label_template/v1.0.0.xsd</file> <file>schema/label_template/v1.0.0.xsd</file>
<file>schema/watermark/v1.0.0.xsd</file> <file>schema/watermark/v1.0.0.xsd</file>
</qresource> </qresource>

View File

@ -0,0 +1,73 @@
<?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:attribute name="specialUnits" type="xs:boolean"/>
</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}*/&amp;|!&lt;&gt;^&#10;\()\-+.,٫, ٬.=?:;'\&quot;]){1,1}([^\p{Zs}*/&amp;|!&lt;&gt;^&#10;\()\-+.,٫, ٬.=?:;\&quot;]){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>

View File

@ -54,8 +54,8 @@
*/ */
const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0"); const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0");
const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.0"); const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.1");
const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.0.xsd"); const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.1.xsd");
//VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VVITConverter::MeasurementMinVer; // <== DON'T FORGET TO UPDATE TOO!!!!
//VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!! //VVITConverter::MeasurementMaxVer; // <== DON'T FORGET TO UPDATE TOO!!!!
@ -89,7 +89,8 @@ QString VVITConverter::XSDSchema(int ver) const
std::make_pair(FORMAT_VERSION(0, 3, 2), QStringLiteral("://schema/individual_measurements/v0.3.2.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, 3, 3), QStringLiteral("://schema/individual_measurements/v0.3.3.xsd")),
std::make_pair(FORMAT_VERSION(0, 4, 0), QStringLiteral("://schema/individual_measurements/v0.4.0.xsd")), 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), std::make_pair(FORMAT_VERSION(0, 5, 0), QStringLiteral("://schema/individual_measurements/v0.5.0.xsd")),
std::make_pair(FORMAT_VERSION(0, 5, 1), CurrentSchema),
}; };
if (schemas.contains(ver)) if (schemas.contains(ver))
@ -132,6 +133,10 @@ void VVITConverter::ApplyPatches()
ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0))); ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0)));
Q_FALLTHROUGH(); Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 5, 0)): case (FORMAT_VERSION(0, 5, 0)):
ToV0_5_1();
ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 1)));
Q_FALLTHROUGH();
case (FORMAT_VERSION(0, 5, 1)):
break; break;
default: default:
InvalidVersion(m_ver); InvalidVersion(m_ver);
@ -150,7 +155,7 @@ void VVITConverter::DowngradeToCurrentMaxVersion()
bool VVITConverter::IsReadOnly() const bool VVITConverter::IsReadOnly() const
{ {
// Check if attribute read-only was not changed in file format // Check if attribute read-only was not changed in file format
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FORMAT_VERSION(0, 5, 0), Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FORMAT_VERSION(0, 5, 1),
"Check attribute read-only."); "Check attribute read-only.");
// Possibly in future attribute read-only will change position etc. // Possibly in future attribute read-only will change position etc.
@ -428,3 +433,14 @@ void VVITConverter::ToV0_5_0()
SetVersion(QStringLiteral("0.5.0")); SetVersion(QStringLiteral("0.5.0"));
Save(); Save();
} }
//---------------------------------------------------------------------------------------------------------------------
void VVITConverter::ToV0_5_1()
{
// TODO. Delete if minimal supported version is 0.5.1
Q_STATIC_ASSERT_X(VVITConverter::MeasurementMinVer < FORMAT_VERSION(0, 5, 1),
"Time to refactor the code.");
SetVersion(QStringLiteral("0.5.1"));
Save();
}

View File

@ -49,7 +49,7 @@ public:
static const QString MeasurementMaxVerStr; static const QString MeasurementMaxVerStr;
static const QString CurrentSchema; static const QString CurrentSchema;
static Q_DECL_CONSTEXPR const int MeasurementMinVer = FORMAT_VERSION(0, 2, 0); static Q_DECL_CONSTEXPR const int MeasurementMinVer = FORMAT_VERSION(0, 2, 0);
static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FORMAT_VERSION(0, 5, 0); static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FORMAT_VERSION(0, 5, 1);
protected: protected:
virtual int MinVer() const override; virtual int MinVer() const override;
@ -82,6 +82,7 @@ private:
void ToV0_3_3(); void ToV0_3_3();
void ToV0_4_0(); void ToV0_4_0();
void ToV0_5_0(); void ToV0_5_0();
void ToV0_5_1();
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------