From a8ddcc56cc9540a43e62a44223b8c4f298aa67d3 Mon Sep 17 00:00:00 2001 From: Roman Telezhynskyi Date: Sat, 3 Oct 2020 17:21:17 +0300 Subject: [PATCH] Update individual measurements schema. Added special units attribute. --- src/libs/ifc/schema.qrc | 1 + .../schema/individual_measurements/v0.5.1.xsd | 73 +++++++++++++++++++ src/libs/ifc/xml/vvitconverter.cpp | 24 +++++- src/libs/ifc/xml/vvitconverter.h | 3 +- 4 files changed, 96 insertions(+), 5 deletions(-) create mode 100644 src/libs/ifc/schema/individual_measurements/v0.5.1.xsd diff --git a/src/libs/ifc/schema.qrc b/src/libs/ifc/schema.qrc index c98ebbe84..a906c1e05 100644 --- a/src/libs/ifc/schema.qrc +++ b/src/libs/ifc/schema.qrc @@ -73,6 +73,7 @@ schema/individual_measurements/v0.3.3.xsd schema/individual_measurements/v0.4.0.xsd schema/individual_measurements/v0.5.0.xsd + schema/individual_measurements/v0.5.1.xsd schema/label_template/v1.0.0.xsd schema/watermark/v1.0.0.xsd diff --git a/src/libs/ifc/schema/individual_measurements/v0.5.1.xsd b/src/libs/ifc/schema/individual_measurements/v0.5.1.xsd new file mode 100644 index 000000000..80d99fcc9 --- /dev/null +++ b/src/libs/ifc/schema/individual_measurements/v0.5.1.xsd @@ -0,0 +1,73 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/libs/ifc/xml/vvitconverter.cpp b/src/libs/ifc/xml/vvitconverter.cpp index a9e9c2bdd..c4da6193a 100644 --- a/src/libs/ifc/xml/vvitconverter.cpp +++ b/src/libs/ifc/xml/vvitconverter.cpp @@ -54,8 +54,8 @@ */ const QString VVITConverter::MeasurementMinVerStr = QStringLiteral("0.2.0"); -const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.0"); -const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.0.xsd"); +const QString VVITConverter::MeasurementMaxVerStr = QStringLiteral("0.5.1"); +const QString VVITConverter::CurrentSchema = QStringLiteral("://schema/individual_measurements/v0.5.1.xsd"); //VVITConverter::MeasurementMinVer; // <== 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, 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, 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)) @@ -132,6 +133,10 @@ void VVITConverter::ApplyPatches() ValidateXML(XSDSchema(FORMAT_VERSION(0, 5, 0))); Q_FALLTHROUGH(); 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; default: InvalidVersion(m_ver); @@ -150,7 +155,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, 5, 0), + Q_STATIC_ASSERT_X(VVITConverter::MeasurementMaxVer == FORMAT_VERSION(0, 5, 1), "Check attribute read-only."); // Possibly in future attribute read-only will change position etc. @@ -428,3 +433,14 @@ void VVITConverter::ToV0_5_0() SetVersion(QStringLiteral("0.5.0")); 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(); +} diff --git a/src/libs/ifc/xml/vvitconverter.h b/src/libs/ifc/xml/vvitconverter.h index fa7a8bba0..aa7360f71 100644 --- a/src/libs/ifc/xml/vvitconverter.h +++ b/src/libs/ifc/xml/vvitconverter.h @@ -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, 5, 0); + static Q_DECL_CONSTEXPR const int MeasurementMaxVer = FORMAT_VERSION(0, 5, 1); protected: virtual int MinVer() const override; @@ -82,6 +82,7 @@ private: void ToV0_3_3(); void ToV0_4_0(); void ToV0_5_0(); + void ToV0_5_1(); }; //---------------------------------------------------------------------------------------------------------------------