diff --git a/src/AasCore.Aas3_0/AasCore.Aas3_0.csproj b/src/AasCore.Aas3_0/AasCore.Aas3_0.csproj index 9603e6eed..96a86a8a9 100644 --- a/src/AasCore.Aas3_0/AasCore.Aas3_0.csproj +++ b/src/AasCore.Aas3_0/AasCore.Aas3_0.csproj @@ -1,13 +1,13 @@ - + - net8.0 + net6.0 enable Debug;Release;DebugSlow AnyCPU 8 AasCore.Aas3_0 - 0.3.0.1-aasV3-alpha-latest + 1.0.0-rc1 Marko Ristin An SDK for manipulating, verifying and de/serializing Asset Administration Shells. @@ -18,8 +18,8 @@ https://raw.githubusercontent.com/aas-core-works/aas-core3.0-csharp/main/LICENSE https://github.com/aas-core-works/aas-core3.0-csharp aas;asset administration shell;iiot;industry internet of things;industrie 4.0;i4.0 - false + diff --git a/src/AasCore.Aas3_0/Attributes/CountForHash.cs b/src/AasCore.Aas3_0/Attributes/CountForHash.cs new file mode 100644 index 000000000..5e58d4681 --- /dev/null +++ b/src/AasCore.Aas3_0/Attributes/CountForHash.cs @@ -0,0 +1,25 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +using System; + +namespace AasCore.Aas3_0.Attributes +{ + /// + /// This attribute indicates, that it should e.g. serialized in JSON. + /// + [AttributeUsage(AttributeTargets.Field, AllowMultiple = true)] + public class CountForHash : Attribute + { + } +} diff --git a/src/AasCore.Aas3_0/Attributes/MetaModelName.cs b/src/AasCore.Aas3_0/Attributes/MetaModelName.cs new file mode 100644 index 000000000..58d37d311 --- /dev/null +++ b/src/AasCore.Aas3_0/Attributes/MetaModelName.cs @@ -0,0 +1,28 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +namespace AasCore.Aas3_0.Attributes +{ + /// + /// This attribute indicates, that the field / property is searchable + /// + [System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true)] + public class MetaModelName : System.Attribute + { + public string name; + public MetaModelName(string name) + { + this.name = name; + } + } +} diff --git a/src/AasCore.Aas3_0/Attributes/SkipForReflection.cs b/src/AasCore.Aas3_0/Attributes/SkipForReflection.cs new file mode 100644 index 000000000..50006dceb --- /dev/null +++ b/src/AasCore.Aas3_0/Attributes/SkipForReflection.cs @@ -0,0 +1,24 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +namespace AasCore.Aas3_0.Attributes +{ + /// + /// This attribute indicates, that the field / property shall be skipped for reflection + /// in order to avoid cycles + /// + [System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true)] + public class SkipForReflection : System.Attribute + { + } +} diff --git a/src/AasCore.Aas3_0/Attributes/SkipForSearch.cs b/src/AasCore.Aas3_0/Attributes/SkipForSearch.cs new file mode 100644 index 000000000..cbee18855 --- /dev/null +++ b/src/AasCore.Aas3_0/Attributes/SkipForSearch.cs @@ -0,0 +1,24 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +namespace AasCore.Aas3_0.Attributes +{ + /// + /// This attribute indicates, that the field / property shall be skipped for searching, because it is not + /// directly displayed in Package Explorer + /// + [System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true)] + public class SkipForSearch : System.Attribute + { + } +} diff --git a/src/AasCore.Aas3_0/Attributes/TextSearchable.cs b/src/AasCore.Aas3_0/Attributes/TextSearchable.cs new file mode 100644 index 000000000..022731d6c --- /dev/null +++ b/src/AasCore.Aas3_0/Attributes/TextSearchable.cs @@ -0,0 +1,23 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +namespace AasCore.Aas3_0.Attributes +{ + /// + /// This attribute indicates, that the field / property is searchable + /// + [System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true)] + public class TextSearchable : System.Attribute + { + } +} diff --git a/src/AasCore.Aas3_0/DiaryData/DiaryDataDef.cs b/src/AasCore.Aas3_0/DiaryData/DiaryDataDef.cs new file mode 100644 index 000000000..bd06bdbec --- /dev/null +++ b/src/AasCore.Aas3_0/DiaryData/DiaryDataDef.cs @@ -0,0 +1,71 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +using AasCore.Aas3_0; +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; +using System.Xml.Serialization; + +namespace AdminShellNS.DiaryData +{ + public class DiaryDataDef + { + public enum TimeStampKind { Create, Update } + + [XmlIgnore] + [JsonIgnore] + private DateTime[] _timeStamp = new DateTime[2]; + + [XmlIgnore] + [JsonIgnore] + public DateTime[] TimeStamp { get { return _timeStamp; } } + + /// + /// List of entries, timewise one after each other (entries are timestamped). + /// Note: Default is Entries = null, as handling of many many AAS elements does not + /// create additional overhead of creating empty lists. An empty list shall be avoided. + /// + public List Entries = null; + + public static void AddAndSetTimestamps(IReferable element, IAasDiaryEntry de, bool isCreate = false) + { + // trivial + if (element == null || de == null || element.DiaryData == null) + return; + + // add entry + if (element.DiaryData.Entries == null) + element.DiaryData.Entries = new List(); + element.DiaryData.Entries.Add(de); + + // figure out which timestamp + var tsk = TimeStampKind.Update; + if (isCreate) + { + tsk = TimeStampKind.Create; + } + + // set this timestamp (and for the parents, as well) + IDiaryData el = element; + while (el?.DiaryData != null) + { + // itself + el.DiaryData.TimeStamp[(int)tsk] = DateTime.UtcNow; + + // go up + el = (el as IReferable)?.Parent as IDiaryData; + } + } + } +} diff --git a/src/AasCore.Aas3_0/DiaryData/IAasDiaryEntry.cs b/src/AasCore.Aas3_0/DiaryData/IAasDiaryEntry.cs new file mode 100644 index 000000000..f4d8e7a9e --- /dev/null +++ b/src/AasCore.Aas3_0/DiaryData/IAasDiaryEntry.cs @@ -0,0 +1,19 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +namespace AdminShellNS.DiaryData +{ + public interface IAasDiaryEntry + { + } +} diff --git a/src/AasCore.Aas3_0/DiaryData/IDiaryData.cs b/src/AasCore.Aas3_0/DiaryData/IDiaryData.cs new file mode 100644 index 000000000..0c2e15942 --- /dev/null +++ b/src/AasCore.Aas3_0/DiaryData/IDiaryData.cs @@ -0,0 +1,26 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdminShellNS.DiaryData +{ + public interface IDiaryData + { + DiaryDataDef DiaryData { get; } + } +} diff --git a/src/AasCore.Aas3_0/LICENSE.txt b/src/AasCore.Aas3_0/LICENSE.txt new file mode 100644 index 000000000..01f9cb5eb --- /dev/null +++ b/src/AasCore.Aas3_0/LICENSE.txt @@ -0,0 +1,1475 @@ +Copyright (c) 2018-2023 Festo SE & Co. KG +, +author: Michael Hoffmeister + +Copyright (c) 2019-2021 PHOENIX CONTACT GmbH & Co. KG +, +author: Andreas Orzelski + +Copyright (c) 2019-2020 Fraunhofer IOSB-INA Lemgo, + eine rechtlich nicht selbstaendige Einrichtung der Fraunhofer-Gesellschaft + zur Foerderung der angewandten Forschung e.V. + +Copyright (c) 2020 Schneider Electric Automation GmbH +, +author: Marco Mendes + +Copyright (c) 2020 SICK AG + +Copyright (c) 2021 KEB Automation KG + +Copyright (c) 2021 Lenze SE +author: Jonas Grote, Denis Göllner, Sebastian Bischof + +The AASX Package Explorer is licensed under the Apache License 2.0 +(Apache-2.0, see below). + +The AASX Package Explorer is a sample application for demonstration of the +features of the Asset Administration Shell. +The implementation uses the concepts of the document "Details of the Asset +Administration Shell" published on www.plattform-i40.de which is licensed +under Creative Commons CC BY-ND 3.0 DE. + +When using eCl@ss or IEC CDD data, please check the corresponding license +conditions. + +------------------------------------------------------------------------------- + +The components below are used in AASX Package Explorer. +The related licenses are listed for information purposes only. +Some licenses may only apply to their related plugins. + +The browser functionality is licensed under the cefSharp license (see below). + +The Newtonsoft.JSON serialization is licensed under the MIT License +(MIT, see below). + +The QR code generation is licensed under the MIT license (MIT, see below). + +The Zxing.Net Dot Matrix Code (DMC) generation is licensed under +the Apache License 2.0 (Apache-2.0, see below). + +The Grapevine REST server framework is licensed under Apache License 2.0 +(Apache-2.0, see below). + +The AutomationML.Engine is licensed under the MIT license (MIT, see below). + +The MQTT server and client is licensed under the MIT license (MIT, see below). + +The ClosedXML Excel reader/writer is licensed under the MIT license (MIT, +see below). + +The CountryFlag WPF control is licensed under the Code Project Open License +(CPOL, see below). + +The DocumentFormat.OpenXml SDK is licensed under the MIT license (MIT, +see below). + +The ExcelNumberFormat number parser is licensed under the MIT license (MIT, +see below). + +The FastMember reflection access is licensed under Apache License 2.0 +(Apache-2.0, see below). + +The IdentityModel OpenID client is licensed under Apache License 2.0 +(Apache-2.0, see below). + +The jose-jwt object signing and encryption is licensed under the +MIT license (MIT, see below). + +The ExcelDataReader is licensed under the MIT license (MIT, see below). + +Portions copyright (c) by OPC Foundation, Inc. and licensed under the +Reciprocal Community License (RCL, see below) + +The OPC UA Example Code of OPC UA Standard is licensed under the MIT license +(MIT, see below). + +The MSAGL (Microsoft Automatic Graph Layout) is licensed under the MIT license +(MIT, see below) + +Glob (https://www.nuget.org/packages/Glob/) is licensed under the MIT license +(MIT, see below). + +The Magick.NET library is licensed under Apache License 2.0 +(Apache-2.0, see below). + +The SSharp.NET library (https://github.com/PetroProtsyk/SSharp) is licensed +under Apache License 2.0 (Apache-2.0, see below). + +------------------------------------------------------------------------------- + + +With respect to AASX Package Explorer +===================================== + +(http://www.apache.org/licenses/LICENSE-2.0) + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + +With respect to cefSharp +======================== + +(https://raw.githubusercontent.com/cefsharp/CefSharp/master/LICENSE) + +Copyright © The CefSharp Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following disclaimer + in the documentation and/or other materials provided with the + distribution. + + * Neither the name of Google Inc. nor the name Chromium Embedded + Framework nor the name CefSharp nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +With respect to Newtonsoft.Json +=============================== + +(https://github.com/JamesNK/Newtonsoft.Json/blob/master/LICENSE.md) + +The MIT License (MIT) + +Copyright (c) 2007 James Newton-King + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +With respect to QRcoder +======================= + +(https://github.com/codebude/QRCoder/blob/master/LICENSE.txt) + +The MIT License (MIT) + +Copyright (c) 2013-2018 Raffael Herrmann + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +With respect to ZXing.Net +========================= +With respect to Grapevine +========================= +With respect to FastMember +========================== +With respect to IdentityModel +============================= + +(http://www.apache.org/licenses/LICENSE-2.0) + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + +With respect to AutomationML.Engine +=================================== + +(https://raw.githubusercontent.com/AutomationML/AMLEngine2.1/master/license.txt) + +The MIT License (MIT) + +Copyright 2017 AutomationML e.V. + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. + + +With respect to MQTTnet +======================= + +(https://github.com/chkr1011/MQTTnet/blob/master/LICENSE) + +MIT License + +MQTTnet Copyright (c) 2016-2019 Christian Kratky + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +With resepct to ClosedXML +========================= + +(https://github.com/ClosedXML/ClosedXML/blob/develop/LICENSE) + +MIT License + +Copyright (c) 2016 ClosedXML + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +With resepct to CountryFlag +=========================== + +(https://www.codeproject.com/Articles/190722/WPF-CountryFlag-Control) + +The Code Project Open License (CPOL) 1.02 + +Copyright © 2017 Meshack Musundi + +Preamble + +This License governs Your use of the Work. This License is intended to allow +developers to use the Source Code and Executable Files provided as part of +the Work in any application in any form. + +The main points subject to the terms of the License are: + + Source Code and Executable Files can be used in commercial applications; + Source Code and Executable Files can be redistributed; and + Source Code can be modified to create derivative works. + No claim of suitability, guarantee, or any warranty whatsoever is provided. + The software is provided "as-is". + The Article(s) accompanying the Work may not be distributed or republished + without the Author's consent + +This License is entered between You, the individual or other entity reading or +otherwise making use of the Work licensed pursuant to this License and the +individual or other entity which offers the Work under the terms of this +License ("Author"). + +License + +THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS +CODE PROJECT OPEN LICENSE ("LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT +AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED +UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED. + +BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HEREIN, YOU ACCEPT AND AGREE +TO BE BOUND BY THE TERMS OF THIS LICENSE. THE AUTHOR GRANTS YOU THE RIGHTS +CONTAINED HEREIN IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND +CONDITIONS. IF YOU DO NOT AGREE TO ACCEPT AND BE BOUND BY THE TERMS OF THIS +LICENSE, YOU CANNOT MAKE ANY USE OF THE WORK. + +Definitions. + "Articles" means, collectively, all articles written by Author which +describes how the Source Code and Executable Files for the Work may +be used by a user. + "Author" means the individual or entity that offers the Work under +the terms of this License. + "Derivative Work" means a work based upon the Work or upon the Work +and other pre-existing works. + "Executable Files" refer to the executables, binary files, +configuration and any required data files included in the Work. + "Publisher" means the provider of the website, magazine, CD-ROM, +DVD or other medium from or by which the Work is obtained by You. + "Source Code" refers to the collection of source code and +configuration files used to create the Executable Files. + "Standard Version" refers to such a Work if it has not been modified, +or has been modified in accordance with the consent of the Author, +such consent being in the full discretion of the Author. + "Work" refers to the collection of files distributed by the Publisher, +including the Source Code, Executable Files, binaries, data files, +documentation, whitepapers and the Articles. + "You" is you, an individual or entity wishing to use the Work and +exercise your rights under this License. + +Fair Use/Fair Use Rights. Nothing in this License is intended to reduce, +limit, or restrict any rights arising from fair use, fair dealing, +first sale or other limitations on the exclusive rights of the +copyright owner under copyright law or other applicable laws. + +License Grant. Subject to the terms and conditions of this License, the +Author hereby grants You a worldwide, royalty-free, non-exclusive, +perpetual (for the duration of the applicable copyright) license +to exercise the rights in the Work as stated below: + You may use the standard version of the Source Code or Executable +Files in Your own applications. + You may apply bug fixes, portability fixes and other modifications +obtained from the Public Domain or from the Author. A Work modified +in such a way shall still be considered the standard version and will +be subject to this License. + You may otherwise modify Your copy of this Work (excluding the Articles) +in any way to create a Derivative Work, provided that You insert a prominent +notice in each changed file stating how, when and where You changed that file. + You may distribute the standard version of the Executable Files and Source +Code or Derivative Work in aggregate with other (possibly commercial) +programs as part of a larger (possibly commercial) software distribution. + The Articles discussing the Work published in any form by the author may +not be distributed or republished without the Author's consent. The author +retains copyright to any such Articles. You may use the Executable Files and +Source Code pursuant to this License but you may not repost or republish or +otherwise distribute or make available the Articles, without the prior written +consent of the Author. + +Any subroutines or modules supplied by You and linked into the Source Code +or Executable Files of this Work shall not be considered part of this Work +and will not be subject to the terms of this License. + +Patent License. Subject to the terms and conditions of this License, each +Author hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, +royalty-free, irrevocable (except as stated in this section) patent license +to make, have made, use, import, and otherwise transfer the Work. + +Restrictions. The license granted in Section 3 above is expressly made subject +to and limited by the following restrictions: + You agree not to remove any of the original copyright, patent, trademark, +and attribution notices and associated disclaimers that may appear in the +Source Code or Executable Files. + You agree not to advertise or in any way imply that this Work is a product +of Your own. + The name of the Author may not be used to endorse or promote products +derived from the Work without the prior written consent of the Author. + You agree not to sell, lease, or rent any part of the Work. This does +not restrict you from including the Work or any part of the Work inside +a larger software distribution that itself is being sold. The Work by itself, +though, cannot be sold, leased or rented. + You may distribute the Executable Files and Source Code only under the terms +of this License, and You must include a copy of, or the Uniform Resource +Identifier for, this License with every copy of the Executable Files or +Source Code You distribute and ensure that anyone receiving such Executable +Files and Source Code agrees that the terms of this License apply to such +Executable Files and/or Source Code. You may not offer or impose any terms +on the Work that alter or restrict the terms of this License or the +recipients' exercise of the rights granted hereunder. You may not sublicense +the Work. You must keep intact all notices that refer to this License and to +the disclaimer of warranties. You may not distribute the Executable Files or +Source Code with any technological measures that control access or use of the +Work in a manner inconsistent with the terms of this License. + You agree not to use the Work for illegal, immoral or improper +purposes, or on pages containing illegal, immoral or improper material. +The Work is subject to applicable export laws. You agree to comply with all +such laws and regulations that may apply to the Work after Your receipt of +the Work. + +Representations, Warranties and Disclaimer. THIS WORK IS PROVIDED "AS IS", +"WHERE IS" AND "AS AVAILABLE", WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES OR +CONDITIONS OR GUARANTEES. YOU, THE USER, ASSUME ALL RISK IN ITS USE, +INCLUDING COPYRIGHT INFRINGEMENT, PATENT INFRINGEMENT, SUITABILITY, ETC. +AUTHOR EXPRESSLY DISCLAIMS ALL EXPRESS, IMPLIED OR STATUTORY WARRANTIES +OR CONDITIONS, INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS +OF MERCHANTABILITY, MERCHANTABLE QUALITY OR FITNESS FOR A PARTICULAR +PURPOSE, OR ANY WARRANTY OF TITLE OR NON-INFRINGEMENT, OR THAT THE WORK +(OR ANY PORTION THEREOF) IS CORRECT, USEFUL, BUG-FREE OR FREE OF VIRUSES. +YOU MUST PASS THIS DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE WORK OR DERIVATIVE +WORKS. + +Indemnity. You agree to defend, indemnify and hold harmless the Author and the +Publisher from and against any claims, suits, losses, damages, liabilities, +costs, and expenses (including reasonable legal or attorneys’ fees) +resulting from or relating to any use of the Work by You. + +Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, +IN NO EVENT WILL THE AUTHOR OR THE PUBLISHER BE LIABLE TO YOU ON ANY LEGAL +THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY +DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK OR OTHERWISE, +EVEN IF THE AUTHOR OR THE PUBLISHER HAS BEEN ADVISED OF THE POSSIBILITY +OF SUCH DAMAGES. + +Termination. + This License and the rights granted hereunder will terminate +automatically upon any breach by You of any term of this License. +Individuals or entities who have received Derivative Works from You under +this License, however, will not have their licenses terminated provided such +individuals or entities remain in full compliance with those licenses. +Sections 1, 2, 6, 7, 8, 9, 10 and 11 will survive any termination of +this License. + If You bring a copyright, trademark, patent or any other infringement +claim against any contributor over infringements You claim are made by the +Work, your License from such contributor to the Work ends automatically. + Subject to the above terms and conditions, this License is perpetual +(for the duration of the applicable copyright in the Work). +Notwithstanding the above, the Author reserves the right to release the Work +under different license terms or to stop distributing the Work at any time; +provided, however that any such election will not serve to withdraw this +License (or any other license that has been, or is required to be, +granted under the terms of this License), and this License will continue +in full force and effect unless terminated as stated above. + +Publisher. The parties hereby confirm that the Publisher shall not, under +any circumstances, be responsible for and shall not have any liability +in respect of the subject matter of this License. The Publisher makes no +warranty whatsoever in connection with the Work and shall not be liable +to You or any party on any legal theory for any damages whatsoever, including +without limitation any general, special, incidental or consequential damages +arising in connection to this license. The Publisher reserves the right to +cease making the Work available to You at any time without notice + +Miscellaneous + This License shall be governed by the laws of the location of the head +office of the Author or if the Author is an individual, the laws of +location of the principal place of residence of the Author. + If any provision of this License is invalid or unenforceable under +applicable law, it shall not affect the validity or enforceability of the +remainder of the terms of this License, and without further action by the +parties to this License, such provision shall be reformed to the minimum +extent necessary to make such provision valid and enforceable. + No term or provision of this License shall be deemed waived and no +breach consented to unless such waiver or consent shall be in writing +and signed by the party to be charged with such waiver or consent. + This License constitutes the entire agreement between the parties +with respect to the Work licensed herein. There are no understandings, +agreements or representations with respect to the Work not specified herein. +The Author shall not be bound by any additional provisions that may appear +in any communication from You. This License may not be modified without +the mutual written agreement of the Author and You. + + +With respect to DocumentFormat.OpenXml +====================================== + +(https://github.com/OfficeDev/Open-XML-SDK/blob/master/LICENSE) + +The MIT License (MIT) + +Copyright (c) Microsoft Corporation + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +With respect to ExcelNumberFormat +================================= + +(https://github.com/andersnm/ExcelNumberFormat/blob/master/LICENSE) + +The MIT License (MIT) + +Copyright (c) 2017 andersnm + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +With respect to jose-jwt +======================== + +(https://github.com/dvsekhvalnov/jose-jwt/blob/master/LICENSE) + +The MIT License (MIT) + +Copyright (c) 2014-2019 dvsekhvalnov + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +With resepect to ExcelDataReader +================================ + +(https://github.com/ExcelDataReader/ExcelDataReader/blob/develop/LICENSE) + +The MIT License (MIT) + +Copyright (c) 2014 ExcelDataReader + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + + +With resepect to OPC UA Example Code +==================================== + + * Copyright (c) 2005-2019 The OPC Foundation, Inc. All rights reserved. + * + * OPC Foundation MIT License 1.00 + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + * The complete license agreement can be found here: + * http://opcfoundation.org/License/MIT/1.00/ + + +With respect to OPC Foundation +============================== + +RCL License +Reciprocal Community License 1.00 (RCL1.00) +Version 1.00, June 24, 2009 +Copyright (C) 2008,2009 OPC Foundation, Inc., All Rights Reserved. + +https://opcfoundation.org/license/rcl.html + +Remark: PHOENIX CONTACT GmbH & Co. KG and Festo SE & Co. KG are members +of OPC foundation. + +With respect to MSAGL (Microsoft Automatic Graph Layout) +======================================================== +(see: https://github.com/microsoft/automatic-graph-layout/blob/master/LICENSE) + +Microsoft Automatic Graph Layout, MSAGL + +Copyright (c) Microsoft Corporation + +All rights reserved. + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +""Software""), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + + +With respect to Glob (https://www.nuget.org/packages/Glob/) +=========================================================== +(see: https://raw.githubusercontent.com/kthompson/glob/master/LICENSE) + +The MIT License (MIT) + +Copyright (c) 2013-2019 Kevin Thompson + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +With respect to Magick.NET +========================== + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +With respect to SSharp.NET library +================================== + + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/src/AasCore.Aas3_0/copying.cs b/src/AasCore.Aas3_0/copying.cs index 38af42018..f63774dfa 100644 --- a/src/AasCore.Aas3_0/copying.cs +++ b/src/AasCore.Aas3_0/copying.cs @@ -16,9 +16,8 @@ * Do NOT edit or append. */ -using System; -using System.Collections.Generic; // can't alias -using Aas = AasCore.Aas3_0; // renamed +using Aas = AasCore.Aas3_0; // renamed +using System.Collections.Generic; // can't alias namespace AasCore.Aas3_0 { @@ -45,7 +44,7 @@ public static class Copying /// type to cast the result to public static T Shallow(T that) where T : Aas.IClass { - return (T) ShallowCopierInstance.Transform(that); + return (T)ShallowCopierInstance.Transform(that); } /// @@ -55,7 +54,7 @@ public static T Shallow(T that) where T : Aas.IClass /// type to cast the result to public static T Deep(T that) where T : Aas.IClass { - return (T) DeepCopierInstance.Transform(that); + return (T)DeepCopierInstance.Transform(that); } /// Dispatch the making of shallow copies. @@ -586,14 +585,14 @@ Aas.IDataSpecificationIec61360 that that.Value, that.LevelType); } - } // internal class ShallowCopier + } // internal class ShallowCopier /// Dispatch the making of deep copies. internal class DeepCopier : Visitation.AbstractTransformer { public override Aas.IClass TransformExtension( - Aas.IExtension that - ) + Aas.IExtension that + ) { List? theSupplementalSemanticIds = null; if (that.SupplementalSemanticIds != null) @@ -1282,8 +1281,7 @@ Aas.IProperty that that.EmbeddedDataSpecifications.Count); foreach (var item in that.EmbeddedDataSpecifications) { - if (item.DataSpecification != null && item.DataSpecificationContent != null) - theEmbeddedDataSpecifications.Add(Deep(item)); + theEmbeddedDataSpecifications.Add(Deep(item)); } } @@ -2378,7 +2376,7 @@ Aas.IReference that ) { var theKeys = new List( - that.Keys.Count); + that.Keys.Count); foreach (var item in that.Keys) { theKeys.Add(Deep(item)); @@ -2471,24 +2469,10 @@ public override Aas.IClass TransformEmbeddedDataSpecification( Aas.IEmbeddedDataSpecification that ) { - IReference? theDataSpecification = null; - if (that.DataSpecification != null) - { - theDataSpecification = Deep(that.DataSpecification); - } - - IDataSpecificationContent? theDataSpecificationContent = null; - if (that.DataSpecificationContent != null) - { - theDataSpecificationContent = Deep(that.DataSpecificationContent); - } - - if (theDataSpecification != null && theDataSpecificationContent != null) - { - return new Aas.EmbeddedDataSpecification(theDataSpecification, theDataSpecificationContent); - } - - throw new NullReferenceException($"{nameof(theDataSpecification)} or {nameof(theDataSpecificationContent)}"); + return new Aas.EmbeddedDataSpecification( + Deep(that.DataSpecification), + Deep(that.DataSpecificationContent) + ); } public override Aas.IClass TransformLevelType( @@ -2613,11 +2597,11 @@ Aas.IDataSpecificationIec61360 that : null ); } - } // internal class DeepCopier - } // public static class Copying -} // namespace AasCore.Aas3_0 + } // internal class DeepCopier + } // public static class Copying +} // namespace AasCore.Aas3_0 /* * This code has been automatically generated by aas-core-codegen. * Do NOT edit or append. - */ \ No newline at end of file + */ diff --git a/src/AasCore.Aas3_0/jsonization.cs b/src/AasCore.Aas3_0/jsonization.cs index c2ba08f33..6154620ff 100644 --- a/src/AasCore.Aas3_0/jsonization.cs +++ b/src/AasCore.Aas3_0/jsonization.cs @@ -339,12 +339,12 @@ internal static class DeserializeImplementation return null; } - string? theName = null; - IReference? theSemanticId = null; + string? theName = null; + IReference? theSemanticId = null; List? theSupplementalSemanticIds = null; - DataTypeDefXsd? theValueType = null; - string? theValue = null; - List? theRefersTo = null; + DataTypeDefXsd? theValueType = null; + string? theValue = null; + List? theRefersTo = null; foreach (var keyValue in obj) { @@ -865,7 +865,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -1069,10 +1069,10 @@ internal static class DeserializeImplementation } List? theEmbeddedDataSpecifications = null; - string? theVersion = null; - string? theRevision = null; - IReference? theCreator = null; - string? theTemplateId = null; + string? theVersion = null; + string? theRevision = null; + IReference? theCreator = null; + string? theTemplateId = null; foreach (var keyValue in obj) { @@ -1356,7 +1356,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -1394,13 +1394,13 @@ internal static class DeserializeImplementation return null; } - string? theType = null; - DataTypeDefXsd? theValueType = null; - IReference? theSemanticId = null; + string? theType = null; + DataTypeDefXsd? theValueType = null; + IReference? theSemanticId = null; List? theSupplementalSemanticIds = null; - QualifierKind? theKind = null; - string? theValue = null; - IReference? theValueId = null; + QualifierKind? theKind = null; + string? theValue = null; + IReference? theValueId = null; foreach (var keyValue in obj) { @@ -1659,17 +1659,17 @@ internal static class DeserializeImplementation return null; } - string? theId = null; - IAssetInformation? theAssetInformation = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IAdministrativeInformation? theAdministration = null; + string? theId = null; + IAssetInformation? theAssetInformation = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IAdministrativeInformation? theAdministration = null; List? theEmbeddedDataSpecifications = null; - IReference? theDerivedFrom = null; - List? theSubmodels = null; + IReference? theDerivedFrom = null; + List? theSubmodels = null; foreach (var keyValue in obj) { @@ -2154,11 +2154,11 @@ internal static class DeserializeImplementation return null; } - AssetKind? theAssetKind = null; - string? theGlobalAssetId = null; + AssetKind? theAssetKind = null; + string? theGlobalAssetId = null; List? theSpecificAssetIds = null; - string? theAssetType = null; - IResource? theDefaultThumbnail = null; + string? theAssetType = null; + IResource? theDefaultThumbnail = null; foreach (var keyValue in obj) { @@ -2358,7 +2358,7 @@ internal static class DeserializeImplementation return null; } - string? thePath = null; + string? thePath = null; string? theContentType = null; foreach (var keyValue in obj) @@ -2445,7 +2445,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -2483,11 +2483,11 @@ internal static class DeserializeImplementation return null; } - string? theName = null; - string? theValue = null; - IReference? theSemanticId = null; + string? theName = null; + string? theValue = null; + IReference? theSemanticId = null; List? theSupplementalSemanticIds = null; - IReference? theExternalSubjectId = null; + IReference? theExternalSubjectId = null; foreach (var keyValue in obj) { @@ -2696,19 +2696,19 @@ internal static class DeserializeImplementation return null; } - string? theId = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IAdministrativeInformation? theAdministration = null; - ModellingKind? theKind = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + string? theId = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IAdministrativeInformation? theAdministration = null; + ModellingKind? theKind = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - List? theSubmodelElements = null; + List? theSubmodelElements = null; foreach (var keyValue in obj) { @@ -3452,16 +3452,16 @@ internal static class DeserializeImplementation return null; } - IReference? theFirst = null; - IReference? theSecond = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + IReference? theFirst = null; + IReference? theSecond = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; foreach (var keyValue in obj) @@ -3970,7 +3970,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -4008,20 +4008,20 @@ internal static class DeserializeImplementation return null; } - AasSubmodelElements? theTypeValueListElement = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + AasSubmodelElements? theTypeValueListElement = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - bool? theOrderRelevant = null; - IReference? theSemanticIdListElement = null; - DataTypeDefXsd? theValueTypeListElement = null; - List? theValue = null; + bool? theOrderRelevant = null; + IReference? theSemanticIdListElement = null; + DataTypeDefXsd? theValueTypeListElement = null; + List? theValue = null; foreach (var keyValue in obj) { @@ -4634,16 +4634,16 @@ internal static class DeserializeImplementation return null; } - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - List? theValue = null; + List? theValue = null; foreach (var keyValue in obj) { @@ -5221,18 +5221,18 @@ internal static class DeserializeImplementation return null; } - DataTypeDefXsd? theValueType = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + DataTypeDefXsd? theValueType = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - string? theValue = null; - IReference? theValueId = null; + string? theValue = null; + IReference? theValueId = null; foreach (var keyValue in obj) { @@ -5764,17 +5764,17 @@ internal static class DeserializeImplementation return null; } - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - List? theValue = null; - IReference? theValueId = null; + List? theValue = null; + IReference? theValueId = null; foreach (var keyValue in obj) { @@ -6305,18 +6305,18 @@ internal static class DeserializeImplementation return null; } - DataTypeDefXsd? theValueType = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + DataTypeDefXsd? theValueType = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - string? theMin = null; - string? theMax = null; + string? theMin = null; + string? theMax = null; foreach (var keyValue in obj) { @@ -6848,16 +6848,16 @@ internal static class DeserializeImplementation return null; } - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - IReference? theValue = null; + IReference? theValue = null; foreach (var keyValue in obj) { @@ -7332,17 +7332,17 @@ internal static class DeserializeImplementation return null; } - string? theContentType = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + string? theContentType = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - byte[]? theValue = null; + byte[]? theValue = null; foreach (var keyValue in obj) { @@ -7849,17 +7849,17 @@ internal static class DeserializeImplementation return null; } - string? theContentType = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + string? theContentType = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - string? theValue = null; + string? theValue = null; foreach (var keyValue in obj) { @@ -8366,18 +8366,18 @@ internal static class DeserializeImplementation return null; } - IReference? theFirst = null; - IReference? theSecond = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + IReference? theFirst = null; + IReference? theSecond = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - List? theAnnotations = null; + List? theAnnotations = null; foreach (var keyValue in obj) { @@ -8949,19 +8949,19 @@ internal static class DeserializeImplementation return null; } - EntityType? theEntityType = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + EntityType? theEntityType = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - List? theStatements = null; - string? theGlobalAssetId = null; - List? theSpecificAssetIds = null; + List? theStatements = null; + string? theGlobalAssetId = null; + List? theSpecificAssetIds = null; foreach (var keyValue in obj) { @@ -9572,7 +9572,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -9602,7 +9602,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -9632,7 +9632,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -9670,14 +9670,14 @@ internal static class DeserializeImplementation return null; } - IReference? theSource = null; - IReference? theObservableReference = null; - string? theTimeStamp = null; - IReference? theSourceSemanticId = null; + IReference? theSource = null; + IReference? theObservableReference = null; + string? theTimeStamp = null; + IReference? theSourceSemanticId = null; IReference? theObservableSemanticId = null; - string? theTopic = null; - IReference? theSubjectId = null; - byte[]? thePayload = null; + string? theTopic = null; + IReference? theSubjectId = null; + byte[]? thePayload = null; foreach (var keyValue in obj) { @@ -9996,23 +9996,23 @@ internal static class DeserializeImplementation return null; } - IReference? theObserved = null; - Direction? theDirection = null; - StateOfEvent? theState = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + IReference? theObserved = null; + Direction? theDirection = null; + StateOfEvent? theState = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - string? theMessageTopic = null; - IReference? theMessageBroker = null; - string? theLastUpdate = null; - string? theMinInterval = null; - string? theMaxInterval = null; + string? theMessageTopic = null; + IReference? theMessageBroker = null; + string? theLastUpdate = null; + string? theMinInterval = null; + string? theMaxInterval = null; foreach (var keyValue in obj) { @@ -10687,18 +10687,18 @@ internal static class DeserializeImplementation return null; } - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - List? theInputVariables = null; - List? theOutputVariables = null; - List? theInoutputVariables = null; + List? theInputVariables = null; + List? theOutputVariables = null; + List? theInoutputVariables = null; foreach (var keyValue in obj) { @@ -11385,14 +11385,14 @@ internal static class DeserializeImplementation return null; } - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IReference? theSemanticId = null; - List? theSupplementalSemanticIds = null; - List? theQualifiers = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IReference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; foreach (var keyValue in obj) @@ -11843,15 +11843,15 @@ internal static class DeserializeImplementation return null; } - string? theId = null; - List? theExtensions = null; - string? theCategory = null; - string? theIdShort = null; - List? theDisplayName = null; - List? theDescription = null; - IAdministrativeInformation? theAdministration = null; + string? theId = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + IAdministrativeInformation? theAdministration = null; List? theEmbeddedDataSpecifications = null; - List? theIsCaseOf = null; + List? theIsCaseOf = null; foreach (var keyValue in obj) { @@ -12269,7 +12269,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -12468,8 +12468,8 @@ internal static class DeserializeImplementation return null; } - KeyTypes? theType = null; - string? theValue = null; + KeyTypes? theType = null; + string? theValue = null; foreach (var keyValue in obj) { @@ -12564,7 +12564,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -12594,7 +12594,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -12702,7 +12702,7 @@ internal static class DeserializeImplementation } string? theLanguage = null; - string? theText = null; + string? theText = null; foreach (var keyValue in obj) { @@ -12806,7 +12806,7 @@ internal static class DeserializeImplementation } string? theLanguage = null; - string? theText = null; + string? theText = null; foreach (var keyValue in obj) { @@ -13269,7 +13269,7 @@ internal static class DeserializeImplementation { error = null; string? text = DeserializeImplementation.StringFrom( - node, out error); + node, out error); if (error != null) { return null; @@ -13686,7 +13686,7 @@ internal static class DeserializeImplementation } string? theLanguage = null; - string? theText = null; + string? theText = null; foreach (var keyValue in obj) { @@ -13790,7 +13790,7 @@ internal static class DeserializeImplementation } string? theLanguage = null; - string? theText = null; + string? theText = null; foreach (var keyValue in obj) { @@ -13894,7 +13894,7 @@ internal static class DeserializeImplementation } string? theLanguage = null; - string? theText = null; + string? theText = null; foreach (var keyValue in obj) { @@ -13997,18 +13997,18 @@ internal static class DeserializeImplementation return null; } - List? thePreferredName = null; - List? theShortName = null; - string? theUnit = null; - IReference? theUnitId = null; - string? theSourceOfDefinition = null; - string? theSymbol = null; - DataTypeIec61360? theDataType = null; - List? theDefinition = null; - string? theValueFormat = null; - IValueList? theValueList = null; - string? theValue = null; - ILevelType? theLevelType = null; + List? thePreferredName = null; + List? theShortName = null; + string? theUnit = null; + IReference? theUnitId = null; + string? theSourceOfDefinition = null; + string? theSymbol = null; + DataTypeIec61360? theDataType = null; + List? theDefinition = null; + string? theValueFormat = null; + IValueList? theValueList = null; + string? theValue = null; + ILevelType? theLevelType = null; foreach (var keyValue in obj) { @@ -14773,7 +14773,7 @@ public static Aas.Qualifier QualifierFrom( /// Thrown when is not a valid JSON /// representation of AssetAdministrationShell. /// - public static AssetAdministrationShell? AssetAdministrationShellFrom( + public static Aas.AssetAdministrationShell AssetAdministrationShellFrom( Nodes.JsonNode node) { Aas.AssetAdministrationShell? result = DeserializeImplementation.AssetAdministrationShellFrom( @@ -14798,7 +14798,7 @@ public static Aas.Qualifier QualifierFrom( /// Thrown when is not a valid JSON /// representation of AssetInformation. /// - public static AssetInformation? AssetInformationFrom( + public static Aas.AssetInformation AssetInformationFrom( Nodes.JsonNode node) { Aas.AssetInformation? result = DeserializeImplementation.AssetInformationFrom( @@ -14873,7 +14873,7 @@ public static Aas.AssetKind AssetKindFrom( /// Thrown when is not a valid JSON /// representation of SpecificAssetId. /// - public static SpecificAssetId? SpecificAssetIdFrom( + public static Aas.SpecificAssetId SpecificAssetIdFrom( Nodes.JsonNode node) { Aas.SpecificAssetId? result = DeserializeImplementation.SpecificAssetIdFrom( @@ -14898,7 +14898,7 @@ public static Aas.AssetKind AssetKindFrom( /// Thrown when is not a valid JSON /// representation of Submodel. /// - public static Submodel? SubmodelFrom( + public static Aas.Submodel SubmodelFrom( Nodes.JsonNode node) { Aas.Submodel? result = DeserializeImplementation.SubmodelFrom( @@ -14924,7 +14924,7 @@ public static Aas.AssetKind AssetKindFrom( /// representation of ISubmodelElement. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - public static ISubmodelElement? ISubmodelElementFrom( + public static Aas.ISubmodelElement ISubmodelElementFrom( Nodes.JsonNode node) { Aas.ISubmodelElement? result = DeserializeImplementation.ISubmodelElementFrom( @@ -15527,7 +15527,7 @@ public static Aas.Capability CapabilityFrom( /// Thrown when is not a valid JSON /// representation of ConceptDescription. /// - public static ConceptDescription? ConceptDescriptionFrom( + public static Aas.ConceptDescription ConceptDescriptionFrom( Nodes.JsonNode node) { Aas.ConceptDescription? result = DeserializeImplementation.ConceptDescriptionFrom( @@ -15577,7 +15577,7 @@ public static Aas.ReferenceTypes ReferenceTypesFrom( /// Thrown when is not a valid JSON /// representation of Reference. /// - public static Reference? ReferenceFrom( + public static Aas.Reference ReferenceFrom( Nodes.JsonNode node) { Aas.Reference? result = DeserializeImplementation.ReferenceFrom( @@ -15753,7 +15753,7 @@ public static Aas.LangStringTextType LangStringTextTypeFrom( /// Thrown when is not a valid JSON /// representation of Environment. /// - public static Environment EnvironmentFrom( + public static Aas.Environment EnvironmentFrom( Nodes.JsonNode node) { Aas.Environment? result = DeserializeImplementation.EnvironmentFrom( @@ -16060,7 +16060,7 @@ Aas.IExtension that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -16090,7 +16090,7 @@ Aas.IExtension that if (that.RefersTo != null) { var arrayRefersTo = new Nodes.JsonArray(); - foreach (IReference? item in that.RefersTo) + foreach (IReference item in that.RefersTo) { arrayRefersTo.Add( Transform( @@ -16111,7 +16111,7 @@ Aas.IAdministrativeInformation that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -16162,7 +16162,7 @@ Aas.IQualifier that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -16210,7 +16210,7 @@ Aas.IAssetAdministrationShell that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -16234,7 +16234,7 @@ Aas.IAssetAdministrationShell that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -16246,7 +16246,7 @@ Aas.IAssetAdministrationShell that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -16267,7 +16267,7 @@ Aas.IAssetAdministrationShell that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -16288,7 +16288,7 @@ Aas.IAssetAdministrationShell that if (that.Submodels != null) { var arraySubmodels = new Nodes.JsonArray(); - foreach (IReference? item in that.Submodels) + foreach (IReference item in that.Submodels) { arraySubmodels.Add( Transform( @@ -16320,7 +16320,7 @@ Aas.IAssetInformation that if (that.SpecificAssetIds != null) { var arraySpecificAssetIds = new Nodes.JsonArray(); - foreach (ISpecificAssetId? item in that.SpecificAssetIds) + foreach (ISpecificAssetId item in that.SpecificAssetIds) { arraySpecificAssetIds.Add( Transform( @@ -16377,7 +16377,7 @@ Aas.ISpecificAssetId that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -16410,7 +16410,7 @@ Aas.ISubmodel that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -16434,7 +16434,7 @@ Aas.ISubmodel that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -16446,7 +16446,7 @@ Aas.ISubmodel that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -16482,7 +16482,7 @@ Aas.ISubmodel that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -16494,7 +16494,7 @@ Aas.ISubmodel that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -16506,7 +16506,7 @@ Aas.ISubmodel that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -16518,7 +16518,7 @@ Aas.ISubmodel that if (that.SubmodelElements != null) { var arraySubmodelElements = new Nodes.JsonArray(); - foreach (ISubmodelElement? item in that.SubmodelElements) + foreach (ISubmodelElement item in that.SubmodelElements) { arraySubmodelElements.Add( Transform( @@ -16541,7 +16541,7 @@ Aas.IRelationshipElement that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -16565,7 +16565,7 @@ Aas.IRelationshipElement that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -16577,7 +16577,7 @@ Aas.IRelationshipElement that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -16595,7 +16595,7 @@ Aas.IRelationshipElement that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -16607,7 +16607,7 @@ Aas.IRelationshipElement that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -16619,7 +16619,7 @@ Aas.IRelationshipElement that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -16648,7 +16648,7 @@ Aas.ISubmodelElementList that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -16672,7 +16672,7 @@ Aas.ISubmodelElementList that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -16684,7 +16684,7 @@ Aas.ISubmodelElementList that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -16702,7 +16702,7 @@ Aas.ISubmodelElementList that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -16714,7 +16714,7 @@ Aas.ISubmodelElementList that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -16726,7 +16726,7 @@ Aas.ISubmodelElementList that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -16762,7 +16762,7 @@ Aas.ISubmodelElementList that if (that.Value != null) { var arrayValue = new Nodes.JsonArray(); - foreach (ISubmodelElement? item in that.Value) + foreach (ISubmodelElement item in that.Value) { arrayValue.Add( Transform( @@ -16785,7 +16785,7 @@ Aas.ISubmodelElementCollection that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -16809,7 +16809,7 @@ Aas.ISubmodelElementCollection that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -16821,7 +16821,7 @@ Aas.ISubmodelElementCollection that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -16839,7 +16839,7 @@ Aas.ISubmodelElementCollection that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -16851,7 +16851,7 @@ Aas.ISubmodelElementCollection that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -16863,7 +16863,7 @@ Aas.ISubmodelElementCollection that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -16875,7 +16875,7 @@ Aas.ISubmodelElementCollection that if (that.Value != null) { var arrayValue = new Nodes.JsonArray(); - foreach (ISubmodelElement? item in that.Value) + foreach (ISubmodelElement item in that.Value) { arrayValue.Add( Transform( @@ -16898,7 +16898,7 @@ Aas.IProperty that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -16922,7 +16922,7 @@ Aas.IProperty that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -16934,7 +16934,7 @@ Aas.IProperty that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -16952,7 +16952,7 @@ Aas.IProperty that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -16964,7 +16964,7 @@ Aas.IProperty that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -16976,7 +16976,7 @@ Aas.IProperty that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -17014,7 +17014,7 @@ Aas.IMultiLanguageProperty that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -17038,7 +17038,7 @@ Aas.IMultiLanguageProperty that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -17050,7 +17050,7 @@ Aas.IMultiLanguageProperty that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -17068,7 +17068,7 @@ Aas.IMultiLanguageProperty that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -17080,7 +17080,7 @@ Aas.IMultiLanguageProperty that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -17092,7 +17092,7 @@ Aas.IMultiLanguageProperty that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -17104,7 +17104,7 @@ Aas.IMultiLanguageProperty that if (that.Value != null) { var arrayValue = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Value) + foreach (ILangStringTextType item in that.Value) { arrayValue.Add( Transform( @@ -17133,7 +17133,7 @@ Aas.IRange that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -17157,7 +17157,7 @@ Aas.IRange that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -17169,7 +17169,7 @@ Aas.IRange that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -17187,7 +17187,7 @@ Aas.IRange that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -17199,7 +17199,7 @@ Aas.IRange that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -17211,7 +17211,7 @@ Aas.IRange that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -17249,7 +17249,7 @@ Aas.IReferenceElement that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -17273,7 +17273,7 @@ Aas.IReferenceElement that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -17285,7 +17285,7 @@ Aas.IReferenceElement that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -17303,7 +17303,7 @@ Aas.IReferenceElement that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -17315,7 +17315,7 @@ Aas.IReferenceElement that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -17327,7 +17327,7 @@ Aas.IReferenceElement that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -17356,7 +17356,7 @@ Aas.IBlob that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -17380,7 +17380,7 @@ Aas.IBlob that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -17392,7 +17392,7 @@ Aas.IBlob that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -17410,7 +17410,7 @@ Aas.IBlob that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -17422,7 +17422,7 @@ Aas.IBlob that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -17434,7 +17434,7 @@ Aas.IBlob that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -17467,7 +17467,7 @@ Aas.IFile that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -17491,7 +17491,7 @@ Aas.IFile that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -17503,7 +17503,7 @@ Aas.IFile that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -17521,7 +17521,7 @@ Aas.IFile that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -17533,7 +17533,7 @@ Aas.IFile that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -17545,7 +17545,7 @@ Aas.IFile that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -17577,7 +17577,7 @@ Aas.IAnnotatedRelationshipElement that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -17601,7 +17601,7 @@ Aas.IAnnotatedRelationshipElement that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -17613,7 +17613,7 @@ Aas.IAnnotatedRelationshipElement that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -17631,7 +17631,7 @@ Aas.IAnnotatedRelationshipElement that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -17643,7 +17643,7 @@ Aas.IAnnotatedRelationshipElement that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -17655,7 +17655,7 @@ Aas.IAnnotatedRelationshipElement that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -17673,7 +17673,7 @@ Aas.IAnnotatedRelationshipElement that if (that.Annotations != null) { var arrayAnnotations = new Nodes.JsonArray(); - foreach (IDataElement? item in that.Annotations) + foreach (IDataElement item in that.Annotations) { arrayAnnotations.Add( Transform( @@ -17696,7 +17696,7 @@ Aas.IEntity that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -17720,7 +17720,7 @@ Aas.IEntity that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -17732,7 +17732,7 @@ Aas.IEntity that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -17750,7 +17750,7 @@ Aas.IEntity that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -17762,7 +17762,7 @@ Aas.IEntity that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -17774,7 +17774,7 @@ Aas.IEntity that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -17786,7 +17786,7 @@ Aas.IEntity that if (that.Statements != null) { var arrayStatements = new Nodes.JsonArray(); - foreach (ISubmodelElement? item in that.Statements) + foreach (ISubmodelElement item in that.Statements) { arrayStatements.Add( Transform( @@ -17807,7 +17807,7 @@ Aas.IEntity that if (that.SpecificAssetIds != null) { var arraySpecificAssetIds = new Nodes.JsonArray(); - foreach (ISpecificAssetId? item in that.SpecificAssetIds) + foreach (ISpecificAssetId item in that.SpecificAssetIds) { arraySpecificAssetIds.Add( Transform( @@ -17879,7 +17879,7 @@ Aas.IBasicEventElement that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -17903,7 +17903,7 @@ Aas.IBasicEventElement that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -17915,7 +17915,7 @@ Aas.IBasicEventElement that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -17933,7 +17933,7 @@ Aas.IBasicEventElement that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -17945,7 +17945,7 @@ Aas.IBasicEventElement that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -17957,7 +17957,7 @@ Aas.IBasicEventElement that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -18019,7 +18019,7 @@ Aas.IOperation that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -18043,7 +18043,7 @@ Aas.IOperation that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -18055,7 +18055,7 @@ Aas.IOperation that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -18073,7 +18073,7 @@ Aas.IOperation that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -18085,7 +18085,7 @@ Aas.IOperation that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -18097,7 +18097,7 @@ Aas.IOperation that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -18109,7 +18109,7 @@ Aas.IOperation that if (that.InputVariables != null) { var arrayInputVariables = new Nodes.JsonArray(); - foreach (IOperationVariable? item in that.InputVariables) + foreach (IOperationVariable item in that.InputVariables) { arrayInputVariables.Add( Transform( @@ -18121,7 +18121,7 @@ Aas.IOperation that if (that.OutputVariables != null) { var arrayOutputVariables = new Nodes.JsonArray(); - foreach (IOperationVariable? item in that.OutputVariables) + foreach (IOperationVariable item in that.OutputVariables) { arrayOutputVariables.Add( Transform( @@ -18133,7 +18133,7 @@ Aas.IOperation that if (that.InoutputVariables != null) { var arrayInoutputVariables = new Nodes.JsonArray(); - foreach (IOperationVariable? item in that.InoutputVariables) + foreach (IOperationVariable item in that.InoutputVariables) { arrayInoutputVariables.Add( Transform( @@ -18168,7 +18168,7 @@ Aas.ICapability that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -18192,7 +18192,7 @@ Aas.ICapability that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -18204,7 +18204,7 @@ Aas.ICapability that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -18222,7 +18222,7 @@ Aas.ICapability that if (that.SupplementalSemanticIds != null) { var arraySupplementalSemanticIds = new Nodes.JsonArray(); - foreach (IReference? item in that.SupplementalSemanticIds) + foreach (IReference item in that.SupplementalSemanticIds) { arraySupplementalSemanticIds.Add( Transform( @@ -18234,7 +18234,7 @@ Aas.ICapability that if (that.Qualifiers != null) { var arrayQualifiers = new Nodes.JsonArray(); - foreach (IQualifier? item in that.Qualifiers) + foreach (IQualifier item in that.Qualifiers) { arrayQualifiers.Add( Transform( @@ -18246,7 +18246,7 @@ Aas.ICapability that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -18269,7 +18269,7 @@ Aas.IConceptDescription that if (that.Extensions != null) { var arrayExtensions = new Nodes.JsonArray(); - foreach (IExtension? item in that.Extensions) + foreach (IExtension item in that.Extensions) { arrayExtensions.Add( Transform( @@ -18293,7 +18293,7 @@ Aas.IConceptDescription that if (that.DisplayName != null) { var arrayDisplayName = new Nodes.JsonArray(); - foreach (ILangStringNameType? item in that.DisplayName) + foreach (ILangStringNameType item in that.DisplayName) { arrayDisplayName.Add( Transform( @@ -18305,7 +18305,7 @@ Aas.IConceptDescription that if (that.Description != null) { var arrayDescription = new Nodes.JsonArray(); - foreach (ILangStringTextType? item in that.Description) + foreach (ILangStringTextType item in that.Description) { arrayDescription.Add( Transform( @@ -18326,7 +18326,7 @@ Aas.IConceptDescription that if (that.EmbeddedDataSpecifications != null) { var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); - foreach (IEmbeddedDataSpecification? item in that.EmbeddedDataSpecifications) + foreach (IEmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { arrayEmbeddedDataSpecifications.Add( Transform( @@ -18338,7 +18338,7 @@ Aas.IConceptDescription that if (that.IsCaseOf != null) { var arrayIsCaseOf = new Nodes.JsonArray(); - foreach (IReference? item in that.IsCaseOf) + foreach (IReference item in that.IsCaseOf) { arrayIsCaseOf.Add( Transform( @@ -18368,7 +18368,7 @@ Aas.IReference that } var arrayKeys = new Nodes.JsonArray(); - foreach (IKey? item in that.Keys) + foreach (IKey item in that.Keys) { arrayKeys.Add( Transform( @@ -18433,7 +18433,7 @@ Aas.IEnvironment that if (that.AssetAdministrationShells != null) { var arrayAssetAdministrationShells = new Nodes.JsonArray(); - foreach (IAssetAdministrationShell? item in that.AssetAdministrationShells) + foreach (IAssetAdministrationShell item in that.AssetAdministrationShells) { arrayAssetAdministrationShells.Add( Transform( @@ -18445,7 +18445,7 @@ Aas.IEnvironment that if (that.Submodels != null) { var arraySubmodels = new Nodes.JsonArray(); - foreach (ISubmodel? item in that.Submodels) + foreach (ISubmodel item in that.Submodels) { arraySubmodels.Add( Transform( @@ -18457,7 +18457,7 @@ Aas.IEnvironment that if (that.ConceptDescriptions != null) { var arrayConceptDescriptions = new Nodes.JsonArray(); - foreach (IConceptDescription? item in that.ConceptDescriptions) + foreach (IConceptDescription item in that.ConceptDescriptions) { arrayConceptDescriptions.Add( Transform( @@ -18527,7 +18527,7 @@ Aas.IValueList that var result = new Nodes.JsonObject(); var arrayValueReferencePairs = new Nodes.JsonArray(); - foreach (IValueReferencePair? item in that.ValueReferencePairs) + foreach (IValueReferencePair item in that.ValueReferencePairs) { arrayValueReferencePairs.Add( Transform( @@ -18590,7 +18590,7 @@ Aas.IDataSpecificationIec61360 that var result = new Nodes.JsonObject(); var arrayPreferredName = new Nodes.JsonArray(); - foreach (ILangStringPreferredNameTypeIec61360? item in that.PreferredName) + foreach (ILangStringPreferredNameTypeIec61360 item in that.PreferredName) { arrayPreferredName.Add( Transform( @@ -18601,7 +18601,7 @@ Aas.IDataSpecificationIec61360 that if (that.ShortName != null) { var arrayShortName = new Nodes.JsonArray(); - foreach (ILangStringShortNameTypeIec61360? item in that.ShortName) + foreach (ILangStringShortNameTypeIec61360 item in that.ShortName) { arrayShortName.Add( Transform( @@ -18646,7 +18646,7 @@ Aas.IDataSpecificationIec61360 that if (that.Definition != null) { var arrayDefinition = new Nodes.JsonArray(); - foreach (ILangStringDefinitionTypeIec61360? item in that.Definition) + foreach (ILangStringDefinitionTypeIec61360 item in that.Definition) { arrayDefinition.Add( Transform( @@ -18706,7 +18706,7 @@ public static class Serialize /// /// Serialize an instance of the meta-model into a JSON object. /// - public static Nodes.JsonObject ToJsonObject(IClass? that) + public static Nodes.JsonObject ToJsonObject(Aas.IClass that) { return Serialize.Transformer.Transform(that); } diff --git a/src/AasCore.Aas3_0/stringification.cs b/src/AasCore.Aas3_0/stringification.cs index 919ffb8f0..2eaddfdf4 100644 --- a/src/AasCore.Aas3_0/stringification.cs +++ b/src/AasCore.Aas3_0/stringification.cs @@ -58,12 +58,12 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _modellingKindFromString = ( - new Dictionary() - { - { "Template", Aas.ModellingKind.Template }, - { "Instance", Aas.ModellingKind.Instance } - }); + private static readonly Dictionary _modellingKindFromString = ( + new Dictionary() + { + { "Template", Aas.ModellingKind.Template }, + { "Instance", Aas.ModellingKind.Instance } + }); /// /// Parse the string representation of . @@ -73,7 +73,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.ModellingKind? ModellingKindFromString(string? text) + public static Aas.ModellingKind? ModellingKindFromString(string text) { if (_modellingKindFromString.TryGetValue(text, out ModellingKind value)) { @@ -119,13 +119,13 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _qualifierKindFromString = ( - new Dictionary() - { - { "ValueQualifier", Aas.QualifierKind.ValueQualifier }, - { "ConceptQualifier", Aas.QualifierKind.ConceptQualifier }, - { "TemplateQualifier", Aas.QualifierKind.TemplateQualifier } - }); + private static readonly Dictionary _qualifierKindFromString = ( + new Dictionary() + { + { "ValueQualifier", Aas.QualifierKind.ValueQualifier }, + { "ConceptQualifier", Aas.QualifierKind.ConceptQualifier }, + { "TemplateQualifier", Aas.QualifierKind.TemplateQualifier } + }); /// /// Parse the string representation of . @@ -135,7 +135,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.QualifierKind? QualifierKindFromString(string? text) + public static Aas.QualifierKind? QualifierKindFromString(string text) { if (_qualifierKindFromString.TryGetValue(text, out QualifierKind value)) { @@ -181,13 +181,13 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _assetKindFromString = ( - new Dictionary() - { - { "Type", Aas.AssetKind.Type }, - { "Instance", Aas.AssetKind.Instance }, - { "NotApplicable", Aas.AssetKind.NotApplicable } - }); + private static readonly Dictionary _assetKindFromString = ( + new Dictionary() + { + { "Type", Aas.AssetKind.Type }, + { "Instance", Aas.AssetKind.Instance }, + { "NotApplicable", Aas.AssetKind.NotApplicable } + }); /// /// Parse the string representation of . @@ -197,7 +197,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.AssetKind? AssetKindFromString(string? text) + public static Aas.AssetKind? AssetKindFromString(string text) { if (_assetKindFromString.TryGetValue(text, out AssetKind value)) { @@ -257,27 +257,27 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _aasSubmodelElementsFromString = ( - new Dictionary() - { - { "AnnotatedRelationshipElement", Aas.AasSubmodelElements.AnnotatedRelationshipElement }, - { "BasicEventElement", Aas.AasSubmodelElements.BasicEventElement }, - { "Blob", Aas.AasSubmodelElements.Blob }, - { "Capability", Aas.AasSubmodelElements.Capability }, - { "DataElement", Aas.AasSubmodelElements.DataElement }, - { "Entity", Aas.AasSubmodelElements.Entity }, - { "EventElement", Aas.AasSubmodelElements.EventElement }, - { "File", Aas.AasSubmodelElements.File }, - { "MultiLanguageProperty", Aas.AasSubmodelElements.MultiLanguageProperty }, - { "Operation", Aas.AasSubmodelElements.Operation }, - { "Property", Aas.AasSubmodelElements.Property }, - { "Range", Aas.AasSubmodelElements.Range }, - { "ReferenceElement", Aas.AasSubmodelElements.ReferenceElement }, - { "RelationshipElement", Aas.AasSubmodelElements.RelationshipElement }, - { "SubmodelElement", Aas.AasSubmodelElements.SubmodelElement }, - { "SubmodelElementList", Aas.AasSubmodelElements.SubmodelElementList }, - { "SubmodelElementCollection", Aas.AasSubmodelElements.SubmodelElementCollection } - }); + private static readonly Dictionary _aasSubmodelElementsFromString = ( + new Dictionary() + { + { "AnnotatedRelationshipElement", Aas.AasSubmodelElements.AnnotatedRelationshipElement }, + { "BasicEventElement", Aas.AasSubmodelElements.BasicEventElement }, + { "Blob", Aas.AasSubmodelElements.Blob }, + { "Capability", Aas.AasSubmodelElements.Capability }, + { "DataElement", Aas.AasSubmodelElements.DataElement }, + { "Entity", Aas.AasSubmodelElements.Entity }, + { "EventElement", Aas.AasSubmodelElements.EventElement }, + { "File", Aas.AasSubmodelElements.File }, + { "MultiLanguageProperty", Aas.AasSubmodelElements.MultiLanguageProperty }, + { "Operation", Aas.AasSubmodelElements.Operation }, + { "Property", Aas.AasSubmodelElements.Property }, + { "Range", Aas.AasSubmodelElements.Range }, + { "ReferenceElement", Aas.AasSubmodelElements.ReferenceElement }, + { "RelationshipElement", Aas.AasSubmodelElements.RelationshipElement }, + { "SubmodelElement", Aas.AasSubmodelElements.SubmodelElement }, + { "SubmodelElementList", Aas.AasSubmodelElements.SubmodelElementList }, + { "SubmodelElementCollection", Aas.AasSubmodelElements.SubmodelElementCollection } + }); /// /// Parse the string representation of . @@ -287,7 +287,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.AasSubmodelElements? AasSubmodelElementsFromString(string? text) + public static Aas.AasSubmodelElements? AasSubmodelElementsFromString(string text) { if (_aasSubmodelElementsFromString.TryGetValue(text, out AasSubmodelElements value)) { @@ -332,12 +332,12 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _entityTypeFromString = ( - new Dictionary() - { - { "CoManagedEntity", Aas.EntityType.CoManagedEntity }, - { "SelfManagedEntity", Aas.EntityType.SelfManagedEntity } - }); + private static readonly Dictionary _entityTypeFromString = ( + new Dictionary() + { + { "CoManagedEntity", Aas.EntityType.CoManagedEntity }, + { "SelfManagedEntity", Aas.EntityType.SelfManagedEntity } + }); /// /// Parse the string representation of . @@ -347,7 +347,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.EntityType? EntityTypeFromString(string? text) + public static Aas.EntityType? EntityTypeFromString(string text) { if (_entityTypeFromString.TryGetValue(text, out EntityType value)) { @@ -392,12 +392,12 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _directionFromString = ( - new Dictionary() - { - { "input", Aas.Direction.Input }, - { "output", Aas.Direction.Output } - }); + private static readonly Dictionary _directionFromString = ( + new Dictionary() + { + { "input", Aas.Direction.Input }, + { "output", Aas.Direction.Output } + }); /// /// Parse the string representation of . @@ -407,7 +407,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.Direction? DirectionFromString(string? text) + public static Aas.Direction? DirectionFromString(string text) { if (_directionFromString.TryGetValue(text, out Direction value)) { @@ -452,12 +452,12 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _stateOfEventFromString = ( - new Dictionary() - { - { "on", Aas.StateOfEvent.On }, - { "off", Aas.StateOfEvent.Off } - }); + private static readonly Dictionary _stateOfEventFromString = ( + new Dictionary() + { + { "on", Aas.StateOfEvent.On }, + { "off", Aas.StateOfEvent.Off } + }); /// /// Parse the string representation of . @@ -467,7 +467,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.StateOfEvent? StateOfEventFromString(string? text) + public static Aas.StateOfEvent? StateOfEventFromString(string text) { if (_stateOfEventFromString.TryGetValue(text, out StateOfEvent value)) { @@ -512,12 +512,12 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _referenceTypesFromString = ( - new Dictionary() - { - { "ExternalReference", Aas.ReferenceTypes.ExternalReference }, - { "ModelReference", Aas.ReferenceTypes.ModelReference } - }); + private static readonly Dictionary _referenceTypesFromString = ( + new Dictionary() + { + { "ExternalReference", Aas.ReferenceTypes.ExternalReference }, + { "ModelReference", Aas.ReferenceTypes.ModelReference } + }); /// /// Parse the string representation of . @@ -527,7 +527,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.ReferenceTypes? ReferenceTypesFromString(string? text) + public static Aas.ReferenceTypes? ReferenceTypesFromString(string text) { if (_referenceTypesFromString.TryGetValue(text, out ReferenceTypes value)) { @@ -594,34 +594,34 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _keyTypesFromString = ( - new Dictionary() - { - { "AnnotatedRelationshipElement", Aas.KeyTypes.AnnotatedRelationshipElement }, - { "AssetAdministrationShell", Aas.KeyTypes.AssetAdministrationShell }, - { "BasicEventElement", Aas.KeyTypes.BasicEventElement }, - { "Blob", Aas.KeyTypes.Blob }, - { "Capability", Aas.KeyTypes.Capability }, - { "ConceptDescription", Aas.KeyTypes.ConceptDescription }, - { "DataElement", Aas.KeyTypes.DataElement }, - { "Entity", Aas.KeyTypes.Entity }, - { "EventElement", Aas.KeyTypes.EventElement }, - { "File", Aas.KeyTypes.File }, - { "FragmentReference", Aas.KeyTypes.FragmentReference }, - { "GlobalReference", Aas.KeyTypes.GlobalReference }, - { "Identifiable", Aas.KeyTypes.Identifiable }, - { "MultiLanguageProperty", Aas.KeyTypes.MultiLanguageProperty }, - { "Operation", Aas.KeyTypes.Operation }, - { "Property", Aas.KeyTypes.Property }, - { "Range", Aas.KeyTypes.Range }, - { "Referable", Aas.KeyTypes.Referable }, - { "ReferenceElement", Aas.KeyTypes.ReferenceElement }, - { "RelationshipElement", Aas.KeyTypes.RelationshipElement }, - { "Submodel", Aas.KeyTypes.Submodel }, - { "SubmodelElement", Aas.KeyTypes.SubmodelElement }, - { "SubmodelElementCollection", Aas.KeyTypes.SubmodelElementCollection }, - { "SubmodelElementList", Aas.KeyTypes.SubmodelElementList } - }); + private static readonly Dictionary _keyTypesFromString = ( + new Dictionary() + { + { "AnnotatedRelationshipElement", Aas.KeyTypes.AnnotatedRelationshipElement }, + { "AssetAdministrationShell", Aas.KeyTypes.AssetAdministrationShell }, + { "BasicEventElement", Aas.KeyTypes.BasicEventElement }, + { "Blob", Aas.KeyTypes.Blob }, + { "Capability", Aas.KeyTypes.Capability }, + { "ConceptDescription", Aas.KeyTypes.ConceptDescription }, + { "DataElement", Aas.KeyTypes.DataElement }, + { "Entity", Aas.KeyTypes.Entity }, + { "EventElement", Aas.KeyTypes.EventElement }, + { "File", Aas.KeyTypes.File }, + { "FragmentReference", Aas.KeyTypes.FragmentReference }, + { "GlobalReference", Aas.KeyTypes.GlobalReference }, + { "Identifiable", Aas.KeyTypes.Identifiable }, + { "MultiLanguageProperty", Aas.KeyTypes.MultiLanguageProperty }, + { "Operation", Aas.KeyTypes.Operation }, + { "Property", Aas.KeyTypes.Property }, + { "Range", Aas.KeyTypes.Range }, + { "Referable", Aas.KeyTypes.Referable }, + { "ReferenceElement", Aas.KeyTypes.ReferenceElement }, + { "RelationshipElement", Aas.KeyTypes.RelationshipElement }, + { "Submodel", Aas.KeyTypes.Submodel }, + { "SubmodelElement", Aas.KeyTypes.SubmodelElement }, + { "SubmodelElementCollection", Aas.KeyTypes.SubmodelElementCollection }, + { "SubmodelElementList", Aas.KeyTypes.SubmodelElementList } + }); /// /// Parse the string representation of . @@ -631,7 +631,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.KeyTypes? KeyTypesFromString(string? text) + public static Aas.KeyTypes? KeyTypesFromString(string text) { if (_keyTypesFromString.TryGetValue(text, out KeyTypes value)) { @@ -704,40 +704,40 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _dataTypeDefXsdFromString = ( - new Dictionary() - { - { "xs:anyURI", Aas.DataTypeDefXsd.AnyUri }, - { "xs:base64Binary", Aas.DataTypeDefXsd.Base64Binary }, - { "xs:boolean", Aas.DataTypeDefXsd.Boolean }, - { "xs:byte", Aas.DataTypeDefXsd.Byte }, - { "xs:date", Aas.DataTypeDefXsd.Date }, - { "xs:dateTime", Aas.DataTypeDefXsd.DateTime }, - { "xs:decimal", Aas.DataTypeDefXsd.Decimal }, - { "xs:double", Aas.DataTypeDefXsd.Double }, - { "xs:duration", Aas.DataTypeDefXsd.Duration }, - { "xs:float", Aas.DataTypeDefXsd.Float }, - { "xs:gDay", Aas.DataTypeDefXsd.GDay }, - { "xs:gMonth", Aas.DataTypeDefXsd.GMonth }, - { "xs:gMonthDay", Aas.DataTypeDefXsd.GMonthDay }, - { "xs:gYear", Aas.DataTypeDefXsd.GYear }, - { "xs:gYearMonth", Aas.DataTypeDefXsd.GYearMonth }, - { "xs:hexBinary", Aas.DataTypeDefXsd.HexBinary }, - { "xs:int", Aas.DataTypeDefXsd.Int }, - { "xs:integer", Aas.DataTypeDefXsd.Integer }, - { "xs:long", Aas.DataTypeDefXsd.Long }, - { "xs:negativeInteger", Aas.DataTypeDefXsd.NegativeInteger }, - { "xs:nonNegativeInteger", Aas.DataTypeDefXsd.NonNegativeInteger }, - { "xs:nonPositiveInteger", Aas.DataTypeDefXsd.NonPositiveInteger }, - { "xs:positiveInteger", Aas.DataTypeDefXsd.PositiveInteger }, - { "xs:short", Aas.DataTypeDefXsd.Short }, - { "xs:string", Aas.DataTypeDefXsd.String }, - { "xs:time", Aas.DataTypeDefXsd.Time }, - { "xs:unsignedByte", Aas.DataTypeDefXsd.UnsignedByte }, - { "xs:unsignedInt", Aas.DataTypeDefXsd.UnsignedInt }, - { "xs:unsignedLong", Aas.DataTypeDefXsd.UnsignedLong }, - { "xs:unsignedShort", Aas.DataTypeDefXsd.UnsignedShort } - }); + private static readonly Dictionary _dataTypeDefXsdFromString = ( + new Dictionary() + { + { "xs:anyURI", Aas.DataTypeDefXsd.AnyUri }, + { "xs:base64Binary", Aas.DataTypeDefXsd.Base64Binary }, + { "xs:boolean", Aas.DataTypeDefXsd.Boolean }, + { "xs:byte", Aas.DataTypeDefXsd.Byte }, + { "xs:date", Aas.DataTypeDefXsd.Date }, + { "xs:dateTime", Aas.DataTypeDefXsd.DateTime }, + { "xs:decimal", Aas.DataTypeDefXsd.Decimal }, + { "xs:double", Aas.DataTypeDefXsd.Double }, + { "xs:duration", Aas.DataTypeDefXsd.Duration }, + { "xs:float", Aas.DataTypeDefXsd.Float }, + { "xs:gDay", Aas.DataTypeDefXsd.GDay }, + { "xs:gMonth", Aas.DataTypeDefXsd.GMonth }, + { "xs:gMonthDay", Aas.DataTypeDefXsd.GMonthDay }, + { "xs:gYear", Aas.DataTypeDefXsd.GYear }, + { "xs:gYearMonth", Aas.DataTypeDefXsd.GYearMonth }, + { "xs:hexBinary", Aas.DataTypeDefXsd.HexBinary }, + { "xs:int", Aas.DataTypeDefXsd.Int }, + { "xs:integer", Aas.DataTypeDefXsd.Integer }, + { "xs:long", Aas.DataTypeDefXsd.Long }, + { "xs:negativeInteger", Aas.DataTypeDefXsd.NegativeInteger }, + { "xs:nonNegativeInteger", Aas.DataTypeDefXsd.NonNegativeInteger }, + { "xs:nonPositiveInteger", Aas.DataTypeDefXsd.NonPositiveInteger }, + { "xs:positiveInteger", Aas.DataTypeDefXsd.PositiveInteger }, + { "xs:short", Aas.DataTypeDefXsd.Short }, + { "xs:string", Aas.DataTypeDefXsd.String }, + { "xs:time", Aas.DataTypeDefXsd.Time }, + { "xs:unsignedByte", Aas.DataTypeDefXsd.UnsignedByte }, + { "xs:unsignedInt", Aas.DataTypeDefXsd.UnsignedInt }, + { "xs:unsignedLong", Aas.DataTypeDefXsd.UnsignedLong }, + { "xs:unsignedShort", Aas.DataTypeDefXsd.UnsignedShort } + }); /// /// Parse the string representation of . @@ -747,7 +747,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.DataTypeDefXsd? DataTypeDefXsdFromString(string? text) + public static Aas.DataTypeDefXsd? DataTypeDefXsdFromString(string text) { if (_dataTypeDefXsdFromString.TryGetValue(text, out DataTypeDefXsd value)) { @@ -809,29 +809,29 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _dataTypeIec61360FromString = ( - new Dictionary() - { - { "DATE", Aas.DataTypeIec61360.Date }, - { "STRING", Aas.DataTypeIec61360.String }, - { "STRING_TRANSLATABLE", Aas.DataTypeIec61360.StringTranslatable }, - { "INTEGER_MEASURE", Aas.DataTypeIec61360.IntegerMeasure }, - { "INTEGER_COUNT", Aas.DataTypeIec61360.IntegerCount }, - { "INTEGER_CURRENCY", Aas.DataTypeIec61360.IntegerCurrency }, - { "REAL_MEASURE", Aas.DataTypeIec61360.RealMeasure }, - { "REAL_COUNT", Aas.DataTypeIec61360.RealCount }, - { "REAL_CURRENCY", Aas.DataTypeIec61360.RealCurrency }, - { "BOOLEAN", Aas.DataTypeIec61360.Boolean }, - { "IRI", Aas.DataTypeIec61360.Iri }, - { "IRDI", Aas.DataTypeIec61360.Irdi }, - { "RATIONAL", Aas.DataTypeIec61360.Rational }, - { "RATIONAL_MEASURE", Aas.DataTypeIec61360.RationalMeasure }, - { "TIME", Aas.DataTypeIec61360.Time }, - { "TIMESTAMP", Aas.DataTypeIec61360.Timestamp }, - { "FILE", Aas.DataTypeIec61360.File }, - { "HTML", Aas.DataTypeIec61360.Html }, - { "BLOB", Aas.DataTypeIec61360.Blob } - }); + private static readonly Dictionary _dataTypeIec61360FromString = ( + new Dictionary() + { + { "DATE", Aas.DataTypeIec61360.Date }, + { "STRING", Aas.DataTypeIec61360.String }, + { "STRING_TRANSLATABLE", Aas.DataTypeIec61360.StringTranslatable }, + { "INTEGER_MEASURE", Aas.DataTypeIec61360.IntegerMeasure }, + { "INTEGER_COUNT", Aas.DataTypeIec61360.IntegerCount }, + { "INTEGER_CURRENCY", Aas.DataTypeIec61360.IntegerCurrency }, + { "REAL_MEASURE", Aas.DataTypeIec61360.RealMeasure }, + { "REAL_COUNT", Aas.DataTypeIec61360.RealCount }, + { "REAL_CURRENCY", Aas.DataTypeIec61360.RealCurrency }, + { "BOOLEAN", Aas.DataTypeIec61360.Boolean }, + { "IRI", Aas.DataTypeIec61360.Iri }, + { "IRDI", Aas.DataTypeIec61360.Irdi }, + { "RATIONAL", Aas.DataTypeIec61360.Rational }, + { "RATIONAL_MEASURE", Aas.DataTypeIec61360.RationalMeasure }, + { "TIME", Aas.DataTypeIec61360.Time }, + { "TIMESTAMP", Aas.DataTypeIec61360.Timestamp }, + { "FILE", Aas.DataTypeIec61360.File }, + { "HTML", Aas.DataTypeIec61360.Html }, + { "BLOB", Aas.DataTypeIec61360.Blob } + }); /// /// Parse the string representation of . @@ -841,7 +841,7 @@ public static class Stringification /// of a literal of , /// return null. /// - public static Aas.DataTypeIec61360? DataTypeIec61360FromString(string? text) + public static Aas.DataTypeIec61360? DataTypeIec61360FromString(string text) { if (_dataTypeIec61360FromString.TryGetValue(text, out DataTypeIec61360 value)) { diff --git a/src/AasCore.Aas3_0/types.cs b/src/AasCore.Aas3_0/types.cs index 00278144c..352cc5525 100644 --- a/src/AasCore.Aas3_0/types.cs +++ b/src/AasCore.Aas3_0/types.cs @@ -15,17 +15,15 @@ * This code has been automatically generated by aas-core-codegen. * Do NOT edit or append. */ - +using AdminShellNS.DiaryData; +using Newtonsoft.Json; using System; -using System.Collections.Generic; -using System.Linq; // can't alias -using Aas = AasCore.Aas3_0; // renamed +using System.Collections.Generic; // can't alias +using Aas = AasCore.Aas3_0; // renamed using EnumMemberAttribute = System.Runtime.Serialization.EnumMemberAttribute; namespace AasCore.Aas3_0 { - using System.Text.Json.Serialization; - /// /// Represent a general class of an AAS model. /// @@ -133,7 +131,7 @@ public interface IExtension : IHasSemantics /// /// /// - public string? Name { get; set; } + public string Name { get; set; } /// /// Type of the value of the extension. @@ -199,7 +197,7 @@ public class Extension : IExtension /// /// /// - public string? Name { get; set; } + public string Name { get; set; } /// /// Type of the value of the extension. @@ -225,7 +223,7 @@ public class Extension : IExtension public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -234,7 +232,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverRefersToOrEmpty() { return RefersTo - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -360,19 +358,19 @@ public T Transform( } public Extension( - string? name, + string name, IReference? semanticId = null, List? supplementalSemanticIds = null, DataTypeDefXsd? valueType = null, string? value = null, List? refersTo = null) { - SemanticId = semanticId; + SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; - Name = name; - ValueType = valueType; - Value = value; - RefersTo = refersTo; + Name = name; + ValueType = valueType; + Value = value; + RefersTo = refersTo; } } @@ -402,7 +400,7 @@ public interface IHasExtensions : IClass /// This ID is not globally unique. /// This ID is unique within the name space of the element. /// - public interface IReferable : IHasExtensions + public interface IReferable : IHasExtensions, IDiaryData { /// /// The category is a value that gives further meta information @@ -456,16 +454,17 @@ public interface IReferable : IHasExtensions public List? Description { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp - - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } #endregion @@ -497,7 +496,7 @@ public interface IIdentifiable : IReferable /// /// The globally unique identification of the element. /// - public string? Id { get; set; } + public string Id { get; set; } } /// @@ -509,13 +508,15 @@ public enum ModellingKind /// Specification of the common features of a structured element in sufficient detail /// that such a instance can be instantiated using it /// - [ EnumMember(Value = "Template") ] Template, + [EnumMember(Value = "Template")] + Template, /// /// Concrete, clearly identifiable element instance. Its creation and validation /// may be guided by a corresponding element template. /// - [ EnumMember(Value = "Instance") ] Instance + [EnumMember(Value = "Instance")] + Instance } /// @@ -630,7 +631,7 @@ public interface IAdministrativeInformation : IHasDataSpecification /// /// /// - public class AdministrativeInformation : IAdministrativeInformation, IEquatable + public class AdministrativeInformation : IAdministrativeInformation { /// /// Embedded data specification. @@ -677,7 +678,7 @@ public class AdministrativeInformation : IAdministrativeInformation, IEquatable< public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -779,78 +780,10 @@ public AdministrativeInformation( string? templateId = null) { EmbeddedDataSpecifications = embeddedDataSpecifications; - Version = version; - Revision = revision; - Creator = creator; - TemplateId = templateId; - } - - - public override bool Equals(object? obj) - { - if (obj == null || !(obj is AdministrativeInformation)) - return false; - - return Equals((AdministrativeInformation) obj); - } - - public bool Equals(AdministrativeInformation? other) - { - if (other == null) - return false; - - // Compare all relevant properties for equality - return EqualsLists(EmbeddedDataSpecifications, other.EmbeddedDataSpecifications) && - Version == other.Version && - Revision == other.Revision && - Equals(Creator, other.Creator) && - TemplateId == other.TemplateId; - } - - private bool EqualsLists(List? list1, List? list2) - { - if (list1 == null && list2 == null) - return true; - if (list1 == null || list2 == null) - return false; - if (list1.Count != list2.Count) - return false; - for (int i = 0; i < list1.Count; i++) - { - if (!EqualityComparer.Default.Equals(list1[ i ], list2[ i ])) - return false; - } - - return true; - } - - public override int GetHashCode() - { - // Calculate hash code based on all relevant properties - unchecked - { - int hashCode = 17; - hashCode = (hashCode * 23) + (EmbeddedDataSpecifications != null ? GetListHashCode(EmbeddedDataSpecifications) : 0); - hashCode = (hashCode * 23) + (Version != null ? Version.GetHashCode() : 0); - hashCode = (hashCode * 23) + (Revision != null ? Revision.GetHashCode() : 0); - hashCode = (hashCode * 23) + (Creator != null ? Creator.GetHashCode() : 0); - hashCode = (hashCode * 23) + (TemplateId != null ? TemplateId.GetHashCode() : 0); - return hashCode; - } - } - - private int GetListHashCode(List list) - { - unchecked - { - int hash = 17; - foreach (var item in list) - { - hash = hash * 23 + (item?.GetHashCode() ?? 0); - } - - return hash; - } + Version = version; + Revision = revision; + Creator = creator; + TemplateId = templateId; } } @@ -916,14 +849,14 @@ public enum QualifierKind /// Value qualifiers are only applicable to elements with kind /// . /// - [ EnumMember(Value = "ValueQualifier") ] + [EnumMember(Value = "ValueQualifier")] ValueQualifier, /// /// qualifies the semantic definition the element is referring to /// () /// - [ EnumMember(Value = "ConceptQualifier") ] + [EnumMember(Value = "ConceptQualifier")] ConceptQualifier, /// @@ -933,7 +866,7 @@ [ EnumMember(Value = "ConceptQualifier") ] /// Template qualifiers are only applicable to elements with kind /// . /// - [ EnumMember(Value = "TemplateQualifier") ] + [EnumMember(Value = "TemplateQualifier")] TemplateQualifier } @@ -975,7 +908,7 @@ public interface IQualifier : IHasSemantics /// The qualifier type describes the type of the qualifier that is applied to /// the element. /// - public string? Type { get; set; } + public string Type { get; set; } /// /// Data type of the qualifier value. @@ -1054,7 +987,7 @@ public class Qualifier : IQualifier /// The qualifier type describes the type of the qualifier that is applied to /// the element. /// - public string? Type { get; set; } + public string Type { get; set; } /// /// Data type of the qualifier value. @@ -1075,16 +1008,17 @@ public class Qualifier : IQualifier public IReference? ValueId { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp - - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } #endregion @@ -1094,7 +1028,7 @@ public class Qualifier : IQualifier public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -1214,7 +1148,7 @@ public T Transform( } public Qualifier( - string? type, + string type, DataTypeDefXsd valueType, IReference? semanticId = null, List? supplementalSemanticIds = null, @@ -1222,13 +1156,13 @@ public Qualifier( string? value = null, IReference? valueId = null) { - SemanticId = semanticId; + SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; - Type = type; - ValueType = valueType; - Kind = kind; - Value = value; - ValueId = valueId; + Type = type; + ValueType = valueType; + Kind = kind; + Value = value; + ValueId = valueId; } } @@ -1236,8 +1170,8 @@ public Qualifier( /// An asset administration shell. /// public interface IAssetAdministrationShell : - IIdentifiable, - IHasDataSpecification + IIdentifiable, + IHasDataSpecification { /// /// The reference to the AAS the AAS was derived from. @@ -1247,7 +1181,7 @@ public interface IAssetAdministrationShell : /// /// Meta-information about the asset the AAS is representing. /// - public IAssetInformation? AssetInformation { get; set; } + public IAssetInformation AssetInformation { get; set; } /// /// References to submodels of the AAS. @@ -1344,7 +1278,7 @@ public class AssetAdministrationShell : IAssetAdministrationShell /// /// The globally unique identification of the element. /// - public string? Id { get; set; } + public string Id { get; set; } /// /// Embedded data specification. @@ -1359,7 +1293,7 @@ public class AssetAdministrationShell : IAssetAdministrationShell /// /// Meta-information about the asset the AAS is representing. /// - public IAssetInformation? AssetInformation { get; set; } + public IAssetInformation AssetInformation { get; set; } /// /// References to submodels of the AAS. @@ -1378,16 +1312,23 @@ public class AssetAdministrationShell : IAssetAdministrationShell public List? Submodels { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } + + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -1397,7 +1338,7 @@ public class AssetAdministrationShell : IAssetAdministrationShell public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -1406,7 +1347,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -1415,7 +1356,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -1424,7 +1365,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -1433,7 +1374,7 @@ public IEnumerable OverEmbeddedDataSpecificationsOrE public IEnumerable OverSubmodelsOrEmpty() { return Submodels - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -1642,8 +1583,8 @@ public T Transform( } public AssetAdministrationShell( - string? id, - IAssetInformation? assetInformation, + string id, + IAssetInformation assetInformation, List? extensions = null, string? category = null, string? idShort = null, @@ -1654,17 +1595,17 @@ public AssetAdministrationShell( IReference? derivedFrom = null, List? submodels = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - Id = id; - Administration = administration; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + Id = id; + Administration = administration; EmbeddedDataSpecifications = embeddedDataSpecifications; - DerivedFrom = derivedFrom; - AssetInformation = assetInformation; - Submodels = submodels; + DerivedFrom = derivedFrom; + AssetInformation = assetInformation; + Submodels = submodels; } } @@ -1878,7 +1819,7 @@ public class AssetInformation : IAssetInformation public IEnumerable OverSpecificAssetIdsOrEmpty() { return SpecificAssetIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -1979,10 +1920,10 @@ public AssetInformation( string? assetType = null, IResource? defaultThumbnail = null) { - AssetKind = assetKind; - GlobalAssetId = globalAssetId; + AssetKind = assetKind; + GlobalAssetId = globalAssetId; SpecificAssetIds = specificAssetIds; - AssetType = assetType; + AssetType = assetType; DefaultThumbnail = defaultThumbnail; } } @@ -1999,7 +1940,7 @@ public interface IResource : IClass /// /// The path can be absolute or relative. /// - public string? Path { get; set; } + public string Path { get; set; } /// /// Content type of the content of the file. @@ -2022,7 +1963,7 @@ public class Resource : IResource /// /// The path can be absolute or relative. /// - public string? Path { get; set; } + public string Path { get; set; } /// /// Content type of the content of the file. @@ -2092,10 +2033,10 @@ public T Transform( } public Resource( - string? path, + string path, string? contentType = null) { - Path = path; + Path = path; ContentType = contentType; } } @@ -2108,17 +2049,19 @@ public enum AssetKind /// /// Type asset /// - [ EnumMember(Value = "Type") ] Type, + [EnumMember(Value = "Type")] + Type, /// /// Instance asset /// - [ EnumMember(Value = "Instance") ] Instance, + [EnumMember(Value = "Instance")] + Instance, /// /// Neither a type asset nor an instance asset /// - [ EnumMember(Value = "NotApplicable") ] + [EnumMember(Value = "NotApplicable")] NotApplicable } @@ -2146,12 +2089,12 @@ public interface ISpecificAssetId : IHasSemantics /// /// Name of the identifier /// - public string? Name { get; set; } + public string Name { get; set; } /// /// The value of the specific asset identifier with the corresponding name. /// - public string? Value { get; set; } + public string Value { get; set; } /// /// The (external) subject the key belongs to or has meaning to. @@ -2204,12 +2147,12 @@ public class SpecificAssetId : ISpecificAssetId /// /// Name of the identifier /// - public string? Name { get; set; } + public string Name { get; set; } /// /// The value of the specific asset identifier with the corresponding name. /// - public string? Value { get; set; } + public string Value { get; set; } /// /// The (external) subject the key belongs to or has meaning to. @@ -2225,7 +2168,7 @@ public class SpecificAssetId : ISpecificAssetId public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -2336,17 +2279,17 @@ public T Transform( } public SpecificAssetId( - string? name, - string? value, + string name, + string value, IReference? semanticId = null, List? supplementalSemanticIds = null, IReference? externalSubjectId = null) { - SemanticId = semanticId; + SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; - Name = name; - Value = value; - ExternalSubjectId = externalSubjectId; + Name = name; + Value = value; + ExternalSubjectId = externalSubjectId; } } @@ -2360,11 +2303,11 @@ public SpecificAssetId( /// standardized and, thus, become submodels templates. /// public interface ISubmodel : - IIdentifiable, - IHasKind, - IHasSemantics, - IQualifiable, - IHasDataSpecification + IIdentifiable, + IHasKind, + IHasSemantics, + IQualifiable, + IHasDataSpecification { /// /// A submodel consists of zero or more submodel elements. @@ -2456,7 +2399,7 @@ public class Submodel : ISubmodel /// /// The globally unique identification of the element. /// - public string? Id { get; set; } + public string Id { get; set; } /// /// Kind of the element: either type or instance. @@ -2512,16 +2455,23 @@ public class Submodel : ISubmodel public List? SubmodelElements { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } + + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -2531,7 +2481,7 @@ public class Submodel : ISubmodel public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -2540,7 +2490,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -2549,7 +2499,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -2558,7 +2508,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -2567,7 +2517,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -2576,7 +2526,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -2585,7 +2535,7 @@ public IEnumerable OverEmbeddedDataSpecificationsOrE public IEnumerable OverSubmodelElementsOrEmpty() { return SubmodelElements - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -2837,7 +2787,7 @@ public T Transform( } public Submodel( - string? id, + string id, List? extensions = null, string? category = null, string? idShort = null, @@ -2851,19 +2801,19 @@ public Submodel( List? embeddedDataSpecifications = null, List? submodelElements = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - Id = id; - Administration = administration; - Kind = kind; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + Id = id; + Administration = administration; + Kind = kind; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - SubmodelElements = submodelElements; + SubmodelElements = submodelElements; } } @@ -2890,10 +2840,10 @@ public Submodel( /// /// public interface ISubmodelElement : - IReferable, - IHasSemantics, - IQualifiable, - IHasDataSpecification + IReferable, + IHasSemantics, + IQualifiable, + IHasDataSpecification { // Intentionally empty. } @@ -2907,12 +2857,12 @@ public interface IRelationshipElement : ISubmodelElement /// /// Reference to the first element in the relationship taking the role of the subject. /// - public IReference? First { get; set; } + public IReference First { get; set; } /// /// Reference to the second element in the relationship taking the role of the object. /// - public IReference? Second { get; set; } + public IReference Second { get; set; } } /// @@ -3020,24 +2970,31 @@ public class RelationshipElement : IRelationshipElement /// /// Reference to the first element in the relationship taking the role of the subject. /// - public IReference? First { get; set; } + public IReference First { get; set; } /// /// Reference to the second element in the relationship taking the role of the object. /// - public IReference? Second { get; set; } + public IReference Second { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); + + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -3047,7 +3004,7 @@ public class RelationshipElement : IRelationshipElement public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3056,7 +3013,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3065,7 +3022,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3074,7 +3031,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3083,7 +3040,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3092,7 +3049,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3317,8 +3274,8 @@ public T Transform( } public RelationshipElement( - IReference? first, - IReference? second, + IReference first, + IReference second, List? extensions = null, string? category = null, string? idShort = null, @@ -3329,17 +3286,17 @@ public RelationshipElement( List? qualifiers = null, List? embeddedDataSpecifications = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - First = first; - Second = second; + First = first; + Second = second; } } @@ -3348,46 +3305,55 @@ public RelationshipElement( /// public enum AasSubmodelElements { - [ EnumMember(Value = "AnnotatedRelationshipElement") ] + [EnumMember(Value = "AnnotatedRelationshipElement")] AnnotatedRelationshipElement, - [ EnumMember(Value = "BasicEventElement") ] + [EnumMember(Value = "BasicEventElement")] BasicEventElement, - [ EnumMember(Value = "Blob") ] Blob, + [EnumMember(Value = "Blob")] + Blob, - [ EnumMember(Value = "Capability") ] Capability, + [EnumMember(Value = "Capability")] + Capability, - [ EnumMember(Value = "DataElement") ] DataElement, + [EnumMember(Value = "DataElement")] + DataElement, - [ EnumMember(Value = "Entity") ] Entity, + [EnumMember(Value = "Entity")] + Entity, - [ EnumMember(Value = "EventElement") ] EventElement, + [EnumMember(Value = "EventElement")] + EventElement, - [ EnumMember(Value = "File") ] File, + [EnumMember(Value = "File")] + File, - [ EnumMember(Value = "MultiLanguageProperty") ] + [EnumMember(Value = "MultiLanguageProperty")] MultiLanguageProperty, - [ EnumMember(Value = "Operation") ] Operation, + [EnumMember(Value = "Operation")] + Operation, - [ EnumMember(Value = "Property") ] Property, + [EnumMember(Value = "Property")] + Property, - [ EnumMember(Value = "Range") ] Range, + [EnumMember(Value = "Range")] + Range, - [ EnumMember(Value = "ReferenceElement") ] + [EnumMember(Value = "ReferenceElement")] ReferenceElement, - [ EnumMember(Value = "RelationshipElement") ] + [EnumMember(Value = "RelationshipElement")] RelationshipElement, - [ EnumMember(Value = "SubmodelElement") ] + [EnumMember(Value = "SubmodelElement")] SubmodelElement, - [ EnumMember(Value = "SubmodelElementList") ] + [EnumMember(Value = "SubmodelElementList")] SubmodelElementList, - [ EnumMember(Value = "SubmodelElementCollection") ] + [EnumMember(Value = "SubmodelElementCollection")] SubmodelElementCollection } @@ -3658,16 +3624,23 @@ public class SubmodelElementList : ISubmodelElementList public List? Value { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } + + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -3677,7 +3650,7 @@ public class SubmodelElementList : ISubmodelElementList public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3686,7 +3659,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3695,7 +3668,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3704,7 +3677,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3713,7 +3686,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3722,7 +3695,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3731,7 +3704,7 @@ public IEnumerable OverEmbeddedDataSpecificationsOrE public IEnumerable OverValueOrEmpty() { return Value - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -3998,20 +3971,20 @@ public SubmodelElementList( DataTypeDefXsd? valueTypeListElement = null, List? value = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - TypeValueListElement = typeValueListElement; - OrderRelevant = orderRelevant; - SemanticIdListElement = semanticIdListElement; - ValueTypeListElement = valueTypeListElement; - Value = value; + TypeValueListElement = typeValueListElement; + OrderRelevant = orderRelevant; + SemanticIdListElement = semanticIdListElement; + ValueTypeListElement = valueTypeListElement; + Value = value; } } @@ -4140,16 +4113,23 @@ public class SubmodelElementCollection : ISubmodelElementCollection public List? Value { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } + + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -4159,7 +4139,7 @@ public class SubmodelElementCollection : ISubmodelElementCollection public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4168,7 +4148,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4177,7 +4157,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4186,7 +4166,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4195,7 +4175,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4204,7 +4184,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4213,7 +4193,7 @@ public IEnumerable OverEmbeddedDataSpecificationsOrE public IEnumerable OverValueOrEmpty() { return Value - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4451,16 +4431,16 @@ public SubmodelElementCollection( List? embeddedDataSpecifications = null, List? value = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - Value = value; + Value = value; } } @@ -4664,16 +4644,23 @@ public class Property : IProperty public IReference? ValueId { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } + + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -4683,7 +4670,7 @@ public class Property : IProperty public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4692,7 +4679,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4701,7 +4688,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4710,7 +4697,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4719,7 +4706,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4728,7 +4715,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -4983,18 +4970,18 @@ public Property( string? value = null, IReference? valueId = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - ValueType = valueType; - Value = value; - ValueId = valueId; + ValueType = valueType; + Value = value; + ValueId = valueId; } } @@ -5161,18 +5148,24 @@ public class MultiLanguageProperty : IMultiLanguageProperty /// It is recommended to use a global reference. /// public IReference? ValueId { get; set; } - #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); + + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -5182,7 +5175,7 @@ public class MultiLanguageProperty : IMultiLanguageProperty public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5191,7 +5184,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5200,7 +5193,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5209,7 +5202,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5218,7 +5211,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5227,7 +5220,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5236,7 +5229,7 @@ public IEnumerable OverEmbeddedDataSpecificationsOrE public IEnumerable OverValueOrEmpty() { return Value - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5512,17 +5505,17 @@ public MultiLanguageProperty( List? value = null, IReference? valueId = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - Value = value; - ValueId = valueId; + Value = value; + ValueId = valueId; } } @@ -5676,16 +5669,23 @@ public class Range : IRange public string? Max { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } + + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -5695,7 +5695,7 @@ public class Range : IRange public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5704,7 +5704,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5713,7 +5713,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5722,7 +5722,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5731,7 +5731,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5740,7 +5740,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -5979,18 +5979,18 @@ public Range( string? min = null, string? max = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - ValueType = valueType; - Min = min; - Max = max; + ValueType = valueType; + Min = min; + Max = max; } } @@ -6120,16 +6120,23 @@ public class ReferenceElement : IReferenceElement public IReference? Value { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); + + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -6139,7 +6146,7 @@ public class ReferenceElement : IReferenceElement public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6148,7 +6155,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6157,7 +6164,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6166,7 +6173,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6175,7 +6182,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6184,7 +6191,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6437,16 +6444,16 @@ public ReferenceElement( List? embeddedDataSpecifications = null, IReference? value = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - Value = value; + Value = value; } } @@ -6480,7 +6487,7 @@ public interface IBlob : IDataElement /// The allowed values are defined as in RFC2046. /// /// - public string? ContentType { get; set; } + public string ContentType { get; set; } } /// @@ -6609,19 +6616,25 @@ public class Blob : IBlob /// The allowed values are defined as in RFC2046. /// /// - public string? ContentType { get; set; } - + public string ContentType { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } + + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -6631,7 +6644,7 @@ public class Blob : IBlob public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6640,7 +6653,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6649,7 +6662,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6658,7 +6671,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6667,7 +6680,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6676,7 +6689,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -6902,7 +6915,7 @@ public T Transform( } public Blob( - string? contentType, + string contentType, List? extensions = null, string? category = null, string? idShort = null, @@ -6914,17 +6927,17 @@ public Blob( List? embeddedDataSpecifications = null, byte[]? value = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - ContentType = contentType; - Value = value; + ContentType = contentType; + Value = value; } } @@ -6950,7 +6963,7 @@ public interface IFile : IDataElement /// /// The content type states which file extensions the file can have. /// - public string? ContentType { get; set; } + public string ContentType { get; set; } } /// @@ -7071,19 +7084,25 @@ public class File : IFile /// /// The content type states which file extensions the file can have. /// - public string? ContentType { get; set; } - + public string ContentType { get; set; } #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } + + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -7093,7 +7112,7 @@ public class File : IFile public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7102,7 +7121,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7111,7 +7130,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7120,7 +7139,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7129,7 +7148,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7138,7 +7157,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7364,7 +7383,7 @@ public T Transform( } public File( - string? contentType, + string contentType, List? extensions = null, string? category = null, string? idShort = null, @@ -7376,17 +7395,17 @@ public File( List? embeddedDataSpecifications = null, string? value = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - ContentType = contentType; - Value = value; + ContentType = contentType; + Value = value; } } @@ -7513,30 +7532,36 @@ public class AnnotatedRelationshipElement : IAnnotatedRelationshipElement /// /// Reference to the first element in the relationship taking the role of the subject. /// - public IReference? First { get; set; } + public IReference First { get; set; } /// /// Reference to the second element in the relationship taking the role of the object. /// - public IReference? Second { get; set; } + public IReference Second { get; set; } /// /// A data element that represents an annotation that holds for the relationship /// between the two elements /// public List? Annotations { get; set; } - #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); + + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -7546,7 +7571,7 @@ public class AnnotatedRelationshipElement : IAnnotatedRelationshipElement public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7555,7 +7580,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7564,7 +7589,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7573,7 +7598,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7582,7 +7607,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7591,7 +7616,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7600,7 +7625,7 @@ public IEnumerable OverEmbeddedDataSpecificationsOrE public IEnumerable OverAnnotationsOrEmpty() { return Annotations - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -7847,8 +7872,8 @@ public T Transform( } public AnnotatedRelationshipElement( - IReference? first, - IReference? second, + IReference first, + IReference second, List? extensions = null, string? category = null, string? idShort = null, @@ -7860,18 +7885,18 @@ public AnnotatedRelationshipElement( List? embeddedDataSpecifications = null, List? annotations = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - First = first; - Second = second; - Annotations = annotations; + First = first; + Second = second; + Annotations = annotations; } } @@ -8067,18 +8092,24 @@ public class Entity : IEntity /// of the asset represented by the Asset Administration Shell. /// public List? SpecificAssetIds { get; set; } - #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } + + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -8088,7 +8119,7 @@ public class Entity : IEntity public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -8097,7 +8128,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -8106,7 +8137,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -8115,7 +8146,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -8124,7 +8155,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -8133,7 +8164,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -8142,7 +8173,7 @@ public IEnumerable OverEmbeddedDataSpecificationsOrE public IEnumerable OverStatementsOrEmpty() { return Statements - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -8151,7 +8182,7 @@ public IEnumerable OverStatementsOrEmpty() public IEnumerable OverSpecificAssetIdsOrEmpty() { return SpecificAssetIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -8414,19 +8445,19 @@ public Entity( string? globalAssetId = null, List? specificAssetIds = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - Statements = statements; - EntityType = entityType; - GlobalAssetId = globalAssetId; - SpecificAssetIds = specificAssetIds; + Statements = statements; + EntityType = entityType; + GlobalAssetId = globalAssetId; + SpecificAssetIds = specificAssetIds; } } @@ -8440,7 +8471,7 @@ public enum EntityType /// For co-managed entities there is no separate AAS. Co-managed entities need to be /// part of a self-managed entity. /// - [ EnumMember(Value = "CoManagedEntity") ] + [EnumMember(Value = "CoManagedEntity")] CoManagedEntity, /// @@ -8450,7 +8481,7 @@ [ EnumMember(Value = "CoManagedEntity") ] /// /// The asset of an I4.0 Component is a self-managed entity per definition. /// - [ EnumMember(Value = "SelfManagedEntity") ] + [EnumMember(Value = "SelfManagedEntity")] SelfManagedEntity } @@ -8466,12 +8497,14 @@ public enum Direction /// /// Input direction. /// - [ EnumMember(Value = "input") ] Input, + [EnumMember(Value = "input")] + Input, /// /// Output direction /// - [ EnumMember(Value = "output") ] Output + [EnumMember(Value = "output")] + Output } /// @@ -8486,12 +8519,14 @@ public enum StateOfEvent /// /// Event is on /// - [ EnumMember(Value = "on") ] On, + [EnumMember(Value = "on")] + On, /// /// Event is off. /// - [ EnumMember(Value = "off") ] Off + [EnumMember(Value = "off")] + Off } /// @@ -8508,7 +8543,7 @@ public interface IEventPayload : IClass /// , , /// 's. /// - public IReference? Source { get; set; } + public IReference Source { get; set; } /// /// of the source event element, if available @@ -8525,7 +8560,7 @@ public interface IEventPayload : IClass /// Can be , or /// . /// - public IReference? ObservableReference { get; set; } + public IReference ObservableReference { get; set; } /// /// of the referable which defines the scope of @@ -8553,7 +8588,7 @@ public interface IEventPayload : IClass /// /// Timestamp in UTC, when this event was triggered. /// - public string? TimeStamp { get; set; } + public string TimeStamp { get; set; } /// /// Event specific payload. @@ -8575,7 +8610,7 @@ public class EventPayload : IEventPayload /// , , /// 's. /// - public IReference? Source { get; set; } + public IReference Source { get; set; } /// /// of the source event element, if available @@ -8592,7 +8627,7 @@ public class EventPayload : IEventPayload /// Can be , or /// . /// - public IReference? ObservableReference { get; set; } + public IReference ObservableReference { get; set; } /// /// of the referable which defines the scope of @@ -8620,7 +8655,7 @@ public class EventPayload : IEventPayload /// /// Timestamp in UTC, when this event was triggered. /// - public string? TimeStamp { get; set; } + public string TimeStamp { get; set; } /// /// Event specific payload. @@ -8749,23 +8784,23 @@ public T Transform( } public EventPayload( - IReference? source, - IReference? observableReference, - string? timeStamp, + IReference source, + IReference observableReference, + string timeStamp, IReference? sourceSemanticId = null, IReference? observableSemanticId = null, string? topic = null, IReference? subjectId = null, byte[]? payload = null) { - Source = source; - ObservableReference = observableReference; - TimeStamp = timeStamp; - SourceSemanticId = sourceSemanticId; + Source = source; + ObservableReference = observableReference; + TimeStamp = timeStamp; + SourceSemanticId = sourceSemanticId; ObservableSemanticId = observableSemanticId; - Topic = topic; - SubjectId = subjectId; - Payload = payload; + Topic = topic; + SubjectId = subjectId; + Payload = payload; } } @@ -8799,7 +8834,7 @@ public interface IBasicEventElement : IEventElement /// Reference to a referable, e.g., a data element or /// a submodel, that is being observed. /// - public IReference? Observed { get; set; } + public IReference Observed { get; set; } /// /// Direction of event. @@ -8987,7 +9022,7 @@ public class BasicEventElement : IBasicEventElement /// Reference to a referable, e.g., a data element or /// a submodel, that is being observed. /// - public IReference? Observed { get; set; } + public IReference Observed { get; set; } /// /// Direction of event. @@ -9059,18 +9094,24 @@ public class BasicEventElement : IBasicEventElement /// /// public string? MaxInterval { get; set; } - #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); + + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -9080,7 +9121,7 @@ public class BasicEventElement : IBasicEventElement public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9089,7 +9130,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9098,7 +9139,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9107,7 +9148,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9116,7 +9157,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9125,7 +9166,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9356,7 +9397,7 @@ public T Transform( } public BasicEventElement( - IReference? observed, + IReference observed, Direction direction, StateOfEvent state, List? extensions = null, @@ -9374,23 +9415,23 @@ public BasicEventElement( string? minInterval = null, string? maxInterval = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - Observed = observed; - Direction = direction; - State = state; - MessageTopic = messageTopic; - MessageBroker = messageBroker; - LastUpdate = lastUpdate; - MinInterval = minInterval; - MaxInterval = maxInterval; + Observed = observed; + Direction = direction; + State = state; + MessageTopic = messageTopic; + MessageBroker = messageBroker; + LastUpdate = lastUpdate; + MinInterval = minInterval; + MaxInterval = maxInterval; } } @@ -9573,18 +9614,24 @@ public class Operation : IOperation /// Parameter that is input and output of the operation. /// public List? InoutputVariables { get; set; } - #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); + + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -9594,7 +9641,7 @@ public class Operation : IOperation public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9603,7 +9650,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9612,7 +9659,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9621,7 +9668,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9630,7 +9677,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9639,7 +9686,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9648,7 +9695,7 @@ public IEnumerable OverEmbeddedDataSpecificationsOrE public IEnumerable OverInputVariablesOrEmpty() { return InputVariables - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9657,7 +9704,7 @@ public IEnumerable OverInputVariablesOrEmpty() public IEnumerable OverOutputVariablesOrEmpty() { return OutputVariables - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9666,7 +9713,7 @@ public IEnumerable OverOutputVariablesOrEmpty() public IEnumerable OverInoutputVariablesOrEmpty() { return InoutputVariables - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -9950,18 +9997,18 @@ public Operation( List? outputVariables = null, List? inoutputVariables = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; - InputVariables = inputVariables; - OutputVariables = outputVariables; - InoutputVariables = inoutputVariables; + InputVariables = inputVariables; + OutputVariables = outputVariables; + InoutputVariables = inoutputVariables; } } @@ -9974,7 +10021,7 @@ public interface IOperationVariable : IClass /// /// Describes an argument or result of an operation via a submodel element /// - public ISubmodelElement? Value { get; set; } + public ISubmodelElement Value { get; set; } } /// @@ -9986,7 +10033,7 @@ public class OperationVariable : IOperationVariable /// /// Describes an argument or result of an operation via a submodel element /// - public ISubmodelElement? Value { get; set; } + public ISubmodelElement Value { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -10051,7 +10098,7 @@ public T Transform( return transformer.TransformOperationVariable(this, context); } - public OperationVariable(ISubmodelElement? value) + public OperationVariable(ISubmodelElement value) { Value = value; } @@ -10175,18 +10222,24 @@ public class Capability : ICapability /// Embedded data specification. /// public List? EmbeddedDataSpecifications { get; set; } - #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); + + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -10196,7 +10249,7 @@ public class Capability : ICapability public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10205,7 +10258,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10214,7 +10267,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10223,7 +10276,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverSupplementalSemanticIdsOrEmpty() { return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10232,7 +10285,7 @@ public IEnumerable OverSupplementalSemanticIdsOrEmpty() public IEnumerable OverQualifiersOrEmpty() { return Qualifiers - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10241,7 +10294,7 @@ public IEnumerable OverQualifiersOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10456,14 +10509,14 @@ public Capability( List? qualifiers = null, List? embeddedDataSpecifications = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - SemanticId = semanticId; - SupplementalSemanticIds = supplementalSemanticIds; - Qualifiers = qualifiers; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + SemanticId = semanticId; + SupplementalSemanticIds = supplementalSemanticIds; + Qualifiers = qualifiers; EmbeddedDataSpecifications = embeddedDataSpecifications; } } @@ -10519,8 +10572,8 @@ public Capability( /// /// public interface IConceptDescription : - IIdentifiable, - IHasDataSpecification + IIdentifiable, + IHasDataSpecification { /// /// Reference to an external definition the concept is compatible to or was derived @@ -10662,7 +10715,7 @@ public class ConceptDescription : IConceptDescription /// /// The globally unique identification of the element. /// - public string? Id { get; set; } + public string Id { get; set; } /// /// Embedded data specification. @@ -10682,18 +10735,24 @@ public class ConceptDescription : IConceptDescription /// /// public List? IsCaseOf { get; set; } - #region Parent - - [ JsonIgnore ] public IClass? Parent { get; set; } - + [JsonIgnore] + public IClass? Parent { get; set; } #endregion #region TimeStamp + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } + [JsonIgnore] + public DateTime TimeStampTree { get; set; } + + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); - [ JsonIgnore ] public DateTime TimeStampCreate { get; set; } - [ JsonIgnore ] public DateTime TimeStamp { get; set; } - [ JsonIgnore ] public DateTime TimeStampTree { get; set; } + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } #endregion @@ -10703,7 +10762,7 @@ public class ConceptDescription : IConceptDescription public IEnumerable OverExtensionsOrEmpty() { return Extensions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10712,7 +10771,7 @@ public IEnumerable OverExtensionsOrEmpty() public IEnumerable OverDisplayNameOrEmpty() { return DisplayName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10721,7 +10780,7 @@ public IEnumerable OverDisplayNameOrEmpty() public IEnumerable OverDescriptionOrEmpty() { return Description - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10730,7 +10789,7 @@ public IEnumerable OverDescriptionOrEmpty() public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { return EmbeddedDataSpecifications - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10739,7 +10798,7 @@ public IEnumerable OverEmbeddedDataSpecificationsOrE public IEnumerable OverIsCaseOfOrEmpty() { return IsCaseOf - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -10922,7 +10981,7 @@ public T Transform( } public ConceptDescription( - string? id, + string id, List? extensions = null, string? category = null, string? idShort = null, @@ -10932,15 +10991,15 @@ public ConceptDescription( List? embeddedDataSpecifications = null, List? isCaseOf = null) { - Extensions = extensions; - IdShort = idShort; - DisplayName = displayName; - Category = category; - Description = description; - Id = id; - Administration = administration; + Extensions = extensions; + IdShort = idShort; + DisplayName = displayName; + Category = category; + Description = description; + Id = id; + Administration = administration; EmbeddedDataSpecifications = embeddedDataSpecifications; - IsCaseOf = isCaseOf; + IsCaseOf = isCaseOf; } } @@ -10952,13 +11011,13 @@ public enum ReferenceTypes /// /// External reference. /// - [ EnumMember(Value = "ExternalReference") ] + [EnumMember(Value = "ExternalReference")] ExternalReference, /// /// Model reference. /// - [ EnumMember(Value = "ModelReference") ] + [EnumMember(Value = "ModelReference")] ModelReference } @@ -11085,7 +11144,7 @@ public interface IReference : IClass /// /// Unique references in their name space. /// - public List? Keys { get; set; } + public List Keys { get; set; } } /// @@ -11184,7 +11243,7 @@ public interface IReference : IClass /// /// /// - public class Reference : IReference, IEquatable + public class Reference : IReference { /// /// Type of the reference. @@ -11211,7 +11270,7 @@ public class Reference : IReference, IEquatable /// /// Unique references in their name space. /// - public List? Keys { get; set; } + public List Keys { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -11300,48 +11359,13 @@ public T Transform( public Reference( ReferenceTypes type, - List? keys, + List keys, IReference? referredSemanticId = null) { - Type = type; - Keys = keys; + Type = type; + Keys = keys; ReferredSemanticId = referredSemanticId; } - - public override bool Equals(object? obj) - { - if (obj == null || !(obj is Reference)) - return false; - - return Equals((Reference) obj); - } - - public bool Equals(Reference? other) - { - if (other == null) - return false; - - // Compare all relevant properties for equality - return Type == other.Type && - Equals(ReferredSemanticId, other.ReferredSemanticId) && - Keys.SequenceEqual(other.Keys); // Assuming IKey implements correct equality - } - - public override int GetHashCode() - { - // Calculate hash code based on Type, ReferredSemanticId, and Keys - unchecked - { - int hashCode = (int) Type; - hashCode = (hashCode * 397) ^ (ReferredSemanticId != null ? ReferredSemanticId.GetHashCode() : 0); - foreach (var key in Keys) - { - hashCode = (hashCode * 397) ^ key.GetHashCode(); - } - - return hashCode; - } - } } /// @@ -11368,7 +11392,7 @@ public interface IKey : IClass /// /// The key value, for example an IRDI or an URI /// - public string? Value { get; set; } + public string Value { get; set; } } /// @@ -11395,7 +11419,7 @@ public class Key : IKey /// /// The key value, for example an IRDI or an URI /// - public string? Value { get; set; } + public string Value { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -11458,9 +11482,9 @@ public T Transform( public Key( KeyTypes type, - string? value) + string value) { - Type = type; + Type = type; Value = value; } } @@ -11470,20 +11494,22 @@ public Key( /// public enum KeyTypes { - [ EnumMember(Value = "AnnotatedRelationshipElement") ] + [EnumMember(Value = "AnnotatedRelationshipElement")] AnnotatedRelationshipElement, - [ EnumMember(Value = "AssetAdministrationShell") ] + [EnumMember(Value = "AssetAdministrationShell")] AssetAdministrationShell, - [ EnumMember(Value = "BasicEventElement") ] + [EnumMember(Value = "BasicEventElement")] BasicEventElement, - [ EnumMember(Value = "Blob") ] Blob, + [EnumMember(Value = "Blob")] + Blob, - [ EnumMember(Value = "Capability") ] Capability, + [EnumMember(Value = "Capability")] + Capability, - [ EnumMember(Value = "ConceptDescription") ] + [EnumMember(Value = "ConceptDescription")] ConceptDescription, /// @@ -11493,9 +11519,11 @@ [ EnumMember(Value = "ConceptDescription") ] /// Data Element is abstract, i.e. if a key uses /// the reference may be a Property, a File etc. /// - [ EnumMember(Value = "DataElement") ] DataElement, + [EnumMember(Value = "DataElement")] + DataElement, - [ EnumMember(Value = "Entity") ] Entity, + [EnumMember(Value = "Entity")] + Entity, /// /// Event. @@ -11503,18 +11531,20 @@ [ EnumMember(Value = "Entity") ] Entity, /// /// is abstract. /// - [ EnumMember(Value = "EventElement") ] EventElement, + [EnumMember(Value = "EventElement")] + EventElement, - [ EnumMember(Value = "File") ] File, + [EnumMember(Value = "File")] + File, /// /// Bookmark or a similar local identifier of a subordinate part of /// a primary resource /// - [ EnumMember(Value = "FragmentReference") ] + [EnumMember(Value = "FragmentReference")] FragmentReference, - [ EnumMember(Value = "GlobalReference") ] + [EnumMember(Value = "GlobalReference")] GlobalReference, /// @@ -11524,38 +11554,44 @@ [ EnumMember(Value = "GlobalReference") ] /// Identifiable is abstract, i.e. if a key uses “Identifiable” the reference /// may be an Asset Administration Shell, a Submodel or a Concept Description. /// - [ EnumMember(Value = "Identifiable") ] Identifiable, + [EnumMember(Value = "Identifiable")] + Identifiable, /// /// Property with a value that can be provided in multiple languages /// - [ EnumMember(Value = "MultiLanguageProperty") ] + [EnumMember(Value = "MultiLanguageProperty")] MultiLanguageProperty, - [ EnumMember(Value = "Operation") ] Operation, + [EnumMember(Value = "Operation")] + Operation, - [ EnumMember(Value = "Property") ] Property, + [EnumMember(Value = "Property")] + Property, /// /// Range with min and max /// - [ EnumMember(Value = "Range") ] Range, + [EnumMember(Value = "Range")] + Range, - [ EnumMember(Value = "Referable") ] Referable, + [EnumMember(Value = "Referable")] + Referable, /// /// Reference /// - [ EnumMember(Value = "ReferenceElement") ] + [EnumMember(Value = "ReferenceElement")] ReferenceElement, /// /// Relationship /// - [ EnumMember(Value = "RelationshipElement") ] + [EnumMember(Value = "RelationshipElement")] RelationshipElement, - [ EnumMember(Value = "Submodel") ] Submodel, + [EnumMember(Value = "Submodel")] + Submodel, /// /// Submodel Element @@ -11564,19 +11600,19 @@ [ EnumMember(Value = "Submodel") ] Submodel, /// Submodel Element is abstract, i.e. if a key uses /// the reference may be a , an etc. /// - [ EnumMember(Value = "SubmodelElement") ] + [EnumMember(Value = "SubmodelElement")] SubmodelElement, /// /// Struct of Submodel Elements /// - [ EnumMember(Value = "SubmodelElementCollection") ] + [EnumMember(Value = "SubmodelElementCollection")] SubmodelElementCollection, /// /// List of Submodel Elements /// - [ EnumMember(Value = "SubmodelElementList") ] + [EnumMember(Value = "SubmodelElementList")] SubmodelElementList } @@ -11585,74 +11621,94 @@ [ EnumMember(Value = "SubmodelElementList") ] /// public enum DataTypeDefXsd { - [ EnumMember(Value = "xs:anyURI") ] AnyUri, + [EnumMember(Value = "xs:anyURI")] + AnyUri, - [ EnumMember(Value = "xs:base64Binary") ] + [EnumMember(Value = "xs:base64Binary")] Base64Binary, - [ EnumMember(Value = "xs:boolean") ] Boolean, + [EnumMember(Value = "xs:boolean")] + Boolean, - [ EnumMember(Value = "xs:byte") ] Byte, + [EnumMember(Value = "xs:byte")] + Byte, - [ EnumMember(Value = "xs:date") ] Date, + [EnumMember(Value = "xs:date")] + Date, - [ EnumMember(Value = "xs:dateTime") ] DateTime, + [EnumMember(Value = "xs:dateTime")] + DateTime, - [ EnumMember(Value = "xs:decimal") ] Decimal, + [EnumMember(Value = "xs:decimal")] + Decimal, - [ EnumMember(Value = "xs:double") ] Double, + [EnumMember(Value = "xs:double")] + Double, - [ EnumMember(Value = "xs:duration") ] Duration, + [EnumMember(Value = "xs:duration")] + Duration, - [ EnumMember(Value = "xs:float") ] Float, + [EnumMember(Value = "xs:float")] + Float, - [ EnumMember(Value = "xs:gDay") ] GDay, + [EnumMember(Value = "xs:gDay")] + GDay, - [ EnumMember(Value = "xs:gMonth") ] GMonth, + [EnumMember(Value = "xs:gMonth")] + GMonth, - [ EnumMember(Value = "xs:gMonthDay") ] GMonthDay, + [EnumMember(Value = "xs:gMonthDay")] + GMonthDay, - [ EnumMember(Value = "xs:gYear") ] GYear, + [EnumMember(Value = "xs:gYear")] + GYear, - [ EnumMember(Value = "xs:gYearMonth") ] + [EnumMember(Value = "xs:gYearMonth")] GYearMonth, - [ EnumMember(Value = "xs:hexBinary") ] HexBinary, + [EnumMember(Value = "xs:hexBinary")] + HexBinary, - [ EnumMember(Value = "xs:int") ] Int, + [EnumMember(Value = "xs:int")] + Int, - [ EnumMember(Value = "xs:integer") ] Integer, + [EnumMember(Value = "xs:integer")] + Integer, - [ EnumMember(Value = "xs:long") ] Long, + [EnumMember(Value = "xs:long")] + Long, - [ EnumMember(Value = "xs:negativeInteger") ] + [EnumMember(Value = "xs:negativeInteger")] NegativeInteger, - [ EnumMember(Value = "xs:nonNegativeInteger") ] + [EnumMember(Value = "xs:nonNegativeInteger")] NonNegativeInteger, - [ EnumMember(Value = "xs:nonPositiveInteger") ] + [EnumMember(Value = "xs:nonPositiveInteger")] NonPositiveInteger, - [ EnumMember(Value = "xs:positiveInteger") ] + [EnumMember(Value = "xs:positiveInteger")] PositiveInteger, - [ EnumMember(Value = "xs:short") ] Short, + [EnumMember(Value = "xs:short")] + Short, - [ EnumMember(Value = "xs:string") ] String, + [EnumMember(Value = "xs:string")] + String, - [ EnumMember(Value = "xs:time") ] Time, + [EnumMember(Value = "xs:time")] + Time, - [ EnumMember(Value = "xs:unsignedByte") ] + [EnumMember(Value = "xs:unsignedByte")] UnsignedByte, - [ EnumMember(Value = "xs:unsignedInt") ] + [EnumMember(Value = "xs:unsignedInt")] UnsignedInt, - [ EnumMember(Value = "xs:unsignedLong") ] + [EnumMember(Value = "xs:unsignedLong")] UnsignedLong, - [ EnumMember(Value = "xs:unsignedShort") ] + [EnumMember(Value = "xs:unsignedShort")] UnsignedShort } @@ -11664,12 +11720,12 @@ public interface IAbstractLangString : IClass /// /// Language tag conforming to BCP 47 /// - public string? Language { get; set; } + public string Language { get; set; } /// /// Text in the /// - public string? Text { get; set; } + public string Text { get; set; } } /// @@ -11688,12 +11744,12 @@ public class LangStringNameType : ILangStringNameType /// /// Language tag conforming to BCP 47 /// - public string? Language { get; set; } + public string Language { get; set; } /// /// Text in the /// - public string? Text { get; set; } + public string Text { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -11755,11 +11811,11 @@ public T Transform( } public LangStringNameType( - string? language, - string? text) + string language, + string text) { Language = language; - Text = text; + Text = text; } } @@ -11779,12 +11835,12 @@ public class LangStringTextType : ILangStringTextType /// /// Language tag conforming to BCP 47 /// - public string? Language { get; set; } + public string Language { get; set; } /// /// Text in the /// - public string? Text { get; set; } + public string Text { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -11846,11 +11902,11 @@ public T Transform( } public LangStringTextType( - string? language, - string? text) + string language, + string text) { Language = language; - Text = text; + Text = text; } } @@ -11862,7 +11918,7 @@ public LangStringTextType( /// files the contained elements are split. If the file is split then there /// shall be no element with the same identifier in two different files. /// - public interface IEnvironment : IClass + public interface IEnvironment : IClass, IDiaryData { /// /// Asset administration shell @@ -11926,16 +11982,22 @@ public class Environment : IEnvironment public IEnumerable OverAssetAdministrationShellsOrEmpty() { return AssetAdministrationShells - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } + [JsonIgnore] + private DiaryDataDef _diaryData = new DiaryDataDef(); + + [JsonIgnore] + public DiaryDataDef DiaryData { get { return _diaryData; } } + /// /// Iterate over Submodels, if set, and otherwise return an empty enumerable. /// public IEnumerable OverSubmodelsOrEmpty() { return Submodels - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -11944,7 +12006,7 @@ public IEnumerable OverSubmodelsOrEmpty() public IEnumerable OverConceptDescriptionsOrEmpty() { return ConceptDescriptions - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -12072,8 +12134,8 @@ public Environment( List? conceptDescriptions = null) { AssetAdministrationShells = assetAdministrationShells; - Submodels = submodels; - ConceptDescriptions = conceptDescriptions; + Submodels = submodels; + ConceptDescriptions = conceptDescriptions; } } @@ -12111,12 +12173,12 @@ public interface IEmbeddedDataSpecification : IClass /// /// Reference to the data specification /// - public IReference? DataSpecification { get; set; } + public IReference DataSpecification { get; set; } /// /// Actual content of the data specification /// - public IDataSpecificationContent? DataSpecificationContent { get; set; } + public IDataSpecificationContent DataSpecificationContent { get; set; } } /// @@ -12127,12 +12189,12 @@ public class EmbeddedDataSpecification : IEmbeddedDataSpecification /// /// Reference to the data specification /// - public IReference? DataSpecification { get; set; } + public IReference DataSpecification { get; set; } /// /// Actual content of the data specification /// - public IDataSpecificationContent? DataSpecificationContent { get; set; } + public IDataSpecificationContent DataSpecificationContent { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -12161,10 +12223,12 @@ public IEnumerable Descend() yield return DataSpecificationContent; // Recurse - foreach (var anItem in DataSpecificationContent.Descend()) - { - yield return anItem; - } + // TODO (MIHO, 2023-06-05): give to AAS core + if (DataSpecificationContent != null) + foreach (var anItem in DataSpecificationContent.Descend()) + { + yield return anItem; + } } /// @@ -12208,10 +12272,10 @@ public T Transform( } public EmbeddedDataSpecification( - IReference? dataSpecification, - IDataSpecificationContent? dataSpecificationContent) + IReference dataSpecification, + IDataSpecificationContent dataSpecificationContent) { - DataSpecification = dataSpecification; + DataSpecification = dataSpecification; DataSpecificationContent = dataSpecificationContent; } } @@ -12223,62 +12287,67 @@ public enum DataTypeIec61360 /// Example from IEC 61360-1:2017: "1999-05-31" is the [DATE] representation of: /// "31 May 1999". /// - [ EnumMember(Value = "DATE") ] Date, + [EnumMember(Value = "DATE")] + Date, /// /// values consisting of sequence of characters but cannot be translated into other /// languages /// - [ EnumMember(Value = "STRING") ] String, + [EnumMember(Value = "STRING")] + String, /// /// values containing string but shall be represented as different string in different /// languages /// - [ EnumMember(Value = "STRING_TRANSLATABLE") ] + [EnumMember(Value = "STRING_TRANSLATABLE")] StringTranslatable, /// /// values containing values that are measure of type INTEGER. In addition such a value /// comes with a physical unit. /// - [ EnumMember(Value = "INTEGER_MEASURE") ] + [EnumMember(Value = "INTEGER_MEASURE")] IntegerMeasure, /// /// values containing values of type INTEGER but are no currencies or measures /// - [ EnumMember(Value = "INTEGER_COUNT") ] + [EnumMember(Value = "INTEGER_COUNT")] IntegerCount, /// /// values containing values of type INTEGER that are currencies /// - [ EnumMember(Value = "INTEGER_CURRENCY") ] + [EnumMember(Value = "INTEGER_CURRENCY")] IntegerCurrency, /// /// values containing values that are measures of type REAL. In addition such a value /// comes with a physical unit. /// - [ EnumMember(Value = "REAL_MEASURE") ] RealMeasure, + [EnumMember(Value = "REAL_MEASURE")] + RealMeasure, /// /// values containing numbers that can be written as a terminating or non-terminating /// decimal; a rational or irrational number but are no currencies or measures /// - [ EnumMember(Value = "REAL_COUNT") ] RealCount, + [EnumMember(Value = "REAL_COUNT")] + RealCount, /// /// values containing values of type REAL that are currencies /// - [ EnumMember(Value = "REAL_CURRENCY") ] + [EnumMember(Value = "REAL_CURRENCY")] RealCurrency, /// /// values representing truth of logic or Boolean algebra (TRUE, FALSE) /// - [ EnumMember(Value = "BOOLEAN") ] Boolean, + [EnumMember(Value = "BOOLEAN")] + Boolean, /// /// values containing values of type STRING conformant to Rfc 3987 @@ -12287,7 +12356,8 @@ [ EnumMember(Value = "BOOLEAN") ] Boolean, /// In IEC61360-1 (2017) only URI is supported. /// An IRI type allows in particular to express an URL or an URI. /// - [ EnumMember(Value = "IRI") ] Iri, + [EnumMember(Value = "IRI")] + Iri, /// /// values conforming to ISO/IEC 11179 series global identifier sequences @@ -12308,18 +12378,20 @@ [ EnumMember(Value = "IRI") ] Iri, /// identifier" (IRDI). /// /// - [ EnumMember(Value = "IRDI") ] Irdi, + [EnumMember(Value = "IRDI")] + Irdi, /// /// values containing values of type rational /// - [ EnumMember(Value = "RATIONAL") ] Rational, + [EnumMember(Value = "RATIONAL")] + Rational, /// /// values containing values of type rational. In addition such a value comes with a /// physical unit. /// - [ EnumMember(Value = "RATIONAL_MEASURE") ] + [EnumMember(Value = "RATIONAL_MEASURE")] RationalMeasure, /// @@ -12336,7 +12408,8 @@ [ EnumMember(Value = "RATIONAL_MEASURE") ] /// Universal Time (UTC). /// /// - [ EnumMember(Value = "TIME") ] Time, + [EnumMember(Value = "TIME")] + Time, /// /// values containing a time, conformant to ISO 8601:2004 but restricted to what is @@ -12345,7 +12418,8 @@ [ EnumMember(Value = "TIME") ] Time, /// /// Format yyyy-mm-dd hh:mm (ECLASS) /// - [ EnumMember(Value = "TIMESTAMP") ] Timestamp, + [EnumMember(Value = "TIMESTAMP")] + Timestamp, /// /// values containing an address to a file. The values are of type URI and can represent @@ -12354,13 +12428,15 @@ [ EnumMember(Value = "TIMESTAMP") ] Timestamp, /// /// IEC61360 does not support the file type. /// - [ EnumMember(Value = "FILE") ] File, + [EnumMember(Value = "FILE")] + File, /// /// Values containing string with any sequence of characters, using the syntax of HTML5 /// (see W3C Recommendation 28:2014) /// - [ EnumMember(Value = "HTML") ] Html, + [EnumMember(Value = "HTML")] + Html, /// /// values containing the content of a file. Values may be binaries. @@ -12374,7 +12450,8 @@ [ EnumMember(Value = "HTML") ] Html, /// “1” only. A binary is a blob but a blob may also contain other source code. /// /// - [ EnumMember(Value = "BLOB") ] Blob + [EnumMember(Value = "BLOB")] + Blob } /// @@ -12597,7 +12674,7 @@ public interface IValueReferencePair : IClass /// /// The value of the referenced concept definition of the value in . /// - public string? Value { get; set; } + public string Value { get; set; } /// /// Global unique id of the value. @@ -12605,7 +12682,7 @@ public interface IValueReferencePair : IClass /// /// It is recommended to use a global reference. /// - public IReference? ValueId { get; set; } + public IReference ValueId { get; set; } } /// @@ -12617,7 +12694,7 @@ public class ValueReferencePair : IValueReferencePair /// /// The value of the referenced concept definition of the value in . /// - public string? Value { get; set; } + public string Value { get; set; } /// /// Global unique id of the value. @@ -12625,7 +12702,7 @@ public class ValueReferencePair : IValueReferencePair /// /// It is recommended to use a global reference. /// - public IReference? ValueId { get; set; } + public IReference ValueId { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -12691,10 +12768,10 @@ public T Transform( } public ValueReferencePair( - string? value, - IReference? valueId) + string value, + IReference valueId) { - Value = value; + Value = value; ValueId = valueId; } } @@ -12817,12 +12894,12 @@ public class LangStringPreferredNameTypeIec61360 : ILangStringPreferredNameTypeI /// /// Language tag conforming to BCP 47 /// - public string? Language { get; set; } + public string Language { get; set; } /// /// Text in the /// - public string? Text { get; set; } + public string Text { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -12884,11 +12961,11 @@ public T Transform( } public LangStringPreferredNameTypeIec61360( - string? language, - string? text) + string language, + string text) { Language = language; - Text = text; + Text = text; } } @@ -12908,12 +12985,12 @@ public class LangStringShortNameTypeIec61360 : ILangStringShortNameTypeIec61360 /// /// Language tag conforming to BCP 47 /// - public string? Language { get; set; } + public string Language { get; set; } /// /// Text in the /// - public string? Text { get; set; } + public string Text { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -12975,11 +13052,11 @@ public T Transform( } public LangStringShortNameTypeIec61360( - string? language, - string? text) + string language, + string text) { Language = language; - Text = text; + Text = text; } } @@ -12999,12 +13076,12 @@ public class LangStringDefinitionTypeIec61360 : ILangStringDefinitionTypeIec6136 /// /// Language tag conforming to BCP 47 /// - public string? Language { get; set; } + public string Language { get; set; } /// /// Text in the /// - public string? Text { get; set; } + public string Text { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -13066,11 +13143,11 @@ public T Transform( } public LangStringDefinitionTypeIec61360( - string? language, - string? text) + string language, + string text) { Language = language; - Text = text; + Text = text; } } @@ -13363,7 +13440,7 @@ public class DataSpecificationIec61360 : IDataSpecificationIec61360 public IEnumerable OverShortNameOrEmpty() { return ShortName - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -13372,7 +13449,7 @@ public IEnumerable OverShortNameOrEmpty() public IEnumerable OverDefinitionOrEmpty() { return Definition - ?? System.Linq.Enumerable.Empty(); + ?? System.Linq.Enumerable.Empty(); } /// @@ -13550,23 +13627,23 @@ public DataSpecificationIec61360( string? value = null, ILevelType? levelType = null) { - PreferredName = preferredName; - ShortName = shortName; - Unit = unit; - UnitId = unitId; + PreferredName = preferredName; + ShortName = shortName; + Unit = unit; + UnitId = unitId; SourceOfDefinition = sourceOfDefinition; - Symbol = symbol; - DataType = dataType; - Definition = definition; - ValueFormat = valueFormat; - ValueList = valueList; - Value = value; - LevelType = levelType; + Symbol = symbol; + DataType = dataType; + Definition = definition; + ValueFormat = valueFormat; + ValueList = valueList; + Value = value; + LevelType = levelType; } } -} // namespace AasCore.Aas3_0 +} // namespace AasCore.Aas3_0 /* * This code has been automatically generated by aas-core-codegen. * Do NOT edit or append. - */ \ No newline at end of file + */ diff --git a/src/AasCore.Aas3_0/verification.cs b/src/AasCore.Aas3_0/verification.cs index fe7008126..76d8fc719 100644 --- a/src/AasCore.Aas3_0/verification.cs +++ b/src/AasCore.Aas3_0/verification.cs @@ -59,7 +59,7 @@ private static Regex _constructMatchesIdShort() /// /// Check that is a valid short ID. /// - public static bool MatchesIdShort(string? text) + public static bool MatchesIdShort(string text) { return RegexMatchesIdShort.IsMatch(text); } @@ -79,7 +79,7 @@ private static Regex _constructMatchesVersionType() /// /// Check that is a valid version string. /// - public static bool MatchesVersionType(string? text) + public static bool MatchesVersionType(string text) { return RegexMatchesVersionType.IsMatch(text); } @@ -99,7 +99,7 @@ private static Regex _constructMatchesRevisionType() /// /// Check that is a valid revision string. /// - public static bool MatchesRevisionType(string? text) + public static bool MatchesRevisionType(string text) { return RegexMatchesRevisionType.IsMatch(text); } @@ -145,7 +145,7 @@ private static Regex _constructMatchesXsDateTimeUtc() /// /// True if the conforms to the pattern /// - public static bool MatchesXsDateTimeUtc(string? text) + public static bool MatchesXsDateTimeUtc(string text) { return RegexMatchesXsDateTimeUtc.IsMatch(text); } @@ -155,7 +155,7 @@ public static bool MatchesXsDateTimeUtc(string? text) /// the time zone set to UTC. /// public static bool IsXsDateTimeUtc( - string? value + string value ) { if (!MatchesXsDateTimeUtc(value)) @@ -203,7 +203,7 @@ private static Regex _constructMatchesMimeType() /// /// True if the conforms to the pattern /// - public static bool MatchesMimeType(string? text) + public static bool MatchesMimeType(string text) { return RegexMatchesMimeType.IsMatch(text); } @@ -217,7 +217,8 @@ private static Regex _constructMatchesRfc8089Path() var decOctet = "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"; var ipv4address = $"{decOctet}\\.{decOctet}\\.{decOctet}\\.{decOctet}"; var ls32 = $"({h16}:{h16}|{ipv4address})"; - var ipv6address = $"(({h16}:){{6}}{ls32}|::({h16}:){{5}}{ls32}|({h16})?::({h16}:){{4}}{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|(({h16}:){{2}}{h16})?::({h16}:){{2}}{ls32}|(({h16}:){{3}}{h16})?::{h16}:{ls32}|(({h16}:){{4}}{h16})?::{ls32}|(({h16}:){{5}}{h16})?::{h16}|(({h16}:){{6}}{h16})?::)"; + var ipv6address = $"(({h16}:){{6}}{ls32}|::({h16}:){{5}}{ls32}|({h16})?::({h16}:){{4}}{ls32}|(({h16}:)?{h16})?::({h16}:)" + + $"{{3}}{ls32}|(({h16}:){{2}}{h16})?::({h16}:){{2}}{ls32}|(({h16}:){{3}}{h16})?::{h16}:{ls32}|(({h16}:){{4}}{h16})?::{ls32}|(({h16}:){{5}}{h16})?::{h16}|(({h16}:){{6}}{h16})?::)"; var unreserved = "[a-zA-Z0-9\\-._~]"; var subDelims = "[!$&'()*+,;=]"; var ipvfuture = $"[vV][0-9A-Fa-f]+\\.({unreserved}|{subDelims}|:)+"; @@ -255,7 +256,7 @@ private static Regex _constructMatchesRfc8089Path() /// /// True if the conforms to the pattern /// - public static bool MatchesRfc8089Path(string? text) + public static bool MatchesRfc8089Path(string text) { return RegexMatchesRfc8089Path.IsMatch(text); } @@ -292,7 +293,7 @@ private static Regex _constructMatchesBcp47() /// /// See: https://en.wikipedia.org/wiki/IETF_language_tag /// - public static bool MatchesBcp47(string? text) + public static bool MatchesBcp47(string text) { return RegexMatchesBcp47.IsMatch(text); } @@ -362,7 +363,7 @@ private static Regex _constructMatchesXmlSerializableString() /// /// True if the conforms to the pattern /// - public static bool MatchesXmlSerializableString(string? text) + public static bool MatchesXmlSerializableString(string text) { return RegexMatchesXmlSerializableString.IsMatch(text); } @@ -373,7 +374,15 @@ public static bool MatchesXmlSerializableString(string? text) private static Regex _constructMatchesXsAnyUri() { var scheme = "[a-zA-Z][a-zA-Z0-9+\\-.]*"; - var ucschar = "([\\xa0-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\uffef]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\ud83e][\\udc00-\\udfff]|\\ud83f[\\udc00-\\udffd]|\\ud840[\\udc00-\\udfff]|[\\ud841-\\ud87e][\\udc00-\\udfff]|\\ud87f[\\udc00-\\udffd]|\\ud880[\\udc00-\\udfff]|[\\ud881-\\ud8be][\\udc00-\\udfff]|\\ud8bf[\\udc00-\\udffd]|\\ud8c0[\\udc00-\\udfff]|[\\ud8c1-\\ud8fe][\\udc00-\\udfff]|\\ud8ff[\\udc00-\\udffd]|\\ud900[\\udc00-\\udfff]|[\\ud901-\\ud93e][\\udc00-\\udfff]|\\ud93f[\\udc00-\\udffd]|\\ud940[\\udc00-\\udfff]|[\\ud941-\\ud97e][\\udc00-\\udfff]|\\ud97f[\\udc00-\\udffd]|\\ud980[\\udc00-\\udfff]|[\\ud981-\\ud9be][\\udc00-\\udfff]|\\ud9bf[\\udc00-\\udffd]|\\ud9c0[\\udc00-\\udfff]|[\\ud9c1-\\ud9fe][\\udc00-\\udfff]|\\ud9ff[\\udc00-\\udffd]|\\uda00[\\udc00-\\udfff]|[\\uda01-\\uda3e][\\udc00-\\udfff]|\\uda3f[\\udc00-\\udffd]|\\uda40[\\udc00-\\udfff]|[\\uda41-\\uda7e][\\udc00-\\udfff]|\\uda7f[\\udc00-\\udffd]|\\uda80[\\udc00-\\udfff]|[\\uda81-\\udabe][\\udc00-\\udfff]|\\udabf[\\udc00-\\udffd]|\\udac0[\\udc00-\\udfff]|[\\udac1-\\udafe][\\udc00-\\udfff]|\\udaff[\\udc00-\\udffd]|\\udb00[\\udc00-\\udfff]|[\\udb01-\\udb3e][\\udc00-\\udfff]|\\udb3f[\\udc00-\\udffd]|\\udb44[\\udc00-\\udfff]|[\\udb45-\\udb7e][\\udc00-\\udfff]|\\udb7f[\\udc00-\\udffd])"; + var ucschar = "([\\xa0-\\ud7ff\\uf900-\\ufdcf\\ufdf0-\\uffef]|\\ud800[\\udc00-\\udfff]|[\\ud801-\\ud83e][\\udc00-\\udfff]|\\ud83f[\\udc" + + "00-\\udffd]|\\ud840[\\udc00-\\udfff]|[\\ud841-\\ud87e][\\udc00-\\udfff]|\\ud87f[\\udc00-\\udffd]|\\ud880[\\udc00-\\udfff]|[\\ud881-\\ud8" + + "be][\\udc00-\\udfff]|\\ud8bf[\\udc00-\\udffd]|\\ud8c0[\\udc00-\\udfff]|[\\ud8c1-\\ud8fe][\\udc00-\\udfff]|\\ud8ff[\\udc00-\\udffd]|\\ud9" + + "00[\\udc00-\\udfff]|[\\ud901-\\ud93e][\\udc00-\\udfff]|\\ud93f[\\udc00-\\udffd]|\\ud940[\\udc00-\\udfff]|[\\ud941-\\ud97e][\\udc00-\\udff" + + "f]|\\ud97f[\\udc00-\\udffd]|\\ud980[\\udc00-\\udfff]|[\\ud981-\\ud9be][\\udc00-\\udfff]|\\ud9bf[\\udc00-\\udffd]|\\ud9c0[\\udc00-\\udff" + + "f]|[\\ud9c1-\\ud9fe][\\udc00-\\udfff]|\\ud9ff[\\udc00-\\udffd]|\\uda00[\\udc00-\\udfff]|[\\uda01-\\uda3e][\\udc00-\\udfff]|\\uda3f[\\udc" + + "00-\\udffd]|\\uda40[\\udc00-\\udfff]|[\\uda41-\\uda7e][\\udc00-\\udfff]|\\uda7f[\\udc00-\\udffd]|\\uda80[\\udc00-\\udfff]|[\\uda81-\\uda" + + "be][\\udc00-\\udfff]|\\udabf[\\udc00-\\udffd]|\\udac0[\\udc00-\\udfff]|[\\udac1-\\udafe][\\udc00-\\udfff]|\\udaff[\\udc00-\\udffd]|\\ud" + + "b00[\\udc00-\\udfff]|[\\udb01-\\udb3e][\\udc00-\\udfff]|\\udb3f[\\udc00-\\udffd]|\\udb44[\\udc00-\\udfff]|[\\udb45-\\udb7e][\\udc00-\\udfff]|\\udb7f[\\udc00-\\udffd])"; var iunreserved = $"([a-zA-Z0-9\\-._~]|{ucschar})"; var pctEncoded = "%[0-9A-Fa-f][0-9A-Fa-f]"; var subDelims = "[!$&'()*+,;=]"; @@ -382,7 +391,9 @@ private static Regex _constructMatchesXsAnyUri() var decOctet = "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"; var ipv4address = $"{decOctet}\\.{decOctet}\\.{decOctet}\\.{decOctet}"; var ls32 = $"({h16}:{h16}|{ipv4address})"; - var ipv6address = $"(({h16}:){{6}}{ls32}|::({h16}:){{5}}{ls32}|({h16})?::({h16}:){{4}}{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|(({h16}:){{2}}{h16})?::({h16}:){{2}}{ls32}|(({h16}:){{3}}{h16})?::{h16}:{ls32}|(({h16}:){{4}}{h16})?::{ls32}|(({h16}:){{5}}{h16})?::{h16}|(({h16}:){{6}}{h16})?::)"; + var ipv6address = $"(({h16}:){{6}}{ls32}|::({h16}:){{5}}{ls32}|({h16})?::({h16}:){{4}}{ls32}|(({h16}:)?{h16})?::({h16}:){{3}}{ls32}|" + + $"(({h16}:){{2}}{h16})?::({h16}:){{2}}{ls32}|(({h16}:){{3}}{h16})?::{h16}:{ls32}|(({h16}:){{4}}{h16})?::{ls32}|(({h16}:){{5}}{h16})?" + + $"::{h16}|(({h16}:){{6}}{h16})?::)"; var unreserved = "[a-zA-Z0-9\\-._~]"; var ipvfuture = $"[vV][0-9A-Fa-f]+\\.({unreserved}|{subDelims}|:)+"; var ipLiteral = $"\\[({ipv6address}|{ipvfuture})\\]"; @@ -427,7 +438,7 @@ private static Regex _constructMatchesXsAnyUri() /// /// True if the conforms to the pattern /// - public static bool MatchesXsAnyUri(string? text) + public static bool MatchesXsAnyUri(string text) { return RegexMatchesXsAnyUri.IsMatch(text); } @@ -468,7 +479,7 @@ private static Regex _constructMatchesXsBase64Binary() /// /// True if the conforms to the pattern /// - public static bool MatchesXsBase64Binary(string? text) + public static bool MatchesXsBase64Binary(string text) { return RegexMatchesXsBase64Binary.IsMatch(text); } @@ -497,7 +508,7 @@ private static Regex _constructMatchesXsBoolean() /// /// True if the conforms to the pattern /// - public static bool MatchesXsBoolean(string? text) + public static bool MatchesXsBoolean(string text) { return RegexMatchesXsBoolean.IsMatch(text); } @@ -533,7 +544,7 @@ private static Regex _constructMatchesXsDate() /// /// True if the conforms to the pattern /// - public static bool MatchesXsDate(string? text) + public static bool MatchesXsDate(string text) { return RegexMatchesXsDate.IsMatch(text); } @@ -572,7 +583,7 @@ private static Regex _constructMatchesXsDateTime() /// /// True if the conforms to the pattern /// - public static bool MatchesXsDateTime(string? text) + public static bool MatchesXsDateTime(string text) { return RegexMatchesXsDateTime.IsMatch(text); } @@ -628,7 +639,7 @@ public static bool IsLeapYear(System.Numerics.BigInteger year) /// /// true if the value starts with a valid date /// - private static bool IsPrefixedWithValidDate(string? value) + private static bool IsPrefixedWithValidDate(string value) { // NOTE (mristin, 2023-03-16): // We can not use System.DateTime.ParseExact since it does not handle the zero and @@ -737,7 +748,7 @@ private static bool IsPrefixedWithValidDate(string? value) /// the time zone set to UTC. /// public static bool IsXsDateTime( - string? value + string value ) { if (!MatchesXsDateTime(value)) @@ -779,7 +790,7 @@ private static Regex _constructMatchesXsDecimal() /// /// True if the conforms to the pattern /// - public static bool MatchesXsDecimal(string? text) + public static bool MatchesXsDecimal(string text) { return RegexMatchesXsDecimal.IsMatch(text); } @@ -809,7 +820,7 @@ private static Regex _constructMatchesXsDouble() /// /// True if the conforms to the pattern /// - public static bool MatchesXsDouble(string? text) + public static bool MatchesXsDouble(string text) { return RegexMatchesXsDouble.IsMatch(text); } @@ -819,7 +830,9 @@ public static bool MatchesXsDouble(string? text) [CodeAnalysis.SuppressMessage("ReSharper", "StringLiteralTypo")] private static Regex _constructMatchesXsDuration() { - var durationRep = "-?P((([0-9]+Y([0-9]+M)?([0-9]+D)?|([0-9]+M)([0-9]+D)?|([0-9]+D))(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S)))?)|(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S))))"; + var durationRep = "-?P((([0-9]+Y([0-9]+M)?([0-9]+D)?|([0-9]+M)([0-9]+D)?|([0-9]+D))(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-" + + "9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S)))?)|(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S" + + ")?|([0-9]+(\\.[0-9]+)?S))))"; var pattern = $"^{durationRep}$"; return new Regex(pattern); @@ -839,7 +852,7 @@ private static Regex _constructMatchesXsDuration() /// /// True if the conforms to the pattern /// - public static bool MatchesXsDuration(string? text) + public static bool MatchesXsDuration(string text) { return RegexMatchesXsDuration.IsMatch(text); } @@ -869,7 +882,7 @@ private static Regex _constructMatchesXsFloat() /// /// True if the conforms to the pattern /// - public static bool MatchesXsFloat(string? text) + public static bool MatchesXsFloat(string text) { return RegexMatchesXsFloat.IsMatch(text); } @@ -899,7 +912,7 @@ private static Regex _constructMatchesXsGDay() /// /// True if the conforms to the pattern /// - public static bool MatchesXsGDay(string? text) + public static bool MatchesXsGDay(string text) { return RegexMatchesXsGDay.IsMatch(text); } @@ -929,7 +942,7 @@ private static Regex _constructMatchesXsGMonth() /// /// True if the conforms to the pattern /// - public static bool MatchesXsGMonth(string? text) + public static bool MatchesXsGMonth(string text) { return RegexMatchesXsGMonth.IsMatch(text); } @@ -959,7 +972,7 @@ private static Regex _constructMatchesXsGMonthDay() /// /// True if the conforms to the pattern /// - public static bool MatchesXsGMonthDay(string? text) + public static bool MatchesXsGMonthDay(string text) { return RegexMatchesXsGMonthDay.IsMatch(text); } @@ -989,7 +1002,7 @@ private static Regex _constructMatchesXsGYear() /// /// True if the conforms to the pattern /// - public static bool MatchesXsGYear(string? text) + public static bool MatchesXsGYear(string text) { return RegexMatchesXsGYear.IsMatch(text); } @@ -1019,7 +1032,7 @@ private static Regex _constructMatchesXsGYearMonth() /// /// True if the conforms to the pattern /// - public static bool MatchesXsGYearMonth(string? text) + public static bool MatchesXsGYearMonth(string text) { return RegexMatchesXsGYearMonth.IsMatch(text); } @@ -1049,7 +1062,7 @@ private static Regex _constructMatchesXsHexBinary() /// /// True if the conforms to the pattern /// - public static bool MatchesXsHexBinary(string? text) + public static bool MatchesXsHexBinary(string text) { return RegexMatchesXsHexBinary.IsMatch(text); } @@ -1079,7 +1092,7 @@ private static Regex _constructMatchesXsTime() /// /// True if the conforms to the pattern /// - public static bool MatchesXsTime(string? text) + public static bool MatchesXsTime(string text) { return RegexMatchesXsTime.IsMatch(text); } @@ -1109,7 +1122,7 @@ private static Regex _constructMatchesXsInteger() /// /// True if the conforms to the pattern /// - public static bool MatchesXsInteger(string? text) + public static bool MatchesXsInteger(string text) { return RegexMatchesXsInteger.IsMatch(text); } @@ -1259,7 +1272,7 @@ private static Regex _constructMatchesXsNonNegativeInteger() /// /// True if the conforms to the pattern /// - public static bool MatchesXsNonNegativeInteger(string? text) + public static bool MatchesXsNonNegativeInteger(string text) { return RegexMatchesXsNonNegativeInteger.IsMatch(text); } @@ -1289,7 +1302,7 @@ private static Regex _constructMatchesXsPositiveInteger() /// /// True if the conforms to the pattern /// - public static bool MatchesXsPositiveInteger(string? text) + public static bool MatchesXsPositiveInteger(string text) { return RegexMatchesXsPositiveInteger.IsMatch(text); } @@ -1439,7 +1452,7 @@ private static Regex _constructMatchesXsNonPositiveInteger() /// /// True if the conforms to the pattern /// - public static bool MatchesXsNonPositiveInteger(string? text) + public static bool MatchesXsNonPositiveInteger(string text) { return RegexMatchesXsNonPositiveInteger.IsMatch(text); } @@ -1469,7 +1482,7 @@ private static Regex _constructMatchesXsNegativeInteger() /// /// True if the conforms to the pattern /// - public static bool MatchesXsNegativeInteger(string? text) + public static bool MatchesXsNegativeInteger(string text) { return RegexMatchesXsNegativeInteger.IsMatch(text); } @@ -1498,7 +1511,7 @@ private static Regex _constructMatchesXsString() /// /// True if the conforms to the pattern /// - public static bool MatchesXsString(string? text) + public static bool MatchesXsString(string text) { return RegexMatchesXsString.IsMatch(text); } @@ -1508,7 +1521,7 @@ public static bool MatchesXsString(string? text) /// the given . /// public static bool ValueConsistentWithXsdType( - string? value, + string value, Aas.DataTypeDefXsd valueType ) { @@ -1820,9 +1833,9 @@ Aas.DataTypeDefXsd valueType // // The positive sign is indeed allowed in the lexical representation, see: // https://www.w3.org/TR/xmlschema11-2/#unsignedByte - string? clipped = (value[0] == '+') - ? value.Substring(1, value.Length - 1) - : value; + string clipped = (value[0] == '+') + ? value.Substring(1, value.Length - 1) + : value; try { @@ -1861,9 +1874,9 @@ Aas.DataTypeDefXsd valueType // // The positive sign is indeed allowed in the lexical representation, see: // https://www.w3.org/TR/xmlschema11-2/#unsignedInt - string? clipped = (value[0] == '+') - ? value.Substring(1, value.Length - 1) - : value; + string clipped = (value[0] == '+') + ? value.Substring(1, value.Length - 1) + : value; try { @@ -1902,9 +1915,9 @@ Aas.DataTypeDefXsd valueType // // The positive sign is indeed allowed in the lexical representation, see: // https://www.w3.org/TR/xmlschema11-2/#unsignedLong - string? clipped = (value[0] == '+') - ? value.Substring(1, value.Length - 1) - : value; + string clipped = (value[0] == '+') + ? value.Substring(1, value.Length - 1) + : value; try { @@ -1943,9 +1956,9 @@ Aas.DataTypeDefXsd valueType // // The positive sign is indeed allowed in the lexical representation, see: // https://www.w3.org/TR/xmlschema11-2/#unsignedShort - string? clipped = (value[0] == '+') - ? value.Substring(1, value.Length - 1) - : value; + string clipped = (value[0] == '+') + ? value.Substring(1, value.Length - 1) + : value; try { @@ -1973,7 +1986,7 @@ Aas.DataTypeDefXsd valueType /// Check that the target of the model reference matches the . /// public static bool IsModelReferenceTo( - IReference? reference, + IReference reference, KeyTypes expectedType ) { @@ -1986,7 +1999,7 @@ KeyTypes expectedType /// Check that the target of the reference matches a . /// public static bool IsModelReferenceToReferable( - IReference? reference + IReference reference ) { return reference.Type == ReferenceTypes.ModelReference @@ -2475,7 +2488,7 @@ private static Regex _constructIsBcp47ForEnglish() /// /// Check that the corresponds to a BCP47 code for english. /// - public static bool IsBcp47ForEnglish(string? text) + public static bool IsBcp47ForEnglish(string text) { return RegexIsBcp47ForEnglish.IsMatch(text); } @@ -9628,7 +9641,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// /// The instance of the meta-model to be verified /// - public static IEnumerable Verify(IClass? that) + public static IEnumerable Verify(Aas.IClass that) { foreach (var error in _transformer.Transform(that)) { @@ -9640,7 +9653,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyNonEmptyXmlSerializableString( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -9663,7 +9676,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyDateTimeUtc( - string? that) + string that) { if (!Verification.MatchesXsDateTimeUtc(that)) { @@ -9686,7 +9699,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyDuration( - string? that) + string that) { if (!Verification.MatchesXsDuration(that)) { @@ -9710,7 +9723,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyIdentifier( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -9740,7 +9753,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyValueTypeIec61360( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -9771,7 +9784,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyNameType( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -9801,7 +9814,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyVersionType( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -9838,7 +9851,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyRevisionType( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -9875,7 +9888,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyLabelType( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -9905,7 +9918,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyMessageTopicType( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -9936,7 +9949,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyBcp47LanguageTag( - string? that) + string that) { if (!Verification.MatchesBcp47(that)) { @@ -9951,7 +9964,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyContentType( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -9989,7 +10002,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyPathType( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -10027,7 +10040,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyQualifierType( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { @@ -10067,7 +10080,7 @@ var error in Verification.VerifyNonEmptyXmlSerializableString( /// Verify the constraints of . /// public static IEnumerable VerifyIdShortType( - string? that) + string that) { if (!Verification.MatchesXmlSerializableString(that)) { diff --git a/src/AasCore.Aas3_0/visitation.cs b/src/AasCore.Aas3_0/visitation.cs index ef73db325..a72b205d5 100644 --- a/src/AasCore.Aas3_0/visitation.cs +++ b/src/AasCore.Aas3_0/visitation.cs @@ -145,7 +145,6 @@ ILangStringDefinitionTypeIec61360 that public void VisitDataSpecificationIec61360( IDataSpecificationIec61360 that ); - // OZ: void Visit(Extension that); } // public interface IVisitor /// @@ -718,7 +717,7 @@ IDataSpecificationIec61360 that /// Context type public interface IVisitorWithContext { - public void Visit(IClass? that, TContext context); + public void Visit(IClass that, TContext context); public void VisitExtension( IExtension that, TContext context @@ -736,7 +735,7 @@ public void VisitAssetAdministrationShell( TContext context ); public void VisitAssetInformation( - IAssetInformation? that, + IAssetInformation that, TContext context ); public void VisitResource( @@ -820,7 +819,7 @@ public void VisitConceptDescription( TContext context ); public void VisitReference( - IReference? that, + IReference that, TContext context ); public void VisitKey( @@ -881,7 +880,7 @@ TContext context public abstract class AbstractVisitorWithContext : IVisitorWithContext { - public void Visit(IClass? that, TContext context) + public void Visit(IClass that, TContext context) { that.Accept(this, context); } @@ -902,7 +901,7 @@ public abstract void VisitAssetAdministrationShell( TContext context ); public abstract void VisitAssetInformation( - IAssetInformation? that, + IAssetInformation that, TContext context ); public abstract void VisitResource( @@ -986,7 +985,7 @@ public abstract void VisitConceptDescription( TContext context ); public abstract void VisitReference( - IReference? that, + IReference that, TContext context ); public abstract void VisitKey( @@ -1051,7 +1050,7 @@ TContext context /// The type of the transformation result public interface ITransformer { - public T Transform(IClass? that); + public T Transform(IClass that); public T TransformExtension( IExtension that ); @@ -1175,7 +1174,7 @@ IDataSpecificationIec61360 that /// The type of the transformation result public abstract class AbstractTransformer : ITransformer { - public T Transform(IClass? that) + public T Transform(IClass that) { return that.Transform(this); } @@ -1346,7 +1345,7 @@ IDataSpecificationIec61360 that /// The type of the transformation result public interface ITransformerWithContext { - public T Transform(IClass? that, TContext context); + public T Transform(IClass that, TContext context); public T TransformExtension( IExtension that, TContext context @@ -1515,7 +1514,7 @@ TContext context public abstract class AbstractTransformerWithContext : ITransformerWithContext { - public T Transform(IClass? that, TContext context) + public T Transform(IClass that, TContext context) { return that.Transform(this, context); } diff --git a/src/AasCore.Aas3_0/xmlization.cs b/src/AasCore.Aas3_0/xmlization.cs index 512711348..988cacad7 100644 --- a/src/AasCore.Aas3_0/xmlization.cs +++ b/src/AasCore.Aas3_0/xmlization.cs @@ -15,6 +15,7 @@ * This code has been automatically generated by aas-core-codegen. * Do NOT edit or append. */ + using System.Collections.Generic; // can't alias using Aas = AasCore.Aas3_0; // renamed using CodeAnalysis = System.Diagnostics.CodeAnalysis; @@ -229,7 +230,7 @@ out Reporting.Error? error List? theSupplementalSemanticIds = null; string? theName = null; DataTypeDefXsd? theValueType = null; - string theValue = null; + string? theValue = null; List? theRefersTo = null; if (!isEmptySequence) @@ -372,7 +373,7 @@ out Reporting.Error? error return null; } - string? textValueType; + string textValueType; try { textValueType = reader.ReadContentAsString(); @@ -1062,10 +1063,10 @@ out Reporting.Error? error error = null; List? theEmbeddedDataSpecifications = null; - string theVersion = null; - string theRevision = null; + string? theVersion = null; + string? theRevision = null; IReference? theCreator = null; - string theTemplateId = null; + string? theTemplateId = null; if (!isEmptySequence) { @@ -1540,7 +1541,7 @@ out Reporting.Error? error QualifierKind? theKind = null; string? theType = null; DataTypeDefXsd? theValueType = null; - string theValue = null; + string? theValue = null; IReference? theValueId = null; if (!isEmptySequence) @@ -1643,7 +1644,7 @@ out Reporting.Error? error return null; } - string? textKind; + string textKind; try { textKind = reader.ReadContentAsString(); @@ -1738,7 +1739,7 @@ out Reporting.Error? error return null; } - string? textValueType; + string textValueType; try { textValueType = reader.ReadContentAsString(); @@ -2029,8 +2030,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IAdministrativeInformation? theAdministration = null; @@ -2618,9 +2619,9 @@ out Reporting.Error? error error = null; AssetKind? theAssetKind = null; - string theGlobalAssetId = null; + string? theGlobalAssetId = null; List? theSpecificAssetIds = null; - string theAssetType = null; + string? theAssetType = null; IResource? theDefaultThumbnail = null; if (!isEmptySequence) @@ -2673,7 +2674,7 @@ out Reporting.Error? error return null; } - string? textAssetKind; + string textAssetKind; try { textAssetKind = reader.ReadContentAsString(); @@ -3028,7 +3029,7 @@ out Reporting.Error? error error = null; string? thePath = null; - string theContentType = null; + string? theContentType = null; if (!isEmptySequence) { @@ -3706,8 +3707,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IAdministrativeInformation? theAdministration = null; @@ -4011,7 +4012,7 @@ out Reporting.Error? error return null; } - string? textKind; + string textKind; try { textKind = reader.ReadContentAsString(); @@ -4488,8 +4489,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -5123,8 +5124,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -5558,7 +5559,7 @@ out Reporting.Error? error return null; } - string? textTypeValueListElement; + string textTypeValueListElement; try { textTypeValueListElement = reader.ReadContentAsString(); @@ -5613,7 +5614,7 @@ out Reporting.Error? error return null; } - string? textValueTypeListElement; + string textValueTypeListElement; try { textValueTypeListElement = reader.ReadContentAsString(); @@ -5883,8 +5884,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -6516,8 +6517,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -6525,7 +6526,7 @@ out Reporting.Error? error List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; DataTypeDefXsd? theValueType = null; - string theValue = null; + string? theValue = null; IReference? theValueId = null; if (!isEmptySequence) @@ -6888,7 +6889,7 @@ out Reporting.Error? error return null; } - string? textValueType; + string textValueType; try { textValueType = reader.ReadContentAsString(); @@ -7174,8 +7175,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -7761,8 +7762,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -7770,8 +7771,8 @@ out Reporting.Error? error List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; DataTypeDefXsd? theValueType = null; - string theMin = null; - string theMax = null; + string? theMin = null; + string? theMax = null; if (!isEmptySequence) { @@ -8133,7 +8134,7 @@ out Reporting.Error? error return null; } - string? textValueType; + string textValueType; try { textValueType = reader.ReadContentAsString(); @@ -8445,8 +8446,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -8994,8 +8995,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -9629,15 +9630,15 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; List? theEmbeddedDataSpecifications = null; - string theValue = null; + string? theValue = null; string? theContentType = null; if (!isEmptySequence) @@ -10256,8 +10257,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -10879,8 +10880,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -10889,7 +10890,7 @@ out Reporting.Error? error List? theEmbeddedDataSpecifications = null; List? theStatements = null; EntityType? theEntityType = null; - string theGlobalAssetId = null; + string? theGlobalAssetId = null; List? theSpecificAssetIds = null; if (!isEmptySequence) @@ -11288,7 +11289,7 @@ out Reporting.Error? error return null; } - string? textEntityType; + string textEntityType; try { textEntityType = reader.ReadContentAsString(); @@ -11600,7 +11601,7 @@ out Reporting.Error? error IReference? theSourceSemanticId = null; IReference? theObservableReference = null; IReference? theObservableSemanticId = null; - string theTopic = null; + string? theTopic = null; IReference? theSubjectId = null; string? theTimeStamp = null; byte[]? thePayload = null; @@ -12093,8 +12094,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -12104,11 +12105,11 @@ out Reporting.Error? error IReference? theObserved = null; Direction? theDirection = null; StateOfEvent? theState = null; - string theMessageTopic = null; + string? theMessageTopic = null; IReference? theMessageBroker = null; - string theLastUpdate = null; - string theMinInterval = null; - string theMaxInterval = null; + string? theLastUpdate = null; + string? theMinInterval = null; + string? theMaxInterval = null; if (!isEmptySequence) { @@ -12484,7 +12485,7 @@ out Reporting.Error? error return null; } - string? textDirection; + string textDirection; try { textDirection = reader.ReadContentAsString(); @@ -12539,7 +12540,7 @@ out Reporting.Error? error return null; } - string? textState; + string textState; try { textState = reader.ReadContentAsString(); @@ -12970,8 +12971,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -13887,8 +13888,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IReference? theSemanticId = null; @@ -14420,8 +14421,8 @@ out Reporting.Error? error error = null; List? theExtensions = null; - string theCategory = null; - string theIdShort = null; + string? theCategory = null; + string? theIdShort = null; List? theDisplayName = null; List? theDescription = null; IAdministrativeInformation? theAdministration = null; @@ -15020,7 +15021,7 @@ out Reporting.Error? error return null; } - string? textType; + string textType; try { textType = reader.ReadContentAsString(); @@ -15355,7 +15356,7 @@ out Reporting.Error? error return null; } - string? textType; + string textType; try { textType = reader.ReadContentAsString(); @@ -16826,27 +16827,33 @@ out Reporting.Error? error } } - /* - if (theDataSpecification == null) - { - error = new Reporting.Error( - "The required property DataSpecification has not been given " + - "in the XML representation of an instance of class EmbeddedDataSpecification"); - return null; - } + //if (theDataSpecification == null) + //{ + // error = new Reporting.Error( + // "The required property DataSpecification has not been given " + + // "in the XML representation of an instance of class EmbeddedDataSpecification"); + // return null; + //} + + //if (theDataSpecificationContent == null) + //{ + // error = new Reporting.Error( + // "The required property DataSpecificationContent has not been given " + + // "in the XML representation of an instance of class EmbeddedDataSpecification"); + // return null; + //} + + //return new Aas.EmbeddedDataSpecification( + // theDataSpecification + // ?? throw new System.InvalidOperationException( + // "Unexpected null, had to be handled before"), + // theDataSpecificationContent + // ?? throw new System.InvalidOperationException( + // "Unexpected null, had to be handled before")); - if (theDataSpecificationContent == null) - { - error = new Reporting.Error( - "The required property DataSpecificationContent has not been given " + - "in the XML representation of an instance of class EmbeddedDataSpecification"); - return null; - } - */ - return new EmbeddedDataSpecification(theDataSpecification, theDataSpecificationContent); - } - + } // internal static Aas.EmbeddedDataSpecification? EmbeddedDataSpecificationFromSequence + /// /// Deserialize an instance of class EmbeddedDataSpecification from an XML element. /// @@ -18867,15 +18874,15 @@ out Reporting.Error? error List? thePreferredName = null; List? theShortName = null; - string theUnit = null; + string? theUnit = null; IReference? theUnitId = null; - string theSourceOfDefinition = null; - string theSymbol = null; + string? theSourceOfDefinition = null; + string? theSymbol = null; DataTypeIec61360? theDataType = null; List? theDefinition = null; - string theValueFormat = null; + string? theValueFormat = null; IValueList? theValueList = null; - string theValue = null; + string? theValue = null; ILevelType? theLevelType = null; if (!isEmptySequence) @@ -19134,7 +19141,7 @@ out Reporting.Error? error return null; } - string? textDataType; + string textDataType; try { textDataType = reader.ReadContentAsString(); @@ -20619,7 +20626,7 @@ public static Aas.LangStringTextType LangStringTextTypeFrom( /// Thrown when the element is not a valid XML /// representation of Environment. /// - public static Environment EnvironmentFrom( + public static Aas.Environment EnvironmentFrom( Xml.XmlReader reader) { Aas.Environment? result = ( @@ -20896,7 +20903,7 @@ private void ExtensionToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -20950,7 +20957,7 @@ private void ExtensionToSequence( writer.WriteEndElement(); } - if (that.RefersTo != null && that.RefersTo.Count > 0) + if (that.RefersTo != null) { writer.WriteStartElement( "refersTo", @@ -20984,7 +20991,7 @@ private void AdministrativeInformationToSequence( Aas.IAdministrativeInformation that, Xml.XmlWriter writer) { - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -21080,7 +21087,7 @@ private void QualifierToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -21179,7 +21186,7 @@ private void AssetAdministrationShellToSequence( Aas.IAssetAdministrationShell that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -21219,7 +21226,7 @@ private void AssetAdministrationShellToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -21235,7 +21242,7 @@ private void AssetAdministrationShellToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -21273,7 +21280,7 @@ private void AssetAdministrationShellToSequence( writer.WriteEndElement(); - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -21312,7 +21319,7 @@ private void AssetAdministrationShellToSequence( writer.WriteEndElement(); - if (that.Submodels != null && that.Submodels.Count > 0) + if (that.Submodels != null) { writer.WriteStartElement( "submodels", @@ -21343,7 +21350,7 @@ public override void VisitAssetAdministrationShell( } private void AssetInformationToSequence( - IAssetInformation? that, + Aas.IAssetInformation that, Xml.XmlWriter writer) { writer.WriteStartElement( @@ -21372,7 +21379,7 @@ private void AssetInformationToSequence( writer.WriteEndElement(); } - if (that.SpecificAssetIds != null && that.SpecificAssetIds.Count > 0) + if (that.SpecificAssetIds != null) { writer.WriteStartElement( "specificAssetIds", @@ -21415,7 +21422,7 @@ private void AssetInformationToSequence( } // private void AssetInformationToSequence public override void VisitAssetInformation( - IAssetInformation? that, + Aas.IAssetInformation that, Xml.XmlWriter writer) { writer.WriteStartElement( @@ -21483,7 +21490,7 @@ private void SpecificAssetIdToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -21548,7 +21555,7 @@ private void SubmodelToSequence( Aas.ISubmodel that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -21588,7 +21595,7 @@ private void SubmodelToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -21604,7 +21611,7 @@ private void SubmodelToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -21672,7 +21679,7 @@ private void SubmodelToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -21688,7 +21695,7 @@ private void SubmodelToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -21704,7 +21711,7 @@ private void SubmodelToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -21720,7 +21727,7 @@ private void SubmodelToSequence( writer.WriteEndElement(); } - if (that.SubmodelElements != null && that.SubmodelElements.Count > 0) + if (that.SubmodelElements != null) { writer.WriteStartElement( "submodelElements", @@ -21754,7 +21761,7 @@ private void RelationshipElementToSequence( Aas.IRelationshipElement that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -21794,7 +21801,7 @@ private void RelationshipElementToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -21810,7 +21817,7 @@ private void RelationshipElementToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -21839,7 +21846,7 @@ private void RelationshipElementToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -21855,7 +21862,7 @@ private void RelationshipElementToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -21871,7 +21878,7 @@ private void RelationshipElementToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -21925,7 +21932,7 @@ private void SubmodelElementListToSequence( Aas.ISubmodelElementList that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -21965,7 +21972,7 @@ private void SubmodelElementListToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -21981,7 +21988,7 @@ private void SubmodelElementListToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -22010,7 +22017,7 @@ private void SubmodelElementListToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -22026,7 +22033,7 @@ private void SubmodelElementListToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -22042,7 +22049,7 @@ private void SubmodelElementListToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -22114,7 +22121,7 @@ private void SubmodelElementListToSequence( writer.WriteEndElement(); } - if (that.Value != null && that.Value.Count > 0) + if (that.Value != null) { writer.WriteStartElement( "value", @@ -22148,7 +22155,7 @@ private void SubmodelElementCollectionToSequence( Aas.ISubmodelElementCollection that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -22188,7 +22195,7 @@ private void SubmodelElementCollectionToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -22204,7 +22211,7 @@ private void SubmodelElementCollectionToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -22233,7 +22240,7 @@ private void SubmodelElementCollectionToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -22249,7 +22256,7 @@ private void SubmodelElementCollectionToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -22265,7 +22272,7 @@ private void SubmodelElementCollectionToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -22281,7 +22288,7 @@ private void SubmodelElementCollectionToSequence( writer.WriteEndElement(); } - if (that.Value != null && that.Value.Count > 0) + if (that.Value != null) { writer.WriteStartElement( "value", @@ -22315,7 +22322,7 @@ private void PropertyToSequence( Aas.IProperty that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -22355,7 +22362,7 @@ private void PropertyToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -22371,7 +22378,7 @@ private void PropertyToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -22400,7 +22407,7 @@ private void PropertyToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -22416,7 +22423,7 @@ private void PropertyToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -22432,7 +22439,7 @@ private void PropertyToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -22505,7 +22512,7 @@ private void MultiLanguagePropertyToSequence( Aas.IMultiLanguageProperty that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -22545,7 +22552,7 @@ private void MultiLanguagePropertyToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -22561,7 +22568,7 @@ private void MultiLanguagePropertyToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -22590,7 +22597,7 @@ private void MultiLanguagePropertyToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -22606,7 +22613,7 @@ private void MultiLanguagePropertyToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -22622,7 +22629,7 @@ private void MultiLanguagePropertyToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -22685,7 +22692,7 @@ private void RangeToSequence( Aas.IRange that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -22725,7 +22732,7 @@ private void RangeToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -22741,7 +22748,7 @@ private void RangeToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -22770,7 +22777,7 @@ private void RangeToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -22786,7 +22793,7 @@ private void RangeToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -22802,7 +22809,7 @@ private void RangeToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -22874,7 +22881,7 @@ private void ReferenceElementToSequence( Aas.IReferenceElement that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -22914,7 +22921,7 @@ private void ReferenceElementToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -22930,7 +22937,7 @@ private void ReferenceElementToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -22959,7 +22966,7 @@ private void ReferenceElementToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -22975,7 +22982,7 @@ private void ReferenceElementToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -22991,7 +22998,7 @@ private void ReferenceElementToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -23038,7 +23045,7 @@ private void BlobToSequence( Aas.IBlob that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -23078,7 +23085,7 @@ private void BlobToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -23094,7 +23101,7 @@ private void BlobToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -23123,7 +23130,7 @@ private void BlobToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -23139,7 +23146,7 @@ private void BlobToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -23155,7 +23162,7 @@ private void BlobToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -23212,7 +23219,7 @@ private void FileToSequence( Aas.IFile that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -23252,7 +23259,7 @@ private void FileToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -23268,7 +23275,7 @@ private void FileToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -23297,7 +23304,7 @@ private void FileToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -23313,7 +23320,7 @@ private void FileToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -23329,7 +23336,7 @@ private void FileToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -23384,7 +23391,7 @@ private void AnnotatedRelationshipElementToSequence( Aas.IAnnotatedRelationshipElement that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -23424,7 +23431,7 @@ private void AnnotatedRelationshipElementToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -23440,7 +23447,7 @@ private void AnnotatedRelationshipElementToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -23469,7 +23476,7 @@ private void AnnotatedRelationshipElementToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -23485,7 +23492,7 @@ private void AnnotatedRelationshipElementToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -23501,7 +23508,7 @@ private void AnnotatedRelationshipElementToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -23537,7 +23544,7 @@ private void AnnotatedRelationshipElementToSequence( writer.WriteEndElement(); - if (that.Annotations != null && that.Annotations.Count > 0) + if (that.Annotations != null) { writer.WriteStartElement( "annotations", @@ -23571,7 +23578,7 @@ private void EntityToSequence( Aas.IEntity that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -23611,7 +23618,7 @@ private void EntityToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -23627,7 +23634,7 @@ private void EntityToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -23656,7 +23663,7 @@ private void EntityToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -23672,7 +23679,7 @@ private void EntityToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -23688,7 +23695,7 @@ private void EntityToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -23704,7 +23711,7 @@ private void EntityToSequence( writer.WriteEndElement(); } - if (that.Statements != null && that.Statements.Count > 0) + if (that.Statements != null) { writer.WriteStartElement( "statements", @@ -23746,7 +23753,7 @@ private void EntityToSequence( writer.WriteEndElement(); } - if (that.SpecificAssetIds != null && that.SpecificAssetIds.Count > 0) + if (that.SpecificAssetIds != null) { writer.WriteStartElement( "specificAssetIds", @@ -23892,7 +23899,7 @@ private void BasicEventElementToSequence( Aas.IBasicEventElement that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -23932,7 +23939,7 @@ private void BasicEventElementToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -23948,7 +23955,7 @@ private void BasicEventElementToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -23977,7 +23984,7 @@ private void BasicEventElementToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -23993,7 +24000,7 @@ private void BasicEventElementToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -24009,7 +24016,7 @@ private void BasicEventElementToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -24142,7 +24149,7 @@ private void OperationToSequence( Aas.IOperation that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -24182,7 +24189,7 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -24198,7 +24205,7 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -24227,7 +24234,7 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -24243,7 +24250,7 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -24259,7 +24266,7 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -24275,7 +24282,7 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.InputVariables != null && that.InputVariables.Count > 0) + if (that.InputVariables != null) { writer.WriteStartElement( "inputVariables", @@ -24291,7 +24298,7 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.OutputVariables != null && that.OutputVariables.Count > 0) + if (that.OutputVariables != null) { writer.WriteStartElement( "outputVariables", @@ -24307,7 +24314,7 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.InoutputVariables != null && that.InoutputVariables.Count > 0) + if (that.InoutputVariables != null) { writer.WriteStartElement( "inoutputVariables", @@ -24369,7 +24376,7 @@ private void CapabilityToSequence( Aas.ICapability that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -24409,7 +24416,7 @@ private void CapabilityToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -24425,7 +24432,7 @@ private void CapabilityToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -24454,7 +24461,7 @@ private void CapabilityToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null && that.SupplementalSemanticIds.Count > 0) + if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( "supplementalSemanticIds", @@ -24470,7 +24477,7 @@ private void CapabilityToSequence( writer.WriteEndElement(); } - if (that.Qualifiers != null && that.Qualifiers.Count > 0) + if (that.Qualifiers != null) { writer.WriteStartElement( "qualifiers", @@ -24486,7 +24493,7 @@ private void CapabilityToSequence( writer.WriteEndElement(); } - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -24520,7 +24527,7 @@ private void ConceptDescriptionToSequence( Aas.IConceptDescription that, Xml.XmlWriter writer) { - if (that.Extensions != null && that.Extensions.Count > 0) + if (that.Extensions != null) { writer.WriteStartElement( "extensions", @@ -24560,7 +24567,7 @@ private void ConceptDescriptionToSequence( writer.WriteEndElement(); } - if (that.DisplayName != null && that.DisplayName.Count > 0) + if (that.DisplayName != null) { writer.WriteStartElement( "displayName", @@ -24576,7 +24583,7 @@ private void ConceptDescriptionToSequence( writer.WriteEndElement(); } - if (that.Description != null && that.Description.Count > 0) + if (that.Description != null) { writer.WriteStartElement( "description", @@ -24614,7 +24621,7 @@ private void ConceptDescriptionToSequence( writer.WriteEndElement(); - if (that.EmbeddedDataSpecifications != null && that.EmbeddedDataSpecifications.Count > 0) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( "embeddedDataSpecifications", @@ -24630,7 +24637,7 @@ private void ConceptDescriptionToSequence( writer.WriteEndElement(); } - if (that.IsCaseOf != null && that.IsCaseOf.Count > 0) + if (that.IsCaseOf != null) { writer.WriteStartElement( "isCaseOf", @@ -24661,7 +24668,7 @@ public override void VisitConceptDescription( } private void ReferenceToSequence( - IReference? that, + Aas.IReference that, Xml.XmlWriter writer) { if (that == null) @@ -24695,25 +24702,22 @@ private void ReferenceToSequence( writer.WriteEndElement(); } - if (that.Keys != null && that.Keys.Count > 0) - { - writer.WriteStartElement( - "keys", - NS); - - foreach (var item in that.Keys) - { - this.Visit( - item, - writer); - } + writer.WriteStartElement( + "keys", + NS); - writer.WriteEndElement(); + foreach (var item in that.Keys) + { + this.Visit( + item, + writer); } + + writer.WriteEndElement(); } // private void ReferenceToSequence public override void VisitReference( - IReference? that, + Aas.IReference that, Xml.XmlWriter writer) { writer.WriteStartElement( @@ -24842,7 +24846,7 @@ private void EnvironmentToSequence( Aas.IEnvironment that, Xml.XmlWriter writer) { - if (that.AssetAdministrationShells != null && that.AssetAdministrationShells.Count > 0) + if (that.AssetAdministrationShells != null) { writer.WriteStartElement( "assetAdministrationShells", @@ -24858,7 +24862,7 @@ private void EnvironmentToSequence( writer.WriteEndElement(); } - if (that.Submodels != null && that.Submodels.Count > 0) + if (that.Submodels != null) { writer.WriteStartElement( "submodels", @@ -24874,7 +24878,7 @@ private void EnvironmentToSequence( writer.WriteEndElement(); } - if (that.ConceptDescriptions != null && that.ConceptDescriptions.Count > 0) + if (that.ConceptDescriptions != null) { writer.WriteStartElement( "conceptDescriptions", @@ -24924,16 +24928,16 @@ private void EmbeddedDataSpecificationToSequence( if (that.DataSpecificationContent != null) { writer.WriteStartElement( - "dataSpecificationContent", - NS); + "dataSpecificationContent", + NS); - if (that.DataSpecificationContent != null) - this.Visit( - that.DataSpecificationContent, - writer); + this.Visit( + that.DataSpecificationContent, + writer); writer.WriteEndElement(); } + } // private void EmbeddedDataSpecificationToSequence public override void VisitEmbeddedDataSpecification( @@ -25044,21 +25048,18 @@ private void ValueListToSequence( Aas.IValueList that, Xml.XmlWriter writer) { - if (that.ValueReferencePairs != null && that.ValueReferencePairs.Count > 0) - { - writer.WriteStartElement( - "valueReferencePairs", - NS); - - foreach (var item in that.ValueReferencePairs) - { - this.Visit( - item, - writer); - } + writer.WriteStartElement( + "valueReferencePairs", + NS); - writer.WriteEndElement(); + foreach (var item in that.ValueReferencePairs) + { + this.Visit( + item, + writer); } + + writer.WriteEndElement(); } // private void ValueListToSequence public override void VisitValueList( @@ -25186,23 +25187,20 @@ private void DataSpecificationIec61360ToSequence( Aas.IDataSpecificationIec61360 that, Xml.XmlWriter writer) { - if (that.PreferredName != null && that.PreferredName.Count > 0) - { - writer.WriteStartElement( - "preferredName", - NS); - - foreach (var item in that.PreferredName) - { - this.Visit( - item, - writer); - } + writer.WriteStartElement( + "preferredName", + NS); - writer.WriteEndElement(); + foreach (var item in that.PreferredName) + { + this.Visit( + item, + writer); } - if (that.ShortName != null && that.ShortName.Count > 0) + writer.WriteEndElement(); + + if (that.ShortName != null) { writer.WriteStartElement( "shortName", @@ -25284,7 +25282,7 @@ private void DataSpecificationIec61360ToSequence( writer.WriteEndElement(); } - if (that.Definition != null && that.Definition.Count > 0) + if (that.Definition != null) { writer.WriteStartElement( "definition", @@ -25390,7 +25388,7 @@ public static class Serialize /// Serialize an instance of the meta-model to XML. /// public static void To( - IClass? that, + Aas.IClass that, Xml.XmlWriter writer) { Serialize._visitorWithWriter.Visit( diff --git a/src/AasxCsharpLibrary/AasxCsharpLibrary.csproj b/src/AasxCsharpLibrary/AasxCsharpLibrary.csproj index f342abea1..d63d52f2f 100644 --- a/src/AasxCsharpLibrary/AasxCsharpLibrary.csproj +++ b/src/AasxCsharpLibrary/AasxCsharpLibrary.csproj @@ -1,6 +1,6 @@ - net8.0 + net6.0 Library AdminShellNS false diff --git a/src/AasxServer.sln b/src/AasxServer.sln index f1a5e4a4c..8cd90abe3 100644 --- a/src/AasxServer.sln +++ b/src/AasxServer.sln @@ -7,15 +7,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxServerStandardBib", "Aa EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B8C116C4-932B-4071-9DCC-D4F64E3C4E6F}" ProjectSection(SolutionItems) = preProject + .editorconfig = .editorconfig + ..\.gitignore = ..\.gitignore ..\CHANGELOG.md = ..\CHANGELOG.md - ..\README.md = ..\README.md ..\CONTRIBUTING.md = ..\CONTRIBUTING.md - ..\LICENSE.TXT = ..\LICENSE.TXT ..\CONTRIBUTORS.md = ..\CONTRIBUTORS.md current_version.cfg = current_version.cfg global.json = global.json - ..\.gitignore = ..\.gitignore - .editorconfig = .editorconfig + ..\LICENSE.TXT = ..\LICENSE.TXT + ..\README.md = ..\README.md ..\SECURITY.md = ..\SECURITY.md EndProjectSection EndProject @@ -45,8 +45,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxServerDB", "AasxServerD EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".github", ".github", "{F847719C-7CF2-40D5-BF7B-6F51E551E13F}" ProjectSection(SolutionItems) = preProject - ..\.github\pull_request_template.md = ..\.github\pull_request_template.md ..\.github\changelog_configuration.json = ..\.github\changelog_configuration.json + ..\.github\pull_request_template.md = ..\.github\pull_request_template.md EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "issue_templates", "issue_templates", "{6F3BB70E-0095-4D58-AE5E-D7D02FD7BB01}" @@ -60,10 +60,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "workflows", "workflows", "{ ProjectSection(SolutionItems) = preProject ..\.github\workflows\build-and-publish-docker-images.yml = ..\.github\workflows\build-and-publish-docker-images.yml ..\.github\workflows\check-release.yml = ..\.github\workflows\check-release.yml - ..\.github\workflows\draft-release-on-merge-to-release-branch.yml = ..\.github\workflows\draft-release-on-merge-to-release-branch.yml - ..\.github\workflows\prerelease-on-merge-to-main.yml = ..\.github\workflows\prerelease-on-merge-to-main.yml ..\.github\workflows\code-analysis.yml = ..\.github\workflows\code-analysis.yml ..\.github\workflows\create-developer-prerelease.yml = ..\.github\workflows\create-developer-prerelease.yml + ..\.github\workflows\draft-release-on-merge-to-release-branch.yml = ..\.github\workflows\draft-release-on-merge-to-release-branch.yml + ..\.github\workflows\prerelease-on-merge-to-main.yml = ..\.github\workflows\prerelease-on-merge-to-main.yml EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ProjectScripts", "ProjectScripts", "{39F9287F-CBC6-4F56-AA55-81A013A89AAE}" @@ -71,6 +71,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ProjectScripts", "ProjectSc AdditionalVerbsInImperativeMood.txt = AdditionalVerbsInImperativeMood.txt BuildDockerImages.ps1 = BuildDockerImages.ps1 BuildForRelease.ps1 = BuildForRelease.ps1 + BuildVersionNumber.ps1 = BuildVersionNumber.ps1 Check.ps1 = Check.ps1 CheckFormat.ps1 = CheckFormat.ps1 CheckHelpInReadme.ps1 = CheckHelpInReadme.ps1 @@ -78,27 +79,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ProjectScripts", "ProjectSc CopyLicense.ps1 = CopyLicense.ps1 FormatCode.ps1 = FormatCode.ps1 PackageRelease.ps1 = PackageRelease.ps1 - BuildVersionNumber.ps1 = BuildVersionNumber.ps1 UpdateProjectVersions.ps1 = UpdateProjectVersions.ps1 EndProjectSection EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docker", "Docker", "{9787F0F9-A50D-4E8E-8AEA-BC7242740BE9}" ProjectSection(SolutionItems) = preProject - docker\docker-compose.yaml = docker\docker-compose.yaml docker\docker-compose-demo.yaml = docker\docker-compose-demo.yaml + docker\docker-compose.yaml = docker\docker-compose.yaml docker\Dockerfile-AasxServerAspNetCore = docker\Dockerfile-AasxServerAspNetCore docker\Dockerfile-AasxServerBlazor = docker\Dockerfile-AasxServerBlazor EndProjectSection EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AasSecurityTests", "AasSecurityTests\AasSecurityTests.csproj", "{716CC065-F58C-455E-8079-3A21C59D42E3}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasSecurityTests", "AasSecurityTests\AasSecurityTests.csproj", "{716CC065-F58C-455E-8079-3A21C59D42E3}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Lib.V3.Tests", "IO.Swagger.Lib.V3.Tests\IO.Swagger.Lib.V3.Tests.csproj", "{64148CC9-DE3E-465A-98E8-370431226E70}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IO.Swagger.Lib.V3.Tests", "IO.Swagger.Lib.V3.Tests\IO.Swagger.Lib.V3.Tests.csproj", "{64148CC9-DE3E-465A-98E8-370431226E70}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger.Registry.Lib.V3.Tests", "IO.Swagger.Registry.Lib.V3.Tests\IO.Swagger.Registry.Lib.V3.Tests.csproj", "{CF9C2ABA-944C-46EB-8788-346D432321D5}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IO.Swagger.Registry.Lib.V3.Tests", "IO.Swagger.Registry.Lib.V3.Tests\IO.Swagger.Registry.Lib.V3.Tests.csproj", "{CF9C2ABA-944C-46EB-8788-346D432321D5}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AasxServerBlazorTests", "AasxServerBlazorTests\AasxServerBlazorTests.csproj", "{731275DC-5730-49FB-A721-3A39EE3F516E}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxServerBlazorTests", "AasxServerBlazorTests\AasxServerBlazorTests.csproj", "{731275DC-5730-49FB-A721-3A39EE3F516E}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AasxCsharpLibrary.Tests", "AasxCsharpLibrary.Tests\AasxCsharpLibrary.Tests.csproj", "{B9B7BFEC-AEBB-42DB-A1C5-DAB16029F850}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxCsharpLibrary.Tests", "AasxCsharpLibrary.Tests\AasxCsharpLibrary.Tests.csproj", "{B9B7BFEC-AEBB-42DB-A1C5-DAB16029F850}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -441,9 +441,6 @@ Global GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {A6054B71-0BA2-4582-9B76-805D46670242} - EndGlobalSection GlobalSection(NestedProjects) = preSolution {F847719C-7CF2-40D5-BF7B-6F51E551E13F} = {B8C116C4-932B-4071-9DCC-D4F64E3C4E6F} {6F3BB70E-0095-4D58-AE5E-D7D02FD7BB01} = {F847719C-7CF2-40D5-BF7B-6F51E551E13F} @@ -451,4 +448,7 @@ Global {39F9287F-CBC6-4F56-AA55-81A013A89AAE} = {B8C116C4-932B-4071-9DCC-D4F64E3C4E6F} {9787F0F9-A50D-4E8E-8AEA-BC7242740BE9} = {B8C116C4-932B-4071-9DCC-D4F64E3C4E6F} EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {A6054B71-0BA2-4582-9B76-805D46670242} + EndGlobalSection EndGlobal diff --git a/src/AasxServerBlazor/Configuration/DependencyRegistry.cs b/src/AasxServerBlazor/Configuration/DependencyRegistry.cs index fbc7fbd67..aa6f19e3d 100644 --- a/src/AasxServerBlazor/Configuration/DependencyRegistry.cs +++ b/src/AasxServerBlazor/Configuration/DependencyRegistry.cs @@ -67,5 +67,6 @@ public static void Register(IServiceCollection services) services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } \ No newline at end of file diff --git a/src/AasxServerBlazor/Configuration/ServerConfiguration.cs b/src/AasxServerBlazor/Configuration/ServerConfiguration.cs index d41882609..695a160ef 100644 --- a/src/AasxServerBlazor/Configuration/ServerConfiguration.cs +++ b/src/AasxServerBlazor/Configuration/ServerConfiguration.cs @@ -127,6 +127,7 @@ public static void ConfigureEnvironment(IApplicationBuilder app, IWebHostEnviron app.UseMiddleware(); app.UseStaticFiles(); + app.UsePathBase("/api/v3.0"); app.UseRouting(); app.UseAuthorization(); app.UseCors(CorsPolicyName); diff --git a/src/AasxServerBlazor/Pages/TreePage.razor b/src/AasxServerBlazor/Pages/TreePage.razor index 03c75cdca..b4e3011d5 100644 --- a/src/AasxServerBlazor/Pages/TreePage.razor +++ b/src/AasxServerBlazor/Pages/TreePage.razor @@ -336,8 +336,9 @@ while (parent is not Submodel) { if (parent is ISubmodelElementList parentList) - { - if (path.Equals(sme.IdShort)) + { + //Considering child elements of SML can have null idShorts + if (path == null || path.Equals(sme.IdShort)) { var index = parentList.Value?.IndexOf(sme); path = $"[{index}]"; @@ -553,11 +554,13 @@ if (SelectedNode is {Tag: BasicEventElement be} && be.Observed != null) { - var observedSingleKey = be.Observed.GetAsExactlyOneKey().ToStringExtended(); + // var observedSingleKey = be.Observed.GetAsExactlyOneKey().ToStringExtended(); + var observedSingleKey = be.Observed.Keys.ToStringExtended(); Observed @($" {observedSingleKey}")
- var refsme = Program.env[0].AasEnv.FindReferableByReference(be.Observed); + // var refsme = Program.env[0].AasEnv.FindReferableByReference(be.Observed); + var refsme = Program.env[SelectedNode.envIndex].AasEnv.FindReferableByReference(be.Observed); if (refsme != null) { UPDATE @TimeStamp.DateTimeToString(refsme.TimeStamp) diff --git a/src/AasxServerStandardBib/Interfaces/IAssetAdministrationShellService.cs b/src/AasxServerStandardBib/Interfaces/IAssetAdministrationShellService.cs index e56a0f291..0e3fe456f 100644 --- a/src/AasxServerStandardBib/Interfaces/IAssetAdministrationShellService.cs +++ b/src/AasxServerStandardBib/Interfaces/IAssetAdministrationShellService.cs @@ -28,7 +28,7 @@ public interface IAssetAdministrationShellService void DeleteSubmodelElementByPath(string aasIdentifier, string submodelIdentifier, string idShortPath); void DeleteSubmodelReferenceById(string aasIdentifier, string submodelIdentifier); void DeleteThumbnail(string aasIdentifier); - List GetAllAssetAdministrationShells(List? assetIds = null, string? idShort = null); + List GetAllAssetAdministrationShells(List? assetIds = null, string? idShort = null); List GetAllSubmodelElements(string aasIdentifier, string submodelIdentifier); List GetAllSubmodelReferencesFromAas(string aasIdentifier); IAssetAdministrationShell GetAssetAdministrationShellById(string aasIdentifier); diff --git a/src/AasxServerStandardBib/Interfaces/IConceptDescriptionService.cs b/src/AasxServerStandardBib/Interfaces/IConceptDescriptionService.cs index bb769daa7..08a4b6d1c 100644 --- a/src/AasxServerStandardBib/Interfaces/IConceptDescriptionService.cs +++ b/src/AasxServerStandardBib/Interfaces/IConceptDescriptionService.cs @@ -20,7 +20,7 @@ public interface IConceptDescriptionService { IConceptDescription CreateConceptDescription(IConceptDescription body); void DeleteConceptDescriptionById(string cdIdentifier); - List GetAllConceptDescriptions(string idShort, Reference isCaseOf, Reference dataSpecificationRef); + List GetAllConceptDescriptions(string idShort = null, Reference isCaseOf = null, Reference dataSpecificationRef = null); IConceptDescription GetConceptDescriptionById(string cdIdentifier); void UpdateConceptDescriptionById(ConceptDescription body, string cdIdentifier); } diff --git a/src/AasxServerStandardBib/Interfaces/ISubmodelService.cs b/src/AasxServerStandardBib/Interfaces/ISubmodelService.cs index 1df444324..b9aa31778 100644 --- a/src/AasxServerStandardBib/Interfaces/ISubmodelService.cs +++ b/src/AasxServerStandardBib/Interfaces/ISubmodelService.cs @@ -25,7 +25,7 @@ public interface ISubmodelService void DeleteSubmodelById(string submodelIdentifier); void DeleteSubmodelElementByPath(string submodelIdentifier, string idShortPath); List GetAllSubmodelElements(string submodelIdentifier); - List GetAllSubmodels(); + List GetAllSubmodels(IReference reqSemanticId = null, string idShort = null); string GetFileByPath(string submodelIdentifier, string idShortPath, out byte[] byteArray, out long fileSize); ISubmodel GetSubmodelById(string submodelIdentifier); ISubmodelElement GetSubmodelElementByPath(string submodelIdentifier, string idShortPath); diff --git a/src/AasxServerStandardBib/Services/AssetAdministrationShellService.cs b/src/AasxServerStandardBib/Services/AssetAdministrationShellService.cs index 1e4238b3a..a5cb93dee 100644 --- a/src/AasxServerStandardBib/Services/AssetAdministrationShellService.cs +++ b/src/AasxServerStandardBib/Services/AssetAdministrationShellService.cs @@ -196,13 +196,13 @@ public void DeleteSubmodelReferenceById(string aasIdentifier, string submodelIde - public List GetAllAssetAdministrationShells(List? assetIds = null, string? idShort = null) + public List GetAllAssetAdministrationShells(List assetIds = null, string? idShort = null) { var output = _packageEnvService.GetAllAssetAdministrationShells(); //Apply filters - if (output.Any()) + if (output.Count != 0) { if (!string.IsNullOrEmpty(idShort)) { @@ -216,20 +216,40 @@ public List GetAllAssetAdministrationShells(List(); foreach (var assetId in assetIds) { - aasList = output.Where(a => a.AssetInformation.SpecificAssetIds.ContainsSpecificAssetId(assetId)).ToList(); + var result = new List(); + if (!string.IsNullOrEmpty(assetId.Name)) + { + if (assetId.Name.Equals("globalAssetId", StringComparison.OrdinalIgnoreCase)) + { + result = output.Where(a => a.AssetInformation.GlobalAssetId!.Equals(assetId.Value)).ToList(); + } + else + { + result = output.Where(a => a.AssetInformation.SpecificAssetIds!.ContainsSpecificAssetId(assetId)).ToList(); + } + } + else + { + throw new InvalidOperationException("The attribute Name cannot be null in the requested assetId."); + } + + if (result.Count != 0) + { + aasList.AddRange(result); + } } - if (aasList.Any()) + if (aasList.Count != 0) { output = aasList; } else { - _logger.LogInformation($"No AAS with requested specific assetId found."); + _logger.LogInformation($"No AAS with requested assetId found."); } } } diff --git a/src/AasxServerStandardBib/Services/ConceptDescriptionService.cs b/src/AasxServerStandardBib/Services/ConceptDescriptionService.cs index 938c347f9..fa3c8c5f7 100644 --- a/src/AasxServerStandardBib/Services/ConceptDescriptionService.cs +++ b/src/AasxServerStandardBib/Services/ConceptDescriptionService.cs @@ -58,7 +58,7 @@ public void DeleteConceptDescriptionById(string cdIdentifier) _packageEnvService.DeleteConceptDescriptionById(cdIdentifier); } - public List GetAllConceptDescriptions(string idShort, Reference isCaseOf, Reference dataSpecificationRef) + public List GetAllConceptDescriptions(string idShort = null, Reference isCaseOf = null, Reference dataSpecificationRef = null) { //Get All Concept descriptions var output = _packageEnvService.GetAllConceptDescriptions(); diff --git a/src/AasxServerStandardBib/Services/SubmodelService.cs b/src/AasxServerStandardBib/Services/SubmodelService.cs index 84877162a..6a5e26fa7 100644 --- a/src/AasxServerStandardBib/Services/SubmodelService.cs +++ b/src/AasxServerStandardBib/Services/SubmodelService.cs @@ -16,10 +16,12 @@ using AasxServerStandardBib.Interfaces; using AasxServerStandardBib.Logging; using AasxServerStandardBib.Transformers; +using AdminShellNS.Extensions; using Extensions; using System; using System.Collections.Generic; using System.IO; +using System.Linq; using System.Text.RegularExpressions; using System.Threading.Tasks; @@ -488,7 +490,35 @@ public void ReplaceSubmodelElementByPath(string submodelIdentifier, string idSho } } - public List GetAllSubmodels() => _packageEnvService.GetAllSubmodels(); + public List GetAllSubmodels(IReference reqSemanticId = null, string idShort = null) + { + var output = _packageEnvService.GetAllSubmodels(); + + if(!output.IsNullOrEmpty()) + { + if (!string.IsNullOrEmpty(idShort)) + { + _logger.LogDebug($"Filtering Submodels with idShort {idShort}."); + output = output.Where(s => s.IdShort.Equals(idShort)).ToList(); + if (output.IsNullOrEmpty()) + { + _logger.LogInformation($"No Submodels with idShort {idShort} found."); + } + } + + if(reqSemanticId != null) + { + _logger.LogDebug($"Filtering Submodels with requested Semnatic Id."); + output = output.Where(s => s.SemanticId != null && s.SemanticId.Matches(reqSemanticId)).ToList(); + if (output.IsNullOrEmpty()) + { + _logger.LogInformation($"No Submodels with requested semanticId found."); + } + } + } + + return output; + } public ISubmodel CreateSubmodel(ISubmodel newSubmodel, string aasIdentifier) { diff --git a/src/DataTransferObjects/CommonDTOs/AdministrativeInformationDTO.cs b/src/DataTransferObjects/CommonDTOs/AdministrativeInformationDTO.cs index c93c7e56d..ce23f8356 100644 --- a/src/DataTransferObjects/CommonDTOs/AdministrativeInformationDTO.cs +++ b/src/DataTransferObjects/CommonDTOs/AdministrativeInformationDTO.cs @@ -14,9 +14,9 @@ namespace DataTransferObjects.CommonDTOs { public record class AdministrativeInformationDTO( - List? embeddedDataSpecifications = null, - string version = null, - string revision = null, - ReferenceDTO? creator = null, - string templateId = null) : IDTO; + List? EmbeddedDataSpecifications = null, + string? Version = null, + string? Revision = null, + ReferenceDTO? Creator = null, + string? TemplateId = null) : IDTO; } diff --git a/src/DataTransferObjects/CommonDTOs/EmbeddedDataSpecificationDTO.cs b/src/DataTransferObjects/CommonDTOs/EmbeddedDataSpecificationDTO.cs index a0e2b2989..d1953628d 100644 --- a/src/DataTransferObjects/CommonDTOs/EmbeddedDataSpecificationDTO.cs +++ b/src/DataTransferObjects/CommonDTOs/EmbeddedDataSpecificationDTO.cs @@ -1,18 +1,6 @@ -/******************************************************************************** -* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License Version 2.0 which is available at -* https://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - namespace DataTransferObjects.CommonDTOs { // TODO (jtikekar, 2023-09-04): support DataSpecificationContent - public record class EmbeddedDataSpecificationDTO(ReferenceDTO dataSpecification) : IDTO; + public record class EmbeddedDataSpecificationDTO( + ReferenceDTO DataSpecification) : IDTO; } diff --git a/src/DataTransferObjects/CommonDTOs/ExtensionDTO.cs b/src/DataTransferObjects/CommonDTOs/ExtensionDTO.cs index af9ffa9bd..67ad965c9 100644 --- a/src/DataTransferObjects/CommonDTOs/ExtensionDTO.cs +++ b/src/DataTransferObjects/CommonDTOs/ExtensionDTO.cs @@ -16,10 +16,10 @@ namespace DataTransferObjects.CommonDTOs { public record class ExtensionDTO( - string? name, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - DataTypeDefXsd? valueType = null, - string value = null, - List? refersTo = null) : IDTO; + string Name, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + DataTypeDefXsd? ValueType = null, + string? Value = null, + List? RefersTo = null) : IDTO; } diff --git a/src/DataTransferObjects/CommonDTOs/KeyDTO.cs b/src/DataTransferObjects/CommonDTOs/KeyDTO.cs index 1bb2cae8c..2790bf0d5 100644 --- a/src/DataTransferObjects/CommonDTOs/KeyDTO.cs +++ b/src/DataTransferObjects/CommonDTOs/KeyDTO.cs @@ -16,6 +16,6 @@ namespace DataTransferObjects.CommonDTOs { public record class KeyDTO( - KeyTypes type, - string? value) : IDTO; + KeyTypes Type, + string Value) : IDTO; } diff --git a/src/DataTransferObjects/CommonDTOs/LangStringNameTypeDTO.cs b/src/DataTransferObjects/CommonDTOs/LangStringNameTypeDTO.cs index 5855b942c..7cb127cb5 100644 --- a/src/DataTransferObjects/CommonDTOs/LangStringNameTypeDTO.cs +++ b/src/DataTransferObjects/CommonDTOs/LangStringNameTypeDTO.cs @@ -14,6 +14,6 @@ namespace DataTransferObjects.CommonDTOs { public record class LangStringNameTypeDTO( - string? language, - string? text) : IDTO; + string Language, + string Text) : IDTO; } diff --git a/src/DataTransferObjects/CommonDTOs/LangStringTextTypeDTO.cs b/src/DataTransferObjects/CommonDTOs/LangStringTextTypeDTO.cs index 893088beb..01d59d293 100644 --- a/src/DataTransferObjects/CommonDTOs/LangStringTextTypeDTO.cs +++ b/src/DataTransferObjects/CommonDTOs/LangStringTextTypeDTO.cs @@ -14,6 +14,6 @@ namespace DataTransferObjects.CommonDTOs { public record class LangStringTextTypeDTO( - string? language, - string? text) : IDTO; + string Language, + string Text) : IDTO; } diff --git a/src/DataTransferObjects/CommonDTOs/QualifierDTO.cs b/src/DataTransferObjects/CommonDTOs/QualifierDTO.cs index 8f96971dc..d573e5dce 100644 --- a/src/DataTransferObjects/CommonDTOs/QualifierDTO.cs +++ b/src/DataTransferObjects/CommonDTOs/QualifierDTO.cs @@ -16,11 +16,11 @@ namespace DataTransferObjects.CommonDTOs { public record class QualifierDTO( - string? type, - DataTypeDefXsd valueType, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - QualifierKind? kind = null, - string value = null, - ReferenceDTO? valueId = null) : IDTO; + string Type, + DataTypeDefXsd ValueType, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + QualifierKind? Kind = null, + string? Value = null, + ReferenceDTO? ValueId = null) : IDTO; } diff --git a/src/DataTransferObjects/CommonDTOs/ReferenceDTO.cs b/src/DataTransferObjects/CommonDTOs/ReferenceDTO.cs index f21cb7039..a49096db7 100644 --- a/src/DataTransferObjects/CommonDTOs/ReferenceDTO.cs +++ b/src/DataTransferObjects/CommonDTOs/ReferenceDTO.cs @@ -16,7 +16,7 @@ namespace DataTransferObjects.CommonDTOs { public record class ReferenceDTO( - ReferenceTypes type, - List? keys, - ReferenceDTO? referredSemanticId = null) : IDTO; + ReferenceTypes Type, + List Keys, + ReferenceDTO? ReferredSemanticId = null) : IDTO; } diff --git a/src/DataTransferObjects/MetadataDTOs/AnnotatedRelationshipElementMetadata.cs b/src/DataTransferObjects/MetadataDTOs/AnnotatedRelationshipElementMetadata.cs index ca89ff185..cbdadcacd 100644 --- a/src/DataTransferObjects/MetadataDTOs/AnnotatedRelationshipElementMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/AnnotatedRelationshipElementMetadata.cs @@ -16,15 +16,14 @@ namespace DataTransferObjects.MetadataDTOs { public record class AnnotatedRelationshipElementMetadata( - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - List annotations = null, - string modelType = "AnnotatedRelationshipElement") : ISubmodelElementMetadata; + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "AnnotatedRelationshipElement") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/BasicEventElementMetadata.cs b/src/DataTransferObjects/MetadataDTOs/BasicEventElementMetadata.cs index ecd8b9e10..010196a61 100644 --- a/src/DataTransferObjects/MetadataDTOs/BasicEventElementMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/BasicEventElementMetadata.cs @@ -17,21 +17,22 @@ namespace DataTransferObjects.MetadataDTOs { public record class BasicEventElementMetadata( - Direction direction, - StateOfEvent state, - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - string messageTopic = null, - ReferenceDTO? messageBroker = null, - string lastUpdate = null, - string minInterval = null, - string maxInterval = null, string modelType = "BasicEventElement") : ISubmodelElementMetadata; + Direction Direction, + StateOfEvent State, + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string? MessageTopic = null, + ReferenceDTO? MessageBroker = null, + string? LastUpdate = null, + string? MinInterval = null, + string? MaxInterval = null, + string ModelType = "BasicEventElement") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/BlobMetadata.cs b/src/DataTransferObjects/MetadataDTOs/BlobMetadata.cs index a7ba625c3..75054be0d 100644 --- a/src/DataTransferObjects/MetadataDTOs/BlobMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/BlobMetadata.cs @@ -16,14 +16,14 @@ namespace DataTransferObjects.MetadataDTOs { public record class BlobMetadata( - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - string modelType = "Blob") : ISubmodelElementMetadata; + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "Blob") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/EntityMetadata.cs b/src/DataTransferObjects/MetadataDTOs/EntityMetadata.cs index 53132eed3..e6435f85b 100644 --- a/src/DataTransferObjects/MetadataDTOs/EntityMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/EntityMetadata.cs @@ -17,16 +17,15 @@ namespace DataTransferObjects.MetadataDTOs { public record class EntityMetadata( - EntityType entityType, - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - List statements = null, - string modelType = "Entity") : ISubmodelElementMetadata; + EntityType EntityType, + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "Entity") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/FileMetadata.cs b/src/DataTransferObjects/MetadataDTOs/FileMetadata.cs index 52489a152..afe223bb6 100644 --- a/src/DataTransferObjects/MetadataDTOs/FileMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/FileMetadata.cs @@ -16,14 +16,14 @@ namespace DataTransferObjects.MetadataDTOs { public record class FileMetadata( - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - string modelType = "File") : ISubmodelElementMetadata; + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "File") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/MultiLanguagePropertyMetadata.cs b/src/DataTransferObjects/MetadataDTOs/MultiLanguagePropertyMetadata.cs index 8c310b44f..386667fa3 100644 --- a/src/DataTransferObjects/MetadataDTOs/MultiLanguagePropertyMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/MultiLanguagePropertyMetadata.cs @@ -16,14 +16,14 @@ namespace DataTransferObjects.MetadataDTOs { public record class MultiLanguagePropertyMetadata( - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - string modelType = "MultiLanguageProperty") : ISubmodelElementMetadata; + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "MultiLanguageProperty") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/OperationMetadata.cs b/src/DataTransferObjects/MetadataDTOs/OperationMetadata.cs index d489c67b9..930446a71 100644 --- a/src/DataTransferObjects/MetadataDTOs/OperationMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/OperationMetadata.cs @@ -16,17 +16,17 @@ namespace DataTransferObjects.MetadataDTOs { public record class OperationMetadata( - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - List? inputVariables = null, - List? outputVariables = null, - List? inoutputVariables = null, - string modelType = "Operation") : ISubmodelElementMetadata; + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + List? InputVariables = null, + List? OutputVariables = null, + List? InoutputVariables = null, + string ModelType = "Operation") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/PropertyMetadata.cs b/src/DataTransferObjects/MetadataDTOs/PropertyMetadata.cs index c22fb1bc7..3d188514e 100644 --- a/src/DataTransferObjects/MetadataDTOs/PropertyMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/PropertyMetadata.cs @@ -19,15 +19,15 @@ namespace DataTransferObjects.MetadataDTOs // TODO (jtikekar, 2023-09-04):DTOs for nested structure, may have performance impact public record class PropertyMetadata( - DataTypeDefXsd valueType, - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - string modelType = "Property") : ISubmodelElementMetadata; + DataTypeDefXsd ValueType, + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "Property") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/RangeMetadata.cs b/src/DataTransferObjects/MetadataDTOs/RangeMetadata.cs index 169dda60e..c46209762 100644 --- a/src/DataTransferObjects/MetadataDTOs/RangeMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/RangeMetadata.cs @@ -17,15 +17,15 @@ namespace DataTransferObjects.MetadataDTOs { public record class RangeMetadata( - DataTypeDefXsd valueType, - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - string modelType = "Range") : ISubmodelElementMetadata; + DataTypeDefXsd ValueType, + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "Range") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/ReferenceElementMetadata.cs b/src/DataTransferObjects/MetadataDTOs/ReferenceElementMetadata.cs index 2fdc3fffe..faf822d15 100644 --- a/src/DataTransferObjects/MetadataDTOs/ReferenceElementMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/ReferenceElementMetadata.cs @@ -16,14 +16,14 @@ namespace DataTransferObjects.MetadataDTOs { public record class ReferenceElementMetadata( - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - string modelType = "ReferenceElement") : ISubmodelElementMetadata; + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "ReferenceElement") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/RelationshipElementMetadata.cs b/src/DataTransferObjects/MetadataDTOs/RelationshipElementMetadata.cs index 2d47a5843..6dbe8f006 100644 --- a/src/DataTransferObjects/MetadataDTOs/RelationshipElementMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/RelationshipElementMetadata.cs @@ -16,14 +16,14 @@ namespace DataTransferObjects.MetadataDTOs { public record class RelationshipElementMetadata( - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - string modelType = "RelationshipElement") : ISubmodelElementMetadata; + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "RelationshipElement") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/SubmodelElementCollectionMetadata.cs b/src/DataTransferObjects/MetadataDTOs/SubmodelElementCollectionMetadata.cs index 8b95a0147..12449c5c9 100644 --- a/src/DataTransferObjects/MetadataDTOs/SubmodelElementCollectionMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/SubmodelElementCollectionMetadata.cs @@ -16,15 +16,14 @@ namespace DataTransferObjects.MetadataDTOs { public record class SubmodelElementCollectionMetadata( - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - List value = null, - string modelType = "SubmodelElementCollection") : ISubmodelElementMetadata; + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "SubmodelElementCollection") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/SubmodelElementListMetadata.cs b/src/DataTransferObjects/MetadataDTOs/SubmodelElementListMetadata.cs index 0a3bb3c1c..b1930380d 100644 --- a/src/DataTransferObjects/MetadataDTOs/SubmodelElementListMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/SubmodelElementListMetadata.cs @@ -17,19 +17,18 @@ namespace DataTransferObjects.MetadataDTOs { public record class SubmodelElementListMetadata( - AasSubmodelElements typeValueListElement, - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - bool? orderRelevant = null, - ReferenceDTO? semanticIdListElement = null, - DataTypeDefXsd? valueTypeListElement = null, - List value = null, - string modelType = "SubmodelElementList") : ISubmodelElementMetadata; + AasSubmodelElements TypeValueListElement, + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + bool? OrderRelevant = null, + ReferenceDTO? SemanticIdListElement = null, + DataTypeDefXsd? ValueTypeListElement = null, + string ModelType = "SubmodelElementList") : ISubmodelElementMetadata; } diff --git a/src/DataTransferObjects/MetadataDTOs/SubmodelMetadata.cs b/src/DataTransferObjects/MetadataDTOs/SubmodelMetadata.cs index aac6da699..55a4c1cd4 100644 --- a/src/DataTransferObjects/MetadataDTOs/SubmodelMetadata.cs +++ b/src/DataTransferObjects/MetadataDTOs/SubmodelMetadata.cs @@ -17,18 +17,17 @@ namespace DataTransferObjects.MetadataDTOs { public record class SubmodelMetadata( - string? id, - List? extensions = null, - string category = null, - string idShort = null, - List? displayName = null, - List? description = null, - AdministrativeInformationDTO? administration = null, - ModellingKind? kind = null, - ReferenceDTO? semanticId = null, - List? supplementalSemanticIds = null, - List? qualifiers = null, - List? embeddedDataSpecifications = null, - List submodelElements = null, - string modelType = "Submodel") : IMetadataDTO; + string Id, + List? Extensions = null, + string? Category = null, + string? IdShort = null, + List? DisplayName = null, + List? Description = null, + AdministrativeInformationDTO? Administration = null, + ModellingKind? Kind = null, + ReferenceDTO? SemanticId = null, + List? SupplementalSemanticIds = null, + List? Qualifiers = null, + List? EmbeddedDataSpecifications = null, + string ModelType = "Submodel") : IMetadataDTO; } diff --git a/src/DataTransferObjects/ValueDTOs/AnnotatedRelationshipElementValue.cs b/src/DataTransferObjects/ValueDTOs/AnnotatedRelationshipElementValue.cs index f5a09acea..c875e758a 100644 --- a/src/DataTransferObjects/ValueDTOs/AnnotatedRelationshipElementValue.cs +++ b/src/DataTransferObjects/ValueDTOs/AnnotatedRelationshipElementValue.cs @@ -15,5 +15,5 @@ namespace DataTransferObjects.ValueDTOs { - public record class AnnotatedRelationshipElementValue(string idShort, ReferenceDTO first, ReferenceDTO second, List? annotations = null) : ISubmodelElementValue; + public record class AnnotatedRelationshipElementValue(string IdShort, ReferenceDTO First, ReferenceDTO Second, List? Annotations = null) : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/BasicEventElementValue.cs b/src/DataTransferObjects/ValueDTOs/BasicEventElementValue.cs index 12b6649f6..0a6534c83 100644 --- a/src/DataTransferObjects/ValueDTOs/BasicEventElementValue.cs +++ b/src/DataTransferObjects/ValueDTOs/BasicEventElementValue.cs @@ -15,5 +15,7 @@ namespace DataTransferObjects.ValueDTOs { - public record class BasicEventElementValue(string idShort, ReferenceDTO observed) : ISubmodelElementValue; + public record class BasicEventElementValue( + string IdShort, + ReferenceDTO Observed) : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/BlobValue.cs b/src/DataTransferObjects/ValueDTOs/BlobValue.cs index 20ed4e8ff..d44f810ab 100644 --- a/src/DataTransferObjects/ValueDTOs/BlobValue.cs +++ b/src/DataTransferObjects/ValueDTOs/BlobValue.cs @@ -13,5 +13,8 @@ namespace DataTransferObjects.ValueDTOs { - public record class BlobValue(string idShort, string? contentType, byte[]? value = null) : ISubmodelElementValue; + public record class BlobValue( + string IdShort, + string ContentType, + byte[]? Value = null) : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/EntityValue.cs b/src/DataTransferObjects/ValueDTOs/EntityValue.cs index c67055b90..c30a53dd4 100644 --- a/src/DataTransferObjects/ValueDTOs/EntityValue.cs +++ b/src/DataTransferObjects/ValueDTOs/EntityValue.cs @@ -15,5 +15,9 @@ namespace DataTransferObjects.ValueDTOs { - public record class EntityValue(string idShort, EntityType entityType, List? statements = null, string globalAssetId = null) : ISubmodelElementValue; + public record class EntityValue( + string IdShort, + EntityType EntityType, + List? Statements = null, + string? GlobalAssetId = null) : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/FileValue.cs b/src/DataTransferObjects/ValueDTOs/FileValue.cs index 56059c5d7..5f3ed91d8 100644 --- a/src/DataTransferObjects/ValueDTOs/FileValue.cs +++ b/src/DataTransferObjects/ValueDTOs/FileValue.cs @@ -13,5 +13,8 @@ namespace DataTransferObjects.ValueDTOs { - public record class FileValue(string idShort, string? contentType, string value = null) : ISubmodelElementValue; + public record class FileValue( + string IdShort, + string ContentType, + string? Value = null) : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/MultiLanguagePropertyValue.cs b/src/DataTransferObjects/ValueDTOs/MultiLanguagePropertyValue.cs index f7e53a858..b6c16fe65 100644 --- a/src/DataTransferObjects/ValueDTOs/MultiLanguagePropertyValue.cs +++ b/src/DataTransferObjects/ValueDTOs/MultiLanguagePropertyValue.cs @@ -13,5 +13,8 @@ namespace DataTransferObjects.ValueDTOs { - public record class MultiLanguagePropertyValue(string idShort, List>? langStrings = null) : ISubmodelElementValue; + public record class MultiLanguagePropertyValue( + string IdShort, + List>? LangStrings = null) + : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/OperationValue.cs b/src/DataTransferObjects/ValueDTOs/OperationValue.cs index 44ce53a4b..d333079fd 100644 --- a/src/DataTransferObjects/ValueDTOs/OperationValue.cs +++ b/src/DataTransferObjects/ValueDTOs/OperationValue.cs @@ -13,5 +13,10 @@ namespace DataTransferObjects.ValueDTOs { - public record class OperationValue(string idShort, List? inputVariables = null, List? outputVariables = null, List? inoutputvariables = null) : ISubmodelElementValue; + public record class OperationValue( + string IdShort, + List? InputVariables = null, + List? OutputVariables = null, + List? Inoutputvariables = null) + : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/PropertyValue.cs b/src/DataTransferObjects/ValueDTOs/PropertyValue.cs index 6ccd035df..221f875c4 100644 --- a/src/DataTransferObjects/ValueDTOs/PropertyValue.cs +++ b/src/DataTransferObjects/ValueDTOs/PropertyValue.cs @@ -13,5 +13,7 @@ namespace DataTransferObjects.ValueDTOs { - public record class PropertyValue(string idShort, string value = null) : ISubmodelElementValue; + public record class PropertyValue( + string IdShort, + string? Value = null) : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/RangeValue.cs b/src/DataTransferObjects/ValueDTOs/RangeValue.cs index 0d039e94a..094ef8eb1 100644 --- a/src/DataTransferObjects/ValueDTOs/RangeValue.cs +++ b/src/DataTransferObjects/ValueDTOs/RangeValue.cs @@ -13,5 +13,8 @@ namespace DataTransferObjects.ValueDTOs { - public record class RangeValue(string idShort, string min = null, string max = null) : ISubmodelElementValue; + public record class RangeValue( + string IdShort, + string? Min = null, + string? Max = null) : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/ReferenceElementValue.cs b/src/DataTransferObjects/ValueDTOs/ReferenceElementValue.cs index 24a7d8fea..3355f13b6 100644 --- a/src/DataTransferObjects/ValueDTOs/ReferenceElementValue.cs +++ b/src/DataTransferObjects/ValueDTOs/ReferenceElementValue.cs @@ -15,5 +15,7 @@ namespace DataTransferObjects.ValueDTOs { - public record class ReferenceElementValue(string idShort, ReferenceDTO? value = null) : ISubmodelElementValue; + public record class ReferenceElementValue( + string IdShort, + ReferenceDTO? Value = null) : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/RelationshipElementValue.cs b/src/DataTransferObjects/ValueDTOs/RelationshipElementValue.cs index 0ef00876d..da35eb015 100644 --- a/src/DataTransferObjects/ValueDTOs/RelationshipElementValue.cs +++ b/src/DataTransferObjects/ValueDTOs/RelationshipElementValue.cs @@ -15,5 +15,8 @@ namespace DataTransferObjects.ValueDTOs { - public record class RelationshipElementValue(string idShort, ReferenceDTO first, ReferenceDTO second) : ISubmodelElementValue; + public record class RelationshipElementValue( + string IdShort, + ReferenceDTO First, + ReferenceDTO Second) : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/SubmodelElementCollectionValue.cs b/src/DataTransferObjects/ValueDTOs/SubmodelElementCollectionValue.cs index c01262907..7a4909870 100644 --- a/src/DataTransferObjects/ValueDTOs/SubmodelElementCollectionValue.cs +++ b/src/DataTransferObjects/ValueDTOs/SubmodelElementCollectionValue.cs @@ -13,5 +13,8 @@ namespace DataTransferObjects.ValueDTOs { - public record class SubmodelElementCollectionValue(string idShort, List? value = null) : ISubmodelElementValue; + public record class SubmodelElementCollectionValue( + string IdShort, + List? Value = null) + : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/SubmodelElementListValue.cs b/src/DataTransferObjects/ValueDTOs/SubmodelElementListValue.cs index d7548d992..c4839a8e3 100644 --- a/src/DataTransferObjects/ValueDTOs/SubmodelElementListValue.cs +++ b/src/DataTransferObjects/ValueDTOs/SubmodelElementListValue.cs @@ -13,5 +13,8 @@ namespace DataTransferObjects.ValueDTOs { - public record class SubmodelElementListValue(string idShort, List? value = null) : ISubmodelElementValue; + public record class SubmodelElementListValue( + string IdShort, + List? Value = null) + : ISubmodelElementValue; } diff --git a/src/DataTransferObjects/ValueDTOs/SubmodelValue.cs b/src/DataTransferObjects/ValueDTOs/SubmodelValue.cs index 213dff23f..1c03c0c6f 100644 --- a/src/DataTransferObjects/ValueDTOs/SubmodelValue.cs +++ b/src/DataTransferObjects/ValueDTOs/SubmodelValue.cs @@ -13,5 +13,7 @@ namespace DataTransferObjects.ValueDTOs { - public record class SubmodelValue(List? submodelElements = null) : IValueDTO; + public record class SubmodelValue( + List? SubmodelElements = null) + : IValueDTO; } diff --git a/src/IO.Swagger.Lib.V3.Tests/Controllers/DescriptionAPIApiControllerTests.cs b/src/IO.Swagger.Lib.V3.Tests/Controllers/DescriptionAPIApiControllerTests.cs index 56f5dc046..07b76f256 100644 --- a/src/IO.Swagger.Lib.V3.Tests/Controllers/DescriptionAPIApiControllerTests.cs +++ b/src/IO.Swagger.Lib.V3.Tests/Controllers/DescriptionAPIApiControllerTests.cs @@ -31,7 +31,7 @@ public void GetDescription_ShouldReturn200WithServiceDescription() var mockServiceDescription = new Mock(); var expectedServiceDescription = new ServiceDescription { - Profiles = new List + profiles = new List { ServiceDescription.ServiceProfiles.AasxFileServerServiceSpecificationSSP001, ServiceDescription.ServiceProfiles.SubmodelRepositoryServiceSpecificationSSP001, diff --git a/src/IO.Swagger.Lib.V3.Tests/Controllers/SubmodelRepositoryAPIApiControllerTests.cs b/src/IO.Swagger.Lib.V3.Tests/Controllers/SubmodelRepositoryAPIApiControllerTests.cs index af5351338..62a4fa0c8 100644 --- a/src/IO.Swagger.Lib.V3.Tests/Controllers/SubmodelRepositoryAPIApiControllerTests.cs +++ b/src/IO.Swagger.Lib.V3.Tests/Controllers/SubmodelRepositoryAPIApiControllerTests.cs @@ -15,8 +15,10 @@ namespace AasxServerBlazorTests.Controllers; +using System.Reflection.Emit; using System.Security.Claims; using System.Security.Principal; +using System.Xml.Linq; using AasCore.Aas3_0; using AasxServer; using AasxServerStandardBib.Interfaces; @@ -282,9 +284,10 @@ public void GetAllSubmodelElements_WithValidRequest_ReturnsPagedResult(string su _authorizationServiceMock.Setup(x => x.AuthorizeAsync(It.IsAny(), It.IsAny(), "SecurityPolicy")) .Returns(Task.FromResult(AuthorizationResult.Success())); - + var levelString = nameof(level); + var extentString = nameof(extent); // Act - var result = _controller.GetAllSubmodelElements(submodelIdentifier, limit, cursor, level, extent, diff); + var result = _controller.GetAllSubmodelElements(submodelIdentifier, limit, cursor, levelString, extentString, diff); // Assert result.Should().BeOfType(); @@ -303,8 +306,11 @@ public void GetAllSubmodelElements_WhenDecodingReturnedNull_ThrowsNotAllowedExce _decoderServiceMock.Setup(x => x.Decode("submodelIdentifier", submodelIdentifier)).Returns((string)null); + var levelString = nameof(LevelEnum.Deep); + var extentString = nameof(ExtentEnum.WithoutBlobValue); + // Act - Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, LevelEnum.Deep, ExtentEnum.WithoutBlobValue, null); + Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, levelString, extentString, null); // Assert action.Should().ThrowExactly().WithMessage($"Decoding {submodelIdentifier} returned null"); @@ -325,8 +331,11 @@ public void GetAllSubmodelElements_WhenAuthorizationFails_ThrowsNotAllowedExcept Program.noSecurity = false; + var levelString = nameof(LevelEnum.Core); + var extentString = nameof(ExtentEnum.WithBlobValue); + // Act - Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, LevelEnum.Core, ExtentEnum.WithBlobValue, null); + Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, levelString, extentString, null); // Assert action.Should().ThrowExactly(); @@ -352,8 +361,12 @@ public void GetAllSubmodelElements_WithValidRequestAndDiffParameter_FiltersSubmo //_paginationServiceMock.Setup(x => x.GetPaginatedList(It.IsAny>(), It.IsAny())) // .Returns((List elements, PaginationParameters parameters) => new List(elements)); + + var levelString = nameof(LevelEnum.Deep); + var extentString = nameof(ExtentEnum.WithoutBlobValue); + // Act - Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, LevelEnum.Deep, ExtentEnum.WithBlobValue, diffParameterValue); + Action action = () => _controller.GetAllSubmodelElements(submodelIdentifier, null, null, levelString, extentString, diffParameterValue); // Assert action.Should().NotThrow(); // Ensure no exception is thrown diff --git a/src/IO.Swagger.Lib.V3.Tests/Models/ServiceDescriptionTests.cs b/src/IO.Swagger.Lib.V3.Tests/Models/ServiceDescriptionTests.cs index 7bf156f63..a99b176da 100644 --- a/src/IO.Swagger.Lib.V3.Tests/Models/ServiceDescriptionTests.cs +++ b/src/IO.Swagger.Lib.V3.Tests/Models/ServiceDescriptionTests.cs @@ -25,7 +25,7 @@ public void ToString_ShouldReturnFormattedString() // Arrange var serviceDescription = new ServiceDescription { - Profiles = new List + profiles = new List { ServiceDescription.ServiceProfiles.DiscoveryServiceSpecificationSSP001 } @@ -45,7 +45,7 @@ public void ToJson_ShouldReturnIndentedJsonString() // Arrange var serviceDescription = new ServiceDescription { - Profiles = new List + profiles = new List { ServiceDescription.ServiceProfiles.DiscoveryServiceSpecificationSSP001 } @@ -66,7 +66,7 @@ public void Equals_WithSameObject_ShouldReturnTrue() // Arrange var serviceDescription = new ServiceDescription { - Profiles = new List + profiles = new List { ServiceDescription.ServiceProfiles.DiscoveryServiceSpecificationSSP001 } @@ -88,8 +88,8 @@ public void Equals_WithEqualObject_ShouldReturnTrue() ServiceDescription.ServiceProfiles.DiscoveryServiceSpecificationSSP001 }; - var serviceDescription1 = new ServiceDescription { Profiles = profiles }; - var serviceDescription2 = new ServiceDescription { Profiles = profiles }; + var serviceDescription1 = new ServiceDescription { profiles = profiles }; + var serviceDescription2 = new ServiceDescription { profiles = profiles }; // Act var result = serviceDescription1.Equals(serviceDescription2); @@ -104,7 +104,7 @@ public void Equals_WithDifferentObject_ShouldReturnFalse() // Arrange var serviceDescription1 = new ServiceDescription { - Profiles = new List + profiles = new List { ServiceDescription.ServiceProfiles.DiscoveryServiceSpecificationSSP001 } @@ -112,7 +112,7 @@ public void Equals_WithDifferentObject_ShouldReturnFalse() var serviceDescription2 = new ServiceDescription { - Profiles = new List + profiles = new List { ServiceDescription.ServiceProfiles.AssetAdministrationShellRepositoryServiceSpecificationSSP001 } @@ -134,7 +134,7 @@ public void GetHashCode_ShouldReturnCorrectHashCode() ServiceDescription.ServiceProfiles.DiscoveryServiceSpecificationSSP001 }; - var serviceDescription = new ServiceDescription { Profiles = profiles }; + var serviceDescription = new ServiceDescription { profiles = profiles }; var expectedHashCode = 41; expectedHashCode = (expectedHashCode * 59) + profiles.GetHashCode(); @@ -154,8 +154,8 @@ public void OperatorEquals_WithEqualObjects_ShouldReturnTrue() ServiceDescription.ServiceProfiles.DiscoveryServiceSpecificationSSP001 }; - var serviceDescription1 = new ServiceDescription { Profiles = profiles }; - var serviceDescription2 = new ServiceDescription { Profiles = profiles }; + var serviceDescription1 = new ServiceDescription { profiles = profiles }; + var serviceDescription2 = new ServiceDescription { profiles = profiles }; // Act var result = serviceDescription1 == serviceDescription2; @@ -170,7 +170,7 @@ public void OperatorNotEquals_WithDifferentObjects_ShouldReturnTrue() // Arrange var serviceDescription1 = new ServiceDescription { - Profiles = new List + profiles = new List { ServiceDescription.ServiceProfiles.DiscoveryServiceSpecificationSSP001 } @@ -178,7 +178,7 @@ public void OperatorNotEquals_WithDifferentObjects_ShouldReturnTrue() var serviceDescription2 = new ServiceDescription { - Profiles = new List + profiles = new List { ServiceDescription.ServiceProfiles.SubmodelServiceSpecificationSSP002 } diff --git a/src/IO.Swagger.Lib.V3.Tests/Services/GenerateSerializationServiceTests.cs b/src/IO.Swagger.Lib.V3.Tests/Services/GenerateSerializationServiceTests.cs index f71836979..b39955c77 100644 --- a/src/IO.Swagger.Lib.V3.Tests/Services/GenerateSerializationServiceTests.cs +++ b/src/IO.Swagger.Lib.V3.Tests/Services/GenerateSerializationServiceTests.cs @@ -25,6 +25,7 @@ public class GenerateSerializationServiceTests private readonly Mock> _mockLogger; private readonly Mock _mockAasService; private readonly Mock _mockSubmodelService; + private readonly Mock _mockCdService; private readonly GenerateSerializationService _service; public GenerateSerializationServiceTests() @@ -32,27 +33,27 @@ public GenerateSerializationServiceTests() _mockLogger = new Mock>(); _mockAasService = new Mock(); _mockSubmodelService = new Mock(); - _service = new GenerateSerializationService(_mockLogger.Object, _mockAasService.Object, _mockSubmodelService.Object); + _service = new GenerateSerializationService(_mockLogger.Object, _mockAasService.Object, _mockSubmodelService.Object, _mockCdService.Object); } [Fact] public void Constructor_ShouldThrowArgumentNullException_WhenLoggerIsNull() { - Action act = () => new GenerateSerializationService(null, _mockAasService.Object, _mockSubmodelService.Object); + Action act = () => new GenerateSerializationService(null, _mockAasService.Object, _mockSubmodelService.Object, _mockCdService.Object); act.Should().Throw().WithParameterName("logger"); } [Fact] public void Constructor_ShouldThrowArgumentNullException_WhenAasServiceIsNull() { - Action act = () => new GenerateSerializationService(_mockLogger.Object, null, _mockSubmodelService.Object); + Action act = () => new GenerateSerializationService(_mockLogger.Object, null, _mockSubmodelService.Object, _mockCdService.Object); act.Should().Throw().WithParameterName("aasService"); } [Fact] public void Constructor_ShouldThrowArgumentNullException_WhenSubmodelServiceIsNull() { - Action act = () => new GenerateSerializationService(_mockLogger.Object, _mockAasService.Object, null); + Action act = () => new GenerateSerializationService(_mockLogger.Object, _mockAasService.Object, null, _mockCdService.Object); act.Should().Throw().WithParameterName("submodelService"); } @@ -60,8 +61,8 @@ public void Constructor_ShouldThrowArgumentNullException_WhenSubmodelServiceIsNu public void GenerateSerializationByIds_ShouldReturnEmptyEnvironment_WhenNoIdsProvided() { // Arrange - _mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny?>(), It.IsAny())).Returns([]); - _mockSubmodelService.Setup(x => x.GetAllSubmodels()).Returns([]); + _mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny?>(), It.IsAny())).Returns([]); + _mockSubmodelService.Setup(x => x.GetAllSubmodels(It.IsAny(), It.IsAny())).Returns([]); // Act var result = _service.GenerateSerializationByIds(); @@ -79,8 +80,8 @@ public void GenerateSerializationByIds_ShouldFetchAASs_WhenAasIdsProvided() var mockAas = new Mock(); mockAas.SetupGet(x => x.Id).Returns(aasId); - _mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny?>(), It.IsAny())).Returns([mockAas.Object]); - _mockSubmodelService.Setup(x => x.GetAllSubmodels()).Returns([]); + _mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny?>(), It.IsAny())).Returns([mockAas.Object]); + _mockSubmodelService.Setup(x => x.GetAllSubmodels(It.IsAny(), It.IsAny())).Returns([]); // Act var result = _service.GenerateSerializationByIds(new List {aasId}); @@ -98,8 +99,8 @@ public void GenerateSerializationByIds_ShouldFetchSubmodels_WhenSubmodelIdsProvi var mockSubmodel = new Mock(); mockSubmodel.SetupGet(x => x.Id).Returns(submodelId); - _mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny?>(), It.IsAny())).Returns([]); - _mockSubmodelService.Setup(x => x.GetAllSubmodels()).Returns([mockSubmodel.Object]); + _mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny?>(), It.IsAny())).Returns([]); + _mockSubmodelService.Setup(x => x.GetAllSubmodels(It.IsAny(), It.IsAny())).Returns([mockSubmodel.Object]); // Act var result = _service.GenerateSerializationByIds(null, new List {submodelId}); @@ -122,8 +123,8 @@ public void GenerateSerializationByIds_ShouldFetchAASsAndSubmodels_WhenBothIdsPr var mockSubmodel = new Mock(); mockSubmodel.SetupGet(x => x.Id).Returns(submodelId); - _mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny?>(), It.IsAny())).Returns([mockAas.Object]); - _mockSubmodelService.Setup(x => x.GetAllSubmodels()).Returns([mockSubmodel.Object]); + _mockAasService.Setup(x => x.GetAllAssetAdministrationShells(It.IsAny?>(), It.IsAny())).Returns([mockAas.Object]); + _mockSubmodelService.Setup(x => x.GetAllSubmodels(It.IsAny(), It.IsAny())).Returns([mockSubmodel.Object]); // Act var result = _service.GenerateSerializationByIds(new List {aasId}, new List {submodelId}); diff --git a/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs index d5dd7f0fb..76a3924b8 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs @@ -16,2822 +16,2711 @@ * * The Full Profile of the Asset Administration Shell Repository Service Specification as part of the [Specification of the Asset Administration Shell: Part 2](http://industrialdigitaltwin.org/en/content-hub). Publisher: Industrial Digital Twin Association (IDTA) April 2023 * - * OpenAPI spec version: V3.0.1_SSP-001 + * OpenAPI spec version: V3.0.3_SSP-001 * Contact: info@idtwin.org * Generated by: https://github.com/swagger-api/swagger-codegen.git */ +using System; +using System.Collections.Generic; +using Microsoft.AspNetCore.Mvc; +using Swashbuckle.AspNetCore.Annotations; +using Swashbuckle.AspNetCore.SwaggerGen; +using Newtonsoft.Json; +using System.ComponentModel.DataAnnotations; +using IO.Swagger.Attributes; -using AasSecurity.Exceptions; -using AasxServer; +using Microsoft.AspNetCore.Authorization; +using IO.Swagger.Models; using AasxServerStandardBib.Interfaces; using AasxServerStandardBib.Logging; -using AdminShellNS.Lib.V3.Models; -using DataTransferObjects.MetadataDTOs; -using DataTransferObjects.ValueDTOs; -using IO.Swagger.Attributes; using IO.Swagger.Lib.V3.Interfaces; -using IO.Swagger.Lib.V3.Models; using IO.Swagger.Lib.V3.SerializationModifiers.Mappers; -using IO.Swagger.Models; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Swashbuckle.AspNetCore.Annotations; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.IO; +using AasSecurity.Exceptions; +using AasxServer; using System.Linq; -using System.Net.Mime; using System.Security.Claims; +using IO.Swagger.Lib.V3.Models; +using System.Reflection.Emit; +using DataTransferObjects.MetadataDTOs; +using AdminShellNS.Lib.V3.Models; +using DataTransferObjects.ValueDTOs; +using System.Net.Mime; +using Microsoft.AspNetCore.Http; +using System.Xml.Linq; +using System.IO; +using AdminShellNS.Extensions; +using System.Text.Json.Nodes; -namespace IO.Swagger.Controllers; - -using System.Threading.Tasks; - -/// -/// -/// -[Authorize(AuthenticationSchemes = "AasSecurityAuth")] -[ApiController] -public class AssetAdministrationShellRepositoryAPIApiController : ControllerBase -{ - private readonly IAppLogger _logger; - private readonly IAssetAdministrationShellService _aasService; - private readonly IBase64UrlDecoderService _decoderService; - private readonly IReferenceModifierService _referenceModifierService; - private readonly IMappingService _mappingService; - private readonly IPathModifierService _pathModifierService; - private readonly ILevelExtentModifierService _levelExtentModifierService; - private readonly IPaginationService _paginationService; - private readonly IAuthorizationService _authorizationService; - - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - public AssetAdministrationShellRepositoryAPIApiController(IAppLogger logger, - IAssetAdministrationShellService aasService, IBase64UrlDecoderService decoderService, - IReferenceModifierService referenceModifierService, - IMappingService mappingService, IPathModifierService pathModifierService, - ILevelExtentModifierService levelExtentModifierService, IPaginationService paginationService, - IAuthorizationService authorizationService) - { - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _aasService = aasService ?? throw new ArgumentNullException(nameof(aasService)); - _decoderService = decoderService ?? throw new ArgumentNullException(nameof(decoderService)); - _referenceModifierService = referenceModifierService ?? throw new ArgumentNullException(nameof(referenceModifierService)); - _mappingService = mappingService ?? throw new ArgumentNullException(nameof(mappingService)); - _pathModifierService = pathModifierService ?? throw new ArgumentNullException(nameof(pathModifierService)); - _levelExtentModifierService = levelExtentModifierService ?? throw new ArgumentNullException(nameof(levelExtentModifierService)); - _paginationService = paginationService ?? throw new ArgumentNullException(nameof(paginationService)); - _authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService)); - } - - /// - /// Deletes an Asset Administration Shell - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// Asset Administration Shell deleted successfully - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpDelete] - [Route("/shells/{aasIdentifier}")] - [ValidateModelState] - [SwaggerOperation("DeleteAssetAdministrationShellById")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult DeleteAssetAdministrationShellById([FromRoute] [Required] string aasIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - - _logger.LogInformation($"Received request to delete AAS with id {decodedAasIdentifier}"); - _aasService.DeleteAssetAdministrationShellById(decodedAasIdentifier); - - return NoContent(); - } - - /// - /// Deletes file content of an existing submodel element at a specified path within submodel elements hierarchy - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Submodel element updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpDelete] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] - [ValidateModelState] - [SwaggerOperation("DeleteFileByPathAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult DeleteFileByPathAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath) - { - _logger.LogInformation($"Received request to delete a file from AAS"); - - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSmIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSmIdentifier)} is null"); - } - - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSmIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - _aasService.DeleteFileByPath(decodedAasIdentifier, decodedSmIdentifier, idShortPath); - - return NoContent(); - } - - /// - /// Deletes the submodel from the Asset Administration Shell and the Repository. - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Submodel deleted successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpDelete] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}")] - [ValidateModelState] - [SwaggerOperation("DeleteSubmodelByIdAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult DeleteSubmodelByIdAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier) - { - _logger.LogInformation($"Received request to delete a submodel from AAS"); - - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSmIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSmIdentifier)} is null"); - } - - _aasService.DeleteSubmodelById(decodedAasIdentifier, decodedSmIdentifier); - - return NoContent(); - } - - /// - /// Deletes a submodel element at a specified path within the submodel elements hierarchy - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Submodel element deleted successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpDelete] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] - [ValidateModelState] - [SwaggerOperation("DeleteSubmodelElementByPathAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult DeleteSubmodelElementByPathAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath) - { - _logger.LogInformation($"Received request to delete a SubmodelElement from AAS"); - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSmIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSmIdentifier)} is null"); - } - - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSmIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - _aasService.DeleteSubmodelElementByPath(decodedAasIdentifier, decodedSmIdentifier, idShortPath); - - return NoContent(); - } - - /// - /// Deletes the submodel reference from the Asset Administration Shell. Does not delete the submodel itself! - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Submodel reference deleted successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpDelete] - [Route("/shells/{aasIdentifier}/submodel-refs/{submodelIdentifier}")] - [ValidateModelState] - [SwaggerOperation("DeleteSubmodelReferenceByIdAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult DeleteSubmodelReferenceByIdAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSmIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSmIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to delete submodel reference with id {submodelIdentifier} from the AAS with id {aasIdentifier}."); - _aasService.DeleteSubmodelReferenceById(decodedAasIdentifier, decodedSmIdentifier); - - return NoContent(); - } - - /// - /// - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// Thumbnail deletion successful - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpDelete] - [Route("/shells/{aasIdentifier}/asset-information/thumbnail")] - [ValidateModelState] - [SwaggerOperation("DeleteThumbnailAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult DeleteThumbnailAasRepository([FromRoute] [Required] string aasIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - - _logger.LogInformation($"Received request to delete the thumbnail from the AAS with id {decodedAasIdentifier}."); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - _aasService.DeleteThumbnail(decodedAasIdentifier); - - return NoContent(); - } - - /// - /// Returns all Asset Administration Shells - /// - /// A list of specific Asset identifiers. Each Asset identifier is a base64-url-encoded [SpecificAssetId](https://api.swaggerhub.com/domains/Plattform_i40/Part1-MetaModel-Schemas/V3.0.1#/components/schemas/SpecificAssetId) - /// The Asset Administration Shell’s IdShort - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Requested Asset Administration Shells - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells")] - [ValidateModelState] - [SwaggerOperation("GetAllAssetAdministrationShells")] - [SwaggerResponse(statusCode: 200, type: typeof(PagedResult), description: "Requested Asset Administration Shells")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - // TODO (jtikekar, 2023-09-04): assetIds: string or specific asset id, and what about Base64Uel encoding - public virtual IActionResult GetAllAssetAdministrationShells([FromQuery] List? assetIds, [FromQuery] string? idShort, [FromQuery] int? limit, - [FromQuery] string? cursor) - { - _logger.LogInformation($"Received the request to get all Asset Administration Shells."); - - var aasList = _aasService.GetAllAssetAdministrationShells(assetIds, idShort); - var output = _paginationService.GetPaginatedList(aasList, new PaginationParameters(cursor, limit)); - return new ObjectResult(output); - } - - /// - /// Returns References to all Asset Administration Shells - /// - /// A list of specific Asset identifiers. Each Asset identifier is a base64-url-encoded [SpecificAssetId](https://api.swaggerhub.com/domains/Plattform_i40/Part1-MetaModel-Schemas/V3.0.1#/components/schemas/SpecificAssetId) - /// The Asset Administration Shell’s IdShort - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Requested Asset Administration Shells as a list of References - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/$reference")] - [ValidateModelState] - [SwaggerOperation("GetAllAssetAdministrationShellsReference")] - [SwaggerResponse(statusCode: 200, type: typeof(GetReferencesResult), description: "Requested Asset Administration Shells as a list of References")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - // TODO (jtikekar, 2023-09-04): assetIds: string or specific asset id, and what about Base64Uel encoding - //public virtual IActionResult GetAllAssetAdministrationShellsReference([FromQuery] List assetIds, [FromQuery] string idShort, [FromQuery] int? limit, [FromQuery] string cursor) - public virtual IActionResult GetAllAssetAdministrationShellsReference([FromQuery] List? assetIds, [FromQuery] string? idShort, [FromQuery] int? limit, - [FromQuery] string? cursor) - { - _logger.LogInformation($"Received the request to get all Asset Administration Shells."); - - var aasList = _aasService.GetAllAssetAdministrationShells(assetIds, idShort); - var aasPaginatedList = _paginationService.GetPaginatedList(aasList, new PaginationParameters(cursor, limit)); - var references = _referenceModifierService.GetReferenceResult(aasPaginatedList.result.ConvertAll(a => (IReferable)a)); - var output = new ReferencePagedResult(references, aasPaginatedList.paging_metadata); - return new ObjectResult(output); - } - - /// - /// Returns all submodel elements including their hierarchy - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// List of found submodel elements - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelElementsAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(GetSubmodelElementsResult), description: "List of found submodel elements")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelElementsAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSmIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSmIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get all the submodel elements from submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSmIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var submodelElements = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSmIdentifier); - - var smePaginated = _paginationService.GetPaginatedList(submodelElements, new PaginationParameters(cursor, limit)); - var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginated.result ?? [], level, extent); - var output = new PagedResult() {result = smeLevelList.ConvertAll(sme => sme), paging_metadata = smePaginated.paging_metadata}; - return new ObjectResult(output); - } - - /// - /// Returns all submodel elements including their hierarchy - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// List of found submodel elements - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$metadata")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelElementsMetadataAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(MetadataPagedResult), description: "List of found submodel elements")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelElementsMetadataAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromQuery] int? limit, [FromQuery] [Required] string cursor, [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get metadata of all the submodel elements from the submodel with id {decodedSubmodelIdentifier} and AAS with id {decodedAasIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var smeList = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSubmodelIdentifier); - - var smePaginated = _paginationService.GetPaginatedList(smeList, new PaginationParameters(cursor, limit)); - var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginated.result ?? [], level); - var smeMetadataList = _mappingService.Map(smeLevelList, "metadata"); - var output = new MetadataPagedResult {result = smeMetadataList.ConvertAll(sme => (IMetadataDTO)sme), paging_metadata = smePaginated.paging_metadata}; - return new ObjectResult(output); - } - - /// - /// Returns all submodel elements including their hierarchy - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// List of found submodel elements in the Path notation - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$path")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelElementsPathAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(GetPathItemsResult), description: "List of found submodel elements in the Path notation")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelElementsPathAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent) - { - var decodedAasIdentifier = _decoderService.Decode($"aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode($"submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _logger.LogInformation($"Received a request to get path for all the submodel elements from the submodel with id {decodedSubmodelIdentifier} and aas with id {decodedAasIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var submodelElementsList = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSubmodelIdentifier); - - var smePaginated = _paginationService.GetPaginatedList(submodelElementsList, new PaginationParameters(cursor, limit)); - var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginated.result ?? [], level, extent); - var smePathList = _pathModifierService.ToIdShortPath(smeLevelList.ConvertAll(sme => (ISubmodelElement)sme)); - var output = new PathPagedResult {result = smePathList, paging_metadata = smePaginated.paging_metadata}; - return new ObjectResult(output); - } - - /// - /// Returns all submodel elements as a list of References - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// - /// List of References of the found submodel elements - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$reference")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelElementsReferenceAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(ReferencePagedResult), description: "List of References of the found submodel elements")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelElementsReferenceAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get references of all the submodel elements from submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var smeList = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSubmodelIdentifier); - - // TODO (jtikekar, 2023-09-04): check performace imapct due to ConvertAll - var smePaginated = _paginationService.GetPaginatedList(smeList, new PaginationParameters(cursor, limit)); - var smeReferenceList = _referenceModifierService.GetReferenceResult(smePaginated.result.ConvertAll(sme => (IReferable)sme)); - var output = new ReferencePagedResult(smeReferenceList, smePaginated.paging_metadata); - return new ObjectResult(output); - } - - /// - /// Returns all submodel elements including their hierarchy in the ValueOnly representation - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// - /// List of found submodel elements in their ValueOnly representation - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$value")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelElementsValueOnlyAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(ValueOnlyPagedResult), description: "List of found submodel elements in their ValueOnly representation")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelElementsValueOnlyAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get the value of all the submodel elements from the submodel with id {decodedSubmodelIdentifier} and aas with id {decodedAasIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var submodelElements = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSubmodelIdentifier); - - var smePaginated = _paginationService.GetPaginatedList(submodelElements, new PaginationParameters(cursor, limit)); - var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginated.result, level); - var smeValueList = _mappingService.Map(smeLevelList, "value"); - var output = new ValueOnlyPagedResult {result = smeValueList.ConvertAll(sme => (IValueDTO)sme), paging_metadata = smePaginated.paging_metadata}; - return new ObjectResult(output); - } - - /// - /// Returns all submodel references - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Requested submodel references - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodel-refs")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelReferencesAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(GetReferencesResult), description: "Requested submodel references")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelReferencesAasRepository([FromRoute] [Required] string aasIdentifier, [FromQuery] int? limit, [FromQuery] string? cursor) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get all the submodel references from the AAS with id {aasIdentifier}."); - - var submodels = _aasService.GetAllSubmodelReferencesFromAas(decodedAasIdentifier); - - var output = _paginationService.GetPaginatedList(submodels, new PaginationParameters(cursor, limit)); - return new ObjectResult(output); - } - - /// - /// Returns a specific Asset Administration Shell - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// Requested Asset Administration Shell - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}")] - [ValidateModelState] - [SwaggerOperation("GetAssetAdministrationShellById")] - [SwaggerResponse(statusCode: 200, type: typeof(AssetAdministrationShell), description: "Requested Asset Administration Shell")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAssetAdministrationShellById([FromRoute] [Required] string aasIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get the AAS with id {aasIdentifier}."); - - var aas = _aasService.GetAssetAdministrationShellById(decodedAasIdentifier); - - /* Turn off AAS security to have existing demos run - var authResult = _authorizationService.AuthorizeAsync(User, aas, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReasons = authResult.Failure.FailureReasons; - if (failedReasons != null && failedReasons.Any()) - { - throw new NotAllowed(failedReasons.First().Message); - } - } - */ - return new ObjectResult(aas); - } - - /// - /// Returns a specific Asset Administration Shell as a Reference - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// Requested Asset Administration Shell - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/$reference")] - [ValidateModelState] - [SwaggerOperation("GetAssetAdministrationShellByIdReferenceAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(Reference), description: "Requested Asset Administration Shell")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAssetAdministrationShellByIdReferenceAasRepository([FromRoute] [Required] string aasIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get the reference of AAS with id {aasIdentifier}."); - - var aas = _aasService.GetAssetAdministrationShellById(decodedAasIdentifier); - - var output = _referenceModifierService.GetReferenceResult(aas); - - return new ObjectResult(output); - } - - /// - /// Returns the Asset Information - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// Requested Asset Information - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/asset-information")] - [ValidateModelState] - [SwaggerOperation("GetAssetInformationAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(AssetInformation), description: "Requested Asset Information")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAssetInformationAasRepository([FromRoute] [Required] string aasIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get the AAS with id {decodedAasIdentifier}."); - - var output = _aasService.GetAssetInformation(decodedAasIdentifier); - - return new ObjectResult(output); - } - - /// - /// Downloads file content from a specific submodel element from the Submodel at a specified path - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Requested file - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] - [ValidateModelState] - [SwaggerOperation("GetFileByPathAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(byte[]), description: "Requested file")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual async Task GetFileByPathAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get file by path at the submodel element {idShortPath} from submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); - - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var fileName = _aasService.GetFileByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, out var content, out var fileSize); - - //content-disposition so that the aasx file can be downloaded from the web browser. - ContentDisposition contentDisposition = new() {FileName = fileName, Inline = fileName.ToLower().EndsWith(".pdf")}; - - HttpContext.Response.Headers.Append("Content-Disposition", contentDisposition.ToString()); - HttpContext.Response.ContentLength = fileSize; - if (fileName.ToLower().EndsWith(".svg")) - { - HttpContext.Response.ContentType = "image/svg+xml"; - } - - if (fileName.ToLower().EndsWith(".pdf")) - { - HttpContext.Response.ContentType = "application/pdf"; - } - - await HttpContext.Response.Body.WriteAsync(content); - return new EmptyResult(); - } - - /// - /// Returns the Operation result of an asynchronous invoked Operation - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) - /// Operation result object - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-results/{handleId}")] - [ValidateModelState] - [SwaggerOperation("GetOperationAsyncResultAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(OperationResult), description: "Operation result object")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetOperationAsyncResultAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromRoute] [Required] string handleId) - { - //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(200, default(OperationResult)); - - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); - - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); - - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); - - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); - - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); - - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); - return new ObjectResult(System.Text.Json.JsonSerializer.Deserialize(string.Empty)); - } - - /// - /// Returns the ValueOnly notation of the Operation result of an asynchronous invoked Operation - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) - /// Operation result object - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-results/{handleId}/$value")] - [ValidateModelState] - [SwaggerOperation("GetOperationAsyncResultValueOnlyAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(IValueDTO), description: "Operation result object")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetOperationAsyncResultValueOnlyAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromRoute] [Required] string handleId) - { - return new ObjectResult(null); - } - - /// - /// Returns the Operation status of an asynchronous invoked Operation - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) - /// Operation result object containing information that the 'executionState' is still 'Running' - /// The target resource is available but at a different location. - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-status/{handleId}")] - [ValidateModelState] - [SwaggerOperation("GetOperationAsyncStatusAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(BaseOperationResult), - description: "Operation result object containing information that the 'executionState' is still 'Running'")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetOperationAsyncStatusAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromRoute] [Required] string handleId) - { - //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(200, default(BaseOperationResult)); - - //TODO: Uncomment the next line to return response 302 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(302); - - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); - - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); - - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); - - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); - - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); - - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); - string exampleJson = null; - exampleJson = "\"\""; - - var example = exampleJson != null - ? System.Text.Json.JsonSerializer.Deserialize(exampleJson) - : default(BaseOperationResult); //TODO: Change the data returned - return new ObjectResult(example); - } - - /// - /// Returns the Submodel - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Requested Submodel - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelByIdAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(Submodel), description: "Requested Submodel")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelByIdAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromQuery] LevelEnum level, [FromQuery] ExtentEnum extent) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get the submodel with id {submodelIdentifier} from the AAS with id {aasIdentifier}."); - - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReasons = authResult.Failure.FailureReasons; - var authorizationFailureReasons = failedReasons.ToList(); - if (authorizationFailureReasons.Count != 0) - { - throw new NotAllowed(authorizationFailureReasons.First().Message); - } - } - - var output = _levelExtentModifierService.ApplyLevelExtent(submodel, level, extent); - return new ObjectResult(output); - } - +namespace IO.Swagger.Controllers +{ /// - /// Returns the Submodel's metadata elements + /// /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Requested Submodel - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$metadata")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelByIdMetadataAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(SubmodelMetadata), description: "Requested Submodel")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelByIdMetadataAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromQuery] LevelEnum level) + [Authorize(AuthenticationSchemes = "AasSecurityAuth")] + [ApiController] + public class AssetAdministrationShellRepositoryAPIApiController : ControllerBase { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + private readonly IAppLogger _logger; + private readonly IAssetAdministrationShellService _aasService; + private readonly IBase64UrlDecoderService _decoderService; + private readonly IReferenceModifierService _referenceModifierService; + private readonly IMappingService _mappingService; + private readonly IPathModifierService _pathModifierService; + private readonly ILevelExtentModifierService _levelExtentModifierService; + private readonly IPaginationService _paginationService; + private readonly IAuthorizationService _authorizationService; + private readonly IValidateSerializationModifierService _validateModifierService; + + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public AssetAdministrationShellRepositoryAPIApiController(IAppLogger logger, + IAssetAdministrationShellService aasService, IBase64UrlDecoderService decoderService, + IReferenceModifierService referenceModifierService, + IMappingService mappingService, IPathModifierService pathModifierService, + ILevelExtentModifierService levelExtentModifierService, IPaginationService paginationService, + IAuthorizationService authorizationService, IValidateSerializationModifierService validateModifierService) + { + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + _aasService = aasService ?? throw new ArgumentNullException(nameof(aasService)); + _decoderService = decoderService ?? throw new ArgumentNullException(nameof(decoderService)); + _referenceModifierService = referenceModifierService ?? throw new ArgumentNullException(nameof(referenceModifierService)); + _mappingService = mappingService ?? throw new ArgumentNullException(nameof(mappingService)); + _pathModifierService = pathModifierService ?? throw new ArgumentNullException(nameof(pathModifierService)); + _levelExtentModifierService = levelExtentModifierService ?? throw new ArgumentNullException(nameof(levelExtentModifierService)); + _paginationService = paginationService ?? throw new ArgumentNullException(nameof(paginationService)); + _authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService)); + _validateModifierService = validateModifierService ?? throw new ArgumentNullException(nameof(authorizationService)); + } + + + /// + /// Deletes an Asset Administration Shell + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// Asset Administration Shell deleted successfully + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("shells/{aasIdentifier}")] + [ValidateModelState] + [SwaggerOperation("DeleteAssetAdministrationShellById")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult DeleteAssetAdministrationShellById([FromRoute][Required] string aasIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + _logger.LogInformation($"Received request to delete AAS with id {decodedAasIdentifier}"); + _aasService.DeleteAssetAdministrationShellById(decodedAasIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + return NoContent(); } - _logger.LogInformation($"Received request to get metadat of the submodel with id {decodedSubmodelIdentifier} from the AAS with id {decodedAasIdentifier}"); - - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason != null) + /// + /// Deletes file content of an existing submodel element at a specified path within submodel elements hierarchy + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Submodel element updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] + [ValidateModelState] + [SwaggerOperation("DeleteFileByPathAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult DeleteFileByPathAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromRoute][Required]string idShortPath) + { + _logger.LogInformation($"Received request to delete a file from AAS"); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) { - throw new NotAllowed(failedReason.Message); + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); } - } - var submodelLevel = _levelExtentModifierService.ApplyLevelExtent(submodel, level); - var output = _mappingService.Map(submodelLevel, "metadata"); - return new ObjectResult(output); - } + if (decodedSmIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSmIdentifier)} is null"); + } - /// - /// Returns the Submodel's metadata elements - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Requested Submodel in Path notation - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$path")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelByIdPathAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested Submodel in Path notation")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelByIdPathAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode($"aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode($"submodelIdentifier", submodelIdentifier); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSmIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + _aasService.DeleteFileByPath(decodedAasIdentifier, decodedSmIdentifier, idShortPath); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + return NoContent(); } - _logger.LogInformation($"Received request to get path of a submodel with is {decodedSubmodelIdentifier} and AAS with id {decodedAasIdentifier}"); - - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason != null) + /// + /// Deletes the submodel from the Asset Administration Shell and the Repository. + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Submodel deleted successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("DeleteSubmodelByIdAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult DeleteSubmodelByIdAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier) + { + _logger.LogInformation($"Received request to delete a submodel from AAS"); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) { - throw new NotAllowed(failedReason.Message); + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); } - } - - var submodelLevel = _levelExtentModifierService.ApplyLevelExtent(submodel, level); - var output = _pathModifierService.ToIdShortPath(submodelLevel); - return new ObjectResult(output); - } - /// - /// Returns the Submodel as a Reference - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Requested Submodel as a Reference - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$reference")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelByIdReferenceAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(Reference), description: "Requested Submodel as a Reference")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelByIdReferenceAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedSmIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSmIdentifier)} is null"); + } - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + _aasService.DeleteSubmodelById(decodedAasIdentifier, decodedSmIdentifier); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + return NoContent(); } - _logger.LogInformation($"Received request to get the submodel with id {submodelIdentifier} from the AAS with id {aasIdentifier}."); - - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason != null) + /// + /// Deletes a submodel element at a specified path within the submodel elements hierarchy + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Submodel element deleted successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("DeleteSubmodelElementByPathAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult DeleteSubmodelElementByPathAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromRoute][Required]string idShortPath) + { + _logger.LogInformation($"Received request to delete a SubmodelElement from AAS"); + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) { - throw new NotAllowed(failedReason.Message); + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); } - } - var output = _referenceModifierService.GetReferenceResult(submodel); - return new ObjectResult(output); - } + if (decodedSmIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSmIdentifier)} is null"); + } - /// - /// Returns the Submodel's ValueOnly representation - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Requested Submodel - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$value")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelByIdValueOnlyAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(SubmodelValue), description: "Requested Submodel")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelByIdValueOnlyAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromQuery] LevelEnum level, [FromQuery] ExtentEnum extent) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSmIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + _aasService.DeleteSubmodelElementByPath(decodedAasIdentifier, decodedSmIdentifier, idShortPath); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + return NoContent(); } - _logger.LogInformation($"Received request to get the value of submodel with id {decodedSubmodelIdentifier} from the aas with id {decodedAasIdentifier}"); - - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason != null) + /// + /// Deletes the submodel reference from the Asset Administration Shell. Does not delete the submodel itself! + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Submodel reference deleted successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("shells/{aasIdentifier}/submodel-refs/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("DeleteSubmodelReferenceByIdAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult DeleteSubmodelReferenceByIdAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) { - throw new NotAllowed(failedReason.Message); + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); } - } - var submodelLevel = _levelExtentModifierService.ApplyLevelExtent(submodel, level, extent); - var output = _mappingService.Map(submodelLevel, "value"); - return new ObjectResult(output); - } + if (decodedSmIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSmIdentifier)} is null"); + } - /// - /// Returns a specific submodel element from the Submodel at a specified path - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Requested submodel element - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelElementByPathAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(ISubmodelElement), description: "Requested submodel element")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelElementByPathAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received request to delete submodel reference with id {submodelIdentifier} from the AAS with id {aasIdentifier}."); + _aasService.DeleteSubmodelReferenceById(decodedAasIdentifier, decodedSmIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + return NoContent(); } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + /// + /// + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// Thumbnail deletion successful + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("shells/{aasIdentifier}/asset-information/thumbnail")] + [ValidateModelState] + [SwaggerOperation("DeleteThumbnailAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult DeleteThumbnailAasRepository([FromRoute][Required]string aasIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + _logger.LogInformation($"Received request to delete the thumbnail from the AAS with id {decodedAasIdentifier}."); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - _logger.LogInformation($"Received request to get the submodel element at {idShortPath} from the submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); + _aasService.DeleteThumbnail(decodedAasIdentifier); - var submodelElement = _aasService.GetSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath); + return NoContent(); + } - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) + /// + /// Returns all Asset Administration Shells + /// + /// A list of specific Asset identifiers. Every single value asset identifier is a base64-url-encoded [SpecificAssetId](https://api.swaggerhub.com/domains/Plattform_i40/Part1-MetaModel-Schemas/V3.0.3#/components/schemas/SpecificAssetId). + /// The Asset Administration Shell’s IdShort + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Requested Asset Administration Shells + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells")] + [ValidateModelState] + [SwaggerOperation("GetAllAssetAdministrationShells")] + [SwaggerResponse(statusCode: 200, type: typeof(PagedResult), description: "Requested Asset Administration Shells")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllAssetAdministrationShells([FromQuery]List assetIds, [FromQuery]string? idShort, [FromQuery]int? limit, [FromQuery]string? cursor) + { + _logger.LogInformation($"Received the request to get all Asset Administration Shells."); + + List reqAssetIds = null; + + foreach (var assetId in assetIds) { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + if (!string.IsNullOrEmpty(assetId)) + { + var decodedAssetIdString = _decoderService.Decode("assetId", assetId); + var assetJsonNode = JsonNode.Parse(decodedAssetIdString); + var reqAssetId = Jsonization.Deserialize.SpecificAssetIdFrom(assetJsonNode); + reqAssetIds??= new List(); + reqAssetIds.Add(reqAssetId); + } } - } - var smeLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, level, extent); - return new ObjectResult(smeLevel); - } + var aasList = _aasService.GetAllAssetAdministrationShells(reqAssetIds, idShort); + var output = _paginationService.GetPaginatedList(aasList, new PaginationParameters(cursor, limit)); + return new ObjectResult(output); + } + + /// + /// Returns References to all Asset Administration Shells + /// + /// A list of specific Asset identifiers. Every single value asset identifier is a base64-url-encoded [SpecificAssetId](https://api.swaggerhub.com/domains/Plattform_i40/Part1-MetaModel-Schemas/V3.0.3#/components/schemas/SpecificAssetId). + /// The Asset Administration Shell’s IdShort + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Requested Asset Administration Shells as a list of References + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/$reference")] + [ValidateModelState] + [SwaggerOperation("GetAllAssetAdministrationShellsReference")] + [SwaggerResponse(statusCode: 200, type: typeof(GetReferencesResult), description: "Requested Asset Administration Shells as a list of References")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllAssetAdministrationShellsReference([FromQuery]List assetIds, [FromQuery]string? idShort, + [FromQuery]int? limit, [FromQuery]string? cursor) + { + _logger.LogInformation($"Received the request to get all Asset Administration Shells."); + + List reqAssetIds = null; + + foreach (var assetId in assetIds) + { + if (!string.IsNullOrEmpty(assetId)) + { + var decodedAssetIdString = _decoderService.Decode("assetId", assetId); + var assetJsonNode = JsonNode.Parse(decodedAssetIdString); + var reqAssetId = Jsonization.Deserialize.SpecificAssetIdFrom(assetJsonNode); + reqAssetIds ??= new List(); + reqAssetIds.Add(reqAssetId); + } + } - /// - /// Returns the metadata attributes if a specific submodel element from the Submodel at a specified path - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Requested submodel element - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelElementByPathMetadataAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(ISubmodelElementMetadata), description: "Requested submodel element")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelElementByPathMetadataAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + var aasList = _aasService.GetAllAssetAdministrationShells(reqAssetIds, idShort); + var aasPaginatedList = _paginationService.GetPaginatedList(aasList, new PaginationParameters(cursor, limit)); + var references = _referenceModifierService.GetReferenceResult(aasPaginatedList.result.ConvertAll(a => (IReferable)a)); + var output = new ReferencePagedResult(references, aasPaginatedList.paging_metadata); + return new ObjectResult(output); + } + + /// + /// Returns all submodel elements including their hierarchy + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// List of found submodel elements + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(GetSubmodelElementsResult), description: "List of found submodel elements")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElementsAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level, [FromQuery]string? extent) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + if (decodedSmIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSmIdentifier)} is null"); + } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + _logger.LogInformation($"Received request to get all the submodel elements from submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSmIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - _logger.LogInformation($"Received request to get metadata of the submodel element at {idShortPath} from the submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); + var submodelElements = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSmIdentifier); + + var smePaginated = _paginationService.GetPaginatedList(submodelElements, new PaginationParameters(cursor, limit)); + var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginated.result ?? [], levelEnum, extentEnum); + var output = new PagedResult() { result = smeLevelList.ConvertAll(sme => sme), paging_metadata = smePaginated.paging_metadata }; + return new ObjectResult(output); + } + + /// + /// Returns all submodel elements including their hierarchy + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// List of found submodel elements + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsMetadataAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(MetadataPagedResult), description: "List of found submodel elements")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElementsMetadataAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromQuery]int? limit, [FromQuery]string? cursor) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - var submodelElement = _aasService.GetSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) + if (decodedSubmodelIdentifier == null) { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); } - } - var smeLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, level); - var output = _mappingService.Map(smeLevel, "metadata"); - return new ObjectResult(output); - } + _logger.LogInformation($"Received request to get metadata of all the submodel elements from the submodel with id {decodedSubmodelIdentifier} and AAS with id {decodedAasIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - /// - /// Returns a specific submodel element from the Submodel at a specified path in the Path notation - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Requested submodel element in the Path notation - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$path")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelElementByPathPathAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(string), description: "Requested submodel element in the Path notation")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelElementByPathPathAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode($"aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode($"submodelIdentifier", submodelIdentifier); + var smeList = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSubmodelIdentifier); + + var smePaginated = _paginationService.GetPaginatedList(smeList, new PaginationParameters(cursor, limit)); + var smeMetadataList = _mappingService.Map(smePaginated.result, "metadata"); + var output = new MetadataPagedResult { result = smeMetadataList.ConvertAll(sme => (IMetadataDTO)sme), paging_metadata = smePaginated.paging_metadata }; + return new ObjectResult(output); + } + + /// + /// Returns all submodel elements including their hierarchy + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// List of found submodel elements in the Path notation + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$path")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsPathAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(GetPathItemsResult), description: "List of found submodel elements in the Path notation")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElementsPathAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level, [FromQuery]string? extent) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + + var decodedAasIdentifier = _decoderService.Decode($"aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode($"submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + _logger.LogInformation($"Received a request to get path for all the submodel elements from the submodel with id {decodedSubmodelIdentifier} and aas with id {decodedAasIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - _logger.LogInformation($"Received a request to get a path of a submodel element at {idShortPath} from a submodel with id {decodedSubmodelIdentifier} and aas with id {decodedAasIdentifier}"); + var submodelElementsList = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSubmodelIdentifier); + + var smePaginated = _paginationService.GetPaginatedList(submodelElementsList, new PaginationParameters(cursor, limit)); + var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginated.result ?? [], levelEnum, extentEnum); + var smePathList = _pathModifierService.ToIdShortPath(smeLevelList.ConvertAll(sme => (ISubmodelElement)sme)); + var output = new PathPagedResult { result = smePathList, paging_metadata = smePaginated.paging_metadata }; + return new ObjectResult(output); + } + + /// + /// Returns all submodel elements as a list of References + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// List of References of the found submodel elements + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$reference")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsReferenceAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(GetReferencesResult), description: "List of References of the found submodel elements")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElementsReferenceAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - var submodelElement = _aasService.GetSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) + if (decodedSubmodelIdentifier == null) { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); } - } - var smeLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, level); - var output = _pathModifierService.ToIdShortPath(smeLevel); - return new ObjectResult(output); - } + _logger.LogInformation($"Received request to get references of all the submodel elements from submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - /// - /// Returns the Reference of a specific submodel element from the Submodel at a specified path - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Requested submodel element in its ValueOnly representation - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$reference")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelElementByPathReferenceAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(Reference), description: "Requested submodel element in its ValueOnly representation")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelElementByPathReferenceAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + var smeList = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSubmodelIdentifier); + + // TODO (jtikekar, 2023-09-04): check performace imapct due to ConvertAll + var smePaginated = _paginationService.GetPaginatedList(smeList, new PaginationParameters(cursor, limit)); + var smeReferenceList = _referenceModifierService.GetReferenceResult(smePaginated.result.ConvertAll(sme => (IReferable)sme)); + var output = new ReferencePagedResult(smeReferenceList, smePaginated.paging_metadata); + return new ObjectResult(output); + } + + /// + /// Returns all submodel elements including their hierarchy in the ValueOnly representation + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// List of found submodel elements in their ValueOnly representation + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$value")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsValueOnlyAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(ValueOnlyPagedResult), description: "List of found submodel elements in their ValueOnly representation")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElementsValueOnlyAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level) + { + //Validate level + var levelEnum = _validateModifierService.ValidateLevel(level); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } + + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - _logger.LogInformation($"Received request to get the submodel element at {idShortPath} from the submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); + _logger.LogInformation($"Received request to get the value of all the submodel elements from the submodel with id {decodedSubmodelIdentifier} and aas with id {decodedAasIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - var submodelElement = _aasService.GetSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) + var submodelElements = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSubmodelIdentifier); + + var smePaginated = _paginationService.GetPaginatedList(submodelElements, new PaginationParameters(cursor, limit)); + var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginated.result, levelEnum); + var smeValueList = _mappingService.Map(smeLevelList, "value"); + var output = new ValueOnlyPagedResult { result = smeValueList.ConvertAll(sme => (IValueDTO)sme), paging_metadata = smePaginated.paging_metadata }; + return new ObjectResult(output); + } + + /// + /// Returns all submodel references + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Requested submodel references + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodel-refs")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelReferencesAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(GetReferencesResult), description: "Requested submodel references")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelReferencesAasRepository([FromRoute][Required]string aasIdentifier, [FromQuery]int? limit, [FromQuery]string? cursor) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + if (decodedAasIdentifier == null) { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); } - } - //Level should not be applicable + _logger.LogInformation($"Received request to get all the submodel references from the AAS with id {aasIdentifier}."); + + var submodels = _aasService.GetAllSubmodelReferencesFromAas(decodedAasIdentifier); + + var output = _paginationService.GetPaginatedList(submodels, new PaginationParameters(cursor, limit)); + return new ObjectResult(output); + } + + /// + /// Returns a specific Asset Administration Shell + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// Requested Asset Administration Shell + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}")] + [ValidateModelState] + [SwaggerOperation("GetAssetAdministrationShellById")] + [SwaggerResponse(statusCode: 200, type: typeof(AssetAdministrationShell), description: "Requested Asset Administration Shell")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAssetAdministrationShellById([FromRoute][Required] string aasIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - var output = _referenceModifierService.GetReferenceResult(submodelElement); - return new ObjectResult(output); - } + _logger.LogInformation($"Received request to get the AAS with id {aasIdentifier}."); - /// - /// Returns a specific submodel element from the Submodel at a specified path in the ValueOnly representation - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Requested submodel element in its ValueOnly representation - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelElementByPathValueOnlyAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(IValueDTO), description: "Requested submodel element in its ValueOnly representation")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelElementByPathValueOnlyAasRepository([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + var aas = _aasService.GetAssetAdministrationShellById(decodedAasIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + /* Turn off AAS security to have existing demos run + var authResult = _authorizationService.AuthorizeAsync(User, aas, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReasons = authResult.Failure.FailureReasons; + if (failedReasons != null && failedReasons.Any()) + { + throw new NotAllowed(failedReasons.First().Message); + } + } + */ + return new ObjectResult(aas); + } + + /// + /// Returns a specific Asset Administration Shell as a Reference + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// Requested Asset Administration Shell + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/$reference")] + [ValidateModelState] + [SwaggerOperation("GetAssetAdministrationShellByIdReferenceAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(Reference), description: "Requested Asset Administration Shell")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAssetAdministrationShellByIdReferenceAasRepository([FromRoute][Required]string aasIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + _logger.LogInformation($"Received request to get the reference of AAS with id {aasIdentifier}."); + + var aas = _aasService.GetAssetAdministrationShellById(decodedAasIdentifier); + + var output = _referenceModifierService.GetReferenceResult(aas); + + return new ObjectResult(output); + } + + /// + /// Returns the Asset Information + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// Requested Asset Information + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/asset-information")] + [ValidateModelState] + [SwaggerOperation("GetAssetInformationAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(AssetInformation), description: "Requested Asset Information")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAssetInformationAasRepository([FromRoute][Required]string aasIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - _logger.LogInformation($"Received request to get the value of the submodel element at {idShortPath} from the submodel with id {decodedSubmodelIdentifier} and the aas with id {decodedAasIdentifier}"); + _logger.LogInformation($"Received request to get the AAS with id {decodedAasIdentifier}."); + + var output = _aasService.GetAssetInformation(decodedAasIdentifier); + + return new ObjectResult(output); + } + + /// + /// Downloads file content from a specific submodel element from the Submodel at a specified path + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Requested file + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] + [ValidateModelState] + [SwaggerOperation("GetFileByPathAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(byte[]), description: "Requested file")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetFileByPathAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromRoute][Required]string idShortPath) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - var submodelElement = _aasService.GetSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) + if (decodedSubmodelIdentifier == null) { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); } - } - var smeLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, level, extent); - var output = _mappingService.Map(smeLevel, "value"); - return new ObjectResult(output); - } + _logger.LogInformation($"Received request to get file by path at the submodel element {idShortPath} from submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); - /// - /// - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The thumbnail of the Asset Information. - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/shells/{aasIdentifier}/asset-information/thumbnail")] - [ValidateModelState] - [SwaggerOperation("GetThumbnailAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(byte[]), description: "The thumbnail of the Asset Information.")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual async Task GetThumbnailAasRepository([FromRoute] [Required] string aasIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + var fileName = _aasService.GetFileByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, out var content, out var fileSize); - _logger.LogInformation($"Received request to get the thumbnail of the AAS with Id {aasIdentifier}"); + //content-disposition so that the aasx file can be downloaded from the web browser. + ContentDisposition contentDisposition = new() { FileName = fileName, Inline = fileName.ToLower().EndsWith(".pdf") }; - var fileName = _aasService.GetThumbnail(decodedAasIdentifier, out var content, out var fileSize); + HttpContext.Response.Headers.Append("Content-Disposition", contentDisposition.ToString()); + HttpContext.Response.ContentLength = fileSize; + if (fileName.ToLower().EndsWith(".svg")) + { + HttpContext.Response.ContentType = "image/svg+xml"; + } - //content-disposition so that the aasx file can be downloaded from the web browser. - ContentDisposition contentDisposition = new() {FileName = fileName}; + if (fileName.ToLower().EndsWith(".pdf")) + { + HttpContext.Response.ContentType = "application/pdf"; + } - HttpContext.Response.Headers.Append("Content-Disposition", contentDisposition.ToString()); - HttpContext.Response.ContentLength = fileSize; - await HttpContext.Response.Body.WriteAsync(content); - return new EmptyResult(); - } + HttpContext.Response.Body.WriteAsync(content); + return new EmptyResult(); + } + + /// + /// Returns the Operation result of an asynchronous invoked Operation + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) + /// Operation result object + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-results/{handleId}")] + [ValidateModelState] + [SwaggerOperation("GetOperationAsyncResultAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(OperationResult), description: "Operation result object")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetOperationAsyncResultAasRepository([FromRoute][Required] string aasIdentifier, [FromRoute][Required] string submodelIdentifier, + [FromRoute][Required] string idShortPath, [FromRoute][Required] string handleId) + { + throw new NotImplementedException(); + } + + /// + /// Returns the ValueOnly notation of the Operation result of an asynchronous invoked Operation + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) + /// Operation result object + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-results/{handleId}/$value")] + [ValidateModelState] + [SwaggerOperation("GetOperationAsyncResultValueOnlyAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(Object), description: "Operation result object")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetOperationAsyncResultValueOnlyAasRepository([FromRoute][Required] string aasIdentifier, [FromRoute][Required] string submodelIdentifier, + [FromRoute][Required] string idShortPath, [FromRoute][Required] string handleId) + { + throw new NotImplementedException(); + } + + /// + /// Returns the Operation status of an asynchronous invoked Operation + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) + /// Operation result object containing information that the 'executionState' is still 'Running' + /// The target resource is available but at a different location. + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-status/{handleId}")] + [ValidateModelState] + [SwaggerOperation("GetOperationAsyncStatusAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(BaseOperationResult), description: "Operation result object containing information that the 'executionState' is still 'Running'")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetOperationAsyncStatusAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromRoute][Required]string idShortPath, [FromRoute][Required]string handleId) + { + throw new NotImplementedException() ; + } + + /// + /// Returns the Submodel + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Requested Submodel + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(Submodel), description: "Requested Submodel")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelByIdAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromQuery]string? level, [FromQuery]string? extent) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - /// - /// Synchronously invokes an Operation at a specified path - /// - /// Operation request object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Operation result object - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke")] - [ValidateModelState] - [SwaggerOperation("InvokeOperationAasRepository")] - [SwaggerResponse(statusCode: 200, type: typeof(OperationResult), description: "Operation result object")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult InvokeOperationAasRepository([FromBody] OperationRequest? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath) - { - //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(200, default(OperationResult)); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); + _logger.LogInformation($"Received request to get the submodel with id {submodelIdentifier} from the AAS with id {aasIdentifier}."); - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReasons = authResult.Failure.FailureReasons; + var authorizationFailureReasons = failedReasons.ToList(); + if (authorizationFailureReasons.Count != 0) + { + throw new NotAllowed(authorizationFailureReasons.First().Message); + } + } - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); + var output = _levelExtentModifierService.ApplyLevelExtent(submodel, levelEnum, extentEnum); + return new ObjectResult(output); + } + + /// + /// Returns the Submodel's metadata elements + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Requested Submodel + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdMetadataAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(Object), description: "Requested Submodel")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelByIdMetadataAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); + _logger.LogInformation($"Received request to get metadat of the submodel with id {decodedSubmodelIdentifier} from the AAS with id {decodedAasIdentifier}"); - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); - string exampleJson = null; - exampleJson = "\"\""; + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason != null) + { + throw new NotAllowed(failedReason.Message); + } + } - var example = exampleJson != null - ? System.Text.Json.JsonSerializer.Deserialize(exampleJson) - : default(OperationResult); //TODO: Change the data returned - return new ObjectResult(example); - } + var output = _mappingService.Map(submodel, "metadata"); + return new ObjectResult(output); + } + + /// + /// Returns the Submodel's metadata elements + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Determines the structural depth of the respective resource content + /// Requested Submodel in Path notation + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/$path")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdPathAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested Submodel in Path notation")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelByIdPathAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromQuery]string? level) + { + //Validate level + var levelEnum = _validateModifierService.ValidateLevel(level); + + var decodedAasIdentifier = _decoderService.Decode($"aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode($"submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - /// - /// Asynchronously invokes an Operation at a specified path - /// - /// Operation request object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// The server has accepted the request. - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke-async")] - [ValidateModelState] - [SwaggerOperation("InvokeOperationAsyncAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult InvokeOperationAsyncAasRepository([FromBody] OperationRequest? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath) - { - //TODO: Uncomment the next line to return response 202 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(202); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); + _logger.LogInformation($"Received request to get path of a submodel with is {decodedSubmodelIdentifier} and AAS with id {decodedAasIdentifier}"); - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason != null) + { + throw new NotAllowed(failedReason.Message); + } + } - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); + var submodelLevel = _levelExtentModifierService.ApplyLevelExtent(submodel, levelEnum); + var output = _pathModifierService.ToIdShortPath(submodelLevel); + return new ObjectResult(output); + } + + /// + /// Returns the Submodel as a Reference + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Requested Submodel as a Reference + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/$reference")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdReferenceAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(Reference), description: "Requested Submodel as a Reference")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelByIdReferenceAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); + _logger.LogInformation($"Received request to get the submodel with id {submodelIdentifier} from the AAS with id {aasIdentifier}."); - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason != null) + { + throw new NotAllowed(failedReason.Message); + } + } - throw new NotImplementedException(); - } + var output = _referenceModifierService.GetReferenceResult(submodel); + return new ObjectResult(output); + } + + /// + /// Returns the Submodel's ValueOnly representation + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Requested Submodel + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/$value")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdValueOnlyAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(SubmodelValue), description: "Requested Submodel")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelByIdValueOnlyAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromQuery]string? level, [FromQuery]string? extent) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - /// - /// Asynchronously invokes an Operation at a specified path - /// - /// Operation request object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// The server has accepted the request. - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke-async/$value")] - [ValidateModelState] - [SwaggerOperation("InvokeOperationAsyncValueOnlyAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - //public virtual IActionResult InvokeOperationAsyncValueOnlyAasRepository([FromBody] OperationRequestValueOnly body, [FromRoute][Required] string aasIdentifier, [FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath) - public virtual IActionResult InvokeOperationAsyncValueOnlyAasRepository([FromBody] object? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath) - { - //TODO: Uncomment the next line to return response 202 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(202); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); + _logger.LogInformation($"Received request to get the value of submodel with id {decodedSubmodelIdentifier} from the aas with id {decodedAasIdentifier}"); - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason != null) + { + throw new NotAllowed(failedReason.Message); + } + } - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); + var submodelLevel = _levelExtentModifierService.ApplyLevelExtent(submodel, levelEnum, extentEnum); + var output = _mappingService.Map(submodelLevel, "value"); + return new ObjectResult(output); + } + + /// + /// Returns a specific submodel element from the Submodel at a specified path + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Requested submodel element + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(ISubmodelElement), description: "Requested submodel element")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelElementByPathAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromRoute][Required]string idShortPath, [FromQuery]string? level, [FromQuery]string? extent) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); + _logger.LogInformation($"Received request to get the submodel element at {idShortPath} from the submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); + var submodelElement = _aasService.GetSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath); - throw new NotImplementedException(); - } + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - /// - /// Synchronously invokes an Operation at a specified path - /// - /// Operation request object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Operation result object - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke/$value")] - [ValidateModelState] - [SwaggerOperation("InvokeOperationValueOnlyAasRepository")] - //[SwaggerResponse(statusCode: 200, type: typeof(OperationResultValueOnly), description: "Operation result object")] - [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Operation result object")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult InvokeOperationValueOnlyAasRepository([FromBody] object? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath) - { - //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(200, default(OperationResultValueOnly)); + var smeLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, levelEnum, extentEnum); + return new ObjectResult(smeLevel); + } + + /// + /// Returns the metadata attributes if a specific submodel element from the Submodel at a specified path + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Requested submodel element + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathMetadataAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(ISubmodelElementMetadata), description: "Requested submodel element")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelElementByPathMetadataAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromRoute][Required]string idShortPath) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); + _logger.LogInformation($"Received request to get metadata of the submodel element at {idShortPath} from the submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); + var submodelElement = _aasService.GetSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); + var output = _mappingService.Map(submodelElement, "metadata"); + return new ObjectResult(output); + } + + /// + /// Returns a specific submodel element from the Submodel at a specified path in the Path notation + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Requested submodel element in the Path notation + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$path")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathPathAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested submodel element in the Path notation")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelElementByPathPathAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromRoute][Required]string idShortPath, [FromQuery]string? level) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + + var decodedAasIdentifier = _decoderService.Decode($"aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode($"submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); - string exampleJson = null; - exampleJson = "\"\""; + _logger.LogInformation($"Received a request to get a path of a submodel element at {idShortPath} from a submodel with id {decodedSubmodelIdentifier} and aas with id {decodedAasIdentifier}"); - var example = exampleJson != null - ? System.Text.Json.JsonSerializer.Deserialize(exampleJson) - : default(object); //TODO: Change the data returned - return new ObjectResult(example); - } + var submodelElement = _aasService.GetSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - /// - /// Updates the Submodel - /// - /// Submodel object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Submodel updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelAasRepository([FromBody] Submodel? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + var output = _pathModifierService.ToIdShortPath(submodelElement); + return new ObjectResult(output); + } + + /// + /// Returns the Reference of a specific submodel element from the Submodel at a specified path + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Requested submodel element in its ValueOnly representation + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$reference")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathReferenceAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(Reference), description: "Requested submodel element in its ValueOnly representation")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelElementByPathReferenceAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromRoute][Required]string idShortPath, [FromQuery]string? level) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received request to get the submodel element at {idShortPath} from the submodel with id {submodelIdentifier} and the AAS with id {aasIdentifier}."); + + var submodelElement = _aasService.GetSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - _logger.LogInformation($"Received request to update the submodel with id {decodedSubmodelIdentifier} from the AAS with id {decodedAasIdentifier}"); - _aasService.UpdateSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier, body); + //Level should not be applicable + + var output = _referenceModifierService.GetReferenceResult(submodelElement); + return new ObjectResult(output); + } + + /// + /// Returns a specific submodel element from the Submodel at a specified path in the ValueOnly representation + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Requested submodel element in its ValueOnly representation + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathValueOnlyAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(IValueDTO), description: "Requested submodel element in its ValueOnly representation")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelElementByPathValueOnlyAasRepository([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, + [FromRoute][Required]string idShortPath, [FromQuery]string? level, [FromQuery]string? extent) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - return NoContent(); - } + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - /// - /// Updates the metadata attributes of the Submodel - /// - /// Submodel object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Submodel updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$metadata")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelByIdMetadataAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelByIdMetadataAasRepository([FromBody] SubmodelMetadata? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received request to get the value of the submodel element at {idShortPath} from the submodel with id {decodedSubmodelIdentifier} and the aas with id {decodedAasIdentifier}"); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + var submodelElement = _aasService.GetSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + var smeLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, levelEnum, extentEnum); + var output = _mappingService.Map(smeLevel, "value"); + return new ObjectResult(output); + } + + /// + /// + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The thumbnail of the Asset Information. + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("shells/{aasIdentifier}/asset-information/thumbnail")] + [ValidateModelState] + [SwaggerOperation("GetThumbnailAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(byte[]), description: "The thumbnail of the Asset Information.")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetThumbnailAasRepository([FromRoute][Required]string aasIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - _logger.LogInformation($"Received Request to update for submodel with id {decodedSubmodelIdentifier} from the aas with id {decodedAasIdentifier}"); + _logger.LogInformation($"Received request to get the thumbnail of the AAS with Id {aasIdentifier}"); + + var fileName = _aasService.GetThumbnail(decodedAasIdentifier, out var content, out var fileSize); + + //content-disposition so that the aasx file can be downloaded from the web browser. + ContentDisposition contentDisposition = new() { FileName = fileName }; + + HttpContext.Response.Headers.Append("Content-Disposition", contentDisposition.ToString()); + HttpContext.Response.ContentLength = fileSize; + HttpContext.Response.Body.WriteAsync(content); + return new EmptyResult(); + } + + /// + /// Synchronously invokes an Operation at a specified path + /// + /// Operation request object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Operation result object + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke")] + [ValidateModelState] + [SwaggerOperation("InvokeOperationAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(OperationResult), description: "Operation result object")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult InvokeOperationAasRepository([FromBody]OperationRequest body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath) + { + throw new NotImplementedException(); + } + + /// + /// Asynchronously invokes an Operation at a specified path + /// + /// Operation request object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// The server has accepted the request. + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke-async")] + [ValidateModelState] + [SwaggerOperation("InvokeOperationAsyncAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult InvokeOperationAsyncAasRepository([FromBody] OperationRequest body, [FromRoute][Required] string aasIdentifier, + [FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath) + { + throw new NotImplementedException(); + } + + /// + /// Asynchronously invokes an Operation at a specified path + /// + /// Operation request object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// The server has accepted the request. + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke-async/$value")] + [ValidateModelState] + [SwaggerOperation("InvokeOperationAsyncValueOnlyAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult InvokeOperationAsyncValueOnlyAasRepository([FromBody]OperationRequestValueOnly body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath) + { + throw new NotImplementedException(); + } + + /// + /// Synchronously invokes an Operation at a specified path + /// + /// Operation request object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Operation result object + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke/$value")] + [ValidateModelState] + [SwaggerOperation("InvokeOperationValueOnlyAasRepository")] + [SwaggerResponse(statusCode: 200, type: typeof(OperationResultValueOnly), description: "Operation result object")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult InvokeOperationValueOnlyAasRepository([FromBody]OperationRequestValueOnly body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath) + { + throw new NotImplementedException(); + } + + /// + /// Updates the Submodel + /// + /// Submodel object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Determines the structural depth of the respective resource content + /// Submodel updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelAasRepository([FromBody]Submodel body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier, [FromQuery]string? level) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received request to update the submodel with id {decodedSubmodelIdentifier} from the AAS with id {decodedAasIdentifier}"); + _aasService.UpdateSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier, body); - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); + return NoContent(); } - //Reverse mapping from Metadata to submodel element - var submodel = _mappingService.Map(body, "metadata") as ISubmodel; - - //Update - if (submodel == null) - { - return BadRequest($"Could not update Submodel as {nameof(submodel)} is null."); - } + /// + /// Updates the metadata attributes of the Submodel + /// + /// Submodel object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Submodel updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/$metadata")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelByIdMetadataAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelByIdMetadataAasRepository([FromBody]SubmodelMetadata body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - _aasService.UpdateSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier, submodel); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - return NoContent(); - } + _logger.LogInformation($"Received Request to update for submodel with id {decodedSubmodelIdentifier} from the aas with id {decodedAasIdentifier}"); - /// - /// Updates teh values of the Submodel - /// - /// Submodel object in the ValueOnly representation - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Submodel updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$value")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelByIdValueOnlyAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelByIdValueOnlyAasRepository([FromBody] SubmodelValue? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + //Reverse mapping from Metadata to submodel element + var submodel = _mappingService.Map(body, "metadata") as ISubmodel; - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + //Update + if (submodel == null) + { + return BadRequest($"Could not update Submodel as {nameof(submodel)} is null."); + } - _logger.LogInformation($"Received request to update the submodel with id {decodedSubmodelIdentifier} from the aas with tid {decodedAasIdentifier} by value."); + _aasService.UpdateSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier, submodel); - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); + return NoContent(); } - var submodel = _mappingService.Map(body, "value") as Submodel; - if (submodel == null) - { - return BadRequest($"Could not update Submodel as {nameof(submodel)} is null."); - } + /// + /// Updates the values of the Submodel + /// + /// Submodel object in the ValueOnly representation + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Determines the structural depth of the respective resource content + /// Submodel updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/$value")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelByIdValueOnlyAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelByIdValueOnlyAasRepository([FromBody]SubmodelValue body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier, [FromQuery]string? level) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - _aasService.UpdateSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier, submodel); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - return NoContent(); - } + _logger.LogInformation($"Received request to update the submodel with id {decodedSubmodelIdentifier} from the aas with tid {decodedAasIdentifier} by value."); - /// - /// Updates an existing submodel element value at a specified path within submodel elements hierarchy - /// - /// The updated value of the submodel element - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Submodel element updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelElementValueByPathAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelElementValueByPathAasRepository([FromBody] ISubmodelElement? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath, - [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + var submodel = _mappingService.Map(body, "value") as Submodel; + if (submodel == null) + { + return BadRequest($"Could not update Submodel as {nameof(submodel)} is null."); + } - _logger.LogInformation($"Received request to update the submodel element at {idShortPath} from submodel with id {decodedSubmodelIdentifier} from the AAS with id {decodedAasIdentifier}"); + _aasService.UpdateSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier, submodel); - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); + return NoContent(); } - _aasService.UpdateSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, body); - - return NoContent(); - } + /// + /// Updates an existing submodel element value at a specified path within submodel elements hierarchy + /// + /// The updated value of the submodel element + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Submodel element updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelElementValueByPathAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelElementValueByPathAasRepository([FromBody]ISubmodelElement body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string? level) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - /// - /// Updates the metadata attributes of an existing submodel element value at a specified path within submodel elements hierarchy - /// - /// The updated metadata attributes of the submodel element - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Submodel element updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelElementValueByPathMetadata")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelElementValueByPathMetadata([FromBody] ISubmodelElementMetadata? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath, - [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + _logger.LogInformation($"Received request to update the submodel element at {idShortPath} from submodel with id {decodedSubmodelIdentifier} from the AAS with id {decodedAasIdentifier}"); - _logger.LogInformation($"Received request to update the submodel element at {idShortPath} in the submodel with id {decodedSubmodelIdentifier} and the AAS with id {decodedAasIdentifier}"); + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); - } + _aasService.UpdateSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, body); - //Reverse mapping from Metadata to submodel element - if (_mappingService.Map(body, "metadata") is not ISubmodelElement submodelElement) - { - return BadRequest($"Could not update Submodel as {nameof(submodelElement)} is null."); + return NoContent(); } - //Update - _aasService.UpdateSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, submodelElement); + /// + /// Updates the metadata attributes of an existing submodel element value at a specified path within submodel elements hierarchy + /// + /// The updated metadata attributes of the submodel element + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Submodel element updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelElementValueByPathMetadata")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelElementValueByPathMetadata([FromBody]ISubmodelElementMetadata body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - return NoContent(); - } + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - /// - /// Updates the value of an existing submodel element value at a specified path within submodel elements hierarchy - /// - /// The updated value of the submodel element - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Submodel element updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelElementValueByPathValueOnly")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelElementValueByPathValueOnly([FromBody] ISubmodelElementValue? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath, - [FromQuery] LevelEnum level) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + _logger.LogInformation($"Received request to update the submodel element at {idShortPath} in the submodel with id {decodedSubmodelIdentifier} and the AAS with id {decodedAasIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - _logger.LogInformation($"Received request to update the submodel element at {idShortPath} in the submodel with id {decodedSubmodelIdentifier} and the AAS with id {decodedAasIdentifier} by value."); - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); - } + //Reverse mapping from Metadata to submodel element + if (_mappingService.Map(body, "metadata") is not ISubmodelElement submodelElement) + { + return BadRequest($"Could not update Submodel as {nameof(submodelElement)} is null."); + } - //Reverse mapping from Metadata to submodel element - var submodelElement = _mappingService.Map(body, "value") as ISubmodelElement; + //Update + _aasService.UpdateSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, submodelElement); - //Update - if (submodelElement == null) - { - return BadRequest($"Could not update Submodel as {nameof(submodelElement)} is null."); + return NoContent(); } - _aasService.UpdateSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, submodelElement); + /// + /// Updates the value of an existing submodel element value at a specified path within submodel elements hierarchy + /// + /// The updated value of the submodel element + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Submodel element updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelElementValueByPathValueOnly")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelElementValueByPathValueOnly([FromBody]ISubmodelElementValue body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string? level) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - return NoContent(); - } + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - /// - /// Creates a new Asset Administration Shell - /// - /// Asset Administration Shell object - /// Asset Administration Shell created successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/shells")] - [ValidateModelState] - [SwaggerOperation("PostAssetAdministrationShell")] - [SwaggerResponse(statusCode: 201, type: typeof(AssetAdministrationShell), description: "Asset Administration Shell created successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 409, type: typeof(Result), - description: - "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PostAssetAdministrationShell([FromBody] AssetAdministrationShell? body) - { - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); - } + _logger.LogInformation($"Received request to update the submodel element at {idShortPath} in the submodel with id {decodedSubmodelIdentifier} and the AAS with id {decodedAasIdentifier} by value."); + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - var output = _aasService.CreateAssetAdministrationShell(body); + //Reverse mapping from Metadata to submodel element + var submodelElement = _mappingService.Map(body, "value") as ISubmodelElement; - return CreatedAtAction("PostAssetAdministrationShell", output); - } + //Update + if (submodelElement == null) + { + return BadRequest($"Could not update Submodel as {nameof(submodelElement)} is null."); + } - /// - /// Creates a new submodel element - /// - /// Requested submodel element - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Submodel element created successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements")] - [ValidateModelState] - [SwaggerOperation("PostSubmodelElementAasRepository")] - [SwaggerResponse(statusCode: 201, type: typeof(ISubmodelElement), description: "Submodel element created successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 409, type: typeof(Result), - description: - "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PostSubmodelElementAasRepository([FromBody] ISubmodelElement? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, bool first) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + _aasService.UpdateSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, submodelElement); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + return NoContent(); } - _logger.LogInformation($"Received request to create a new submodel element in the submodel {decodedSubmodelIdentifier} and AAS {decodedAasIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{body?.IdShort}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{body?.IdShort}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) + /// + /// Creates a new Asset Administration Shell + /// + /// Asset Administration Shell object + /// Asset Administration Shell created successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("shells")] + [ValidateModelState] + [SwaggerOperation("PostAssetAdministrationShell")] + [SwaggerResponse(statusCode: 201, type: typeof(AssetAdministrationShell), description: "Asset Administration Shell created successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 409, type: typeof(Result), description: "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PostAssetAdministrationShell([FromBody] AssetAdministrationShell body) + { + if (body == null) { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + return BadRequest($"Could not proceed, as {nameof(body)} is null."); } - } - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); - } + var output = _aasService.CreateAssetAdministrationShell(body); + + return CreatedAtAction("PostAssetAdministrationShell", output); + } + + /// + /// Creates a new submodel element + /// + /// Requested submodel element + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Submodel element created successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements")] + [ValidateModelState] + [SwaggerOperation("PostSubmodelElementAasRepository")] + [SwaggerResponse(statusCode: 201, type: typeof(ISubmodelElement), description: "Submodel element created successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 409, type: typeof(Result), description: "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PostSubmodelElementAasRepository([FromBody] ISubmodelElement body, [FromRoute][Required] string aasIdentifier, + [FromRoute][Required] string submodelIdentifier, bool first) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - var output = _aasService.CreateSubmodelElement(decodedAasIdentifier, decodedSubmodelIdentifier, first, body); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - return CreatedAtAction("PostSubmodelElementAasRepository", output); - } + _logger.LogInformation($"Received request to create a new submodel element in the submodel {decodedSubmodelIdentifier} and AAS {decodedAasIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{body?.IdShort}")); + var claimsList = new List(User.Claims) { new Claim("IdShortPath", $"{submodel.IdShort}.{body?.IdShort}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - /// - /// Creates a new submodel element at a specified path within submodel elements hierarchy - /// - /// Requested submodel element - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Submodel element created successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] - [ValidateModelState] - [SwaggerOperation("PostSubmodelElementByPathAasRepository")] - [SwaggerResponse(statusCode: 201, type: typeof(ISubmodelElement), description: "Submodel element created successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 409, type: typeof(Result), - description: - "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PostSubmodelElementByPathAasRepository([FromBody] ISubmodelElement? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath, - bool first) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + var output = _aasService.CreateSubmodelElement(decodedAasIdentifier, decodedSubmodelIdentifier, first, body); + + return CreatedAtAction("PostSubmodelElementAasRepository", output); + } + + /// + /// Creates a new submodel element at a specified path within submodel elements hierarchy + /// + /// Requested submodel element + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Submodel element created successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("PostSubmodelElementByPathAasRepository")] + [SwaggerResponse(statusCode: 201, type: typeof(ISubmodelElement), description: "Submodel element created successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 409, type: typeof(Result), description: "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PostSubmodelElementByPathAasRepository([FromBody]ISubmodelElement body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, bool first) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - _logger.LogInformation($"Received request to create a new submodel element in the submodel {decodedSubmodelIdentifier} and AAS {decodedAasIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) + if (decodedSubmodelIdentifier == null) { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); } - } - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); - } + _logger.LogInformation($"Received request to create a new submodel element in the submodel {decodedSubmodelIdentifier} and AAS {decodedAasIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _aasService.GetSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } - var output = _aasService.CreateSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, first, body); + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - return CreatedAtAction("PostSubmodelElementByPathAasRepository", output); - } + var output = _aasService.CreateSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, first, body); + + return CreatedAtAction("PostSubmodelElementByPathAasRepository", output); + } + + /// + /// Creates a submodel reference at the Asset Administration Shell + /// + /// Reference to the Submodel + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// Submodel reference created successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("shells/{aasIdentifier}/submodel-refs")] + [ValidateModelState] + [SwaggerOperation("PostSubmodelReferenceAasRepository")] + [SwaggerResponse(statusCode: 201, type: typeof(Reference), description: "Submodel reference created successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 409, type: typeof(Result), description: "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PostSubmodelReferenceAasRepository([FromBody]Reference body, [FromRoute][Required]string aasIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - /// - /// Creates a submodel reference at the Asset Administration Shell - /// - /// Reference to the Submodel - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// Submodel reference created successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/shells/{aasIdentifier}/submodel-refs")] - [ValidateModelState] - [SwaggerOperation("PostSubmodelReferenceAasRepository")] - [SwaggerResponse(statusCode: 201, type: typeof(Reference), description: "Submodel reference created successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 409, type: typeof(Result), - description: - "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PostSubmodelReferenceAasRepository([FromBody] Reference? body, [FromRoute] [Required] string aasIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + _logger.LogInformation($"Received request to create a submodel reference in the AAS with id {decodedAasIdentifier}"); - _logger.LogInformation($"Received request to create a submodel reference in the AAS with id {decodedAasIdentifier}"); + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); - } + var output = _aasService.CreateSubmodelReferenceInAAS(body, decodedAasIdentifier); + + return CreatedAtAction("PostSubmodelReferenceAasRepository", output); + } + + /// + /// Updates an existing Asset Administration Shell + /// + /// Asset Administration Shell object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// Asset Administration Shell updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("shells/{aasIdentifier}")] + [ValidateModelState] + [SwaggerOperation("PutAssetAdministrationShellById")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PutAssetAdministrationShellById([FromBody]AssetAdministrationShell body, [FromRoute][Required]string aasIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - var output = _aasService.CreateSubmodelReferenceInAAS(body, decodedAasIdentifier); + _logger.LogInformation($"Received request to replace the AAS with id {decodedAasIdentifier}"); + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - return CreatedAtAction("PostSubmodelReferenceAasRepository", output); - } + _aasService.ReplaceAssetAdministrationShellById(decodedAasIdentifier, body); - /// - /// Updates an existing Asset Administration Shell - /// - /// Asset Administration Shell object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// Asset Administration Shell updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPut] - [Route("/shells/{aasIdentifier}")] - [ValidateModelState] - [SwaggerOperation("PutAssetAdministrationShellById")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PutAssetAdministrationShellById([FromBody] AssetAdministrationShell? body, [FromRoute] [Required] string aasIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + return NoContent(); } - _logger.LogInformation($"Received request to replace the AAS with id {decodedAasIdentifier}"); - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); - } + /// + /// Updates the Asset Information + /// + /// Asset Information object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// Asset Information updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("shells/{aasIdentifier}/asset-information")] + [ValidateModelState] + [SwaggerOperation("PutAssetInformationAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PutAssetInformationAasRepository([FromBody]AssetInformation body, [FromRoute][Required]string aasIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - _aasService.ReplaceAssetAdministrationShellById(decodedAasIdentifier, body); + _logger.LogInformation($"Received request to replace the asset information of the AAS with id {decodedAasIdentifier}"); + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - return NoContent(); - } + _aasService.ReplaceAssetInformation(decodedAasIdentifier, body); - /// - /// Updates the Asset Information - /// - /// Asset Information object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// Asset Information updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPut] - [Route("/shells/{aasIdentifier}/asset-information")] - [ValidateModelState] - [SwaggerOperation("PutAssetInformationAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PutAssetInformationAasRepository([FromBody] AssetInformation? body, [FromRoute] [Required] string aasIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + return NoContent(); } - _logger.LogInformation($"Received request to replace the asset information of the AAS with id {decodedAasIdentifier}"); - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); - } - _aasService.ReplaceAssetInformation(decodedAasIdentifier, body); + /// + /// Updates the Submodel + /// + /// Submodel object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Submodel updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("PutSubmodelByIdAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PutSubmodelByIdAasRepository([FromBody]Submodel body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } + + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - return NoContent(); - } + _logger.LogInformation($"Received request to replace a a submodel {decodedSubmodelIdentifier} from the AAS {decodedAasIdentifier}"); + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } + _aasService.ReplaceSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier, body); - /// - /// Updates the Submodel - /// - /// Submodel object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Submodel updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPut] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}")] - [ValidateModelState] - [SwaggerOperation("PutSubmodelByIdAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PutSubmodelByIdAasRepository([FromBody] Submodel? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + return NoContent(); } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + /// + /// Updates an existing submodel element at a specified path within submodel elements hierarchy + /// + /// Requested submodel element + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Submodel element updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("PutSubmodelElementByPathAasRepository")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PutSubmodelElementByPathAasRepository([FromBody]ISubmodelElement body, [FromRoute][Required]string aasIdentifier, + [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - _logger.LogInformation($"Received request to replace a a submodel {decodedSubmodelIdentifier} from the AAS {decodedAasIdentifier}"); - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); - } + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - _aasService.ReplaceSubmodelById(decodedAasIdentifier, decodedSubmodelIdentifier, body); + _logger.LogInformation($"Received request to replace a submodel element at {idShortPath} dom the submodel with id {decodedSubmodelIdentifier} from the AAS {decodedAasIdentifier}"); + if (body == null) + { + return BadRequest($"Could not proceed, as {nameof(body)} is null."); + } - return NoContent(); - } + _aasService.ReplaceSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, body); - /// - /// Updates an existing submodel element at a specified path within submodel elements hierarchy - /// - /// Requested submodel element - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Submodel element updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPut] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] - [ValidateModelState] - [SwaggerOperation("PutSubmodelElementByPathAasRepository")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PutSubmodelElementByPathAasRepository([FromBody] ISubmodelElement? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + return NoContent(); } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + /// + /// Uploads file content to an existing submodel element at a specified path within submodel elements hierarchy + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// File to upload + /// Submodel element updated successfully + /// Bad Request + /// Not Found + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] + [ValidateModelState] + [SwaggerOperation("PutFileByPath")] + [SwaggerResponse(statusCode: 204, type: typeof(Result), description: "Submodel element updated successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PutFileByPath([FromRoute][Required] string aasIdentifier, [FromRoute][Required] string submodelIdentifier, [FromRoute] string? idShortPath, + IFormFile? file) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - _logger.LogInformation($"Received request to replace a submodel element at {idShortPath} dom the submodel with id {decodedSubmodelIdentifier} from the AAS {decodedAasIdentifier}"); - if (body == null) - { - return BadRequest($"Could not proceed, as {nameof(body)} is null."); - } + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } - _aasService.ReplaceSubmodelElementByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, body); + var stream = new MemoryStream(); + if (file == null) + { + return NoContent(); + } - return NoContent(); - } + file.CopyTo(stream); + var fileName = file.FileName; + var contentType = file.ContentType; - /// - /// Uploads file content to an existing submodel element at a specified path within submodel elements hierarchy - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// File to upload - /// Submodel element updated successfully - /// Bad Request - /// Not Found - /// Default error handling for unmentioned status codes - [HttpPut] - [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] - [ValidateModelState] - [SwaggerOperation("PutFileByPath")] - [SwaggerResponse(statusCode: 204, type: typeof(Result), description: "Submodel element updated successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PutFileByPath([FromRoute] [Required] string aasIdentifier, [FromRoute] [Required] string submodelIdentifier, [FromRoute] string? idShortPath, - IFormFile? file) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + if (idShortPath == null) + { + return BadRequest($"Could not proceed, as {nameof(idShortPath)} is null."); + } - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } + _aasService.ReplaceFileByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, fileName, contentType, stream); - var stream = new MemoryStream(); - if (file == null) - { return NoContent(); } - file.CopyTo(stream); - var fileName = file.FileName; - var contentType = file.ContentType; - - if (idShortPath == null) - { - return BadRequest($"Could not proceed, as {nameof(idShortPath)} is null."); - } + /// + /// Replaces the thumbnail file + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// Thumbnail to upload + /// Thumbnail updated successfully + /// Bad Request + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("shells/{aasIdentifier}/asset-information/thumbnail")] + [ValidateModelState] + [SwaggerOperation("PutThumbnail")] + [SwaggerResponse(statusCode: 204, type: typeof(Result), description: "Thumbnail updated successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PutThumbnail([FromRoute][Required] string aasIdentifier, IFormFile? file) + { + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } - _aasService.ReplaceFileByPath(decodedAasIdentifier, decodedSubmodelIdentifier, idShortPath, fileName, contentType, stream); + var stream = new MemoryStream(); + if (file == null) + { + return NoContent(); + } - return NoContent(); - } + file.CopyTo(stream); + var fileName = file.FileName; + var contentType = file.ContentType; - /// - /// Replaces the thumbnail file - /// - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// Thumbnail to upload - /// Thumbnail updated successfully - /// Bad Request - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPut] - [Route("/shells/{aasIdentifier}/asset-information/thumbnail")] - [ValidateModelState] - [SwaggerOperation("PutThumbnail")] - [SwaggerResponse(statusCode: 204, type: typeof(Result), description: "Thumbnail updated successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PutThumbnail([FromRoute] [Required] string aasIdentifier, IFormFile? file) - { - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } + _aasService.UpdateThumbnail(decodedAasIdentifier, fileName, contentType, stream); - var stream = new MemoryStream(); - if (file == null) - { return NoContent(); } - file.CopyTo(stream); - var fileName = file.FileName; - var contentType = file.ContentType; - - _aasService.UpdateThumbnail(decodedAasIdentifier, fileName, contentType, stream); - - return NoContent(); } -} \ No newline at end of file +} diff --git a/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs index a436a754b..7bc6792d4 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs @@ -14,9 +14,9 @@ /* * DotAAS Part 2 | HTTP/REST | Concept Description Repository Service Specification * - * The ConceptDescription Repository Service Specification as part of Details of the Asset Administration Shell Part 2. Publisher: Industrial Digital Twin Association (IDTA) March 2023 + * The ConceptDescription Repository Service Specification as part of [Specification of the Asset Administration Shell: Part 2](http://industrialdigitaltwin.org/en/content-hub). Publisher: Industrial Digital Twin Association (IDTA) March 2023 * - * OpenAPI spec version: V3.0_SSP-001 + * OpenAPI spec version: V3.0.3_SSP-001 * Contact: info@idtwin.org * Generated by: https://github.com/swagger-api/swagger-codegen.git */ @@ -36,212 +36,210 @@ using System.ComponentModel.DataAnnotations; using System.Linq; -namespace IO.Swagger.Controllers; +using Microsoft.AspNetCore.Authorization; +using IO.Swagger.Models; -/// -/// -/// -[Authorize(AuthenticationSchemes = "AasSecurityAuth")] -[ApiController] -public class ConceptDescriptionRepositoryAPIApiController : ControllerBase +namespace IO.Swagger.Controllers { - private readonly IAppLogger _logger; - private readonly IBase64UrlDecoderService _decoderService; - private readonly IConceptDescriptionService _cdService; - private readonly IJsonQueryDeserializer _jsonQueryDeserializer; - private readonly IPaginationService _paginationService; - private readonly IAuthorizationService _authorizationService; - - public ConceptDescriptionRepositoryAPIApiController(IAppLogger logger, IBase64UrlDecoderService decoderService, - IConceptDescriptionService cdService, IJsonQueryDeserializer jsonQueryDeserializer, - IPaginationService paginationService, IAuthorizationService authorizationService) - { - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _decoderService = decoderService ?? throw new ArgumentNullException(nameof(decoderService)); - _cdService = cdService ?? throw new ArgumentNullException(nameof(cdService)); - _jsonQueryDeserializer = jsonQueryDeserializer ?? throw new ArgumentNullException(nameof(jsonQueryDeserializer)); - _paginationService = paginationService ?? throw new ArgumentNullException(nameof(paginationService)); - _authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService)); - } - /// - /// Deletes a Concept Description + /// /// - /// The Concept Description’s unique id (UTF8-BASE64-URL-encoded) - /// Concept Description deleted successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpDelete] - [Route("/concept-descriptions/{cdIdentifier}")] - [ValidateModelState] - [SwaggerOperation("DeleteConceptDescriptionById")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult DeleteConceptDescriptionById([FromRoute] [Required] string cdIdentifier) + [Authorize(AuthenticationSchemes = "AasSecurityAuth")] + [ApiController] + public class ConceptDescriptionRepositoryAPIApiController : ControllerBase { - var decodedCdIdentifier = _decoderService.Decode("cdIdentifier", cdIdentifier); - if (decodedCdIdentifier == null) + private readonly IAppLogger _logger; + private readonly IBase64UrlDecoderService _decoderService; + private readonly IConceptDescriptionService _cdService; + private readonly IJsonQueryDeserializer _jsonQueryDeserializer; + private readonly IPaginationService _paginationService; + private readonly IAuthorizationService _authorizationService; + + public ConceptDescriptionRepositoryAPIApiController(IAppLogger logger, IBase64UrlDecoderService decoderService, + IConceptDescriptionService cdService, IJsonQueryDeserializer jsonQueryDeserializer, + IPaginationService paginationService, IAuthorizationService authorizationService) { - throw new NotAllowed($"Cannot proceed as {nameof(decodedCdIdentifier)} is null"); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + _decoderService = decoderService ?? throw new ArgumentNullException(nameof(decoderService)); + _cdService = cdService ?? throw new ArgumentNullException(nameof(cdService)); + _jsonQueryDeserializer = jsonQueryDeserializer ?? throw new ArgumentNullException(nameof(jsonQueryDeserializer)); + _paginationService = paginationService ?? throw new ArgumentNullException(nameof(paginationService)); + _authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService)); } - _logger.LogInformation($"Received request to delete concept description with id {decodedCdIdentifier}"); - - _cdService.DeleteConceptDescriptionById(decodedCdIdentifier); + /// + /// Deletes a Concept Description + /// + /// The Concept Description’s unique id (UTF8-BASE64-URL-encoded) + /// Concept Description deleted successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("concept-descriptions/{cdIdentifier}")] + [ValidateModelState] + [SwaggerOperation("DeleteConceptDescriptionById")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult DeleteConceptDescriptionById([FromRoute][Required] string cdIdentifier) + { + var decodedCdIdentifier = _decoderService.Decode("cdIdentifier", cdIdentifier); + if (decodedCdIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedCdIdentifier)} is null"); + } + _logger.LogInformation($"Received request to delete concept description with id {decodedCdIdentifier}"); - return NoContent(); - } + _cdService.DeleteConceptDescriptionById(decodedCdIdentifier); - /// - /// Returns all Concept Descriptions - /// - /// The Concept Description’s IdShort - /// IsCaseOf reference (UTF8-BASE64-URL-encoded) - /// DataSpecification reference (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Requested Concept Descriptions - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Forbidden - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/concept-descriptions")] - [ValidateModelState] - [SwaggerOperation("GetAllConceptDescriptions")] - [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested Concept Descriptions")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllConceptDescriptions([FromQuery] string? idShort, [FromQuery] string? isCaseOf, [FromQuery] string? dataSpecificationRef, - [FromQuery] int? limit, [FromQuery] string? cursor) - { - _logger.LogInformation($"Received request to get all the concept descriptions."); - var reqIsCaseOf = _jsonQueryDeserializer.DeserializeReference("isCaseOf", isCaseOf); - var reqDataSpecificationRef = _jsonQueryDeserializer.DeserializeReference("dataSpecificationRef", dataSpecificationRef); + return NoContent(); + } - var cdList = new List(); - if (reqDataSpecificationRef != null) + /// + /// Returns all Concept Descriptions + /// + /// The Concept Description’s IdShort + /// IsCaseOf reference (UTF8-BASE64-URL-encoded) + /// DataSpecification reference (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Requested Concept Descriptions + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("concept-descriptions")] + [ValidateModelState] + [SwaggerOperation("GetAllConceptDescriptions")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested Concept Descriptions")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllConceptDescriptions([FromQuery] string? idShort, [FromQuery] string? isCaseOf, [FromQuery] string? dataSpecificationRef, [FromQuery] int? limit, [FromQuery] string? cursor) { + _logger.LogInformation($"Received request to get all the concept descriptions."); + var reqIsCaseOf = _jsonQueryDeserializer.DeserializeReference("isCaseOf", isCaseOf); + var reqDataSpecificationRef = _jsonQueryDeserializer.DeserializeReference("dataSpecificationRef", dataSpecificationRef); + + var cdList = new List(); cdList = _cdService.GetAllConceptDescriptions(idShort, reqIsCaseOf, reqDataSpecificationRef); - } - var authResult = _authorizationService.AuthorizeAsync(User, cdList, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason != null) + var authResult = _authorizationService.AuthorizeAsync(User, cdList, "SecurityPolicy").Result; + if (!authResult.Succeeded) { - throw new NotAllowed(failedReason.Message); + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason != null) + { + throw new NotAllowed(failedReason.Message); + } } - } - var output = _paginationService.GetPaginatedList(cdList, new PaginationParameters(cursor, limit)); - return new ObjectResult(output); - } + var output = _paginationService.GetPaginatedList(cdList, new PaginationParameters(cursor, limit)); + return new ObjectResult(output); + } - /// - /// Returns a specific Concept Description - /// - /// The Concept Description’s unique id (UTF8-BASE64-URL-encoded) - /// Requested Concept Description - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/concept-descriptions/{cdIdentifier}")] - [ValidateModelState] - [SwaggerOperation("GetConceptDescriptionById")] - [SwaggerResponse(statusCode: 200, type: typeof(ConceptDescription), description: "Requested Concept Description")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetConceptDescriptionById([FromRoute] [Required] string cdIdentifier) - { - var decodedCdIdentifier = _decoderService.Decode("cdIdentifier", cdIdentifier); + /// + /// Returns a specific Concept Description + /// + /// The Concept Description’s unique id (UTF8-BASE64-URL-encoded) + /// Requested Concept Description + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("concept-descriptions/{cdIdentifier}")] + [ValidateModelState] + [SwaggerOperation("GetConceptDescriptionById")] + [SwaggerResponse(statusCode: 200, type: typeof(ConceptDescription), description: "Requested Concept Description")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetConceptDescriptionById([FromRoute][Required] string cdIdentifier) + { + var decodedCdIdentifier = _decoderService.Decode("cdIdentifier", cdIdentifier); - _logger.LogInformation($"Received request to get concept description with id {decodedCdIdentifier}"); + _logger.LogInformation($"Received request to get concept description with id {decodedCdIdentifier}"); - var output = _cdService.GetConceptDescriptionById(decodedCdIdentifier); + var output = _cdService.GetConceptDescriptionById(decodedCdIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, output, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason != null) + var authResult = _authorizationService.AuthorizeAsync(User, output, "SecurityPolicy").Result; + if (!authResult.Succeeded) { - throw new NotAllowed(failedReason.Message); + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason != null) + { + throw new NotAllowed(failedReason.Message); + } } - } - return new ObjectResult(output); - } + return new ObjectResult(output); + } - /// - /// Creates a new Concept Description - /// - /// Concept Description object - /// Concept Description created successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Forbidden - /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/concept-descriptions")] - [ValidateModelState] - [SwaggerOperation("PostConceptDescription")] - [SwaggerResponse(statusCode: 201, type: typeof(ConceptDescription), description: "Concept Description created successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 409, type: typeof(Result), - description: - "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PostConceptDescription([FromBody] ConceptDescription? body) - { - var output = _cdService.CreateConceptDescription(body); + /// + /// Creates a new Concept Description + /// + /// Concept Description object + /// Concept Description created successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Forbidden + /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("concept-descriptions")] + [ValidateModelState] + [SwaggerOperation("PostConceptDescription")] + [SwaggerResponse(statusCode: 201, type: typeof(ConceptDescription), description: "Concept Description created successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 409, type: typeof(Result), description: "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PostConceptDescription([FromBody] ConceptDescription? body) + { + //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + var output = _cdService.CreateConceptDescription(body); - return CreatedAtAction(nameof(PostConceptDescription), output); - } + return CreatedAtAction(nameof(PostConceptDescription), output); + } - /// - /// Updates an existing Concept Description - /// - /// Concept Description object - /// The Concept Description’s unique id (UTF8-BASE64-URL-encoded) - /// Concept Description updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPut] - [Route("/concept-descriptions/{cdIdentifier}")] - [ValidateModelState] - [SwaggerOperation("PutConceptDescriptionById")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PutConceptDescriptionById([FromBody] ConceptDescription? body, [FromRoute] [Required] string cdIdentifier) - { - var decodedCdId = _decoderService.Decode("cdIdentifier", cdIdentifier); + /// + /// Updates an existing Concept Description + /// + /// Concept Description object + /// The Concept Description’s unique id (UTF8-BASE64-URL-encoded) + /// Concept Description updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("concept-descriptions/{cdIdentifier}")] + [ValidateModelState] + [SwaggerOperation("PutConceptDescriptionById")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PutConceptDescriptionById([FromBody] ConceptDescription? body, [FromRoute][Required] string cdIdentifier) + { + var decodedCdId = _decoderService.Decode("cdIdentifier", cdIdentifier); - _cdService.UpdateConceptDescriptionById(body, decodedCdId); + _cdService.UpdateConceptDescriptionById(body, decodedCdId); - return NoContent(); + return NoContent(); + } } -} \ No newline at end of file +} diff --git a/src/IO.Swagger.Lib.V3/Controllers/DescriptionAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/DescriptionAPIApi.cs index 6439d3bb8..79a5eab65 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/DescriptionAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/DescriptionAPIApi.cs @@ -12,11 +12,11 @@ ********************************************************************************/ /* - * DotAAS Part 2 | HTTP/REST | Asset Administration Shell Repository Service Specification + * DotAAS Part 2 | HTTP/REST | Submodel Repository Service Specification * - * The Full Profile of the Asset Administration Shell Repository Service Specification as part of Specification of the Asset Administration Shell: Part 2. Publisher: Industrial Digital Twin Association (IDTA) April 2023 + * The entire Submodel Repository Service Specification as part of the [Specification of the Asset Administration Shell: Part 2](http://industrialdigitaltwin.org/en/content-hub). Publisher: Industrial Digital Twin Association (IDTA) 2023 * - * OpenAPI spec version: V3.0_SSP-001 + * OpenAPI spec version: V3.0.3_SSP-001 * Contact: info@idtwin.org * Generated by: https://github.com/swagger-api/swagger-codegen.git */ @@ -28,35 +28,34 @@ using System.Collections.Generic; using static IO.Swagger.Models.ServiceDescription; -namespace IO.Swagger.Controllers; - -/// -/// -/// -[ApiController] -public class DescriptionAPIApiController : ControllerBase +namespace IO.Swagger.Controllers { - private readonly IServiceDescription _serviceDescription; - - public DescriptionAPIApiController(IServiceDescription serviceDescription) => _serviceDescription = serviceDescription; - /// - /// Returns the self-describing information of a network resource (ServiceDescription) + /// /// - /// Requested Description - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - [HttpGet] - [Route("/description")] - [ValidateModelState] - [SwaggerOperation("GetDescription")] - [SwaggerResponse(statusCode: 200, type: typeof(ServiceDescription), description: "Requested Description")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - public virtual IActionResult GetDescription() + [ApiController] + public class DescriptionAPIApiController : ControllerBase { - var output = new ServiceDescription(); - _serviceDescription.Profiles = new List + private readonly IServiceDescription _serviceDescription; + + public DescriptionAPIApiController(IServiceDescription serviceDescription) => _serviceDescription = serviceDescription; + /// + /// Returns the self-describing information of a network resource (ServiceDescription) + /// + /// Requested Description + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + [HttpGet] + [Route("description")] + [ValidateModelState] + [SwaggerOperation("GetDescription")] + [SwaggerResponse(statusCode: 200, type: typeof(ServiceDescription), description: "Requested Description")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + public virtual IActionResult GetDescription() + { + var output = new ServiceDescription(); + _serviceDescription.profiles = new List { ServiceProfiles.AasxFileServerServiceSpecificationSSP001, ServiceProfiles.SubmodelRepositoryServiceSpecificationSSP001, @@ -67,7 +66,8 @@ public virtual IActionResult GetDescription() ServiceProfiles.DiscoveryServiceSpecificationSSP001, ServiceProfiles.ConceptDescriptionServiceSpecificationSSP001 }; - //return new ObjectResult(_serviceDescription.ToJson()); - return new ObjectResult(_serviceDescription.ToJson()); + //return new ObjectResult(_serviceDescription.ToJson()); + return new ObjectResult(_serviceDescription.ToJson()); + } } } \ No newline at end of file diff --git a/src/IO.Swagger.Lib.V3/Controllers/SerializationAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/SerializationAPIApi.cs index bb49a5d31..d95477a71 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/SerializationAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/SerializationAPIApi.cs @@ -12,11 +12,11 @@ ********************************************************************************/ /* - * DotAAS Part 2 | HTTP/REST | Asset Administration Shell Repository Service Specification + * DotAAS Part 2 | HTTP/REST | Submodel Repository Service Specification * - * The Full Profile of the Asset Administration Shell Repository Service Specification as part of Specification of the Asset Administration Shell: Part 2. Publisher: Industrial Digital Twin Association (IDTA) April 2023 + * The entire Submodel Repository Service Specification as part of the [Specification of the Asset Administration Shell: Part 2](http://industrialdigitaltwin.org/en/content-hub). Publisher: Industrial Digital Twin Association (IDTA) 2023 * - * OpenAPI spec version: V3.0_SSP-001 + * OpenAPI spec version: V3.0.3_SSP-001 * Contact: info@idtwin.org * Generated by: https://github.com/swagger-api/swagger-codegen.git */ @@ -31,81 +31,72 @@ using System.Collections.Generic; using System.Xml; -namespace IO.Swagger.Controllers; - -using System.Linq; -using AasSecurity.Exceptions; - -/// -/// -/// -[ApiController] -public class SerializationAPIApiController : ControllerBase +namespace IO.Swagger.Controllers { - private readonly IAppLogger _logger; - private readonly IBase64UrlDecoderService _decoderService; - private readonly IGenerateSerializationService _serializationService; - - public SerializationAPIApiController(IAppLogger logger, IBase64UrlDecoderService decoderService, - IGenerateSerializationService serializationService) - { - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _decoderService = decoderService ?? throw new ArgumentNullException(nameof(decoderService)); - _serializationService = serializationService ?? throw new ArgumentNullException(nameof(serializationService)); - } - + using System.Linq; + using AasSecurity.Exceptions; /// - /// Returns an appropriate serialization based on the specified format (see SerializationFormat) + /// /// - /// The Asset Administration Shells' unique ids (UTF8-BASE64-URL-encoded) - /// The Submodels' unique ids (UTF8-BASE64-URL-encoded) - /// Include Concept Descriptions? - /// Requested serialization based on SerializationFormat - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/serialization")] - [ValidateModelState] - [SwaggerOperation("GenerateSerializationByIds")] - [SwaggerResponse(statusCode: 200, type: typeof(byte[]), description: "Requested serialization based on SerializationFormat")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GenerateSerializationByIds([FromQuery] List? aasIds, [FromQuery] List? submodelIds, - [FromQuery] bool includeConceptDescriptions = false) + [ApiController] + public class SerializationAPIApiController : ControllerBase { - if (aasIds == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(aasIds)} is null"); - } + private readonly IAppLogger _logger; + private readonly IBase64UrlDecoderService _decoderService; + private readonly IGenerateSerializationService _serializationService; - if (submodelIds == null) + public SerializationAPIApiController(IAppLogger logger, IBase64UrlDecoderService decoderService, + IGenerateSerializationService serializationService) { - throw new NotAllowed($"Cannot proceed as {nameof(submodelIds)} is null"); + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + _decoderService = decoderService ?? throw new ArgumentNullException(nameof(decoderService)); + _serializationService = serializationService ?? throw new ArgumentNullException(nameof(serializationService)); } + /// + /// Returns an appropriate serialization based on the specified format (see SerializationFormat) + /// + /// The Asset Administration Shells' unique ids (UTF8-BASE64-URL-encoded) + /// The Submodels' unique ids (UTF8-BASE64-URL-encoded) + /// Include Concept Descriptions? + /// Requested serialization based on SerializationFormat + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("serialization")] + [ValidateModelState] + [SwaggerOperation("GenerateSerializationByIds")] + [SwaggerResponse(statusCode: 200, type: typeof(byte[]), description: "Requested serialization based on SerializationFormat")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GenerateSerializationByIds([FromQuery] List? aasIds, [FromQuery] List? submodelIds, + [FromQuery] bool? includeConceptDescriptions = false) + { + _logger.LogDebug($"Received a request an appropriate serialization"); - var decodedAasIds = aasIds.Select(aasId => _decoderService.Decode("aasIdentifier", aasId)).ToList(); + var decodedAasIds = aasIds.Select(aasId => _decoderService.Decode("aasIdentifier", aasId)).ToList(); - var decodedSubmodelIds = submodelIds.Select(submodelId => _decoderService.Decode("submodelIdentifier", submodelId)).ToList(); + var decodedSubmodelIds = submodelIds.Select(submodelId => _decoderService.Decode("submodelIdentifier", submodelId)).ToList(); - var environment = _serializationService.GenerateSerializationByIds(decodedAasIds, decodedSubmodelIds); + var environment = _serializationService.GenerateSerializationByIds(decodedAasIds, decodedSubmodelIds, includeConceptDescriptions); - HttpContext.Request.Headers.TryGetValue("Content-Type", out var contentType); - if (!contentType.Equals("application/xml")) - { - return new ObjectResult(environment); - } + HttpContext.Request.Headers.TryGetValue("Content-Type", out var contentType); + if (!contentType.Equals("application/xml")) + { + return new ObjectResult(environment); + } - var outputBuilder = new System.Text.StringBuilder(); - var writer = XmlWriter.Create(outputBuilder, new XmlWriterSettings {Indent = true, OmitXmlDeclaration = true}); - Xmlization.Serialize.To(environment, writer); - writer.Flush(); - writer.Close(); - return new ObjectResult(outputBuilder.ToString()); + var outputBuilder = new System.Text.StringBuilder(); + var writer = XmlWriter.Create(outputBuilder, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true }); + Xmlization.Serialize.To(environment, writer); + writer.Flush(); + writer.Close(); + return new ObjectResult(outputBuilder.ToString()); + } } } \ No newline at end of file diff --git a/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs index a3ea331ee..70c6b65b1 100644 --- a/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs +++ b/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs @@ -1,1623 +1,220 @@ -/******************************************************************************** -* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation -* -* See the NOTICE file(s) distributed with this work for additional -* information regarding copyright ownership. -* -* This program and the accompanying materials are made available under the -* terms of the Apache License Version 2.0 which is available at -* https://www.apache.org/licenses/LICENSE-2.0 -* -* SPDX-License-Identifier: Apache-2.0 -********************************************************************************/ - -/* - * DotAAS Part 2 | HTTP/REST | Submodel Repository Service Specification - * - * The entire Submodel Repository Service Specification as part of the [Specification of the Asset Administration Shell: Part 2](http://industrialdigitaltwin.org/en/content-hub). Publisher: Industrial Digital Twin Association (IDTA) 2023 - * - * OpenAPI spec version: V3.0.1_SSP-001 - * Contact: info@idtwin.org - * Generated by: https://github.com/swagger-api/swagger-codegen.git - */ - -using AasSecurity.Exceptions; -using AasxServer; -using AasxServerStandardBib.Interfaces; -using AasxServerStandardBib.Logging; -using AdminShellNS.Lib.V3.Models; -using DataTransferObjects.MetadataDTOs; -using DataTransferObjects.ValueDTOs; -using IO.Swagger.Attributes; -using IO.Swagger.Lib.V3.Interfaces; -using IO.Swagger.Lib.V3.Models; -using IO.Swagger.Lib.V3.SerializationModifiers.Mappers; -using IO.Swagger.Lib.V3.Services; -using IO.Swagger.Models; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Swashbuckle.AspNetCore.Annotations; -using System; -using System.Collections.Generic; -using System.ComponentModel.DataAnnotations; -using System.IO; -using System.Linq; -using System.Net.Mime; -using System.Security.Claims; - -namespace IO.Swagger.Controllers; - -using System.Globalization; -using System.Threading.Tasks; -using AdminShellNS.Exceptions; -using Microsoft.IdentityModel.Tokens; - -/// -/// -/// -[Authorize(AuthenticationSchemes = "AasSecurityAuth")] -[ApiController] -public class SubmodelRepositoryAPIApiController : ControllerBase -{ - private readonly IAppLogger _logger; - private readonly IBase64UrlDecoderService _decoderService; - private readonly ISubmodelService _submodelService; - private readonly IReferenceModifierService _referenceModifierService; - private readonly IJsonQueryDeserializer _jsonQueryDeserializer; - private readonly IMappingService _mappingService; - private readonly IPathModifierService _pathModifierService; - private readonly ILevelExtentModifierService _levelExtentModifierService; - private readonly IPaginationService _paginationService; - private readonly IAuthorizationService _authorizationService; +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +namespace IO.Swagger.Controllers; +/* + * DotAAS Part 2 | HTTP/REST | Submodel Repository Service Specification + * + * The entire Submodel Repository Service Specification as part of the [Specification of the Asset Administration Shell: Part 2](http://industrialdigitaltwin.org/en/content-hub). Publisher: Industrial Digital Twin Association (IDTA) 2023 + * + * OpenAPI spec version: V3.0.3_SSP-001 + * Contact: info@idtwin.org + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ + +using AasSecurity.Exceptions; +using AasxServer; +using AasxServerStandardBib.Interfaces; +using AasxServerStandardBib.Logging; +using AdminShellNS.Lib.V3.Models; +using DataTransferObjects.MetadataDTOs; +using DataTransferObjects.ValueDTOs; +using IO.Swagger.Attributes; +using IO.Swagger.Lib.V3.Interfaces; +using IO.Swagger.Lib.V3.Models; +using IO.Swagger.Lib.V3.SerializationModifiers.Mappers; +using IO.Swagger.Lib.V3.Services; +using IO.Swagger.Models; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Swashbuckle.AspNetCore.Annotations; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.IO; +using System.Linq; +using System.Net.Mime; +using System.Security.Claims; +using System.Threading.Tasks; +using AdminShellNS.Exceptions; +using Microsoft.IdentityModel.Tokens; + +/// +/// +/// +[Authorize(AuthenticationSchemes = "AasSecurityAuth")] +[ApiController] +public class SubmodelRepositoryAPIApiController : ControllerBase +{ + private readonly IAppLogger _logger; + private readonly IBase64UrlDecoderService _decoderService; + private readonly ISubmodelService _submodelService; + private readonly IReferenceModifierService _referenceModifierService; + private readonly IJsonQueryDeserializer _jsonQueryDeserializer; + private readonly IMappingService _mappingService; + private readonly IPathModifierService _pathModifierService; + private readonly ILevelExtentModifierService _levelExtentModifierService; + private readonly IPaginationService _paginationService; + private readonly IAuthorizationService _authorizationService; private readonly IAdminShellPackageEnvironmentService _adminShellPackageEnvironmentService; - - public SubmodelRepositoryAPIApiController(IAppLogger logger, IBase64UrlDecoderService decoderService, ISubmodelService submodelService, - IReferenceModifierService referenceModifierService, IJsonQueryDeserializer jsonQueryDeserializer, IMappingService mappingService, - IPathModifierService pathModifierService, ILevelExtentModifierService levelExtentModifierService, - IPaginationService paginationService, IAuthorizationService authorizationService, - IAdminShellPackageEnvironmentService adminShellPackageEnvironmentService) - { - _logger = logger ?? throw new ArgumentNullException(nameof(logger)); - _decoderService = decoderService ?? throw new ArgumentNullException(nameof(decoderService)); - _submodelService = submodelService ?? throw new ArgumentNullException(nameof(submodelService)); - _referenceModifierService = referenceModifierService ?? throw new ArgumentNullException(nameof(referenceModifierService)); - _jsonQueryDeserializer = jsonQueryDeserializer ?? throw new ArgumentNullException(nameof(jsonQueryDeserializer)); - _mappingService = mappingService ?? throw new ArgumentNullException(nameof(mappingService)); - _pathModifierService = pathModifierService ?? throw new ArgumentNullException(nameof(pathModifierService)); - _levelExtentModifierService = levelExtentModifierService ?? throw new ArgumentNullException(nameof(levelExtentModifierService)); - _paginationService = paginationService ?? throw new ArgumentNullException(nameof(paginationService)); - _authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService)); + private readonly IValidateSerializationModifierService _validateModifierService; + + public SubmodelRepositoryAPIApiController(IAppLogger logger, IBase64UrlDecoderService decoderService, ISubmodelService submodelService, + IReferenceModifierService referenceModifierService, IJsonQueryDeserializer jsonQueryDeserializer, IMappingService mappingService, + IPathModifierService pathModifierService, ILevelExtentModifierService levelExtentModifierService, + IPaginationService paginationService, IAuthorizationService authorizationService, + IAdminShellPackageEnvironmentService adminShellPackageEnvironmentService, IValidateSerializationModifierService validateModifierService) + { + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + _decoderService = decoderService ?? throw new ArgumentNullException(nameof(decoderService)); + _submodelService = submodelService ?? throw new ArgumentNullException(nameof(submodelService)); + _referenceModifierService = referenceModifierService ?? throw new ArgumentNullException(nameof(referenceModifierService)); + _jsonQueryDeserializer = jsonQueryDeserializer ?? throw new ArgumentNullException(nameof(jsonQueryDeserializer)); + _mappingService = mappingService ?? throw new ArgumentNullException(nameof(mappingService)); + _pathModifierService = pathModifierService ?? throw new ArgumentNullException(nameof(pathModifierService)); + _levelExtentModifierService = levelExtentModifierService ?? throw new ArgumentNullException(nameof(levelExtentModifierService)); + _paginationService = paginationService ?? throw new ArgumentNullException(nameof(paginationService)); + _authorizationService = authorizationService ?? throw new ArgumentNullException(nameof(authorizationService)); _adminShellPackageEnvironmentService = adminShellPackageEnvironmentService ?? throw new ArgumentNullException(nameof(adminShellPackageEnvironmentService)); - } - - /// - /// Deletes file content of an existing submodel element at a specified path within submodel elements hierarchy - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Submodel element updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpDelete] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] - [ValidateModelState] - [SwaggerOperation("DeleteFileByPathSubmodelRepo")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult DeleteFileByPathSubmodelRepo([FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); - } - - _logger.LogInformation($"Received a request to delete a file at {idShortPath} from the submodel {decodedSubmodelIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - _submodelService.DeleteFileByPath(decodedSubmodelIdentifier, idShortPath); - - return NoContent(); - } - - /// - /// Deletes a Submodel - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Submodel deleted successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpDelete] - [Route("/submodels/{submodelIdentifier}")] - [ValidateModelState] - [SwaggerOperation("DeleteSubmodelById")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult DeleteSubmodelById([FromRoute] [Required] string submodelIdentifier) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); - } - - _logger.LogInformation($"Received a request to delete a submodel with id {decodedSubmodelIdentifier}"); - _submodelService.DeleteSubmodelById(decodedSubmodelIdentifier); - - return NoContent(); - } - - /// - /// Deletes a submodel element at a specified path within the submodel elements hierarchy - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Submodel element deleted successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpDelete] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] - [ValidateModelState] - [SwaggerOperation("DeleteSubmodelElementByPathSubmodelRepo")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult DeleteSubmodelElementByPathSubmodelRepo([FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); - } - - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - _logger.LogInformation($"Received a request to delete a submodel element at {idShortPath} from submodel with id {decodedSubmodelIdentifier}"); - - _submodelService.DeleteSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); - - return NoContent(); - } - - /// - /// Returns all submodel elements including their hierarchy - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Filters response, only elements changed after DateTime - /// List of found submodel elements - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelElements")] - [SwaggerResponse(statusCode: 200, type: typeof(GetSubmodelElementsResult), description: "List of found submodel elements")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelElements([FromRoute] [Required] string submodelIdentifier, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent, - [FromQuery] string? diff) + _validateModifierService = validateModifierService ?? throw new ArgumentNullException(nameof(authorizationService)); + } + + /// + /// Deletes file content of an existing submodel element at a specified path within submodel elements hierarchy + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Submodel element updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] + [ValidateModelState] + [SwaggerOperation("DeleteFileByPathSubmodelRepo")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult DeleteFileByPathSubmodelRepo([FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath) + { + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); + } + + _logger.LogInformation($"Received a request to delete a file at {idShortPath} from the submodel {decodedSubmodelIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) {new("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + _submodelService.DeleteFileByPath(decodedSubmodelIdentifier, idShortPath); + + return NoContent(); + } + + /// + /// Deletes a Submodel + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Submodel deleted successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("DeleteSubmodelById")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult DeleteSubmodelById([FromRoute][Required] string submodelIdentifier) { var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); if (decodedSubmodelIdentifier == null) { throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); - } - - _logger.LogInformation($"Received a request to get all the submodel elements from submodel with id {decodedSubmodelIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var submodelElements = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); - - var filtered = new List(); - if (!diff.IsNullOrEmpty()) - { - try - { - var _diff = TimeStamp.TimeStamp.StringToDateTime(diff); - filtered = filterSubmodelElements(submodelElements, _diff); - } - catch - { - // ignored - } - } - else - filtered = submodelElements; - - var smePaginatedList = _paginationService.GetPaginatedList(filtered, new PaginationParameters(cursor, limit)); - var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginatedList.result, level, extent); - var output = new PagedResult {result = smeLevelList, paging_metadata = smePaginatedList.paging_metadata}; - return new ObjectResult(output); - } - - List filterSubmodelElements(List submodelElements, DateTime diff) - { - var output = new List(); - - foreach (var sme in submodelElements.Where(sme => sme != null && sme.TimeStampTree >= diff)) - { - List smeDiff; - switch (sme) - { - case SubmodelElementCollection smc: - { - smeDiff = filterSubmodelElements(smc.Value ?? [], diff); - if (smeDiff.Count != 0) - { - var smcDiff = new SubmodelElementCollection( - extensions: smc.Extensions, - category: smc.Category, - idShort: smc.IdShort, - displayName: smc.DisplayName, - description: smc.Description, - semanticId: smc.SemanticId, - supplementalSemanticIds: smc.SupplementalSemanticIds, - qualifiers: smc.Qualifiers, - embeddedDataSpecifications: smc.EmbeddedDataSpecifications, - value: smeDiff) {Parent = smc.Parent}; - output.Add(smcDiff); - } - else if (smc.TimeStamp >= diff) - { - output.Add(smc); - } - - break; - } - case SubmodelElementList sml: - { - smeDiff = filterSubmodelElements(sml.Value ?? [], diff); - if (smeDiff.Count != 0) - { - var smlDiff = new SubmodelElementList( - typeValueListElement: sml.TypeValueListElement, - extensions: sml.Extensions, - category: sml.Category, - idShort: sml.IdShort, - displayName: sml.DisplayName, - description: sml.Description, - semanticId: sml.SemanticId, - supplementalSemanticIds: sml.SupplementalSemanticIds, - qualifiers: sml.Qualifiers, - embeddedDataSpecifications: sml.EmbeddedDataSpecifications, - value: smeDiff) {Parent = sml.Parent}; - output.Add(smlDiff); - } - else if (sml.TimeStamp >= diff) - { - output.Add(sml); - } - - break; - } - default: - output.Add(sme); - break; - } - } - - return output; - } - - /// - /// Returns the metadata attributes of all submodel elements including their hierarchy - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// Filters response, only elements changed after DateTime - /// List of found submodel elements - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/$metadata")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelElementsMetadataSubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(MetadataPagedResult), description: "List of found submodel elements")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelElementsMetadataSubmodelRepo([FromRoute] [Required] string submodelIdentifier, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level, - [FromQuery] string? diff) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to get the metadata of all the submodel elements from the submodel with id {decodedSubmodelIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var smeList = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); - - var filtered = new List(); - if (!diff.IsNullOrEmpty()) - { - try - { - var _diff = TimeStamp.TimeStamp.StringToDateTime(diff); - filtered = filterSubmodelElements(smeList, _diff); - } - catch - { - // ignored - } - } - else - filtered = smeList; - - var smePagedList = _paginationService.GetPaginatedList(filtered, new PaginationParameters(cursor, limit)); - var smeListLevel = _levelExtentModifierService.ApplyLevelExtent(smePagedList.result, level); - var smeMetadataList = _mappingService.Map(smeListLevel, "metadata"); - var output = new MetadataPagedResult() {result = smeMetadataList.ConvertAll(sme => (IMetadataDTO)sme), paging_metadata = smePagedList.paging_metadata}; - return new ObjectResult(output); - } - - /// - /// Returns all submodel elements including their hierarchy in the Path notation - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// Filters response, only elements changed after DateTime - /// List of found submodel elements in the Path notation - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/$path")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelElementsPathSubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(List>), description: "List of found submodel elements in the Path notation")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelElementsPathSubmodelRepo([FromRoute] [Required] string submodelIdentifier, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] string? level, - [FromQuery] string? diff) - { - var decodedSubmodelIdentifier = _decoderService.Decode($"submodelIdentifier", submodelIdentifier); - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); - } - - _logger.LogDebug($"Received request to get all the submodel elements from the submodel with id {decodedSubmodelIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var submodelElementList = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); - - var filtered = new List(); - if (!diff.IsNullOrEmpty()) - { - try - { - var _diff = TimeStamp.TimeStamp.StringToDateTime(diff); - filtered = filterSubmodelElements(submodelElementList, _diff); - } - catch - { - // ignored - } - } - else - filtered = submodelElementList; - - // TODO (jtikekar, 2023-09-04): pagination and modifier - // TODO (jtikekar, 2023-09-04): not complete implemented - var output = _pathModifierService.ToIdShortPath(filtered); - return new ObjectResult(output); - } - - /// - /// Returns the References of all submodel elements - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// List of found submodel elements - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/$reference")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelElementsReferenceSubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(GetReferencesResult), description: "List of found submodel elements")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelElementsReferenceSubmodelRepo([FromRoute] [Required] string submodelIdentifier, [FromQuery] int? limit, - [FromQuery] string? cursor, [FromQuery] LevelEnum level) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); - } - - _logger.LogInformation($"Received a request to get all the submodel elements from submodel with id {decodedSubmodelIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var smeList = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); - - var smePagedList = _paginationService.GetPaginatedList(smeList, new PaginationParameters(cursor, limit)); - var smeReferences = _referenceModifierService.GetReferenceResult(smePagedList.result.ConvertAll(sme => (IReferable)sme)); - var output = new ReferencePagedResult(smeReferences, smePagedList.paging_metadata); - return new ObjectResult(output); - } - - /// - /// Returns all submodel elements including their hierarchy in the ValueOnly representation - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Filters response, only elements changed after DateTime - /// List of found submodel elements - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/$value")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelElementsValueOnlySubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(ValueOnlyPagedResult), description: "List of found submodel elements")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelElementsValueOnlySubmodelRepo([FromRoute] [Required] string submodelIdentifier, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent, [FromQuery] string? diff) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); - } - - _logger.LogInformation($"Received request to get value of all the submodel elements from the submodel with id {decodedSubmodelIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var submodelElements = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); - - var filtered = new List(); - if (!diff.IsNullOrEmpty()) - { - try - { - var _diff = TimeStamp.TimeStamp.StringToDateTime(diff); - filtered = filterSubmodelElements(submodelElements, _diff); - } - catch - { - // ignored - } - } - else - filtered = submodelElements; - - var smePagedList = _paginationService.GetPaginatedList(filtered, new PaginationParameters(cursor, limit)); - var smeLevelExtent = _levelExtentModifierService.ApplyLevelExtent(smePagedList.result ?? [], level, extent); - var smeValues = _mappingService.Map(smeLevelExtent, "value"); - var output = new ValueOnlyPagedResult() {result = smeValues.ConvertAll(sme => (IValueDTO)sme), paging_metadata = smePagedList.paging_metadata}; - return new ObjectResult(output); - } - - /// - /// Returns all Submodels - /// - /// The value of the semantic id reference (BASE64-URL-encoded) - /// The Asset Administration Shell’s IdShort - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Requested Submodels - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodels")] - [SwaggerResponse(statusCode: 200, type: typeof(PagedResult), description: "Requested Submodels")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodels([FromQuery] [StringLength(3072, MinimumLength = 1)] string? semanticId, [FromQuery] string? idShort, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent) - { - _logger.LogInformation($"Received a request to get all the submodels."); - - var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); - - var submodelList = new List(); - - if (reqSemanticId != null) - { - submodelList.AddRange(_adminShellPackageEnvironmentService.GetSubmodelsBySemanticId(reqSemanticId)); - } - - if (idShort != null) - { - submodelList.AddRange(_adminShellPackageEnvironmentService.GetSubmodelsByIdShort(idShort)); - } - - var submodelsPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); - var smLevelList = _levelExtentModifierService.ApplyLevelExtent(submodelsPagedList.result, level, extent); - var output = new PagedResult {result = smLevelList, paging_metadata = submodelsPagedList.paging_metadata}; - return new ObjectResult(output); - } - - /// - /// Returns the metadata attributes of all Submodels - /// - /// The value of the semantic id reference (BASE64-URL-encoded) - /// The Asset Administration Shell’s IdShort - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// Requested Submodels - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/$metadata")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelsMetadata")] - [SwaggerResponse(statusCode: 200, type: typeof(MetadataPagedResult), description: "Requested Submodels")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelsMetadata([FromQuery] [StringLength(3072, MinimumLength = 1)] string? semanticId, [FromQuery] string? idShort, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level) - { - _logger.LogInformation($"Received request to get the metadata of all the submodels."); - - var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); - - var submodelList = new List(); - - if (reqSemanticId != null) - { - submodelList.AddRange(_adminShellPackageEnvironmentService.GetSubmodelsBySemanticId(reqSemanticId)); - } - - if (idShort != null) - { - submodelList.AddRange(_adminShellPackageEnvironmentService.GetSubmodelsByIdShort(idShort)); - } - - var submodelPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); - var submodelLevelList = _levelExtentModifierService.ApplyLevelExtent(submodelPagedList.result ?? [], level); - var smMetadataList = _mappingService.Map(submodelLevelList, "metadata"); - var output = new MetadataPagedResult() {result = smMetadataList.ConvertAll(sme => (IMetadataDTO)sme), paging_metadata = submodelPagedList.paging_metadata}; - return new ObjectResult(output); - } - - /// - /// Returns all Submodels in the Path notation - /// - /// The value of the semantic id reference (BASE64-URL-encoded) - /// The Asset Administration Shell’s IdShort - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// Requested Submodels - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/$path")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelsPath")] - [SwaggerResponse(statusCode: 200, type: typeof(GetPathItemsResult), description: "Requested Submodels")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelsPath([FromQuery] [StringLength(3072, MinimumLength = 1)] string semanticId, [FromQuery] string? idShort, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level) - { - _logger.LogInformation($"Received request to get the metadata of all the submodels."); - - var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); - - var submodelList = new List(); - - if (reqSemanticId != null) - { - submodelList.AddRange(_adminShellPackageEnvironmentService.GetSubmodelsBySemanticId(reqSemanticId)); - } - - if (idShort != null) - { - submodelList.AddRange(_adminShellPackageEnvironmentService.GetSubmodelsByIdShort(idShort)); - } - - var submodelPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); - var submodelLevelList = _levelExtentModifierService.ApplyLevelExtent(submodelPagedList.result, level); - // TODO (jtikekar, 2023-09-04): @Andreas, what if the first element is property, where path is not applicable - var submodelsPath = _pathModifierService.ToIdShortPath(submodelLevelList.ConvertAll(sm => (ISubmodel)sm)); - var output = new PathPagedResult() {result = submodelsPath, paging_metadata = submodelPagedList.paging_metadata}; - return new ObjectResult(output); - } - - /// - /// Returns the References for all Submodels - /// - /// The value of the semantic id reference (BASE64-URL-encoded) - /// The Asset Administration Shell’s IdShort - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// References of the requested Submodels - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/$reference")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelsReference")] - [SwaggerResponse(statusCode: 200, type: typeof(GetReferencesResult), description: "References of the requested Submodels")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelsReference([FromQuery] [StringLength(3072, MinimumLength = 1)] string? semanticId, [FromQuery] string? idShort, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level) - { - _logger.LogInformation($"Received a request to get all the submodels."); - - var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); - - var submodelList = new List(); - - if (reqSemanticId != null) - { - submodelList.AddRange(_adminShellPackageEnvironmentService.GetSubmodelsBySemanticId(reqSemanticId)); - } - - if (idShort != null) - { - submodelList.AddRange(_adminShellPackageEnvironmentService.GetSubmodelsByIdShort(idShort)); - } - - var submodelsPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); - var smReferences = _referenceModifierService.GetReferenceResult(submodelsPagedList.result.ConvertAll(sm => (IReferable)sm)); - var output = new ReferencePagedResult(smReferences, submodelsPagedList.paging_metadata); - return new ObjectResult(output); - } - - /// - /// Returns all Submodels in their ValueOnly representation - /// - /// The value of the semantic id reference (BASE64-URL-encoded) - /// The Asset Administration Shell’s IdShort - /// The maximum number of elements in the response array - /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Requested Submodels - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/$value")] - [ValidateModelState] - [SwaggerOperation("GetAllSubmodelsValueOnly")] - [SwaggerResponse(statusCode: 200, type: typeof(ValueOnlyPagedResult), description: "Requested Submodels")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelsValueOnly([FromQuery] [StringLength(3072, MinimumLength = 1)] string? semanticId, [FromQuery] string? idShort, - [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent) - { - _logger.LogInformation($"Received a request to get all the submodels."); - - var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); - - var submodelList = new List(); - - if (reqSemanticId != null) - { - submodelList.AddRange(_adminShellPackageEnvironmentService.GetSubmodelsBySemanticId(reqSemanticId)); - } - - if (idShort != null) - { - submodelList.AddRange(_adminShellPackageEnvironmentService.GetSubmodelsByIdShort(idShort)); - } - - var submodelsPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); - var submodelLevelList = _levelExtentModifierService.ApplyLevelExtent(submodelsPagedList.result, level, extent); - var submodelsValue = _mappingService.Map(submodelLevelList, "value"); - var output = new ValueOnlyPagedResult {result = submodelsValue.ConvertAll(sme => (IValueDTO)sme), paging_metadata = submodelsPagedList.paging_metadata}; - return new ObjectResult(output); - } - - /// - /// Downloads file content from a specific submodel element from the Submodel at a specified path - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Requested file - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Method not allowed - Download only valid for File submodel element - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] - [ValidateModelState] - [SwaggerOperation("GetFileByPathSubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(byte[]), description: "Requested file")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 405, type: typeof(Result), description: "Method not allowed - Download only valid for File submodel element")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual async Task GetFileByPathSubmodelRepo([FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - _logger.LogInformation($"Received a request to get file at {idShortPath} from submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var fileName = _submodelService.GetFileByPath(decodedSubmodelIdentifier, idShortPath, out var content, out var fileSize); - - //content-disposition so that the aasx file can be downloaded from the web browser. - ContentDisposition contentDisposition = new() - { - FileName = fileName ?? throw new NullValueException(nameof(fileName)), - Inline = fileName.EndsWith(".pdf", StringComparison.InvariantCulture) - }; - - HttpContext.Response.Headers.Append("Content-Disposition", contentDisposition.ToString()); - HttpContext.Response.ContentLength = fileSize; - if (fileName.EndsWith(".svg", StringComparison.InvariantCulture)) - { - HttpContext.Response.ContentType = "image/svg+xml"; - } - - if (fileName.EndsWith(".pdf", StringComparison.InvariantCulture)) - { - HttpContext.Response.ContentType = "application/pdf"; - } - - await HttpContext.Response.Body.WriteAsync(content); - return new EmptyResult(); - } - - /// - /// Returns the Operation result of an asynchronously invoked Operation - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) - /// Operation result object - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-results/{handleId}")] - [ValidateModelState] - [SwaggerOperation("GetOperationAsyncResult")] - [SwaggerResponse(statusCode: 200, type: typeof(OperationResult), description: "Operation result object")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetOperationAsyncResult([FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath, - [FromRoute] [Required] string handleId) - { - //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(200, default(OperationResult)); - - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); - - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); - - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); - - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); - - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); - - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); - string exampleJson = null; - exampleJson = "\"\""; - - var example = exampleJson != null - ? System.Text.Json.JsonSerializer.Deserialize(exampleJson) - : default(OperationResult); //TODO: Change the data returned - return new ObjectResult(example); - } - - /// - /// Returns the Operation result of an asynchronously invoked Operation - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) - /// Value of the operation result object - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-results/{handleId}/$value")] - [ValidateModelState] - [SwaggerOperation("GetOperationAsyncResultValueOnly")] - [SwaggerResponse(statusCode: 200, type: typeof(IValueDTO), description: "Value of the operation result object")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetOperationAsyncResultValueOnly([FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath, - [FromRoute] [Required] string handleId) => - new ObjectResult(null); - - /// - /// Returns the status of an asynchronously invoked Operation - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) - /// Operation result object containing information that the 'executionState' is still 'Running' - /// The target resource is available but at a different location. - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-status/{handleId}")] - [ValidateModelState] - [SwaggerOperation("GetOperationAsyncStatus")] - [SwaggerResponse(statusCode: 200, type: typeof(BaseOperationResult), - description: "Operation result object containing information that the 'executionState' is still 'Running'")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetOperationAsyncStatus([FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath, - [FromRoute] [Required] string handleId) - { - //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(200, default(BaseOperationResult)); - - //TODO: Uncomment the next line to return response 302 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(302); - - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); - - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); - - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); - - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); - - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); - - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); - - return new ObjectResult(System.Text.Json.JsonSerializer.Deserialize(string.Empty)); - } - - //TODO:jtikekar @Andreas the route is same as GetSubmodelById - /// - /// Returns a specific Submodel - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Requested Submodel - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpHead] - [Route("/submodels/{submodelIdentifier}")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelPolicyHeader")] - [SwaggerResponse(statusCode: 200, type: typeof(Submodel), description: "Requested Header")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelPolicyHeader([FromRoute] [Required] string submodelIdentifier) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - _logger.LogInformation($"Received head request to get the submodel policy for id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - - // JUIJUI - // with HEAD the needed policy shall be returned - // access must be checked, but no given policy is ok - // to be changed - - return Ok(); - } - - //TODO:jtikekar @Andreas what about GetSubmodel from AAS-Repo? - /// - /// Returns a specific Submodel - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Requested Submodel - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - // [HttpHead] - [HttpGet] - [Route("/submodels/{submodelIdentifier}")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelById")] - [SwaggerResponse(statusCode: 200, type: typeof(Submodel), description: "Requested Submodel")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelById([FromRoute] [Required] string submodelIdentifier, [FromQuery] LevelEnum level, [FromQuery] ExtentEnum extent) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - _logger.LogInformation($"Received request to get the submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason.Message != "") - { - throw new NotAllowed(failedReason.Message); - } - - throw new NotAllowed("Policy incorrect!"); - } - - var output = _levelExtentModifierService.ApplyLevelExtent(submodel, level, extent); - - //TODO:jtikekar @Andreas, in earlier API policy set as getPolicy - //Response.Headers.Add("policy", policy); - return new ObjectResult(output); - } - - /// - /// Returns the metadata attributes of a specific Submodel - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Requested Submodel in the metadata representation - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/$metadata")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelByIdMetadata")] - [SwaggerResponse(statusCode: 200, type: typeof(SubmodelMetadata), description: "Requested Submodel in the metadata representation")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelByIdMetadata([FromRoute] [Required] string submodelIdentifier, [FromQuery] LevelEnum level) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received request to get the metadata of the submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason != null) - { - throw new NotAllowed(failedReason.Message); - } - } - - var submodelLevel = _levelExtentModifierService.ApplyLevelExtent(submodel, level); - var output = _mappingService.Map(submodelLevel, "metadata"); - return new ObjectResult(output); - } - - /// - /// Returns a specific Submodel in the Path notation - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Requested Submodel - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/$path")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelByIdPath")] - [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested Submodel")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelByIdPath([FromRoute] [Required] string submodelIdentifier, [FromQuery] LevelEnum level) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received request to get the idShortPath of the submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason != null) - { - throw new NotAllowed(failedReason.Message); - } - } - - var submodelLevel = _levelExtentModifierService.ApplyLevelExtent(submodel, level); - var output = _pathModifierService.ToIdShortPath(submodelLevel); - return new ObjectResult(output); - } - - /// - /// Returns the Reference of a specific Submodel - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Requested Submodel - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/$reference")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelByIdReference")] - [SwaggerResponse(statusCode: 200, type: typeof(Reference), description: "Requested Submodel")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelByIdReference([FromRoute] [Required] string submodelIdentifier) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - _logger.LogInformation($"Received request to get the submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason != null) - { - throw new NotAllowed(failedReason.Message); - } - } - - var output = _referenceModifierService.GetReferenceResult(submodel); - return new ObjectResult(output); - } - - /// - /// Returns a specific Submodel in the ValueOnly representation - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Requested Submodel - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/$value")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelByIdValueOnly")] - [SwaggerResponse(statusCode: 200, type: typeof(SubmodelValue), description: "Requested Submodel")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelByIdValueOnly([FromRoute] [Required] string submodelIdentifier, [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received request to get value of submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - var failedReason = authResult.Failure.FailureReasons.First(); - if (failedReason != null) - { - throw new NotAllowed(failedReason.Message); - } - } - - var submodelLevel = _levelExtentModifierService.ApplyLevelExtent(submodel, level, extent); - var output = _mappingService.Map(submodelLevel, "value"); - return new ObjectResult(output); - } - - /// - /// Returns the matadata attributes of a specific submodel element from the Submodel at a specified path - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Metadata attributes of the requested submodel element - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelElementByPathMetadataSubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(ISubmodelElementMetadata), description: "Metadata attributes of the requested submodel element")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelElementByPathMetadataSubmodelRepo([FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromQuery] LevelEnum level) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received request to get metadata of submodel element at {idShortPath} from the submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - var submodelElement = _submodelService.GetSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var smeLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, level); - var output = _mappingService.Map(smeLevel, "metadata"); - - return new ObjectResult(output); - } - - /// - /// Returns a specific submodel element from the Submodel at a specified path in the Path notation - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Requested submodel element - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$path")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelElementByPathPathSubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested submodel element")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelElementByPathPathSubmodelRepo([FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath, - [FromQuery] LevelEnum level) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received request to path of the submodel element at {idShortPath} from a submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - var submodelElement = _submodelService.GetSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var submodelElementLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, level); - var output = _pathModifierService.ToIdShortPath(submodelElementLevel); - return new ObjectResult(output); - } - - /// - /// Returns the Referene of a specific submodel element from the Submodel at a specified path - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Requested submodel element - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$reference")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelElementByPathReferenceSubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(Reference), description: "Requested submodel element")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelElementByPathReferenceSubmodelRepo([FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromQuery] LevelEnum level) - { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - _logger.LogInformation($"Received request to get reference of the submodel element atv{idShortPath} from the submodel with id {decodedSubmodelIdentifier}"); - - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var submodelElement = _submodelService.GetSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); - - var output = _referenceModifierService.GetReferenceResult(submodelElement); - return new ObjectResult(output); - } - - /// - /// Returns a specific submodel element from the Submodel at a specified path - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Requested submodel element - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelElementByPathSubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(ISubmodelElement), description: "Requested submodel element")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelElementByPathSubmodelRepo([FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath, - [FromQuery] LevelEnum level, [FromQuery] ExtentEnum extent) + } + + _logger.LogInformation($"Received a request to delete a submodel with id {decodedSubmodelIdentifier}"); + _submodelService.DeleteSubmodelById(decodedSubmodelIdentifier); + + return NoContent(); + } + + /// + /// Deletes a submodel element at a specified path within the submodel elements hierarchy + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Submodel element deleted successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("DeleteSubmodelElementByPathSubmodelRepo")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult DeleteSubmodelElementByPathSubmodelRepo([FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath) { var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received request to get the submodel element at {idShortPath} from the submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); } if (!Program.noSecurity) { var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; if (!authResult.Succeeded) { @@ -1625,878 +222,2094 @@ public virtual IActionResult GetSubmodelElementByPathSubmodelRepo([FromRoute] [R } } - var submodelElement = _submodelService.GetSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); + _logger.LogInformation($"Received a request to delete a submodel element at {idShortPath} from submodel with id {decodedSubmodelIdentifier}"); + // return StatusCode(500, default(Result)); - var output = _levelExtentModifierService.ApplyLevelExtent(submodelElement, level, extent); - return new ObjectResult(output); - } + _submodelService.DeleteSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); - /// - /// Returns a specific submodel element from the Submodel at a specified path in the ValueOnly representation - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Determines to which extent the resource is being serialized - /// Requested submodel element - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpGet] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value")] - [ValidateModelState] - [SwaggerOperation("GetSubmodelElementByPathValueOnlySubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(ISubmodelElementValue), description: "Requested submodel element")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetSubmodelElementByPathValueOnlySubmodelRepo([FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, - [FromQuery] LevelEnum level, - [FromQuery] ExtentEnum extent) + return NoContent(); + } + + /// + /// Returns all submodel elements including their hierarchy + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// List of found submodel elements + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElements")] + [SwaggerResponse(statusCode: 200, type: typeof(GetSubmodelElementsResult), description: "List of found submodel elements")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElements([FromRoute][Required] string submodelIdentifier, + [FromQuery] int? limit, [FromQuery] string? cursor, [FromQuery] string? level, + [FromQuery] string? extent, [FromQuery] string? diff) { - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received request to get the value of the submodel element at {idShortPath} from the submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var submodelElement = _submodelService.GetSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); - - var submodelElementLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, level, extent); - var output = _mappingService.Map(submodelElementLevel, "value"); + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); + } + + _logger.LogInformation($"Received a request to get all the submodel elements from submodel with id {decodedSubmodelIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var submodelElements = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); + + var filtered = new List(); + if (!diff.IsNullOrEmpty()) + { + try + { + var _diff = TimeStamp.TimeStamp.StringToDateTime(diff); + filtered = filterSubmodelElements(submodelElements, _diff); + } + catch + { + // ignored + } + } + else + filtered = submodelElements; + + var smePaginatedList = _paginationService.GetPaginatedList(filtered, new PaginationParameters(cursor, limit)); + var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginatedList.result, levelEnum, extentEnum); + var output = new PagedResult {result = smeLevelList, paging_metadata = smePaginatedList.paging_metadata}; + return new ObjectResult(output); + } + + List filterSubmodelElements(List submodelElements, DateTime diff) + { + var output = new List(); + + foreach (var sme in submodelElements.Where(sme => sme != null && sme.TimeStampTree >= diff)) + { + List smeDiff; + switch (sme) + { + case SubmodelElementCollection smc: + { + smeDiff = filterSubmodelElements(smc.Value ?? [], diff); + if (smeDiff.Count != 0) + { + var smcDiff = new SubmodelElementCollection( + extensions: smc.Extensions, + category: smc.Category, + idShort: smc.IdShort, + displayName: smc.DisplayName, + description: smc.Description, + semanticId: smc.SemanticId, + supplementalSemanticIds: smc.SupplementalSemanticIds, + qualifiers: smc.Qualifiers, + embeddedDataSpecifications: smc.EmbeddedDataSpecifications, + value: smeDiff) {Parent = smc.Parent}; + output.Add(smcDiff); + } + else if (smc.TimeStamp >= diff) + { + output.Add(smc); + } + + break; + } + case SubmodelElementList sml: + { + smeDiff = filterSubmodelElements(sml.Value ?? [], diff); + if (smeDiff.Count != 0) + { + var smlDiff = new SubmodelElementList( + typeValueListElement: sml.TypeValueListElement, + extensions: sml.Extensions, + category: sml.Category, + idShort: sml.IdShort, + displayName: sml.DisplayName, + description: sml.Description, + semanticId: sml.SemanticId, + supplementalSemanticIds: sml.SupplementalSemanticIds, + qualifiers: sml.Qualifiers, + embeddedDataSpecifications: sml.EmbeddedDataSpecifications, + value: smeDiff) {Parent = sml.Parent}; + output.Add(smlDiff); + } + else if (sml.TimeStamp >= diff) + { + output.Add(sml); + } + + break; + } + default: + output.Add(sme); + break; + } + } + + return output; + } + + /// + /// Returns the metadata attributes of all submodel elements including their hierarchy + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// Filters response, only elements changed after DateTime + /// List of found submodel elements + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsMetadataSubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(MetadataPagedResult), description: "List of found submodel elements")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElementsMetadataSubmodelRepo([FromRoute] [Required] string submodelIdentifier, + [FromQuery] int? limit, [FromQuery] string? cursor, + [FromQuery] string? diff) + { + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + _logger.LogInformation($"Received request to get the metadata of all the submodel elements from the submodel with id {decodedSubmodelIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var smeList = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); + + var filtered = new List(); + if (!diff.IsNullOrEmpty()) + { + try + { + var _diff = TimeStamp.TimeStamp.StringToDateTime(diff); + filtered = filterSubmodelElements(smeList, _diff); + } + catch + { + // ignored + } + } + else + filtered = smeList; + + var smePagedList = _paginationService.GetPaginatedList(filtered, new PaginationParameters(cursor, limit)); + var smeMetadataList = _mappingService.Map(smePagedList.result, "metadata"); + var output = new MetadataPagedResult() {result = smeMetadataList.ConvertAll(sme => (IMetadataDTO)sme), paging_metadata = smePagedList.paging_metadata}; + return new ObjectResult(output); + } + + /// + /// Returns all submodel elements including their hierarchy in the Path notation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// Filters response, only elements changed after DateTime + /// List of found submodel elements in the Path notation + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/$path")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsPathSubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(List>), description: "List of found submodel elements in the Path notation")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElementsPathSubmodelRepo([FromRoute][Required]string submodelIdentifier, + [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level, [FromQuery] string? diff) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + + var decodedSubmodelIdentifier = _decoderService.Decode($"submodelIdentifier", submodelIdentifier); + + _logger.LogDebug($"Received request to get all the submodel elements from the submodel with id {decodedSubmodelIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var submodelElementList = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); + + var filtered = new List(); + if (!diff.IsNullOrEmpty()) + { + try + { + var _diff = TimeStamp.TimeStamp.StringToDateTime(diff); + filtered = filterSubmodelElements(submodelElementList, _diff); + } + catch + { + // ignored + } + } + else + filtered = submodelElementList; + + var smePaginated = _paginationService.GetPaginatedList(filtered, new PaginationParameters(cursor, limit)); + var smeLevelList = _levelExtentModifierService.ApplyLevelExtent(smePaginated.result ?? [], levelEnum); + var smePathList = _pathModifierService.ToIdShortPath(smeLevelList.ConvertAll(sme => (ISubmodelElement)sme)); + var output = new PathPagedResult { result = smePathList, paging_metadata = smePaginated.paging_metadata }; return new ObjectResult(output); - } - - /// - /// Asynchronously invokes an Operation at a specified path - /// - /// Operation request object - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// The server has accepted the request. - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Method not allowed - Invoke only valid for Operation submodel element - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke-async")] - [ValidateModelState] - [SwaggerOperation("InvokeOperationAsync")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 405, type: typeof(Result), description: "Method not allowed - Invoke only valid for Operation submodel element")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult InvokeOperationAsync([FromBody] OperationRequest? body, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath) + } + + /// + /// Returns the References of all submodel elements + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// List of found submodel elements + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/$reference")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsReferenceSubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(GetReferencesResult), description: "List of found submodel elements")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElementsReferenceSubmodelRepo([FromRoute][Required]string submodelIdentifier, [FromQuery]int? limit, + [FromQuery]string? cursor, [FromQuery]string? level) + { + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); + } + + _logger.LogInformation($"Received a request to get all the submodel elements from submodel with id {decodedSubmodelIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var smeList = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); + + var smePagedList = _paginationService.GetPaginatedList(smeList, new PaginationParameters(cursor, limit)); + var smeReferences = _referenceModifierService.GetReferenceResult(smePagedList.result.ConvertAll(sme => (IReferable)sme)); + var output = new ReferencePagedResult(smeReferences, smePagedList.paging_metadata); + return new ObjectResult(output); + } + + /// + /// Returns all submodel elements including their hierarchy in the ValueOnly representation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Filters response, only elements changed after DateTime + /// List of found submodel elements + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/$value")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsValueOnlySubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(ValueOnlyPagedResult), description: "List of found submodel elements")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElementsValueOnlySubmodelRepo([FromRoute][Required]string submodelIdentifier, + [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level, + [FromQuery]string? extent, [FromQuery] string? diff) { - //TODO: Uncomment the next line to return response 202 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(202); - - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); - - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); - - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); - - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); - - //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(405, default(Result)); - - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); - - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); - - throw new NotImplementedException(); - } - - /// - /// Asynchronously invokes an Operation at a specified path - /// - /// Operation request object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// The server has accepted the request. - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke-async/$value")] - [ValidateModelState] - [SwaggerOperation("InvokeOperationAsyncValueOnly")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult InvokeOperationAsyncValueOnly([FromBody] object? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath) + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Decoding {submodelIdentifier} returned null"); + } + + _logger.LogInformation($"Received request to get value of all the submodel elements from the submodel with id {decodedSubmodelIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var submodelElements = _submodelService.GetAllSubmodelElements(decodedSubmodelIdentifier); + + var filtered = new List(); + if (!diff.IsNullOrEmpty()) + { + try + { + var _diff = TimeStamp.TimeStamp.StringToDateTime(diff); + filtered = filterSubmodelElements(submodelElements, _diff); + } + catch + { + // ignored + } + } + else + filtered = submodelElements; + + var smePagedList = _paginationService.GetPaginatedList(filtered, new PaginationParameters(cursor, limit)); + var smeLevelExtent = _levelExtentModifierService.ApplyLevelExtent(smePagedList.result ?? [], levelEnum, extentEnum); + var smeValues = _mappingService.Map(smeLevelExtent, "value"); + var output = new ValueOnlyPagedResult() {result = smeValues.ConvertAll(sme => (IValueDTO)sme), paging_metadata = smePagedList.paging_metadata}; + return new ObjectResult(output); + } + + /// + /// Returns all Submodels + /// + /// The value of the semantic id reference (BASE64-URL-encoded) + /// The Asset Administration Shell’s IdShort + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Requested Submodels + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodels")] + [SwaggerResponse(statusCode: 200, type: typeof(PagedResult), description: "Requested Submodels")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodels([FromQuery][StringLength(3072, MinimumLength=1)] string? semanticId, [FromQuery]string? idShort, [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level, [FromQuery]string? extent) { - //TODO: Uncomment the next line to return response 202 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(202); - - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); - - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); - - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); - - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); - - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); - - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); - - throw new NotImplementedException(); - } - - /// - /// Synchronously or asynchronously invokes an Operation at a specified path - /// - /// Operation request object - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines whether an operation invocation is performed asynchronously or synchronously - /// Operation result object - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Method not allowed - Invoke only valid for Operation submodel element - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke")] - [ValidateModelState] - [SwaggerOperation("InvokeOperationSubmodelRepo")] - [SwaggerResponse(statusCode: 200, type: typeof(OperationResult), description: "Operation result object")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 405, type: typeof(Result), description: "Method not allowed - Invoke only valid for Operation submodel element")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult InvokeOperationSubmodelRepo([FromBody] OperationRequest? body, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromQuery] bool async) + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + _logger.LogInformation($"Received a request to get all the submodels."); + + var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); + + var submodelList = _submodelService.GetAllSubmodels(reqSemanticId, idShort); + + var submodelsPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); + var smLevelList = _levelExtentModifierService.ApplyLevelExtent(submodelsPagedList.result, levelEnum, extentEnum); + var output = new PagedResult {result = smLevelList, paging_metadata = submodelsPagedList.paging_metadata}; + return new ObjectResult(output); +} + + /// + /// Returns the metadata attributes of all Submodels + /// + /// The value of the semantic id reference (BASE64-URL-encoded) + /// The Asset Administration Shell’s IdShort + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// Requested Submodels + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelsMetadata")] + [SwaggerResponse(statusCode: 200, type: typeof(MetadataPagedResult), description: "Requested Submodels")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelsMetadata([FromQuery][StringLength(3072, MinimumLength=1)]string? semanticId, [FromQuery]string? idShort, [FromQuery]int? limit, [FromQuery]string? cursor) + { + _logger.LogInformation($"Received request to get the metadata of all the submodels."); + + var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); + + var submodelList = _submodelService.GetAllSubmodels(reqSemanticId, idShort); + + var submodelPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); + var smMetadataList = _mappingService.Map(submodelPagedList.result, "metadata"); + var output = new MetadataPagedResult() {result = smMetadataList.ConvertAll(sme => (IMetadataDTO)sme), paging_metadata = submodelPagedList.paging_metadata}; + return new ObjectResult(output); + } + + /// + /// Returns all Submodels in the Path notation + /// + /// The value of the semantic id reference (BASE64-URL-encoded) + /// The Asset Administration Shell’s IdShort + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// Requested Submodels + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/$path")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelsPath")] + [SwaggerResponse(statusCode: 200, type: typeof(GetPathItemsResult), description: "Requested Submodels")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelsPath([FromQuery][StringLength(3072, MinimumLength=1)]string? semanticId, [FromQuery]string? idShort, [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level) { - //TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(200, default(OperationResult)); - - //TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(400, default(Result)); - - //TODO: Uncomment the next line to return response 401 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(401, default(Result)); - - //TODO: Uncomment the next line to return response 403 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(403, default(Result)); - - //TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(404, default(Result)); - - //TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(405, default(Result)); - - //TODO: Uncomment the next line to return response 500 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(500, default(Result)); - - //TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ... - // return StatusCode(0, default(Result)); - return new ObjectResult(System.Text.Json.JsonSerializer.Deserialize(string.Empty)); - } - - /// - /// Synchronously or asynchronously invokes an Operation at a specified path - /// - /// Operation request object - /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines whether an operation invocation is performed asynchronously or synchronously - /// Operation result object - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke/$value")] - [ValidateModelState] - [SwaggerOperation("InvokeOperationValueOnly")] - [SwaggerResponse(statusCode: 200, type: typeof(IValueDTO), description: "Operation result object")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult InvokeOperationValueOnly([FromBody] object? body, [FromRoute] [Required] string aasIdentifier, - [FromRoute] [Required] string submodelIdentifier, [FromRoute] [Required] string idShortPath, - [FromQuery] bool async) => - new ObjectResult(null); - - /// - /// Updates an existing Submodel - /// - /// Submodel object - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Submodel updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/submodels/{submodelIdentifier}")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelById")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelById([FromBody] Submodel? body, [FromRoute] [Required] string submodelIdentifier, [FromQuery] LevelEnum level) + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + _logger.LogInformation($"Received request to get the metadata of all the submodels."); + + var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); + + var submodelList = _submodelService.GetAllSubmodels(reqSemanticId, idShort); + + var submodelPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); + var submodelLevelList = _levelExtentModifierService.ApplyLevelExtent(submodelPagedList.result, levelEnum); + var submodelsPath = _pathModifierService.ToIdShortPath(submodelLevelList.ConvertAll(sm => (ISubmodel)sm)); + var output = new PathPagedResult() {result = submodelsPath, paging_metadata = submodelPagedList.paging_metadata}; + return new ObjectResult(output); + } + + /// + /// Returns the References for all Submodels + /// + /// The value of the semantic id reference (BASE64-URL-encoded) + /// The Asset Administration Shell’s IdShort + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// References of the requested Submodels + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/$reference")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelsReference")] + [SwaggerResponse(statusCode: 200, type: typeof(GetReferencesResult), description: "References of the requested Submodels")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelsReference([FromQuery][StringLength(3072, MinimumLength=1)]string? semanticId, [FromQuery]string? idShort, [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level) + { + _logger.LogInformation($"Received a request to get all the submodels."); + var levelEnum = _validateModifierService.ValidateLevel(level); + var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); + + var submodelList = _submodelService.GetAllSubmodels(reqSemanticId, idShort); + + var submodelsPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); + var smReferences = _referenceModifierService.GetReferenceResult(submodelsPagedList.result.ConvertAll(sm => (IReferable)sm)); + var output = new ReferencePagedResult(smReferences, submodelsPagedList.paging_metadata); + return new ObjectResult(output); + } + + /// + /// Returns all Submodels in their ValueOnly representation + /// + /// The value of the semantic id reference (BASE64-URL-encoded) + /// The Asset Administration Shell’s IdShort + /// The maximum number of elements in the response array + /// A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Requested Submodels + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/$value")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelsValueOnly")] + [SwaggerResponse(statusCode: 200, type: typeof(ValueOnlyPagedResult), description: "Requested Submodels")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelsValueOnly([FromQuery][StringLength(3072, MinimumLength=1)]string? semanticId, [FromQuery]string? idShort, [FromQuery]int? limit, [FromQuery]string? cursor, [FromQuery]string? level, [FromQuery]string? extent) { - if (body == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - _logger.LogInformation($"Received request to update the submodel with id {decodedSubmodelIdentifier}."); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _submodelService.UpdateSubmodelById(decodedSubmodelIdentifier, body); + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + _logger.LogInformation($"Received a request to get all the submodels."); + + var reqSemanticId = _jsonQueryDeserializer.DeserializeReference("semanticId", semanticId); + + var submodelList = _submodelService.GetAllSubmodels(reqSemanticId, idShort); + + var submodelsPagedList = _paginationService.GetPaginatedList(submodelList, new PaginationParameters(cursor, limit)); + var submodelLevelList = _levelExtentModifierService.ApplyLevelExtent(submodelsPagedList.result, levelEnum, extentEnum); + var submodelsValue = _mappingService.Map(submodelLevelList, "value"); + var output = new ValueOnlyPagedResult {result = submodelsValue.ConvertAll(sme => (IValueDTO)sme), paging_metadata = submodelsPagedList.paging_metadata}; + return new ObjectResult(output); + } + + /// + /// Downloads file content from a specific submodel element from the Submodel at a specified path + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Requested file + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Method not allowed - Download only valid for File submodel element + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] + [ValidateModelState] + [SwaggerOperation("GetFileByPathSubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(byte[]), description: "Requested file")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 405, type: typeof(Result), description: "Method not allowed - Download only valid for File submodel element")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual async Task GetFileByPathSubmodelRepo([FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath) + { + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received a request to get file at {idShortPath} from submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var fileName = _submodelService.GetFileByPath(decodedSubmodelIdentifier, idShortPath, out var content, out var fileSize); + + //content-disposition so that the aasx file can be downloaded from the web browser. + ContentDisposition contentDisposition = new() + { + FileName = fileName ?? throw new NullValueException(nameof(fileName)), + Inline = fileName.EndsWith(".pdf", StringComparison.InvariantCulture) + }; + + HttpContext.Response.Headers.Append("Content-Disposition", contentDisposition.ToString()); + HttpContext.Response.ContentLength = fileSize; + if (fileName.EndsWith(".svg", StringComparison.InvariantCulture)) + { + HttpContext.Response.ContentType = "image/svg+xml"; + } + + if (fileName.EndsWith(".pdf", StringComparison.InvariantCulture)) + { + HttpContext.Response.ContentType = "application/pdf"; + } + + await HttpContext.Response.Body.WriteAsync(content); + return new EmptyResult(); + } + + /// + /// Returns the Operation result of an asynchronously invoked Operation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) + /// Operation result object + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-results/{handleId}")] + [ValidateModelState] + [SwaggerOperation("GetOperationAsyncResult")] + [SwaggerResponse(statusCode: 200, type: typeof(OperationResult), description: "Operation result object")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetOperationAsyncResult([FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath, + [FromRoute][Required] string handleId) => throw new NotImplementedException(); + + /// + /// Returns the Operation result of an asynchronously invoked Operation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) + /// Value of the operation result object + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-results/{handleId}/$value")] + [ValidateModelState] + [SwaggerOperation("GetOperationAsyncResultValueOnly")] + [SwaggerResponse(statusCode: 200, type: typeof(IValueDTO), description: "Value of the operation result object")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetOperationAsyncResultValueOnly([FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath, + [FromRoute][Required] string handleId) => throw new NotImplementedException(); + + /// + /// Returns the status of an asynchronously invoked Operation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// The returned handle id of an operation’s asynchronous invocation used to request the current state of the operation’s execution (UTF8-BASE64-URL-encoded) + /// Operation result object containing information that the 'executionState' is still 'Running' + /// The target resource is available but at a different location. + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/operation-status/{handleId}")] + [ValidateModelState] + [SwaggerOperation("GetOperationAsyncStatus")] + [SwaggerResponse(statusCode: 200, type: typeof(BaseOperationResult), description: "Operation result object containing information that the 'executionState' is still 'Running'")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetOperationAsyncStatus([FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath, + [FromRoute][Required] string handleId) => throw new NotImplementedException(); - return NoContent(); - } - - /// - /// Updates the metadata attributes of an existing Submodel - /// - /// The metadata attributes of the Submodel object - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Submodel updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/submodels/{submodelIdentifier}/$metadata")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelByIdMetadata")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelByIdMetadata([FromBody] SubmodelMetadata? body, [FromRoute] [Required] string? submodelIdentifier, - [FromQuery] LevelEnum level) + //TODO:jtikekar @Andreas the route is same as GetSubmodelById + /// + /// Returns a specific Submodel + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Requested Submodel + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpHead] + [Route("submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelPolicyHeader")] + [SwaggerResponse(statusCode: 200, type: typeof(Submodel), description: "Requested Header")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelPolicyHeader([FromRoute] [Required] string submodelIdentifier) + { + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received head request to get the submodel policy for id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + + // JUIJUI + // with HEAD the needed policy shall be returned + // access must be checked, but no given policy is ok + // to be changed + + return Ok(); + } + + + /// + /// Returns a specific Submodel + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Requested Submodel + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelById")] + [SwaggerResponse(statusCode: 200, type: typeof(Submodel), description: "Requested Submodel")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelById([FromRoute][Required] string submodelIdentifier, [FromQuery] string? level, [FromQuery] string? extent) { - if (body == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received Patch Request for submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - var submodel = _mappingService.Map(body, "metadata") as ISubmodel; - if (submodel == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(submodel)} is null"); - } - - //Update - _submodelService.UpdateSubmodelById(decodedSubmodelIdentifier, submodel); - - return NoContent(); - } - - /// - /// Updates the values of an existing Submodel - /// - /// Submodel object in its ValueOnly representation - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Determines the structural depth of the respective resource content - /// Submodel updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/submodels/{submodelIdentifier}/$value")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelByIdValueOnly")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelByIdValueOnly([FromBody] SubmodelValue? body, [FromRoute] [Required] string submodelIdentifier, - [FromQuery] LevelEnum level) + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received request to get the submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason.Message != "") + { + throw new NotAllowed(failedReason.Message); + } + + throw new NotAllowed("Policy incorrect!"); + } + + var output = _levelExtentModifierService.ApplyLevelExtent(submodel, levelEnum, extentEnum); + + //TODO:jtikekar @Andreas, in earlier API policy set as getPolicy + //Response.Headers.Add("policy", policy); + return new ObjectResult(output); + } + + /// + /// Returns the metadata attributes of a specific Submodel + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Requested Submodel in the metadata representation + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdMetadata")] + [SwaggerResponse(statusCode: 200, type: typeof(SubmodelMetadata), description: "Requested Submodel in the metadata representation")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelByIdMetadata([FromRoute][Required] string submodelIdentifier) { - if (body == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to update the submodel with id {decodedSubmodelIdentifier} by value."); - - var submodel = _mappingService.Map(body, "value") as Submodel; - if (submodel == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(submodel)} is null"); - } - - _submodelService.UpdateSubmodelById(decodedSubmodelIdentifier, submodel); - - return NoContent(); - } - - /// - /// Updates the metadata attributes an existing SubmodelElement - /// - /// Metadata attributes of the SubmodelElement - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// SubmodelElement updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelElementByPathMetadataSubmodelRepo")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelElementByPathMetadataSubmodelRepo([FromBody] ISubmodelElementMetadata? body, - [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, - [FromQuery] LevelEnum level) + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received request to get the metadata of the submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason != null) + { + throw new NotAllowed(failedReason.Message); + } + } + + var output = _mappingService.Map(submodel, "metadata"); + return new ObjectResult(output); + } + + /// + /// Returns a specific Submodel in the Path notation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Determines the structural depth of the respective resource content + /// Requested Submodel + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/$path")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdPath")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested Submodel")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelByIdPath([FromRoute][Required] string submodelIdentifier, [FromQuery] string? level) { - if (body == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received request to update the submodel element at {idShortPath} in the submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - //Reverse mapping from Metadata to submodel element - var submodelElement = _mappingService.Map(body, "metadata") as ISubmodelElement; - if (submodelElement == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(submodelElement)} is null"); - } - - //Update - _submodelService.UpdateSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath, submodelElement); - - return NoContent(); - } - - /// - /// Updates an existing SubmodelElement - /// - /// SubmodelElement object - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// SubmodelElement updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelElementByPathSubmodelRepo")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelElementByPathSubmodelRepo([FromBody] ISubmodelElement? body, [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, [FromQuery] LevelEnum level) + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received request to get the idShortPath of the submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason != null) + { + throw new NotAllowed(failedReason.Message); + } + } + + var submodelLevel = _levelExtentModifierService.ApplyLevelExtent(submodel, levelEnum); + var output = _pathModifierService.ToIdShortPath(submodelLevel); + return new ObjectResult(output); + } + + /// + /// Returns the Reference of a specific Submodel + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Requested Submodel + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/$reference")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdReference")] + [SwaggerResponse(statusCode: 200, type: typeof(Reference), description: "Requested Submodel")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelByIdReference([FromRoute][Required] string submodelIdentifier) + { + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received request to get the submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason != null) + { + throw new NotAllowed(failedReason.Message); + } + } + + var output = _referenceModifierService.GetReferenceResult(submodel); + return new ObjectResult(output); + } + + /// + /// Returns a specific Submodel in the ValueOnly representation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Requested Submodel + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/$value")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdValueOnly")] + [SwaggerResponse(statusCode: 200, type: typeof(SubmodelValue), description: "Requested Submodel")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelByIdValueOnly([FromRoute][Required] string submodelIdentifier, [FromQuery] string? level, [FromQuery] string? extent) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received request to get value of submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var authResult = _authorizationService.AuthorizeAsync(User, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + var failedReason = authResult.Failure.FailureReasons.First(); + if (failedReason != null) + { + throw new NotAllowed(failedReason.Message); + } + } + + var submodelLevel = _levelExtentModifierService.ApplyLevelExtent(submodel, levelEnum, extentEnum); + var output = _mappingService.Map(submodelLevel, "value"); + return new ObjectResult(output); + } + + /// + /// Returns the matadata attributes of a specific submodel element from the Submodel at a specified path + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Metadata attributes of the requested submodel element + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathMetadataSubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(ISubmodelElementMetadata), description: "Metadata attributes of the requested submodel element")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelElementByPathMetadataSubmodelRepo([FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath) + { + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received request to get metadata of submodel element at {idShortPath} from the submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + var submodelElement = _submodelService.GetSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var output = _mappingService.Map(submodelElement, "metadata"); + + return new ObjectResult(output); + } + + /// + /// Returns a specific submodel element from the Submodel at a specified path in the Path notation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Submodel elements in path notation + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$path")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathPathSubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Submodel elements in path notation")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelElementByPathPathSubmodelRepo([FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath, [FromQuery] string? level) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received request to path of the submodel element at {idShortPath} from a submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + var submodelElement = _submodelService.GetSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var submodelElementLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, levelEnum); + var output = _pathModifierService.ToIdShortPath(submodelElementLevel); + return new ObjectResult(output); + } + + /// + /// Returns the Referene of a specific submodel element from the Submodel at a specified path + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Requested submodel element + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$reference")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathReferenceSubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(Reference), description: "Requested submodel element")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelElementByPathReferenceSubmodelRepo([FromRoute][Required] string submodelIdentifier, + [FromRoute][Required] string idShortPath) + { + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received request to get reference of the submodel element atv{idShortPath} from the submodel with id {decodedSubmodelIdentifier}"); + + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) {new("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var submodelElement = _submodelService.GetSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); + + var output = _referenceModifierService.GetReferenceResult(submodelElement); + return new ObjectResult(output); + } + + /// + /// Returns a specific submodel element from the Submodel at a specified path + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Requested submodel element + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathSubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(ISubmodelElement), description: "Requested submodel element")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelElementByPathSubmodelRepo([FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath, + [FromQuery] string? level, [FromQuery] string? extent) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received request to get the submodel element at {idShortPath} from the submodel with id {decodedSubmodelIdentifier}"); + + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var submodelElement = _submodelService.GetSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); + + var output = _levelExtentModifierService.ApplyLevelExtent(submodelElement, levelEnum, extentEnum); + return new ObjectResult(output); + } + + /// + /// Returns a specific submodel element from the Submodel at a specified path in the ValueOnly representation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// Requested submodel element + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathValueOnlySubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(ISubmodelElementValue), description: "Requested submodel element")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetSubmodelElementByPathValueOnlySubmodelRepo([FromRoute][Required] string submodelIdentifier, + [FromRoute][Required] string idShortPath, [FromQuery] string? level, [FromQuery] string? extent) + { + //Validate level and extent + var levelEnum = _validateModifierService.ValidateLevel(level); + var extentEnum = _validateModifierService.ValidateExtent(extent); + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received request to get the value of the submodel element at {idShortPath} from the submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var submodelElement = _submodelService.GetSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath); + + var submodelElementLevel = _levelExtentModifierService.ApplyLevelExtent(submodelElement, levelEnum, extentEnum); + var output = _mappingService.Map(submodelElementLevel, "value"); + return new ObjectResult(output); + } + + /// + /// Asynchronously invokes an Operation at a specified path + /// + /// Operation request object + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// The server has accepted the request. + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Method not allowed - Invoke only valid for Operation submodel element + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke-async")] + [ValidateModelState] + [SwaggerOperation("InvokeOperationAsync")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 405, type: typeof(Result), description: "Method not allowed - Invoke only valid for Operation submodel element")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult InvokeOperationAsync([FromBody] OperationRequest? body, [FromRoute][Required] string submodelIdentifier, + [FromRoute][Required] string idShortPath) => throw new NotImplementedException(); + + /// + /// Asynchronously invokes an Operation at a specified path + /// + /// Operation request object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// The server has accepted the request. + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke-async/$value")] + [ValidateModelState] + [SwaggerOperation("InvokeOperationAsyncValueOnly")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult InvokeOperationAsyncValueOnly([FromBody] OperationRequestValueOnly body, [FromRoute][Required] string aasIdentifier, + [FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath) => throw new NotImplementedException(); + + /// + /// Synchronously or asynchronously invokes an Operation at a specified path + /// + /// Operation request object + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines whether an operation invocation is performed asynchronously or synchronously + /// Operation result object + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Method not allowed - Invoke only valid for Operation submodel element + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke")] + [ValidateModelState] + [SwaggerOperation("InvokeOperationSubmodelRepo")] + [SwaggerResponse(statusCode: 200, type: typeof(OperationResult), description: "Operation result object")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 405, type: typeof(Result), description: "Method not allowed - Invoke only valid for Operation submodel element")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult InvokeOperationSubmodelRepo([FromBody] OperationRequest body, [FromRoute][Required] string submodelIdentifier, + [FromRoute][Required] string idShortPath, [FromQuery] bool? _async) => throw new NotImplementedException(); + + /// + /// Synchronously or asynchronously invokes an Operation at a specified path + /// + /// Operation request object + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines whether an operation invocation is performed asynchronously or synchronously + /// Operation result object + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke/$value")] + [ValidateModelState] + [SwaggerOperation("InvokeOperationValueOnly")] + [SwaggerResponse(statusCode: 200, type: typeof(IValueDTO), description: "Operation result object")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult InvokeOperationValueOnly([FromBody] OperationRequestValueOnly body, [FromRoute][Required] string aasIdentifier, + [FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath, + [FromQuery] bool? _async) => throw new NotImplementedException(); + + /// + /// Updates an existing Submodel + /// + /// Submodel object + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Determines the structural depth of the respective resource content + /// Submodel updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelById")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelById([FromBody]Submodel? body, [FromRoute][Required] string submodelIdentifier, [FromQuery] string? level) + { + if (body == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received request to update the submodel with id {decodedSubmodelIdentifier}."); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + _submodelService.UpdateSubmodelById(decodedSubmodelIdentifier, body); + + return NoContent(); + } + + /// + /// Updates the metadata attributes of an existing Submodel + /// + /// The metadata attributes of the Submodel object + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Submodel updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("submodels/{submodelIdentifier}/$metadata")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelByIdMetadata")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelByIdMetadata([FromBody]SubmodelMetadata? body, [FromRoute][Required] string? submodelIdentifier) + { + if (body == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received Patch Request for submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + var submodel = _mappingService.Map(body, "metadata") as ISubmodel; + if (submodel == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(submodel)} is null"); + } + + //Update + _submodelService.UpdateSubmodelById(decodedSubmodelIdentifier, submodel); + + return NoContent(); + } + + /// + /// Updates the values of an existing Submodel + /// + /// Submodel object in its ValueOnly representation + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Determines the structural depth of the respective resource content + /// Submodel updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("submodels/{submodelIdentifier}/$value")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelByIdValueOnly")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelByIdValueOnly([FromBody]SubmodelValue? body, [FromRoute][Required]string submodelIdentifier, + [FromQuery]string? level) { if (body == null) { throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to update the submodel element at {idShortPath} from submodel with id {decodedSubmodelIdentifier}."); - _submodelService.UpdateSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath, body); - - return NoContent(); - } - - /// - /// Updates the value of an existing SubmodelElement - /// - /// The SubmodelElement in its ValueOnly representation - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Submodel updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPatch] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value")] - [ValidateModelState] - [SwaggerOperation("PatchSubmodelElementByPathValueOnlySubmodelRepo")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PatchSubmodelElementByPathValueOnlySubmodelRepo([FromBody] ISubmodelElementValue? body, - [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, - [FromQuery] LevelEnum level) + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + _logger.LogInformation($"Received request to update the submodel with id {decodedSubmodelIdentifier} by value."); + + var submodel = _mappingService.Map(body, "value") as Submodel; + if (submodel == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(submodel)} is null"); + } + + _submodelService.UpdateSubmodelById(decodedSubmodelIdentifier, submodel); + + return NoContent(); + } + + /// + /// Updates the metadata attributes an existing SubmodelElement + /// + /// Metadata attributes of the SubmodelElement + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// SubmodelElement updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelElementByPathMetadataSubmodelRepo")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelElementByPathMetadataSubmodelRepo([FromBody] ISubmodelElementMetadata? body, + [FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath) { if (body == null) { throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received an update request for a submodel element at {idShortPath} in the submodel with id {decodedSubmodelIdentifier}."); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - if (_mappingService.Map(body, "value") is not ISubmodelElement submodelElement) - { - throw new NotAllowed($"Cannot proceed as {nameof(submodelElement)} is null"); - } - - //Update - _submodelService.UpdateSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath, submodelElement); - - return NoContent(); - } - - /// - /// Creates a new Submodel - /// - /// Submodel object - /// The AAS’s unique id (UTF8-BASE64-URL-encoded) - /// Submodel created successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/submodels")] - [ValidateModelState] - [SwaggerOperation("PostSubmodel")] - [SwaggerResponse(statusCode: 201, type: typeof(Submodel), description: "Submodel created successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 409, type: typeof(Result), - description: - "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PostSubmodel([FromBody] Submodel? body, [FromQuery] string? aasIdentifier) + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received request to update the submodel element at {idShortPath} in the submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + //Reverse mapping from Metadata to submodel element + var submodelElement = _mappingService.Map(body, "metadata") as ISubmodelElement; + if (submodelElement == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(submodelElement)} is null"); + } + + //Update + _submodelService.UpdateSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath, submodelElement); + + return NoContent(); + } + + /// + /// Updates an existing SubmodelElement + /// + /// SubmodelElement object + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// SubmodelElement updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelElementByPathSubmodelRepo")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelElementByPathSubmodelRepo([FromBody] ISubmodelElement? body, [FromRoute][Required] string submodelIdentifier, + [FromRoute][Required] string idShortPath, [FromQuery] string? level) { if (body == null) { throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - _logger.LogInformation($"Received request to create a submodel."); - - var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); - if (decodedAasIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); - } - - var output = _submodelService.CreateSubmodel(body, decodedAasIdentifier); - - return CreatedAtAction("PostSubmodel", output); - } - - /// - /// Creates a new submodel element at a specified path within submodel elements hierarchy - /// - /// Requested submodel element - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Create element as first one in list - /// Submodel element created successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] - [ValidateModelState] - [SwaggerOperation("PostSubmodelElementByPathSubmodelRepo")] - [SwaggerResponse(statusCode: 201, type: typeof(ISubmodelElement), description: "Submodel element created successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 409, type: typeof(Result), - description: - "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PostSubmodelElementByPathSubmodelRepo([FromBody] ISubmodelElement? body, - [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, - bool first) + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + _logger.LogInformation($"Received request to update the submodel element at {idShortPath} from submodel with id {decodedSubmodelIdentifier}."); + _submodelService.UpdateSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath, body); + + return NoContent(); + } + + /// + /// Updates the value of an existing SubmodelElement + /// + /// The SubmodelElement in its ValueOnly representation + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Submodel updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelElementByPathValueOnlySubmodelRepo")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PatchSubmodelElementByPathValueOnlySubmodelRepo([FromBody] ISubmodelElementValue? body, + [FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath, + [FromQuery] string? level) { if (body == null) { throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _logger.LogInformation($"Received request to create a new submodel element at {idShortPath} in the submodel with id {decodedSubmodelIdentifier}"); - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); - var claimsList = new List(User.Claims) {new("IdShortPath", $"{submodel.IdShort}.{idShortPath}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var output = _submodelService.CreateSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath, first, body); - - return CreatedAtAction("PostSubmodelElementByPathSubmodelRepo", output); - } - - /// - /// Creates a new submodel element - /// - /// Requested submodel element - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Create element as first one in list - /// Submodel element created successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPost] - [Route("/submodels/{submodelIdentifier}/submodel-elements")] - [ValidateModelState] - [SwaggerOperation("PostSubmodelElementSubmodelRepo")] - [SwaggerResponse(statusCode: 201, type: typeof(ISubmodelElement), description: "Submodel element created successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 409, type: typeof(Result), - description: - "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PostSubmodelElementSubmodelRepo([FromBody] ISubmodelElement? body, - [FromRoute] [Required] string submodelIdentifier, - bool first) + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received an update request for a submodel element at {idShortPath} in the submodel with id {decodedSubmodelIdentifier}."); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + if (_mappingService.Map(body, "value") is not ISubmodelElement submodelElement) + { + throw new NotAllowed($"Cannot proceed as {nameof(submodelElement)} is null"); + } + + //Update + _submodelService.UpdateSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath, submodelElement); + + return NoContent(); + } + + /// + /// Creates a new Submodel + /// + /// Submodel object + /// The AAS’s unique id (UTF8-BASE64-URL-encoded) + /// Submodel created successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("submodels")] + [ValidateModelState] + [SwaggerOperation("PostSubmodel")] + [SwaggerResponse(statusCode: 201, type: typeof(Submodel), description: "Submodel created successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 409, type: typeof(Result), description: "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PostSubmodel([FromBody]Submodel body, [FromQuery] string aasIdentifier) { if (body == null) { throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - _logger.LogInformation($"Received request to create a new submodel element in the submodel with id {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{body.IdShort}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - var output = _submodelService.CreateSubmodelElement(decodedSubmodelIdentifier, body, first); - - return CreatedAtAction("PostSubmodelElementSubmodelRepo", output); - } - - - /// - /// Updates an existing Submodel - /// - /// Submodel object - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// Submodel updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPut] - [Route("/submodels/{submodelIdentifier}")] - [ValidateModelState] - [SwaggerOperation("PutSubmodelById")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PutSubmodelById([FromBody] Submodel? body, [FromRoute] [Required] string submodelIdentifier) + } + + _logger.LogInformation($"Received request to create a submodel."); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + if (decodedAasIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedAasIdentifier)} is null"); + } + + var output = _submodelService.CreateSubmodel(body, decodedAasIdentifier); + + return CreatedAtAction("PostSubmodel", output); + } + + /// + /// Creates a new submodel element at a specified path within submodel elements hierarchy + /// + /// Requested submodel element + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Create element as first one in list + /// Submodel element created successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("PostSubmodelElementByPathSubmodelRepo")] + [SwaggerResponse(statusCode: 201, type: typeof(ISubmodelElement), description: "Submodel element created successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 409, type: typeof(Result), description: "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PostSubmodelElementByPathSubmodelRepo([FromBody] ISubmodelElement? body, + [FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath, + bool first) { if (body == null) { throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - _logger.LogInformation($"Received request to replace a submodel {decodedSubmodelIdentifier}"); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - _submodelService.ReplaceSubmodelById(decodedSubmodelIdentifier, body); - - return NoContent(); - } - - /// - /// Updates an existing submodel element at a specified path within submodel elements hierarchy - /// - /// Requested submodel element - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// Determines the structural depth of the respective resource content - /// Submodel element updated successfully - /// Bad Request, e.g. the request parameters of the format of the request body is wrong. - /// Unauthorized, e.g. the server refused the authorization attempt. - /// Forbidden - /// Not Found - /// Internal Server Error - /// Default error handling for unmentioned status codes - [HttpPut] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] - [ValidateModelState] - [SwaggerOperation("PutSubmodelElementByPathSubmodelRepo")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] - [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] - [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + _logger.LogInformation($"Received request to create a new submodel element at {idShortPath} in the submodel with id {decodedSubmodelIdentifier}"); + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + User.Claims.ToList().Add(new Claim("idShortPath", $"{submodel.IdShort}.{idShortPath}")); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{idShortPath}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var output = _submodelService.CreateSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath, first, body); + + return CreatedAtAction("PostSubmodelElementByPathSubmodelRepo", output); + } + + /// + /// Creates a new submodel element + /// + /// Requested submodel element + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Create element as first one in list + /// Submodel element created successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request. + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPost] + [Route("submodels/{submodelIdentifier}/submodel-elements")] + [ValidateModelState] + [SwaggerOperation("PostSubmodelElementSubmodelRepo")] + [SwaggerResponse(statusCode: 201, type: typeof(ISubmodelElement), description: "Submodel element created successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 409, type: typeof(Result), + description: + "Conflict, a resource which shall be created exists already. Might be thrown if a Submodel or SubmodelElement with the same ShortId is contained in a POST request.")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PostSubmodelElementSubmodelRepo([FromBody] ISubmodelElement? body, + [FromRoute][Required] string submodelIdentifier, + bool first) + { + if (body == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + _logger.LogInformation($"Received request to create a new submodel element in the submodel with id {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{body.IdShort}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + var output = _submodelService.CreateSubmodelElement(decodedSubmodelIdentifier, body, first); + + return CreatedAtAction("PostSubmodelElementSubmodelRepo", output); + } + + + /// + /// Updates an existing Submodel + /// + /// Submodel object + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// Submodel updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("PutSubmodelById")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PutSubmodelById([FromBody] Submodel? body, [FromRoute][Required] string submodelIdentifier) + { + if (body == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received request to replace a submodel {decodedSubmodelIdentifier}"); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + _submodelService.ReplaceSubmodelById(decodedSubmodelIdentifier, body); + + return NoContent(); + } + + /// + /// Updates an existing submodel element at a specified path within submodel elements hierarchy + /// + /// Requested submodel element + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// Determines the structural depth of the respective resource content + /// Submodel element updated successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// Unauthorized, e.g. the server refused the authorization attempt. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("PutSubmodelElementByPathSubmodelRepo")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request, e.g. the request parameters of the format of the request body is wrong.")] + [SwaggerResponse(statusCode: 401, type: typeof(Result), description: "Unauthorized, e.g. the server refused the authorization attempt.")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] public virtual IActionResult PutSubmodelElementByPathSubmodelRepo([FromBody] ISubmodelElement? body, - [FromRoute] [Required] string submodelIdentifier, - [FromRoute] [Required] string idShortPath, - [FromQuery] LevelEnum level) + [FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath, + [FromQuery] string? level) { if (body == null) { throw new NotAllowed($"Cannot proceed as {nameof(body)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - - _logger.LogInformation($"Received request to replace a submodel element at {idShortPath} deom the submodel with id {decodedSubmodelIdentifier}."); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - if (!Program.noSecurity) - { - var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); - var claimsList = new List(User.Claims) {new Claim("IdShortPath", $"{submodel.IdShort}.{body.IdShort}")}; - var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); - var principal = new System.Security.Principal.GenericPrincipal(identity, null); - var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; - if (!authResult.Succeeded) - { - throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); - } - } - - _submodelService.ReplaceSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath, body); - - return NoContent(); - } - - /// - /// Uploads file content to an existing submodel element at a specified path within submodel elements hierarchy - /// - /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) - /// IdShort path to the submodel element (dot-separated) - /// File to upload - /// Submodel element updated successfully - /// Bad Request - /// Not Found - /// Default error handling for unmentioned status codes - [HttpPut] - [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] - [ValidateModelState] - [SwaggerOperation("PutFileByPathSubmodelRepo")] - [SwaggerResponse(statusCode: 204, type: typeof(Result), description: "Submodel element updated successfully")] - [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request")] - [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] - [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult PutFileByPathSubmodelRepo([FromRoute] [Required] string submodelIdentifier, [FromRoute] string? idShortPath, IFormFile? file) - { - if (idShortPath == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(idShortPath)} is null"); - } - - var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); - if (decodedSubmodelIdentifier == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); - } - - var stream = new MemoryStream(); - file?.CopyTo(stream); - var fileName = file?.FileName; - var contentType = file?.ContentType; - if (fileName == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(fileName)} is null"); - } - - if (contentType == null) - { - throw new NotAllowed($"Cannot proceed as {nameof(contentType)} is null"); - } - - _submodelService.ReplaceFileByPath(decodedSubmodelIdentifier, idShortPath, fileName, contentType, stream); - - return NoContent(); - } -} \ No newline at end of file + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _logger.LogInformation($"Received request to replace a submodel element at {idShortPath} deom the submodel with id {decodedSubmodelIdentifier}."); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + if (!Program.noSecurity) + { + var submodel = _submodelService.GetSubmodelById(decodedSubmodelIdentifier); + var claimsList = new List(User.Claims) { new("IdShortPath", $"{submodel.IdShort}.{body.IdShort}") }; + var identity = new ClaimsIdentity(claimsList, "AasSecurityAuth"); + var principal = new System.Security.Principal.GenericPrincipal(identity, null); + var authResult = _authorizationService.AuthorizeAsync(principal, submodel, "SecurityPolicy").Result; + if (!authResult.Succeeded) + { + throw new NotAllowed(authResult.Failure.FailureReasons.FirstOrDefault()?.Message ?? string.Empty); + } + } + + _submodelService.ReplaceSubmodelElementByPath(decodedSubmodelIdentifier, idShortPath, body); + + return NoContent(); + } + +/// + /// Uploads file content to an existing submodel element at a specified path within submodel elements hierarchy + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated) + /// File to upload + /// Submodel element updated successfully + /// Bad Request + /// Not Found + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/attachment")] + [ValidateModelState] + [SwaggerOperation("PutFileByPathSubmodelRepo")] + [SwaggerResponse(statusCode: 204, type: typeof(Result), description: "Submodel element updated successfully")] + [SwaggerResponse(statusCode: 400, type: typeof(Result), description: "Bad Request")] + [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult PutFileByPathSubmodelRepo([FromRoute] [Required] string submodelIdentifier, [FromRoute] string? idShortPath, IFormFile? file) + { + if (idShortPath == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(idShortPath)} is null"); + } + + var decodedSubmodelIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + if (decodedSubmodelIdentifier == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(decodedSubmodelIdentifier)} is null"); + } + + var stream = new MemoryStream(); + file?.CopyTo(stream); + var fileName = file?.FileName; + var contentType = file?.ContentType; + if (fileName == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(fileName)} is null"); + } + + if (contentType == null) + { + throw new NotAllowed($"Cannot proceed as {nameof(contentType)} is null"); + } + + _submodelService.ReplaceFileByPath(decodedSubmodelIdentifier, idShortPath, fileName, contentType, stream); + + return NoContent(); + } +} diff --git a/src/IO.Swagger.Lib.V3/Exceptions/InvalidSerializationModifierException.cs b/src/IO.Swagger.Lib.V3/Exceptions/InvalidSerializationModifierException.cs index 34db59397..f94e92729 100644 --- a/src/IO.Swagger.Lib.V3/Exceptions/InvalidSerializationModifierException.cs +++ b/src/IO.Swagger.Lib.V3/Exceptions/InvalidSerializationModifierException.cs @@ -21,5 +21,15 @@ public class InvalidSerializationModifierException : Exception { } + + public InvalidSerializationModifierException(string modifier) : base($"Invalid serialization modifier {modifier}.") + { + + } + + public InvalidSerializationModifierException() : base($"Invalid serialization modifier combination Level = Deeep & Content = Reference.") + { + + } } } diff --git a/src/IO.Swagger.Lib.V3/Exceptions/NoIdentifierException.cs b/src/IO.Swagger.Lib.V3/Exceptions/NoIdentifierException.cs index 4fe8c4fb5..16a934d8a 100644 --- a/src/IO.Swagger.Lib.V3/Exceptions/NoIdentifierException.cs +++ b/src/IO.Swagger.Lib.V3/Exceptions/NoIdentifierException.cs @@ -21,7 +21,7 @@ namespace IO.Swagger.Lib.V3.Exceptions { public class NoIdentifierException : Exception { - public NoIdentifierException(string fieldName) : base($"No indentier found in {fieldName}.") + public NoIdentifierException(string fieldName) : base($"No identifier found in {fieldName}.") { } diff --git a/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs b/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs index fae1fbabf..62de3a8c5 100644 --- a/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs +++ b/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs @@ -189,9 +189,6 @@ private void GetSerializationMidifiersFromRequest(HttpRequest request, out Level return output; } - // Deserialize submodelElements - var valueMetadata = ISubmodelElementMetadatListFrom(obj["submodelElements"]); - var jsonString = obj.ToString(); // Deserialize using System.Text.Json @@ -205,19 +202,18 @@ private void GetSerializationMidifiersFromRequest(HttpRequest request, out Level if (submodelMetadata != null) { output = new SubmodelMetadata( - submodelMetadata.id, - submodelMetadata.extensions, - submodelMetadata.category, - submodelMetadata.idShort, - submodelMetadata.displayName, - submodelMetadata.description, - submodelMetadata.administration, - submodelMetadata.kind, - submodelMetadata.semanticId, - submodelMetadata.supplementalSemanticIds, - submodelMetadata.qualifiers, - submodelMetadata.embeddedDataSpecifications, - valueMetadata); + submodelMetadata.Id, + submodelMetadata.Extensions, + submodelMetadata.Category, + submodelMetadata.IdShort, + submodelMetadata.DisplayName, + submodelMetadata.Description, + submodelMetadata.Administration, + submodelMetadata.Kind, + submodelMetadata.SemanticId, + submodelMetadata.SupplementalSemanticIds, + submodelMetadata.Qualifiers, + submodelMetadata.EmbeddedDataSpecifications); } return output; @@ -273,15 +269,13 @@ private void GetSerializationMidifiersFromRequest(HttpRequest request, out Level } case "annotatedrelationshipelement": { - var valueMetadata = ISubmodelElementMetadatListFrom(obj["annotations"]); - node["annotations"] = null; var annotatedRelElement = JsonSerializer.Deserialize(node.ToJsonString(), serializerOptions); - output = new AnnotatedRelationshipElementMetadata(annotatedRelElement.extensions, annotatedRelElement.category, annotatedRelElement.idShort, - annotatedRelElement.displayName, annotatedRelElement.description, annotatedRelElement.semanticId, - annotatedRelElement.supplementalSemanticIds, annotatedRelElement.qualifiers, - annotatedRelElement.embeddedDataSpecifications, valueMetadata); + output = new AnnotatedRelationshipElementMetadata(annotatedRelElement.Extensions, annotatedRelElement.Category, annotatedRelElement.IdShort, + annotatedRelElement.DisplayName, annotatedRelElement.Description, annotatedRelElement.SemanticId, + annotatedRelElement.SupplementalSemanticIds, annotatedRelElement.Qualifiers, + annotatedRelElement.EmbeddedDataSpecifications); break; } case "basiceventelement": @@ -292,13 +286,10 @@ private void GetSerializationMidifiersFromRequest(HttpRequest request, out Level break; case "entity": { - var valueMetadata = ISubmodelElementMetadatListFrom(obj["statements"]); - - node["statements"] = null; var entity = JsonSerializer.Deserialize(node.ToJsonString(), serializerOptions); - output = new EntityMetadata(entity.entityType, entity.extensions, entity.category, entity.idShort, entity.displayName, entity.description, - entity.semanticId, entity.supplementalSemanticIds, entity.qualifiers, entity.embeddedDataSpecifications, valueMetadata); + output = new EntityMetadata(entity.EntityType, entity.Extensions, entity.Category, entity.IdShort, entity.DisplayName, entity.Description, + entity.SemanticId, entity.SupplementalSemanticIds, entity.Qualifiers, entity.EmbeddedDataSpecifications); break; } case "file": @@ -321,28 +312,21 @@ private void GetSerializationMidifiersFromRequest(HttpRequest request, out Level break; case "submodelelementcollection": { - var valueMetadata = ISubmodelElementMetadatListFrom(obj["value"]); - - node["value"] = null; var smeColl = JsonSerializer.Deserialize(node.ToJsonString(), serializerOptions); - output = new SubmodelElementCollectionMetadata(smeColl.extensions, smeColl.category, smeColl.idShort, smeColl.displayName, smeColl.description, - smeColl.semanticId, smeColl.supplementalSemanticIds, smeColl.qualifiers, smeColl.embeddedDataSpecifications, - valueMetadata); + output = new SubmodelElementCollectionMetadata(smeColl.Extensions, smeColl.Category, smeColl.IdShort, smeColl.DisplayName, smeColl.Description, + smeColl.SemanticId, smeColl.SupplementalSemanticIds, smeColl.Qualifiers, smeColl.EmbeddedDataSpecifications); break; } case "submodelelementlist": { - var valueMetadata = ISubmodelElementMetadatListFrom(obj["value"]); - - node["value"] = null; var smeList = JsonSerializer.Deserialize(node.ToJsonString(), serializerOptions); - output = new SubmodelElementListMetadata(smeList.typeValueListElement, smeList.extensions, smeList.category, smeList.idShort, smeList.displayName, - smeList.description, smeList.semanticId, smeList.supplementalSemanticIds, smeList.qualifiers, - smeList.embeddedDataSpecifications, smeList.orderRelevant, smeList.semanticIdListElement, - smeList.valueTypeListElement, valueMetadata); + output = new SubmodelElementListMetadata(smeList.TypeValueListElement, smeList.Extensions, smeList.Category, smeList.IdShort, smeList.DisplayName, + smeList.Description, smeList.SemanticId, smeList.SupplementalSemanticIds, smeList.Qualifiers, + smeList.EmbeddedDataSpecifications, smeList.OrderRelevant, smeList.SemanticIdListElement, + smeList.ValueTypeListElement); break; } } diff --git a/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs b/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs index 971b707f1..3b9835479 100644 --- a/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs +++ b/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs @@ -34,6 +34,10 @@ using System.Text.Json; using System.Text.Json.Nodes; using System.Threading.Tasks; +using DataTransferObjects.MetadataDTOs; +using IO.Swagger.Lib.V3.SerializationModifiers.Mappers.MetadataMappers; +using IO.Swagger.Lib.V3.Models; +using System.Text.Json.Serialization; namespace IO.Swagger.Lib.V3.Formatters { @@ -98,6 +102,18 @@ public override bool CanWriteResult(OutputFormatterCanWriteContext context) { return base.CanWriteResult(context); } + if (typeof(IMetadataDTO).IsAssignableFrom(context.ObjectType)) + { + return base.CanWriteResult(context); + } + if (typeof(MetadataPagedResult).IsAssignableFrom(context.ObjectType)) + { + return base.CanWriteResult(context); + } + if (typeof(PathPagedResult).IsAssignableFrom(context.ObjectType)) + { + return base.CanWriteResult(context); + } else return false; } @@ -217,6 +233,53 @@ public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context) jsonArray.WriteTo(writer); writer.FlushAsync().GetAwaiter().GetResult(); } + else if(typeof(IMetadataDTO).IsAssignableFrom(context.ObjectType)) + { + JsonNode? json = MetadataJsonSerializer.ToJsonObject((IMetadataDTO)context.Object); + var writer = new Utf8JsonWriter(response.Body); + json.WriteTo(writer); + writer.FlushAsync().GetAwaiter().GetResult(); + } + else if (typeof(MetadataPagedResult).IsAssignableFrom(context.ObjectType)) + { + var jsonArray = new JsonArray(); + string cursor = null; + if (context.Object is MetadataPagedResult pagedResult) + { + cursor = pagedResult.paging_metadata.cursor; + foreach (var item in pagedResult.result) + { + var json = MetadataJsonSerializer.ToJsonObject(item); + jsonArray.Add(json); + } + } + JsonObject jsonNode = new JsonObject(); + jsonNode["result"] = jsonArray; + var pagingMetadata = new JsonObject(); + if (cursor != null) + { + pagingMetadata["cursor"] = cursor; + } + jsonNode["paging_metadata"] = pagingMetadata; + var writer = new Utf8JsonWriter(response.Body); + jsonNode.WriteTo(writer); + writer.FlushAsync().GetAwaiter().GetResult(); + } + else if (typeof(PathPagedResult).IsAssignableFrom(context.ObjectType)) + { + JsonNode jsonNode = null; + var options = new JsonSerializerOptions + { + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull + }; + if (context.Object is PathPagedResult pagedResult) + { + jsonNode = JsonSerializer.SerializeToNode(pagedResult, options); + } + var writer = new Utf8JsonWriter(response.Body); + jsonNode.WriteTo(writer); + writer.FlushAsync().GetAwaiter().GetResult(); + } else if (typeof(PagedResult).IsAssignableFrom(context.ObjectType)) { var jsonArray = new JsonArray(); diff --git a/src/IO.Swagger.Lib.V3/Interfaces/IGenerateSerializationService.cs b/src/IO.Swagger.Lib.V3/Interfaces/IGenerateSerializationService.cs index 9449daf8a..9b9e301fd 100644 --- a/src/IO.Swagger.Lib.V3/Interfaces/IGenerateSerializationService.cs +++ b/src/IO.Swagger.Lib.V3/Interfaces/IGenerateSerializationService.cs @@ -26,5 +26,5 @@ public interface IGenerateSerializationService /// Optional list of AAS IDs to include in the serialized output. /// Optional list of Submodel IDs to include in the serialized output. /// An object containing the specified AAS and Submodels. - Environment GenerateSerializationByIds(List? aasIds = null, List? submodelIds = null); + Environment GenerateSerializationByIds(List? aasIds = null, List? submodelIds = null, bool? includeCD = false); } \ No newline at end of file diff --git a/src/IO.Swagger.Lib.V3/Interfaces/IPathModifierService.cs b/src/IO.Swagger.Lib.V3/Interfaces/IPathModifierService.cs index 66d6e0e8c..dd357c1bb 100644 --- a/src/IO.Swagger.Lib.V3/Interfaces/IPathModifierService.cs +++ b/src/IO.Swagger.Lib.V3/Interfaces/IPathModifierService.cs @@ -32,12 +32,13 @@ public interface IPathModifierService /// /// The list of submodels to transform. /// A list of lists of strings representing the transformed paths. - List> ToIdShortPath(List submodelList); + List ToIdShortPath(List submodelList); /// /// Transforms the paths of a list of submodel elements into short ID paths. /// /// The list of submodel elements to transform. /// A list of lists of strings representing the transformed paths. - List> ToIdShortPath(List submodelElementList); + //List> ToIdShortPath(List submodelElementList); + List ToIdShortPath(List submodelElementList); } diff --git a/src/IO.Swagger.Lib.V3/Interfaces/IValidateSerializationModifierService.cs b/src/IO.Swagger.Lib.V3/Interfaces/IValidateSerializationModifierService.cs new file mode 100644 index 000000000..3abd39330 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Interfaces/IValidateSerializationModifierService.cs @@ -0,0 +1,22 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +namespace IO.Swagger.Lib.V3.Interfaces; + +using IO.Swagger.Models; + +public interface IValidateSerializationModifierService +{ + LevelEnum ValidateLevel(string level); + ExtentEnum ValidateExtent(string extent); +} diff --git a/src/IO.Swagger.Lib.V3/Middleware/ExceptionMiddleware.cs b/src/IO.Swagger.Lib.V3/Middleware/ExceptionMiddleware.cs index 99f8da881..150ee4797 100644 --- a/src/IO.Swagger.Lib.V3/Middleware/ExceptionMiddleware.cs +++ b/src/IO.Swagger.Lib.V3/Middleware/ExceptionMiddleware.cs @@ -113,7 +113,9 @@ private async Task HandleExceptionAsync(HttpContext context, Exception exception case OperationVariableException: case JsonDeserializationException: case Base64UrlDecoderException: - { + case InvalidOperationException: + case InvalidSerializationModifierException: + { context.Response.StatusCode = (int)HttpStatusCode.BadRequest; message.Code = HttpStatusCode.BadRequest.ToString(); message.Text = exception.Message; @@ -121,15 +123,6 @@ private async Task HandleExceptionAsync(HttpContext context, Exception exception message.MessageType = MessageTypeEnum.Error; break; } - case InvalidSerializationModifierException: - { - context.Response.StatusCode = (int)HttpStatusCode.MethodNotAllowed; - message.Code = HttpStatusCode.MethodNotAllowed.ToString(); - message.Text = exception.Message; - message.Timestamp = currentDateTime; - message.MessageType = MessageTypeEnum.Error; - break; - } case Exceptions.NotImplementedException: { context.Response.StatusCode = (int)HttpStatusCode.NotImplemented; diff --git a/src/IO.Swagger.Lib.V3/Models/IServiceDescription.cs b/src/IO.Swagger.Lib.V3/Models/IServiceDescription.cs index 6270c6e6d..154d251fe 100644 --- a/src/IO.Swagger.Lib.V3/Models/IServiceDescription.cs +++ b/src/IO.Swagger.Lib.V3/Models/IServiceDescription.cs @@ -23,7 +23,7 @@ public interface IServiceDescription /// /// Gets or Sets Profiles /// - List? Profiles { get; set; } + List? profiles { get; set; } /// /// Returns the string presentation of the object diff --git a/src/IO.Swagger.Lib.V3/Models/OperationRequestValueOnly.cs b/src/IO.Swagger.Lib.V3/Models/OperationRequestValueOnly.cs new file mode 100644 index 000000000..5df1e855d --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/OperationRequestValueOnly.cs @@ -0,0 +1,151 @@ +/* + * DotAAS Part 2 | HTTP/REST | Asset Administration Shell Repository Service Specification + * + * The Full Profile of the Asset Administration Shell Repository Service Specification as part of the [Specification of the Asset Administration Shell: Part 2](http://industrialdigitaltwin.org/en/content-hub). Publisher: Industrial Digital Twin Association (IDTA) April 2023 + * + * OpenAPI spec version: V3.0.3_SSP-001 + * Contact: info@idtwin.org + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class OperationRequestValueOnly : IEquatable + { + /// + /// Gets or Sets InoutputArguments + /// + + [DataMember(Name="inoutputArguments")] + public ValueOnly InoutputArguments { get; set; } + + /// + /// Gets or Sets InputArguments + /// + + [DataMember(Name="inputArguments")] + public ValueOnly InputArguments { get; set; } + + /// + /// Gets or Sets ClientTimeoutDuration + /// + [Required] + [RegularExpression("/^-?P((([0-9]+Y([0-9]+M)?([0-9]+D)?|([0-9]+M)([0-9]+D)?|([0-9]+D))(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S)))?)|(T(([0-9]+H)([0-9]+M)?([0-9]+(\\.[0-9]+)?S)?|([0-9]+M)([0-9]+(\\.[0-9]+)?S)?|([0-9]+(\\.[0-9]+)?S))))$/")] + [DataMember(Name="clientTimeoutDuration")] + public string ClientTimeoutDuration { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class OperationRequestValueOnly {\n"); + sb.Append(" InoutputArguments: ").Append(InoutputArguments).Append("\n"); + sb.Append(" InputArguments: ").Append(InputArguments).Append("\n"); + sb.Append(" ClientTimeoutDuration: ").Append(ClientTimeoutDuration).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((OperationRequestValueOnly)obj); + } + + /// + /// Returns true if OperationRequestValueOnly instances are equal + /// + /// Instance of OperationRequestValueOnly to be compared + /// Boolean + public bool Equals(OperationRequestValueOnly other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + InoutputArguments == other.InoutputArguments || + InoutputArguments != null && + InoutputArguments.Equals(other.InoutputArguments) + ) && + ( + InputArguments == other.InputArguments || + InputArguments != null && + InputArguments.Equals(other.InputArguments) + ) && + ( + ClientTimeoutDuration == other.ClientTimeoutDuration || + ClientTimeoutDuration != null && + ClientTimeoutDuration.Equals(other.ClientTimeoutDuration) + ); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (InoutputArguments != null) + hashCode = hashCode * 59 + InoutputArguments.GetHashCode(); + if (InputArguments != null) + hashCode = hashCode * 59 + InputArguments.GetHashCode(); + if (ClientTimeoutDuration != null) + hashCode = hashCode * 59 + ClientTimeoutDuration.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(OperationRequestValueOnly left, OperationRequestValueOnly right) + { + return Equals(left, right); + } + + public static bool operator !=(OperationRequestValueOnly left, OperationRequestValueOnly right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger.Lib.V3/Models/OperationResultValueOnly.cs b/src/IO.Swagger.Lib.V3/Models/OperationResultValueOnly.cs new file mode 100644 index 000000000..a47f22124 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/OperationResultValueOnly.cs @@ -0,0 +1,135 @@ +/* + * DotAAS Part 2 | HTTP/REST | Asset Administration Shell Repository Service Specification + * + * The Full Profile of the Asset Administration Shell Repository Service Specification as part of the [Specification of the Asset Administration Shell: Part 2](http://industrialdigitaltwin.org/en/content-hub). Publisher: Industrial Digital Twin Association (IDTA) April 2023 + * + * OpenAPI spec version: V3.0.3_SSP-001 + * Contact: info@idtwin.org + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class OperationResultValueOnly : BaseOperationResult, IEquatable + { + /// + /// Gets or Sets InoutputArguments + /// + + [DataMember(Name="inoutputArguments")] + public ValueOnly InoutputArguments { get; set; } + + /// + /// Gets or Sets OutputArguments + /// + + [DataMember(Name="outputArguments")] + public ValueOnly OutputArguments { get; set; } + + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class OperationResultValueOnly {\n"); + sb.Append(" InoutputArguments: ").Append(InoutputArguments).Append("\n"); + sb.Append(" OutputArguments: ").Append(OutputArguments).Append("\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public new string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((OperationResultValueOnly)obj); + } + + /// + /// Returns true if OperationResultValueOnly instances are equal + /// + /// Instance of OperationResultValueOnly to be compared + /// Boolean + public bool Equals(OperationResultValueOnly other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + InoutputArguments == other.InoutputArguments || + InoutputArguments != null && + InoutputArguments.Equals(other.InoutputArguments) + ) && + ( + OutputArguments == other.OutputArguments || + OutputArguments != null && + OutputArguments.Equals(other.OutputArguments) + ) && base.Equals(other); + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + if (InoutputArguments != null) + hashCode = hashCode * 59 + InoutputArguments.GetHashCode(); + if (OutputArguments != null) + hashCode = hashCode * 59 + OutputArguments.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(OperationResultValueOnly left, OperationResultValueOnly right) + { + return Equals(left, right); + } + + public static bool operator !=(OperationResultValueOnly left, OperationResultValueOnly right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger.Lib.V3/Models/PathPagedResult.cs b/src/IO.Swagger.Lib.V3/Models/PathPagedResult.cs index a1809305c..5f5cb2622 100644 --- a/src/IO.Swagger.Lib.V3/Models/PathPagedResult.cs +++ b/src/IO.Swagger.Lib.V3/Models/PathPagedResult.cs @@ -18,7 +18,7 @@ namespace IO.Swagger.Lib.V3.Models { public class PathPagedResult { - public List>? result { get; set; } + public List? result { get; set; } public PagedResultPagingMetadata? paging_metadata { get; set; } } diff --git a/src/IO.Swagger.Lib.V3/Models/ServiceDescription.cs b/src/IO.Swagger.Lib.V3/Models/ServiceDescription.cs index 1c35f2deb..8615b935c 100644 --- a/src/IO.Swagger.Lib.V3/Models/ServiceDescription.cs +++ b/src/IO.Swagger.Lib.V3/Models/ServiceDescription.cs @@ -39,14 +39,14 @@ public partial class ServiceDescription : IEquatable, IServi { /// [DataMember(Name = "profiles")] - public List? Profiles { get; set; } + public List? profiles { get; set; } /// public override string ToString() { var sb = new StringBuilder(); sb.Append("class ServiceDescription {\n"); - sb.Append(" Profiles: ").Append(Profiles).Append('\n'); + sb.Append(" Profiles: ").Append(profiles).Append('\n'); sb.Append("}\n"); return sb.ToString(); } @@ -56,12 +56,11 @@ public override string ToString() public string ToJson() => JsonSerializer.Serialize(this, Options); private static readonly JsonSerializerOptions Options = new() - { - WriteIndented = true, - DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, - //Converters = {new JsonStringEnumConverter()} - Converters = {new ServiceProfileEnumValueConverter()} - }; + { + WriteIndented = true, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + Converters = { new ServiceProfileEnumValueConverter() } + }; /// @@ -95,9 +94,9 @@ public bool Equals(ServiceDescription? other) } return - other.Profiles != null && (Profiles == other.Profiles || - (Profiles != null && - Profiles.SequenceEqual(other.Profiles))); + other.profiles != null && (profiles == other.profiles || + (profiles != null && + profiles.SequenceEqual(other.profiles))); } @@ -108,9 +107,9 @@ public override int GetHashCode() { var hashCode = 41; // Suitable nullity checks etc., of course :) - if (Profiles != null) + if (profiles != null) { - hashCode = (hashCode * 59) + Profiles.GetHashCode(); + hashCode = (hashCode * 59) + profiles.GetHashCode(); } return hashCode; diff --git a/src/IO.Swagger.Lib.V3/Models/ValueOnly.cs b/src/IO.Swagger.Lib.V3/Models/ValueOnly.cs new file mode 100644 index 000000000..339be4035 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/ValueOnly.cs @@ -0,0 +1,105 @@ +/* + * DotAAS Part 2 | HTTP/REST | Asset Administration Shell Repository Service Specification + * + * The Full Profile of the Asset Administration Shell Repository Service Specification as part of the [Specification of the Asset Administration Shell: Part 2](http://industrialdigitaltwin.org/en/content-hub). Publisher: Industrial Digital Twin Association (IDTA) April 2023 + * + * OpenAPI spec version: V3.0.3_SSP-001 + * Contact: info@idtwin.org + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.Linq; +using System.IO; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel.DataAnnotations; +using System.Runtime.Serialization; +using Newtonsoft.Json; + +namespace IO.Swagger.Models +{ + /// + /// The ValueOnly serialization (patternProperties and propertyNames will be supported probably with OpenApi 3.1). For the full description of the generic JSON validation schema see the ValueOnly-Serialization as defined in the 'Specification of the Asset Administration Shell - Part 2'. + /// + [DataContract] + public partial class ValueOnly : IEquatable + { + /// + /// Returns the string presentation of the object + /// + /// String presentation of the object + public override string ToString() + { + var sb = new StringBuilder(); + sb.Append("class ValueOnly {\n"); + sb.Append("}\n"); + return sb.ToString(); + } + + /// + /// Returns the JSON string presentation of the object + /// + /// JSON string presentation of the object + public string ToJson() + { + return JsonConvert.SerializeObject(this, Formatting.Indented); + } + + /// + /// Returns true if objects are equal + /// + /// Object to be compared + /// Boolean + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + return obj.GetType() == GetType() && Equals((ValueOnly)obj); + } + + /// + /// Returns true if ValueOnly instances are equal + /// + /// Instance of ValueOnly to be compared + /// Boolean + public bool Equals(ValueOnly other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return false; + } + + /// + /// Gets the hash code + /// + /// Hash code + public override int GetHashCode() + { + unchecked // Overflow is fine, just wrap + { + var hashCode = 41; + // Suitable nullity checks etc, of course :) + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(ValueOnly left, ValueOnly right) + { + return Equals(left, right); + } + + public static bool operator !=(ValueOnly left, ValueOnly right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtent/LevelExtentModifierContext.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtent/LevelExtentModifierContext.cs index 8fda929d2..8b1aae6e3 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtent/LevelExtentModifierContext.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtent/LevelExtentModifierContext.cs @@ -25,12 +25,15 @@ public class LevelExtentModifierContext public bool IsRoot { get; set; } - public LevelExtentModifierContext(LevelEnum level, ExtentEnum extent) + public bool IsGetAllSmes { get; set; } + + public LevelExtentModifierContext(LevelEnum level, ExtentEnum extent, bool isGetAllSme = false) { Level = level; Extent = extent; IsRoot = true; IncludeChildren = true; + IsGetAllSmes = isGetAllSme; } } } diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtent/LevelExtentTransformer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtent/LevelExtentTransformer.cs index 81a85f58e..cd9b9088c 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtent/LevelExtentTransformer.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtent/LevelExtentTransformer.cs @@ -16,525 +16,421 @@ using System.Collections.Generic; using static AasCore.Aas3_0.Visitation; -namespace IO.Swagger.Lib.V3.SerializationModifiers.LevelExtent; - -/// -public class LevelExtentTransformer : AbstractTransformerWithContext +namespace IO.Swagger.Lib.V3.SerializationModifiers.LevelExtent { - public override IClass TransformAdministrativeInformation(IAdministrativeInformation that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformAnnotatedRelationshipElement(IAnnotatedRelationshipElement that, LevelExtentModifierContext context) + public class LevelExtentTransformer : AbstractTransformerWithContext { - var output = Copying.Deep(that); + public override IClass TransformAdministrativeInformation(IAdministrativeInformation that, LevelExtentModifierContext context) + { + throw new System.NotImplementedException(); + } - context.IsRoot = false; - if (context.IncludeChildren) + public override IClass TransformAnnotatedRelationshipElement(IAnnotatedRelationshipElement that, LevelExtentModifierContext context) { - if (context.Level == LevelEnum.Core) - { - if (that.Annotations == null) - { - return output; - } + var output = Copying.Deep(that); - output.Annotations = new List(); - foreach (var child in that.Annotations) - { - context.IncludeChildren = false; - output.Annotations.Add((IDataElement)Transform(child, context)); - } - } - else + if (output != null) { - if (that.Annotations == null) + context.IsRoot = false; + if (context.IncludeChildren) { - return output; + if (context.Level == LevelEnum.Core) + { + if (that.Annotations != null) + { + output.Annotations = new List(); + foreach (var child in that.Annotations) + { + context.IncludeChildren = false; + output.Annotations.Add((IDataElement)Transform(child, context)); + } + } + } + else + { + if (that.Annotations != null) + { + output.Annotations = new List(); + foreach (var child in that.Annotations) + { + output.Annotations.Add((IDataElement)Transform(child, context)); + } + } + } } - - output.Annotations = new List(); - foreach (var child in that.Annotations) + else { - output.Annotations.Add((IDataElement)Transform(child, context)); + output.Annotations = null; } } - } - else - { - output.Annotations = null; - } - - return output; - } - - public override IClass TransformAssetAdministrationShell(IAssetAdministrationShell that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - public override IClass TransformAssetInformation(IAssetInformation that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformBasicEventElement(IBasicEventElement that, LevelExtentModifierContext context) - { - if (!context.IsRoot) - { - return Copying.Deep(that); + return output; } - if (context.Extent == ExtentEnum.WithBlobValue) + public override IClass TransformAssetAdministrationShell(IAssetAdministrationShell that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Extent", that.GetType().Name); + throw new System.NotImplementedException(); } - if (context.Level == LevelEnum.Core) + public override IClass TransformAssetInformation(IAssetInformation that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Level", that.GetType().Name); + throw new System.NotImplementedException(); } - return Copying.Deep(that); - } - - public override IClass TransformBlob(IBlob that, LevelExtentModifierContext context) - { - if (context is {IsRoot: true, Level: LevelEnum.Core}) + public override IClass TransformBasicEventElement(IBasicEventElement that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Level", that.GetType().Name); + return Copying.Deep(that); } - var output = Copying.Deep(that); - if (context.Extent == ExtentEnum.WithoutBlobValue) + public override IClass TransformBlob(IBlob that, LevelExtentModifierContext context) { - output.Value = null; - } + var output = Copying.Deep(that); + if (context.Extent == ExtentEnum.WithoutBlobValue) + { + output.Value = null; + } - return output; - } + return output; + } - public override IClass TransformCapability(ICapability that, LevelExtentModifierContext context) - { - if (!context.IsRoot) + public override IClass TransformCapability(ICapability that, LevelExtentModifierContext context) { return Copying.Deep(that); } - if (context.Extent == ExtentEnum.WithBlobValue) + public override IClass TransformConceptDescription(IConceptDescription that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Extent", that.GetType().Name); + throw new System.NotImplementedException(); } - if (context.Level == LevelEnum.Core) + public override IClass TransformDataSpecificationIec61360(IDataSpecificationIec61360 that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Level", that.GetType().Name); + throw new System.NotImplementedException(); } - return Copying.Deep(that); - } - - public override IClass TransformConceptDescription(IConceptDescription that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformDataSpecificationIec61360(IDataSpecificationIec61360 that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformEmbeddedDataSpecification(IEmbeddedDataSpecification that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformEntity(IEntity that, LevelExtentModifierContext context) - { - var output = Copying.Deep(that); + public override IClass TransformEmbeddedDataSpecification(IEmbeddedDataSpecification that, LevelExtentModifierContext context) + { + throw new System.NotImplementedException(); + } - context.IsRoot = false; - if (context.IncludeChildren) + public override IClass TransformEntity(IEntity that, LevelExtentModifierContext context) { - if (context.Level == LevelEnum.Core) - { - if (that.Statements == null) - { - return output; - } + var output = Copying.Deep(that); - output.Statements = new List(); - foreach (var child in that.Statements) - { - context.IncludeChildren = false; - output.Statements.Add((ISubmodelElement)Transform(child, context)); - } - } - else + if (output != null) { - if (that.Statements == null) + context.IsRoot = false; + if (context.IncludeChildren) { - return output; + if (context.Level == LevelEnum.Core) + { + if (that.Statements != null) + { + output.Statements = new List(); + foreach (var child in that.Statements) + { + context.IncludeChildren = false; + output.Statements.Add((ISubmodelElement)Transform(child, context)); + } + } + } + else + { + if (that.Statements != null) + { + output.Statements = new List(); + foreach (var child in that.Statements) + { + output.Statements.Add((ISubmodelElement)Transform(child, context)); + } + } + } } - - output.Statements = new List(); - foreach (var child in that.Statements) + else { - output.Statements.Add((ISubmodelElement)Transform(child, context)); + output.Statements = null; } } + + return output; } - else + + public override IClass TransformEnvironment(IEnvironment that, LevelExtentModifierContext context) { - output.Statements = null; + throw new System.NotImplementedException(); } - return output; - } - - public override IClass TransformEnvironment(IEnvironment that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformEventPayload(IEventPayload that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); + public override IClass TransformEventPayload(IEventPayload that, LevelExtentModifierContext context) + { + throw new System.NotImplementedException(); + } - public override IClass TransformExtension(IExtension that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); + public override IClass TransformExtension(IExtension that, LevelExtentModifierContext context) + { + throw new System.NotImplementedException(); + } - public override IClass TransformFile(IFile that, LevelExtentModifierContext context) - { - if (!context.IsRoot) + public override IClass TransformFile(IFile that, LevelExtentModifierContext context) { return Copying.Deep(that); } - if (context.Extent == ExtentEnum.WithBlobValue) + public override IClass TransformKey(IKey that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Extent", that.GetType().Name); + throw new System.NotImplementedException(); } - if (context.Level == LevelEnum.Core) + public override IClass TransformLangStringDefinitionTypeIec61360(ILangStringDefinitionTypeIec61360 that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Level", that.GetType().Name); + throw new System.NotImplementedException(); } - return Copying.Deep(that); - } - - public override IClass TransformKey(IKey that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformLangStringDefinitionTypeIec61360(ILangStringDefinitionTypeIec61360 that, LevelExtentModifierContext context) => - throw new System.NotImplementedException(); - - public override IClass TransformLangStringNameType(ILangStringNameType that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformLangStringPreferredNameTypeIec61360(ILangStringPreferredNameTypeIec61360 that, LevelExtentModifierContext context) => - throw new System.NotImplementedException(); - - public override IClass TransformLangStringShortNameTypeIec61360(ILangStringShortNameTypeIec61360 that, LevelExtentModifierContext context) => - throw new System.NotImplementedException(); - - public override IClass TransformLangStringTextType(ILangStringTextType that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformLevelType(ILevelType that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformMultiLanguageProperty(IMultiLanguageProperty that, LevelExtentModifierContext context) - { - if (!context.IsRoot) + public override IClass TransformLangStringNameType(ILangStringNameType that, LevelExtentModifierContext context) { - return Copying.Deep(that); + throw new System.NotImplementedException(); } - if (context.Extent == ExtentEnum.WithBlobValue) + public override IClass TransformLangStringPreferredNameTypeIec61360(ILangStringPreferredNameTypeIec61360 that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Extent", that.GetType().Name); + throw new System.NotImplementedException(); } - if (context.Level == LevelEnum.Core) + public override IClass TransformLangStringShortNameTypeIec61360(ILangStringShortNameTypeIec61360 that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Level", that.GetType().Name); + throw new System.NotImplementedException(); } - return Copying.Deep(that); - } - - public override IClass TransformOperation(IOperation that, LevelExtentModifierContext context) - { - var output = Copying.Deep(that); - - context.IsRoot = false; - if (context.Level == LevelEnum.Core) + public override IClass TransformLangStringTextType(ILangStringTextType that, LevelExtentModifierContext context) { - if (that.InputVariables != null) - { - output.InputVariables = new List(); - foreach (var child in that.InputVariables) - { - context.IncludeChildren = false; - output.InputVariables.Add((IOperationVariable)Transform(child, context)); - } - } - - if (that.OutputVariables != null) - { - output.OutputVariables = new List(); - foreach (var child in that.OutputVariables) - { - context.IncludeChildren = false; - output.OutputVariables.Add((IOperationVariable)Transform(child, context)); - } - } + throw new System.NotImplementedException(); + } - if (that.InoutputVariables == null) - { - return output; - } + public override IClass TransformLevelType(ILevelType that, LevelExtentModifierContext context) + { + throw new System.NotImplementedException(); + } - { - output.InoutputVariables = new List(); - foreach (var child in that.InoutputVariables) - { - context.IncludeChildren = false; - output.OutputVariables?.Add((IOperationVariable)Transform(child, context)); - } - } + public override IClass TransformMultiLanguageProperty(IMultiLanguageProperty that, LevelExtentModifierContext context) + { + return Copying.Deep(that); } - else + + public override IClass TransformOperation(IOperation that, LevelExtentModifierContext context) { - if (that.InputVariables != null) + var output = Copying.Deep(that); + + if (output != null) { - output.InputVariables = new List(); - foreach (var child in that.InputVariables) + context.IsRoot = false; + if (that.InputVariables != null) { - output.InputVariables.Add((IOperationVariable)Transform(child, context)); + output.InputVariables = new List(); + foreach (var child in that.InputVariables) + { + output.InputVariables.Add((IOperationVariable)Transform(child, context)); + } } - } - if (that.OutputVariables != null) - { - output.OutputVariables = new List(); - foreach (var child in that.OutputVariables) + if (that.OutputVariables != null) { - output.OutputVariables.Add((IOperationVariable)Transform(child, context)); + output.OutputVariables = new List(); + foreach (var child in that.OutputVariables) + { + output.OutputVariables.Add((IOperationVariable)Transform(child, context)); + } } - } - - if (that.InoutputVariables == null) - { - return output; - } - { - output.InoutputVariables = new List(); - foreach (var child in that.InoutputVariables) + if (that.InoutputVariables != null) { - output.OutputVariables?.Add((IOperationVariable)Transform(child, context)); + output.InoutputVariables = new List(); + foreach (var child in that.InoutputVariables) + { + output.InoutputVariables.Add((IOperationVariable)Transform(child, context)); + } } } - } - - return output; - } - - public override IClass TransformOperationVariable(IOperationVariable that, LevelExtentModifierContext context) - { - var output = Copying.Deep(that); - output.Value = (ISubmodelElement)Transform(that.Value, context); - return output; - } - - public override IClass TransformProperty(IProperty that, LevelExtentModifierContext context) - { - if (!context.IsRoot) - { - return Copying.Deep(that); + return output; } - if (context.Extent == ExtentEnum.WithBlobValue) + public override IClass TransformOperationVariable(IOperationVariable that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Extent", that.GetType().Name); - } + var output = Copying.Deep(that); + if (output != null) + { + output.Value = (ISubmodelElement)Transform(that.Value, context); + } - if (context.Level == LevelEnum.Core) - { - throw new InvalidSerializationModifierException("Level", that.GetType().Name); + return output; } - return Copying.Deep(that); - } - - public override IClass TransformQualifier(IQualifier that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformRange(IRange that, LevelExtentModifierContext context) - { - if (!context.IsRoot) + public override IClass TransformProperty(IProperty that, LevelExtentModifierContext context) { return Copying.Deep(that); } - if (context.Extent == ExtentEnum.WithBlobValue) - { - throw new InvalidSerializationModifierException("Extent", that.GetType().Name); - } - - if (context.Level == LevelEnum.Core) + public override IClass TransformQualifier(IQualifier that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Level", that.GetType().Name); + throw new System.NotImplementedException(); } - return Copying.Deep(that); - } - - public override IClass TransformReference(IReference that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformReferenceElement(IReferenceElement that, LevelExtentModifierContext context) - { - if (!context.IsRoot) + public override IClass TransformRange(IRange that, LevelExtentModifierContext context) { return Copying.Deep(that); } - if (context.Extent == ExtentEnum.WithBlobValue) + public override IClass TransformReference(IReference that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Extent", that.GetType().Name); + throw new System.NotImplementedException(); } - if (context.Level == LevelEnum.Core) + public override IClass TransformReferenceElement(IReferenceElement that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Level", that.GetType().Name); + return Copying.Deep(that); } - return Copying.Deep(that); - } - - public override IClass TransformRelationshipElement(IRelationshipElement that, LevelExtentModifierContext context) - { - if (!context.IsRoot) + public override IClass TransformRelationshipElement(IRelationshipElement that, LevelExtentModifierContext context) { return Copying.Deep(that); } - if (context.Extent == ExtentEnum.WithBlobValue) + public override IClass TransformResource(IResource that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Extent", that.GetType().Name); + throw new System.NotImplementedException(); } - if (context.Level == LevelEnum.Core) + public override IClass TransformSpecificAssetId(ISpecificAssetId that, LevelExtentModifierContext context) { - throw new InvalidSerializationModifierException("Level", that.GetType().Name); + throw new System.NotImplementedException(); } - return Copying.Deep(that); - } - - public override IClass TransformResource(IResource that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformSpecificAssetId(ISpecificAssetId that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformSubmodel(ISubmodel that, LevelExtentModifierContext context) - { - var output = Copying.Deep(that); - - context.IsRoot = false; - if (context.Level == LevelEnum.Core) + public override IClass TransformSubmodel(ISubmodel that, LevelExtentModifierContext context) { - if (that.SubmodelElements == null) - { - return output; - } + var output = Copying.Deep(that); - output.SubmodelElements = new List(); - foreach (var child in that.SubmodelElements) + if (output != null) { - context.IncludeChildren = false; - output.SubmodelElements.Add((ISubmodelElement)Transform(child, context)); - } - } - else - { - if (that.SubmodelElements == null) - { - return output; + context.IsRoot = false; + if (context.Level == LevelEnum.Core) + { + if (that.SubmodelElements != null) + { + output.SubmodelElements = new List(); + foreach (var child in that.SubmodelElements) + { + context.IncludeChildren = false; + output.SubmodelElements.Add((ISubmodelElement)Transform(child, context)); + } + } + } + else + { + if (that.SubmodelElements != null) + { + output.SubmodelElements = new List(); + foreach (var child in that.SubmodelElements) + { + output.SubmodelElements.Add((ISubmodelElement)Transform(child, context)); + } + } + } } - output.SubmodelElements = new List(); - foreach (var child in that.SubmodelElements) - { - output.SubmodelElements.Add((ISubmodelElement)Transform(child, context)); - } + return output; } - return output; - } - - public override IClass TransformSubmodelElementCollection(ISubmodelElementCollection that, LevelExtentModifierContext context) - { - var output = Copying.Deep(that); - - context.IsRoot = false; - if (context.IncludeChildren) + public override IClass TransformSubmodelElementCollection(ISubmodelElementCollection that, LevelExtentModifierContext context) { - if (context.Level == LevelEnum.Core) - { - if (that.Value == null) - { - return output; - } + var output = Copying.Deep(that); - output.Value = new List(); - foreach (var child in that.Value) - { - context.IncludeChildren = false; - output.Value.Add((ISubmodelElement)Transform(child, context)); - } - } - else + if (output != null) { - if (that.Value == null) + context.IsRoot = false; + if (context.IncludeChildren) { - return output; + if (context.Level == LevelEnum.Core) + { + if (that.Value != null) + { + output.Value = new List(); + foreach (var child in that.Value) + { + context.IncludeChildren = false; + output.Value.Add((ISubmodelElement)Transform(child, context)); + } + } + } + else + { + if (that.Value != null) + { + output.Value = new List(); + foreach (var child in that.Value) + { + output.Value.Add((ISubmodelElement)Transform(child, context)); + } + } + } } - - output.Value = new List(); - foreach (var child in that.Value) + else { - output.Value.Add((ISubmodelElement)Transform(child, context)); + output.Value = null; } } - } - else - { - output.Value = null; - } - return output; - } + return output; + } - public override IClass TransformSubmodelElementList(ISubmodelElementList that, LevelExtentModifierContext context) - { - var output = Copying.Deep(that); - context.IsRoot = false; - if (context.IncludeChildren) + public override IClass TransformSubmodelElementList(ISubmodelElementList that, LevelExtentModifierContext context) { - if (context.Level == LevelEnum.Core) + var output = Copying.Deep(that); + if (output != null) { - if (that.Value == null) + context.IsRoot = false; + if (context.IncludeChildren) { - return output; + if (context.Level == LevelEnum.Core) + { + if (that.Value != null) + { + output.Value = new List(); + foreach (var child in that.Value) + { + context.IncludeChildren = false; + output.Value.Add((ISubmodelElement)Transform(child, context)); + } + } + } + else + { + if (that.Value != null) + { + output.Value = new List(); + foreach (var child in that.Value) + { + output.Value.Add((ISubmodelElement)Transform(child, context)); + } + } + } } - - output.Value = new List(); - foreach (var child in that.Value) + else { - context.IncludeChildren = false; - output.Value.Add((ISubmodelElement)Transform(child, context)); + output.Value = null; } } - else - { - if (that.Value == null) - { - return output; - } - output.Value = new List(); - foreach (var child in that.Value) - { - output.Value.Add((ISubmodelElement)Transform(child, context)); - } - } + return output; } - else + + public override IClass TransformValueList(IValueList that, LevelExtentModifierContext context) { - output.Value = null; + throw new System.NotImplementedException(); } - return output; + public override IClass TransformValueReferencePair(IValueReferencePair that, LevelExtentModifierContext context) + { + throw new System.NotImplementedException(); + } } - - public override IClass TransformValueList(IValueList that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); - - public override IClass TransformValueReferencePair(IValueReferencePair that, LevelExtentModifierContext context) => throw new System.NotImplementedException(); -} \ No newline at end of file +} diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/MetadataJsonSerializer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/MetadataJsonSerializer.cs new file mode 100644 index 000000000..fa53da025 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/MetadataJsonSerializer.cs @@ -0,0 +1,402 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +namespace IO.Swagger.Lib.V3.SerializationModifiers.Mappers.MetadataMappers; + +using DataTransferObjects.ValueDTOs; +using System.Text.Json.Nodes; +using System; +using DataTransferObjects.MetadataDTOs; +using AasCore.Aas3_0; +using DataTransferObjects.CommonDTOs; +using System.Collections.Generic; +using IO.Swagger.Lib.V3.Exceptions; +using static AasxServerStandardBib.TimeSeriesPlotting.PlotArguments; + +public class MetadataJsonSerializer +{ + internal static JsonNode? ToJsonObject(IMetadataDTO that) + { + ArgumentNullException.ThrowIfNull(that); + + if (that is RelationshipElementMetadata relationshipElementMetadata) + { + return TransformRelationshipElement(relationshipElementMetadata); + } + else if (that is AnnotatedRelationshipElementMetadata annotatedRelationshipElementMetadata) + { + return TransformAnnotatedRelationshipElement(annotatedRelationshipElementMetadata); + } + else if (that is BasicEventElementMetadata basicEventElementMetadata) + { + return TransformBasicEventElement(basicEventElementMetadata); + } + else + { + return Serialize(that); + } + } + + //TODO:jtikekar Rename the method + private static JsonNode Serialize(IMetadataDTO that) + { + var mappedIClass = RequestMetadataMapper.Map(that); + + if (mappedIClass != null) + { + var jsonNode = Jsonization.Serialize.ToJsonObject(mappedIClass); + if (mappedIClass is IBlob or IFile) + { + jsonNode.Remove("contentType"); + } + return jsonNode; + } + else + { + throw new InvalidSerializationModifierException("metadata", that.GetType().Name); + } + } + + private static JsonNode? TransformBasicEventElement(BasicEventElementMetadata that) + { + var result = new JsonObject(); + + if (that.Extensions != null) + { + result["extensions"] = TransformExtensions(that.Extensions); + } + + if (that.Category != null) + { + result["category"] = JsonValue.Create( + that.Category); + } + + if (that.IdShort != null) + { + result["idShort"] = JsonValue.Create( + that.IdShort); + } + + if (that.DisplayName != null) + { + result["displayName"] = TransformDisplayName(that.DisplayName); + } + + if (that.Description != null) + { + result["description"] = TransformDescription(that.Description); + } + + if (that.SemanticId != null) + { + result["semanticId"] = TransformReference(that.SemanticId); + } + + if (that.SupplementalSemanticIds != null) + { + result["supplementalSemanticIds"] = TransformReferenceList(that.SupplementalSemanticIds); + } + + if (that.Qualifiers != null) + { + result["qualifiers"] = TransformQualifiers(that.Qualifiers); + } + + if (that.EmbeddedDataSpecifications != null) + { + result["embeddedDataSpecifications"] = TransformEmbeddedDataSpecifications(that.EmbeddedDataSpecifications); + } + + result["direction"] = Jsonization.Serialize.DirectionToJsonValue( + that.Direction); + + result["state"] = Jsonization.Serialize.StateOfEventToJsonValue( + that.State); + + if (that.MessageTopic != null) + { + result["messageTopic"] = JsonValue.Create( + that.MessageTopic); + } + + if (that.MessageBroker != null) + { + result["messageBroker"] = TransformReference(that.MessageBroker); + } + + if (that.LastUpdate != null) + { + result["lastUpdate"] = JsonValue.Create( + that.LastUpdate); + } + + if (that.MinInterval != null) + { + result["minInterval"] = JsonValue.Create( + that.MinInterval); + } + + if (that.MaxInterval != null) + { + result["maxInterval"] = JsonValue.Create( + that.MaxInterval); + } + + result["modelType"] = "BasicEventElement"; + + return result; + } + private static JsonNode? TransformAnnotatedRelationshipElement(AnnotatedRelationshipElementMetadata that) + { + var result = new JsonObject(); + + if (that.Extensions != null) + { + result["extensions"] = TransformExtensions(that.Extensions); + } + + if (that.Category != null) + { + result["category"] = JsonValue.Create( + that.Category); + } + + if (that.IdShort != null) + { + result["idShort"] = JsonValue.Create( + that.IdShort); + } + + if (that.DisplayName != null) + { + result["displayName"] = TransformDisplayName(that.DisplayName); + } + + if (that.Description != null) + { + result["description"] = TransformDescription(that.Description); + } + + if (that.SemanticId != null) + { + result["semanticId"] = TransformReference(that.SemanticId); + } + + if (that.SupplementalSemanticIds != null) + { + result["supplementalSemanticIds"] = TransformReferenceList(that.SupplementalSemanticIds); + } + + if (that.Qualifiers != null) + { + result["qualifiers"] = TransformQualifiers(that.Qualifiers); + } + + if (that.EmbeddedDataSpecifications != null) + { + result["embeddedDataSpecifications"] = TransformEmbeddedDataSpecifications(that.EmbeddedDataSpecifications); + } + + result["modelType"] = "AnnotatedRelationshipElement"; + + return result; + } + + private static JsonNode? TransformRelationshipElement(RelationshipElementMetadata that) + { + var result = new JsonObject(); + + if (that.Extensions != null) + { + result["extensions"] = TransformExtensions(that.Extensions); + } + + if (that.Category != null) + { + result["category"] = JsonValue.Create( + that.Category); + } + + if (that.IdShort != null) + { + result["idShort"] = JsonValue.Create( + that.IdShort); + } + + if (that.DisplayName != null) + { + result["displayName"] = TransformDisplayName(that.DisplayName); + } + + if (that.Description != null) + { + result["description"] = TransformDescription(that.Description); + } + + if (that.SemanticId != null) + { + result["semanticId"] = TransformReference(that.SemanticId); + } + + if (that.SupplementalSemanticIds != null) + { + result["supplementalSemanticIds"] = TransformReferenceList(that.SupplementalSemanticIds); + } + + if (that.Qualifiers != null) + { + result["qualifiers"] = TransformQualifiers(that.Qualifiers); + } + + if (that.EmbeddedDataSpecifications != null) + { + result["embeddedDataSpecifications"] = TransformEmbeddedDataSpecifications(that.EmbeddedDataSpecifications); + } + + result["modelType"] = "RelationshipElement"; + + return result; + } + + private static JsonArray? TransformExtensions(List that) + { + var arrayExtensions = new JsonArray(); + foreach (var extnsionDto in that) + { + var extension = new Extension(extnsionDto.Name, MapReference(extnsionDto.SemanticId), MapReferenceList(extnsionDto.SupplementalSemanticIds), extnsionDto.ValueType, extnsionDto.Value); + arrayExtensions.Add(Jsonization.Serialize.ToJsonObject(extension)); + } + return arrayExtensions; + } + + private static JsonArray? TransformDisplayName(List that) + { + var arrayDisplayName = new JsonArray(); + foreach (var langStringDto in that) + { + var langString = new LangStringNameType(langStringDto.Language, langStringDto.Text); + arrayDisplayName.Add(Jsonization.Serialize.ToJsonObject(langString)); + } + return arrayDisplayName; + } + + private static JsonArray? TransformDescription(List that) + { + var arrayDescription = new JsonArray(); + foreach (var langStringDto in that) + { + var langString = new LangStringTextType(langStringDto.Language, langStringDto.Text); + arrayDescription.Add(Jsonization.Serialize.ToJsonObject(langString)); + } + return arrayDescription; + } + + private static JsonArray? TransformQualifiers(List that) + { + var arrayQualifiers = new JsonArray(); + foreach (var qualifierDto in that) + { + arrayQualifiers.Add(TransformQualifier(qualifierDto)); + } + return arrayQualifiers; + } + + private static JsonNode? TransformQualifier(QualifierDTO that) + { + var qualifier = MapQualifier(that); + return Jsonization.Serialize.ToJsonObject(qualifier); + } + + private static JsonArray? TransformReferenceList(List that) + { + var arrayReferences = new JsonArray(); + foreach (var referenceDto in that) + { + arrayReferences.Add(TransformReference(referenceDto)); + } + return arrayReferences; + } + + private static JsonNode? TransformReference(ReferenceDTO that) + { + var reference = MapReference(that); + return Jsonization.Serialize.ToJsonObject(reference); + } + + private static JsonArray? TransformEmbeddedDataSpecifications(List that) + { + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (var embeddedDSDto in that) + { + arrayEmbeddedDataSpecifications.Add(TransformEmbeddedDataSpecification(embeddedDSDto)); + } + return arrayEmbeddedDataSpecifications; + } + + private static JsonNode? TransformEmbeddedDataSpecification(EmbeddedDataSpecificationDTO that) + { + var embeddedDS = MapEmbeddedDataSpecification(that); + return Jsonization.Serialize.ToJsonObject(embeddedDS); + } + + private static List MapReferenceList(List references) + { + if (references == null) + return null; + var result = new List(); + foreach (var reference in references) + { + result.Add(MapReference(reference)); + } + + return result; + } + + private static IReference MapReference(ReferenceDTO referenceDTO) + { + if (referenceDTO == null) + return null; + return new Reference(referenceDTO.Type, MapKeys(referenceDTO.Keys), MapReference(referenceDTO.ReferredSemanticId)); + } + + private static List MapKeys(List keys) + { + if (keys == null) + return null; + + var result = new List(); + foreach (var key in keys) + { + result.Add(new Key(key.Type, key.Value)); + } + + return result; + } + + private static IQualifier MapQualifier(QualifierDTO qualifierDTO) + { + if (qualifierDTO == null) + return null; + return new Qualifier(qualifierDTO.Type, qualifierDTO.ValueType, MapReference(qualifierDTO.SemanticId), MapReferenceList(qualifierDTO.SupplementalSemanticIds), qualifierDTO.Kind, qualifierDTO.Value, MapReference(qualifierDTO.ValueId)); + } + + private static IEmbeddedDataSpecification MapEmbeddedDataSpecification(EmbeddedDataSpecificationDTO embDataSpecDTO) + { + if (embDataSpecDTO == null) + return null; + + //TODO: Map Dataspecification content + return new EmbeddedDataSpecification(MapReference(embDataSpecDTO.DataSpecification), null); + } +} diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/RequestMetadataMapper.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/RequestMetadataMapper.cs index 48f0987e5..09c24cad7 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/RequestMetadataMapper.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/RequestMetadataMapper.cs @@ -13,238 +13,233 @@ using DataTransferObjects.CommonDTOs; using DataTransferObjects.MetadataDTOs; +using IO.Swagger.Lib.V3.Exceptions; using System.Collections.Generic; -namespace IO.Swagger.Lib.V3.SerializationModifiers.Mappers.MetadataMappers; - -using System.Linq; - -public static class RequestMetadataMapper +namespace IO.Swagger.Lib.V3.SerializationModifiers.Mappers.MetadataMappers { - public static IClass? Map(IMetadataDTO source) => - source switch - { - PropertyMetadata propertyMetadata => Transform(propertyMetadata), - MultiLanguagePropertyMetadata multiLanguagePropertyMetadata => Transform(multiLanguagePropertyMetadata), - BasicEventElementMetadata basicEventElementMetadata => Transform(basicEventElementMetadata), - BlobMetadata blobMetadata => Transform(blobMetadata), - FileMetadata fileMetadata => Transform(fileMetadata), - RangeMetadata rangeMetadata => Transform(rangeMetadata), - ReferenceElementMetadata referenceElementMetadata => Transform(referenceElementMetadata), - RelationshipElementMetadata relationshipElementMetadata => Transform(relationshipElementMetadata), - SubmodelElementCollectionMetadata submodelElementCollectionMetadata => Transform(submodelElementCollectionMetadata), - SubmodelElementListMetadata submodelElementListMetadata => Transform(submodelElementListMetadata), - AnnotatedRelationshipElementMetadata annotationElementMetadata => Transform(annotationElementMetadata), - EntityMetadata entityMetadata => Transform(entityMetadata), - SubmodelMetadata submodelMetadata => Transform(submodelMetadata), - _ => null - }; - - private static ISubmodel? Transform(SubmodelMetadata metadata) + public static class RequestMetadataMapper { - List submodelElements = null; - if (metadata.submodelElements != null) + public static IClass Map(IMetadataDTO source) { - submodelElements = new List(); - foreach (var element in metadata.submodelElements) - { - submodelElements.Add((ISubmodelElement)Map(element)); - } + if (source is PropertyMetadata propertyMetadata) + return Transform(propertyMetadata); + if (source is MultiLanguagePropertyMetadata multiLanguagePropertyMetadata) + return Transform(multiLanguagePropertyMetadata); + if (source is BasicEventElementMetadata basicEventElementMetadata) + return Transform(basicEventElementMetadata); + if (source is BlobMetadata blobMetadata) + return Transform(blobMetadata); + if (source is FileMetadata fileMetadata) + return Transform(fileMetadata); + if (source is RangeMetadata rangeMetadata) + return Transform(rangeMetadata); + if (source is ReferenceElementMetadata referenceElementMetadata) + return Transform(referenceElementMetadata); + if (source is RelationshipElementMetadata relationshipElementMetadata) + return Transform(relationshipElementMetadata); + if (source is SubmodelElementCollectionMetadata submodelElementCollectionMetadata) + return Transform(submodelElementCollectionMetadata); + if (source is SubmodelElementListMetadata submodelElementListMetadata) + return Transform(submodelElementListMetadata); + if (source is AnnotatedRelationshipElementMetadata annotationElementMetadata) + return Transform(annotationElementMetadata); + if (source is EntityMetadata entityMetadata) + return Transform(entityMetadata); + if (source is SubmodelMetadata submodelMetadata) + return Transform(submodelMetadata); + + throw new InvalidSerializationModifierException("metadata", source.GetType().Name); } - return new Submodel(metadata.id, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, TransformLangStringNameTypeList(metadata.displayName), - TransformLangStringTextTypeList(metadata.description), TransformAdministrationInformation(metadata.administration), metadata.kind, - TransformReference(metadata.semanticId), TransformReferenceList(metadata.supplementalSemanticIds), TransformQualifierList(metadata.qualifiers), - TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications), submodelElements); - } + private static ISubmodel Transform(SubmodelMetadata metadata) + { + return new Submodel(metadata.Id, TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformAdministrationInformation(metadata.Administration), metadata.Kind, TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications)); + } - private static IEntity Transform(EntityMetadata metadata) - { - List statements = null; - if (metadata.statements != null) + + private static IEntity Transform(EntityMetadata metadata) { - statements = new List(); - foreach (var element in metadata.statements) - { - statements.Add((ISubmodelElement)Map(element)); - } + return new Entity(metadata.EntityType, TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications)); } - return new Entity(metadata.entityType, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, - TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), TransformReference(metadata.semanticId), - TransformReferenceList(metadata.supplementalSemanticIds), TransformQualifierList(metadata.qualifiers), - TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications), statements); - } + private static IAnnotatedRelationshipElement Transform(AnnotatedRelationshipElementMetadata metadata) + { + return new AnnotatedRelationshipElement(null, null, TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications)); + } - private static IAnnotatedRelationshipElement Transform(AnnotatedRelationshipElementMetadata metadata) - { - List annotations = null; - if (metadata.annotations != null) + private static ISubmodelElementList Transform(SubmodelElementListMetadata metadata) { - annotations = new List(); - foreach (var element in metadata.annotations) - { - annotations.Add((IDataElement)Map(element)); - } + return new SubmodelElementList(metadata.TypeValueListElement, TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications), metadata.OrderRelevant, TransformReference(metadata.SemanticIdListElement), metadata.ValueTypeListElement); } - return new AnnotatedRelationshipElement(null, null, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, - TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), - TransformReference(metadata.semanticId), TransformReferenceList(metadata.supplementalSemanticIds), - TransformQualifierList(metadata.qualifiers), TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications), annotations); - } + private static ISubmodelElementCollection Transform(SubmodelElementCollectionMetadata metadata) + { + return new SubmodelElementCollection(TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications)); + } - private static ISubmodelElementList Transform(SubmodelElementListMetadata metadata) - { - List value = null; - if (metadata.value != null) + private static IRelationshipElement Transform(RelationshipElementMetadata metadata) { - value = new List(); - foreach (var element in metadata.value) - { - value.Add((ISubmodelElement)Map(element)); - } + return new RelationshipElement(null, null, TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications)); } - return new SubmodelElementList(metadata.typeValueListElement, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, - TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), - TransformReference(metadata.semanticId), TransformReferenceList(metadata.supplementalSemanticIds), - TransformQualifierList(metadata.qualifiers), TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications), metadata.orderRelevant, - TransformReference(metadata.semanticIdListElement), metadata.valueTypeListElement, value); - } + private static IReferenceElement Transform(ReferenceElementMetadata metadata) + { + return new ReferenceElement(TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications)); + } - private static ISubmodelElementCollection Transform(SubmodelElementCollectionMetadata metadata) - { - List value = null; - if (metadata.value != null) + private static IRange Transform(RangeMetadata metadata) { - value = new List(); - foreach (var element in metadata.value) - { - value.Add((ISubmodelElement)Map(element)); - } + return new AasCore.Aas3_0.Range(metadata.ValueType, TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications)); } - return new SubmodelElementCollection(TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, - TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), - TransformReference(metadata.semanticId), TransformReferenceList(metadata.supplementalSemanticIds), - TransformQualifierList(metadata.qualifiers), TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications), value); - } + private static IFile Transform(FileMetadata metadata) + { + return new File(null, TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications)); + } - private static IRelationshipElement Transform(RelationshipElementMetadata metadata) - { - return new RelationshipElement(null, null, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, - TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), - TransformReference(metadata.semanticId), TransformReferenceList(metadata.supplementalSemanticIds), - TransformQualifierList(metadata.qualifiers), TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications)); - } + private static IBlob Transform(BlobMetadata metadata) + { + return new Blob(null, TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications)); + } - private static IReferenceElement Transform(ReferenceElementMetadata metadata) - { - return new ReferenceElement(TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, TransformLangStringNameTypeList(metadata.displayName), - TransformLangStringTextTypeList(metadata.description), TransformReference(metadata.semanticId), - TransformReferenceList(metadata.supplementalSemanticIds), TransformQualifierList(metadata.qualifiers), - TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications)); - } + private static IBasicEventElement Transform(BasicEventElementMetadata metadata) + { + return new BasicEventElement(null, metadata.Direction, metadata.State, TransformExtensions(metadata.Extensions), metadata.Category, metadata.IdShort, TransformLangStringNameTypeList(metadata.DisplayName), TransformLangStringTextTypeList(metadata.Description), TransformReference(metadata.SemanticId), TransformReferenceList(metadata.SupplementalSemanticIds), TransformQualifierList(metadata.Qualifiers), TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications), metadata.MessageTopic, TransformReference(metadata.MessageBroker), metadata.LastUpdate, metadata.MinInterval, metadata.MaxInterval); + } - private static IRange Transform(RangeMetadata metadata) - { - return new AasCore.Aas3_0.Range(metadata.valueType, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, - TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), - TransformReference(metadata.semanticId), TransformReferenceList(metadata.supplementalSemanticIds), - TransformQualifierList(metadata.qualifiers), TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications)); - } + private static IMultiLanguageProperty Transform(MultiLanguagePropertyMetadata multiLanguagePropertyMetadata) + { + return new MultiLanguageProperty(TransformExtensions(multiLanguagePropertyMetadata.Extensions), multiLanguagePropertyMetadata.Category, multiLanguagePropertyMetadata.IdShort, TransformLangStringNameTypeList(multiLanguagePropertyMetadata.DisplayName), TransformLangStringTextTypeList(multiLanguagePropertyMetadata.Description), TransformReference(multiLanguagePropertyMetadata.SemanticId), TransformReferenceList(multiLanguagePropertyMetadata.SupplementalSemanticIds), TransformQualifierList(multiLanguagePropertyMetadata.Qualifiers), TransformEmbeddedDataSpecList(multiLanguagePropertyMetadata.EmbeddedDataSpecifications)); + } - private static IFile Transform(FileMetadata metadata) - { - return new File(null, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, TransformLangStringNameTypeList(metadata.displayName), - TransformLangStringTextTypeList(metadata.description), TransformReference(metadata.semanticId), - TransformReferenceList(metadata.supplementalSemanticIds), TransformQualifierList(metadata.qualifiers), - TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications)); - } + private static IProperty Transform(PropertyMetadata propertyMetadata) + { + return new Property(propertyMetadata.ValueType, TransformExtensions(propertyMetadata.Extensions), propertyMetadata.Category, propertyMetadata.IdShort, TransformLangStringNameTypeList(propertyMetadata.DisplayName), TransformLangStringTextTypeList(propertyMetadata.Description), TransformReference(propertyMetadata.SemanticId), TransformReferenceList(propertyMetadata.SupplementalSemanticIds), TransformQualifierList(propertyMetadata.Qualifiers), TransformEmbeddedDataSpecList(propertyMetadata.EmbeddedDataSpecifications)); + } - private static IBlob Transform(BlobMetadata metadata) - { - return new Blob(null, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, TransformLangStringNameTypeList(metadata.displayName), - TransformLangStringTextTypeList(metadata.description), TransformReference(metadata.semanticId), - TransformReferenceList(metadata.supplementalSemanticIds), TransformQualifierList(metadata.qualifiers), - TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications)); - } + private static List TransformLangStringNameTypeList(List langStringNameTypeList) + { + if (langStringNameTypeList == null) return null; + var result = new List(); + foreach (var langString in langStringNameTypeList) + { + result.Add(TransformLangStringNameType(langString)); + } - private static IBasicEventElement Transform(BasicEventElementMetadata metadata) - { - return new BasicEventElement(null, metadata.direction, metadata.state, TransformExtensions(metadata.extensions), metadata.category, metadata.idShort, - TransformLangStringNameTypeList(metadata.displayName), TransformLangStringTextTypeList(metadata.description), - TransformReference(metadata.semanticId), TransformReferenceList(metadata.supplementalSemanticIds), - TransformQualifierList(metadata.qualifiers), TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications), metadata.messageTopic, - TransformReference(metadata.messageBroker), metadata.lastUpdate, metadata.minInterval, metadata.maxInterval); - } + return result; + } - private static IMultiLanguageProperty Transform(MultiLanguagePropertyMetadata multiLanguagePropertyMetadata) => - new MultiLanguageProperty(TransformExtensions(multiLanguagePropertyMetadata.extensions), multiLanguagePropertyMetadata.category, - multiLanguagePropertyMetadata.idShort, TransformLangStringNameTypeList(multiLanguagePropertyMetadata.displayName), - TransformLangStringTextTypeList(multiLanguagePropertyMetadata.description), - TransformReference(multiLanguagePropertyMetadata.semanticId), - TransformReferenceList(multiLanguagePropertyMetadata.supplementalSemanticIds), - TransformQualifierList(multiLanguagePropertyMetadata.qualifiers), - TransformEmbeddedDataSpecList(multiLanguagePropertyMetadata.embeddedDataSpecifications)); - - private static IProperty Transform(PropertyMetadata propertyMetadata) => - new Property(propertyMetadata.valueType, TransformExtensions(propertyMetadata.extensions), propertyMetadata.category, propertyMetadata.idShort, - TransformLangStringNameTypeList(propertyMetadata.displayName), TransformLangStringTextTypeList(propertyMetadata.description), - TransformReference(propertyMetadata.semanticId), TransformReferenceList(propertyMetadata.supplementalSemanticIds), - TransformQualifierList(propertyMetadata.qualifiers), TransformEmbeddedDataSpecList(propertyMetadata.embeddedDataSpecifications)); - - private static List TransformLangStringNameTypeList(List langStringNameTypeList) - { - return langStringNameTypeList.Select(langString => TransformLangStringNameType(langString)).ToList(); - } + private static ILangStringNameType TransformLangStringNameType(LangStringNameTypeDTO langString) + { + return new LangStringNameType(langString.Language, langString.Text); + } - private static ILangStringNameType TransformLangStringNameType(LangStringNameTypeDTO langString) => new LangStringNameType(langString.language, langString.text); + private static List TransformLangStringTextTypeList(List langStringTextTypeList) + { + if (langStringTextTypeList == null) return null; + var result = new List(); + foreach (var langString in langStringTextTypeList) + { + result.Add(TransformLangStringTextType(langString)); + } - private static List TransformLangStringTextTypeList(List langStringTextTypeList) => - langStringTextTypeList.Select(langString => TransformLangStringTextType(langString)).ToList(); + return result; + } - private static ILangStringTextType TransformLangStringTextType(LangStringTextTypeDTO langString) => new LangStringTextType(langString.language, langString.text); + private static ILangStringTextType TransformLangStringTextType(LangStringTextTypeDTO langString) + { + return new LangStringTextType(langString.Language, langString.Text); + } - private static List TransformExtensions(List extensions) => extensions - .Select(extension => - new Extension(extension.name, TransformReference(extension.semanticId), - TransformReferenceList(extension.supplementalSemanticIds), - extension.valueType, extension.value)).Cast() - .ToList(); + private static List TransformExtensions(List extensions) + { + if (extensions == null) + return null; + var result = new List(); + foreach (var extension in extensions) + { + result.Add(new Extension(extension.Name, TransformReference(extension.SemanticId), TransformReferenceList(extension.SupplementalSemanticIds), extension.ValueType, extension.Value)); + } - private static List TransformReferenceList(List references) - { - return references.Select(reference => TransformReference(reference)).ToList(); - } + return result; + } - private static IReference? TransformReference(ReferenceDTO referenceDTO) - { - var transformedKeys = TransformKeys(referenceDTO.keys); - var transformedSemanticId = referenceDTO.referredSemanticId != null ? - TransformReference(referenceDTO.referredSemanticId) : - null; + private static List TransformReferenceList(List references) + { + if (references == null) return null; + var result = new List(); + foreach (var reference in references) + { + result.Add(TransformReference(reference)); + } - return new Reference(referenceDTO.type, transformedKeys, transformedSemanticId); - } + return result; + } - private static List? TransformKeys(List? keys) => keys?.Select(key => new Key(key.type, key.value)).Cast().ToList(); + private static IReference TransformReference(ReferenceDTO referenceDTO) + { + if (referenceDTO == null) + return null; + return new Reference(referenceDTO.Type, TransformKeys(referenceDTO.Keys), TransformReference(referenceDTO.ReferredSemanticId)); + } + + private static List TransformKeys(List keys) + { + if (keys == null) return null; + + var result = new List(); + foreach (var key in keys) + { + result.Add(new Key(key.Type, key.Value)); + } + + return result; + } + + private static List TransformQualifierList(List qualifiers) + { + if (qualifiers == null) return null; + var result = new List(); + foreach (var qualifier in qualifiers) + { + result.Add(TransformQualifier(qualifier)); + } - private static List TransformQualifierList(List qualifiers) => qualifiers.Select(qualifier => TransformQualifier(qualifier)).ToList(); + return result; + } - private static IQualifier TransformQualifier(QualifierDTO qualifierDTO) => - new Qualifier(qualifierDTO.type, qualifierDTO.valueType, TransformReference(qualifierDTO.semanticId), - TransformReferenceList(qualifierDTO.supplementalSemanticIds), qualifierDTO.kind, qualifierDTO.value, TransformReference(qualifierDTO.valueId)); + private static IQualifier TransformQualifier(QualifierDTO qualifierDTO) + { + if (qualifierDTO == null) + return null; + return new Qualifier(qualifierDTO.Type, qualifierDTO.ValueType, TransformReference(qualifierDTO.SemanticId), TransformReferenceList(qualifierDTO.SupplementalSemanticIds), qualifierDTO.Kind, qualifierDTO.Value, TransformReference(qualifierDTO.ValueId)); + } - private static List TransformEmbeddedDataSpecList(List embeddedDataSpecifications) => - embeddedDataSpecifications.Select(embDataSpec => TransformEmbeddedDataSpecification(embDataSpec)).ToList(); + private static List TransformEmbeddedDataSpecList(List embeddedDataSpecifications) + { + if (embeddedDataSpecifications == null) return null; + var result = new List(); + foreach (var embDataSpec in embeddedDataSpecifications) + { + result.Add(TransformEmbeddedDataSpecification(embDataSpec)); + } - private static IEmbeddedDataSpecification TransformEmbeddedDataSpecification(EmbeddedDataSpecificationDTO embDataSpecDTO) => - new EmbeddedDataSpecification(TransformReference(embDataSpecDTO.dataSpecification), null); + return result; + } - private static IAdministrativeInformation TransformAdministrationInformation(AdministrativeInformationDTO metadata) => - new AdministrativeInformation(TransformEmbeddedDataSpecList(metadata.embeddedDataSpecifications), metadata.version, metadata.revision, - TransformReference(metadata.creator), metadata.templateId); -} \ No newline at end of file + private static IEmbeddedDataSpecification TransformEmbeddedDataSpecification(EmbeddedDataSpecificationDTO embDataSpecDTO) + { + if (embDataSpecDTO == null) + return null; + return new EmbeddedDataSpecification(TransformReference(embDataSpecDTO.DataSpecification), null); + } + + private static IAdministrativeInformation TransformAdministrationInformation(AdministrativeInformationDTO metadata) + { + if (metadata == null) return null; + return new AdministrativeInformation(TransformEmbeddedDataSpecList(metadata.EmbeddedDataSpecifications), metadata.Version, metadata.Revision, TransformReference(metadata.Creator), metadata.TemplateId); + } + } +} diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataTransformer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataTransformer.cs index 250a25d29..ff471aa3c 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataTransformer.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/MetadataMappers/ResponseMetadataTransformer.cs @@ -14,69 +14,61 @@ using DataTransferObjects; using DataTransferObjects.CommonDTOs; using DataTransferObjects.MetadataDTOs; +using IO.Swagger.Lib.V3.Exceptions; using Microsoft.IdentityModel.Tokens; +using System; using System.Collections.Generic; using static AasCore.Aas3_0.Visitation; namespace IO.Swagger.Lib.V3.SerializationModifiers.Mappers.MetadataMappers { - using System.Linq; - internal class ResponseMetadataTransformer : ITransformer { - public IDTO Transform(IClass? that) => that.Transform(this); + public IDTO Transform(IClass that) + { + if (that == null) return null; + return that.Transform(this); + } - public IDTO TransformAdministrativeInformation(IAdministrativeInformation that) => - new AdministrativeInformationDTO(TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), that.Version, that.Revision, (ReferenceDTO)Transform(that.Creator), - that.TemplateId); + public IDTO TransformAdministrativeInformation(IAdministrativeInformation that) + { + if (that == null) return null; + return new AdministrativeInformationDTO(TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), that.Version, that.Revision, (ReferenceDTO)Transform(that.Creator), that.TemplateId); + } public IDTO TransformAnnotatedRelationshipElement(IAnnotatedRelationshipElement that) { - List smeMetadataList = null; - if (!that.Annotations.IsNullOrEmpty()) - { - smeMetadataList = new List(); - foreach (var submodelElement in that.Annotations) - { - smeMetadataList.Add((ISubmodelElementMetadata)Transform(submodelElement)); - } - } + if (that == null) return null; - return new AnnotatedRelationshipElementMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), smeMetadataList); + return new AnnotatedRelationshipElementMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); } - public IDTO TransformAssetAdministrationShell(IAssetAdministrationShell that) => throw new System.NotImplementedException(); + public IDTO TransformAssetAdministrationShell(IAssetAdministrationShell that) => throw new InvalidOperationException("Metadata modifier cannot be applied to AssetAdministrationShell"); - public IDTO TransformAssetInformation(IAssetInformation that) => throw new System.NotImplementedException(); + public IDTO TransformAssetInformation(IAssetInformation that) => throw new InvalidOperationException("Metadata modifier cannot be applied to AssetInformation"); - public IDTO TransformBasicEventElement(IBasicEventElement that) => new BasicEventElementMetadata(that.Direction, that.State, TransformExtensionList(that.Extensions), - that.Category, that.IdShort, - TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), - (ReferenceDTO)Transform(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), - TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), - that.MessageTopic, (ReferenceDTO)Transform(that.MessageBroker), - that.LastUpdate, that.MinInterval, that.MaxInterval); + public IDTO TransformBasicEventElement(IBasicEventElement that) + { + if (that == null) return null; + return new BasicEventElementMetadata(that.Direction, that.State, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), that.MessageTopic, (ReferenceDTO)Transform(that.MessageBroker), that.LastUpdate, that.MinInterval, that.MaxInterval); + } - public IDTO TransformBlob(IBlob that) => new BlobMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, - TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), - (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), - TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + public IDTO TransformBlob(IBlob that) + { + if (that == null) + return null; + return new BlobMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + } - public IDTO TransformCapability(ICapability that) => throw new System.NotImplementedException(); + public IDTO TransformCapability(ICapability that) => throw new InvalidSerializationModifierException("Metadata", that.GetType().Name); - public IDTO TransformConceptDescription(IConceptDescription that) => throw new System.NotImplementedException(); + public IDTO TransformConceptDescription(IConceptDescription that) => throw new InvalidOperationException("Metadata modifier cannot be applied to ConceptDescription"); - public IDTO TransformDataSpecificationIec61360(IDataSpecificationIec61360 that) => throw new System.NotImplementedException(); + public IDTO TransformDataSpecificationIec61360(IDataSpecificationIec61360 that) => throw new InvalidOperationException("Metadata modifier cannot be applied to DataSpecification"); - internal List? TransformEmbeddedDataSpecList(List that) + internal List TransformEmbeddedDataSpecList(List that) { - List? output = null; + List output = null; if (!that.IsNullOrEmpty()) { output = new List(); @@ -88,32 +80,23 @@ public IDTO TransformAnnotatedRelationshipElement(IAnnotatedRelationshipElement return output; } - - public IDTO TransformEmbeddedDataSpecification(IEmbeddedDataSpecification that) => new EmbeddedDataSpecificationDTO((ReferenceDTO)Transform(that.DataSpecification)); + public IDTO TransformEmbeddedDataSpecification(IEmbeddedDataSpecification that) + { + if (that == null) return null; + return new EmbeddedDataSpecificationDTO((ReferenceDTO)Transform(that.DataSpecification)); + } public IDTO TransformEntity(IEntity that) { - List smeMetadataList = null; - if (!that.Statements.IsNullOrEmpty()) - { - smeMetadataList = new List(); - foreach (var submodelElement in that.Statements) - { - smeMetadataList.Add((ISubmodelElementMetadata)Transform(submodelElement)); - } - } - - return new EntityMetadata(that.EntityType, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), smeMetadataList); + if (that == null) return null; + return new EntityMetadata(that.EntityType, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); } - public IDTO TransformEnvironment(IEnvironment that) => throw new System.NotImplementedException(); + public IDTO TransformEnvironment(IEnvironment that) => throw new InvalidOperationException("Metadata modifier cannot be applied to Environment."); - public IDTO TransformEventPayload(IEventPayload that) => throw new System.NotImplementedException(); + public IDTO TransformEventPayload(IEventPayload that) => throw new InvalidOperationException("Metadata modifier cannot be applied to EventPayload."); - public List TransformExtensionList(List that) + public List TransformExtensionList(List that) { List extensions = null; if (that != null) @@ -126,21 +109,21 @@ public List TransformExtensionList(List that) return extensions; } - public IDTO TransformExtension(IExtension that) => - new ExtensionDTO(that.Name, (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), that.ValueType, that.Value, - TransformReferenceList(that.RefersTo)); + public IDTO TransformExtension(IExtension that) + { + return new ExtensionDTO(that.Name, (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), that.ValueType, that.Value, TransformReferenceList(that.RefersTo)); + } public IDTO TransformFile(IFile that) { - return new FileMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + if (that == null) + return null; + return new FileMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); } - internal List? TransformKeyList(List? keyList) + internal List TransformKeyList(List keyList) { - List? output = null; + List output = null; if (keyList != null) { @@ -153,53 +136,80 @@ public IDTO TransformFile(IFile that) return output; } - - public IDTO TransformKey(IKey that) => new KeyDTO(that.Type, that.Value); + public IDTO TransformKey(IKey that) + { + if (that == null) return null; + return new KeyDTO(that.Type, that.Value); + } public IDTO TransformLangStringDefinitionTypeIec61360(ILangStringDefinitionTypeIec61360 that) => throw new System.NotImplementedException(); - public List TransformLangStringNameTypeList(List that) + public List TransformLangStringNameTypeList(List that) { List langStrings = null; if (that != null) { langStrings = new List(); foreach (var langString in that) + { langStrings.Add((LangStringNameTypeDTO)Transform(langString)); + } } return langStrings; } - public IDTO TransformLangStringNameType(ILangStringNameType that) => new LangStringNameTypeDTO(that.Language, that.Text); + public IDTO TransformLangStringNameType(ILangStringNameType that) + { + if (that == null) + return null; + return new LangStringNameTypeDTO(that.Language, that.Text); + } public IDTO TransformLangStringPreferredNameTypeIec61360(ILangStringPreferredNameTypeIec61360 that) => throw new System.NotImplementedException(); public IDTO TransformLangStringShortNameTypeIec61360(ILangStringShortNameTypeIec61360 that) => throw new System.NotImplementedException(); - public List TransformLangStringTextTypeList(List that) + public List TransformLangStringTextTypeList(List that) { List langStrings = null; + if (that != null) + { + langStrings = new List(); + foreach (var langString in that) + langStrings.Add((LangStringTextTypeDTO)Transform(langString)); + } - return that.Select(langString => (LangStringTextTypeDTO)Transform(langString)).ToList(); + return langStrings; } - public IDTO TransformLangStringTextType(ILangStringTextType that) => new LangStringTextTypeDTO(that.Language, that.Text); + public IDTO TransformLangStringTextType(ILangStringTextType that) + { + if (that == null) + return null; + return new LangStringTextTypeDTO(that.Language, that.Text); + } public IDTO TransformLevelType(ILevelType that) => throw new System.NotImplementedException(); - public IDTO TransformMultiLanguageProperty(IMultiLanguageProperty that) => - new MultiLanguagePropertyMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + public IDTO TransformMultiLanguageProperty(IMultiLanguageProperty that) + { + if (that == null) + return null; + return new MultiLanguagePropertyMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + } public IDTO TransformOperation(IOperation that) { + if (that == null) return null; List inputVarMetadataList = null; if (!that.InputVariables.IsNullOrEmpty()) { - inputVarMetadataList = that.InputVariables.Select(submodelElement => (IMetadataDTO)Transform(submodelElement)).ToList(); + inputVarMetadataList = new List(); + foreach (var submodelElement in that.InputVariables) + { + inputVarMetadataList.Add((IMetadataDTO)Transform(submodelElement)); + } } List outputVarMetadataList = null; @@ -222,60 +232,79 @@ public IDTO TransformOperation(IOperation that) } } - return new OperationMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), inputVarMetadataList, outputVarMetadataList, inOutVarMetadataList); + return new OperationMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), inputVarMetadataList, outputVarMetadataList, inOutVarMetadataList); } public IDTO TransformOperationVariable(IOperationVariable that) => Transform(that.Value); - public IDTO TransformProperty(IProperty that) => - new PropertyMetadata(that.ValueType, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (ReferenceDTO)TransformReference(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + public IDTO TransformProperty(IProperty that) + { + if (that == null) + return null; + return new PropertyMetadata(that.ValueType, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)TransformReference(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + } - internal List TransformQualifierList(List qualifierList) + internal List TransformQualifierList(List qualifierList) { List output = null; - return (qualifierList.IsNullOrEmpty() ? output : qualifierList.Select(qualifier => (QualifierDTO)Transform(qualifier)).ToList()) ?? []; + if (!qualifierList.IsNullOrEmpty()) + { + output = new List(); + foreach (var qualifier in qualifierList) + { + output.Add((QualifierDTO)Transform(qualifier)); + } + } + + return output; } - public IDTO TransformQualifier(IQualifier that) => - new QualifierDTO(that.Type, that.ValueType, (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), that.Kind, - that.Value, (ReferenceDTO)Transform(that.ValueId)); + public IDTO TransformQualifier(IQualifier that) + { + if (that == null) + return null; + return new QualifierDTO(that.Type, that.ValueType, (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), that.Kind, that.Value, (ReferenceDTO)Transform(that.ValueId)); + } - public IDTO TransformRange(IRange that) => - new RangeMetadata(that.ValueType, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + public IDTO TransformRange(IRange that) + { + if (that == null) + return null; + return new RangeMetadata(that.ValueType, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + } - internal List TransformReferenceList(List that) + internal List TransformReferenceList(List that) { List output = null; if (!that.IsNullOrEmpty()) { - output = that.Select(reference => (ReferenceDTO)Transform(reference)).ToList(); + output = new List(); + foreach (var reference in that) + output.Add((ReferenceDTO)Transform(reference)); } return output; } + public IDTO TransformReference(IReference that) + { + if (that == null) + return null; + return new ReferenceDTO(that.Type, TransformKeyList(that.Keys), (ReferenceDTO)Transform(that.ReferredSemanticId)); + } - public IDTO TransformReference(IReference that) => new ReferenceDTO(that.Type, TransformKeyList(that.Keys), (ReferenceDTO)Transform(that.ReferredSemanticId)); - - public IDTO TransformReferenceElement(IReferenceElement that) => - new ReferenceElementMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + public IDTO TransformReferenceElement(IReferenceElement that) + { + if (that == null) + return null; + return new ReferenceElementMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + } - public IDTO TransformRelationshipElement(IRelationshipElement that) => - new RelationshipElementMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + public IDTO TransformRelationshipElement(IRelationshipElement that) + { + if (that == null) + return null; + return new RelationshipElementMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); + } public IDTO TransformResource(IResource that) => throw new System.NotImplementedException(); @@ -283,57 +312,27 @@ public IDTO TransformRelationshipElement(IRelationshipElement that) => public IDTO TransformSubmodel(ISubmodel that) { - List smeMetadataList = null; - if (!that.SubmodelElements.IsNullOrEmpty()) - { - smeMetadataList = that.SubmodelElements.Select(submodelElement => (ISubmodelElementMetadata)Transform(submodelElement)).ToList(); - } + if (that == null) return null; - return new SubmodelMetadata(that.Id, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (AdministrativeInformationDTO)Transform(that.Administration), that.Kind, - (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), smeMetadataList); + return new SubmodelMetadata(that.Id, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (AdministrativeInformationDTO)Transform(that.Administration), that.Kind, (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); } public IDTO TransformSubmodelElementCollection(ISubmodelElementCollection that) { - List smeMetadataList = null; - if (!that.Value.IsNullOrEmpty()) - { - smeMetadataList = new List(); - foreach (var submodelElement in that.Value) - { - smeMetadataList.Add((ISubmodelElementMetadata)Transform(submodelElement)); - } - } - - return new SubmodelElementCollectionMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), - TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), - TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), - TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), smeMetadataList); + if (that == null) + return null; + return new SubmodelElementCollectionMetadata(TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications)); } public IDTO TransformSubmodelElementList(ISubmodelElementList that) { - List smeMetadataList = null; - if (!that.Value.IsNullOrEmpty()) - { - smeMetadataList = new List(); - foreach (var submodelElement in that.Value) - { - smeMetadataList.Add((ISubmodelElementMetadata)Transform(submodelElement)); - } - } - - return new SubmodelElementListMetadata(that.TypeValueListElement, TransformExtensionList(that.Extensions), that.Category, that.IdShort, - TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), - (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), - TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), that.OrderRelevant, - (ReferenceDTO)Transform(that.SemanticIdListElement), that.ValueTypeListElement, smeMetadataList); + if (that == null) + return null; + return new SubmodelElementListMetadata(that.TypeValueListElement, TransformExtensionList(that.Extensions), that.Category, that.IdShort, TransformLangStringNameTypeList(that.DisplayName), TransformLangStringTextTypeList(that.Description), (ReferenceDTO)Transform(that.SemanticId), TransformReferenceList(that.SupplementalSemanticIds), TransformQualifierList(that.Qualifiers), TransformEmbeddedDataSpecList(that.EmbeddedDataSpecifications), that.OrderRelevant, (ReferenceDTO)Transform(that.SemanticIdListElement), that.ValueTypeListElement); } public IDTO TransformValueList(IValueList that) => throw new System.NotImplementedException(); public IDTO TransformValueReferencePair(IValueReferencePair that) => throw new System.NotImplementedException(); } -} \ No newline at end of file +} diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/RequestValueMapper.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/RequestValueMapper.cs index 7b7cacf0a..bfafe9f5f 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/RequestValueMapper.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/RequestValueMapper.cs @@ -87,16 +87,16 @@ public static class RequestValueMapper private static IClass? Transform(BasicEventElementValue valueDTO) { - return new BasicEventElement(TransformReference(valueDTO.observed), Direction.Output, StateOfEvent.On, idShort: valueDTO.idShort); + return new BasicEventElement(TransformReference(valueDTO.Observed), Direction.Output, StateOfEvent.On, idShort: valueDTO.IdShort); } private static IClass Transform(SubmodelValue valueDTO) { List submodelElements = null; - if (valueDTO.submodelElements != null) + if (valueDTO.SubmodelElements != null) { submodelElements = new List(); - foreach (var element in valueDTO.submodelElements) + foreach (var element in valueDTO.SubmodelElements) { submodelElements.Add((ISubmodelElement)Map(element)); } @@ -107,107 +107,107 @@ private static IClass Transform(SubmodelValue valueDTO) private static IClass Transform(RangeValue valueDTO) { - return new AasCore.Aas3_0.Range(DataTypeDefXsd.String, idShort: valueDTO.idShort, min: valueDTO.min, max: valueDTO.max); + return new AasCore.Aas3_0.Range(DataTypeDefXsd.String, idShort: valueDTO.IdShort, min: valueDTO.Min, max: valueDTO.Max); } private static IClass Transform(SubmodelElementListValue valueDTO) { List value = null; - if (valueDTO.value != null) + if (valueDTO.Value != null) { value = new List(); - foreach (var element in valueDTO.value) + foreach (var element in valueDTO.Value) { value.Add((ISubmodelElement)Map(element)); } } - return new SubmodelElementList(AasSubmodelElements.SubmodelElement, idShort: valueDTO.idShort, value: value); + return new SubmodelElementList(AasSubmodelElements.SubmodelElement, idShort: valueDTO.IdShort, value: value); } private static IClass Transform(MultiLanguagePropertyValue valueDTO) { var value = new List(); - foreach (var langString in valueDTO.langStrings) + foreach (var langString in valueDTO.LangStrings) { value.Add(new LangStringTextType(langString.Key, langString.Value)); } - return new MultiLanguageProperty(idShort: valueDTO.idShort, value: value); + return new MultiLanguageProperty(idShort: valueDTO.IdShort, value: value); } private static IClass Transform(SubmodelElementCollectionValue valueDTO) { List value = null; - if (valueDTO.value != null) + if (valueDTO.Value != null) { value = new List(); - foreach (var element in valueDTO.value) + foreach (var element in valueDTO.Value) { value.Add((ISubmodelElement)Map(element)); } } - return new SubmodelElementCollection(idShort: valueDTO.idShort, value: value); + return new SubmodelElementCollection(idShort: valueDTO.IdShort, value: value); } private static IClass Transform(EntityValue valueDTO) { List statements = null; - if (valueDTO.statements != null) + if (valueDTO.Statements != null) { statements = new List(); - foreach (var element in valueDTO.statements) + foreach (var element in valueDTO.Statements) { statements.Add((ISubmodelElement)Map(element)); } } - return new Entity(valueDTO.entityType, idShort: valueDTO.idShort, statements: statements, globalAssetId: valueDTO.globalAssetId); + return new Entity(valueDTO.EntityType, idShort: valueDTO.IdShort, statements: statements, globalAssetId: valueDTO.GlobalAssetId); } private static IClass Transform(ReferenceElementValue valueDTO) { - return new ReferenceElement(idShort: valueDTO.idShort, value: TransformReference(valueDTO.value)); + return new ReferenceElement(idShort: valueDTO.IdShort, value: TransformReference(valueDTO.Value)); } private static IClass Transform(RelationshipElementValue valueDTO) { - return new RelationshipElement(TransformReference(valueDTO.first), TransformReference(valueDTO.second), idShort: valueDTO.idShort); + return new RelationshipElement(TransformReference(valueDTO.First), TransformReference(valueDTO.Second), idShort: valueDTO.IdShort); } private static IClass? Transform(AnnotatedRelationshipElementValue valueDTO) { List annotations = null; - if (valueDTO.annotations != null) + if (valueDTO.Annotations != null) { annotations = new List(); - foreach (var element in valueDTO.annotations) + foreach (var element in valueDTO.Annotations) { annotations.Add((IDataElement)Map(element)); } } - return new AnnotatedRelationshipElement(TransformReference(valueDTO.first), TransformReference(valueDTO.second), idShort: valueDTO.idShort, annotations: annotations); + return new AnnotatedRelationshipElement(TransformReference(valueDTO.First), TransformReference(valueDTO.Second), idShort: valueDTO.IdShort, annotations: annotations); } private static IClass Transform(FileValue valueDTO) { - return new File(valueDTO.contentType, idShort: valueDTO.idShort, value: valueDTO.value); + return new File(valueDTO.ContentType, idShort: valueDTO.IdShort, value: valueDTO.Value); } private static IClass Transform(BlobValue valueDTO) { - return new Blob(valueDTO.contentType, idShort: valueDTO.idShort, value: valueDTO.value); + return new Blob(valueDTO.ContentType, idShort: valueDTO.IdShort, value: valueDTO.Value); } private static IClass Transform(PropertyValue valueDTO) { - return new Property(DataTypeDefXsd.String, idShort: valueDTO.idShort, value: valueDTO.value); + return new Property(DataTypeDefXsd.String, idShort: valueDTO.IdShort, value: valueDTO.Value); } private static IReference? TransformReference(ReferenceDTO referenceDTO) { if (referenceDTO == null) return null; - return new Reference(referenceDTO.type, TransformKeys(referenceDTO.keys), TransformReference(referenceDTO.referredSemanticId)); + return new Reference(referenceDTO.Type, TransformKeys(referenceDTO.Keys), TransformReference(referenceDTO.ReferredSemanticId)); } private static List? TransformKeys(List? keys) @@ -217,7 +217,7 @@ private static IClass Transform(PropertyValue valueDTO) var result = new List(); foreach (var key in keys) { - result.Add(new Key(key.type, key.value)); + result.Add(new Key(key.Type, key.Value)); } return result; diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ResponseValueTransformer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ResponseValueTransformer.cs index 3ab829a09..933e237ac 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ResponseValueTransformer.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ResponseValueTransformer.cs @@ -183,37 +183,7 @@ public IDTO TransformMultiLanguageProperty(IMultiLanguageProperty that) public IDTO TransformOperation(IOperation that) { - List inputVariables = null; - List outputVariables = null; - List inoutputVariables = null; - if (that.InputVariables != null) - { - inputVariables = new List(); - foreach (var inputVariable in that.InputVariables) - { - inputVariables.Add((ISubmodelElementValue) Transform(inputVariable)); - } - } - - if (that.OutputVariables != null) - { - outputVariables = new List(); - foreach (var outputVariable in that.OutputVariables) - { - outputVariables.Add((ISubmodelElementValue) Transform(outputVariable)); - } - } - - if (that.InoutputVariables != null) - { - inoutputVariables = new List(); - foreach (var inoutputVariable in that.InoutputVariables) - { - inoutputVariables.Add((ISubmodelElementValue) Transform(inoutputVariable)); - } - } - - return new OperationValue(that.IdShort, inputVariables, outputVariables, inoutputVariables); + throw new InvalidSerializationModifierException("ValueOnly", that.GetType().Name); } public IDTO? TransformOperationVariable(IOperationVariable? that) => Transform(that?.Value); @@ -266,7 +236,14 @@ public IDTO TransformSubmodel(ISubmodel that) submodelElements = new List(); foreach (var element in that.SubmodelElements) { - submodelElements.Add((ISubmodelElementValue) Transform(element)); + try + { + submodelElements.Add((ISubmodelElementValue)Transform(element)); + } + catch (InvalidSerializationModifierException) + { + continue; + } } } @@ -281,7 +258,14 @@ public IDTO TransformSubmodelElementCollection(ISubmodelElementCollection that) value = new List(); foreach (var element in that.Value) { - value.Add((ISubmodelElementValue) Transform(element)); + try + { + value.Add((ISubmodelElementValue)Transform(element)); + } + catch (InvalidSerializationModifierException) + { + continue; + } } } diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonSerializer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonSerializer.cs index 0afaed76f..6343e30a3 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonSerializer.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/Mappers/ValueMappers/ValueOnlyJsonSerializer.cs @@ -21,57 +21,57 @@ namespace IO.Swagger.Lib.V3.SerializationModifiers.Mappers.ValueMappers { public static class ValueOnlyJsonSerializer { - internal static JsonNode? ToJsonObject(IValueDTO that) + internal static JsonNode? ToJsonObject(IValueDTO that, bool isParentSML = false) { if (that == null) throw new ArgumentNullException(nameof(that)); if (that is PropertyValue propertyValue) { - return Transform(propertyValue); + return Transform(propertyValue, isParentSML); } else if (that is MultiLanguagePropertyValue multiLanguagePropertyValue) { - return Transform(multiLanguagePropertyValue); + return Transform(multiLanguagePropertyValue, isParentSML); } else if (that is BasicEventElementValue basicEventElementValue) { - return Transform(basicEventElementValue); + return Transform(basicEventElementValue, isParentSML); } else if (that is BlobValue blobValue) { - return Transform(blobValue); + return Transform(blobValue, isParentSML); } else if (that is FileValue fileValue) { - return Transform(fileValue); + return Transform(fileValue, isParentSML); } else if (that is RangeValue rangeValue) { - return Transform(rangeValue); + return Transform(rangeValue, isParentSML); } else if (that is ReferenceElementValue referenceElementValue) { - return Transform(referenceElementValue); + return Transform(referenceElementValue, isParentSML); } else if (that is RelationshipElementValue relationshipElementValue) { - return Transform(relationshipElementValue); + return Transform(relationshipElementValue, isParentSML); } else if (that is SubmodelElementCollectionValue submodelElementCollectionValue) { - return Transform(submodelElementCollectionValue); + return Transform(submodelElementCollectionValue, isParentSML); } else if (that is SubmodelElementListValue submodelElementListValue) { - return Transform(submodelElementListValue); + return Transform(submodelElementListValue, isParentSML); } else if (that is AnnotatedRelationshipElementValue annotatedRelEleValue) { - return Transform(annotatedRelEleValue); + return Transform(annotatedRelEleValue, isParentSML); } else if (that is EntityValue EntityValue) { - return Transform(EntityValue); + return Transform(EntityValue, isParentSML); } else if (that is SubmodelValue submodelValue) { @@ -82,14 +82,12 @@ public static class ValueOnlyJsonSerializer return null; } - private static JsonNode Transform(EntityValue entityValue) + private static JsonNode Transform(EntityValue entityValue, bool isParentSML = false) { - var result = new JsonObject(); - var statements = new JsonObject(); - if (entityValue.statements != null) + if (entityValue.Statements != null) { - foreach (var element in entityValue.statements) + foreach (var element in entityValue.Statements) { var elementObject = ToJsonObject(element) as JsonObject; foreach (var keyValue in elementObject) @@ -103,22 +101,26 @@ private static JsonNode Transform(EntityValue entityValue) var valueObject = new JsonObject(); valueObject["statements"] = statements; - valueObject["entityType"] = Jsonization.Serialize.EntityTypeToJsonValue(entityValue.entityType); - valueObject["globalAssetId"] = entityValue.globalAssetId; + valueObject["entityType"] = Jsonization.Serialize.EntityTypeToJsonValue(entityValue.EntityType); + valueObject["globalAssetId"] = entityValue.GlobalAssetId; + + if (isParentSML) + { + return valueObject; + } - result[entityValue.idShort] = valueObject; + var result = new JsonObject(); + result[entityValue.IdShort] = valueObject; return result; } - private static JsonNode Transform(AnnotatedRelationshipElementValue annotatedRelEleValue) + private static JsonNode Transform(AnnotatedRelationshipElementValue annotatedRelEleValue, bool isParentSML = false) { - var result = new JsonObject(); - var annotations = new JsonArray(); - if (annotatedRelEleValue.annotations != null) + if (annotatedRelEleValue.Annotations != null) { - foreach (var element in annotatedRelEleValue.annotations) + foreach (var element in annotatedRelEleValue.Annotations) { var elementObject = ToJsonObject(element); annotations.Add(elementObject); @@ -126,11 +128,17 @@ private static JsonNode Transform(AnnotatedRelationshipElementValue annotatedRel } var valueObject = new JsonObject(); - valueObject["first"] = Transform(annotatedRelEleValue.first); - valueObject["second"] = Transform(annotatedRelEleValue.second); + valueObject["first"] = Transform(annotatedRelEleValue.First); + valueObject["second"] = Transform(annotatedRelEleValue.Second); valueObject["annotations"] = annotations; - result[annotatedRelEleValue.idShort] = valueObject; + if (isParentSML) + { + return valueObject; + } + + var result = new JsonObject(); + result[annotatedRelEleValue.IdShort] = valueObject; return result; } @@ -138,15 +146,19 @@ private static JsonNode Transform(AnnotatedRelationshipElementValue annotatedRel private static JsonNode Transform(SubmodelValue submodelValue) { var result = new JsonObject(); - if (submodelValue.submodelElements != null) + if (submodelValue.SubmodelElements != null) { - foreach (var element in submodelValue.submodelElements) + foreach (var element in submodelValue.SubmodelElements) { var elementObject = ToJsonObject(element) as JsonObject; foreach (var keyValue in elementObject) { - var valueString = keyValue.Value.ToJsonString(); - var valueNode = JsonSerializer.Deserialize(valueString); + JsonNode valueNode = null; + if (keyValue.Value != null) + { + var valueString = keyValue.Value.ToJsonString(); + valueNode = JsonSerializer.Deserialize(valueString); + } result[keyValue.Key] = valueNode; } } @@ -155,38 +167,41 @@ private static JsonNode Transform(SubmodelValue submodelValue) return result; } - private static JsonObject Transform(SubmodelElementListValue submodelElementListValue) + private static JsonNode Transform(SubmodelElementListValue submodelElementListValue, bool isParentSML = false) { - var result = new JsonObject(); - var valueArray = new JsonArray(); - if (submodelElementListValue.value != null) + if (submodelElementListValue.Value != null) { - foreach (var element in submodelElementListValue.value) + foreach (var element in submodelElementListValue.Value) { - var elementObject = ToJsonObject(element) as JsonObject; - foreach (var keyValue in elementObject) - { - var valueString = keyValue.Value.ToJsonString(); - var valueNode = JsonSerializer.Deserialize(valueString); - valueArray.Add(valueNode); - } + var elementNode = ToJsonObject(element, true) as JsonNode; + valueArray.Add(elementNode); + //foreach (var keyValue in elementObject) + //{ + // var valueString = keyValue.Value.ToJsonString(); + // var valueNode = JsonSerializer.Deserialize(valueString); + // valueArray.Add(valueNode); + //} } } - result[submodelElementListValue.idShort] = valueArray; + if (isParentSML) + { + return valueArray; + } + + var result = new JsonObject(); + result[submodelElementListValue.IdShort] = valueArray; return result; } - private static JsonObject Transform(SubmodelElementCollectionValue submodelElementCollectionValue) + private static JsonObject Transform(SubmodelElementCollectionValue submodelElementCollectionValue, bool isParentSML = false) { - var result = new JsonObject(); - var valueObject = new JsonObject(); - if (submodelElementCollectionValue.value != null) + if (submodelElementCollectionValue.Value != null) { - foreach (var element in submodelElementCollectionValue.value) + foreach (var element in submodelElementCollectionValue.Value) { var elementObject = ToJsonObject(element) as JsonObject; foreach (var keyValue in elementObject) @@ -198,83 +213,120 @@ private static JsonObject Transform(SubmodelElementCollectionValue submodelEleme } } - result[submodelElementCollectionValue.idShort] = valueObject; + if (isParentSML) + { + return valueObject; + } + + if (isParentSML) + { + return valueObject; + } + + var result = new JsonObject(); + result[submodelElementCollectionValue.IdShort] = valueObject; return result; } - private static JsonObject Transform(RelationshipElementValue relationshipElementValue) + private static JsonObject Transform(RelationshipElementValue relationshipElementValue, bool isParentSML = false) { - var result = new JsonObject(); - var valueObject = new JsonObject(); - valueObject["first"] = Transform(relationshipElementValue.first); - valueObject["second"] = Transform(relationshipElementValue.second); + valueObject["first"] = Transform(relationshipElementValue.First); + valueObject["second"] = Transform(relationshipElementValue.Second); + + if (isParentSML) + { + return valueObject; + } - result[relationshipElementValue.idShort] = valueObject; + var result = new JsonObject(); + result[relationshipElementValue.IdShort] = valueObject; return result; } - private static JsonObject Transform(ReferenceElementValue referenceElementValue) + private static JsonNode Transform(ReferenceElementValue referenceElementValue, bool isParentSML = false) { - var result = new JsonObject(); + var valueObject = Transform(referenceElementValue.Value); + + if(isParentSML) + { + return valueObject; + } - result[referenceElementValue.idShort] = Transform(referenceElementValue.value); + var result = new JsonObject(); + result[referenceElementValue.IdShort] = valueObject; return result; } - private static JsonObject Transform(RangeValue rangeValue) + private static JsonObject Transform(RangeValue rangeValue, bool isParentSML = false) { - var result = new JsonObject(); - var valueObject = new JsonObject(); - valueObject["min"] = rangeValue.min; - valueObject["max"] = rangeValue.max; + valueObject["min"] = rangeValue.Min; + valueObject["max"] = rangeValue.Max; + + if (isParentSML ) + { + return valueObject; + } - result[rangeValue.idShort] = valueObject; + var result = new JsonObject(); + result[rangeValue.IdShort] = valueObject; return result; } - private static JsonObject Transform(FileValue fileValue) + private static JsonObject Transform(FileValue fileValue, bool isParentSML = false) { - var result = new JsonObject(); - var valueObject = new JsonObject(); - valueObject["contentType"] = fileValue.contentType; - valueObject["value"] = fileValue.value; + valueObject["contentType"] = fileValue.ContentType; + valueObject["value"] = fileValue.Value; - result[fileValue.idShort] = valueObject; + if(isParentSML) + { + return valueObject; + } + + var result = new JsonObject(); + result[fileValue.IdShort] = valueObject; return result; } - private static JsonObject Transform(BlobValue blobValue) + private static JsonObject Transform(BlobValue blobValue, bool isParentSML = false) { - var result = new JsonObject(); - var valueObject = new JsonObject(); - valueObject["contentType"] = blobValue.contentType; - if (blobValue.value != null) + valueObject["contentType"] = blobValue.ContentType; + if (blobValue.Value != null) { - valueObject["value"] = JsonValue.Create(System.Convert.ToBase64String(blobValue.value)); + valueObject["value"] = JsonValue.Create(System.Convert.ToBase64String(blobValue.Value)); } - result[blobValue.idShort] = valueObject; + if(isParentSML) + { + return valueObject; + } + + var result = new JsonObject(); + result[blobValue.IdShort] = valueObject; return result; } - private static JsonObject Transform(BasicEventElementValue basicEventElementValue) + private static JsonObject Transform(BasicEventElementValue basicEventElementValue, bool isParentSML = false) { - var result = new JsonObject(); - var valueObject = new JsonObject(); - valueObject["observed"] = Transform(basicEventElementValue.observed); + valueObject["observed"] = Transform(basicEventElementValue.Observed); - result[basicEventElementValue.idShort] = valueObject; + if(isParentSML) + { + return valueObject; + } + + var result = new JsonObject(); + result[basicEventElementValue.IdShort] = valueObject; return result; } @@ -284,16 +336,16 @@ private static JsonNode Transform(ReferenceDTO that) var result = new JsonObject(); result["type"] = Jsonization.Serialize.ReferenceTypesToJsonValue( - that.type); + that.Type); - if (that.referredSemanticId != null) + if (that.ReferredSemanticId != null) { result["referredSemanticId"] = Transform( - that.referredSemanticId); + that.ReferredSemanticId); } var arrayKeys = new JsonArray(); - foreach (KeyDTO item in that.keys) + foreach (KeyDTO item in that.Keys) { arrayKeys.Add(Transform(item)); } @@ -307,34 +359,43 @@ private static JsonNode Transform(KeyDTO that) var result = new JsonObject(); result["type"] = Jsonization.Serialize.KeyTypesToJsonValue( - that.type); + that.Type); result["value"] = JsonValue.Create( - that.value); + that.Value); return result; } - private static JsonObject Transform(MultiLanguagePropertyValue multiLanguagePropertyValue) + private static JsonNode Transform(MultiLanguagePropertyValue multiLanguagePropertyValue, bool isParentSML = false) { - var result = new JsonObject(); - var arrayLangStrings = new JsonArray(); - foreach (var item in multiLanguagePropertyValue.langStrings) + foreach (var item in multiLanguagePropertyValue.LangStrings) { var langNode = new JsonObject(); langNode[item.Key] = item.Value; arrayLangStrings.Add(langNode); } - result[multiLanguagePropertyValue.idShort] = arrayLangStrings; + if(isParentSML) + { + return arrayLangStrings; + } + + var result = new JsonObject(); + result[multiLanguagePropertyValue.IdShort] = arrayLangStrings; return result; } - private static JsonObject Transform(PropertyValue propertyValue) + private static JsonNode Transform(PropertyValue propertyValue, bool isParentSML = false) { + //Considering this property belongs to SML, henceno IdShort + if(isParentSML) + { + return JsonValue.Create(propertyValue.Value); + } var result = new JsonObject(); - result[propertyValue.idShort] = propertyValue.value; + result[propertyValue.IdShort] = propertyValue.Value; return result; } } diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathModifierContext.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathModifierContext.cs index e5ab2e62c..ae9314ac3 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathModifierContext.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathModifierContext.cs @@ -23,9 +23,15 @@ public class PathModifierContext public List? IdShortPaths { get => idShortPaths; set => idShortPaths = value; } - public PathModifierContext() + public bool IsRoot { get; set; } + + public bool IsGetAllSmes { get; set; } + + public PathModifierContext(bool isGetAllSmes = false) { idShortPaths = new List(); + IsRoot = true; + IsGetAllSmes = isGetAllSmes; } } } diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathTransformer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathTransformer.cs index 3833e6fca..7dcfa3b6b 100644 --- a/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathTransformer.cs +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/PathModifier/PathTransformer.cs @@ -26,12 +26,14 @@ public List Transform(IClass? that, PathModifierContext context) public List TransformAdministrativeInformation(IAdministrativeInformation that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformAnnotatedRelationshipElement(IAnnotatedRelationshipElement that, PathModifierContext context) { - if (context.IdShortPaths.Count == 0) + if (context.IsRoot && !context.IsGetAllSmes) + throw new InvalidSerializationModifierException("Path", that.GetType().Name); + if (string.IsNullOrEmpty(context.ParentPath)) { context.IdShortPaths.Add(that.IdShort); } @@ -39,60 +41,67 @@ public List TransformAnnotatedRelationshipElement(IAnnotatedRelationship { context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); } - - if (that.Annotations != null) - { - var currentParentPath = string.IsNullOrEmpty(context.ParentPath) ? that.IdShort : $"{context.ParentPath}.{that.IdShort}"; - foreach (ISubmodelElement? item in that.Annotations) - { - context.ParentPath = currentParentPath; - Transform(item, context); - } - } - return context.IdShortPaths; } public List TransformAssetAdministrationShell(IAssetAdministrationShell that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformAssetInformation(IAssetInformation that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformBasicEventElement(IBasicEventElement that, PathModifierContext context) { - if (context.ParentPath == null) + if (context.IsRoot) throw new InvalidSerializationModifierException("Path", that.GetType().Name); - - context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + if (string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + } return context.IdShortPaths; } public List TransformBlob(IBlob that, PathModifierContext context) { - if (context.ParentPath == null) + if (context.IsRoot) throw new InvalidSerializationModifierException("Path", that.GetType().Name); - - context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + if (string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + } return context.IdShortPaths; } public List TransformCapability(ICapability that, PathModifierContext context) { - if (context.ParentPath == null) + if (context.IsRoot) throw new InvalidSerializationModifierException("Path", that.GetType().Name); - - context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + if (string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + } return context.IdShortPaths; } public List TransformConceptDescription(IConceptDescription that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformDataSpecificationIec61360(IDataSpecificationIec61360 that, PathModifierContext context) @@ -102,12 +111,12 @@ public List TransformDataSpecificationIec61360(IDataSpecificationIec6136 public List TransformEmbeddedDataSpecification(IEmbeddedDataSpecification that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformEntity(IEntity that, PathModifierContext context) { - if (context.IdShortPaths.Count == 0) + if (context.IdShortPaths.Count == 0 || string.IsNullOrEmpty(context.ParentPath)) { context.IdShortPaths.Add(that.IdShort ?? string.Empty); } @@ -121,6 +130,7 @@ public List TransformEntity(IEntity that, PathModifierContext context) var currentParentPath = string.IsNullOrEmpty(context.ParentPath) ? that.IdShort : $"{context.ParentPath}.{that.IdShort}"; foreach (var item in that.Statements) { + context.IsRoot = false; context.ParentPath = currentParentPath; Transform(item, context); } @@ -131,162 +141,187 @@ public List TransformEntity(IEntity that, PathModifierContext context) public List TransformEnvironment(IEnvironment that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformEventPayload(IEventPayload that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformExtension(IExtension that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformFile(IFile that, PathModifierContext context) { - if (context.ParentPath == null) + if (context.IsRoot) throw new InvalidSerializationModifierException("Path", that.GetType().Name); - - context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + if (string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + } return context.IdShortPaths; } public List TransformKey(IKey that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformLangStringDefinitionTypeIec61360(ILangStringDefinitionTypeIec61360 that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformLangStringNameType(ILangStringNameType that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformLangStringPreferredNameTypeIec61360(ILangStringPreferredNameTypeIec61360 that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformLangStringShortNameTypeIec61360(ILangStringShortNameTypeIec61360 that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformLangStringTextType(ILangStringTextType that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformLevelType(ILevelType that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformMultiLanguageProperty(IMultiLanguageProperty that, PathModifierContext context) { - if (context.ParentPath == null) + if (context.IsRoot) throw new InvalidSerializationModifierException("Path", that.GetType().Name); - - context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + if (string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + } return context.IdShortPaths; } public List TransformOperation(IOperation that, PathModifierContext context) { - context.IdShortPaths.Add(that.IdShort); - - if (that.InputVariables != null) - { - foreach (var element in that.InputVariables) - { - context.ParentPath = that.IdShort; - Transform(element, context); - } - } - - if (that.OutputVariables != null) + if (context.IsRoot && !context.IsGetAllSmes) + throw new InvalidSerializationModifierException("Path", that.GetType().Name); + if (string.IsNullOrEmpty(context.ParentPath)) { - foreach (var element in that.OutputVariables) - { - context.ParentPath = that.IdShort; - Transform(element, context); - } + context.IdShortPaths.Add(that.IdShort); } - - if (that.InoutputVariables != null) + else { - foreach (var element in that.InoutputVariables) - { - context.ParentPath = that.IdShort; - Transform(element, context); - } + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); } - return context.IdShortPaths; } public List TransformOperationVariable(IOperationVariable that, PathModifierContext context) { - if (context.ParentPath == null) + if (context.IsRoot) throw new InvalidSerializationModifierException("Path", that.GetType().Name); - context.IdShortPaths.Add(context.ParentPath + "." + that.Value.IdShort); + if (string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.Value.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.Value.IdShort}"); + } return context.IdShortPaths; } public List TransformProperty(IProperty that, PathModifierContext context) { - if (context.ParentPath == null) + if (context.IsRoot && !context.IsGetAllSmes) throw new InvalidSerializationModifierException("Path", that.GetType().Name); - context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + if (string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + } return context.IdShortPaths; } public List TransformQualifier(IQualifier that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformRange(IRange that, PathModifierContext context) { - if (context.ParentPath == null) + if (context.IsRoot) throw new InvalidSerializationModifierException("Path", that.GetType().Name); - - context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + if (string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + } return context.IdShortPaths; } public List TransformReference(IReference that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformReferenceElement(IReferenceElement that, PathModifierContext context) { - if (context.ParentPath == null) + if (context.IsRoot) throw new InvalidSerializationModifierException("Path", that.GetType().Name); - - context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + if (string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + } return context.IdShortPaths; } public List TransformRelationshipElement(IRelationshipElement that, PathModifierContext context) { - if (context.ParentPath == null) + if (context.IsRoot) throw new InvalidSerializationModifierException("Path", that.GetType().Name); - - context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + if (string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + } return context.IdShortPaths; } public List TransformResource(IResource that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformSpecificAssetId(ISpecificAssetId that, PathModifierContext context) @@ -296,13 +331,11 @@ public List TransformSpecificAssetId(ISpecificAssetId that, PathModifier public List TransformSubmodel(ISubmodel? that, PathModifierContext context) { - context.IdShortPaths.Add(that.IdShort); - if (that.SubmodelElements != null) { foreach (var element in that.SubmodelElements) { - context.ParentPath = that.IdShort; + context.IsRoot = false; Transform(element, context); } } @@ -312,7 +345,7 @@ public List TransformSubmodel(ISubmodel? that, PathModifierContext conte public List TransformSubmodelElementCollection(ISubmodelElementCollection that, PathModifierContext context) { - if (context.IdShortPaths.Count == 0) + if (context.IdShortPaths.Count == 0 || string.IsNullOrEmpty(context.ParentPath)) { context.IdShortPaths.Add(that.IdShort); } @@ -326,6 +359,7 @@ public List TransformSubmodelElementCollection(ISubmodelElementCollectio var currentParentPath = string.IsNullOrEmpty(context.ParentPath) ? that.IdShort : $"{context.ParentPath}.{that.IdShort}"; foreach (var item in that.Value) { + context.IsRoot = false ; context.ParentPath = currentParentPath; Transform(item, context); } @@ -336,6 +370,15 @@ public List TransformSubmodelElementCollection(ISubmodelElementCollectio public List TransformSubmodelElementList(ISubmodelElementList that, PathModifierContext context) { + if (context.IdShortPaths.Count == 0 || string.IsNullOrEmpty(context.ParentPath)) + { + context.IdShortPaths.Add(that.IdShort); + } + else + { + context.IdShortPaths.Add($"{context.ParentPath}.{that.IdShort}"); + } + if (that.Value != null) { for (var i = 0; i < that.Value.Count; i++) @@ -357,12 +400,12 @@ public List TransformSubmodelElementList(ISubmodelElementList that, Path public List TransformValueList(IValueList that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } public List TransformValueReferencePair(IValueReferencePair that, PathModifierContext context) { - throw new System.NotImplementedException(); + throw new InvalidSerializationModifierException("Path", that.GetType().Name); } } } diff --git a/src/IO.Swagger.Lib.V3/Services/Base64UrlDecoderService.cs b/src/IO.Swagger.Lib.V3/Services/Base64UrlDecoderService.cs index d4501df0a..1ea845293 100644 --- a/src/IO.Swagger.Lib.V3/Services/Base64UrlDecoderService.cs +++ b/src/IO.Swagger.Lib.V3/Services/Base64UrlDecoderService.cs @@ -22,20 +22,26 @@ namespace IO.Swagger.Lib.V3.Services; public class Base64UrlDecoderService : IBase64UrlDecoderService { /// - public string? Decode(string fieldName, string? encodedString) + public string Decode(string fieldName, string encodedString) { - if (string.IsNullOrEmpty(encodedString)) - { - return null; - } - try { - return Base64UrlEncoder.Decode(encodedString); + if (!string.IsNullOrEmpty(encodedString)) + { + return Base64UrlEncoder.Decode(encodedString); + } + else + { + throw new NoIdentifierException(fieldName); + } } catch (FormatException) { throw new Base64UrlDecoderException(fieldName); } + catch (Exception) + { + throw; + } } } \ No newline at end of file diff --git a/src/IO.Swagger.Lib.V3/Services/GenerateSerializationService.cs b/src/IO.Swagger.Lib.V3/Services/GenerateSerializationService.cs index b08c020dd..37c8b077a 100644 --- a/src/IO.Swagger.Lib.V3/Services/GenerateSerializationService.cs +++ b/src/IO.Swagger.Lib.V3/Services/GenerateSerializationService.cs @@ -29,6 +29,7 @@ public class GenerateSerializationService : IGenerateSerializationService private readonly IAppLogger _logger; private readonly IAssetAdministrationShellService _aasService; private readonly ISubmodelService _submodelService; + private readonly IConceptDescriptionService _cdService; /// /// Initializes a new instance of the class. @@ -39,17 +40,21 @@ public class GenerateSerializationService : IGenerateSerializationService /// /// Thrown when any of the required services (logger, aasService, submodelService) are null. /// - public GenerateSerializationService(IAppLogger logger, IAssetAdministrationShellService aasService, ISubmodelService submodelService) + public GenerateSerializationService(IAppLogger logger, IAssetAdministrationShellService aasService, ISubmodelService submodelService, IConceptDescriptionService cdService) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _aasService = aasService ?? throw new ArgumentNullException(nameof(aasService)); _submodelService = submodelService ?? throw new ArgumentNullException(nameof(submodelService)); + _cdService = cdService ?? throw new ArgumentNullException(nameof(cdService)); } /// - public Environment GenerateSerializationByIds(List? aasIds = null, List? submodelIds = null) + public Environment GenerateSerializationByIds(List? aasIds = null, List? submodelIds = null, bool? includeCD = false) { - var outputEnv = new Environment {AssetAdministrationShells = new List(), Submodels = new List()}; + List aas = null; + List submodels = null; + List conceptDescriptions = null; + var outputEnv = new Environment(aas, submodels, conceptDescriptions); //Fetch AASs for the requested aasIds var aasList = _aasService.GetAllAssetAdministrationShells(); @@ -58,27 +63,40 @@ public Environment GenerateSerializationByIds(List? aasIds = null, List { foreach (var foundAas in aasIds.Select(aasId => aasList.Where(a => a.Id != null && a.Id.Equals(aasId, StringComparison.Ordinal))).Where(foundAas => foundAas.Any())) { + outputEnv.AssetAdministrationShells ??= new List(); outputEnv.AssetAdministrationShells.Add(foundAas.First()); } } else { + outputEnv.AssetAdministrationShells ??= new List(); outputEnv.AssetAdministrationShells.AddRange(aasList); } //Fetch Submodels for the requested submodelIds var submodelList = _submodelService.GetAllSubmodels(); //Using is null or empty, as the query parameter in controll currently receives empty list (not null, but count = 0) - if (submodelIds.IsNullOrEmpty()) + if (!submodelIds.IsNullOrEmpty()) { + foreach (var foundSubmodel in submodelIds.Select(submodelId => submodelList.Where(s => s.Id != null && s.Id.Equals(submodelId, StringComparison.Ordinal))) + .Where(foundSubmodel => foundSubmodel.Any())) + { + outputEnv.Submodels ??= new List(); + outputEnv.Submodels.Add(foundSubmodel.First()); + } + } + else + { + outputEnv.Submodels ??= new List(); outputEnv.Submodels.AddRange(submodelList); - return outputEnv; } - foreach (var foundSubmodel in submodelIds.Select(submodelId => submodelList.Where(s => s.Id != null && s.Id.Equals(submodelId, StringComparison.Ordinal))) - .Where(foundSubmodel => foundSubmodel.Any())) + + + if((bool)includeCD) { - outputEnv.Submodels.Add(foundSubmodel.First()); + outputEnv.ConceptDescriptions ??= new List(); + outputEnv.ConceptDescriptions.AddRange(_cdService.GetAllConceptDescriptions()); } return outputEnv; diff --git a/src/IO.Swagger.Lib.V3/Services/LevelExtentModifierService.cs b/src/IO.Swagger.Lib.V3/Services/LevelExtentModifierService.cs index 5d07e9e25..bc11555ae 100644 --- a/src/IO.Swagger.Lib.V3/Services/LevelExtentModifierService.cs +++ b/src/IO.Swagger.Lib.V3/Services/LevelExtentModifierService.cs @@ -18,30 +18,39 @@ using System; using System.Collections.Generic; -namespace IO.Swagger.Lib.V3.Services; - -using System.Linq; - -/// -public class LevelExtentModifierService : ILevelExtentModifierService +namespace IO.Swagger.Lib.V3.Services { - private readonly LevelExtentTransformer _transformer = new(); - - /// - public IClass ApplyLevelExtent(IClass that, LevelEnum level = LevelEnum.Deep, ExtentEnum extent = ExtentEnum.WithoutBlobValue) - { - ArgumentNullException.ThrowIfNull(that); - - var context = new LevelExtentModifierContext(level, extent); - return _transformer.Transform(that, context); - } - - /// - public List ApplyLevelExtent(List that, LevelEnum level = LevelEnum.Deep, ExtentEnum extent = ExtentEnum.WithoutBlobValue) + public class LevelExtentModifierService : ILevelExtentModifierService { - ArgumentNullException.ThrowIfNull(that); - - var context = new LevelExtentModifierContext(level, extent); - return that.Select(source => source != null ? _transformer.Transform(source, context) : null).ToList(); + private readonly IAppLogger _logger; + LevelExtentTransformer _transformer; + + public LevelExtentModifierService(IAppLogger logger) + { + _logger = logger ?? throw new ArgumentNullException(nameof(logger)); + _transformer = new LevelExtentTransformer(); + } + + public IClass ApplyLevelExtent(IClass that, LevelEnum level = LevelEnum.Deep, ExtentEnum extent = ExtentEnum.WithoutBlobValue) + { + if (that == null) { throw new ArgumentNullException(nameof(that)); } + + var context = new LevelExtentModifierContext(level, extent); + return _transformer.Transform(that, context); + } + + public List ApplyLevelExtent(List sourceList, LevelEnum level = LevelEnum.Deep, ExtentEnum extent = ExtentEnum.WithoutBlobValue) + { + ArgumentNullException.ThrowIfNull(sourceList); + + var output = new List(); + var context = new LevelExtentModifierContext(level, extent, isGetAllSme: true); + foreach (var source in sourceList) + { + output.Add(_transformer.Transform(source, context)); + } + + return output; + } } -} \ No newline at end of file +} diff --git a/src/IO.Swagger.Lib.V3/Services/PathModifierService.cs b/src/IO.Swagger.Lib.V3/Services/PathModifierService.cs index ba08d4a37..4b3f7dc6d 100644 --- a/src/IO.Swagger.Lib.V3/Services/PathModifierService.cs +++ b/src/IO.Swagger.Lib.V3/Services/PathModifierService.cs @@ -14,6 +14,7 @@ using IO.Swagger.Lib.V3.Interfaces; using IO.Swagger.Lib.V3.SerializationModifiers.PathModifier; using System.Collections.Generic; +using System.Linq; namespace IO.Swagger.Lib.V3.Services { @@ -30,29 +31,29 @@ public List ToIdShortPath(IClass? that) return _pathTransformer.Transform(that, context); } - public List> ToIdShortPath(List submodelList) + public List ToIdShortPath(List submodelList) { - var output = new List>(); + var output = new List(); foreach (var submodel in submodelList) { var context = new PathModifierContext(); var path = _pathTransformer.Transform(submodel, context); - output.Add(path); + output.AddRange(path); } return output; } - public List> ToIdShortPath(List submodelElementList) + public List ToIdShortPath(List submodelElementList) { - var output = new List>(); - + //var output = new List>(); + var output = new List(); foreach (var submodelElement in submodelElementList) { - var context = new PathModifierContext(); + var context = new PathModifierContext(isGetAllSmes: true); var path = _pathTransformer.Transform(submodelElement, context); - output.Add(path); + output.AddRange(path); } return output; diff --git a/src/IO.Swagger.Lib.V3/Services/ValidateSerializationModifierService.cs b/src/IO.Swagger.Lib.V3/Services/ValidateSerializationModifierService.cs new file mode 100644 index 000000000..9aa1f27e2 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Services/ValidateSerializationModifierService.cs @@ -0,0 +1,61 @@ +/******************************************************************************** +* Copyright (c) {2019 - 2024} Contributors to the Eclipse Foundation +* +* See the NOTICE file(s) distributed with this work for additional +* information regarding copyright ownership. +* +* This program and the accompanying materials are made available under the +* terms of the Apache License Version 2.0 which is available at +* https://www.apache.org/licenses/LICENSE-2.0 +* +* SPDX-License-Identifier: Apache-2.0 +********************************************************************************/ + +namespace IO.Swagger.Lib.V3.Services; + +using System; +using System.Reflection.Emit; +using System.Xml.Linq; +using IO.Swagger.Lib.V3.Exceptions; +using IO.Swagger.Lib.V3.Interfaces; +using IO.Swagger.Models; + +public class ValidateSerializationModifierService : IValidateSerializationModifierService +{ + /// + public ExtentEnum ValidateExtent(string extent) + { + ExtentEnum result = ExtentEnum.WithoutBlobValue; + if (!string.IsNullOrEmpty(extent)) + { + try + { + result = Enum.Parse(extent, true); + } + catch (Exception e) + { + throw new InvalidSerializationModifierException("extent"); + } + } + + return result; + } + /// + public LevelEnum ValidateLevel(string level) + { + LevelEnum result = LevelEnum.Deep; + if (!string.IsNullOrEmpty(level)) + { + try + { + result = Enum.Parse(level, true); + } + catch(Exception e) + { + throw new InvalidSerializationModifierException("level"); + } + } + + return result; + } +} diff --git a/src/IO.Swagger.Registry.Lib.V3/Controllers/AssetAdministrationShellRegistryAPIApi.cs b/src/IO.Swagger.Registry.Lib.V3/Controllers/AssetAdministrationShellRegistryAPIApi.cs index 882dcb0cb..ebd6bb5be 100644 --- a/src/IO.Swagger.Registry.Lib.V3/Controllers/AssetAdministrationShellRegistryAPIApi.cs +++ b/src/IO.Swagger.Registry.Lib.V3/Controllers/AssetAdministrationShellRegistryAPIApi.cs @@ -214,7 +214,7 @@ public virtual IActionResult GetAllAssetAdministrationShellDescriptors([FromQuer [SwaggerResponse(statusCode: 404, type: typeof(Result), description: "Not Found")] [SwaggerResponse(statusCode: 500, type: typeof(Result), description: "Internal Server Error")] [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] - public virtual IActionResult GetAllSubmodelDescriptorsThroughSuperpath([FromRoute] [Required] string aasIdentifier, + public virtual IActionResult GetAllSubmodelDescriptorsThroughSuperpath([FromRoute] [Required] string? aasIdentifier, [FromQuery] int? limit, [FromQuery] string cursor) {