Skip to content

Commit a771b42

Browse files
author
Indenbirken, Marcel IT/HZA-TT
committed
new schema formats due to changes on rexs.info
1 parent 7175bf2 commit a771b42

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+153145
-34885
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111

1212
- Spelling error in CMakeLists.txt corrected.
1313

14+
### Changed
15+
16+
- Changed to new schema format on REXS hp
17+
1418
## [2.1.0]
1519

1620
### Fixed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
cmake_minimum_required(VERSION 3.22)
2-
project(rexsapi VERSION 2.1.0 LANGUAGES CXX)
2+
project(rexsapi VERSION 2.2.0 LANGUAGES CXX)
33

44
include(FetchContent)
55

include/rexsapi/ModelLoader.hxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ namespace rexsapi
3030
* @brief Creates a model registry containing all models found in the given filesystem path.
3131
*
3232
* The filesystem path should contain REXS database model files for different versions and languages. Additionally,
33-
* the XML database model schema file (*rexs-dbmodel.xsd*) has to be available in the path.
33+
* the XML database model schema file (*rexs-schema.xsd*) has to be available in the path.
3434
*
3535
* @param path The filesystem path to load REXS database model files from.
3636
* @return database::TModelRegistry containing all available REXS database models
@@ -59,9 +59,9 @@ namespace rexsapi
5959
*
6060
* @param databasePath filesystem path containing REXS database model files for different versions and languages and
6161
* all relevant schema files. The necessary schema files are:
62-
* - rexs-dbmodel.xsd
6362
* - rexs-schema.xsd
64-
* - rexs-schema.json
63+
* - rexs-file.xsd
64+
* - rexs-file.json
6565
* @param dataSourceResolver Will be used to load external model data sources if set. Triggers an error if not set
6666
* and model has external references.
6767
* @throws TException if the model registry or the schema validators cannot be created
@@ -80,9 +80,9 @@ namespace rexsapi
8080
*
8181
* @param databasePath filesystem path containing REXS database model files for different versions and languages and
8282
* all relevant schema files. The necessary schema files are:
83-
* - rexs-dbmodel.xsd
8483
* - rexs-schema.xsd
85-
* - rexs-schema.json
84+
* - rexs-file.xsd
85+
* - rexs-file.json
8686
* @param customExtensionMappings Additional custom extension mappings to respect for REXS model file type detection
8787
* @param dataSourceResolver Will be used to load external model data sources if set. Triggers an error if not set
8888
* and model has external references.
@@ -199,7 +199,7 @@ namespace rexsapi
199199

200200
static inline database::TModelRegistry createModelRegistry(const std::filesystem::path& path)
201201
{
202-
TFileXsdSchemaLoader schemaLoader{path / "rexs-dbmodel.xsd"};
202+
TFileXsdSchemaLoader schemaLoader{path / "rexs-schema.xsd"};
203203
database::TFileResourceLoader resourceLoader{path};
204204
database::TXmlModelLoader modelLoader{resourceLoader, schemaLoader};
205205
return database::TModelRegistry::createModelRegistry(modelLoader).first;
@@ -257,13 +257,13 @@ namespace rexsapi
257257

258258
inline TXSDSchemaValidator TModelLoader::createXMLSchemaValidator(const std::filesystem::path& path)
259259
{
260-
TFileXsdSchemaLoader schemaLoader{path / "rexs-schema.xsd"};
260+
TFileXsdSchemaLoader schemaLoader{path / "rexs-file.xsd"};
261261
return TXSDSchemaValidator{schemaLoader};
262262
}
263263

264264
inline TJsonSchemaValidator TModelLoader::createJsonSchemaValidator(const std::filesystem::path& path)
265265
{
266-
TFileJsonSchemaLoader schemaLoader{path / "rexs-schema.json"};
266+
TFileJsonSchemaLoader schemaLoader{path / "rexs-file.json"};
267267
return TJsonSchemaValidator{schemaLoader};
268268
}
269269

include/rexsapi/XSDSchemaValidator.hxx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -865,10 +865,10 @@ namespace rexsapi
865865
auto type1 = std::make_unique<detail::TPodType<detail::TStringType>>(fmt::format("{}:string", detail::xsdSchemaNS));
866866
m_Types.try_emplace(type1->getName(), std::move(type1));
867867
auto type2 =
868-
std::make_unique<detail::TPodType<detail::TIntegerType>>(fmt::format("{}:integer", detail::xsdSchemaNS));
868+
std::make_unique<detail::TPodType<detail::TIntegerType>>(fmt::format("{}:int", detail::xsdSchemaNS));
869869
m_Types.try_emplace(type2->getName(), std::move(type2));
870870
auto type3 =
871-
std::make_unique<detail::TPodType<detail::TDecimalType>>(fmt::format("{}:decimal", detail::xsdSchemaNS));
871+
std::make_unique<detail::TPodType<detail::TDecimalType>>(fmt::format("{}:double", detail::xsdSchemaNS));
872872
m_Types.try_emplace(type3->getName(), std::move(type3));
873873
auto type4 =
874874
std::make_unique<detail::TPodType<detail::TBooleanType>>(fmt::format("{}:boolean", detail::xsdSchemaNS));
@@ -926,9 +926,10 @@ namespace rexsapi
926926

927927
for (const auto& element :
928928
node.select_nodes(fmt::format("{0}:complexType/{0}:sequence/{0}:element", detail::xsdSchemaNS).c_str())) {
929-
auto min = convertToUint64(element.node().attribute("minOccurs").as_string());
929+
auto minString = std::string(element.node().attribute("minOccurs").as_string());
930+
auto min = (minString=="") ? 1 : convertToUint64(minString);
930931
auto maxString = std::string(element.node().attribute("maxOccurs").as_string());
931-
auto max = maxString == "unbounded" ? std::numeric_limits<uint64_t>::max() : convertToUint64(maxString);
932+
auto max = (maxString=="") ? 1 : (maxString == "unbounded" ? std::numeric_limits<uint64_t>::max() : convertToUint64(maxString));
932933

933934
if (const auto refName = element.node().attribute("ref"); !refName.empty()) {
934935
const detail::TElement& ref = findOrRegisterElement(refName.as_string());

include/rexsapi/database/XMLModelLoader.hxx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,25 +91,25 @@ namespace rexsapi::database
9191
return;
9292
}
9393

94-
const auto rexsModel = *doc.select_nodes("/rexsModel").begin();
94+
const auto rexsModel = *doc.select_nodes("/rexsSchema").begin();
9595
TModel model{TRexsVersion{rexsapi::detail::getStringAttribute(rexsModel, "version")},
9696
rexsapi::detail::getStringAttribute(rexsModel, "language"),
9797
rexsapi::detail::getStringAttribute(rexsModel, "date"),
9898
statusFromString(rexsapi::detail::getStringAttribute(rexsModel, "status"))};
9999

100-
for (const auto& node : doc.select_nodes("/rexsModel/units/unit")) {
100+
for (const auto& node : doc.select_nodes("/rexsSchema/units/unit")) {
101101
auto id = convertToUint64(rexsapi::detail::getStringAttribute(node, "id"));
102102
auto name = rexsapi::detail::getStringAttribute(node, "name");
103103
model.addUnit(TUnit{id, name});
104104
}
105105

106-
for (const auto& node : doc.select_nodes("/rexsModel/valueTypes/valueType")) {
106+
for (const auto& node : doc.select_nodes("/rexsSchema/valueTypes/valueType")) {
107107
auto id = convertToUint64(rexsapi::detail::getStringAttribute(node, "id"));
108108
auto name = rexsapi::detail::getStringAttribute(node, "name");
109109
model.addType(id, typeFromString(name));
110110
}
111111

112-
for (const auto& node : doc.select_nodes("/rexsModel/attributes/attribute")) {
112+
for (const auto& node : doc.select_nodes("/rexsSchema/attributes/attribute")) {
113113
auto attributeId = rexsapi::detail::getStringAttribute(node, "attributeId");
114114
auto name = rexsapi::detail::getStringAttribute(node, "name");
115115
auto valueType =
@@ -137,14 +137,14 @@ namespace rexsapi::database
137137
}
138138

139139
std::vector<std::pair<std::string, std::string>> attributeMappings;
140-
for (const auto& node : doc.select_nodes("/rexsModel/componentAttributeMappings/componentAttributeMapping")) {
140+
for (const auto& node : doc.select_nodes("/rexsSchema/componentAttributeMappings/componentAttributeMapping")) {
141141
auto componentId = rexsapi::detail::getStringAttribute(node, "componentId");
142142
auto attributeId = rexsapi::detail::getStringAttribute(node, "attributeId");
143143
attributeMappings.emplace_back(componentId, attributeId);
144144
}
145145
rexsapi::database::detail::TComponentAttributeMapper attributeMapper{model, std::move(attributeMappings)};
146146

147-
for (const auto& node : doc.select_nodes("/rexsModel/components/component")) {
147+
for (const auto& node : doc.select_nodes("/rexsSchema/components/component")) {
148148
auto id = rexsapi::detail::getStringAttribute(node, "componentId");
149149
auto name = rexsapi::detail::getStringAttribute(node, "name");
150150
auto attributes = attributeMapper.getAttributesForComponent(id);

models/rexs-dbmodel.xsd

Lines changed: 0 additions & 156 deletions
This file was deleted.

0 commit comments

Comments
 (0)