diff --git a/src/AasxServerStandardBib/AasxCompatibilityModels/V10/AdminShellV10.cs b/src/AasxCsharpLibrary/AasxCompatibilityModels/V10/AdminShellV10.cs similarity index 89% rename from src/AasxServerStandardBib/AasxCompatibilityModels/V10/AdminShellV10.cs rename to src/AasxCsharpLibrary/AasxCompatibilityModels/V10/AdminShellV10.cs index 003c671a5..18999575b 100644 --- a/src/AasxServerStandardBib/AasxCompatibilityModels/V10/AdminShellV10.cs +++ b/src/AasxCsharpLibrary/AasxCompatibilityModels/V10/AdminShellV10.cs @@ -1,4 +1,11 @@ -#define UseAasxCompatibilityModels +/* +Copyright (c) 2018-2021 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ using System; using System.Collections; @@ -14,24 +21,18 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; -/* Copyright (c) 2018-2019 Festo AG & Co. KG , author: Michael Hoffmeister - -This source code is licensed under the Apache License 2.0 (see LICENSE.txt). - -This source code may use other Open Source software components (see LICENSE.txt). -*/ - +// ReSharper disable All .. as this is legacy code! -#if UseAasxCompatibilityModels +#if !DoNotUseAasxCompatibilityModels namespace AasxCompatibilityModels { #region Utils - // + // // Utils // - public class AdminShellUtil + public class AdminShellUtilV10 { public static string EvalToNonNullString(string fmt, object o, string elseString = "") { @@ -57,20 +58,21 @@ public static string FilterFriendlyName(string src) public static bool HasWhitespace(string src) { if (src == null) - throw new ArgumentNullException("src"); + throw new ArgumentNullException(nameof(src)); for (var i = 0; i < src.Length; i++) - if (char.IsWhiteSpace(src[i])) - return true; + foreach (var c in src) + if (char.IsWhiteSpace(c)) + return true; return false; } public static bool ComplyIdShort(string src) { if (src == null) - throw new ArgumentNullException("src"); + throw new ArgumentNullException(nameof(src)); var res = true; - for (var i = 0; i < src.Length; i++) - if (!Char.IsLetterOrDigit(src[i]) && src[i] != '_') + foreach (var c in src) + if (!Char.IsLetterOrDigit(c) && c != '_') res = false; if (src.Length > 0 && !Char.IsLetter(src[0])) res = false; @@ -94,7 +96,7 @@ public static string ShortLocation(Exception ex) if (currLine >= lines.Length) return ""; // access current line - var p = lines[currLine].IndexOf(" in "); + var p = lines[currLine].IndexOf(" in ", StringComparison.Ordinal); if (p < 0) { // advance to next oldest line @@ -102,7 +104,7 @@ public static string ShortLocation(Exception ex) continue; } // search last "\" or "/", to get only filename portion and position - p = lines[currLine].LastIndexOfAny(new char[] { '\\', '/' }); + p = lines[currLine].LastIndexOfAny(new[] { '\\', '/' }); if (p < 0) { // advance to next oldest line @@ -1090,7 +1092,7 @@ public virtual string GetElementName() public string GetFriendlyName() { - return AdminShellUtil.FilterFriendlyName(this.idShort); + return AdminShellUtilV10.FilterFriendlyName(this.idShort); } public void CollectReferencesByParent(List refs) @@ -1099,7 +1101,8 @@ public void CollectReferencesByParent(List refs) if (this is Identifiable) { var idf = this as Identifiable; - var k = Key.CreateNew(idf.GetElementName(), true, idf.identification.idType, idf.identification.id); + var k = Key.CreateNew( + idf.GetElementName(), true, idf.identification.idType, idf.identification.id); refs.Insert(0, k); } else @@ -1168,8 +1171,8 @@ public void SetAdminstration(string version, string revision) public new string GetFriendlyName() { if (identification != null && identification.id != "") - return AdminShellUtil.FilterFriendlyName(this.identification.id); - return AdminShellUtil.FilterFriendlyName(this.idShort); + return AdminShellUtilV10.FilterFriendlyName(this.identification.id); + return AdminShellUtilV10.FilterFriendlyName(this.idShort); } } @@ -1245,7 +1248,8 @@ public AdministrationShell(AdministrationShell src) } } - public static AdministrationShell CreateNew(string idType, string id, string version = null, string revision = null) + public static AdministrationShell CreateNew( + string idType, string id, string version = null, string revision = null) { var s = new AdministrationShell(); s.identification.idType = idType; @@ -1287,7 +1291,7 @@ public override string GetElementName() public Tuple ToCaptionInfo() { - var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, "\"AAS\""); + var caption = AdminShellUtilV10.EvalToNonNullString("\"{0}\" ", idShort, "\"AAS\""); if (administration != null) caption += "V" + administration.version + "." + administration.revision; @@ -1389,7 +1393,8 @@ public Asset(Asset src) public AssetRef GetReference() { var r = new AssetRef(); - r.Keys.Add(Key.CreateNew(this.GetElementName(), true, this.identification.idType, this.identification.id)); + r.Keys.Add( + Key.CreateNew(this.GetElementName(), true, this.identification.idType, this.identification.id)); return r; } @@ -1400,7 +1405,7 @@ public override string GetElementName() public Tuple ToCaptionInfo() { - var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, ""); + var caption = AdminShellUtilV10.EvalToNonNullString("\"{0}\" ", idShort, ""); if (administration != null) caption += "V" + administration.version + "." + administration.revision; @@ -1454,7 +1459,14 @@ public ContainedElementRef[] JsonContainedElements [JsonIgnore] public int Count { get { if (containedElements == null) return 0; return containedElements.Count; } } - public ContainedElementRef this[int index] { get { if (containedElements == null) return null; return containedElements[index]; } } + public ContainedElementRef this[int index] + { + get + { + if ( +containedElements == null) return null; return containedElements[index]; + } + } // constructors / creators @@ -1528,12 +1540,13 @@ public override string GetElementName() public Tuple ToCaptionInfo() { - var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, ""); + var caption = AdminShellUtilV10.EvalToNonNullString("\"{0}\" ", idShort, ""); var info = ""; if (this.semanticId != null) info = Key.KeyListToString(this.semanticId.Keys); if (this.containedElements != null && this.containedElements.reference != null) - info = (info + " ").Trim() + String.Format("({0} elements)", this.containedElements.reference.Count); + info = + (info + " ").Trim() + String.Format("({0} elements)", this.containedElements.reference.Count); return Tuple.Create(caption, info); } @@ -1716,10 +1729,9 @@ public class DataSpecificationIEC61360 public List sourceOfDefinition = new List(); public string symbol = null; public string dataType = ""; - // public List definition = new List(); public LangStringIEC61360 definition = new LangStringIEC61360(); - // getter / setters + // getter / setters // constructors @@ -1828,7 +1840,7 @@ public class ConceptDescription : Identifiable, System.IDisposable void System.IDisposable.Dispose() { } public void GetData() { } // from HasDataSpecification - // TODO: in V1.0, shall be a list of embeddedDataSpecification + // TODO (Michael Hoffmeister, 1970-01-01): in V1.0, shall be a list of embeddedDataSpecification [XmlElement(ElementName = "embeddedDataSpecification")] [JsonIgnore] public EmbeddedDataSpecification embeddedDataSpecification = new EmbeddedDataSpecification(); @@ -1851,11 +1863,6 @@ public EmbeddedDataSpecification[] JsonEmbeddedDataSpecifications } } - - // old - // [XmlElement(ElementName="conceptDefinitionRef")] - // public Reference conceptDefinitionRef = null ; - // this class [XmlIgnore] private List isCaseOf = null; @@ -1888,7 +1895,8 @@ public ConceptDescription(ConceptDescription src) } } - public static ConceptDescription CreateNew(string idType, string id, string version = null, string revision = null) + public static ConceptDescription CreateNew( + string idType, string id, string version = null, string revision = null) { var cd = new ConceptDescription(); cd.identification.idType = idType; @@ -1906,7 +1914,8 @@ public static ConceptDescription CreateNew(string idType, string id, string vers public ConceptDescriptionRef GetReference() { var r = new ConceptDescriptionRef(); - r.Keys.Add(Key.CreateNew(this.GetElementName(), true, this.identification.idType, this.identification.id)); + r.Keys.Add( + Key.CreateNew(this.GetElementName(), true, this.identification.idType, this.identification.id)); return r; } @@ -1930,23 +1939,32 @@ public void SetIEC61360Spec( ) { this.embeddedDataSpecification = new EmbeddedDataSpecification(); - this.embeddedDataSpecification.hasDataSpecification.Keys.Add(Key.CreateNew("GlobalReference", false, "URI", "www.admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360")); - this.embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360 = AdminShellV10.DataSpecificationIEC61360.CreateNew( - preferredNames, shortName, unit, unitId, valueFormat, sourceOfDefinition, symbol, dataType, definition - ); - this.AddIsCaseOf(Reference.CreateNew(new Key("ConceptDescription", false, this.identification.idType, this.identification.id))); + this.embeddedDataSpecification.hasDataSpecification.Keys.Add( + Key.CreateNew("GlobalReference", false, "URI", + "www.admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360")); + this.embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360 = + AdminShellV10.DataSpecificationIEC61360.CreateNew( + preferredNames, shortName, unit, unitId, valueFormat, sourceOfDefinition, symbol, dataType, + definition); + this.AddIsCaseOf( + Reference.CreateNew(new Key( + "ConceptDescription", false, this.identification.idType, this.identification.id))); } public DataSpecificationIEC61360 GetIEC61360() { - if (embeddedDataSpecification != null && embeddedDataSpecification.dataSpecificationContent != null && embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360 != null) + if (embeddedDataSpecification != null && + embeddedDataSpecification.dataSpecificationContent != null && + embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360 != null) return embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360; return null; } public string GetShortName() { - if (embeddedDataSpecification != null && embeddedDataSpecification.dataSpecificationContent != null && embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360 != null) + if (embeddedDataSpecification != null && + embeddedDataSpecification.dataSpecificationContent != null && + embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360 != null) return embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360.shortName; return ""; } @@ -1965,7 +1983,9 @@ public Tuple ToCaptionInfo() caption = (caption + " " + this.identification).Trim(); var info = ""; - if (embeddedDataSpecification != null && embeddedDataSpecification.dataSpecificationContent != null && embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360 != null) + if (embeddedDataSpecification != null && + embeddedDataSpecification.dataSpecificationContent != null && + embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360 != null) info += embeddedDataSpecification.dataSpecificationContent.dataSpecificationIEC61360.shortName; return Tuple.Create(caption, info); @@ -2033,9 +2053,10 @@ public override string GetElementName() public class AdministrationShellEnv { [XmlAttribute(Namespace = System.Xml.Schema.XmlSchema.InstanceNamespace)] - public string schemaLocation = "http://www.admin-shell.io/aas/1/0 AAS.xsd http://www.admin-shell.io/IEC61360/1/0 IEC61360.xsd"; + public string schemaLocation = + "http://www.admin-shell.io/aas/1/0 AAS.xsd http://www.admin-shell.io/IEC61360/1/0 IEC61360.xsd"; - // [XmlElement(ElementName="assetAdministrationShells")] + /// [XmlElement(ElementName="assetAdministrationShells")] [XmlIgnore] // will be ignored, anyway private List administrationShells = new List(); [XmlIgnore] // will be ignored, anyway @@ -2144,7 +2165,7 @@ public Asset FindAsset(AssetRef aref) if (a.identification.idType.ToLower().Trim() == key.idType.ToLower().Trim() && a.identification.id.ToLower().Trim() == key.value.ToLower().Trim()) return a; - // uups + // uups return null; } @@ -2175,31 +2196,10 @@ public Submodel FindSubmodel(SubmodelRef smref) if (sm.identification.idType.ToLower().Trim() == key.idType.ToLower().Trim() && sm.identification.id.ToLower().Trim() == key.value.ToLower().Trim()) return sm; - // uups + // uups return null; } - /* OLD VERSION. OPC UA -> inadequate for finding all References - public Referable FindReferableByReference(Reference rf, int keyIndex = 0) - { - // first index needs to exist .. - if (rf == null || keyIndex >= rf.Count) - return null; - - // .. and point to an Submodel - if (rf[keyIndex].type.Trim().ToLower() != Key.Submodel.Trim().ToLower()) - return null; - - // ok, search Submodel - var sm = this.FindSubmodel(new Identification(rf[keyIndex].idType, rf[keyIndex].value)); - if (sm == null) - return null; - - // go inside - return SubmodelElementWrapper.FindReferableByReference(sm.submodelElements, rf, keyIndex + 1); - } - */ - public Referable FindReferableByReference(Reference rf, int keyIndex = 0) { // first index needs to exist .. @@ -2269,7 +2269,7 @@ public ConceptDescription FindConceptDescription(List keys) if (cd.identification.idType.ToLower().Trim() == key.idType.ToLower().Trim() && cd.identification.id.ToLower().Trim() == key.value.ToLower().Trim()) return cd; - // uups + // uups return null; } @@ -2284,7 +2284,8 @@ public ConceptDescription FindConceptDescription(Key key) // creators - private void CopyConceptDescriptionsFrom(AdministrationShellEnv srcEnv, SubmodelElement src, bool shallowCopy = false) + private void CopyConceptDescriptionsFrom( + AdministrationShellEnv srcEnv, SubmodelElement src, bool shallowCopy = false) { // access if (srcEnv == null || src == null || src.semanticId == null) @@ -2306,7 +2307,8 @@ private void CopyConceptDescriptionsFrom(AdministrationShellEnv srcEnv, Submodel } - public SubmodelElementWrapper CopySubmodelElementAndCD(AdministrationShellEnv srcEnv, SubmodelElement srcElem, bool copyCD = false, bool shallowCopy = false) + public SubmodelElementWrapper CopySubmodelElementAndCD( + AdministrationShellEnv srcEnv, SubmodelElement srcElem, bool copyCD = false, bool shallowCopy = false) { // access if (srcEnv == null || srcElem == null) @@ -2323,7 +2325,9 @@ public SubmodelElementWrapper CopySubmodelElementAndCD(AdministrationShellEnv sr return res; } - public SubmodelRef CopySubmodelRefAndCD(AdministrationShellEnv srcEnv, SubmodelRef srcSubRef, bool copySubmodel = false, bool copyCD = false, bool shallowCopy = false) + public SubmodelRef CopySubmodelRefAndCD( + AdministrationShellEnv srcEnv, SubmodelRef srcSubRef, bool copySubmodel = false, bool copyCD = false, + bool shallowCopy = false) { // access if (srcEnv == null || srcSubRef == null) @@ -2400,7 +2404,8 @@ public JsonWriter SerialiazeJsonToStream(StreamWriter sw, bool leaveJsonWriterOp public AdministrationShellEnv DeserializeFromXmlStream(TextReader reader) { - XmlSerializer serializer = new XmlSerializer(typeof(AdminShellV10.AdministrationShellEnv), "http://www.admin-shell.io/aas/1/0"); + XmlSerializer serializer = new XmlSerializer( + typeof(AdminShellV10.AdministrationShellEnv), "http://www.admin-shell.io/aas/1/0"); var res = serializer.Deserialize(reader) as AdminShellV10.AdministrationShellEnv; return res; } @@ -2415,7 +2420,9 @@ public AdministrationShellEnv DeserializeFromJsonStream(TextReader reader) // special functions - private static void CreateFromExistingEnvRecurseForCDs(AdministrationShellEnv src, List wrappers, ref List filterForCD) + private static void CreateFromExistingEnvRecurseForCDs( + AdministrationShellEnv src, List wrappers, + ref List filterForCD) { if (wrappers == null || filterForCD == null) return; @@ -2432,7 +2439,8 @@ private static void CreateFromExistingEnvRecurseForCDs(AdministrationShellEnv sr // recurse? if (w.submodelElement is SubmodelElementCollection) - CreateFromExistingEnvRecurseForCDs(src, (w.submodelElement as SubmodelElementCollection).value, ref filterForCD); + CreateFromExistingEnvRecurseForCDs( + src, (w.submodelElement as SubmodelElementCollection).value, ref filterForCD); if (w.submodelElement is Operation) for (int i = 0; i < 2; i++) @@ -2488,7 +2496,8 @@ public static AdministrationShellEnv CreateFromExistingEnv(AdministrationShellEn if (aas.conceptDictionaries != null) foreach (var cdd in aas.conceptDictionaries) - if (cdd.conceptDescriptionsRefs != null && cdd.conceptDescriptionsRefs.conceptDescriptions != null) + if (cdd.conceptDescriptionsRefs != null && + cdd.conceptDescriptionsRefs.conceptDescriptions != null) foreach (var cdr in cdd.conceptDescriptionsRefs.conceptDescriptions) { var cd = src.FindConceptDescription(cdr); @@ -2512,7 +2521,7 @@ public static AdministrationShellEnv CreateFromExistingEnv(AdministrationShellEn // take over res.submodels.Add(new Submodel(sm)); - // recursion in order to find used CDs ... :-( + // recursion in order to find used CDs CreateFromExistingEnvRecurseForCDs(src, sm.submodelElements, ref filterForCD); } @@ -2549,16 +2558,13 @@ public class Qualifier // from hasSemantics: [XmlElement(ElementName = "semanticId")] - // TODO: Qualifiers not working! + // TODO (Michael Hoffmeister, 1970-01-01): Qualifiers not working! // 190410: test-wise enable them again, everyhing works fine .. - // [JsonIgnore] public SemanticId semanticId = null; + // this class - // [JsonIgnore] public string qualifierType = null; - // [JsonIgnore] public string qualifierValue = null; - // [JsonIgnore] public Reference qualifierValueId = null; // constructors @@ -2665,7 +2671,9 @@ public void CreateNewLogic(string idShort = null, string category = null, Key se } } - public void AddQualifier(string qualifierType = null, string qualifierValue = null, KeyList semanticKeys = null, Reference qualifierValueId = null) + public void AddQualifier( + string qualifierType = null, string qualifierValue = null, KeyList semanticKeys = null, + Reference qualifierValueId = null) { if (this.qualifiers == null) this.qualifiers = new List(); @@ -2726,10 +2734,10 @@ public Reference GetReference() public Tuple ToCaptionInfo() { - var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, ""); + var caption = AdminShellUtilV10.EvalToNonNullString("\"{0}\" ", idShort, ""); var info = ""; if (semanticId != null) - AdminShellUtil.EvalToNonEmptyString("\u21e8 {0}", semanticId.ToString(), ""); + info = AdminShellUtilV10.EvalToNonEmptyString("\u21e8 {0}", semanticId.ToString(), ""); return Tuple.Create(caption, info); } @@ -2758,7 +2766,8 @@ public class SubmodelElementWrapper public SubmodelElement submodelElement; // element names - public static string[] AdequateElementNames = { "SubmodelElementCollection", "Property", "File", "Blob", "ReferenceElement", + public static string[] AdequateElementNames = { + "SubmodelElementCollection", "Property", "File", "Blob", "ReferenceElement", "RelationshipElement", "Operation", "OperationVariable" }; // constructors @@ -2779,7 +2788,8 @@ public SubmodelElementWrapper(SubmodelElement src, bool shallowCopy = false) if (src is RelationshipElement) this.submodelElement = new RelationshipElement(src as RelationshipElement); if (src is SubmodelElementCollection) - this.submodelElement = new SubmodelElementCollection(src as SubmodelElementCollection, shallowCopy: shallowCopy); + this.submodelElement = new SubmodelElementCollection( + src as SubmodelElementCollection, shallowCopy: shallowCopy); if (src is Operation) this.submodelElement = new Operation(src as Operation); } @@ -2880,20 +2890,23 @@ public static SubmodelElementWrapper CreateFor(SubmodelElement sme) return res; } - public static Referable FindReferableByReference(List wrappers, Reference rf, int keyIndex) + public static Referable FindReferableByReference( + List wrappers, Reference rf, int keyIndex) { // first index needs to exist .. if (wrappers == null || rf == null || keyIndex >= rf.Count) return null; // as SubmodelElements are not Identifiables, the actual key shall be IdSHort - if (rf[keyIndex].idType.Trim().ToLower() != Key.GetIdentifierTypeName(Key.IdentifierType.IdShort).Trim().ToLower()) + if (rf[keyIndex].idType.Trim().ToLower() != + Key.GetIdentifierTypeName(Key.IdentifierType.IdShort).Trim().ToLower()) return null; // over all wrappers if (wrappers != null) foreach (var smw in wrappers) - if (smw.submodelElement != null && smw.submodelElement.idShort.Trim().ToLower() == rf[keyIndex].value.Trim().ToLower()) + if (smw.submodelElement != null && + smw.submodelElement.idShort.Trim().ToLower() == rf[keyIndex].value.Trim().ToLower()) { // match on this level. Did we find a leaf element? if ((keyIndex + 1) >= rf.Count) @@ -2902,11 +2915,12 @@ public static Referable FindReferableByReference(List wr // ok, not a leaf, must be a recursion // int SMEC if (smw.submodelElement is SubmodelElementCollection) - return FindReferableByReference((smw.submodelElement as SubmodelElementCollection).value, rf, keyIndex + 1); + return FindReferableByReference( + (smw.submodelElement as SubmodelElementCollection).value, rf, keyIndex + 1); - // TODO: Operation + // TODO (Michael Hoffmeister, 1970-01-01): Operation - // else: :-( + // else: return null; } @@ -2959,23 +2973,11 @@ public string JsonKind [XmlArrayItem("qualifier")] public List qualifiers = null; - // from this very class + // from this very class [JsonIgnore] public List submodelElements = null; [XmlIgnore] [JsonProperty(PropertyName = "submodelElements")] - /* - public IEnumerator JsonSubmodelElements - { - get - { - if (submodelElements == null) - yield return null; - foreach (var smew in submodelElements) - yield return smew.submodelElement; - } - } - */ public SubmodelElement[] JsonSubmodelElements { get @@ -3000,7 +3002,6 @@ public SubmodelElement[] JsonSubmodelElements } } } - // public List JsonSubmodelElements = new List(); // getter / setter @@ -3049,7 +3050,8 @@ public override string GetElementName() public Reference GetReference() { SubmodelRef l = new SubmodelRef(); - l.Keys.Add(Key.CreateNew(this.GetElementName(), true, this.identification.idType, this.identification.id)); + l.Keys.Add( + Key.CreateNew(this.GetElementName(), true, this.identification.idType, this.identification.id)); return l; } @@ -3085,7 +3087,7 @@ public SubmodelElementWrapper FindSubmodelElementWrapper(string idShort) public Tuple ToCaptionInfo() { - var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, ""); + var caption = AdminShellUtilV10.EvalToNonNullString("\"{0}\" ", idShort, ""); if (administration != null) caption += "V" + administration.version + "." + administration.revision; var info = ""; @@ -3102,7 +3104,9 @@ public override string ToString() // Recursing - private void RecurseOnSubmodelElementsRecurse(List wrappers, object state, List parents, Action, SubmodelElement> lambda) + private void RecurseOnSubmodelElementsRecurse( + List wrappers, object state, List parents, + Action, SubmodelElement> lambda) { // trivial if (wrappers == null || parents == null || lambda == null) @@ -3140,7 +3144,8 @@ private void RecurseOnSubmodelElementsRecurse(List wrapp } } - public void RecurseOnSubmodelElements(object state, Action, SubmodelElement> lambda) + public void RecurseOnSubmodelElements( + object state, Action, SubmodelElement> lambda) { RecurseOnSubmodelElementsRecurse(this.submodelElements, state, new List(), lambda); } @@ -3207,7 +3212,10 @@ public class Property : DataElement // for JSON only [XmlIgnore] [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } + public new JsonModelTypeWrapper JsonModelType + { + get { return new JsonModelTypeWrapper(GetElementName()); } + } // members @@ -3267,7 +3275,10 @@ public class Blob : DataElement // for JSON only [XmlIgnore] [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } + public new JsonModelTypeWrapper JsonModelType + { + get { return new JsonModelTypeWrapper(GetElementName()); } + } // members @@ -3310,7 +3321,10 @@ public class File : DataElement // for JSON only [XmlIgnore] [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } + public new JsonModelTypeWrapper JsonModelType + { + get { return new JsonModelTypeWrapper(GetElementName()); } + } // members @@ -3370,7 +3384,10 @@ public class ReferenceElement : DataElement // for JSON only [XmlIgnore] [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } + public new JsonModelTypeWrapper JsonModelType + { + get { return new JsonModelTypeWrapper(GetElementName()); } + } // members @@ -3387,7 +3404,8 @@ public ReferenceElement(ReferenceElement src) this.value = new Reference(src.value); } - public static ReferenceElement CreateNew(string idShort = null, string category = null, Key semanticIdKey = null) + public static ReferenceElement CreateNew( + string idShort = null, string category = null, Key semanticIdKey = null) { var x = new ReferenceElement(); x.CreateNewLogic(idShort, category, semanticIdKey); @@ -3411,7 +3429,10 @@ public class RelationshipElement : DataElement // for JSON only [XmlIgnore] [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } + public new JsonModelTypeWrapper JsonModelType + { + get { return new JsonModelTypeWrapper(GetElementName()); } + } // members @@ -3431,7 +3452,8 @@ public RelationshipElement(RelationshipElement src) this.second = new Reference(src.second); } - public static RelationshipElement CreateNew(string idShort = null, string category = null, Key semanticIdKey = null) + public static RelationshipElement CreateNew( + string idShort = null, string category = null, Key semanticIdKey = null) { var x = new RelationshipElement(); x.CreateNewLogic(idShort, category, semanticIdKey); @@ -3455,7 +3477,10 @@ public class SubmodelElementCollection : SubmodelElement // for JSON only [XmlIgnore] [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } + public new JsonModelTypeWrapper JsonModelType + { + get { return new JsonModelTypeWrapper(GetElementName()); } + } // members [JsonIgnore] @@ -3463,21 +3488,6 @@ public class SubmodelElementCollection : SubmodelElement [XmlIgnore] [JsonProperty(PropertyName = "value")] - /* - public IEnumerator JsonValue - { - get - { - /* - if (value == null) - yield return null; - var sme = new Property(); - sme.idShort = "test"; - yield return sme; - yield break; - } - } - */ public SubmodelElement[] JsonValue { get @@ -3502,7 +3512,6 @@ public SubmodelElement[] JsonValue } } } - // public List JsonSubmodelElements = new List(); // further members public bool ordered = false; @@ -3522,7 +3531,8 @@ public SubmodelElementCollection(SubmodelElementCollection src, bool shallowCopy value.Add(new SubmodelElementWrapper(smw.submodelElement)); } - public static SubmodelElementCollection CreateNew(string idShort = null, string category = null, Key semanticIdKey = null) + public static SubmodelElementCollection CreateNew( + string idShort = null, string category = null, Key semanticIdKey = null) { var x = new SubmodelElementCollection(); x.CreateNewLogic(idShort, category, semanticIdKey); @@ -3572,7 +3582,10 @@ public enum Direction { In, Out }; // for JSON only [XmlIgnore] [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } + public new JsonModelTypeWrapper JsonModelType + { + get { return new JsonModelTypeWrapper(GetElementName()); } + } // members public SubmodelElementWrapper value = null; @@ -3607,7 +3620,10 @@ public class Operation : SubmodelElement // for JSON only [XmlIgnore] [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } + public new JsonModelTypeWrapper JsonModelType + { + get { return new JsonModelTypeWrapper(GetElementName()); } + } // members [JsonIgnore] @@ -3621,7 +3637,6 @@ public class Operation : SubmodelElement [XmlIgnore] // MICHA 190504: enabled JSON operation variables! [JsonProperty(PropertyName = "in")] - // [JsonIgnore] public OperationVariable[] JsonValueIn { get { return valueIn?.ToArray(); } @@ -3631,7 +3646,6 @@ public OperationVariable[] JsonValueIn [XmlIgnore] [JsonProperty(PropertyName = "out")] // MICHA 190504: enabled JSON operation variables! - // [JsonIgnore] public OperationVariable[] JsonValueOut { get { return valueOut?.ToArray(); } @@ -3706,9 +3720,11 @@ public override string GetElementName() // /// - /// This converter is used for reading JSON files; it claims to be responsible for "SubmodelElements" (the base class) - /// and decides, which sub-class of the base class shall be populated. - /// The decision, shich special sub-class to create is done in a factory AdminShell.SubmodelElementWrapper.CreateAdequateType(), + /// This converter is used for reading JSON files; it claims to be responsible for + /// "SubmodelElements" (the base class) + /// and decides, which sub-class of the base class shall be populated. + /// The decision, shich special sub-class to create is done in a factory + /// AdminShell.SubmodelElementWrapper.CreateAdequateType(), /// in order to have all sub-class specific decisions in one place (SubmodelElementWrapper) /// Remark: There is a NuGet package JsonSubTypes, which could have done the job, except the fact of having /// "modelType" being a class property with a contained property "name". @@ -3759,7 +3775,9 @@ public override object ReadJson(JsonReader reader, var cprop = c as Newtonsoft.Json.Linq.JProperty; if (cprop == null) continue; - if (cprop.Name == LowerClassProperty && cprop.Value != null && cprop.Value.Type.ToString() == "String") + if (cprop.Name == LowerClassProperty && + cprop.Value != null && + cprop.Value.Type.ToString() == "String") { var cpval = cprop.Value.ToObject(); if (cpval == null) @@ -3798,7 +3816,9 @@ public enum SpecialHandlingType { None, EmbedAsThumbnail } public LocationType location = LocationType.InPackage; public SpecialHandlingType specialHandling = SpecialHandlingType.None; - public PackageSupplementaryFile(Uri uri, string sourcePath = null, LocationType location = LocationType.InPackage, SpecialHandlingType specialHandling = SpecialHandlingType.None) + public PackageSupplementaryFile( + Uri uri, string sourcePath = null, LocationType location = LocationType.InPackage, + SpecialHandlingType specialHandling = SpecialHandlingType.None) { this.uri = uri; this.sourcePath = sourcePath; @@ -3877,8 +3897,9 @@ public bool Load(string fn) // load only XML try { - // TODO: use aasenv serialzers here! - XmlSerializer serializer = new XmlSerializer(typeof(AdminShellV10.AdministrationShellEnv), "http://www.admin-shell.io/aas/1/0"); + // TODO (Michael Hoffmeister, 1970-01-01): use aasenv serialzers here! + XmlSerializer serializer = new XmlSerializer( + typeof(AdminShellV10.AdministrationShellEnv), "http://www.admin-shell.io/aas/1/0"); TextReader reader = new StreamReader(fn); this.aasenv = serializer.Deserialize(reader) as AdminShellV10.AdministrationShellEnv; if (this.aasenv == null) @@ -3887,7 +3908,9 @@ public bool Load(string fn) } catch (Exception ex) { - throw (new Exception(string.Format("While reading AAS {0} at {1} gave: {2}", fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + throw (new Exception( + string.Format("While reading AAS {0} at {1} gave: {2}", fn, + AdminShellUtilV10.ShortLocation(ex), ex.Message))); } return true; } @@ -3899,15 +3922,18 @@ public bool Load(string fn) { using (StreamReader file = System.IO.File.OpenText(fn)) { - // TODO: use aasenv serialzers here! + // TODO (Michael Hoffmeister, 1970-01-01): use aasenv serialzers here! JsonSerializer serializer = new JsonSerializer(); serializer.Converters.Add(new AdminShellV10.JsonAasxConverter("modelType", "name")); - this.aasenv = (AdministrationShellEnv)serializer.Deserialize(file, typeof(AdministrationShellEnv)); + this.aasenv = (AdministrationShellEnv)serializer.Deserialize( + file, typeof(AdministrationShellEnv)); } } catch (Exception ex) { - throw (new Exception(string.Format("While reading AAS {0} at {1} gave: {2}", fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + throw (new Exception( + string.Format("While reading AAS {0} at {1} gave: {2}", + fn, AdminShellUtilV10.ShortLocation(ex), ex.Message))); } return true; } @@ -3921,7 +3947,8 @@ public bool Load(string fn) // get the origin from the package PackagePart originPart = null; - var xs = package.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aasx-origin"); + var xs = package.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aasx-origin"); foreach (var x in xs) if (x.SourceUri.ToString() == "/") { @@ -3933,7 +3960,8 @@ public bool Load(string fn) // get the specs from the package PackagePart specPart = null; - xs = originPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-spec"); + xs = originPart.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aas-spec"); foreach (var x in xs) { specPart = package.GetPart(x.TargetUri); @@ -3952,8 +3980,10 @@ public bool Load(string fn) using (StreamReader file = new StreamReader(s)) { JsonSerializer serializer = new JsonSerializer(); - serializer.Converters.Add(new AdminShellV10.JsonAasxConverter("modelType", "name")); - this.aasenv = (AdministrationShellEnv)serializer.Deserialize(file, typeof(AdministrationShellEnv)); + serializer.Converters.Add( + new AdminShellV10.JsonAasxConverter("modelType", "name")); + this.aasenv = (AdministrationShellEnv)serializer.Deserialize( + file, typeof(AdministrationShellEnv)); } } } @@ -3962,7 +3992,9 @@ public bool Load(string fn) using (var s = specPart.GetStream(FileMode.Open)) { // own catch loop to be more specific - XmlSerializer serializer = new XmlSerializer(typeof(AdminShellV10.AdministrationShellEnv), "http://www.admin-shell.io/aas/1/0"); + XmlSerializer serializer = new XmlSerializer( + typeof(AdminShellV10.AdministrationShellEnv), + "http://www.admin-shell.io/aas/1/0"); this.aasenv = serializer.Deserialize(s) as AdminShellV10.AdministrationShellEnv; this.openPackage = package; if (this.aasenv == null) @@ -3973,12 +4005,16 @@ public bool Load(string fn) } catch (Exception ex) { - throw (new Exception(string.Format("While reading AAS {0} spec at {1} gave: {2}", fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + throw (new Exception( + string.Format("While reading AAS {0} spec at {1} gave: {2}", + fn, AdminShellUtilV10.ShortLocation(ex), ex.Message))); } } catch (Exception ex) { - throw (new Exception(string.Format("While reading AASX {0} at {1} gave: {2}", fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + throw (new Exception( + string.Format("While reading AASX {0} at {1} gave: {2}", fn, + AdminShellUtilV10.ShortLocation(ex), ex.Message))); } return true; } @@ -3993,15 +4029,18 @@ public bool LoadFromAasEnvString(string content) { using (var file = new StringReader(content)) { - // TODO: use aasenv serialzers here! + // TODO (Michael Hoffmeister, 1970-01-01): use aasenv serialzers here! JsonSerializer serializer = new JsonSerializer(); serializer.Converters.Add(new AdminShellV10.JsonAasxConverter("modelType", "name")); - this.aasenv = (AdministrationShellEnv)serializer.Deserialize(file, typeof(AdministrationShellEnv)); + this.aasenv = (AdministrationShellEnv)serializer.Deserialize( + file, typeof(AdministrationShellEnv)); } } catch (Exception ex) { - throw (new Exception(string.Format("While reading AASENV string {0} gave: {1}", AdminShellUtil.ShortLocation(ex), ex.Message))); + throw (new Exception( + string.Format("While reading AASENV string {0} gave: {1}", + AdminShellUtilV10.ShortLocation(ex), ex.Message))); } return true; } @@ -4019,7 +4058,7 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt { using (var s = new StreamWriter(this.fn)) { - // TODO: use aasenv serialzers here! + // TODO (Michael Hoffmeister, 1970-01-01): use aasenv serialzers here! var serializer = new XmlSerializer(typeof(AdminShellV10.AdministrationShellEnv)); var nss = new XmlSerializerNamespaces(); nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); @@ -4030,7 +4069,9 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt } catch (Exception ex) { - throw (new Exception(string.Format("While writing AAS {0} at {1} gave: {2}", fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + throw (new Exception( + string.Format("While writing AAS {0} at {1} gave: {2}", + fn, AdminShellUtilV10.ShortLocation(ex), ex.Message))); } return true; } @@ -4044,7 +4085,7 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt { using (var sw = new StreamWriter(fn)) { - // TODO: use aasenv serialzers here! + // TODO (Michael Hoffmeister, 1970-01-01): use aasenv serialzers here! sw.AutoFlush = true; @@ -4060,7 +4101,9 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt } catch (Exception ex) { - throw (new Exception(string.Format("While writing AAS {0} at {1} gave: {2}", fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + throw (new Exception( + string.Format("While writing AAS {0} at {1} gave: {2}", + fn, AdminShellUtilV10.ShortLocation(ex), ex.Message))); } return true; } @@ -4091,7 +4134,8 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt // get the origin from the package PackagePart originPart = null; - var xs = package.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aasx-origin"); + var xs = package.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aasx-origin"); foreach (var x in xs) if (x.SourceUri.ToString() == "/") { @@ -4101,19 +4145,25 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt if (originPart == null) { // create, as not existing - originPart = package.CreatePart(new Uri("/aasx/aasx-origin", UriKind.RelativeOrAbsolute), System.Net.Mime.MediaTypeNames.Text.Plain, CompressionOption.Maximum); + originPart = package.CreatePart( + new Uri( + "/aasx/aasx-origin", UriKind.RelativeOrAbsolute), + System.Net.Mime.MediaTypeNames.Text.Plain, CompressionOption.Maximum); using (var s = originPart.GetStream(FileMode.Create)) { var bytes = System.Text.Encoding.ASCII.GetBytes("Intentionally empty."); s.Write(bytes, 0, bytes.Length); } - package.CreateRelationship(originPart.Uri, TargetMode.Internal, "http://www.admin-shell.io/aasx/relationships/aasx-origin"); + package.CreateRelationship( + originPart.Uri, TargetMode.Internal, + "http://www.admin-shell.io/aasx/relationships/aasx-origin"); } // get the specs from the package PackagePart specPart = null; PackageRelationship specRel = null; - xs = originPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-spec"); + xs = originPart.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aas-spec"); foreach (var x in xs) { specRel = x; @@ -4124,7 +4174,8 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt // check, if we have to change the spec part if (specPart != null && specRel != null) { - var name = System.IO.Path.GetFileNameWithoutExtension(specPart.Uri.ToString()).ToLower().Trim(); + var name = System.IO.Path.GetFileNameWithoutExtension( + specPart.Uri.ToString()).ToLower().Trim(); var ext = System.IO.Path.GetExtension(specPart.Uri.ToString()).ToLower().Trim(); if ((ext == ".json" && prefFmt == PreferredFormat.Xml) || (ext == ".xml" && prefFmt == PreferredFormat.Json) @@ -4145,16 +4196,21 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt { // create, as not existing var frn = "aasenv-with-no-id"; - if (this.AasEnv.AdministrationShells.Count > 0) - frn = this.AasEnv.AdministrationShells[0].GetFriendlyName() ?? frn; + if (this.aasenv.AdministrationShells.Count > 0) + frn = this.aasenv.AdministrationShells[0].GetFriendlyName() ?? frn; var aas_spec_fn = "/aasx/#/#.aas"; if (prefFmt == PreferredFormat.Json) aas_spec_fn += ".json"; else aas_spec_fn += ".xml"; aas_spec_fn = aas_spec_fn.Replace("#", "" + frn); - specPart = package.CreatePart(new Uri(aas_spec_fn, UriKind.RelativeOrAbsolute), System.Net.Mime.MediaTypeNames.Text.Xml, CompressionOption.Maximum); - originPart.CreateRelationship(specPart.Uri, TargetMode.Internal, "http://www.admin-shell.io/aasx/relationships/aas-spec"); + specPart = package.CreatePart( + new Uri( + aas_spec_fn, UriKind.RelativeOrAbsolute), System.Net.Mime.MediaTypeNames.Text.Xml, + CompressionOption.Maximum); + originPart.CreateRelationship( + specPart.Uri, TargetMode.Internal, + "http://www.admin-shell.io/aasx/relationships/aas-spec"); } // now, specPart shall be != null! @@ -4188,14 +4244,16 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt } } - // there might be pending files to be deleted (first delete, then add, in case of identical files in both categories) + // there might be pending files to be deleted (first delete, then add, in case of identical + // files in both categories) foreach (var psfDel in pendingFilesToDelete) { // try find an existing part for that file .. var found = false; - // normal files - xs = specPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-suppl"); + // normal files + xs = specPart.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aas-suppl"); foreach (var x in xs) if (x.TargetUri == psfDel.uri) { @@ -4207,7 +4265,8 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt } // thumbnails - xs = package.GetRelationshipsByType("http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); + xs = package.GetRelationshipsByType( + "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); foreach (var x in xs) if (x.TargetUri == psfDel.uri) { @@ -4219,7 +4278,8 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt } if (!found) - throw (new Exception($"Not able to delete pending file {psfDel.uri} in saving package {fn}")); + throw (new Exception( + $"Not able to delete pending file {psfDel.uri} in saving package {fn}")); } // after this, there are no more pending for delete files @@ -4229,7 +4289,8 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt foreach (var psfAdd in pendingFilesToAdd) { // make sure .. - if (psfAdd.sourcePath == null || psfAdd.location != PackageSupplementaryFile.LocationType.AddPending) + if (psfAdd.sourcePath == null || + psfAdd.location != PackageSupplementaryFile.LocationType.AddPending) continue; // normal file? @@ -4238,7 +4299,8 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt // try find an existing part for that file .. PackagePart filePart = null; - xs = specPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-suppl"); + xs = specPart.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aas-suppl"); foreach (var x in xs) if (x.TargetUri == psfAdd.uri) { @@ -4249,8 +4311,12 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt if (filePart == null) { // create new part and link - filePart = package.CreatePart(psfAdd.uri, AdminShellV10.PackageEnv.GuessMimeType(psfAdd.sourcePath), CompressionOption.Maximum); - specPart.CreateRelationship(filePart.Uri, TargetMode.Internal, "http://www.admin-shell.io/aasx/relationships/aas-suppl"); + filePart = package.CreatePart( + psfAdd.uri, AdminShellV10.PackageEnv.GuessMimeType(psfAdd.sourcePath), + CompressionOption.Maximum); + specPart.CreateRelationship( + filePart.Uri, TargetMode.Internal, + "http://www.admin-shell.io/aasx/relationships/aas-suppl"); } // now should be able to write @@ -4262,11 +4328,13 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt } // thumbnail file? - if (psfAdd.specialHandling == PackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail) + if (psfAdd.specialHandling == + PackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail) { // try find an existing part for that file .. PackagePart filePart = null; - xs = package.GetRelationshipsByType("http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); + xs = package.GetRelationshipsByType( + "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); foreach (var x in xs) if (x.SourceUri.ToString() == "/" && x.TargetUri == psfAdd.uri) { @@ -4277,8 +4345,13 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt if (filePart == null) { // create new part and link - filePart = package.CreatePart(psfAdd.uri, AdminShellV10.PackageEnv.GuessMimeType(psfAdd.sourcePath), CompressionOption.Maximum); - package.CreateRelationship(filePart.Uri, TargetMode.Internal, "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); + filePart = package.CreatePart( + psfAdd.uri, AdminShellV10.PackageEnv.GuessMimeType(psfAdd.sourcePath), + CompressionOption.Maximum); + package.CreateRelationship( + filePart.Uri, TargetMode.Internal, + "http://schemas.openxmlformats.org/package/2006/" + + "relationships/metadata/thumbnail"); } // now should be able to write @@ -4299,7 +4372,9 @@ public bool SaveAs(string fn, bool writeFreshly = false, PreferredFormat prefFmt } catch (Exception ex) { - throw (new Exception(string.Format("While write AASX {0} at {1} gave: {2}", fn, AdminShellUtil.ShortLocation(ex), ex.Message))); + throw (new Exception( + string.Format("While write AASX {0} at {1} gave: {2}", + fn, AdminShellUtilV10.ShortLocation(ex), ex.Message))); } return true; } @@ -4353,7 +4428,9 @@ public Stream GetLocalStreamFromPackage(string uriString) throw (new Exception(string.Format($"AASX Package {this.fn} not opened. Aborting!"))); var part = this.openPackage.GetPart(new Uri(uriString, UriKind.RelativeOrAbsolute)); if (part == null) - throw (new Exception(string.Format($"Cannot access URI {uriString} in {this.fn} not opened. Aborting!"))); + throw (new Exception( + string.Format( + $"Cannot access URI {uriString} in {this.fn} not opened. Aborting!"))); return part.GetStream(FileMode.Open); } @@ -4383,7 +4460,8 @@ public Stream GetLocalThumbnailStream(ref Uri thumbUri) throw (new Exception(string.Format($"AASX Package {this.fn} not opened. Aborting!"))); // get the thumbnail over the relationship PackagePart thumbPart = null; - var xs = this.openPackage.GetRelationshipsByType("http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); + var xs = this.openPackage.GetRelationshipsByType( + "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); foreach (var x in xs) if (x.SourceUri.ToString() == "/") { @@ -4412,7 +4490,8 @@ public List GetListOfSupplementaryFiles() { // get the thumbnail(s) from the package - var xs = this.openPackage.GetRelationshipsByType("http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); + var xs = this.openPackage.GetRelationshipsByType( + "http://schemas.openxmlformats.org/package/2006/relationships/metadata/thumbnail"); foreach (var x in xs) if (x.SourceUri.ToString() == "/") { @@ -4424,7 +4503,8 @@ public List GetListOfSupplementaryFiles() // get the origin from the package PackagePart originPart = null; - xs = this.openPackage.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aasx-origin"); + xs = this.openPackage.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aasx-origin"); foreach (var x in xs) if (x.SourceUri.ToString() == "/") { @@ -4436,7 +4516,8 @@ public List GetListOfSupplementaryFiles() { // get the specs from the origin PackagePart specPart = null; - xs = originPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-spec"); + xs = originPart.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aas-spec"); foreach (var x in xs) { specPart = this.openPackage.GetPart(x.TargetUri); @@ -4446,10 +4527,13 @@ public List GetListOfSupplementaryFiles() if (specPart != null) { // get the supplementaries from the package, derived from spec - xs = specPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-suppl"); + xs = specPart.GetRelationshipsByType( + "http://www.admin-shell.io/aasx/relationships/aas-suppl"); foreach (var x in xs) { - result.Add(new PackageSupplementaryFile(x.TargetUri, location: PackageSupplementaryFile.LocationType.InPackage)); + result.Add( + new PackageSupplementaryFile( + x.TargetUri, location: PackageSupplementaryFile.LocationType.InPackage)); } } } @@ -4505,7 +4589,8 @@ public static string GuessMimeType(string fn) return content_type; } - public void AddSupplementaryFileToStore(string sourcePath, string targetDir, string targetFn, bool embedAsThumb) + public void AddSupplementaryFileToStore( + string sourcePath, string targetDir, string targetFn, bool embedAsThumb) { // beautify parameters sourcePath = sourcePath.Trim(); @@ -4525,7 +4610,10 @@ public void AddSupplementaryFileToStore(string sourcePath, string targetDir, str new Uri(file_fn, UriKind.RelativeOrAbsolute), sourcePath, location: PackageSupplementaryFile.LocationType.AddPending, - specialHandling: (embedAsThumb ? PackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail : PackageSupplementaryFile.SpecialHandlingType.None) + specialHandling: ( + embedAsThumb + ? PackageSupplementaryFile.SpecialHandlingType.EmbedAsThumbnail + : PackageSupplementaryFile.SpecialHandlingType.None) )); } @@ -4547,57 +4635,6 @@ public void DeleteSupplementaryFile(PackageSupplementaryFile psf) } } - /* - private void AddSupplementaryFileDirect(string srcFn, string targetDir, string targetFn) - { - // access - if (this.openPackage == null) - throw (new Exception(string.Format($"AASX Package {this.fn} not opened. Aborting!"))); - - srcFn = srcFn.Trim(); - targetDir = targetDir.Trim(); - if (!targetDir.EndsWith("/")) - targetDir += "/"; - targetDir = targetDir.Replace(@"\", "/"); - targetFn = targetFn.Trim(); - if (srcFn == "" || targetDir == "" || targetFn == "") - throw (new Exception(string.Format("Trying add supplementary file with empty name or path!"))); - - // get the origin from the package - PackagePart originPart = null; - var xs = this.openPackage.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aasx-origin"); - foreach (var x in xs) - if (x.SourceUri.ToString() == "/") - { - originPart = this.openPackage.GetPart(x.TargetUri); - break; - } - if (originPart == null) - throw (new Exception(string.Format("Unable to find AASX origin. Aborting!"))); - - // get the specs from the package - PackagePart specPart = null; - xs = originPart.GetRelationshipsByType("http://www.admin-shell.io/aasx/relationships/aas-spec"); - foreach (var x in xs) - { - specPart = this.openPackage.GetPart(x.TargetUri); - break; - } - if (specPart == null) - throw (new Exception(string.Format("Unable to find AASX spec(s). Aborting!"))); - - // add a supplementary file - var file_fn = "" + targetDir.Trim() + targetFn.Trim(); - var file_part = this.openPackage.CreatePart(new Uri(file_fn, UriKind.RelativeOrAbsolute), AdminShellV10.PackageEnv.GuessMimeType(srcFn), CompressionOption.Maximum); - using (var s = file_part.GetStream(FileMode.Create)) - { - var bytes = System.IO.File.ReadAllBytes(srcFn); - s.Write(bytes, 0, bytes.Length); - } - specPart.CreateRelationship(file_part.Uri, TargetMode.Internal, "http://www.admin-shell.io/aasx/relationships/aas-suppl"); - } - */ - public void Close() { if (this.openPackage != null) @@ -4613,4 +4650,4 @@ public void Close() #endregion } -#endif \ No newline at end of file +#endif diff --git a/src/AasxServerStandardBib/AasxCompatibilityModels/V20/AdminShellV20.cs b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShell.cs similarity index 80% rename from src/AasxServerStandardBib/AasxCompatibilityModels/V20/AdminShellV20.cs rename to src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShell.cs index 0e885ba76..5aa491279 100644 --- a/src/AasxServerStandardBib/AasxCompatibilityModels/V20/AdminShellV20.cs +++ b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShell.cs @@ -10,20 +10,30 @@ This source code may use other Open Source software components (see LICENSE.txt) using System; using System.Collections; using System.Collections.Generic; -using System.Dynamic; +using System.ComponentModel; using System.Globalization; using System.IO; +using System.IO.Packaging; using System.Linq; using System.Reflection; +using System.Runtime; using System.Text; +using System.Text.RegularExpressions; using System.Xml; using System.Xml.Serialization; -using AdminShellNS; -using Microsoft.IdentityModel.Tokens; +using AdminShell_V20; using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +//namespace AdminShellNS +//namespace AdminShell_V20 namespace AasxCompatibilityModels { + /// + /// This empty class derives always from the current version of the Administration Shell class hierarchy. + /// + public class AdminShell : AdminShellV20 { } + #region AdminShell_V2_0 /// @@ -31,7 +41,6 @@ namespace AasxCompatibilityModels /// public class AdminShellV20 { - public class Identification { @@ -105,6 +114,17 @@ public bool IsEqual(Identification other) && this.id.Trim().ToLower() == other.id.Trim().ToLower()); } + public bool IsIRI() + { + return idType?.Trim().ToUpper() == "URI" + || idType?.Trim().ToUpper() == IRI; + } + + public bool IsIRDI() + { + return idType?.Trim().ToUpper() == IRDI; + } + public override string ToString() { return $"[{this.idType}] {this.id}"; @@ -276,6 +296,56 @@ public string ToString(int format = 0) return $"[{this.type}, {tlc}, {this.idType}, {this.value}]"; } + public static Key Parse(string cell, string typeIfNotSet = null, + bool allowFmtAll = false, bool allowFmt0 = false, + bool allowFmt1 = false, bool allowFmt2 = false) + { + // access and defaults? + if (cell == null || cell.Trim().Length < 1) + return null; + if (typeIfNotSet == null) + typeIfNotSet = Key.GlobalReference; + + // format == 1 + if (allowFmtAll || allowFmt1) + { + var m = Regex.Match(cell, @"\((\w+)\)\((\S+)\)\[(\w+)\]( ?)(.*)$"); + if (m.Success) + { + return new AdminShell.Key( + m.Groups[1].ToString(), m.Groups[2].ToString() == "local", + m.Groups[3].ToString(), m.Groups[5].ToString()); + } + } + + // format == 2 + if (allowFmtAll || allowFmt2) + { + var m = Regex.Match(cell, @"\[(\w+)\]( ?)(.*)$"); + if (m.Success) + { + return new AdminShell.Key( + typeIfNotSet, true, + m.Groups[1].ToString(), m.Groups[3].ToString()); + } + } + + // format == 0 + if (allowFmtAll || allowFmt0) + { + var m = Regex.Match(cell, @"\[(\w+),( ?)([^,]+),( ?)\[(\w+)\],( ?)(.*)\]"); + if (m.Success) + { + return new AdminShell.Key( + m.Groups[1].ToString(), !m.Groups[3].ToString().Contains("not"), + m.Groups[5].ToString(), m.Groups[7].ToString()); + } + } + + // no + return null; + } + public static string KeyListToString(List keys) { if (keys == null || keys.Count < 1) @@ -383,6 +453,7 @@ public static string KeyListToString(List keys) public static string Asset = "Asset"; public static string AAS = "AssetAdministrationShell"; public static string Entity = "Entity"; + public static string View = "View"; // Resharper enable MemberHidesStaticFromOuterClass public static string[] IdentifierTypeNames = new string[] { @@ -424,6 +495,21 @@ public bool IsIdType(string value) return value.Trim().Equals(idType.Trim()); } + public bool IsType(string value) + { + if (value == null || type == null || type.Trim() == "") + return false; + return value.Trim().ToLower().Equals(type.Trim().ToLower()); + } + + public bool IsAbsolute() + { + return IsType(Key.GlobalReference) + || IsType(Key.AAS) + || IsType(Key.Asset) + || IsType(Key.Submodel); + } + public bool Matches( string type, bool local, string idType, string id, MatchMode matchMode = MatchMode.Strict) { @@ -456,69 +542,69 @@ public bool Matches(Key key, MatchMode matchMode = MatchMode.Strict) // validation - public static AasValidationActionV20 Validate(AasValidationRecordListV20 results, Key k, Referable container) + public static AasValidationAction Validate(AasValidationRecordList results, Key k, Referable container) { // access if (results == null || container == null) - return AasValidationActionV20.No; + return AasValidationAction.No; - var res = AasValidationActionV20.No; + var res = AasValidationAction.No; // check if (k == null) { // violation case - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SpecViolation, container, + results.Add(new AasValidationRecord( + AasValidationSeverity.SpecViolation, container, "Key: is null", () => { - res = AasValidationActionV20.ToBeDeleted; + res = AasValidationAction.ToBeDeleted; })); } else { // check IdType - var idf = AdminShellNS.AdminShellUtil.CheckIfInConstantStringArray(IdentifierTypeNames, k.idType); - if (idf == AdminShellNS.AdminShellUtil.ConstantFoundEnum.No) + var idf = AdminShellUtilV20.CheckIfInConstantStringArray(IdentifierTypeNames, k.idType); + if (idf == AdminShellUtilV20.ConstantFoundEnum.No) // violation case - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SchemaViolation, container, + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, container, "Key: idType is not in allowed enumeration values", () => { k.idType = Custom; })); - if (idf == AdminShellNS.AdminShellUtil.ConstantFoundEnum.AnyCase) + if (idf == AdminShellUtilV20.ConstantFoundEnum.AnyCase) // violation case - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SchemaViolation, container, + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, container, "Key: idType in wrong casing", () => { - k.idType = AdminShellNS.AdminShellUtil.CorrectCasingForConstantStringArray( + k.idType = AdminShellUtilV20.CorrectCasingForConstantStringArray( IdentifierTypeNames, k.idType); })); // check type - var tf = AdminShellNS.AdminShellUtil.CheckIfInConstantStringArray(KeyElements, k.type); - if (tf == AdminShellNS.AdminShellUtil.ConstantFoundEnum.No) + var tf = AdminShellUtilV20.CheckIfInConstantStringArray(KeyElements, k.type); + if (tf == AdminShellUtilV20.ConstantFoundEnum.No) // violation case - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SchemaViolation, container, + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, container, "Key: type is not in allowed enumeration values", () => { k.type = GlobalReference; })); - if (tf == AdminShellNS.AdminShellUtil.ConstantFoundEnum.AnyCase) + if (tf == AdminShellUtilV20.ConstantFoundEnum.AnyCase) // violation case - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SchemaViolation, container, + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, container, "Key: type in wrong casing", () => { - k.idType = AdminShellNS.AdminShellUtil.CorrectCasingForConstantStringArray( + k.idType = AdminShellUtilV20.CorrectCasingForConstantStringArray( KeyElements, k.type); })); } @@ -537,6 +623,15 @@ public class KeyList : List // constructors / creators + public KeyList() { } + + public KeyList(KeyList src) + { + if (src != null) + foreach (var k in src) + this.Add(new Key(k)); + } + public static KeyList CreateNew(Key k) { var kl = new KeyList { k }; @@ -558,12 +653,26 @@ public static KeyList CreateNew(string type, bool local, string idType, string[] return null; // prepare - var kl = new KeyList(); + var kl = new AdminShell.KeyList(); foreach (var x in valueItems) - kl.Add(new Key(type, local, idType, "" + x)); + kl.Add(new AdminShell.Key(type, local, idType, "" + x)); return kl; } + // matches + + public bool Matches(KeyList other, Key.MatchMode matchMode = Key.MatchMode.Strict) + { + if (other == null || other.Count != this.Count) + return false; + + var same = true; + for (int i = 0; i < this.Count; i++) + same = same && this[i].Matches(other[i], matchMode); + + return same; + } + // other public void NumberIndices() @@ -574,10 +683,28 @@ public void NumberIndices() public string ToString(int format = 0, string delimiter = ",") { - var res = ""; - foreach (var k in this) - res += k.ToString(format) + delimiter; - return res.TrimEnd(','); + var res = string.Join(delimiter, this.Select((k) => k.ToString(format))); + return res; + } + + public static KeyList Parse(string input) + { + // access + if (input == null) + return null; + + // split + var parts = input.Split(',', ';'); + var kl = new KeyList(); + + foreach (var p in parts) + { + var k = Key.Parse(p); + if (k != null) + kl.Add(k); + } + + return kl; } public string MostSignificantInfo() @@ -593,7 +720,7 @@ public string MostSignificantInfo() // validation - public static void Validate(AasValidationRecordListV20 results, KeyList kl, + public static void Validate(AasValidationRecordList results, KeyList kl, Referable container) { // access @@ -605,7 +732,7 @@ public static void Validate(AasValidationRecordListV20 results, KeyList kl, while (idx < kl.Count) { var act = Key.Validate(results, kl[idx], container); - if (act == AasValidationActionV20.ToBeDeleted) + if (act == AasValidationAction.ToBeDeleted) { kl.RemoveAt(idx); continue; @@ -637,22 +764,100 @@ public bool StartsWith(KeyList head, bool emptyIsTrue = false, // ok! return true; } + + // arithmetics + + public static KeyList operator +(KeyList a, Key b) + { + var res = new KeyList(a); + if (b != null) + res.Add(b); + return res; + } + + public static KeyList operator +(KeyList a, KeyList b) + { + var res = new KeyList(a); + if (b != null) + res.AddRange(b); + return res; + } + + public KeyList SubList(int startPos, int count = int.MaxValue) + { + var res = new KeyList(); + if (startPos >= this.Count) + return res; + int nr = 0; + for (int i = startPos; i < this.Count && nr < count; i++) + { + nr++; + res.Add(this[i]); + } + return res; + } + + public KeyList ReplaceLastKey(KeyList newKeys) + { + var res = new KeyList(this); + if (res.Count < 1 || newKeys == null || newKeys.Count < 1) + return res; + + res.Remove(res.Last()); + res = res + newKeys; + + return res; + } + + // other + + /// + /// Take only idShort, ignore all other key-types and create a '/'-separated list + /// + /// Empty string or list of idShorts + public string BuildIdShortPath(int startPos = 0, int count = int.MaxValue) + { + if (startPos >= this.Count) + return ""; + int nr = 0; + var res = ""; + for (int i = startPos; i < this.Count && nr < count; i++) + { + nr++; + if (this[i].idType.Trim().ToLower() == Key.IdShort.Trim().ToLower()) + { + if (res != "") + res += "/"; + res += this[i].value; + } + } + return res; + } } public class AasElementSelfDescription { public string ElementName = ""; public string ElementAbbreviation = ""; + public SubmodelElementWrapper.AdequateElementEnum ElementEnum = + SubmodelElementWrapper.AdequateElementEnum.Unknown; public AasElementSelfDescription() { } - public AasElementSelfDescription(string ElementName, string ElementAbbreviation) + public AasElementSelfDescription( + string ElementName, string ElementAbbreviation, + SubmodelElementWrapper.AdequateElementEnum elementEnum + = SubmodelElementWrapper.AdequateElementEnum.Unknown) { this.ElementName = ElementName; this.ElementAbbreviation = ElementAbbreviation; + this.ElementEnum = elementEnum; } } + /// + /// Extends understanding of Referable to further elements, which can be related to + /// public interface IAasElement { AasElementSelfDescription GetSelfDescription(); @@ -885,6 +1090,11 @@ public string ToString(int format = 0, string delimiter = ",") return keys?.ToString(format, delimiter); } + public static Reference Parse(string input) + { + return CreateNew(KeyList.Parse(input)); + } + public string ListOfValues(string delim) { string res = ""; @@ -899,6 +1109,8 @@ public string ListOfValues(string delim) return res; } + // self description + public virtual AasElementSelfDescription GetSelfDescription() { return new AasElementSelfDescription("Reference", "Rfc"); @@ -1345,12 +1557,23 @@ public static ListOfLangStr CreateManyFromStringArray(string[] s) } return r; } + + public override string ToString() + { + return $"{str}@{lang}"; + } } public class ListOfLangStr : List { public ListOfLangStr() { } + public ListOfLangStr(LangStr ls) + { + if (ls != null) + this.Add(ls); + } + public ListOfLangStr(ListOfLangStr src) { if (src != null) @@ -1358,6 +1581,24 @@ public ListOfLangStr(ListOfLangStr src) this.Add(ls); } + public string this[string lang] + { + get + { + return GetDefaultStr(lang); + } + set + { + foreach (var ls in this) + if (ls.lang.Trim().ToLower() == lang?.Trim().ToLower()) + { + ls.str = value; + return; + } + this.Add(new LangStr(lang, value)); + } + } + public string GetDefaultStr(string defaultLang = null) { // start @@ -1377,6 +1618,27 @@ public string GetDefaultStr(string defaultLang = null) return res; } + public string GetExactStrForLang(string lang) + { + // start + if (lang == null) + return null; + string res = null; + + // exact search + foreach (var ls in this) + if (ls.lang.Trim().ToLower() == lang) + res = ls.str; + + // found? + return res; + } + + public bool ContainsLang(string lang) + { + return GetExactStrForLang(lang) != null; + } + public bool AllLangSameString() { if (this.Count < 2) @@ -1388,6 +1650,46 @@ public bool AllLangSameString() return true; } + + public override string ToString() + { + return string.Join(", ", this.Select((ls) => ls.ToString())); + } + + public static ListOfLangStr Parse(string cell) + { + // access + if (cell == null) + return null; + + // iterative approach + var res = new ListOfLangStr(); + while (true) + { + // trivial case and finite end + if (!cell.Contains("@")) + { + if (cell.Trim() != "") + res.Add(new LangStr(LangStr.LANG_DEFAULT, cell)); + break; + } + + // OK, pick the next couple + var m = Regex.Match(cell, @"(.*?)@(\w+)", RegexOptions.Singleline); + if (!m.Success) + { + // take emergency exit? + res.Add(new LangStr("??", cell)); + break; + } + + // use the match and shorten cell .. + res.Add(new LangStr(m.Groups[2].ToString(), m.Groups[1].ToString().Trim())); + cell = cell.Substring(m.Index + m.Length); + } + + return res; + } } public class Description @@ -1435,6 +1737,10 @@ public string GetDefaultStr(string defaultLang = null) public class AssetKind { + // constants + public static string Type = "Type"; + public static string Instance = "Instance"; + [MetaModelName("AssetKind.kind")] [TextSearchable] [XmlText] @@ -1474,20 +1780,20 @@ public AssetKind(string kind) public static AssetKind CreateAsType() { - var res = new AssetKind() { kind = "Type" }; + var res = new AssetKind() { kind = AssetKind.Type }; return res; } public static AssetKind CreateAsInstance() { - var res = new AssetKind() { kind = "Instance" }; + var res = new AssetKind() { kind = AssetKind.Instance }; return res; } } public class ModelingKind { - // constnts + // constants public static string Template = "Template"; public static string Instance = "Instance"; @@ -1542,7 +1848,7 @@ public static ModelingKind CreateAsInstance() // validation - public static void Validate(AasValidationRecordListV20 results, ModelingKind mk, Referable container) + public static void Validate(AasValidationRecordList results, ModelingKind mk, Referable container) { // access if (results == null || container == null) @@ -1552,8 +1858,8 @@ public static void Validate(AasValidationRecordListV20 results, ModelingKind mk, if (mk == null || mk.kind == null) { // warning - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.Warning, container, + results.Add(new AasValidationRecord( + AasValidationSeverity.Warning, container, "ModelingKind: is null", () => { @@ -1566,8 +1872,8 @@ public static void Validate(AasValidationRecordListV20 results, ModelingKind mk, if (kl != Template.ToLower() && kl != Instance.ToLower()) { // violation case - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SchemaViolation, container, + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, container, $"ModelingKind: enumeration value neither {Template} nor {Instance}", () => { @@ -1577,8 +1883,8 @@ public static void Validate(AasValidationRecordListV20 results, ModelingKind mk, else if (k != Template && k != Instance) { // warning - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.Warning, container, + results.Add(new AasValidationRecord( + AasValidationSeverity.Warning, container, "ModelingKind: enumeration value in wrong casing", () => { @@ -1635,17 +1941,29 @@ public static SemanticId CreateFromKeys(List keys) return res; } + public new static SemanticId Parse(string input) + { + return (SemanticId)CreateNew(KeyList.Parse(input)); + } + } + + /// + /// This class allows to describe further data (in derived classes) when enumerating Children. + /// + public class EnumerationPlacmentBase + { } public interface IEnumerateChildren { IEnumerable EnumerateChildren(); - void AddChild(SubmodelElementWrapper smw); + EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child); + object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null); } public interface IValidateEntity { - void Validate(AasValidationRecordListV20 results); + void Validate(AasValidationRecordList results); } /// @@ -1703,112 +2021,127 @@ public class TextSearchable : System.Attribute { } - public class Referable : IValidateEntity, IAasElement + /// + /// Result of FindReferable in Environment + /// + public class ReferableRootInfo { - [XmlIgnore] - [JsonIgnore] - [SkipForHash] // important to skip, as recursion elsewise will go in cycles! - [SkipForReflection] // important to skip, as recursion elsewise will go in cycles! - public DateTime TimeStampCreate; + public AdministrationShell AAS = null; + public Asset Asset = null; + public Submodel Submodel = null; - [XmlIgnore] - [JsonIgnore] - [SkipForHash] // important to skip, as recursion elsewise will go in cycles! - [SkipForReflection] // important to skip, as recursion elsewise will go in cycles! - public DateTime TimeStamp; + public int NrOfRootKeys = 0; - public void setTimeStamp(DateTime timeStamp) + public bool IsValid { - Referable r = this; - - do + get { - r.TimeStamp = timeStamp; - if (r != r.parent) - { - r = r.parent; - } - else - r = null; + return NrOfRootKeys > 0 && (AAS != null || Submodel != null || Asset != null); } - while (r != null); } + } - public void SetAllTimeStamps(DateTime timeStamp, DateTime timeStampCreate) - { - TimeStamp = timeStamp; - TimeStampCreate = timeStampCreate; + /// + /// Marks an object, preferaby a payload item, which might be featured by the diary collection + /// + public interface IAasDiaryEntry + { + } - // via interface enumaration - if (this is IEnumerateChildren) - { - var childs = (this as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - c.submodelElement.SetAllTimeStamps(timeStamp, timeStampCreate); - } - } + public class DiaryDataDef + { + public enum TimeStampKind { Create, Update } - public void SetAllTimeStamps(DateTime timeStamp) - { - TimeStamp = timeStamp; - TimeStampCreate = timeStamp; + [XmlIgnore] + [JsonIgnore] + private DateTime[] _timeStamp = new DateTime[2]; - // via interface enumaration - if (this is IEnumerateChildren) - { - var childs = (this as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - c.submodelElement.SetAllTimeStamps(timeStamp); - } - } + [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 void SetAllParents(Referable parent, DateTime timeStamp) + public static void AddAndSetTimestamps(Referable element, IAasDiaryEntry de, bool isCreate = false) { - if (parent == null) + // trivial + if (element == null || de == null || element.DiaryData == null) return; - this.parent = parent; - this.TimeStamp = timeStamp; - this.TimeStampCreate = timeStamp; + // add entry + if (element.DiaryData.Entries == null) + element.DiaryData.Entries = new List(); + element.DiaryData.Entries.Add(de); - // via interface enumaration - if (this is IEnumerateChildren) + // figure out which timestamp + var tsk = TimeStampKind.Update; + if (isCreate) { - var childs = (this as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - c.submodelElement.SetAllParents(this, timeStamp); + 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 Referable)?.parent as IDiaryData; } } + } - public void SetAllParentsAndTimestamps(Referable parent, DateTime timeStamp, DateTime timeStampCreate) - { - if (parent == null) - return; + public interface IDiaryData + { + DiaryDataDef DiaryData { get; } + } - this.parent = parent; - this.TimeStamp = timeStamp; - this.TimeStampCreate = timeStampCreate; + public class ListOfReferable : List + { + // conversion to other list - // via interface enumaration - if (this is IEnumerateChildren) - { - var childs = (this as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - c.submodelElement.SetAllParentsAndTimestamps(this, timeStamp, timeStampCreate); - } + public KeyList ToKeyList() + { + var res = new KeyList(); + foreach (var rf in this) + res.Add(rf.ToKey()); + return res; } - public Submodel getParentSubmodel() + public Reference GetReference() { - Referable parent = this; - while (!(parent is Submodel) && parent != null) - parent = parent.parent; - return parent as Submodel; + return Reference.CreateNew(ToKeyList()); } + } + + public interface IRecurseOnReferables + { + void RecurseOnReferables( + object state, Func lambda, + bool includeThis = false); + } + + public class Referable : IValidateEntity, IAasElement, IDiaryData, IGetReference, IRecurseOnReferables + { + // diary + + [XmlIgnore] + [JsonIgnore] + [SkipForHash] + [SkipForReflection] + private DiaryDataDef _diaryData = new DiaryDataDef(); + + [XmlIgnore] + [JsonIgnore] + [SkipForReflection] + public DiaryDataDef DiaryData { get { return _diaryData; } } // members @@ -1853,7 +2186,7 @@ public ListOfLangStr JsonDescription [JsonIgnore] [SkipForHash] // important to skip, as recursion elsewise will go in cycles! [SkipForReflection] // important to skip, as recursion elsewise will go in cycles! - public Referable parent = null; + public IAasElement parent = null; public static string CONSTANT = "CONSTANT"; public static string Category_PARAMETER = "PARAMETER"; @@ -1895,6 +2228,25 @@ public Referable(AasxCompatibilityModels.AdminShellV10.Referable src) } #endif + /// + /// Introduced for JSON serialization, can create Referables based on a string name + /// + /// string name (standard PascalCased) + public static Referable CreateAdequateType(string elementName) + { + if (elementName == Key.AAS) + return new AdministrationShell(); + if (elementName == Key.Asset) + return new Asset(); + if (elementName == Key.ConceptDescription) + return new ConceptDescription(); + if (elementName == Key.Submodel) + return new Submodel(); + if (elementName == Key.View) + return new View(); + return SubmodelElementWrapper.CreateAdequateType(elementName); + } + public void AddDescription(string lang, string str) { if (description == null) @@ -1914,7 +2266,14 @@ public virtual string GetElementName() public string GetFriendlyName() { - return AdminShellNS.AdminShellUtil.FilterFriendlyName(this.idShort); + return AdminShellUtilV20.FilterFriendlyName(this.idShort); + } + + public virtual Reference GetReference(bool includeParents = true) + { + return new Reference( + new AdminShell.Key( + this.GetElementName(), false, Key.IdShort, "" + this.idShort)); } public void CollectReferencesByParent(List refs) @@ -1939,8 +2298,8 @@ public void CollectReferencesByParent(List refs) var k = Key.CreateNew(this.GetElementName(), true, "IdShort", this.idShort); refs.Insert(0, k); // recurse upwards! - if (parent != null) - (this.parent).CollectReferencesByParent(refs); + if (this.parent is Referable prf) + prf.CollectReferencesByParent(refs); } } @@ -1948,9 +2307,9 @@ public string CollectIdShortByParent() { // recurse first var head = ""; - if (!(this is Identifiable) && this.parent != null) + if (!(this is Identifiable) && this.parent is Referable prf) // can go up - head = this.parent.CollectIdShortByParent() + "/"; + head = prf.CollectIdShortByParent() + "/"; // add own var myid = ""; if (this.idShort != null && this.idShort.Trim() != "") @@ -1973,6 +2332,11 @@ public override string ToString() return "" + this.idShort; } + public virtual Key ToKey() + { + return new Key(GetElementName(), true, Key.IdShort, idShort); + } + // hash functionality public class ObjectFieldInfo @@ -2137,7 +2501,7 @@ public int Compare(Referable a, Referable b) // validation - public virtual void Validate(AasValidationRecordListV20 results) + public virtual void Validate(AasValidationRecordList results) { // access if (results == null) @@ -2145,8 +2509,8 @@ public virtual void Validate(AasValidationRecordListV20 results) // check if (this.idShort == null || this.idShort.Trim() == "") - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SpecViolation, this, + results.Add(new AasValidationRecord( + AasValidationSeverity.SpecViolation, this, "Referable: missing idShort", () => { @@ -2155,17 +2519,39 @@ public virtual void Validate(AasValidationRecordListV20 results) if (this.description != null && (this.description.langString == null || this.description.langString.Count < 1)) - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SchemaViolation, this, + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, this, "Referable: existing description with missing langString", () => { this.description = null; })); } + + // hierarchy & recursion (by derived elements) + + public virtual void RecurseOnReferables( + object state, Func lambda, + bool includeThis = false) + { + if (includeThis) + lambda(state, null, this); + } + + public Identifiable FindParentFirstIdentifiable() + { + Referable curr = this; + while (curr != null) + { + if (curr is Identifiable curri) + return curri; + curr = curr.parent as Referable; + } + return null; + } } - public class Identifiable : Referable + public class Identifiable : Referable, IGetReference { // members @@ -2220,8 +2606,8 @@ public void SetAdminstration(string version, string revision) public new string GetFriendlyName() { if (identification != null && identification.id != "") - return AdminShellNS.AdminShellUtil.FilterFriendlyName(this.identification.id); - return AdminShellNS.AdminShellUtil.FilterFriendlyName(this.idShort); + return AdminShellUtilV20.FilterFriendlyName(this.identification.id); + return AdminShellUtilV20.FilterFriendlyName(this.idShort); } public override string ToString() @@ -2229,6 +2615,22 @@ public override string ToString() return ("" + identification?.ToString() + " " + administration?.ToString()).Trim(); } + public override Key ToKey() + { + return new Key(GetElementName(), true, "" + identification?.idType, "" + identification?.id); + } + + // self description + + public override Reference GetReference(bool includeParents = true) + { + var r = new Reference(); + r.Keys.Add( + Key.CreateNew( + this.GetElementName(), true, this.identification.idType, this.identification.id)); + return r; + } + // sorting public class ComparerIdentification : IComparer @@ -2263,7 +2665,7 @@ public class JsonModelTypeWrapper public interface IFindAllReferences { - IEnumerable FindAllReferences(); + IEnumerable FindAllReferences(); } public interface IGetSemanticId @@ -2271,12 +2673,8 @@ public interface IGetSemanticId SemanticId GetSemanticId(); } - public class AdministrationShell : Identifiable, IFindAllReferences, IGetReference + public class AdministrationShell : Identifiable, IFindAllReferences { - [XmlIgnore] - [JsonIgnore] - public ulong ChangeNumber = 0; - // for JSON only [XmlIgnore] [JsonProperty(PropertyName = "modelType")] @@ -2411,15 +2809,6 @@ public void AddDataSpecification(Key k) hasDataSpecification.Add(new EmbeddedDataSpecification(r)); } - public Reference GetReference() - { - var r = new Reference(); - r.Keys.Add( - Key.CreateNew( - this.GetElementName(), true, this.identification.idType, this.identification.id)); - return r; - } - public override AasElementSelfDescription GetSelfDescription() { return new AasElementSelfDescription("AssetAdministrationShell", "AAS"); @@ -2427,7 +2816,7 @@ public override AasElementSelfDescription GetSelfDescription() public Tuple ToCaptionInfo() { - var caption = AdminShellNS.AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, "\"AAS\""); + var caption = AdminShellUtilV20.EvalToNonNullString("\"{0}\" ", idShort, "\"AAS\""); if (administration != null) caption += "V" + administration.version + "." + administration.revision; @@ -2473,27 +2862,42 @@ public void AddSubmodelRef(SubmodelRef newref) this.submodelRefs.Add(newref); } - public IEnumerable FindAllReferences() + public IEnumerable FindAllReferences() { // Asset if (this.assetRef != null) - yield return this.assetRef; + yield return new LocatedReference(this, this.assetRef); // Submodel references if (this.submodelRefs != null) foreach (var r in this.submodelRefs) - yield return r; + yield return new LocatedReference(this, r); // Views if (this.views?.views != null) foreach (var vw in this.views.views) if (vw?.containedElements?.reference != null) foreach (var r in vw.containedElements.reference) - yield return r; + yield return new LocatedReference(this, r); + } + } + + public class ListOfAdministrationShells : List, IAasElement + { + // self decscription + + public AasElementSelfDescription GetSelfDescription() + { + return new AasElementSelfDescription("AssetAdministrationShells", "AASs"); + } + + public string GetElementName() + { + return this.GetSelfDescription()?.ElementName; } } - public class Asset : Identifiable, IGetReference + public class Asset : Identifiable { // for JSON only [XmlIgnore] @@ -2580,11 +2984,6 @@ public AssetRef GetAssetReference() return r; } - public Reference GetReference() - { - return GetAssetReference(); - } - public override AasElementSelfDescription GetSelfDescription() { return new AasElementSelfDescription("Asset", "Asset"); @@ -2592,7 +2991,7 @@ public override AasElementSelfDescription GetSelfDescription() public Tuple ToCaptionInfo() { - var caption = AdminShellNS.AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, ""); + var caption = AdminShellUtilV20.EvalToNonNullString("\"{0}\" ", idShort, ""); if (administration != null) caption += "V" + administration.version + "." + administration.revision; @@ -2617,6 +3016,22 @@ public IEnumerable FindAllReferences() } } + public class ListOfAssets : List, IAasElement + { + // self decscription + + public AasElementSelfDescription GetSelfDescription() + { + return new AasElementSelfDescription("Assets", "Assets"); + } + + public string GetElementName() + { + return this.GetSelfDescription()?.ElementName; + } + + } + public class View : Referable { // for JSON only @@ -2745,7 +3160,7 @@ public override AasElementSelfDescription GetSelfDescription() public Tuple ToCaptionInfo() { - var caption = AdminShellNS.AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, ""); + var caption = AdminShellUtilV20.EvalToNonNullString("\"{0}\" ", idShort, ""); var info = ""; if (this.semanticId != null) info = Key.KeyListToString(this.semanticId.Keys); @@ -2763,7 +3178,7 @@ public override string ToString() // validation - public override void Validate(AasValidationRecordListV20 results) + public override void Validate(AasValidationRecordList results) { // access if (results == null) @@ -3017,8 +3432,10 @@ public static UnitId CreateNew(string type, bool local, string idType, string va public static UnitId CreateNew(Reference src) { + if (src == null) + return null; var res = new UnitId(); - if (src != null && src.Keys != null) + if (src.Keys != null) foreach (var k in src.Keys) res.keys.Add(k); return res; @@ -3173,7 +3590,7 @@ public static Key GetKey() // validation - public void Validate(AasValidationRecordListV20 results, ConceptDescription cd) + public void Validate(AasValidationRecordList results, ConceptDescription cd) { // access if (results == null || cd == null) @@ -3181,18 +3598,18 @@ public void Validate(AasValidationRecordListV20 results, ConceptDescription cd) // check IEC61360 spec if (this.preferredName == null || this.preferredName.Count < 1) - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SchemaViolation, cd, + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, cd, "ConceptDescription: missing preferredName", () => { - this.preferredName = new LangStringSetIEC61360("EN?", - AdminShellNS.AdminShellUtil.EvalToNonEmptyString("{0}", cd.idShort, "UNKNOWN")); + this.preferredName = new AdminShell.LangStringSetIEC61360("EN?", + AdminShellUtilV20.EvalToNonEmptyString("{0}", cd.idShort, "UNKNOWN")); })); if (this.shortName != null && this.shortName.Count < 1) - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SchemaViolation, cd, + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, cd, "ConceptDescription: existing shortName with missing langString", () => { @@ -3200,8 +3617,8 @@ public void Validate(AasValidationRecordListV20 results, ConceptDescription cd) })); if (this.definition != null && this.definition.Count < 1) - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SchemaViolation, cd, + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, cd, "ConceptDescription: existing definition with missing langString", () => { @@ -3215,8 +3632,8 @@ public void Validate(AasValidationRecordListV20 results, ConceptDescription cd) if (this.dataType.Trim() == dtn.Trim()) foundDataType = this.dataType; if (foundDataType == null) - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SchemaViolation, cd, + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, cd, "ConceptDescription: dataType does not match allowed enumeration values", () => { @@ -3331,7 +3748,7 @@ public static EmbeddedDataSpecification CreateIEC61360WithContent() eds.dataSpecification.Keys.Add(DataSpecificationIEC61360.GetKey()); eds.dataSpecificationContent.dataSpecificationIEC61360 = - DataSpecificationIEC61360.CreateNew(); + AdminShell.DataSpecificationIEC61360.CreateNew(); return eds; } @@ -3468,11 +3885,6 @@ public ConceptDescriptionRef GetCdReference() return r; } - public Reference GetReference() - { - return GetCdReference(); - } - public void SetIEC61360Spec( string[] preferredNames = null, string shortName = "", @@ -3489,7 +3901,7 @@ public void SetIEC61360Spec( eds.dataSpecification.Keys.Add( DataSpecificationIEC61360.GetKey()); eds.dataSpecificationContent.dataSpecificationIEC61360 = - DataSpecificationIEC61360.CreateNew( + AdminShell.DataSpecificationIEC61360.CreateNew( preferredNames, shortName, unit, unitId, valueFormat, sourceOfDefinition, symbol, dataType, definition); @@ -3559,7 +3971,7 @@ public DataSpecificationIEC61360 IEC61360Content public DataSpecificationIEC61360 CreateDataSpecWithContentIec61360() { - var eds = EmbeddedDataSpecification.CreateIEC61360WithContent(); + var eds = AdminShell.EmbeddedDataSpecification.CreateIEC61360WithContent(); if (this.embeddedDataSpecification == null) this.embeddedDataSpecification = new HasDataSpecification(); this.embeddedDataSpecification.Add(eds); @@ -3618,7 +4030,7 @@ public static IDisposable CreateNew() // validation - public override void Validate(AasValidationRecordListV20 results) + public override void Validate(AasValidationRecordList results) { // access if (results == null) @@ -3634,8 +4046,8 @@ public override void Validate(AasValidationRecordListV20 results) // check data spec if (eds61360.dataSpecification == null || !(eds61360.dataSpecification.MatchesExactlyOneKey(DataSpecificationIEC61360.GetKey()))) - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SpecViolation, this, + results.Add(new AasValidationRecord( + AasValidationSeverity.SpecViolation, this, "HasDataSpecification: data specification content set to IEC61360, but no " + "data specification reference set!", () => @@ -3648,8 +4060,8 @@ public override void Validate(AasValidationRecordListV20 results) // validate content if (eds61360.dataSpecificationContent?.dataSpecificationIEC61360 == null) { - results.Add(new AasValidationRecordV20( - AasValidationSeverityV20.SpecViolation, this, + results.Add(new AasValidationRecord( + AasValidationSeverity.SpecViolation, this, "HasDataSpecification: data specification reference set to IEC61360, but no " + "data specification content set!", () => @@ -3675,9 +4087,8 @@ public IEnumerable FindAllReferences() } } - public class ListOfConceptDescriptions : List + public class ListOfConceptDescriptions : List, IAasElement { - // finding public ConceptDescription Find(ConceptDescriptionRef cdr) @@ -3729,6 +4140,18 @@ public ConceptDescription AddIfNew(ConceptDescription cd) return cd; } + // self decscription + + public AasElementSelfDescription GetSelfDescription() + { + return new AasElementSelfDescription("ConceptDescriptions", "CDS"); + } + + public string GetElementName() + { + return this.GetSelfDescription()?.ElementName; + } + // sorting @@ -3781,20 +4204,53 @@ public override AasElementSelfDescription GetSelfDescription() } } + /// + /// Use by FindAllReference to provide a enumeration of referenced with location + /// info, where they are contained + /// + public class LocatedReference + { + public Identifiable Identifiable; + public Reference Reference; + + public LocatedReference() { } + public LocatedReference(Identifiable identifiable, Reference reference) + { + Identifiable = identifiable; + Reference = reference; + } + } + [XmlRoot(ElementName = "aasenv", Namespace = "http://www.admin-shell.io/aas/2/0")] - public class AdministrationShellEnv : IFindAllReferences + public class AdministrationShellEnv : IFindAllReferences, IAasElement, IDiaryData, IRecurseOnReferables { + + // diary (as e.g. deleted AASes need to be listed somewhere) + + [XmlIgnore] + [JsonIgnore] + [SkipForHash] + [SkipForReflection] + private DiaryDataDef _diaryData = new DiaryDataDef(); + + [XmlIgnore] + [JsonIgnore] + [SkipForReflection] + public DiaryDataDef DiaryData { get { return _diaryData; } } + + // members + [XmlAttribute(Namespace = System.Xml.Schema.XmlSchema.InstanceNamespace)] [JsonIgnore] public string schemaLocation = "http://www.admin-shell.io/aas/2/0 AAS.xsd http://www.admin-shell.io/IEC61360/2/0 IEC61360.xsd"; [XmlIgnore] // will be ignored, anyway - private List administrationShells = new List(); + private ListOfAdministrationShells administrationShells = new ListOfAdministrationShells(); [XmlIgnore] // will be ignored, anyway - private List assets = new List(); + private ListOfAssets assets = new ListOfAssets(); [XmlIgnore] // will be ignored, anyway - private List submodels = new List(); + private ListOfSubmodels submodels = new ListOfSubmodels(); [XmlIgnore] // will be ignored, anyway private ListOfConceptDescriptions conceptDescriptions = new ListOfConceptDescriptions(); @@ -3803,7 +4259,7 @@ public class AdministrationShellEnv : IFindAllReferences [XmlArray("assetAdministrationShells")] [XmlArrayItem("assetAdministrationShell")] [JsonProperty(PropertyName = "assetAdministrationShells")] - public List AdministrationShells + public ListOfAdministrationShells AdministrationShells { get { return administrationShells; } set { administrationShells = value; } @@ -3812,7 +4268,7 @@ public List AdministrationShells [XmlArray("assets")] [XmlArrayItem("asset")] [JsonProperty(PropertyName = "assets")] - public List Assets + public ListOfAssets Assets { get { return assets; } set { assets = value; } @@ -3821,7 +4277,7 @@ public List Assets [XmlArray("submodels")] [XmlArrayItem("submodel")] [JsonProperty(PropertyName = "submodels")] - public List Submodels + public ListOfSubmodels Submodels { get { return submodels; } set { submodels = value; } @@ -3877,6 +4333,18 @@ public override string ToString() return res; } + // self decscription + + public AasElementSelfDescription GetSelfDescription() + { + return new AasElementSelfDescription("AdministrationShellEnv", "Env"); + } + + public string GetElementName() + { + return this.GetSelfDescription()?.ElementName; + } + // finders public AdministrationShell FindAAS(Identification id) @@ -4038,7 +4506,7 @@ public IEnumerable FindAllReferable(Predicate p) yield return r; } - public IEnumerable FindAllReferable() + public IEnumerable FindAllReferable(bool onlyIdentifiables = false) { if (this.AdministrationShells != null) foreach (var aas in this.AdministrationShells) @@ -4047,10 +4515,13 @@ public IEnumerable FindAllReferable() // AAS itself yield return aas; - // Views - if (aas.views?.views != null) - foreach (var view in aas.views.views) - yield return view; + if (!onlyIdentifiables) + { + // Views + if (aas.views?.views != null) + foreach (var view in aas.views.views) + yield return view; + } } if (this.Assets != null) @@ -4064,14 +4535,17 @@ public IEnumerable FindAllReferable() { yield return sm; - // TODO (MIHO, 2020-08-26): not very elegant, yet. Avoid temporary collection - var allsme = new List(); - sm.RecurseOnSubmodelElements(null, (state, parents, sme) => + if (!onlyIdentifiables) { - allsme.Add(sme); - }); - foreach (var sme in allsme) - yield return sme; + // TODO (MIHO, 2020-08-26): not very elegant, yet. Avoid temporary collection + var allsme = new ListOfSubmodelElement(); + sm.RecurseOnSubmodelElements(null, (state, parents, sme) => + { + allsme.Add(sme); return true; + }); + foreach (var sme in allsme) + yield return sme; + } } if (this.ConceptDescriptions != null) @@ -4085,14 +4559,20 @@ public IEnumerable FindAllReferable() // public Referable FindReferableByReference(Reference rf, int keyIndex = 0, bool exactMatch = false) + { + return FindReferableByReference(rf?.Keys); + } + + public Referable FindReferableByReference(KeyList kl, int keyIndex = 0, bool exactMatch = false, + ReferableRootInfo rootInfo = null) { // first index needs to exist .. - if (rf == null || keyIndex >= rf.Count) + if (kl == null || keyIndex >= kl.Count) return null; // which type? - var firstType = rf[keyIndex].type.Trim().ToLower(); - var firstIdentification = new Identification(rf[keyIndex].idType, rf[keyIndex].value); + var firstType = kl[keyIndex].type.Trim().ToLower(); + var firstIdentification = new Identification(kl[keyIndex].idType, kl[keyIndex].value); AdministrationShell aasToFollow = null; if (firstType == Key.AAS.Trim().ToLower()) @@ -4101,9 +4581,16 @@ public Referable FindReferableByReference(Reference rf, int keyIndex = 0, bool e var aas = this.FindAAS(firstIdentification); // not found or already at end with our search? - if (aas == null || keyIndex >= rf.Count - 1) + if (aas == null || keyIndex >= kl.Count - 1) return aas; + // side info? + if (rootInfo != null) + { + rootInfo.AAS = aas; + rootInfo.NrOfRootKeys = 1 + keyIndex; + } + // follow up aasToFollow = aas; } @@ -4114,7 +4601,7 @@ public Referable FindReferableByReference(Reference rf, int keyIndex = 0, bool e var asset = this.FindAsset(firstIdentification); // not found or already at end with our search? - if (asset == null || keyIndex >= rf.Count - 1) + if (asset == null || keyIndex >= kl.Count - 1) return exactMatch ? null : asset; // try find aas for it @@ -4125,6 +4612,13 @@ public Referable FindReferableByReference(Reference rf, int keyIndex = 0, bool e if (aas == null) return exactMatch ? null : asset; + // side info? + if (rootInfo != null) + { + rootInfo.Asset = asset; + rootInfo.NrOfRootKeys = 1 + keyIndex; + } + // follow up aasToFollow = aas; } @@ -4133,11 +4627,11 @@ public Referable FindReferableByReference(Reference rf, int keyIndex = 0, bool e if (aasToFollow != null) { // search different entities - if (rf[keyIndex + 1].type.Trim().ToLower() == Key.Submodel.ToLower() - || rf[keyIndex + 1].type.Trim().ToLower() == Key.SubmodelRef.ToLower()) + if (kl[keyIndex + 1].type.Trim().ToLower() == Key.Submodel.ToLower() + || kl[keyIndex + 1].type.Trim().ToLower() == Key.SubmodelRef.ToLower()) { // ok, search SubmodelRef - var smref = aasToFollow.FindSubmodelRef(rf[keyIndex + 1].ToId()); + var smref = aasToFollow.FindSubmodelRef(kl[keyIndex + 1].ToId()); if (smref == null) return exactMatch ? null : aasToFollow; @@ -4146,12 +4640,20 @@ public Referable FindReferableByReference(Reference rf, int keyIndex = 0, bool e if (sm == null) return exactMatch ? null : aasToFollow; + // side info + // side info? + if (rootInfo != null) + { + rootInfo.Submodel = sm; + rootInfo.NrOfRootKeys = 2 + keyIndex; + } + // at our end? - if (keyIndex >= rf.Count - 2) + if (keyIndex >= kl.Count - 2) return sm; // go inside - return SubmodelElementWrapper.FindReferableByReference(sm.submodelElements, rf, keyIndex + 2); + return SubmodelElementWrapper.FindReferableByReference(sm.submodelElements, kl, keyIndex + 2); } } @@ -4161,16 +4663,37 @@ public Referable FindReferableByReference(Reference rf, int keyIndex = 0, bool e if (firstType == Key.Submodel.Trim().ToLower()) { // ok, search Submodel - var sm = this.FindSubmodel(new Identification(rf[keyIndex].idType, rf[keyIndex].value)); + var sm = this.FindSubmodel(new Identification(kl[keyIndex].idType, kl[keyIndex].value)); if (sm == null) return null; + // notice in side info + if (rootInfo != null) + { + rootInfo.Submodel = sm; + rootInfo.NrOfRootKeys = 1 + keyIndex; + + // add even more info + if (rootInfo.AAS == null) + { + foreach (var aas2 in this.AdministrationShells) + { + var smref2 = aas2.FindSubmodelRef(sm.identification); + if (smref2 != null) + { + rootInfo.AAS = aas2; + break; + } + } + } + } + // at our end? - if (keyIndex >= rf.Count - 1) + if (keyIndex >= kl.Count - 1) return sm; // go inside - return SubmodelElementWrapper.FindReferableByReference(sm.submodelElements, rf, keyIndex + 1); + return SubmodelElementWrapper.FindReferableByReference(sm.submodelElements, kl, keyIndex + 1); } // nothing in this Environment @@ -4263,7 +4786,7 @@ public ConceptDescription FindConceptDescription(Key key) return (FindConceptDescription(l)); } - public IEnumerable FindAllReferences() + public IEnumerable FindAllReferences() { if (this.AdministrationShells != null) foreach (var aas in this.AdministrationShells) @@ -4275,7 +4798,7 @@ public IEnumerable FindAllReferences() foreach (var asset in this.Assets) if (asset != null) foreach (var r in asset.FindAllReferences()) - yield return r; + yield return new LocatedReference(asset, r); if (this.Submodels != null) foreach (var sm in this.Submodels) @@ -4287,7 +4810,7 @@ public IEnumerable FindAllReferences() foreach (var cd in this.ConceptDescriptions) if (cd != null) foreach (var r in cd.FindAllReferences()) - yield return r; + yield return new LocatedReference(cd, r); } // creators @@ -4388,23 +4911,27 @@ public SubmodelRef CopySubmodelRefAndCD( /// Tries renaming an Identifiable, specifically: the identification of an Identifiable and /// all references to it. /// Currently supported: ConceptDescriptions - /// Returns, if a successful renaming was performed + /// Returns a list of Referables, which were changed or null in case of error /// - public bool RenameIdentifiable(Identification oldId, Identification newId) where T : Identifiable + public List RenameIdentifiable(Identification oldId, Identification newId) + where T : Identifiable { // access if (oldId == null || newId == null || oldId.IsEqual(newId)) - return false; + return null; + + var res = new List(); if (typeof(T) == typeof(ConceptDescription)) { // check, if exist or not exist var cdOld = FindConceptDescription(oldId); if (cdOld == null || FindConceptDescription(newId) != null) - return false; + return null; // rename old cd cdOld.identification = newId; + res.Add(cdOld); // search all SMEs referring to this CD foreach (var sme in this.FindAllSubmodelElements(match: (s) => @@ -4414,10 +4941,11 @@ public bool RenameIdentifiable(Identification oldId, Identification newId) wh { sme.semanticId[0].idType = newId.idType; sme.semanticId[0].value = newId.id; + res.Add(sme); } // seems fine - return true; + return res; } if (typeof(T) == typeof(Submodel)) @@ -4425,10 +4953,12 @@ public bool RenameIdentifiable(Identification oldId, Identification newId) wh // check, if exist or not exist var smOld = FindSubmodel(oldId); if (smOld == null || FindSubmodel(newId) != null) - return false; + return null; // recurse all possible Referenes in the aas env - foreach (var r in this.FindAllReferences()) + foreach (var lr in this.FindAllReferences()) + { + var r = lr?.Reference; if (r != null) for (int i = 0; i < r.Count; i++) if (r[i].Matches(Key.Submodel, false, oldId.idType, oldId.id, Key.MatchMode.Relaxed)) @@ -4436,13 +4966,16 @@ public bool RenameIdentifiable(Identification oldId, Identification newId) wh // directly replace r[i].idType = newId.idType; r[i].value = newId.id; + if (res.Contains(lr.Identifiable)) + res.Add(lr.Identifiable); } + } // rename old Submodel smOld.identification = newId; // seems fine - return true; + return res; } if (typeof(T) == typeof(Asset)) @@ -4450,10 +4983,12 @@ public bool RenameIdentifiable(Identification oldId, Identification newId) wh // check, if exist or not exist var assetOld = FindAsset(oldId); if (assetOld == null || FindAsset(newId) != null) - return false; + return null; // recurse all possible Referenes in the aas env - foreach (var r in this.FindAllReferences()) + foreach (var lr in this.FindAllReferences()) + { + var r = lr?.Reference; if (r != null) for (int i = 0; i < r.Count; i++) if (r[i].Matches(Key.Asset, false, oldId.idType, oldId.id, Key.MatchMode.Relaxed)) @@ -4461,24 +4996,27 @@ public bool RenameIdentifiable(Identification oldId, Identification newId) wh // directly replace r[i].idType = newId.idType; r[i].value = newId.id; + if (res.Contains(lr.Identifiable)) + res.Add(lr.Identifiable); } + } // rename old Submodel assetOld.identification = newId; // seems fine - return true; + return res; } // no result is false, as well - return false; + return null; } // serializations public void SerializeXmlToStream(StreamWriter s) { - var serializer = new XmlSerializer(typeof(AdministrationShellEnv)); + var serializer = new XmlSerializer(typeof(AdminShell.AdministrationShellEnv)); var nss = new XmlSerializerNamespaces(); nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); nss.Add("aas", "http://www.admin-shell.io/aas/2/0"); @@ -4508,8 +5046,8 @@ public JsonWriter SerialiazeJsonToStream(StreamWriter sw, bool leaveJsonWriterOp public AdministrationShellEnv DeserializeFromXmlStream(TextReader reader) { XmlSerializer serializer = new XmlSerializer( - typeof(AdministrationShellEnv), "http://www.admin-shell.io/aas/2/0"); - var res = serializer.Deserialize(reader) as AdministrationShellEnv; + typeof(AdminShell.AdministrationShellEnv), "http://www.admin-shell.io/aas/2/0"); + var res = serializer.Deserialize(reader) as AdminShell.AdministrationShellEnv; return res; } @@ -4566,7 +5104,7 @@ private static void CreateFromExistingEnvRecurseForCDs( public static AdministrationShellEnv CreateFromExistingEnv(AdministrationShellEnv src, List filterForAas = null, List filterForAsset = null, - List filterForSubmodel = null, + ListOfSubmodels filterForSubmodel = null, List filterForCD = null) { // prepare defaults @@ -4575,7 +5113,7 @@ public static AdministrationShellEnv CreateFromExistingEnv(AdministrationShellEn if (filterForAsset == null) filterForAsset = new List(); if (filterForSubmodel == null) - filterForSubmodel = new List(); + filterForSubmodel = new ListOfSubmodels(); if (filterForCD == null) filterForCD = new List(); @@ -4671,10 +5209,10 @@ public Referable.ComparerIndexed CreateIndexedComparerCdsForSmUsage() // Validation - public AasValidationRecordListV20 ValidateAll() + public AasValidationRecordList ValidateAll() { // collect results - var results = new AasValidationRecordListV20(); + var results = new AasValidationRecordList(); // all entities foreach (var rf in this.FindAllReferable()) @@ -4684,7 +5222,7 @@ public AasValidationRecordListV20 ValidateAll() return results; } - public int AutoFix(IEnumerable records) + public int AutoFix(IEnumerable records) { // access if (records == null) @@ -4720,6 +5258,15 @@ public int AutoFix(IEnumerable records) // return number of applied fixes return res; } + + public void RecurseOnReferables( + object state, Func lambda, bool includeThis = false) + { + // includeThis does not make sense, as no Referable + // just use the others + foreach (var idf in this.FindAllReferable(onlyIdentifiables: true)) + idf?.RecurseOnReferables(state, lambda, includeThis); + } } // @@ -4728,7 +5275,12 @@ public int AutoFix(IEnumerable records) public interface IGetReference { - Reference GetReference(); + Reference GetReference(bool includeParents = true); + } + + public interface IGetQualifiers + { + QualifierCollection GetQualifiers(); } public class Qualifier : IAasElement @@ -4786,6 +5338,12 @@ public Qualifier(Qualifier src) this.valueId = new Reference(src.valueId); } + public Qualifier(string type, string value) + { + this.type = type; + this.value = value; + } + #if !DoNotUseAasxCompatibilityModels public Qualifier(AasxCompatibilityModels.AdminShellV10.Qualifier src) { @@ -4830,6 +5388,21 @@ public override string ToString() } // ReSharper enable MethodOverloadWithOptionalParameter // ReSharper enable RedundantArgumentDefaultValue + + public static Qualifier Parse(string input) + { + var m = Regex.Match(input, @"\s*([^,]*)(,[^=]+){0,1}\s*=\s*([^,]*)(,.+){0,1}\s*"); + if (!m.Success) + return null; + + return new Qualifier() + { + type = m.Groups[1].ToString().Trim(), + semanticId = SemanticId.Parse(m.Groups[1].ToString().Trim()), + value = m.Groups[3].ToString().Trim(), + valueId = Reference.Parse(m.Groups[1].ToString().Trim()) + }; + } } /// @@ -4907,14 +5480,83 @@ public override string ToString() } // ReSharper enable MethodOverloadWithOptionalParameter // ReSharper enable RedundantArgumentDefaultValue + + // for convenience methods of Submodel, SubmodelElement + + public static void AddQualifier( + ref QualifierCollection qualifiers, + Qualifier q) + { + if (q == null) + return; + if (qualifiers == null) + qualifiers = new QualifierCollection(); + qualifiers.Add(q); + } + + public static void AddQualifier( + ref QualifierCollection qualifiers, + string qualifierType = null, string qualifierValue = null, KeyList semanticKeys = null, + Reference qualifierValueId = null) + { + if (qualifiers == null) + qualifiers = new QualifierCollection(); + var q = new Qualifier() + { + type = qualifierType, + value = qualifierValue, + valueId = qualifierValueId, + }; + if (semanticKeys != null) + q.semanticId = SemanticId.CreateFromKeys(semanticKeys); + qualifiers.Add(q); + } + + public static Qualifier HasQualifierOfType( + QualifierCollection qualifiers, + string qualifierType) + { + if (qualifiers == null || qualifierType == null) + return null; + foreach (var q in qualifiers) + if (q.type.Trim().ToLower() == qualifierType.Trim().ToLower()) + return q; + return null; + } + + public IEnumerable FindAllQualifierType(string qualifierType) + { + if (qualifierType == null) + yield break; + foreach (var q in this) + if (q.type.Trim().ToLower() == qualifierType.Trim().ToLower()) + yield return q; + } } - [JsonConverter(typeof(AdminShellConverters.JsonAasxConverter))] - public class SubmodelElement : Referable, System.IDisposable, IGetReference, IGetSemanticId + public class ListOfSubmodelElement : List + { + // conversion to other list + + public KeyList ToKeyList() + { + var res = new KeyList(); + foreach (var sme in this) + res.Add(sme.ToKey()); + return res; + } + + public Reference GetReference() + { + return Reference.CreateNew(ToKeyList()); + } + } + + public class SubmodelElement : Referable, System.IDisposable, IGetReference, IGetSemanticId, IGetQualifiers { // constants public static Type[] PROP_MLP = new Type[] { - typeof(MultiLanguageProperty), typeof(Property) }; + typeof(AdminShell.MultiLanguageProperty), typeof(AdminShell.Property) }; // for JSON only [XmlIgnore] @@ -4959,6 +5601,7 @@ public string JsonKind [XmlArrayItem("qualifier")] [JsonProperty(PropertyName = "constraints")] public QualifierCollection qualifiers = null; + public QualifierCollection GetQualifiers() => qualifiers; // from hasDataSpecification: [XmlElement(ElementName = "embeddedDataSpecification")] @@ -5038,37 +5681,24 @@ public void CreateNewLogic(string idShort = null, string category = null, Key se } } + public void AddQualifier( + Qualifier q) + { + QualifierCollection.AddQualifier( + ref this.qualifiers, q); + } + public void AddQualifier( string qualifierType = null, string qualifierValue = null, KeyList semanticKeys = null, Reference qualifierValueId = null) { - if (this.qualifiers == null) - this.qualifiers = new QualifierCollection(); - var q = new Qualifier() - { - type = qualifierType, - value = qualifierValue, - valueId = qualifierValueId, - }; - if (semanticKeys != null) - q.semanticId = SemanticId.CreateFromKeys(semanticKeys); - // dead-csharp off - /* OZ - if (valueType != null) - q.valueType = valueType; - */ - // dead-csharp on - this.qualifiers.Add(q); + QualifierCollection.AddQualifier( + ref this.qualifiers, qualifierType, qualifierValue, semanticKeys, qualifierValueId); } public Qualifier HasQualifierOfType(string qualifierType) { - if (this.qualifiers == null || qualifierType == null) - return null; - foreach (var q in this.qualifiers) - if (q.type.Trim().ToLower() == qualifierType.Trim().ToLower()) - return q; - return null; + return QualifierCollection.HasQualifierOfType(this.qualifiers, qualifierType); } public override AasElementSelfDescription GetSelfDescription() @@ -5076,40 +5706,46 @@ public override AasElementSelfDescription GetSelfDescription() return new AasElementSelfDescription("SubmodelElement", "SME"); } - public Reference GetReference() + public override Reference GetReference(bool includeParents = true) { Reference r = new Reference(); // this is the tail of our referencing chain .. r.Keys.Add(Key.CreateNew(GetElementName(), true, "IdShort", this.idShort)); // try to climb up .. var current = this.parent; - while (current != null) + while (includeParents && current != null) { - if (current is Identifiable) + if (current is Identifiable cid) { // add big information set r.Keys.Insert(0, Key.CreateNew( current.GetElementName(), true, - (current as Identifiable).identification.idType, - (current as Identifiable).identification.id)); + cid.identification.idType, + cid.identification.id)); } else + if (current is Referable crf) { // reference via idShort r.Keys.Insert(0, Key.CreateNew( current.GetElementName(), true, - "IdShort", current.idShort)); + "IdShort", crf.idShort)); } - current = current.parent; + + if (current is Referable crf2) + current = crf2.parent; + else + current = null; } return r; } public IEnumerable FindAllParents( Predicate p, - bool includeThis = false, bool includeSubmodel = false) + bool includeThis = false, bool includeSubmodel = false, + bool passOverMiss = false) { // call for this? if (includeThis) @@ -5117,6 +5753,7 @@ public IEnumerable FindAllParents( if (p == null || p.Invoke(this)) yield return this; else + if (!passOverMiss) yield break; } @@ -5125,7 +5762,8 @@ public IEnumerable FindAllParents( { if (this.parent is SubmodelElement psme) { - foreach (var q in psme.FindAllParents(p, includeThis: true)) + foreach (var q in psme.FindAllParents(p, includeThis: true, + passOverMiss: passOverMiss)) yield return q; } else if (includeSubmodel && this.parent is Submodel psm) @@ -5136,12 +5774,24 @@ public IEnumerable FindAllParents( } } - public Tuple ToCaptionInfo() + public IEnumerable FindAllParentsWithSemanticId( + SemanticId semId, + bool includeThis = false, bool includeSubmodel = false, bool passOverMiss = false) { - var caption = AdminShellNS.AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, ""); - var info = ""; + return (FindAllParents( + (rf) => (true == (rf as IGetSemanticId)?.GetSemanticId()?.Matches(semId, + matchMode: Key.MatchMode.Relaxed)), + includeThis: includeThis, includeSubmodel: includeSubmodel, passOverMiss: passOverMiss)); + } + + public Tuple ToCaptionInfo() + { + var caption = AdminShellUtilV20.EvalToNonNullString("\"{0}\" ", idShort, ""); + var info = ""; + // TODO (MIHO, 2021-07-08): obvious error .. info should receive semanticId .. but would change + // display presentation .. therefore to be checked again if (semanticId != null) - AdminShellNS.AdminShellUtil.EvalToNonEmptyString("\u21e8 {0}", semanticId.ToString(), ""); + AdminShellUtilV20.EvalToNonEmptyString("\u21e8 {0}", semanticId.ToString(), ""); return Tuple.Create(caption, info); } @@ -5161,9 +5811,13 @@ public virtual string ValueAsText(string defaultLang = null) return null; } + public virtual void ValueFromText(string text, string defaultLang = null) + { + } + // validation - public override void Validate(AasValidationRecordListV20 results) + public override void Validate(AasValidationRecordList results) { // access if (results == null) @@ -5174,11 +5828,6 @@ public override void Validate(AasValidationRecordListV20 results) ModelingKind.Validate(results, kind, this); KeyList.Validate(results, semanticId?.Keys, this); } - - public virtual object ToValueOnlySerialization() - { - throw new NotImplementedException(); - } } [XmlType(TypeName = "submodelElement")] @@ -5212,14 +5861,18 @@ public enum AdequateElementEnum public static AdequateElementEnum[] AdequateElementsDataElement = { - AdequateElementEnum.SubmodelElementCollection, AdequateElementEnum.RelationshipElement, - AdequateElementEnum.AnnotatedRelationshipElement, AdequateElementEnum.Capability, - AdequateElementEnum.Operation, AdequateElementEnum.BasicEvent, AdequateElementEnum.Entity - }; + AdequateElementEnum.SubmodelElementCollection, AdequateElementEnum.RelationshipElement, + AdequateElementEnum.AnnotatedRelationshipElement, AdequateElementEnum.Capability, + AdequateElementEnum.Operation, AdequateElementEnum.BasicEvent, AdequateElementEnum.Entity + }; public static string[] AdequateElementNames = { "Unknown", "SubmodelElementCollection", "Property", - "MultiLanguageProperty", "Range", "File", "Blob", "ReferenceElement", "RelationshipElement", - "AnnotatedRelationshipElement", "Capability", "Operation", "BasicEvent", "Entity" }; + "MultiLanguageProperty", "Range", "File", "Blob", "ReferenceElement", "RelationshipElement", + "AnnotatedRelationshipElement", "Capability", "Operation", "BasicEvent", "Entity" }; + + public static string[] AdequateElementShortName = { null, "SMC", null, + "MLP", null, null, null, "Ref", "Rel", + "ARel", null, null, "Event", "Entity" }; // constructors @@ -5229,6 +5882,9 @@ public SubmodelElementWrapper() { } public SubmodelElementWrapper(SubmodelElement src, bool shallowCopy = false) { + /* TODO (MIHO, 2021-08-12): consider using: + Activator.CreateInstance(pl.GetType(), new object[] { pl }) */ + if (src is SubmodelElementCollection) this.submodelElement = new SubmodelElementCollection( src as SubmodelElementCollection, shallowCopy: shallowCopy); @@ -5288,6 +5944,9 @@ public static string GetAdequateName(AdequateElementEnum ae) return AdequateElementNames[(int)ae]; } + /// + /// Deprecated. See below. + /// public static AdequateElementEnum GetAdequateEnum(string adequateName) { if (adequateName == null) @@ -5301,6 +5960,26 @@ public static AdequateElementEnum GetAdequateEnum(string adequateName) return AdequateElementEnum.Unknown; } + /// + /// This version uses the element name array and allows using ShortName + /// + public static AdequateElementEnum GetAdequateEnum2(string adequateName, bool useShortName = false) + { + if (adequateName == null) + return AdequateElementEnum.Unknown; + + foreach (var en in (AdequateElementEnum[])Enum.GetValues(typeof(AdequateElementEnum))) + if (((int)en < AdequateElementNames.Length + && AdequateElementNames[(int)en].Trim().ToLower() == adequateName.Trim().ToLower()) + || (useShortName + && (int)en < AdequateElementShortName.Length + && AdequateElementShortName[(int)en] != null + && AdequateElementShortName[(int)en].Trim().ToLower() == adequateName.Trim().ToLower())) + return en; + + return AdequateElementEnum.Unknown; + } + public static IEnumerable GetAdequateEnums( AdequateElementEnum[] excludeValues = null, AdequateElementEnum[] includeValues = null) { @@ -5372,7 +6051,7 @@ public static SubmodelElement CreateAdequateType(string elementName) /// SubmodelElement or null public static SubmodelElement CreateAdequateType(Type t) { - if (t == null || !t.IsSubclassOf(typeof(SubmodelElement))) + if (t == null || !t.IsSubclassOf(typeof(AdminShell.SubmodelElement))) return null; var sme = Activator.CreateInstance(t) as SubmodelElement; return sme; @@ -5388,9 +6067,26 @@ public string GetElementAbbreviation() return dsc.ElementAbbreviation; } - public static List ListOfWrappersToListOfElems(List wrappers) + public static string GetElementNameByAdequateType(SubmodelElement sme) { - var res = new List(); + // access + var sd = sme.GetSelfDescription(); + if (sd == null || sd.ElementEnum == AdequateElementEnum.Unknown) + return null; + var en = sd.ElementEnum; + + // get the names + string res = null; + if ((int)en < AdequateElementNames.Length) + res = AdequateElementNames[(int)en].Trim(); + if ((int)en < AdequateElementShortName.Length && AdequateElementShortName[(int)en] != null) + res = AdequateElementShortName[(int)en].Trim(); + return res; + } + + public static ListOfSubmodelElement ListOfWrappersToListOfElems(List wrappers) + { + var res = new ListOfSubmodelElement(); if (wrappers == null) return res; foreach (var w in wrappers) @@ -5407,6 +6103,12 @@ public static SubmodelElementWrapper CreateFor(SubmodelElement sme) public static Referable FindReferableByReference( List wrappers, Reference rf, int keyIndex) + { + return FindReferableByReference(wrappers, rf?.Keys, keyIndex); + } + + public static Referable FindReferableByReference( + List wrappers, KeyList rf, int keyIndex) { // first index needs to exist .. if (wrappers == null || rf == null || keyIndex >= rf.Count) @@ -5463,10 +6165,11 @@ public class SubmodelElementWrapperCollection : BaseSubmodelElementWrapperCollec { public SubmodelElementWrapperCollection() : base() { } - public SubmodelElementWrapperCollection(SubmodelElementWrapperCollection other) - : base(other) - { - } + public SubmodelElementWrapperCollection(SubmodelElementWrapper smw) : base(smw) { } + + public SubmodelElementWrapperCollection(SubmodelElement sme) : base(sme) { } + + public SubmodelElementWrapperCollection(SubmodelElementWrapperCollection other) : base(other) { } } public class DataElementWrapperCollection : BaseSubmodelElementWrapperCollection @@ -5495,7 +6198,10 @@ public class BaseSubmodelElementWrapperCollection : List FindDeep(Predicate match = null) where T : SubmodelElement @@ -5574,7 +6294,8 @@ public T FindFirstIdShortAs(string idShort) where T : SubmodelElement return FindAllIdShortAs(idShort)?.FirstOrDefault(); } - public IEnumerable FindAllSemanticId(Key semId, Type[] allowedTypes = null) + public IEnumerable FindAllSemanticId( + Key semId, Type[] allowedTypes = null, Key.MatchMode matchMode = Key.MatchMode.Strict) { foreach (var smw in this) if (smw.submodelElement != null && smw.submodelElement.semanticId != null) @@ -5589,7 +6310,7 @@ public IEnumerable FindAllSemanticId(Key semId, Type[] a continue; } - if (smw.submodelElement.semanticId.MatchesExactlyOneKey(semId)) + if (smw.submodelElement.semanticId.MatchesExactlyOneKey(semId, matchMode)) yield return smw; } } @@ -5615,9 +6336,33 @@ public IEnumerable FindAllSemanticIdAs(Reference semId, yield return smw.submodelElement as T; } - public SubmodelElementWrapper FindFirstSemanticId(Key semId, Type[] allowedTypes = null) + public IEnumerable FindAllSemanticIdAs(ConceptDescription cd, + Key.MatchMode matchMode = Key.MatchMode.Strict) + where T : SubmodelElement + { + foreach (var x in FindAllSemanticIdAs(cd.GetReference(), matchMode)) + yield return x; + } + + public SubmodelElementWrapper FindFirstSemanticId( + Key semId, Type[] allowedTypes = null, Key.MatchMode matchMode = Key.MatchMode.Strict) { - return FindAllSemanticId(semId, allowedTypes)?.FirstOrDefault(); + return FindAllSemanticId(semId, allowedTypes, matchMode)?.FirstOrDefault(); + } + + public SubmodelElementWrapper FindFirstAnySemanticId( + Key[] semId, Type[] allowedTypes = null, Key.MatchMode matchMode = Key.MatchMode.Strict) + { + if (semId == null) + return null; + foreach (var si in semId) + { + var found = FindAllSemanticId(si, allowedTypes, matchMode)? + .FirstOrDefault(); + if (found != null) + return found; + } + return null; } public T FindFirstSemanticIdAs(Key semId, Key.MatchMode matchMode = Key.MatchMode.Strict) @@ -5626,6 +6371,20 @@ public T FindFirstSemanticIdAs(Key semId, Key.MatchMode matchMode = Key.Match return FindAllSemanticIdAs(semId, matchMode)?.FirstOrDefault(); } + public T FindFirstAnySemanticIdAs(Key[] semId, Key.MatchMode matchMode = Key.MatchMode.Strict) + where T : SubmodelElement + { + if (semId == null) + return null; + foreach (var si in semId) + { + var found = FindAllSemanticIdAs(si, matchMode)?.FirstOrDefault(); + if (found != null) + return found; + } + return null; + } + public T FindFirstSemanticIdAs(Reference semId, Key.MatchMode matchMode = Key.MatchMode.Strict) where T : SubmodelElement { @@ -5681,15 +6440,28 @@ public T FindFirstAnySemanticId( // recursion - public void RecurseOnSubmodelElements( - object state, List parents, - Action, SubmodelElement> lambda) + /// + /// Recurses on all Submodel elements of a Submodel or SME, which allows children. + /// The state object will be passed to the lambda function in order to provide + /// stateful approaches. Also a list of parents will be provided to + /// the lambda. This list of parents can be initialized or simply set to null + /// in order to be created automatically. + /// + /// State object to be provided to lambda. Could be null. + /// List of already existing parents to be provided to lambda. + /// Could be null. + /// The lambda function as (state, parents, SME) + /// The lambda shall return TRUE in order to deep into recursion. + /// + public void RecurseOnReferables( + object state, ListOfReferable parents, + Func lambda) { // trivial if (lambda == null) return; if (parents == null) - parents = new List(); + parents = new ListOfReferable(); // over all elements foreach (var smw in this) @@ -5699,27 +6471,31 @@ public void RecurseOnSubmodelElements( continue; // call lambda for this element - lambda(state, parents, current); + // AND decide, if to recurse! + var goDeeper = lambda(state, parents, current); - // add to parents - parents.Add(current); + if (goDeeper) + { + // add to parents + parents.Add(current); - // dive into? - if (current is SubmodelElementCollection smc) - smc.value?.RecurseOnSubmodelElements(state, parents, lambda); + // dive into? + if (current is SubmodelElementCollection smc) + smc.value?.RecurseOnReferables(state, parents, lambda); - if (current is Entity ent) - ent.statements?.RecurseOnSubmodelElements(state, parents, lambda); + if (current is Entity ent) + ent.statements?.RecurseOnReferables(state, parents, lambda); - if (current is Operation op) - for (int i = 0; i < 2; i++) - Operation.GetWrappers(op[i])?.RecurseOnSubmodelElements(state, parents, lambda); + if (current is Operation op) + for (int i = 0; i < 2; i++) + Operation.GetWrappers(op[i])?.RecurseOnReferables(state, parents, lambda); - if (current is AnnotatedRelationshipElement arel) - arel.annotations?.RecurseOnSubmodelElements(state, parents, lambda); + if (current is AnnotatedRelationshipElement arel) + arel.annotations?.RecurseOnReferables(state, parents, lambda); - // remove from parents - parents.RemoveAt(parents.Count - 1); + // remove from parents + parents.RemoveAt(parents.Count - 1); + } } } @@ -5779,9 +6555,21 @@ public void Add(SubmodelElement sme) { if (sme == null) return; + sme.parent = this.Parent; this.Add(SubmodelElementWrapper.CreateFor(sme)); } + /// + /// Add sme by creating a SubmodelElementWrapper for it and adding to this collection. + /// + public void Insert(int index, SubmodelElement sme) + { + if (sme == null || index < 0 || index >= this.Count) + return; + sme.parent = this.Parent; + this.Insert(index, SubmodelElementWrapper.CreateFor(sme)); + } + /// /// Finds the first (shall be only 1!) SubmodelElementWrapper with SubmodelElement sme. /// @@ -5809,7 +6597,8 @@ public void Remove(SubmodelElement sme) // a little more business logic public T CreateSMEForCD(ConceptDescription cd, string category = null, string idShort = null, - string idxTemplate = null, int maxNum = 999, bool addSme = false) where T : SubmodelElement, new() + string idxTemplate = null, int maxNum = 999, bool addSme = false, bool isTemplate = false) + where T : SubmodelElement, new() { // access if (cd == null) @@ -5817,7 +6606,7 @@ public T CreateSMEForCD(ConceptDescription cd, string category = null, string // try to potentially figure out idShort var ids = cd.idShort; - if (ids == null && cd.GetIEC61360() != null) + if ((ids == null || ids.Trim() == "") && cd.GetIEC61360() != null) ids = cd.GetIEC61360().shortName? .GetDefaultStr(); if (idShort != null) @@ -5837,6 +6626,8 @@ public T CreateSMEForCD(ConceptDescription cd, string category = null, string }; if (category != null) sme.category = category; + if (isTemplate) + sme.kind = ModelingKind.CreateAsTemplate(); // if its a SMC, make sure its accessible if (sme is SubmodelElementCollection smc) @@ -5879,13 +6670,56 @@ public T CreateSMEForIdShort(string idShort, string category = null, // for conversion + public T AdaptiveConvertTo( + SubmodelElement anySrc, + ConceptDescription createDefault = null, + string idShort = null, bool addSme = false) where T : SubmodelElement, new() + { + if (typeof(T) == typeof(MultiLanguageProperty) + && anySrc is Property srcProp) + { + var res = this.CreateSMEForCD(createDefault, idShort: idShort, addSme: addSme); + if (res is MultiLanguageProperty mlp) + { + mlp.value = new LangStringSet("EN?", srcProp.value); + mlp.valueId = srcProp.valueId; + return res; + } + } + + if (typeof(T) == typeof(Property) + && anySrc is MultiLanguageProperty srcMlp) + { + var res = this.CreateSMEForCD(createDefault, idShort: idShort, addSme: addSme); + if (res is Property prp) + { + prp.value = "" + srcMlp.value?.GetDefaultStr(); + prp.valueId = srcMlp.valueId; + return res; + } + } + + return null; + } + public T CopyOneSMEbyCopy(Key destSemanticId, - SubmodelElementWrapperCollection sourceSmc, Key sourceSemanticId, + SubmodelElementWrapperCollection sourceSmc, Key[] sourceSemanticId, ConceptDescription createDefault = null, Action setDefault = null, - Key.MatchMode matchMode = Key.MatchMode.Relaxed, bool addSme = false) where T : SubmodelElement, new() + Key.MatchMode matchMode = Key.MatchMode.Relaxed, + string idShort = null, bool addSme = false) where T : SubmodelElement, new() { // get source - var src = sourceSmc?.FindFirstSemanticIdAs(sourceSemanticId, matchMode); + var src = sourceSmc?.FindFirstAnySemanticIdAs(sourceSemanticId, matchMode); + + // may be make an adaptive conversion + if (src == null) + { + var anySrc = sourceSmc?.FindFirstAnySemanticId(sourceSemanticId, matchMode: matchMode); + src = AdaptiveConvertTo(anySrc?.submodelElement, createDefault, + idShort: idShort, addSme: false); + } + + // proceed var aeSrc = SubmodelElementWrapper.GetAdequateEnum(src?.GetElementName()); if (src == null || aeSrc == SubmodelElementWrapper.AdequateElementEnum.Unknown) { @@ -5894,7 +6728,7 @@ public T CopyOneSMEbyCopy(Key destSemanticId, return null; // ok, default - var dflt = this.CreateSMEForCD(createDefault, addSme: addSme); + var dflt = this.CreateSMEForCD(createDefault, idShort: idShort, addSme: addSme); // set default? setDefault?.Invoke(dflt); @@ -5924,10 +6758,21 @@ public T CopyOneSMEbyCopy(Key destSemanticId, public T CopyOneSMEbyCopy(ConceptDescription destCD, SubmodelElementWrapperCollection sourceSmc, ConceptDescription sourceCD, bool createDefault = false, Action setDefault = null, - Key.MatchMode matchMode = Key.MatchMode.Relaxed, bool addSme = false) where T : SubmodelElement, new() + Key.MatchMode matchMode = Key.MatchMode.Relaxed, + string idShort = null, bool addSme = false) where T : SubmodelElement, new() { - return this.CopyOneSMEbyCopy(destCD?.GetSingleKey(), sourceSmc, sourceCD?.GetSingleKey(), - createDefault ? destCD : null, setDefault, matchMode, addSme); + return this.CopyOneSMEbyCopy(destCD?.GetSingleKey(), sourceSmc, new[] { sourceCD?.GetSingleKey() }, + createDefault ? destCD : null, setDefault, matchMode, idShort, addSme); + } + + public T CopyOneSMEbyCopy(ConceptDescription destCD, + SubmodelElementWrapperCollection sourceSmc, Key[] sourceKeys, + bool createDefault = false, Action setDefault = null, + Key.MatchMode matchMode = Key.MatchMode.Relaxed, + string idShort = null, bool addSme = false) where T : SubmodelElement, new() + { + return this.CopyOneSMEbyCopy(destCD?.GetSingleKey(), sourceSmc, sourceKeys, + createDefault ? destCD : null, setDefault, matchMode, idShort, addSme); } public void CopyManySMEbyCopy(Key destSemanticId, @@ -5987,12 +6832,13 @@ public void CopyManySMEbyCopy(ConceptDescription destCD, public interface IManageSubmodelElements { void Add(SubmodelElement sme); + void Insert(int index, SubmodelElement sme); void Remove(SubmodelElement sme); } public class Submodel : Identifiable, IManageSubmodelElements, - System.IDisposable, IGetReference, IEnumerateChildren, IFindAllReferences, - IGetSemanticId + System.IDisposable, IEnumerateChildren, IFindAllReferences, + IGetSemanticId, IGetQualifiers { // for JSON only [XmlIgnore] @@ -6036,23 +6882,31 @@ public string JsonKind [XmlArray("qualifier")] [XmlArrayItem("qualifier")] public QualifierCollection qualifiers = null; + public QualifierCollection GetQualifiers() => qualifiers; // from hasDataSpecification: [XmlElement(ElementName = "embeddedDataSpecification")] public HasDataSpecification hasDataSpecification = null; // from this very class + [XmlIgnore] [JsonIgnore] - public SubmodelElementWrapperCollection submodelElements = null; + private SubmodelElementWrapperCollection _submodelElements = null; + + [JsonIgnore] + public SubmodelElementWrapperCollection submodelElements + { + get { return _submodelElements; } + set { _submodelElements = value; _submodelElements.Parent = this; } + } [XmlIgnore] [JsonProperty(PropertyName = "submodelElements")] - public SubmodelElement[] JsonSubmodelElements { get { - var res = new List(); + var res = new ListOfSubmodelElement(); if (submodelElements != null) foreach (var smew in submodelElements) res.Add(smew.submodelElement); @@ -6153,13 +7007,21 @@ public IEnumerable EnumerateChildren() yield return smw; } - public void AddChild(SubmodelElementWrapper smw) + public EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child) + { + return null; + } + + public object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null) { if (smw == null) - return; + return null; if (this.submodelElements == null) this.submodelElements = new SubmodelElementWrapperCollection(); + if (smw.submodelElement != null) + smw.submodelElement.parent = this; this.submodelElements.Add(smw); + return smw; } // from IManageSubmodelElements @@ -6180,6 +7042,8 @@ public void Insert(int index, SubmodelElement sme) var sew = new SubmodelElementWrapper(); sme.parent = this; // track parent here! sew.submodelElement = sme; + if (index < 0 || index >= submodelElements.Count) + return; submodelElements.Insert(index, sew); } @@ -6191,12 +7055,26 @@ public void Remove(SubmodelElement sme) // further + public void AddQualifier( + string qualifierType = null, string qualifierValue = null, KeyList semanticKeys = null, + Reference qualifierValueId = null) + { + QualifierCollection.AddQualifier( + ref this.qualifiers, qualifierType, qualifierValue, semanticKeys, qualifierValueId); + } + + public Qualifier HasQualifierOfType(string qualifierType) + { + return QualifierCollection.HasQualifierOfType(this.qualifiers, qualifierType); + } + + public override AasElementSelfDescription GetSelfDescription() { return new AasElementSelfDescription("Submodel", "SM"); } - public Reference GetReference() + public SubmodelRef GetSubmodelRef() { SubmodelRef l = new SubmodelRef(); l.Keys.Add( @@ -6248,7 +7126,7 @@ public IEnumerable FindDeep(Predicate match = null) where T : SubmodelE public Tuple ToCaptionInfo() { - var caption = AdminShellNS.AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, ""); + var caption = AdminShellUtilV20.EvalToNonNullString("\"{0}\" ", idShort, ""); if (administration != null) caption += "V" + administration.version + "." + administration.revision; var info = ""; @@ -6265,46 +7143,58 @@ public override string ToString() // Recursing + /// + /// Recurses on all Submodel elements of a Submodel or SME, which allows children. + /// The state object will be passed to the lambda function in order to provide + /// stateful approaches. + /// + /// State object to be provided to lambda. Could be null. + /// The lambda function as (state, parents, SME) + /// The lambda shall return TRUE in order to deep into recursion. + /// public void RecurseOnSubmodelElements( - object state, Action, SubmodelElement> lambda) + object state, Func lambda) { - this.submodelElements?.RecurseOnSubmodelElements(state, null, lambda); + this.submodelElements?.RecurseOnReferables(state, null, (o, par, rf) => + { + if (rf is SubmodelElement sme) + return lambda(o, par, sme); + else + return true; + }); } - // Parents stuff - - private static void SetParentsForSME(Referable parent, SubmodelElement se) - { - if (se == null) - return; - - se.parent = parent; - - // via interface enumaration - if (se is IEnumerateChildren) + /// + /// Recurses on all Submodel elements of a Submodel or SME, which allows children. + /// The state object will be passed to the lambda function in order to provide + /// stateful approaches. Include this element, as well. + /// + /// State object to be provided to lambda. Could be null. + /// The lambda function as (state, parents, SME) + /// The lambda shall return TRUE in order to deep into recursion. + /// Include this element as well. parents will then + /// include this element as well! + public override void RecurseOnReferables( + object state, Func lambda, + bool includeThis = false) + { + var parents = new ListOfReferable(); + if (includeThis) { - var childs = (se as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - SetParentsForSME(se, c.submodelElement); + lambda(state, null, this); + parents.Add(this); } + this.submodelElements?.RecurseOnReferables(state, parents, lambda); } - public void SetAllParents() - { - if (this.submodelElements != null) - foreach (var sme in this.submodelElements) - SetParentsForSME(this, sme.submodelElement); - } + // Parents stuff - private static void SetParentsForSME(Referable parent, SubmodelElement se, DateTime timeStamp) + public static void SetParentsForSME(Referable parent, SubmodelElement se) { if (se == null) return; se.parent = parent; - se.TimeStamp = timeStamp; - se.TimeStampCreate = timeStamp; // via interface enumaration if (se is IEnumerateChildren) @@ -6312,15 +7202,15 @@ private static void SetParentsForSME(Referable parent, SubmodelElement se, DateT var childs = (se as IEnumerateChildren).EnumerateChildren(); if (childs != null) foreach (var c in childs) - SetParentsForSME(se, c.submodelElement, timeStamp); + SetParentsForSME(se, c.submodelElement); } } - public void SetAllParents(DateTime timeStamp) + public void SetAllParents() { if (this.submodelElements != null) foreach (var sme in this.submodelElements) - SetParentsForSME(this, sme.submodelElement, timeStamp); + SetParentsForSME(this, sme.submodelElement); } public T CreateSMEForCD(ConceptDescription cd, string category = null, string idShort = null, @@ -6341,7 +7231,7 @@ public T CreateSMEForIdShort(string idShort, string category = null, // validation - public override void Validate(AasValidationRecordListV20 results) + public override void Validate(AasValidationRecordList results) { // access if (results == null) @@ -6355,7 +7245,7 @@ public override void Validate(AasValidationRecordListV20 results) // find - public IEnumerable FindAllReferences() + public IEnumerable FindAllReferences() { // not nice: use temp list var temp = new List(); @@ -6373,11 +7263,28 @@ public IEnumerable FindAllReferences() if (rl.second != null) temp.Add(rl.second); } + // recurse + return true; }); // now, give back foreach (var r in temp) - yield return r; + yield return new LocatedReference(this, r); + } + } + + public class ListOfSubmodels : List, IAasElement + { + // self decscription + + public AasElementSelfDescription GetSelfDescription() + { + return new AasElementSelfDescription("Submodels", "SMS"); + } + + public string GetElementName() + { + return this.GetSelfDescription()?.ElementName; } } @@ -6388,23 +7295,23 @@ public IEnumerable FindAllReferences() public class DataElement : SubmodelElement { public static string ValueType_STRING = "string"; - public static string ValueType_DATE = "string"; - public static string ValueType_BOOLEAN = "date"; + public static string ValueType_DATE = "date"; + public static string ValueType_BOOLEAN = "boolean"; public static string[] ValueTypeItems = new string[] { "anyType", "complexType", "anySimpleType", "anyAtomicType", "anyURI", "base64Binary", "boolean", "date", "dateTime", "dateTimeStamp", "decimal", "integer", "long", "int", "short", "byte", "nonNegativeInteger", "positiveInteger", - "unsignedLong", "unsignedShort", "unsignedByte", "nonPositiveInteger", "negativeInteger", - "double", "duration", + "unsignedLong", "unsignedInt", "unsignedShort", "unsignedByte", "nonPositiveInteger", + "negativeInteger", "double", "duration", "dayTimeDuration", "yearMonthDuration", "float", "hexBinary", "string", "langString", "time" }; public static string[] ValueTypes_Number = new[] { "decimal", "integer", "long", "int", "short", "byte", "nonNegativeInteger", "positiveInteger", - "unsignedLong", "unsignedShort", "unsignedByte", "nonPositiveInteger", "negativeInteger", - "double", "float" }; + "unsignedLong", "unsignedInt", "unsignedShort", "unsignedByte", "nonPositiveInteger", + "negativeInteger", "double", "float" }; public DataElement() { } @@ -6442,7 +7349,6 @@ public JsonValueTypeCast(string name) } } - //[JsonConverter(typeof(IO.Swagger.Helpers.ValueOnlyJsonConverter))] public class Property : DataElement { // for JSON only @@ -6522,9 +7428,17 @@ public Property Set(string type, bool local, string idType, string value) return this; } + public Property Set(Qualifier q) + { + if (q != null) + this.AddQualifier(q); + return this; + } + public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("Property", "Prop"); + return new AasElementSelfDescription("Property", "Prop", + SubmodelElementWrapper.AdequateElementEnum.Property); } public override string ValueAsText(string defaultLang = null) @@ -6532,6 +7446,11 @@ public override string ValueAsText(string defaultLang = null) return "" + value; } + public override void ValueFromText(string text, string defaultLang = null) + { + value = "" + text; + } + public bool IsTrue() { if (this.valueType?.Trim().ToLower() == "boolean") @@ -6562,14 +7481,6 @@ public bool IsTrue() return null; } - public override object ToValueOnlySerialization() - { - var valueObject = new Dictionary - { - { idShort, value } - }; - return valueObject; - } } public class MultiLanguageProperty : DataElement @@ -6616,7 +7527,8 @@ public static MultiLanguageProperty CreateNew( public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("MultiLanguageProperty", "MLP"); + return new AasElementSelfDescription("MultiLanguageProperty", "MLP", + SubmodelElementWrapper.AdequateElementEnum.MultiLanguageProperty); } public MultiLanguageProperty Set(LangStringSet ls) @@ -6633,9 +7545,11 @@ public MultiLanguageProperty Set(ListOfLangStr ls) public MultiLanguageProperty Set(LangStr ls) { - if (this.value == null) + if (ls == null) + return this; + if (this.value?.langString == null) this.value = new LangStringSet(); - this.value.Add(ls); + this.value.langString[ls.lang] = ls.str; return this; } @@ -6649,18 +7563,11 @@ public override string ValueAsText(string defaultLang = null) return "" + value?.GetDefaultStr(defaultLang); } - public override object ToValueOnlySerialization() + public override void ValueFromText(string text, string defaultLang = null) { - var output = new Dictionary>(); - var valueDict = new Dictionary(); - foreach (LangStr langStr in value.langString) - { - valueDict.Add(langStr.lang, langStr.str); - } - - output.Add(idShort, valueDict); - return output; + Set(defaultLang, text); } + } public class Range : DataElement @@ -6727,7 +7634,8 @@ public static Range CreateNew(string idShort = null, string category = null, Key public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("Range", "Range"); + return new AasElementSelfDescription("Range", "Range", + SubmodelElementWrapper.AdequateElementEnum.Range); } public override string ValueAsText(string defaultLang = null) @@ -6735,18 +7643,6 @@ public override string ValueAsText(string defaultLang = null) return "" + min + " .. " + max; } - public override object ToValueOnlySerialization() - { - var output = new Dictionary>(); - var valueDict = new Dictionary - { - { "min", min }, - { "max", max } - }; - - output.Add(idShort, valueDict); - return output; - } } public class Blob : DataElement @@ -6812,33 +7708,10 @@ public void Set(string mimeType = "", string value = "") public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("Blob", "Blob"); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary>(); - var valueDict = new Dictionary - { - { "mimeType", mimeType }, - }; - - output.Add(idShort, valueDict); - return output; + return new AasElementSelfDescription("Blob", "Blob", + SubmodelElementWrapper.AdequateElementEnum.Blob); } - public object ToWithBlobOnlyValue() - { - var output = new Dictionary>(); - var valueDict = new Dictionary - { - { "mimeType", mimeType }, - { "value", Base64UrlEncoder.Encode(value) } - }; - - output.Add(idShort, valueDict); - return output; - } } public class File : DataElement @@ -6904,7 +7777,8 @@ public void Set(string mimeType = "", string value = "") public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("File", "File"); + return new AasElementSelfDescription("File", "File", + SubmodelElementWrapper.AdequateElementEnum.File); } public static string[] GetPopularMimeTypes() @@ -6929,19 +7803,6 @@ public override string ValueAsText(string defaultLang = null) { return "" + value; } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary>(); - var valueDict = new Dictionary - { - { "mimeType", mimeType }, - { "value", value } - }; - - output.Add(idShort, valueDict); - return output; - } } public class ReferenceElement : DataElement @@ -6999,27 +7860,10 @@ public void Set(Reference value = null) public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("ReferenceElement", "Ref"); + return new AasElementSelfDescription("ReferenceElement", "Ref", + SubmodelElementWrapper.AdequateElementEnum.ReferenceElement); } - public override object ToValueOnlySerialization() - { - var output = new Dictionary>>(); - - var list = new List>(); - foreach (var key in value.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - list.Add(valueDict); - } - - output.Add(idShort, list); - return output; - } } public class RelationshipElement : DataElement @@ -7086,40 +7930,8 @@ public void Set(Reference first = null, Reference second = null) public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("RelationshipElement", "Rel"); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary(); - - var listFirst = new List>(); - foreach (var key in first.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - listFirst.Add(valueDict); - } - - var listSecond = new List>(); - foreach (var key in second.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - listSecond.Add(valueDict); - } - - dynamic relObj = new ExpandoObject(); - relObj.first = listFirst; - relObj.second = listSecond; - output.Add(idShort, relObj); - return output; + return new AasElementSelfDescription("RelationshipElement", "Rel", + SubmodelElementWrapper.AdequateElementEnum.RelationshipElement); } } @@ -7207,13 +8019,21 @@ public IEnumerable EnumerateChildren() yield return smw; } - public void AddChild(SubmodelElementWrapper smw) + public EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child) + { + return null; + } + + public object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null) { if (smw == null || !(smw.submodelElement is DataElement)) - return; + return null; if (this.annotations == null) this.annotations = new DataElementWrapperCollection(); + if (smw.submodelElement != null) + smw.submodelElement.parent = this; this.annotations.Add(smw); + return smw; } // from IManageSubmodelElements @@ -7227,6 +8047,17 @@ public void Add(SubmodelElement sme) annotations.Add(sew); } + public void Insert(int index, SubmodelElement sme) + { + if (annotations == null) + annotations = new DataElementWrapperCollection(); + var sew = new SubmodelElementWrapper(); + sme.parent = this; // track parent here! + if (index < 0 || index >= annotations.Count) + return; + annotations.Insert(index, sew); + } + public void Remove(SubmodelElement sme) { if (annotations != null) @@ -7243,49 +8074,11 @@ public void Remove(SubmodelElement sme) public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("AnnotatedRelationshipElement", "RelA"); + return new AasElementSelfDescription("AnnotatedRelationshipElement", "RelA", + SubmodelElementWrapper.AdequateElementEnum.AnnotatedRelationshipElement); } - public override object ToValueOnlySerialization() - { - var output = new Dictionary(); - - var listFirst = new List>(); - foreach (var key in first.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - listFirst.Add(valueDict); - } - - var listSecond = new List>(); - foreach (var key in second.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - listSecond.Add(valueDict); - } - - List valueOnlyAnnotations = new List(); - - foreach (var sme in annotations) - { - valueOnlyAnnotations.Add(sme.submodelElement.ToValueOnlySerialization()); - } - dynamic relObj = new ExpandoObject(); - relObj.first = listFirst; - relObj.second = listSecond; - relObj.annotation = valueOnlyAnnotations; - output.Add(idShort, relObj); - return output; - } } public class Capability : SubmodelElement @@ -7298,7 +8091,8 @@ public Capability(SubmodelElement src) public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("Capability", "Cap"); + return new AasElementSelfDescription("Capability", "Cap", + SubmodelElementWrapper.AdequateElementEnum.Capability); } } @@ -7314,9 +8108,17 @@ public class SubmodelElementCollection : SubmodelElement, IManageSubmodelElement } // values == SMEs + [XmlIgnore] [JsonIgnore] [SkipForHash] // do NOT count children! - public SubmodelElementWrapperCollection value = new SubmodelElementWrapperCollection(); + private SubmodelElementWrapperCollection _value = null; + + [JsonIgnore] + public SubmodelElementWrapperCollection value + { + get { return _value; } + set { _value = value; _value.Parent = this; } + } [XmlIgnore] [JsonProperty(PropertyName = "value")] @@ -7324,7 +8126,7 @@ public SubmodelElement[] JsonValue { get { - var res = new List(); + var res = new ListOfSubmodelElement(); if (value != null) foreach (var smew in value) res.Add(smew.submodelElement); @@ -7357,13 +8159,21 @@ public IEnumerable EnumerateChildren() yield return smw; } - public void AddChild(SubmodelElementWrapper smw) + public EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child) + { + return null; + } + + public object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null) { if (smw == null) - return; + return null; if (this.value == null) this.value = new SubmodelElementWrapperCollection(); + if (smw.submodelElement != null) + smw.submodelElement.parent = this; this.value.Add(smw); + return smw; } // constructors @@ -7378,6 +8188,7 @@ public SubmodelElementCollection(SubmodelElement src, bool shallowCopy = false) this.ordered = smc.ordered; this.allowDuplicates = smc.allowDuplicates; + this.value = new SubmodelElementWrapperCollection(); if (!shallowCopy) foreach (var smw in smc.value) value.Add(new SubmodelElementWrapper(smw.submodelElement)); @@ -7393,6 +8204,7 @@ public SubmodelElementCollection( this.ordered = src.ordered; this.allowDuplicates = src.allowDuplicates; + this.value = new SubmodelElementWrapperCollection(); if (!shallowCopy) foreach (var smw in src.value) value.Add(new SubmodelElementWrapper(smw.submodelElement)); @@ -7425,6 +8237,8 @@ public void Insert(int index, SubmodelElement sme) var sew = new SubmodelElementWrapper(); sme.parent = this; // track parent here! sew.submodelElement = sme; + if (index < 0 || index >= value.Count) + return; value.Insert(index, sew); } @@ -7466,7 +8280,54 @@ public T CreateSMEForIdShort(string idShort, string category = null, public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("SubmodelElementCollection", "SMC"); + return new AasElementSelfDescription("SubmodelElementCollection", "SMC", + SubmodelElementWrapper.AdequateElementEnum.SubmodelElementCollection); + } + + // Recursing + + /// + /// Recurses on all Submodel elements of a Submodel or SME, which allows children. + /// The state object will be passed to the lambda function in order to provide + /// stateful approaches. + /// + /// State object to be provided to lambda. Could be null. + /// The lambda function as (state, parents, SME) + /// The lambda shall return TRUE in order to deep into recursion. + /// + public void RecurseOnSubmodelElements( + object state, Func lambda) + { + this.value?.RecurseOnReferables(state, null, (o, par, rf) => + { + if (rf is SubmodelElement sme) + return lambda(o, par, sme); + else + return true; + }); + } + + /// + /// Recurses on all Submodel elements of a Submodel or SME, which allows children. + /// The state object will be passed to the lambda function in order to provide + /// stateful approaches. Include this element, as well. + /// + /// State object to be provided to lambda. Could be null. + /// The lambda function as (state, parents, SME) + /// The lambda shall return TRUE in order to deep into recursion. + /// Include this element as well. parents will then + /// include this element as well! + public override void RecurseOnReferables( + object state, Func lambda, + bool includeThis = false) + { + var parents = new ListOfReferable(); + if (includeThis) + { + lambda(state, null, this); + parents.Add(this); + } + this.value?.RecurseOnReferables(state, parents, lambda); } } @@ -7602,14 +8463,23 @@ public List this[int dir] { get { - return (dir == 0) ? inputVariable : outputVariable; + if (dir == 0) + return inputVariable; + else + if (dir == 1) + return outputVariable; + else + return inoutputVariable; } set { if (dir == 0) inputVariable = value; else + if (dir == 1) outputVariable = value; + else + inoutputVariable = value; } } @@ -7638,9 +8508,91 @@ public IEnumerable EnumerateChildren() yield return smw?.value; } - public void AddChild(SubmodelElementWrapper smw) + public class EnumerationPlacmentOperationVariable : EnumerationPlacmentBase { - // not enough information to select list of children + public OperationVariable.Direction Direction; + public OperationVariable OperationVariable; + } + + public EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child) + { + // trivial + if (child == null) + return null; + + // search + OperationVariable.Direction? dir = null; + OperationVariable opvar = null; + if (this.inputVariable != null) + foreach (var ov in this.inputVariable) + if (ov?.value?.submodelElement == child) + { + dir = OperationVariable.Direction.In; + opvar = ov; + } + + if (this.outputVariable != null) + foreach (var ov in this.outputVariable) + if (ov?.value?.submodelElement == child) + { + dir = OperationVariable.Direction.Out; + opvar = ov; + } + + if (this.inoutputVariable != null) + foreach (var ov in this.inoutputVariable) + if (ov?.value?.submodelElement == child) + { + dir = OperationVariable.Direction.InOut; + opvar = ov; + } + + // found + if (!dir.HasValue) + return null; + return new EnumerationPlacmentOperationVariable() + { + Direction = dir.Value, + OperationVariable = opvar + }; + } + + public object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null) + { + // not enough information to select list of children? + var pl = placement as EnumerationPlacmentOperationVariable; + if (smw == null || pl == null) + return null; + + // ok, use information + var ov = new OperationVariable(); + ov.value = smw; + + if (smw.submodelElement != null) + smw.submodelElement.parent = this; + + if (pl.Direction == OperationVariable.Direction.In) + { + if (inputVariable == null) + inputVariable = new List(); + inputVariable.Add(ov); + } + + if (pl.Direction == OperationVariable.Direction.Out) + { + if (outputVariable == null) + outputVariable = new List(); + outputVariable.Add(ov); + } + + if (pl.Direction == OperationVariable.Direction.InOut) + { + if (inoutputVariable == null) + inoutputVariable = new List(); + inoutputVariable.Add(ov); + } + + return ov; } // constructors @@ -7680,7 +8632,8 @@ public Operation(AasxCompatibilityModels.AdminShellV10.Operation src) public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("Operation", "Opr"); + return new AasElementSelfDescription("Operation", "Opr", + SubmodelElementWrapper.AdequateElementEnum.Operation); } } @@ -7699,10 +8652,17 @@ public enum EntityTypeEnum { CoManagedEntity = 0, SelfManagedEntity = 1, Undef = } // from this very class - + [XmlIgnore] [JsonIgnore] [SkipForHash] // do NOT count children! - public SubmodelElementWrapperCollection statements = new SubmodelElementWrapperCollection(); + private SubmodelElementWrapperCollection _statements = null; + + [JsonIgnore] + public SubmodelElementWrapperCollection statements + { + get { return _statements; } + set { _statements = value; _statements.Parent = this; } + } [XmlIgnore] [JsonProperty(PropertyName = "statements")] @@ -7710,7 +8670,7 @@ public SubmodelElement[] JsonStatements { get { - var res = new List(); + var res = new ListOfSubmodelElement(); if (statements != null) foreach (var smew in statements) res.Add(smew.submodelElement); @@ -7747,13 +8707,21 @@ public IEnumerable EnumerateChildren() yield return smw; } - public void AddChild(SubmodelElementWrapper smw) + public EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child) + { + return null; + } + + public object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null) { if (smw == null) - return; + return null; if (this.statements == null) this.statements = new SubmodelElementWrapperCollection(); + if (smw.submodelElement != null) + smw.submodelElement.parent = this; this.statements.Add(smw); + return smw; } // constructors @@ -7777,10 +8745,12 @@ public Entity(SubmodelElement src) this.assetRef = new AssetRef(ent.assetRef); } - public Entity(EntityTypeEnum entityType, string idShort = null, AssetRef assetRef = null) + public Entity(EntityTypeEnum entityType, string idShort = null, AssetRef assetRef = null, + string category = null, Key semanticIdKey = null) { + CreateNewLogic(idShort, null, semanticIdKey); + this.entityType = EntityTypeNames[(int)entityType]; - this.idShort = idShort; this.assetRef = assetRef; } @@ -7806,6 +8776,18 @@ public void Add(SubmodelElement sme) statements.Add(sew); } + public void Insert(int index, SubmodelElement sme) + { + if (statements == null) + statements = new SubmodelElementWrapperCollection(); + var sew = new SubmodelElementWrapper(); + sme.parent = this; // track parent here! + sew.submodelElement = sme; + if (index < 0 || index >= statements.Count) + return; + statements.Insert(index, sew); + } + public void Remove(SubmodelElement sme) { if (statements != null) @@ -7825,6 +8807,22 @@ public SubmodelElementWrapper FindSubmodelElementWrapper(string idShort) return null; } + public T CreateSMEForCD(ConceptDescription cd, string category = null, string idShort = null, + string idxTemplate = null, int maxNum = 999, bool addSme = false) where T : SubmodelElement, new() + { + if (this.statements == null) + this.statements = new SubmodelElementWrapperCollection(); + return this.statements.CreateSMEForCD(cd, category, idShort, idxTemplate, maxNum, addSme); + } + + public T CreateSMEForIdShort(string idShort, string category = null, + string idxTemplate = null, int maxNum = 999, bool addSme = false) where T : SubmodelElement, new() + { + if (this.statements == null) + this.statements = new SubmodelElementWrapperCollection(); + return this.statements.CreateSMEForIdShort(idShort, category, idxTemplate, maxNum, addSme); + } + // entity type public EntityTypeEnum GetEntityType() @@ -7841,28 +8839,8 @@ public EntityTypeEnum GetEntityType() public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("Entity", "Ent"); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary(); - List valueOnlyStatements = new List(); - - foreach (var sme in statements) - { - valueOnlyStatements.Add(sme.submodelElement.ToValueOnlySerialization()); - } - - var valueDict = new Dictionary - { - { "statements", valueOnlyStatements }, - { "entityType", entityType}, - { "assetId", assetRef.First.value }, - }; - - output.Add(idShort, valueDict); - return output; + return new AasElementSelfDescription("Entity", "Ent", + SubmodelElementWrapper.AdequateElementEnum.Entity); } } @@ -7906,33 +8884,11 @@ public static BasicEvent CreateNew(string idShort = null, string category = null public override AasElementSelfDescription GetSelfDescription() { - return new AasElementSelfDescription("BasicEvent", "Evt"); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary(); - var list = new List>(); - foreach (var key in observed.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - list.Add(valueDict); - } - - var observedDict = new Dictionary>>(); - observedDict.Add("observed", list); - output.Add(idShort, observedDict); - - return output; + return new AasElementSelfDescription("BasicEvent", "Evt", + SubmodelElementWrapper.AdequateElementEnum.BasicEvent); } } - - // // Handling of packages // diff --git a/src/AasxServerStandardBib/AdminShellConverters.cs b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellConverters.cs similarity index 64% rename from src/AasxServerStandardBib/AdminShellConverters.cs rename to src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellConverters.cs index 3b6b74f20..63dd76d92 100644 --- a/src/AasxServerStandardBib/AdminShellConverters.cs +++ b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellConverters.cs @@ -1,22 +1,34 @@ -using System; +/* +Copyright (c) 2018-2021 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ + +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; -using AasCore.Aas3_0_RC02; +using AasxCompatibilityModels; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; -namespace AdminShellNS +//namespace AdminShellNS +namespace AdminShell_V20 { - public class AdminShellConverters + public static class AdminShellConverters { /// - /// This converter is used for reading JSON files; it claims to be responsible for "SubmodelElements" (the base class) - /// and decides, which sub-class of the base class shall be populated. - /// The decision, shich special sub-class to create is done in a factory SubmodelElementWrapper.CreateAdequateType(), + /// This converter is used for reading JSON files; it claims to be responsible for + /// "Referable" (the base class) + /// and decides, which sub-class of the base class shall be populated. + /// If the object is SubmodelElement, the decision, shich special sub-class to create is done in a factory + /// AdminShell.SubmodelElementWrapper.CreateAdequateType(), /// in order to have all sub-class specific decisions in one place (SubmodelElementWrapper) /// Remark: There is a NuGet package JsonSubTypes, which could have done the job, except the fact of having /// "modelType" being a class property with a contained property "name". @@ -38,7 +50,8 @@ public JsonAasxConverter(string UpperClassProperty, string LowerClassProperty) : public override bool CanConvert(Type objectType) { - if (typeof(ISubmodelElement).IsAssignableFrom(objectType)) + // Info MIHO 21 APR 2020: changed this from SubmodelElement to Referable + if (typeof(AdminShell.Referable).IsAssignableFrom(objectType)) return true; return false; } @@ -57,27 +70,28 @@ public override object ReadJson(JsonReader reader, JObject jObject = JObject.Load(reader); // Create target object based on JObject - //object target = new SubmodelElement(); - ISubmodelElement target = null; + object target = new AdminShell.Referable(); if (jObject.ContainsKey(UpperClassProperty)) { var j2 = jObject[UpperClassProperty]; - foreach (var c in j2.Children()) - { - var cprop = c as Newtonsoft.Json.Linq.JProperty; - if (cprop == null) - continue; - if (cprop.Name == LowerClassProperty && cprop.Value != null && cprop.Value.Type.ToString() == "String") + if (j2 != null) + foreach (var c in j2.Children()) { - var cpval = cprop.Value.ToObject(); - if (cpval == null) + var cprop = c as Newtonsoft.Json.Linq.JProperty; + if (cprop == null) continue; - var o = CreateSubmodelElementIstance(cpval); - if (o != null) - target = o; + if (cprop.Name == LowerClassProperty && cprop.Value.Type.ToString() == "String") + { + var cpval = cprop.Value.ToObject(); + if (cpval == null) + continue; + // Info MIHO 21 APR 2020: use Referable.CreateAdequateType instead of SMW... + var o = AdminShell.Referable.CreateAdequateType(cpval); + if (o != null) + target = o; + } } - } } // Populate the object properties @@ -86,22 +100,16 @@ public override object ReadJson(JsonReader reader, return target; } - - private static ISubmodelElement CreateSubmodelElementIstance(string typeName) - { - //TODO: jtikekar Need to test - Type type = Type.GetType(typeName); - if (type == null || !type.IsSubclassOf(typeof(ISubmodelElement))) - return null; - var sme = Activator.CreateInstance(type) as ISubmodelElement; - return sme; - } + /// + /// Introduced for JSON serialization, can create Referables based on a string name + /// + /// string name (standard PascalCased) + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { throw new NotImplementedException(); } - } /// @@ -138,21 +146,24 @@ protected override JsonProperty CreateProperty(MemberInfo member, MemberSerializ { JsonProperty property = base.CreateProperty(member, memberSerialization); - if (!BlobHasValue && property.DeclaringType == typeof(Blob) && property.PropertyName == "value") + if (!BlobHasValue && property.DeclaringType == typeof(AdminShell.Blob) && + property.PropertyName == "value") property.ShouldSerialize = instance => { return false; }; - if (!SubmodelHasElements && property.DeclaringType == typeof(Submodel) && property.PropertyName == "submodelElements") + if (!SubmodelHasElements && property.DeclaringType == typeof(AdminShell.Submodel) && + property.PropertyName == "submodelElements") property.ShouldSerialize = instance => { return false; }; - if (!SmcHasValue && property.DeclaringType == typeof(SubmodelElementCollection) && property.PropertyName == "value") + if (!SmcHasValue && property.DeclaringType == typeof(AdminShell.SubmodelElementCollection) && + property.PropertyName == "value") property.ShouldSerialize = instance => { return false; }; - if (!OpHasVariables && property.DeclaringType == typeof(Operation) && (property.PropertyName == "in" || property.PropertyName == "out")) + if (!OpHasVariables && property.DeclaringType == typeof(AdminShell.Operation) && + (property.PropertyName == "in" || property.PropertyName == "out")) property.ShouldSerialize = instance => { return false; }; - - //TODO (jtikekar, 2022-07-08): AssetAdministrationShell.View not supported anymore - if (!AasHasViews && property.DeclaringType == typeof(AssetAdministrationShell) && property.PropertyName == "views") + if (!AasHasViews && property.DeclaringType == typeof(AdminShell.AdministrationShell) && + property.PropertyName == "views") property.ShouldSerialize = instance => { return false; }; return property; diff --git a/src/AasxServerStandardBib/AdminShellUtil.cs b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellUtil.cs similarity index 79% rename from src/AasxServerStandardBib/AdminShellUtil.cs rename to src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellUtil.cs index 6054a508d..81b80b9c5 100644 --- a/src/AasxServerStandardBib/AdminShellUtil.cs +++ b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellUtil.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2019 Festo AG & Co. KG +Copyright (c) 2018-2021 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). @@ -7,8 +7,7 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt). This source code may use other Open Source software components (see LICENSE.txt). */ -using AasCore.Aas3_0_RC02; -using AasxServerStandardBib; +using AasxCompatibilityModels; using System; using System.Collections; using System.Collections.Generic; @@ -19,9 +18,10 @@ This source code may use other Open Source software components (see LICENSE.txt) using System.Text.RegularExpressions; using System.Threading.Tasks; -namespace AdminShellNS +//namespace AdminShellNS +namespace AdminShell_V20 { - public static class AdminShellUtil + public static class AdminShellUtilV20 { public static string EvalToNonNullString(string fmt, object o, string elseString = "") { @@ -187,7 +187,7 @@ public static string[] CleanHereStringToArray(string here) public static string CleanHereStringWithNewlines(string here, string nl = null) { if (nl == null) - nl = System.Environment.NewLine; + nl = Environment.NewLine; var lines = CleanHereStringToArray(here); if (lines == null) return null; @@ -362,12 +362,12 @@ public static void CheckSearchable( { // try get a speaking name var metaModelName = ""; - var x1 = mi.GetCustomAttribute(); + var x1 = mi.GetCustomAttribute(); if (x1 != null && x1.name != null) metaModelName = x1.name; // check if this object is searchable - var x2 = mi.GetCustomAttribute(); + var x2 = mi.GetCustomAttribute(); if (x2 != null) { // what to check? @@ -415,10 +415,9 @@ public static void EnumerateSearchable( // try to get element name of an AAS entity string elName = null; - if (obj is IReferable) + if (obj is AdminShell.Referable) { - //elName = (obj as IReferable).GetElementName(); - elName = obj.GetType().Name; + elName = (obj as AdminShell.Referable).GetElementName(); businessObject = obj; } @@ -431,16 +430,20 @@ public static void EnumerateSearchable( if (options.allowedAssemblies == null || !options.allowedAssemblies.Contains(objType.Assembly)) return; + // do not dive into enums + if (objType.IsEnum) + return; + // look at fields, first var fields = objType.GetFields(); foreach (var fi in fields) { // is the object marked to be skipped? - var x3 = fi.GetCustomAttribute(); + var x3 = fi.GetCustomAttribute(); if (x3 != null) continue; - var x4 = fi.GetCustomAttribute(); + var x4 = fi.GetCustomAttribute(); if (x4 != null) continue; @@ -477,11 +480,11 @@ public static void EnumerateSearchable( continue; // is the object marked to be skipped? - var x3 = pi.GetCustomAttribute(); + var x3 = pi.GetCustomAttribute(); if (x3 != null) continue; - var x4 = pi.GetCustomAttribute(); + var x4 = pi.GetCustomAttribute(); if (x4 != null) continue; @@ -508,5 +511,126 @@ public static void EnumerateSearchable( } } } + + // + // String manipulations + // + + public static string ReplacePercentPlaceholder( + string input, + string searchFor, + Func substLamda, + StringComparison comparisonType = StringComparison.InvariantCulture) + { + // access + if (input == null || searchFor == null || searchFor == "") + return input; + + // find + while (true) + { + // any occurence + var p = input.IndexOf(searchFor, comparisonType); + if (p < 0) + break; + + // split + var left = input.Substring(0, p); + var right = ""; + var rp = p + searchFor.Length; + if (rp < input.Length) + right = input.Substring(rp); + + // lambda + var repl = "" + substLamda?.Invoke(); + + // build new + input = left + repl + right; + } + + // ok + return input; + } + + // + // Base 64 + // + + public static string Base64Encode(string plainText) + { + var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); + return System.Convert.ToBase64String(plainTextBytes); + } + + public static string Base64Decode(string base64EncodedData) + { + var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData); + return System.Text.Encoding.UTF8.GetString(base64EncodedBytes); + } + + // + // Generation of Ids + // + + private static Random MyRnd = new Random(); + + public static string GenerateIdAccordingTemplate(string tpl) + { + // generate a deterministic decimal digit string + var decimals = String.Format("{0:ffffyyMMddHHmmss}", DateTime.UtcNow); + decimals = new string(decimals.Reverse().ToArray()); + // convert this to an int + if (!Int64.TryParse(decimals, out Int64 decii)) + decii = MyRnd.Next(Int32.MaxValue); + // make an hex out of this + string hexamals = decii.ToString("X"); + // make an alphanumeric string out of this + string alphamals = ""; + var dii = decii; + while (dii >= 1) + { + var m = dii % 26; + alphamals += Convert.ToChar(65 + m); + dii = dii / 26; + } + + // now, "salt" the strings + for (int i = 0; i < 32; i++) + { + var c = Convert.ToChar(48 + MyRnd.Next(10)); + decimals += c; + hexamals += c; + alphamals += c; + } + + // now, can just use the template + var id = ""; + foreach (var tpli in tpl) + { + if (tpli == 'D' && decimals.Length > 0) + { + id += decimals[0]; + decimals = decimals.Remove(0, 1); + } + else + if (tpli == 'X' && hexamals.Length > 0) + { + id += hexamals[0]; + hexamals = hexamals.Remove(0, 1); + } + else + if (tpli == 'A' && alphamals.Length > 0) + { + id += alphamals[0]; + alphamals = alphamals.Remove(0, 1); + } + else + id += tpli; + } + + // ok + return id; + } + } } diff --git a/src/AasxServerStandardBib/AdminShellValidate.cs b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellValidate.cs similarity index 95% rename from src/AasxServerStandardBib/AdminShellValidate.cs rename to src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellValidate.cs index 8411a7760..524683e57 100644 --- a/src/AasxServerStandardBib/AdminShellValidate.cs +++ b/src/AasxCsharpLibrary/AasxCompatibilityModels/V20/AdminShellValidate.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2019 Festo AG & Co. KG +Copyright (c) 2018-2021 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). @@ -7,17 +7,24 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt). This source code may use other Open Source software components (see LICENSE.txt). */ -using AasCore.Aas3_0_RC02; using System; using System.Collections.Generic; +using System.ComponentModel.Design; using System.IO; using System.Linq; using System.Reflection; +using System.Text; using System.Text.RegularExpressions; +using System.Threading.Tasks; using System.Xml; using System.Xml.Schema; +using JetBrains.Annotations; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Schema; -namespace AdminShellNS +//namespace AdminShellNS +namespace AdminShell_V20 { /// /// validates the XML content against the AASX XML schema. @@ -76,6 +83,7 @@ public enum AasValidationSeverity Hint, Warning, SpecViolation, SchemaViolation, Serialization } + [UsedImplicitlyAttribute] // for eventual use public enum AasValidationAction { No, ToBeDeleted @@ -84,12 +92,12 @@ public enum AasValidationAction public class AasValidationRecord { public AasValidationSeverity Severity = AasValidationSeverity.Hint; - public IReferable Source = null; + public AasxCompatibilityModels.AdminShellV20.Referable Source = null; public string Message = ""; public Action Fix = null; - public AasValidationRecord(AasValidationSeverity Severity, IReferable Source, + public AasValidationRecord(AasValidationSeverity Severity, AasxCompatibilityModels.AdminShellV20.Referable Source, string Message, Action Fix = null) { this.Severity = Severity; @@ -203,7 +211,7 @@ public static XmlValidator NewXmlValidator() { var parts = new List { $"Failed to compile the schema files:" }; parts.AddRange(newRecs.Select((r) => r.Message)); - throw new InvalidOperationException(string.Join(System.Environment.NewLine, parts)); + throw new InvalidOperationException(string.Join(Environment.NewLine, parts)); } return new XmlValidator(xmlSchemaSet); diff --git a/src/AasxCsharpLibrary/AasxCsharpLibrary.csproj b/src/AasxCsharpLibrary/AasxCsharpLibrary.csproj new file mode 100644 index 000000000..8814bd04d --- /dev/null +++ b/src/AasxCsharpLibrary/AasxCsharpLibrary.csproj @@ -0,0 +1,42 @@ + + + net6.0 + Library + AdminShellNS + false + + + TRACE;UseAasxCompatibilityModels + + + + PreserveNewest + + + + + Designer + PreserveNewest + + + Designer + PreserveNewest + + + Designer + PreserveNewest + + + + + + + + + + + + + + + diff --git a/src/AasxCsharpLibrary/AdminShellCollections.cs b/src/AasxCsharpLibrary/AdminShellCollections.cs new file mode 100644 index 000000000..26fc3f837 --- /dev/null +++ b/src/AasxCsharpLibrary/AdminShellCollections.cs @@ -0,0 +1,66 @@ +/* +Copyright (c) 2018-2021 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdminShellNS +{ + public class MultiValueDictionary + { + private Dictionary> dict = new Dictionary>(); + public void Add(K key, V value) + { + if (dict.TryGetValue(key, out var list)) + list.Add(value); + else + dict.Add(key, new List { value }); + } + + public bool ContainsKey(K key) => dict.ContainsKey(key); + + public List this[K key] => dict[key]; + + public IEnumerable> Keys + { + get + { + return dict.Values; + } + } + } + + public class DoubleSidedDict + { + private Dictionary _forward = new Dictionary(); + private Dictionary _backward = new Dictionary(); + + public void AddPair(T1 item1, T2 item2) + { + _forward.Add(item1, item2); + _backward.Add(item2, item1); + } + + public bool Contains1(T1 key1) => _forward.ContainsKey(key1); + public bool Contains2(T2 key2) => _backward.ContainsKey(key2); + + public T2 Get2(T1 key1) => _forward[key1]; + public T1 Get1(T2 key2) => _backward[key2]; + + public T2 Get2OrDefault(T1 key1) + => (key1 != null && _forward.ContainsKey(key1)) ? _forward[key1] : default(T2); + public T1 Get1OrDefault(T2 key2) + => (key2 != null && _backward.ContainsKey(key2)) ? _backward[key2] : default(T1); + + public void Clear() { _forward.Clear(); _backward.Clear(); } + } +} diff --git a/src/AasxCsharpLibrary/AdminShellConverters.cs b/src/AasxCsharpLibrary/AdminShellConverters.cs new file mode 100644 index 000000000..fd30b6ec7 --- /dev/null +++ b/src/AasxCsharpLibrary/AdminShellConverters.cs @@ -0,0 +1,192 @@ +/* +Copyright (c) 2018-2021 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ + +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using AasCore.Aas3_0_RC02; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Serialization; + +namespace AdminShellNS +{ + public static class AdminShellConverters + { + /// + /// This converter is used for reading JSON files; it claims to be responsible for + /// "Referable" (the base class) + /// and decides, which sub-class of the base class shall be populated. + /// If the object is SubmodelElement, the decision, shich special sub-class to create is done in a factory + /// SubmodelElementWrapper.CreateAdequateType(), + /// in order to have all sub-class specific decisions in one place (SubmodelElementWrapper) + /// Remark: There is a NuGet package JsonSubTypes, which could have done the job, except the fact of having + /// "modelType" being a class property with a contained property "name". + /// + public class JsonAasxConverter : JsonConverter + { + private string UpperClassProperty = "modelType"; + private string LowerClassProperty = "name"; + + public JsonAasxConverter() : base() + { + } + + public JsonAasxConverter(string UpperClassProperty, string LowerClassProperty) : base() + { + this.UpperClassProperty = UpperClassProperty; + this.LowerClassProperty = LowerClassProperty; + } + + public override bool CanConvert(Type objectType) + { + // Info MIHO 21 APR 2020: changed this from SubmodelElement to Referable + if (typeof(IReferable).IsAssignableFrom(objectType)) + return true; + return false; + } + + public override bool CanWrite + { + get { return false; } + } + + public override object ReadJson(JsonReader reader, + Type objectType, + object existingValue, + JsonSerializer serializer) + { + // Load JObject from stream + JObject jObject = JObject.Load(reader); + + // Create target object based on JObject + IReferable target = null; + + if (jObject.ContainsKey(UpperClassProperty)) + { + var j2 = jObject[UpperClassProperty]; + if (j2 != null) + foreach (var c in j2.Children()) + { + var cprop = c as Newtonsoft.Json.Linq.JProperty; + if (cprop == null) + continue; + if (cprop.Name == LowerClassProperty && cprop.Value.Type.ToString() == "String") + { + var cpval = cprop.Value.ToObject(); + if (cpval == null) + continue; + // Info MIHO 21 APR 2020: use Referable.CreateAdequateType instead of SMW... + var o = CreateAdequateType(cpval); + if (o != null) + target = o; + } + } + } + + // Populate the object properties + serializer.Populate(jObject.CreateReader(), target); + + return target; + } + + public static IReferable CreateAdequateType(string elementName) + { + if (elementName == KeyTypes.AssetAdministrationShell.ToString()) + return new AssetAdministrationShell("", null); //TODO: jtikekar: refactor default + //if (elementName == "Asset") //TODO: jtikekar Change + // return new AssetInformation(AssetKind.Instance); + if (elementName == KeyTypes.ConceptDescription.ToString()) + return new ConceptDescription(""); + if (elementName == KeyTypes.Submodel.ToString()) + return new Submodel(""); + //if (elementName == KeyTypes.View) + // return new View(); + return CreateSubmodelElementIstance(elementName); + } + + private static ISubmodelElement CreateSubmodelElementIstance(string typeName) + { + //TODO: jtikekar Need to test + Type type = Type.GetType(typeName); + if (type == null || !type.IsSubclassOf(typeof(ISubmodelElement))) + return null; + var sme = Activator.CreateInstance(type) as ISubmodelElement; + return sme; + } + + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new NotImplementedException(); + } + } + + /// + /// This converter / contract resolver for Json.NET adaptively filters different levels of depth + /// of nested AASX structures. + /// + public class AdaptiveFilterContractResolver : DefaultContractResolver + { + public bool AasHasViews = true; + public bool BlobHasValue = true; + public bool SubmodelHasElements = true; + public bool SmcHasValue = true; + public bool OpHasVariables = true; + + public AdaptiveFilterContractResolver() { } + + public AdaptiveFilterContractResolver(bool deep = true, bool complete = true) + { + if (!deep) + { + this.SubmodelHasElements = false; + this.SmcHasValue = false; + this.OpHasVariables = false; + } + if (!complete) + { + this.AasHasViews = false; + this.BlobHasValue = false; + } + + } + + protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization) + { + JsonProperty property = base.CreateProperty(member, memberSerialization); + + if (!BlobHasValue && property.DeclaringType == typeof(Blob) && + property.PropertyName == "value") + property.ShouldSerialize = instance => { return false; }; + + if (!SubmodelHasElements && property.DeclaringType == typeof(Submodel) && + property.PropertyName == "submodelElements") + property.ShouldSerialize = instance => { return false; }; + + if (!SmcHasValue && property.DeclaringType == typeof(SubmodelElementCollection) && + property.PropertyName == "value") + property.ShouldSerialize = instance => { return false; }; + + if (!OpHasVariables && property.DeclaringType == typeof(Operation) && + (property.PropertyName == "in" || property.PropertyName == "out")) + property.ShouldSerialize = instance => { return false; }; + + if (!AasHasViews && property.DeclaringType == typeof(AssetAdministrationShell) && + property.PropertyName == "views") + property.ShouldSerialize = instance => { return false; }; + + return property; + } + } + + } +} diff --git a/src/AasxServerStandardBib/AdminShellPackageEnv.cs b/src/AasxCsharpLibrary/AdminShellPackageEnv.cs similarity index 82% rename from src/AasxServerStandardBib/AdminShellPackageEnv.cs rename to src/AasxCsharpLibrary/AdminShellPackageEnv.cs index d09927342..b3bffc6f5 100644 --- a/src/AasxServerStandardBib/AdminShellPackageEnv.cs +++ b/src/AasxCsharpLibrary/AdminShellPackageEnv.cs @@ -7,10 +7,6 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt). This source code may use other Open Source software components (see LICENSE.txt). */ -using AasCore.Aas3_0_RC02; -using Extenstions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.IO; @@ -20,6 +16,11 @@ This source code may use other Open Source software components (see LICENSE.txt) using System.Threading.Tasks; using System.Xml; using System.Xml.Serialization; +using AasCore.Aas3_0_RC02; +using AdminShellNS; +using Extensions; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; namespace AdminShellNS { @@ -27,7 +28,6 @@ namespace AdminShellNS /// This class lets an outer functionality keep track on the supplementary files, which are in or /// are pending to be added or deleted to an Package. /// - //TODO: jtikekar need to test if require implementation of IReferable public class AdminShellPackageSupplementaryFile /*: IReferable*/ { public delegate byte[] SourceGetByteChunk(); @@ -46,7 +46,6 @@ public enum SpecialHandlingType { None, EmbedAsThumbnail } public LocationType Location; public readonly SpecialHandlingType SpecialHandling; - public AdminShellPackageSupplementaryFile( Uri uri, string sourceLocalPath = null, LocationType location = LocationType.InPackage, SpecialHandlingType specialHandling = SpecialHandlingType.None, @@ -61,41 +60,11 @@ public AdminShellPackageSupplementaryFile( } // class derives from Referable in order to provide GetElementName - //public override string GetElementName() public string GetElementName() { return "File"; } - public IEnumerable DescendOnce() - { - throw new NotImplementedException(); - } - - public IEnumerable Descend() - { - throw new NotImplementedException(); - } - - public void Accept(Visitation.IVisitor visitor) - { - throw new NotImplementedException(); - } - - public void Accept(Visitation.IVisitorWithContext visitor, TContext context) - { - throw new NotImplementedException(); - } - - public T Transform(Visitation.ITransformer transformer) - { - throw new NotImplementedException(); - } - - public T Transform(Visitation.ITransformerWithContext transformer, TContext context) - { - throw new NotImplementedException(); - } } public class ListOfAasSupplementaryFile : List @@ -153,7 +122,20 @@ public static string TryReadXmlFirstElementNamespaceURI(Stream s) } /// - /// De-serialize an open stream into AdministrationShellEnv. Does version/ compatibility management. + /// Skips first few tokens of an XML content until first "real" element is encountered + /// + /// + public static void XmlSkipHeader(XmlReader xmlReader) + { + while (xmlReader.NodeType == XmlNodeType.XmlDeclaration || + xmlReader.NodeType == XmlNodeType.Whitespace || + xmlReader.NodeType == XmlNodeType.Comment || + xmlReader.NodeType == XmlNodeType.None) + xmlReader.Read(); + } + + /// + /// De-serialize an open stream into Environment. Does version/ compatibility management. /// /// Open for read stream /// @@ -174,7 +156,7 @@ public static AasCore.Aas3_0_RC02.Environment DeserializeXmlFromStreamWithCompat "http://www.admin-shell.io/aas/1/0"); var v10 = serializer.Deserialize(s) as AasxCompatibilityModels.AdminShellV10.AdministrationShellEnv; //res = new AdministrationShellEnv(v10); - res = new AasCore.Aas3_0_RC02.Environment(); + res = new AasCore.Aas3_0_RC02.Environment(new List(), new List(), new List()); res.ConvertFromV10(v10); return res; #else @@ -191,7 +173,7 @@ public static AasCore.Aas3_0_RC02.Environment DeserializeXmlFromStreamWithCompat "http://www.admin-shell.io/aas/2/0"); var v20 = serializer.Deserialize(s) as AasxCompatibilityModels.AdminShellV20.AdministrationShellEnv; //res = new AdministrationShellEnv(v20); - res = new AasCore.Aas3_0_RC02.Environment(); + res = new AasCore.Aas3_0_RC02.Environment(new List(), new List(), new List()); res.ConvertFromV20(v20); return res; #else @@ -200,78 +182,69 @@ public static AasCore.Aas3_0_RC02.Environment DeserializeXmlFromStreamWithCompat } // read V3.0? - if (nsuri != null && nsuri.Trim() == "http://www.admin-shell.io/aas/3/0") + if (nsuri != null && nsuri.Trim() == Xmlization.NS) { //XmlSerializer serializer = new XmlSerializer( // typeof(AasCore.Aas3_0_RC02.Environment), "http://www.admin-shell.io/aas/3/0"); //res = serializer.Deserialize(s) as AasCore.Aas3_0_RC02.Environment; - XmlReader xmlReader = XmlReader.Create(s); - res = Xmlization.Deserialize.EnvironmentFrom(xmlReader, "http://www.admin-shell.io/aas/3/0"); - return res; + using (var xmlReader = XmlReader.Create(s)) + { + // TODO (MIHO, 2022-12-26): check if could be feature of AAS core + XmlSkipHeader(xmlReader); + res = Xmlization.Deserialize.EnvironmentFrom(xmlReader); + return res; + } } // nope! return null; } - public static JsonSerializer BuildDefaultAasxJsonSerializer() - { - var serializer = new JsonSerializer(); - serializer.Converters.Add( - new AdminShellConverters.JsonAasxConverter( - "modelType", "name")); - return serializer; - } - - /// - /// This does not work enough - /// - public static string FixSerializedVersionedEntities(string txt) - { - txt = txt.Replace(".AdminShellV20+", ".AdminShellV30+"); - return txt; - } - - public static T DeserializeFromJSON(TextReader textReader) where T : IReferable - { - var serializer = BuildDefaultAasxJsonSerializer(); - var rf = (T)serializer.Deserialize(textReader, typeof(T)); - return rf; - } + //public static JsonSerializer BuildDefaultAasxJsonSerializer() + //{ + // var serializer = new JsonSerializer(); + // serializer.Converters.Add( + // new AdminShellConverters.JsonAasxConverter( + // "modelType", "name")); + // return serializer; + //} public static T DeserializeFromJSON(string data) where T : IReferable { - using (var tr = new StringReader(data)) - { - var serializer = BuildDefaultAasxJsonSerializer(); - var rf = (T)serializer.Deserialize(tr, typeof(T)); - return rf; - } - } + //using (var tr = new StringReader(data)) + //{ + //var serializer = BuildDefaultAasxJsonSerializer(); + //var rf = (T)serializer.Deserialize(tr, typeof(T)); - public static T DeserializeFromJSON(JToken obj) where T : IReferable - { - if (obj == null) - //return null; - return default; - var serializer = BuildDefaultAasxJsonSerializer(); - var rf = obj.ToObject(serializer); - return rf; - } + var node = System.Text.Json.Nodes.JsonNode.Parse(data); + var rf = Jsonization.Deserialize.IReferableFrom(node); - /// - /// Use this, if DeserializeFromJSON is too tight. - /// - public static T DeserializePureObjectFromJSON(string data) - { - using (var tr = new StringReader(data)) - { - var serializer = BuildDefaultAasxJsonSerializer(); - var rf = (T)serializer.Deserialize(tr, typeof(T)); - return rf; - } + return (T)rf; + //} } + + //public static T DeserializeFromJSON(JToken obj) where T : IReferable + //{ + // if (obj == null) + // return default(T); + // var serializer = BuildDefaultAasxJsonSerializer(); + // var rf = obj.ToObject(serializer); + // return rf; + //} + + ///// + ///// Use this, if DeserializeFromJSON is too tight. + ///// + //public static T DeserializePureObjectFromJSON(string data) + //{ + // using (var tr = new StringReader(data)) + // { + // //var serializer = BuildDefaultAasxJsonSerializer(); + // //var rf = (T)serializer.Deserialize(tr, typeof(T)); + // return null; + // } + //} } /// @@ -284,7 +257,7 @@ public class AdminShellPackageEnv : IDisposable private string _tempFn = null; - private AasCore.Aas3_0_RC02.Environment _aasEnv = new AasCore.Aas3_0_RC02.Environment(new List(), new List(), new List(), new List()); + private AasCore.Aas3_0_RC02.Environment _aasEnv = new AasCore.Aas3_0_RC02.Environment(new List(), new List(), new List()); private Package _openPackage = null; private readonly ListOfAasSupplementaryFile _pendingFilesToAdd = new ListOfAasSupplementaryFile(); private readonly ListOfAasSupplementaryFile _pendingFilesToDelete = new ListOfAasSupplementaryFile(); @@ -357,16 +330,19 @@ private static AasCore.Aas3_0_RC02.Environment LoadJson(string fn) { try { - using (StreamReader file = System.IO.File.OpenText(fn)) + using (var file = System.IO.File.OpenRead(fn)) { - // TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer - var serializer = new JsonSerializer(); - serializer.Converters.Add( - new AdminShellConverters.JsonAasxConverter( - "modelType", "name")); + //// TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer + //var serializer = new JsonSerializer(); + //serializer.Converters.Add( + // new AdminShellConverters.JsonAasxConverter( + // "modelType", "name")); + + //var aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( + // file, typeof(AasCore.Aas3_0_RC02.Environment)); - var aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( - file, typeof(AasCore.Aas3_0_RC02.Environment)); + var node = System.Text.Json.Nodes.JsonNode.Parse(file); + var aasEnv = Jsonization.Deserialize.EnvironmentFrom(node); return aasEnv; } @@ -434,16 +410,19 @@ private static (AasCore.Aas3_0_RC02.Environment, Package) LoadPackageAasx(string { using (var s = specPart.GetStream(FileMode.Open)) { - using (var file = new StreamReader(s)) - { - JsonSerializer serializer = new JsonSerializer(); - serializer.Converters.Add( - new AdminShellConverters.JsonAasxConverter( - "modelType", "name")); - - aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( - file, typeof(AasCore.Aas3_0_RC02.Environment)); - } + //using (var file = new StreamReader(s)) + //{ + //JsonSerializer serializer = new JsonSerializer(); + //serializer.Converters.Add( + // new AdminShellConverters.JsonAasxConverter( + // "modelType", "name")); + + //aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( + // file, typeof(AasCore.Aas3_0_RC02.Environment)); + + var node = System.Text.Json.Nodes.JsonNode.Parse(s); + aasEnv = Jsonization.Deserialize.EnvironmentFrom(node); + //} } } else @@ -452,8 +431,6 @@ private static (AasCore.Aas3_0_RC02.Environment, Package) LoadPackageAasx(string { // own catch loop to be more specific aasEnv = AdminShellSerializationHelper.DeserializeXmlFromStreamWithCompat(s); - //XmlReader xmlReader = XmlReader.Create(s); - //aasEnv = Xmlization.Deserialize.EnvironmentFrom(xmlReader); openPackage = package; if (aasEnv == null) @@ -561,14 +538,17 @@ public void LoadFromAasEnvString(string content) { try { - using (var file = new StringReader(content)) - { + //using (var file = new StringReader(content)) + //{ // TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer - JsonSerializer serializer = new JsonSerializer(); - serializer.Converters.Add(new AdminShellConverters.JsonAasxConverter("modelType", "name")); - _aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( - file, typeof(AasCore.Aas3_0_RC02.Environment)); - } + //JsonSerializer serializer = new JsonSerializer(); + //serializer.Converters.Add(new AdminShellConverters.JsonAasxConverter("modelType", "name")); + //_aasEnv = (AasCore.Aas3_0_RC02.Environment)serializer.Deserialize( + // file, typeof(AasCore.Aas3_0_RC02.Environment)); + + var node = System.Text.Json.Nodes.JsonNode.Parse(content); + _aasEnv = Jsonization.Deserialize.EnvironmentFrom(node); + //} } catch (Exception ex) { @@ -580,15 +560,15 @@ public void LoadFromAasEnvString(string content) public enum SerializationFormat { None, Xml, Json }; - public static XmlSerializerNamespaces GetXmlDefaultNamespaces() - { - var nss = new XmlSerializerNamespaces(); - nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); - nss.Add("aas", "http://www.admin-shell.io/aas/3/0"); - nss.Add("IEC", "http://www.admin-shell.io/IEC61360/3/0"); - nss.Add("abac", "http://www.admin-shell.io/aas/abac/3/0"); - return nss; - } + //public static XmlSerializerNamespaces GetXmlDefaultNamespaces() + //{ + // var nss = new XmlSerializerNamespaces(); + // nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); + // nss.Add("aas", "http://www.admin-shell.io/aas/2/0"); + // nss.Add("IEC", "http://www.admin-shell.io/IEC61360/2/0"); + // nss.Add("abac", "http://www.admin-shell.io/aas/abac/2/0"); + // return nss; + //} public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat prefFmt = SerializationFormat.None, MemoryStream useMemoryStream = null, bool saveOnlyCopy = false) @@ -607,9 +587,19 @@ public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat pre try { // TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer - var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); - var nss = GetXmlDefaultNamespaces(); - serializer.Serialize(s, _aasEnv, nss); + //var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); + //var nss = GetXmlDefaultNamespaces(); + //serializer.Serialize(s, _aasEnv, nss); + + var writer = XmlWriter.Create(s, new XmlWriterSettings() + { + Indent = true, + OmitXmlDeclaration = true + }); + Xmlization.Serialize.To( + _aasEnv, writer); + writer.Flush(); + writer.Close(); s.Flush(); } finally @@ -641,23 +631,37 @@ public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat pre try { - // TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer - JsonSerializer serializer = new JsonSerializer() + //// TODO (Michael Hoffmeister, 2020-08-01): use a unified function to create a serializer + //JsonSerializer serializer = new JsonSerializer() + //{ + // NullValueHandling = NullValueHandling.Ignore, + // ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + // Formatting = Newtonsoft.Json.Formatting.Indented + //}; + + //var sw = new StreamWriter(s); + //var writer = new JsonTextWriter(sw); + + //serializer.Serialize(writer, _aasEnv); + //writer.Flush(); + //sw.Flush(); + //s.Flush(); + + //if (useMemoryStream == null) + //{ + // writer.Close(); + // sw.Close(); + //} + + using (var wr = new System.Text.Json.Utf8JsonWriter(s)) { - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Serialize, - Formatting = Newtonsoft.Json.Formatting.Indented - }; - - using (var sw = new StreamWriter(s)) - { - using (var writer = new JsonTextWriter(sw)) - { - serializer.Serialize(writer, _aasEnv); - writer.Flush(); - sw.Flush(); - s.Flush(); - } + Jsonization.Serialize.ToJsonObject(_aasEnv).WriteTo(wr, + new System.Text.Json.JsonSerializerOptions() + { + WriteIndented = true + }); + wr.Flush(); + s.Flush(); } } finally @@ -791,8 +795,8 @@ public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat pre { // create, as not existing var frn = "aasenv-with-no-id"; - if (this.AasEnv.AssetAdministrationShells.Count > 0) - frn = this.AasEnv.AssetAdministrationShells[0].GetFriendlyName() ?? frn; + if (_aasEnv.AssetAdministrationShells.Count > 0) + frn = _aasEnv.AssetAdministrationShells[0].GetFriendlyName() ?? frn; var aas_spec_fn = "/aasx/#/#.aas"; if (prefFmt == SerializationFormat.Json) aas_spec_fn += ".json"; @@ -829,18 +833,20 @@ public bool SaveAs(string fn, bool writeFreshly = false, SerializationFormat pre { using (var s = specPart.GetStream(FileMode.Create)) { - var nss = GetXmlDefaultNamespaces(); //var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); + //var nss = GetXmlDefaultNamespaces(); //serializer.Serialize(s, _aasEnv, nss); - XmlWriterSettings settings = new XmlWriterSettings + var writer = XmlWriter.Create(s, new XmlWriterSettings() { Indent = true, OmitXmlDeclaration = true - }; - using XmlWriter writer = XmlWriter.Create(s, settings); - string ns = "http://www.admin-shell.io/aas/3/0"; - Xmlization.Serialize.To((IClass)_aasEnv, writer, ns: ns); + }); + Xmlization.Serialize.To( + _aasEnv, writer); + writer.Flush(); + writer.Close(); + s.Flush(); } } @@ -1074,12 +1080,23 @@ public void BackupInDir(string backupDir, int maxFiles) // raw save using (var s = new StreamWriter(bdfn)) { - var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); - var nss = new XmlSerializerNamespaces(); - nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); - nss.Add("aas", "http://www.admin-shell.io/aas/2/0"); - nss.Add("IEC61360", "http://www.admin-shell.io/IEC61360/2/0"); - serializer.Serialize(s, _aasEnv, nss); + //var serializer = new XmlSerializer(typeof(AasCore.Aas3_0_RC02.Environment)); + //var nss = new XmlSerializerNamespaces(); + //nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); + //nss.Add("aas", "http://www.admin-shell.io/aas/2/0"); + //nss.Add("IEC61360", "http://www.admin-shell.io/IEC61360/2/0"); + //serializer.Serialize(s, _aasEnv, nss); + + var writer = XmlWriter.Create(s, new XmlWriterSettings() + { + Indent = true, + OmitXmlDeclaration = true + }); + Xmlization.Serialize.To( + _aasEnv, writer); + writer.Flush(); + writer.Close(); + s.Flush(); } } catch (Exception ex) @@ -1094,7 +1111,7 @@ public Stream GetStreamFromUriOrLocalPackage(string uriString, { // local if (IsLocalFile(uriString)) - return GetLocalStreamFromPackage(uriString, mode); + return GetLocalStreamFromPackage(uriString, mode, access); // no .. return System.IO.File.Open(uriString, mode, access); @@ -1124,7 +1141,7 @@ public bool IsLocalFile(string uriString) { // access if (_openPackage == null) - throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); + return false; if (uriString == null || uriString == "" || !uriString.StartsWith("/")) return false; @@ -1133,27 +1150,23 @@ public bool IsLocalFile(string uriString) return isLocal; } - public Stream GetLocalStreamFromPackage(string uriString, FileMode mode = FileMode.Open) + public Stream GetLocalStreamFromPackage(string uriString, FileMode mode = FileMode.Open, FileAccess access = FileAccess.Read) { // access - try - { - if (_openPackage == null) - throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); + if (_openPackage == null) + throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); - // gte part - var uri = PackUriHelper.CreatePartUri(new Uri(uriString, UriKind.RelativeOrAbsolute)); - var part = _openPackage.GetPart(uri); - if (part == null) - throw (new Exception( - string.Format($"Cannot access URI {uriString} in {_fn} not opened. Aborting!"))); - return part.GetStream(mode); - } - catch (InvalidOperationException ex) - { - //Considering the exception occurs at GetPart method - throw new AasxServerStandardBib.Exceptions.UnprocessableEntityException($"No File found at {uriString}"); - } + // exist + var puri = new Uri(uriString, UriKind.RelativeOrAbsolute); + if (!_openPackage.PartExists(puri)) + throw (new Exception(string.Format($"AASX Package has no part {uriString}. Aborting!"))); + + // get part + var part = _openPackage.GetPart(puri); + if (part == null) + throw (new Exception( + string.Format($"Cannot access part {uriString} in {_fn}. Aborting!"))); + return part.GetStream(mode, access); } public async Task ReplaceSupplementaryFileInPackageAsync(string sourceUri, string targetFile, string targetContentType, Stream fileContent) @@ -1166,7 +1179,7 @@ public async Task ReplaceSupplementaryFileInPackageAsync(string sourceUri, strin { _openPackage.DeletePart(new Uri(sourceUri, UriKind.RelativeOrAbsolute)); - } + } var targetUri = PackUriHelper.CreatePartUri(new Uri(targetFile, UriKind.RelativeOrAbsolute)); PackagePart packagePart = _openPackage.CreatePart(targetUri, targetContentType); fileContent.Position = 0; @@ -1374,8 +1387,7 @@ public void PrepareSupplementaryFileParameters(ref string targetDir, ref string /// Target path of file in package public string AddSupplementaryFileToStore( string sourcePath, string targetDir, string targetFn, bool embedAsThumb, - AdminShellPackageSupplementaryFile.SourceGetByteChunk sourceGetBytesDel = null, - string useMimeType = null) + AdminShellPackageSupplementaryFile.SourceGetByteChunk sourceGetBytesDel = null, string useMimeType = null) { // beautify parameters if ((sourcePath == null && sourceGetBytesDel == null) || targetDir == null || targetFn == null) @@ -1449,6 +1461,12 @@ public void Close() _aasEnv = null; } + public void Flush() + { + if (_openPackage != null) + _openPackage.Flush(); + } + public void Dispose() { Close(); @@ -1486,5 +1504,32 @@ public string MakePackageFileAvailableAsTempFile(string packageUri, bool keepFil } } + public void EmbeddAssetInformationThumbnail(Resource defaultThumbnail, Stream fileContent) + { + // access + if (_openPackage == null) + throw (new Exception(string.Format($"AASX Package {_fn} not opened. Aborting!"))); + + if (!string.IsNullOrEmpty(defaultThumbnail.Path)) + { + var sourceUri = defaultThumbnail.Path.Replace(Path.DirectorySeparatorChar, '/'); + _openPackage.DeletePart(new Uri(sourceUri, UriKind.RelativeOrAbsolute)); + + } + var targetUri = PackUriHelper.CreatePartUri(new Uri(defaultThumbnail.Path, UriKind.RelativeOrAbsolute)); + + PackagePart packagePart = _openPackage.CreatePart(targetUri, defaultThumbnail.ContentType, compressionOption: CompressionOption.Maximum); + + _openPackage.CreateRelationship(packagePart.Uri, TargetMode.Internal, + "http://schemas.openxmlformats.org/package/2006/" + + "relationships/metadata/thumbnail"); + + //Write to the part + fileContent.Position = 0; + using (Stream dest = packagePart.GetStream()) + { + fileContent.CopyTo(dest); + } + } } } diff --git a/src/AasxCsharpLibrary/AdminShellUtil.cs b/src/AasxCsharpLibrary/AdminShellUtil.cs new file mode 100644 index 000000000..bca364a23 --- /dev/null +++ b/src/AasxCsharpLibrary/AdminShellUtil.cs @@ -0,0 +1,678 @@ +/* +Copyright (c) 2018-2021 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ + +using AasCore.Aas3_0_RC02; +using Extensions; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using static AasxCompatibilityModels.AdminShellV20.SubmodelElementWrapper; +using static Extensions.ExtendIDataSpecificationContent; + +namespace AdminShellNS +{ + public static class AdminShellUtil + { + + #region Various utilities + // ------------------------------------------------------------------------------------ + + public static T[] GetEnumValues() where T : Enum + => (T[])Enum.GetValues(typeof(T)); + + public static IEnumerable GetEnumValues(T[] excludes) where T : Enum + { + foreach (var v in (T[])Enum.GetValues(typeof(T))) + if (!excludes.Contains(v)) + yield return v; + } + + #endregion + + #region V3 Methods + + public static string[] GetPopularMimeTypes() + { + return + new[] { + System.Net.Mime.MediaTypeNames.Text.Plain, + System.Net.Mime.MediaTypeNames.Text.Xml, + System.Net.Mime.MediaTypeNames.Text.Html, + "application/json", + "application/rdf+xml", + System.Net.Mime.MediaTypeNames.Application.Pdf, + System.Net.Mime.MediaTypeNames.Image.Jpeg, + "image/png", + System.Net.Mime.MediaTypeNames.Image.Gif, + "application/iges", + "application/step" + }; + } + + public static IEnumerable GetAdequateEnums(AasSubmodelElements[] excludeValues = null, AasSubmodelElements[] includeValues = null) + { + if (includeValues != null) + { + foreach (var en in includeValues) + yield return en; + } + else + { + foreach (var en in (AasSubmodelElements[])Enum.GetValues(typeof(AasSubmodelElements))) + { + if (en == AasSubmodelElements.SubmodelElement) + continue; + if (excludeValues != null && excludeValues.Contains(en)) + continue; + yield return en; + } + } + } + + public static AasSubmodelElements? AasSubmodelElementsFrom() where T : ISubmodelElement + { + if (typeof(T) == typeof(Property)) + return AasSubmodelElements.Property; + if (typeof(T) == typeof(MultiLanguageProperty)) + return AasSubmodelElements.MultiLanguageProperty; + if (typeof(T) == typeof(AasCore.Aas3_0_RC02.Range)) + return AasSubmodelElements.Range; + if (typeof(T) == typeof(AasCore.Aas3_0_RC02.File)) + return AasSubmodelElements.File; + if (typeof(T) == typeof(Blob)) + return AasSubmodelElements.Blob; + if (typeof(T) == typeof(ReferenceElement)) + return AasSubmodelElements.ReferenceElement; + if (typeof(T) == typeof(RelationshipElement)) + return AasSubmodelElements.RelationshipElement; + if (typeof(T) == typeof(AnnotatedRelationshipElement)) + return AasSubmodelElements.AnnotatedRelationshipElement; + if (typeof(T) == typeof(Capability)) + return AasSubmodelElements.Capability; + if (typeof(T) == typeof(SubmodelElementCollection)) + return AasSubmodelElements.SubmodelElementCollection; + if (typeof(T) == typeof(Operation)) + return AasSubmodelElements.Operation; + if (typeof(T) == typeof(BasicEventElement)) + return AasSubmodelElements.BasicEventElement; + if (typeof(T) == typeof(Entity)) + return AasSubmodelElements.Entity; + return null; + } + + + public static ISubmodelElement CreateSubmodelElementFromEnum(AasSubmodelElements smeEnum, ISubmodelElement sourceSme = null) + { + switch(smeEnum) + { + case AasSubmodelElements.Property: + { + return new Property(DataTypeDefXsd.String).UpdateFrom(sourceSme); + } + case AasSubmodelElements.MultiLanguageProperty: + { + return new MultiLanguageProperty().UpdateFrom(sourceSme); + } + case AasSubmodelElements.Range: + { + return new AasCore.Aas3_0_RC02.Range(DataTypeDefXsd.String).UpdateFrom(sourceSme); + } + case AasSubmodelElements.File: + { + return new AasCore.Aas3_0_RC02.File("").UpdateFrom(sourceSme); + } + case AasSubmodelElements.Blob: + { + return new Blob("").UpdateFrom(sourceSme); + } + case AasSubmodelElements.ReferenceElement: + { + return new ReferenceElement().UpdateFrom(sourceSme); + } + case AasSubmodelElements.RelationshipElement: + { + return new RelationshipElement(null, null).UpdateFrom(sourceSme); + } + case AasSubmodelElements.AnnotatedRelationshipElement: + { + return new AnnotatedRelationshipElement(null, null).UpdateFrom(sourceSme); + } + case AasSubmodelElements.Capability: + { + return new Capability(); + } + case AasSubmodelElements.SubmodelElementCollection: + { + return new SubmodelElementCollection().UpdateFrom(sourceSme); + } + case AasSubmodelElements.SubmodelElementList: + { + return new SubmodelElementList(AasSubmodelElements.SubmodelElement).UpdateFrom(sourceSme); + } + case AasSubmodelElements.Operation: + { + return new Operation().UpdateFrom(sourceSme); + } + case AasSubmodelElements.BasicEventElement: + { + return new BasicEventElement(null, Direction.Input, StateOfEvent.Off); + } + case AasSubmodelElements.Entity: + { + return new Entity(EntityType.SelfManagedEntity); + } + default: + { + return null; + } + } + } + + #endregion + public static string EvalToNonNullString(string fmt, object o, string elseString = "") + { + if (o == null) + return elseString; + return string.Format(fmt, o); + } + + public static string EvalToNonEmptyString(string fmt, string o, string elseString = "") + { + if (o == null || o == "") + return elseString; + return string.Format(fmt, o); + } + + /// + /// If len of exceeds then + /// string is shortened and returned with an ellipsis(…) at the end. + /// + /// Shortened string + public static string ShortenWithEllipses(string str, int maxLen) + { + if (str == null) + return null; + if (maxLen >= 0 && str.Length > maxLen) + str = str.Substring(0, maxLen) + "\u2026"; + return str; + } + + /// + /// Returns a string without newlines and shortened (with ellipsis) + /// to a certain length + /// + /// Single-line, shortened string + public static string ToSingleLineShortened(string str, int maxLen, string textNewLine = " ") + { + str = str.ReplaceLineEndings(textNewLine); + return ShortenWithEllipses(str, maxLen); + } + + /// Creates a filter-friendly name from the source. + /// + /// Assert.AreEqual("", AdminShellUtil.FilterFriendlyName("")); + /// Assert.AreEqual("someName", AdminShellUtil.FilterFriendlyName("someName")); + /// Assert.AreEqual("some__name", AdminShellUtil.FilterFriendlyName("some!;name")); + /// + public static string FilterFriendlyName(string src) + { + if (src == null) + return null; + return Regex.Replace(src, @"[^a-zA-Z0-9\-_]", "_"); + } + + /// + /// Assert.IsFalse(AdminShellUtil.HasWhitespace("")); + /// Assert.IsTrue(AdminShellUtil.HasWhitespace(" ")); + /// Assert.IsTrue(AdminShellUtil.HasWhitespace("aa bb")); + /// Assert.IsTrue(AdminShellUtil.HasWhitespace(" aabb")); + /// Assert.IsTrue(AdminShellUtil.HasWhitespace("aabb ")); + /// Assert.IsFalse(AdminShellUtil.HasWhitespace("aabb")); + /// + public static bool HasWhitespace(string src) + { + if (src == null) + throw new ArgumentNullException(nameof(src)); + foreach (var s in src) + if (char.IsWhiteSpace(s)) + return true; + return false; + } + + /// Assert.IsTrue(AdminShellUtil.ComplyIdShort("")); + public static bool ComplyIdShort(string src) + { + if (src == null) + throw new ArgumentNullException(nameof(src)); + var res = true; + foreach (var s in src) + if (!Char.IsLetterOrDigit(s) && s != '_') + res = false; + if (src.Length > 0 && !Char.IsLetter(src[0])) + res = false; + return res; + } + + public static string ByteSizeHumanReadable(long len) + { + // see: https://stackoverflow.com/questions/281640/ + // how-do-i-get-a-human-readable-file-size-in-bytes-abbreviation-using-net + string[] sizes = { "B", "KB", "MB", "GB", "TB" }; + int order = 0; + while (len >= 1024 && order < sizes.Length - 1) + { + order++; + len = len / 1024; + } + // Adjust the format string to your preferences. For example "{0:0.#}{1}" would + // show a single decimal place, and no space. + string res = String.Format("{0:0.##} {1}", len, sizes[order]); + return res; + } + + public static string ExtractPascalCasingLetters(string src) + { + // access + src = src?.Trim(); + if (src == null || src.Length < 1) + return null; + + // walk through + var res = ""; + var arm = true; + foreach (var c in src) + { + // take? + if (arm && Char.IsUpper(c)) + res += c; + // state for next iteration + arm = !Char.IsUpper(c); + } + + // result + return res; + } + + public static int CountHeadingSpaces(string line) + { + if (line == null) + return 0; + int j; + for (j = 0; j < line.Length; j++) + if (!Char.IsWhiteSpace(line[j])) + break; + return j; + } + + /// + /// Used to re-reformat a C# here string, which is multiline string introduced by @" ... "; + /// + public static string[] CleanHereStringToArray(string here) + { + if (here == null) + return null; + + // convert all weird breaks to pure new lines + here = here.Replace("\r\n", "\n"); + here = here.Replace("\n\r", "\n"); + + // convert all tabs to spaces + here = here.Replace("\t", " "); + + // split these + var lines = new List(here.Split('\n')); + if (lines.Count < 1) + return lines.ToArray(); + + // the first line could be special + string firstLine = null; + if (lines[0].Trim() != "") + { + firstLine = lines[0].Trim(); + lines.RemoveAt(0); + } + + // detect an constant amount of heading spaces + var headSpaces = int.MaxValue; + foreach (var line in lines) + if (line.Trim() != "") + headSpaces = Math.Min(headSpaces, CountHeadingSpaces(line)); + + // multi line trim possible? + if (headSpaces != int.MaxValue && headSpaces > 0) + for (int i = 0; i < lines.Count; i++) + if (lines[i].Length > headSpaces) + lines[i] = lines[i].Substring(headSpaces); + + // re-compose again + if (firstLine != null) + lines.Insert(0, firstLine); + + // return + return lines.ToArray(); + } + + /// + /// Used to re-reformat a C# here string, which is multiline string introduced by @" ... "; + /// + public static string CleanHereStringWithNewlines(string here, string nl = null) + { + if (nl == null) + nl = System.Environment.NewLine; + var lines = CleanHereStringToArray(here); + if (lines == null) + return null; + return String.Join(nl, lines); + } + + public static string ShortLocation(Exception ex) + { + if (ex == null || ex.StackTrace == null) + return ""; + string[] lines = ex.StackTrace.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); + if (lines.Length < 1) + return ""; + // search for " in " + // as the most actual stacktrace might be a built-in function, this might not work and therefore + // go down in the stack + int currLine = 0; + while (true) + { + // nothing found at all + if (currLine >= lines.Length) + return ""; + // access current line + /* TODO (MIHO, 2020-11-12): replace with Regex for multi language. Ideally have Exception messages + always as English. */ + var p = lines[currLine].IndexOf(" in ", StringComparison.Ordinal); + if (p < 0) + p = lines[currLine].IndexOf(" bei ", StringComparison.Ordinal); + if (p < 0) + { + // advance to next oldest line + currLine++; + continue; + } + // search last "\" or "/", to get only filename portion and position + p = lines[currLine].LastIndexOfAny(new[] { '\\', '/' }); + if (p < 0) + { + // advance to next oldest line + currLine++; + continue; + } + // return this + return lines[currLine].Substring(p); + } + } + + public enum ConstantFoundEnum { No, AnyCase, ExactCase } + + public static ConstantFoundEnum CheckIfInConstantStringArray(string[] arr, string str) + { + if (arr == null || str == null) + return ConstantFoundEnum.No; + + bool anyCaseFound = false; + bool exactCaseFound = false; + foreach (var a in arr) + { + anyCaseFound = anyCaseFound || str.ToLower() == a.ToLower(); + exactCaseFound = exactCaseFound || str == a; + } + if (exactCaseFound) + return ConstantFoundEnum.ExactCase; + if (anyCaseFound) + return ConstantFoundEnum.AnyCase; + return ConstantFoundEnum.No; + } + + public static string CorrectCasingForConstantStringArray(string[] arr, string str) + { + if (arr == null || str == null) + return str; + + foreach (var a in arr) + if (str.ToLower() == a.ToLower()) + return a; + + return str; + } + + // + // String manipulations + // + + public static string ReplacePercentPlaceholder( + string input, + string searchFor, + Func substLamda, + StringComparison comparisonType = StringComparison.InvariantCulture) + { + // access + if (input == null || searchFor == null || searchFor == "") + return input; + + // find + while (true) + { + // any occurence + var p = input.IndexOf(searchFor, comparisonType); + if (p < 0) + break; + + // split + var left = input.Substring(0, p); + var right = ""; + var rp = p + searchFor.Length; + if (rp < input.Length) + right = input.Substring(rp); + + // lambda + var repl = "" + substLamda?.Invoke(); + + // build new + input = left + repl + right; + } + + // ok + return input; + } + + // + // Reflection + // + + public static void SetFieldLazyValue(FieldInfo f, object obj, object value) + { + // access + if (f == null || obj == null) + return; + + switch (Type.GetTypeCode(f.FieldType)) + { + case TypeCode.String: + f.SetValue(obj, "" + value); + break; + + case TypeCode.Byte: + if (Byte.TryParse("" + value, out var ui8)) + f.SetValue(obj, ui8); + break; + + case TypeCode.SByte: + if (SByte.TryParse("" + value, out var i8)) + f.SetValue(obj, i8); + break; + + case TypeCode.Int16: + if (Int16.TryParse("" + value, out var i16)) + f.SetValue(obj, i16); + break; + + case TypeCode.Int32: + if (Int32.TryParse("" + value, out var i32)) + f.SetValue(obj, i32); + break; + + case TypeCode.Int64: + if (Int64.TryParse("" + value, out var i64)) + f.SetValue(obj, i64); + break; + + case TypeCode.UInt16: + if (UInt16.TryParse("" + value, out var ui16)) + f.SetValue(obj, ui16); + break; + + case TypeCode.UInt32: + if (UInt32.TryParse("" + value, out var ui32)) + f.SetValue(obj, ui32); + break; + + case TypeCode.UInt64: + if (UInt64.TryParse("" + value, out var ui64)) + f.SetValue(obj, ui64); + break; + + case TypeCode.Single: + if (Single.TryParse("" + value, NumberStyles.Float, + CultureInfo.InvariantCulture, out var sgl)) + f.SetValue(obj, sgl); + break; + + case TypeCode.Double: + if (Double.TryParse("" + value, NumberStyles.Float, + CultureInfo.InvariantCulture, out var dbl)) + f.SetValue(obj, dbl); + break; + + case TypeCode.Boolean: + var isFalse = value == null + || (value is int vi && vi == 0) + || (value is string vs && vs == "") + || (value is bool vb && !vb); + f.SetValue(obj, isFalse); + break; + } + } + + // + // Base 64 + // + + public static string Base64Encode(string plainText) + { + var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText); + return System.Convert.ToBase64String(plainTextBytes); + } + + public static string Base64Decode(string base64EncodedData) + { + var base64EncodedBytes = System.Convert.FromBase64String(base64EncodedData); + return System.Text.Encoding.UTF8.GetString(base64EncodedBytes); + } + + // + // Generation of Ids + // + + private static Random MyRnd = new Random(); + + public static string GenerateIdAccordingTemplate(string tpl) + { + // generate a deterministic decimal digit string + var decimals = String.Format("{0:ffffyyMMddHHmmss}", DateTime.UtcNow); + decimals = new string(decimals.Reverse().ToArray()); + // convert this to an int + if (!Int64.TryParse(decimals, out Int64 decii)) + decii = MyRnd.Next(Int32.MaxValue); + // make an hex out of this + string hexamals = decii.ToString("X"); + // make an alphanumeric string out of this + string alphamals = ""; + var dii = decii; + while (dii >= 1) + { + var m = dii % 26; + alphamals += Convert.ToChar(65 + m); + dii = dii / 26; + } + + // now, "salt" the strings + for (int i = 0; i < 32; i++) + { + var c = Convert.ToChar(48 + MyRnd.Next(10)); + decimals += c; + hexamals += c; + alphamals += c; + } + + // now, can just use the template + var id = ""; + foreach (var tpli in tpl) + { + if (tpli == 'D' && decimals.Length > 0) + { + id += decimals[0]; + decimals = decimals.Remove(0, 1); + } + else + if (tpli == 'X' && hexamals.Length > 0) + { + id += hexamals[0]; + hexamals = hexamals.Remove(0, 1); + } + else + if (tpli == 'A' && alphamals.Length > 0) + { + id += alphamals[0]; + alphamals = alphamals.Remove(0, 1); + } + else + id += tpli; + } + + // ok + return id; + } + + public static string RemoveNewLinesAndLimit(string input, int maxLength = -1, string ellipsis = "..") + { + // access + if (input == null) + return null; + + // maybe do a generouse limit first + if (maxLength >= 1 && input.Length > 2 * maxLength) + input = input.Substring(0, 2 * maxLength); + + // now do expensive operations + input = input.Replace('\r', ' '); + input = input.Replace('\n', ' '); + input = Regex.Replace(input, @"\s+", " ", RegexOptions.Compiled); + + // now apply exact limit + if (maxLength >= 1 && input.Length > maxLength) + input = input.Substring(0, maxLength) + ellipsis; + + // ok + return input; + } + + + } +} diff --git a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShellValidate.cs b/src/AasxCsharpLibrary/AdminShellValidate.cs similarity index 97% rename from src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShellValidate.cs rename to src/AasxCsharpLibrary/AdminShellValidate.cs index 3515ab451..938c91c57 100644 --- a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShellValidate.cs +++ b/src/AasxCsharpLibrary/AdminShellValidate.cs @@ -1,5 +1,5 @@ /* -Copyright (c) 2018-2019 Festo AG & Co. KG +Copyright (c) 2018-2021 Festo AG & Co. KG Author: Michael Hoffmeister This source code is licensed under the Apache License 2.0 (see LICENSE.txt). @@ -18,12 +18,14 @@ This source code may use other Open Source software components (see LICENSE.txt) using System.Threading.Tasks; using System.Xml; using System.Xml.Schema; +using JetBrains.Annotations; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Schema; +using AasCore.Aas3_0_RC02; +using Environment = System.Environment; -//namespace AdminShellNS -namespace AdminShell_V30 +namespace AdminShellNS { /// /// validates the XML content against the AASX XML schema. @@ -82,6 +84,7 @@ public enum AasValidationSeverity Hint, Warning, SpecViolation, SchemaViolation, Serialization } + [UsedImplicitlyAttribute] // for eventual use public enum AasValidationAction { No, ToBeDeleted @@ -90,12 +93,12 @@ public enum AasValidationAction public class AasValidationRecord { public AasValidationSeverity Severity = AasValidationSeverity.Hint; - public AdminShell.Referable Source = null; + public IReferable Source = null; public string Message = ""; public Action Fix = null; - public AasValidationRecord(AasValidationSeverity Severity, AdminShell.Referable Source, + public AasValidationRecord(AasValidationSeverity Severity, IReferable Source, string Message, Action Fix = null) { this.Severity = Severity; diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/IValue.cs b/src/AasxCsharpLibrary/Display/EnumerationPlacmentBase.cs similarity index 50% rename from src/IO.Swagger.V1RC03/APIModels/ValueOnly/IValue.cs rename to src/AasxCsharpLibrary/Display/EnumerationPlacmentBase.cs index 28f78e68e..5920e6f6d 100644 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/IValue.cs +++ b/src/AasxCsharpLibrary/Display/EnumerationPlacmentBase.cs @@ -1,14 +1,13 @@ using System; using System.Collections.Generic; -using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace IO.Swagger.V1RC03.APIModels.ValueOnly +namespace AdminShellNS.Display { - internal interface IValue + public class EnumerationPlacmentBase { - void ToJsonObject(Stream body); + } } diff --git a/src/AasxCsharpLibrary/Display/EnumerationPlacmentOperationVariable.cs b/src/AasxCsharpLibrary/Display/EnumerationPlacmentOperationVariable.cs new file mode 100644 index 000000000..b6d0e3a0a --- /dev/null +++ b/src/AasxCsharpLibrary/Display/EnumerationPlacmentOperationVariable.cs @@ -0,0 +1,15 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdminShellNS.Display +{ + public class EnumerationPlacmentOperationVariable : EnumerationPlacmentBase + { + public OperationVariableDirection Direction; + public OperationVariable OperationVariable; + } +} diff --git a/src/AasxCsharpLibrary/Display/OperationVariableDirection.cs b/src/AasxCsharpLibrary/Display/OperationVariableDirection.cs new file mode 100644 index 000000000..d64f9c794 --- /dev/null +++ b/src/AasxCsharpLibrary/Display/OperationVariableDirection.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdminShellNS.Display +{ + public enum OperationVariableDirection + { + In, + Out, + InOut + } +} diff --git a/src/AasxCsharpLibrary/Exceptions/MetamodelVerificationException.cs b/src/AasxCsharpLibrary/Exceptions/MetamodelVerificationException.cs new file mode 100644 index 000000000..11e8381c4 --- /dev/null +++ b/src/AasxCsharpLibrary/Exceptions/MetamodelVerificationException.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using static AasCore.Aas3_0_RC02.Reporting; + +namespace AdminShellNS.Exceptions +{ + public class MetamodelVerificationException : Exception + { + public List ErrorList { get; } + + public MetamodelVerificationException(List errorList) : base($"The request body not conformant with the metamodel. Found {errorList.Count} errors !!") + { + ErrorList = errorList; + } + + + } +} diff --git a/src/AasxCsharpLibrary/Exceptions/NullValueException.cs b/src/AasxCsharpLibrary/Exceptions/NullValueException.cs new file mode 100644 index 000000000..7d44af167 --- /dev/null +++ b/src/AasxCsharpLibrary/Exceptions/NullValueException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdminShellNS.Exceptions +{ + public class NullValueException: Exception + { + public NullValueException(string field) : base($"The field {field} is null!!") + { + + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/AasElementSelfDescription.cs b/src/AasxCsharpLibrary/Extensions/AasElementSelfDescription.cs new file mode 100644 index 000000000..8ac8f2ed2 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/AasElementSelfDescription.cs @@ -0,0 +1,29 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public class AasElementSelfDescription + { + public string AasElementName { get; set; } + + public string ElementAbbreviation { get; set; } + + public KeyTypes? KeyType { get; set; } + + public AasSubmodelElements? SmeType { get; set; } + + public AasElementSelfDescription(string aasElementName, string elementAbbreviation, + KeyTypes? keyType, AasSubmodelElements? smeType) + { + AasElementName = aasElementName; + ElementAbbreviation = elementAbbreviation; + KeyType = keyType; + SmeType = smeType; + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ComparerUtils.cs b/src/AasxCsharpLibrary/Extensions/ComparerUtils.cs new file mode 100644 index 000000000..7becf56cb --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ComparerUtils.cs @@ -0,0 +1,57 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public class ComparerIdShort : IComparer + { + public int Compare(IReferable a, IReferable b) + { + return string.Compare(a?.IdShort, b?.IdShort, + CultureInfo.InvariantCulture, CompareOptions.IgnoreCase); + } + } + + public class ComparerIdentification : IComparer + { + public int Compare(IIdentifiable a, IIdentifiable b) + { + return string.Compare(a.Id, b.Id, + CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace); + } + } + + public class ComparerIndexed : IComparer + { + public int NullIndex = int.MaxValue; + public Dictionary Index = new(); + + public int Compare(IReferable a, IReferable b) + { + var ca = Index.ContainsKey(a); + var cb = Index.ContainsKey(b); + + if (!ca && !cb) + return 0; + // make CDs without usage to appear at end of list + if (!ca) + return +1; + if (!cb) + return -1; + + var ia = Index[a]; + var ib = Index[b]; + + if (ia == ib) + return 0; + if (ia < ib) + return -1; + return +1; + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendAnnotatedRelationshipElement.cs b/src/AasxCsharpLibrary/Extensions/ExtendAnnotatedRelationshipElement.cs new file mode 100644 index 000000000..0a9c9f212 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendAnnotatedRelationshipElement.cs @@ -0,0 +1,124 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AasCore.Aas3_0_RC02; +using Extensions; +using AdminShellNS.Display; + +namespace Extensions +{ + public static class ExtendAnnotatedRelationshipElement + { + #region AasxPackageExplorer + + public static void Add(this AnnotatedRelationshipElement annotatedRelationshipElement, ISubmodelElement submodelElement) + { + if (annotatedRelationshipElement != null) + { + annotatedRelationshipElement.Annotations ??= new(); + + submodelElement.Parent = annotatedRelationshipElement; + + annotatedRelationshipElement.Annotations.Add((IDataElement)submodelElement); + } + } + + public static void Remove(this AnnotatedRelationshipElement annotatedRelationshipElement, ISubmodelElement submodelElement) + { + if(annotatedRelationshipElement != null) + { + if(annotatedRelationshipElement.Annotations != null) + { + annotatedRelationshipElement.Annotations.Remove((IDataElement)submodelElement); + } + } + } + + public static object AddChild(this AnnotatedRelationshipElement annotatedRelationshipElement, ISubmodelElement childSubmodelElement, EnumerationPlacmentBase placement = null) + { + if (childSubmodelElement == null || childSubmodelElement is not IDataElement) + return null; + + annotatedRelationshipElement.Annotations ??= new (); + + if (childSubmodelElement != null) + childSubmodelElement.Parent = annotatedRelationshipElement; + + annotatedRelationshipElement.Annotations.Add((IDataElement)childSubmodelElement); + return childSubmodelElement; + } + + #endregion + public static AnnotatedRelationshipElement ConvertAnnotationsFromV20(this AnnotatedRelationshipElement annotatedRelationshipElement, AasxCompatibilityModels.AdminShellV20.AnnotatedRelationshipElement sourceAnnotedRelElement) + { + if (sourceAnnotedRelElement == null) + { + return null; + } + + if (sourceAnnotedRelElement.annotations != null) + { + annotatedRelationshipElement.Annotations ??= new List(); + foreach (var submodelElementWrapper in sourceAnnotedRelElement.annotations) + { + var sourceSubmodelElement = submodelElementWrapper.submodelElement; + ISubmodelElement outputSubmodelElement = null; + if (sourceSubmodelElement != null) + { + outputSubmodelElement = outputSubmodelElement.ConvertFromV20(sourceSubmodelElement); + } + annotatedRelationshipElement.Annotations.Add((IDataElement)outputSubmodelElement); + } + } + + return annotatedRelationshipElement; + } + + public static T FindFirstIdShortAs(this AnnotatedRelationshipElement annotedRelationshipElement, string idShort) where T : ISubmodelElement + { + + var submodelElements = annotedRelationshipElement.Annotations.Where(sme => sme != null && sme is T && sme.IdShort.Equals(idShort, StringComparison.OrdinalIgnoreCase)); + + if (submodelElements.Any()) + { + return (T)submodelElements.First(); + } + + return default; + } + + public static AnnotatedRelationshipElement Set(this AnnotatedRelationshipElement elem, + Reference first, Reference second) + { + elem.First = first; + elem.Second = second; + return elem; + } + + public static AnnotatedRelationshipElement UpdateFrom( + this AnnotatedRelationshipElement elem, ISubmodelElement source) + { + if (source == null) + return elem; + + ((ISubmodelElement)elem).UpdateFrom(source); + + if (source is ReferenceElement srcRef) + { + if (srcRef.Value != null) + elem.First = srcRef.Value.Copy(); + } + + if (source is RelationshipElement srcRel) + { + if (srcRel.First != null) + elem.First = srcRel.First.Copy(); + } + + return elem; + } + + } +} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendAssetAdministrationShell.cs b/src/AasxCsharpLibrary/Extensions/ExtendAssetAdministrationShell.cs similarity index 75% rename from src/AasxServerStandardBib/Extenstions/ExtendAssetAdministrationShell.cs rename to src/AasxCsharpLibrary/Extensions/ExtendAssetAdministrationShell.cs index 7f5cdd173..66ccbb974 100644 --- a/src/AasxServerStandardBib/Extenstions/ExtendAssetAdministrationShell.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendAssetAdministrationShell.cs @@ -1,15 +1,47 @@ using AasCore.Aas3_0_RC02; +using AdminShellNS; using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.CompilerServices; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; -namespace Extenstions +namespace Extensions { public static class ExtendAssetAdministrationShell { + #region AasxPackageExplorer + + public static Tuple ToCaptionInfo(this AssetAdministrationShell assetAdministrationShell) + { + var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", assetAdministrationShell.IdShort, "\"AAS\""); + if (assetAdministrationShell.Administration != null) + caption += "V" + assetAdministrationShell.Administration.Version + "." + assetAdministrationShell.Administration.Revision; + + var info = ""; + if (assetAdministrationShell.Id != null) + info = $"[{assetAdministrationShell.Id}]"; + return Tuple.Create(caption, info); + } + + public static IEnumerable FindAllReferences(this AssetAdministrationShell assetAdministrationShell) + { + // Asset + //TODO:jtikekar support asset + //if (assetAdministrationShell.AssetInformation != null) + // yield return new LocatedReference(assetAdministrationShell, assetAdministrationShell.AssetInformation); + + // Submodel references + if (assetAdministrationShell.Submodels != null) + foreach (var r in assetAdministrationShell.Submodels) + yield return new LocatedReference(assetAdministrationShell, r); + + } + + #endregion + public static bool HasSubmodelReference(this AssetAdministrationShell assetAdministrationShell, Reference submodelReference) { if (submodelReference == null) @@ -110,13 +142,15 @@ public static AssetAdministrationShell ConvertFromV10(this AssetAdministrationSh if (sourceAas.hasDataSpecification != null) { //TODO: jtikekar : EmbeddedDataSpecification?? (as per old implementation) - if (assetAdministrationShell.DataSpecifications == null) + if (assetAdministrationShell.EmbeddedDataSpecifications == null) { - assetAdministrationShell.DataSpecifications = new List(); + assetAdministrationShell.EmbeddedDataSpecifications = new List(); } foreach (var dataSpecification in sourceAas.hasDataSpecification.reference) { - assetAdministrationShell.DataSpecifications.Add(ExtensionsUtil.ConvertReferenceFromV10(dataSpecification, ReferenceTypes.GlobalReference)); + assetAdministrationShell.EmbeddedDataSpecifications.Add(new EmbeddedDataSpecification( + ExtensionsUtil.ConvertReferenceFromV10(dataSpecification, ReferenceTypes.GlobalReference), + null)); } } @@ -181,12 +215,12 @@ public static AssetAdministrationShell ConvertFromV20(this AssetAdministrationSh } } - if (sourceAas.hasDataSpecification != null) + if (sourceAas.hasDataSpecification != null && sourceAas.hasDataSpecification.Count >0) { //TODO: jtikekar : EmbeddedDataSpecification?? (as per old implementation) - if (assetAdministrationShell.DataSpecifications == null) + if (assetAdministrationShell.EmbeddedDataSpecifications == null) { - assetAdministrationShell.DataSpecifications = new List(); + assetAdministrationShell.EmbeddedDataSpecifications = new List(); } //TODO: jtikekar: DataSpecificationContent?? (as per old implementation) @@ -194,7 +228,10 @@ public static AssetAdministrationShell ConvertFromV20(this AssetAdministrationSh { if (sourceDataSpec.dataSpecification != null) { - assetAdministrationShell.DataSpecifications.Add(ExtensionsUtil.ConvertReferenceFromV20(sourceDataSpec.dataSpecification, ReferenceTypes.GlobalReference)); + assetAdministrationShell.EmbeddedDataSpecifications.Add( + new EmbeddedDataSpecification( + ExtensionsUtil.ConvertReferenceFromV20(sourceDataSpec.dataSpecification, ReferenceTypes.GlobalReference), + null)); } } } diff --git a/src/AasxServerStandardBib/Extenstions/ExtendAssetInformation.cs b/src/AasxCsharpLibrary/Extensions/ExtendAssetInformation.cs similarity index 76% rename from src/AasxServerStandardBib/Extenstions/ExtendAssetInformation.cs rename to src/AasxCsharpLibrary/Extensions/ExtendAssetInformation.cs index ef6b778f9..41fb5b0c4 100644 --- a/src/AasxServerStandardBib/Extenstions/ExtendAssetInformation.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendAssetInformation.cs @@ -5,10 +5,22 @@ using System.Text; using System.Threading.Tasks; -namespace Extenstions +namespace Extensions { public static class ExtendAssetInformation { + #region AasxPackageExplorer + + public static Tuple ToCaptionInfo(this AssetInformation assetInformation) + { + //TODO:jtikekar support KeyType.AssetInformation + //var caption = Key.AssetInformation; + var caption = "AssetInformation"; + var info = "" + assetInformation.GlobalAssetId?.ToStringExtended(); + return Tuple.Create(caption, info); + } + + #endregion public static AssetInformation ConvertFromV10(this AssetInformation assetInformation, AasxCompatibilityModels.AdminShellV10.Asset sourceAsset) { //Determine AssetKind diff --git a/src/AasxCsharpLibrary/Extensions/ExtendBlob.cs b/src/AasxCsharpLibrary/Extensions/ExtendBlob.cs new file mode 100644 index 000000000..b49adce56 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendBlob.cs @@ -0,0 +1,69 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendBlob + { + public static void Set(this Blob blob, + string contentType = "", byte[]? value = null) + { + blob.ContentType = contentType; + blob.Value = value; + } + + public static Blob ConvertFromV10(this Blob blob, AasxCompatibilityModels.AdminShellV10.Blob sourceBlob) + { + blob.ContentType = sourceBlob.mimeType; + blob.Value = Encoding.ASCII.GetBytes(sourceBlob.value); + return blob; + } + + public static Blob ConvertFromV20(this Blob blob, AasxCompatibilityModels.AdminShellV20.Blob sourceBlob) + { + blob.ContentType = sourceBlob.mimeType; + blob.Value = Encoding.ASCII.GetBytes(sourceBlob.value); + return blob; + } + + public static Blob UpdateFrom(this Blob elem, ISubmodelElement source) + { + if (source == null) + return elem; + + ((ISubmodelElement)elem).UpdateFrom(source); + + if (source is Property srcProp) + { + if (srcProp.Value != null) + elem.Value = Encoding.Default.GetBytes(srcProp.Value); + } + + if (source is AasCore.Aas3_0_RC02.Range srcRng) + { + if (srcRng.Min != null) + elem.Value = Encoding.Default.GetBytes(srcRng.Min); + } + + if (source is MultiLanguageProperty srcMlp) + { + var s = srcMlp.Value?.GetDefaultString(); + if (s != null) + elem.Value = Encoding.Default.GetBytes(s); + } + + if (source is File srcFile) + { + if (srcFile.Value != null) + elem.Value = Encoding.Default.GetBytes(srcFile.Value); + } + + return elem; + } + + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendConceptDescription.cs b/src/AasxCsharpLibrary/Extensions/ExtendConceptDescription.cs new file mode 100644 index 000000000..96fc0fb79 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendConceptDescription.cs @@ -0,0 +1,299 @@ +using AasCore.Aas3_0_RC02; +using AasxCompatibilityModels; +using AdminShellNS; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection.Metadata; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendConceptDescription + { + #region AasxPackageExplorer + + public static string GetDefaultPreferredName(this ConceptDescription conceptDescription,string defaultLang = null) + { + return "" + + conceptDescription.GetIEC61360()? + .PreferredName?.GetDefaultString(defaultLang); + } + + public static EmbeddedDataSpecification SetIEC61360Spec(this ConceptDescription conceptDescription, + string[] preferredNames = null, + string shortName = "", + string unit = "", + Reference unitId = null, + string valueFormat = null, + string sourceOfDefinition = null, + string symbol = null, + string dataType = "", + string[] definition = null + ) + { + var eds = new EmbeddedDataSpecification( + new Reference(ReferenceTypes.GlobalReference, + new List { ExtendIDataSpecificationContent.GetKeyForIec61360() }), + new DataSpecificationIec61360( + ExtendLangStringSet.CreateManyFromStringArray(preferredNames), + new List { new LangString("EN?", shortName)}, + unit, + unitId, + sourceOfDefinition, + symbol, + Stringification.DataTypeIec61360FromString(dataType), + ExtendLangStringSet.CreateManyFromStringArray(definition) + )); + + conceptDescription.EmbeddedDataSpecifications = new List { eds }; + + // TODO (MIHO, 2022-12-22): Check, but I think it makes no sense + // conceptDescription.IsCaseOf ??= new List(); + // conceptDescription.IsCaseOf.Add(new Reference(ReferenceTypes.ModelReference, new List() { new Key(KeyTypes.ConceptDescription, conceptDescription.Id) })); + + return eds; + } + + /* + + public static DataSpecificationIec61360 CreateDataSpecWithContentIec61360(this ConceptDescription conceptDescription) + { + var eds = EmbeddedDataSpecification.CreateIEC61360WithContent(); + conceptDescription.EmbeddedDataSpecification ??= new HasDataSpecification(); + conceptDescription.EmbeddedDataSpecification.Add(eds); + return eds.DataSpecificationContent?.DataSpecificationIEC61360; + } + + */ + + public static Tuple ToCaptionInfo(this ConceptDescription conceptDescription) + { + var caption = ""; + if (!string.IsNullOrEmpty(conceptDescription.IdShort)) + caption = $"\"{conceptDescription.IdShort.Trim()}\""; + if (conceptDescription.Id != null) + caption = (caption + " " + conceptDescription.Id).Trim(); + + var info = "" + conceptDescription.GetDefaultShortName(); + + return Tuple.Create(caption, info); + } + + public static string GetDefaultShortName(this ConceptDescription conceptDescription, string defaultLang = null) + { + return "" + + conceptDescription.GetIEC61360()? + .ShortName?.GetDefaultString(defaultLang); + } + + public static DataSpecificationIec61360 GetIEC61360(this ConceptDescription conceptDescription) + { + return conceptDescription.EmbeddedDataSpecifications?.GetIEC61360Content(); + } + + public static DataSpecificationPhysicalUnit GetPhysicalUnit(this ConceptDescription conceptDescription) + { + return conceptDescription.EmbeddedDataSpecifications?.GetPhysicalUnitContent(); + } + + public static IEnumerable FindAllReferences(this ConceptDescription conceptDescription) + { + yield break; + } + + #endregion + #region ListOfConceptDescription + public static ConceptDescription AddConceptDescriptionOrReturnExisting(this List conceptDescriptions, ConceptDescription newConceptDescription) + { + if(newConceptDescription == null) + { + return null; + } + if(conceptDescriptions != null) + { + var existingCd = conceptDescriptions.Where(c => c.Id == newConceptDescription.Id).First(); + if(existingCd != null) + { + return existingCd; + } + else + { + conceptDescriptions.Add(newConceptDescription); + } + } + + return newConceptDescription; + } + #endregion + + public static void Validate(this ConceptDescription conceptDescription,AasValidationRecordList results) + { + // access + if (results == null) + return; + + // check CD itself + //Handled by BaseValidation Method + //conceptDescription.Validate(results); + + // check IEC61360 spec + + //TODO:jtikekar Temporarily Removed + //var eds61360 = this.IEC61360DataSpec; + //if (eds61360 != null) + //{ + // // check data spec + // if (eds61360.dataSpecification == null || + // !(eds61360.dataSpecification.MatchesExactlyOneKey(DataSpecificationIEC61360.GetKey()))) + // results.Add(new AasValidationRecord( + // AasValidationSeverity.SpecViolation, this, + // "HasDataSpecification: data specification content set to IEC61360, but no " + + // "data specification reference set!", + // () => + // { + // eds61360.dataSpecification = new DataSpecificationRef( + // new Reference( + // DataSpecificationIEC61360.GetKey())); + // })); + + // // validate content + // if (eds61360.dataSpecificationContent?.dataSpecificationIEC61360 == null) + // { + // results.Add(new AasValidationRecord( + // AasValidationSeverity.SpecViolation, this, + // "HasDataSpecification: data specification reference set to IEC61360, but no " + + // "data specification content set!", + // () => + // { + // eds61360.dataSpecificationContent = new DataSpecificationContent(); + // eds61360.dataSpecificationContent.dataSpecificationIEC61360 = + // new DataSpecificationIEC61360(); + // })); + // } + // else + // { + // // validate + // eds61360.dataSpecificationContent.dataSpecificationIEC61360.Validate(results, this); + // } + } + + public static Key GetSingleKey(this ConceptDescription conceptDescription) + { + return new Key(KeyTypes.ConceptDescription, conceptDescription.Id); + } + public static ConceptDescription ConvertFromV10(this ConceptDescription conceptDescription, AasxCompatibilityModels.AdminShellV10.ConceptDescription sourceConceptDescription) + { + if (sourceConceptDescription == null) + { + return null; + } + + if (string.IsNullOrEmpty(sourceConceptDescription.idShort)) + { + conceptDescription.IdShort = ""; + } + else + { + conceptDescription.IdShort = sourceConceptDescription.idShort; + } + + if (sourceConceptDescription.description != null) + { + conceptDescription.Description = ExtensionsUtil.ConvertDescriptionFromV10(sourceConceptDescription.description); + } + + if (sourceConceptDescription.administration != null) + { + conceptDescription.Administration = new AdministrativeInformation(version: sourceConceptDescription.administration.version, revision: sourceConceptDescription.administration.revision); + } + + if (sourceConceptDescription.IsCaseOf != null && sourceConceptDescription.IsCaseOf.Count != 0) + { + if (conceptDescription.IsCaseOf == null) + { + conceptDescription.IsCaseOf = new List(); + } + foreach (var caseOf in sourceConceptDescription.IsCaseOf) + { + conceptDescription.IsCaseOf.Add(ExtensionsUtil.ConvertReferenceFromV10(caseOf, ReferenceTypes.ModelReference)); + } + } + + return conceptDescription; + } + + public static ConceptDescription ConvertFromV20(this ConceptDescription cd, AasxCompatibilityModels.AdminShellV20.ConceptDescription srcCD) + { + if (srcCD == null) + return null; + + if (string.IsNullOrEmpty(srcCD.idShort)) + cd.IdShort = ""; + else + cd.IdShort = srcCD.idShort; + + if (srcCD.identification?.id != null) + cd.Id = srcCD.identification.id; + + if (srcCD.description != null && srcCD.description.langString.Count >=1) + cd.Description = ExtensionsUtil.ConvertDescriptionFromV20(srcCD.description); + + if (srcCD.administration != null) + cd.Administration = new AdministrativeInformation( + version: srcCD.administration.version, revision: srcCD.administration.revision); + + if (srcCD.IsCaseOf != null && srcCD.IsCaseOf.Count != 0) + { + if (cd.IsCaseOf == null) + { + cd.IsCaseOf = new List(); + } + foreach (var caseOf in srcCD.IsCaseOf) + { + cd.IsCaseOf.Add(ExtensionsUtil.ConvertReferenceFromV20(caseOf, ReferenceTypes.ModelReference)); + } + } + + //jtikekar:as per old implementation + if(srcCD.embeddedDataSpecification != null) + { + foreach (var sourceEds in srcCD.embeddedDataSpecification) + { + var eds = new EmbeddedDataSpecification(null, null); + eds.ConvertFromV20(sourceEds); + cd.AddEmbeddedDataSpecification(eds); + } + } + + return cd; + } + + public static EmbeddedDataSpecification AddEmbeddedDataSpecification(this ConceptDescription cd, EmbeddedDataSpecification eds) + { + if (cd == null) + return null; + if (cd.EmbeddedDataSpecifications == null) + cd.EmbeddedDataSpecifications = new List(); + if (eds == null) + return null; + cd.EmbeddedDataSpecifications.Add(eds); + return eds; + } + + public static Reference GetCdReference(this ConceptDescription conceptDescription) + { + var key = new Key(KeyTypes.ConceptDescription, conceptDescription.Id); + return new Reference(ReferenceTypes.ModelReference, new List { key }); + } + + public static void AddIsCaseOf(this ConceptDescription cd, + Reference ico) + { + if (cd.IsCaseOf == null) + cd.IsCaseOf = new List(); + cd.IsCaseOf.Add(ico); + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendDataElement.cs b/src/AasxCsharpLibrary/Extensions/ExtendDataElement.cs new file mode 100644 index 000000000..299e3b350 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendDataElement.cs @@ -0,0 +1,19 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendDataElement + { + public static DataTypeDefXsd[] ValueTypes_Number = + new[] { DataTypeDefXsd.Decimal, DataTypeDefXsd.Double, DataTypeDefXsd.Float, + DataTypeDefXsd.Integer, DataTypeDefXsd.Long, DataTypeDefXsd.Int, DataTypeDefXsd.Short, + DataTypeDefXsd.Byte, DataTypeDefXsd.NonNegativeInteger, DataTypeDefXsd.NonPositiveInteger, + DataTypeDefXsd.UnsignedInt, DataTypeDefXsd.Integer, DataTypeDefXsd.UnsignedByte, + DataTypeDefXsd.UnsignedLong, DataTypeDefXsd.UnsignedShort, DataTypeDefXsd.NegativeInteger }; + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendDataSpecificationIEC61360.cs b/src/AasxCsharpLibrary/Extensions/ExtendDataSpecificationIEC61360.cs new file mode 100644 index 000000000..63a2db0e0 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendDataSpecificationIEC61360.cs @@ -0,0 +1,47 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendDataSpecificationIEC61360 + { + public static DataSpecificationIec61360 ConvertFromV20(this DataSpecificationIec61360 ds61360, AasxCompatibilityModels.AdminShellV20.DataSpecificationIEC61360 src616360) + { + if (src616360.preferredName != null) + ds61360.PreferredName = new List().ConvertFromV20(src616360.preferredName); + + if (src616360.shortName != null) + ds61360.ShortName = new List().ConvertFromV20(src616360.shortName); + + if (!string.IsNullOrEmpty(src616360.unit)) + { + ds61360.Unit = src616360.unit; + } + + if (src616360.unitId != null) + ds61360.UnitId = ExtensionsUtil.ConvertReferenceFromV20(AasxCompatibilityModels.AdminShellV20.Reference.CreateNew(src616360.unitId.keys), ReferenceTypes.GlobalReference); + + ds61360.ValueFormat = src616360.valueFormat; + ds61360.SourceOfDefinition = src616360.sourceOfDefinition; + ds61360.Symbol = src616360.symbol; + if (!(string.IsNullOrEmpty(src616360.dataType))) + { + var dt = src616360.dataType; + if (!dt.StartsWith("xs:")) + dt = "xs:" + dt; + ds61360.DataType = Stringification.DataTypeIec61360FromString(dt); + } + if (src616360.definition != null) + ds61360.Definition = new List().ConvertFromV20(src616360.definition); + + //TODO:jtikekar check with Andreas + ds61360.Value = ""; + + return ds61360; + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendEmbeddedDataSpecification.cs b/src/AasxCsharpLibrary/Extensions/ExtendEmbeddedDataSpecification.cs new file mode 100644 index 000000000..e89dd5ad5 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendEmbeddedDataSpecification.cs @@ -0,0 +1,108 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +// using DataSpecificationContent = HasDataSpecification.DataSpecificationContent; + +namespace Extensions +{ + // TODO (Jui, 2022-12-21): I do not know, if to put the List<> extension here or in a separate file + public static class ExtendListOfEmbeddedDataSpecification + { + + + public static EmbeddedDataSpecification FindFirstIEC61360Spec(this List list) + { + foreach (var eds in list) + if (eds?.DataSpecificationContent is DataSpecificationIec61360 + || eds?.DataSpecification?.MatchesExactlyOneKey( + ExtendIDataSpecificationContent.GetKeyForIec61360()) == true) + return eds; + return null; + } + + public static DataSpecificationIec61360 GetIEC61360Content(this List list) + { + foreach (var eds in list) + if (eds?.DataSpecificationContent is DataSpecificationIec61360 dsiec) + return dsiec; + return null; + } + + public static DataSpecificationPhysicalUnit GetPhysicalUnitContent(this List list) + { + foreach (var eds in list) + if (eds?.DataSpecificationContent is DataSpecificationPhysicalUnit dspu) + return dspu; + return null; + } + } + + public static class ExtendEmbeddedDataSpecification + { + public static EmbeddedDataSpecification ConvertFromV20(this EmbeddedDataSpecification embeddedDataSpecification, AasxCompatibilityModels.AdminShellV20.EmbeddedDataSpecification sourceEmbeddedSpec) + { + if(sourceEmbeddedSpec != null) + { + embeddedDataSpecification.DataSpecification = ExtensionsUtil.ConvertReferenceFromV20(sourceEmbeddedSpec.dataSpecification, ReferenceTypes.GlobalReference); + + // TODO (MIHO, 2022-19-12): check again, see questions + var o2id = "http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360"; + var oldid = "http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/2/0"; + var newid = "http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0"; + + if (sourceEmbeddedSpec.dataSpecification?.Matches("", false, "IRI", oldid, + AasxCompatibilityModels.AdminShellV20.Key.MatchMode.Identification) == true) + { + embeddedDataSpecification.DataSpecification.Keys[0].Value = newid; + } + + if (sourceEmbeddedSpec.dataSpecification?.Matches("", false, "IRI", o2id, + AasxCompatibilityModels.AdminShellV20.Key.MatchMode.Identification) == true) + { + embeddedDataSpecification.DataSpecification.Keys[0].Value = newid; + } + } + + if(sourceEmbeddedSpec.dataSpecificationContent?.dataSpecificationIEC61360 != null) + { + embeddedDataSpecification.DataSpecificationContent = + new DataSpecificationIec61360(null).ConvertFromV20( + sourceEmbeddedSpec.dataSpecificationContent.dataSpecificationIEC61360); + } + return embeddedDataSpecification; + } + + public static EmbeddedDataSpecification CreateIec61360WithContent(DataSpecificationIec61360 content = null) + { + if (content == null) + content = new DataSpecificationIec61360(null); + + var res = new EmbeddedDataSpecification( + new Reference(ReferenceTypes.GlobalReference, + new List( new[] { ExtendIDataSpecificationContent.GetKeyForIec61360() })), + content); + return res; + } + + public static bool FixReferenceWrtContent(this EmbeddedDataSpecification eds) + { + // does content tell something? + var ctc = ExtendIDataSpecificationContent.GuessContentTypeFor(eds?.DataSpecificationContent); + var ctr = ExtendIDataSpecificationContent.GuessContentTypeFor(eds?.DataSpecification); + + if (ctc == ExtendIDataSpecificationContent.ContentTypes.NoInfo) + return false; + + if (ctr == ctc) + return false; + + // ok, fix + eds.DataSpecification = new Reference(ReferenceTypes.GlobalReference, + new List { ExtendIDataSpecificationContent.GetKeyFor(ctc) }); + return true; + } + } +} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendEntity.cs b/src/AasxCsharpLibrary/Extensions/ExtendEntity.cs similarity index 51% rename from src/AasxServerStandardBib/Extenstions/ExtendEntity.cs rename to src/AasxCsharpLibrary/Extensions/ExtendEntity.cs index 968f10ab7..4b520e1cf 100644 --- a/src/AasxServerStandardBib/Extenstions/ExtendEntity.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendEntity.cs @@ -1,14 +1,53 @@ using AasCore.Aas3_0_RC02; +using AdminShellNS.Display; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Extenstions +namespace Extensions { public static class ExtendEntity { + #region AasxPackageExplorer + + public static void Add(this Entity entity, ISubmodelElement submodelElement) + { + if (entity != null) + { + entity.Statements ??= new(); + + submodelElement.Parent = entity; + + entity.Statements.Add(submodelElement); + } + } + + public static void Remove(this Entity entity, ISubmodelElement submodelElement) + { + if(entity != null) + { + if(entity.Statements != null) + { + entity.Statements.Remove(submodelElement); + } + } + } + + public static object AddChild(this Entity entity, ISubmodelElement childSubmodelElement, EnumerationPlacmentBase placement = null) + { + if (childSubmodelElement == null) + return null; + if (entity.Statements == null) + entity.Statements = new (); + if (childSubmodelElement != null) + childSubmodelElement.Parent = entity; + entity.Statements.Add(childSubmodelElement); + return childSubmodelElement; + } + + #endregion public static Entity ConvertFromV20(this Entity entity, AasxCompatibilityModels.AdminShellV20.Entity sourceEntity) { if (sourceEntity == null) @@ -53,5 +92,17 @@ public static T FindFirstIdShortAs(this Entity entity, string idShort) where return default; } + + public static T CreateSMEForCD( + this Entity ent, + ConceptDescription conceptDescription, string category = null, string idShort = null, + string idxTemplate = null, int maxNum = 999, bool addSme = false, bool isTemplate = false) + where T : ISubmodelElement + { + if (ent.Statements == null) + ent.Statements = new List(); + return ent.Statements.CreateSMEForCD( + conceptDescription, category, idShort, idxTemplate, maxNum, addSme, isTemplate); + } } } diff --git a/src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs b/src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs new file mode 100644 index 000000000..3558ef96a --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs @@ -0,0 +1,1051 @@ +using AasCore.Aas3_0_RC02; +using Extensions; +using AdminShellNS; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.CompilerServices; + +namespace Extensions +{ + public static class ExtendEnvironment + { + #region Environment + + #region AasxPackageExplorer + + public static void RecurseOnReferables(this AasCore.Aas3_0_RC02.Environment environment, + object state, Func, IReferable, bool> lambda, bool includeThis = false) + { + // includeThis does not make sense, as no Referable + // just use the others + foreach (var idf in environment.FindAllReferable(onlyIdentifiables: true)) + idf?.RecurseOnReferables(state, lambda, includeThis); + } + + #endregion + + public static AasValidationRecordList ValidateAll(this AasCore.Aas3_0_RC02.Environment environment) + { + // collect results + var results = new AasValidationRecordList(); + + // all entities + foreach (var rf in environment.FindAllReferable()) + rf.Validate(results); + + // give back + return results; + } + + public static int AutoFix(this AasCore.Aas3_0_RC02.Environment environment, IEnumerable records) + { + // access + if (records == null) + return -1; + + // collect Referables (expensive safety measure) + var allowedReferables = environment.FindAllReferable().ToList(); + + // go thru records + int res = 0; + foreach (var rec in records) + { + // access + if (rec == null || rec.Fix == null || rec.Source == null) + continue; + + // minimal safety measure + if (!allowedReferables.Contains(rec.Source)) + continue; + + // apply fix + res++; + try + { + rec.Fix.Invoke(); + } + catch + { + res--; + } + } + + // return number of applied fixes + return res; + } + + public static IEnumerable FindAllReferable(this AasCore.Aas3_0_RC02.Environment environment, bool onlyIdentifiables = false) + { + if (environment.AssetAdministrationShells != null) + foreach (var aas in environment.AssetAdministrationShells) + if (aas != null) + { + // AAS itself + yield return aas; + } + + if (environment.Submodels != null) + foreach (var sm in environment.Submodels) + if (sm != null) + { + yield return sm; + + if (!onlyIdentifiables) + { + // TODO (MIHO, 2020-08-26): not very elegant, yet. Avoid temporary collection + var allsme = new List(); + sm.RecurseOnSubmodelElements(null, (state, parents, sme) => + { + allsme.Add(sme); return true; + }); + foreach (var sme in allsme) + yield return sme; + } + } + + if (environment.ConceptDescriptions != null) + foreach (var cd in environment.ConceptDescriptions) + if (cd != null) + yield return cd; + } + +#if !DoNotUseAasxCompatibilityModels + + public static AasCore.Aas3_0_RC02.Environment ConvertFromV10(this AasCore.Aas3_0_RC02.Environment environment, AasxCompatibilityModels.AdminShellV10.AdministrationShellEnv sourceEnvironement) + { + //Convert Administration Shells + if (sourceEnvironement.AdministrationShells != null) + { + if (environment.AssetAdministrationShells == null) + { + environment.AssetAdministrationShells = new List(); + } + foreach (var sourceAas in sourceEnvironement.AdministrationShells) + { + var sourceAsset = sourceEnvironement?.FindAsset(sourceAas.assetRef); + if (sourceAsset != null) + { + var newAssetInformation = new AssetInformation(AssetKind.Instance); + newAssetInformation = newAssetInformation.ConvertFromV10(sourceAsset); + + var newAas = new AssetAdministrationShell(id: sourceAas.identification.id, newAssetInformation); + newAas = newAas.ConvertFromV10(sourceAas); + + environment.AssetAdministrationShells.Add(newAas); + } + + } + } + + //Convert Submodels + if (sourceEnvironement.Submodels != null) + { + if (environment.Submodels == null) + { + environment.Submodels = new List(); + } + foreach (var sourceSubmodel in sourceEnvironement.Submodels) + { + var newSubmodel = new Submodel(sourceSubmodel.identification.id); + newSubmodel = newSubmodel.ConvertFromV10(sourceSubmodel); + environment.Submodels.Add(newSubmodel); + } + } + + if (sourceEnvironement.ConceptDescriptions != null) + { + if (environment.ConceptDescriptions == null) + { + environment.ConceptDescriptions = new List(); + } + foreach (var sourceConceptDescription in sourceEnvironement.ConceptDescriptions) + { + var newConceptDescription = new ConceptDescription(sourceConceptDescription.identification.id); + newConceptDescription = newConceptDescription.ConvertFromV10(sourceConceptDescription); + environment.ConceptDescriptions.Add(newConceptDescription); + } + } + + return environment; + } + + + public static AasCore.Aas3_0_RC02.Environment ConvertFromV20(this AasCore.Aas3_0_RC02.Environment environment, AasxCompatibilityModels.AdminShellV20.AdministrationShellEnv sourceEnvironement) + { + //Convert Administration Shells + if (sourceEnvironement.AdministrationShells != null) + { + if (environment.AssetAdministrationShells == null) + { + environment.AssetAdministrationShells = new List(); + } + foreach (var sourceAas in sourceEnvironement.AdministrationShells) + { + // first make the AAS + var newAas = new AssetAdministrationShell(id: sourceAas.identification.id, null); + newAas = newAas.ConvertFromV20(sourceAas); + environment.AssetAdministrationShells.Add(newAas); + + var sourceAsset = sourceEnvironement?.FindAsset(sourceAas.assetRef); + if (sourceAsset != null) + { + var newAssetInformation = new AssetInformation(AssetKind.Instance); + newAssetInformation = newAssetInformation.ConvertFromV20(sourceAsset); + newAas.AssetInformation = newAssetInformation; + } + + } + } + + //Convert Submodels + if (sourceEnvironement.Submodels != null) + { + if (environment.Submodels == null) + { + environment.Submodels = new List(); + } + foreach (var sourceSubmodel in sourceEnvironement.Submodels) + { + var newSubmodel = new Submodel(sourceSubmodel.identification.id); + newSubmodel = newSubmodel.ConvertFromV20(sourceSubmodel); + environment.Submodels.Add(newSubmodel); + } + } + + if (sourceEnvironement.ConceptDescriptions != null) + { + if (environment.ConceptDescriptions == null) + { + environment.ConceptDescriptions = new List(); + } + foreach (var sourceConceptDescription in sourceEnvironement.ConceptDescriptions) + { + var newConceptDescription = new ConceptDescription(sourceConceptDescription.identification.id); + newConceptDescription = newConceptDescription.ConvertFromV20(sourceConceptDescription); + environment.ConceptDescriptions.Add(newConceptDescription); + } + } + + return environment; + } + +#endif + + //TODO:jtikekar to test + public static AasCore.Aas3_0_RC02.Environment CreateFromExistingEnvironment(this AasCore.Aas3_0_RC02.Environment environment, AasCore.Aas3_0_RC02.Environment sourceEnvironment, List filterForAas = null, List filterForAssets = null, List filterForSubmodel = null, List filterForConceptDescriptions = null) + { + if (filterForAas == null) + { + filterForAas = new List(); + } + + if (filterForAssets == null) + { + filterForAssets = new List(); + } + + if (filterForSubmodel == null) + { + filterForSubmodel = new List(); + } + + if (filterForConceptDescriptions == null) + { + filterForConceptDescriptions = new List(); + } + + //var outputEnvironment = new AasCore.Aas3_0_RC02.Environment(); + + //Copy AssetAdministrationShells + foreach (var aas in sourceEnvironment.AssetAdministrationShells) + { + if (filterForAas.Contains(aas)) + { + environment.AssetAdministrationShells.Add(aas); + + if (aas.Submodels != null && aas.Submodels.Count > 0) + { + foreach (var submodelReference in aas.Submodels) + { + var submodel = sourceEnvironment.FindSubmodel(submodelReference); + if (submodel != null) + { + filterForSubmodel.Add(submodel); + } + } + } + } + } + + //Copy Submodel + foreach (var submodel in sourceEnvironment.Submodels) + { + if (filterForSubmodel.Contains(submodel)) + { + environment.Submodels.Add(submodel); + + //Find Used CDs + environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, submodel.SubmodelElements, ref filterForConceptDescriptions); + } + } + + //Copy ConceptDescription + foreach (var conceptDescription in sourceEnvironment.ConceptDescriptions) + { + if (filterForConceptDescriptions.Contains(conceptDescription)) + { + environment.ConceptDescriptions.Add(conceptDescription); + } + } + + return environment; + + } + + public static void CreateFromExistingEnvRecurseForCDs(this AasCore.Aas3_0_RC02.Environment environment, AasCore.Aas3_0_RC02.Environment sourceEnvironment, List submodelElements, ref List filterForConceptDescription) + { + if (submodelElements == null || submodelElements.Count == 0 || filterForConceptDescription == null || filterForConceptDescription.Count == 0) + { + return; + } + + foreach (var submodelElement in submodelElements) + { + if (submodelElement == null) + { + return; + } + + if (submodelElement.SemanticId != null) + { + var conceptDescription = sourceEnvironment.FindConceptDescriptionByReference(submodelElement.SemanticId); + if (conceptDescription != null) + { + filterForConceptDescription.Add(conceptDescription); + } + } + + if (submodelElement is SubmodelElementCollection smeColl) + { + environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, smeColl.Value, ref filterForConceptDescription); + } + + if (submodelElement is SubmodelElementList smeList) + { + environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, smeList.Value, ref filterForConceptDescription); + } + + if (submodelElement is Entity entity) + { + environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, entity.Statements, ref filterForConceptDescription); + } + + if (submodelElement is AnnotatedRelationshipElement annotatedRelationshipElement) + { + var annotedELements = new List(); + foreach (var annotation in annotatedRelationshipElement.Annotations) + { + annotedELements.Add(annotation); + } + environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, annotedELements, ref filterForConceptDescription); + } + + if (submodelElement is Operation operation) + { + var operationELements = new List(); + foreach (var inputVariable in operation.InputVariables) + { + operationELements.Add(inputVariable.Value); + } + + foreach (var outputVariable in operation.OutputVariables) + { + operationELements.Add(outputVariable.Value); + } + + foreach (var inOutVariable in operation.InoutputVariables) + { + operationELements.Add(inOutVariable.Value); + } + + environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, operationELements, ref filterForConceptDescription); + + } + } + } + + public static ConceptDescription Add(this AasCore.Aas3_0_RC02.Environment env, ConceptDescription cd) + { + if (cd == null) + return null; + if (env.ConceptDescriptions == null) + env.ConceptDescriptions = new(); + env.ConceptDescriptions.Add(cd); + return cd; + } + + public static Submodel Add(this AasCore.Aas3_0_RC02.Environment env, Submodel sm) + { + if (sm == null) + return null; + if (env.Submodels == null) + env.Submodels = new(); + env.Submodels.Add(sm); + return sm; + } + + public static AssetAdministrationShell Add(this AasCore.Aas3_0_RC02.Environment env, AssetAdministrationShell aas) + { + if (aas == null) + return null; + if (env.AssetAdministrationShells == null) + env.AssetAdministrationShells = new(); + env.AssetAdministrationShells.Add(aas); + return aas; + } + + public static JsonWriter SerialiazeJsonToStream(this AasCore.Aas3_0_RC02.Environment environment, StreamWriter streamWriter, bool leaveJsonWriterOpen = false) + { + streamWriter.AutoFlush = true; + + JsonSerializer serializer = new JsonSerializer() + { + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + Formatting = Newtonsoft.Json.Formatting.Indented + }; + + JsonWriter writer = new JsonTextWriter(streamWriter); + serializer.Serialize(writer, environment); + if (leaveJsonWriterOpen) + return writer; + writer.Close(); + return null; + } + + #endregion + + #region Submodel Queries + + public static IEnumerable FindAllSubmodelGroupedByAAS(this AasCore.Aas3_0_RC02.Environment environment, Func p = null) + { + if (environment.AssetAdministrationShells == null || environment.Submodels == null) + yield break; + foreach (var aas in environment.AssetAdministrationShells) + { + if (aas?.Submodels == null) + continue; + foreach (var smref in aas.Submodels) + { + var sm = environment.FindSubmodel(smref); + if (sm != null && (p == null || p(aas, sm))) + yield return sm; + } + } + } + public static Submodel FindSubmodel(this AasCore.Aas3_0_RC02.Environment environment, Reference submodelReference) + { + if (submodelReference == null) + { + return null; + } + + if (submodelReference.Keys.Count != 1) // Can have only one reference key + { + return null; + } + + var key = submodelReference.Keys[0]; + if (key.Type != KeyTypes.Submodel) + { + return null; + } + + var submodels = environment.Submodels.Where(s => s.Id.Equals(key.Value, StringComparison.OrdinalIgnoreCase)); + if (submodels.Any()) + { + return submodels.First(); + } + + return null; + } + + public static Submodel FindSubmodelById(this AasCore.Aas3_0_RC02.Environment environment, string submodelId) + { + if (string.IsNullOrEmpty(submodelId)) + { + return null; + } + + var submodels = environment.Submodels.Where(s => s.Id.Equals(submodelId)); + if (submodels.Any()) + { + return submodels.First(); + } + + return null; + } + + public static IEnumerable FindAllSubmodelsGroupedByAAS(this AasCore.Aas3_0_RC02.Environment environment, Func p = null) + { + if (environment.AssetAdministrationShells == null || environment.Submodels == null) + yield break; + foreach (var aas in environment.AssetAdministrationShells) + { + if (aas?.Submodels == null) + continue; + foreach (var submodelReference in aas.Submodels) + { + var submodel = environment.FindSubmodel(submodelReference); + if (submodel != null && (p == null || p(aas, submodel))) + yield return submodel; + } + } + } + + public static IEnumerable FindAllSubmodelBySemanticId(this AasCore.Aas3_0_RC02.Environment environment, string semanticId) + { + if (semanticId == null) + yield break; + + foreach (var submodel in environment.Submodels) + if (true == submodel.SemanticId?.Matches(semanticId)) + yield return submodel; + } + + #endregion + + #region AssetAdministrationShell Queries + public static AssetAdministrationShell FindAasWithSubmodelId(this AasCore.Aas3_0_RC02.Environment environment, string submodelId) + { + if (submodelId == null) + { + return null; + } + + var aas = environment.AssetAdministrationShells.Where(a => (a.Submodels?.Where(s => s.Matches(submodelId)).First()) != null).First(); + + return aas; + } + + public static AssetAdministrationShell FindAasById(this AasCore.Aas3_0_RC02.Environment environment, string aasId) + { + if (string.IsNullOrEmpty(aasId)) + { + return null; + } + + var aas = environment.AssetAdministrationShells.Where(a => a.Id.Equals(aasId)).First(); + + return aas; + } + + #endregion + + #region ConceptDescription Queries + + public static ConceptDescription FindConceptDescriptionById( + this AasCore.Aas3_0_RC02.Environment env, string cdId) + { + if (string.IsNullOrEmpty(cdId)) + return null; + + var conceptDescription = env.ConceptDescriptions.Where(c => c.Id.Equals(cdId)).FirstOrDefault(); + return conceptDescription; + } + + public static ConceptDescription FindConceptDescriptionByReference( + this AasCore.Aas3_0_RC02.Environment env, Reference rf) + { + if (rf == null) + return null; + + return env.FindConceptDescriptionById(rf.GetAsIdentifier()); + } + + #endregion + + #region Referable Queries + + /// + /// Result of FindReferable in Environment + /// + public class ReferableRootInfo + { + public AssetAdministrationShell AAS = null; + public AssetInformation Asset = null; + public Submodel Submodel = null; + public ConceptDescription CD = null; + + public int NrOfRootKeys = 0; + + public bool IsValid + { + get + { + return NrOfRootKeys > 0 && (AAS != null || Submodel != null || Asset != null); + } + } + } + + //TODO: jtikekar Need to test + public static IReferable FindReferableByReference( + this AasCore.Aas3_0_RC02.Environment environment, + Reference reference, + int keyIndex = 0, + List submodelElementList = null, + ReferableRootInfo rootInfo = null) + { + // access + var keyList = reference?.Keys; + if (keyList == null || keyList.Count == 0 || keyIndex >= keyList.Count) + return null; + + // shortcuts + var firstKeyType = keyList[keyIndex].Type; + var firstKeyId = keyList[keyIndex].Value; + + // different pathes + switch (firstKeyType) + { + case KeyTypes.AssetAdministrationShell: + { + var aas = environment.FindAasById(firstKeyId); + + // side info? + if (rootInfo != null) + { + rootInfo.AAS = aas; + rootInfo.NrOfRootKeys = 1 + keyIndex; + } + + //Not found or already at the end of our search + if (aas == null || keyIndex >= keyList.Count - 1) + { + return aas; + } + + return environment.FindReferableByReference(reference, ++keyIndex); + } + + // TODO (MIHO, 2023-01-01): stupid generalization :-( + case KeyTypes.GlobalReference: + case KeyTypes.ConceptDescription: + { + // In meta model V3, multiple important things might by identified + // by a flat GlobalReference :-( + + // find an Asset by that id? + var keyedAas = environment.FindAasWithAssetInformation(firstKeyId); + if (keyedAas?.AssetInformation != null) + { + // found an Asset + + // side info? + if (rootInfo != null) + { + rootInfo.AAS = keyedAas; + rootInfo.Asset = keyedAas?.AssetInformation; + rootInfo.NrOfRootKeys = 1 + keyIndex; + } + + // give back the AAS + return keyedAas; + } + + // Concept?Description + var keyedCd = environment.FindConceptDescriptionById(firstKeyId); + if (keyedCd != null) + { + // side info? + if (rootInfo != null) + { + rootInfo.CD = keyedCd; + rootInfo.NrOfRootKeys = 1 + keyIndex; + } + + // give back the CD + return keyedCd; + } + + // Nope + return null; + } + + case KeyTypes.Submodel: + { + var submodel = environment.FindSubmodelById(firstKeyId); + // No? + if (submodel == null) + return null; + + // notice in side info + if (rootInfo != null) + { + rootInfo.Submodel = submodel; + rootInfo.NrOfRootKeys = 1 + keyIndex; + + // add even more info + if (rootInfo.AAS == null) + { + foreach (var aas2 in environment.AssetAdministrationShells) + { + var smref2 = environment.FindSubmodelById(submodel.Id); + if (smref2 != null) + { + rootInfo.AAS = aas2; + break; + } + } + } + } + + // at the end of the journey? + if (keyIndex >= keyList.Count - 1) + return submodel; + + return environment.FindReferableByReference(reference, ++keyIndex, submodel.SubmodelElements); + } + } + + if (firstKeyType.IsSME() && submodelElementList != null) + { + var submodelElement = submodelElementList.Where( + sme => sme.IdShort.Equals(keyList[keyIndex].Value, + StringComparison.OrdinalIgnoreCase)).First(); + + //This is required element + if (keyIndex + 1 >= keyList.Count) + { + return submodelElement; + } + + //Recurse again + if (submodelElement != null && submodelElement is SubmodelElementCollection smeColl) + { + return environment.FindReferableByReference(reference, ++keyIndex, smeColl.Value); + } + + if (submodelElement != null && submodelElement is SubmodelElementList smeList) + { + return environment.FindReferableByReference(reference, ++keyIndex, smeList.Value); + } + } + + //Nothing in this environment + return null; + } + + #endregion + + #region AasxPackageExplorer + + public static IEnumerable FindAllSubmodelElements(this AasCore.Aas3_0_RC02.Environment environment, + Predicate match = null, AssetAdministrationShell onlyForAAS = null) where T : ISubmodelElement + { + // more or less two different schemes + if (onlyForAAS != null) + { + if (onlyForAAS.Submodels == null) + yield break; + foreach (var smr in onlyForAAS.Submodels) + { + var sm = environment.FindSubmodel(smr); + if (sm?.SubmodelElements != null) + foreach (var x in sm.SubmodelElements.FindDeep(match)) + yield return x; + } + } + else + { + if (environment.Submodels != null) + foreach (var sm in environment.Submodels) + if (sm?.SubmodelElements != null) + foreach (var x in sm.SubmodelElements.FindDeep(match)) + yield return x; + } + } + + public static IEnumerable FindAllReferences(this AasCore.Aas3_0_RC02.Environment environment) + { + if (environment.AssetAdministrationShells != null) + foreach (var aas in environment.AssetAdministrationShells) + if (aas != null) + foreach (var r in aas.FindAllReferences()) + yield return r; + + //if (this.Assets != null) + // foreach (var asset in this.Assets) + // if (asset != null) + // foreach (var r in asset.FindAllReferences()) + // yield return new LocatedReference(asset, r); + + if (environment.Submodels != null) + foreach (var sm in environment.Submodels) + if (sm != null) + foreach (var r in sm.FindAllReferences()) + yield return r; + + if (environment.ConceptDescriptions != null) + foreach (var cd in environment.ConceptDescriptions) + if (cd != null) + foreach (var r in cd.FindAllReferences()) + yield return new LocatedReference(cd, r); + } + + /// + /// Tries renaming an Identifiable, specifically: the identification of an Identifiable and + /// all references to it. + /// Currently supported: ConceptDescriptions + /// Returns a list of Referables, which were changed or null in case of error + /// + public static List RenameIdentifiable(this AasCore.Aas3_0_RC02.Environment environment, string oldId, string newId) + where T : IClass + { + // access + if (oldId == null || newId == null || oldId.Equals(newId)) + return null; + + var res = new List(); + + if (typeof(T) == typeof(ConceptDescription)) + { + // check, if exist or not exist + var cdOld = environment.FindConceptDescriptionById(oldId); + if (cdOld == null || environment.FindConceptDescriptionById(newId) != null) + return null; + + // rename old cd + cdOld.Id = newId; + res.Add(cdOld); + + // search all SMEs referring to this CD + foreach (var sme in environment.FindAllSubmodelElements(match: (s) => + { + return (s != null && s.SemanticId != null && s.SemanticId.Matches(oldId)); + })) + { + sme.SemanticId.Keys[0].Value = newId; + res.Add(sme); + } + + // seems fine + return res; + } + else + if (typeof(T) == typeof(Submodel)) + { + // check, if exist or not exist + var smOld = environment.FindSubmodelById(oldId); + if (smOld == null || environment.FindSubmodelById(newId) != null) + return null; + + // recurse all possible Referenes in the aas env + foreach (var lr in environment.FindAllReferences()) + { + var r = lr?.Reference; + if (r != null) + for (int i = 0; i < r.Keys.Count; i++) + if (r.Keys[i].Matches(KeyTypes.Submodel, oldId, MatchMode.Relaxed)) + { + // directly replace + r.Keys[i].Value = newId; + if (res.Contains(lr.Identifiable)) + res.Add(lr.Identifiable); + } + } + + // rename old Submodel + smOld.Id = newId; + + // seems fine + return res; + } + else + if (typeof(T) == typeof(AssetAdministrationShell)) + { + // check, if exist or not exist + var aasOld = environment.FindAasById(oldId); + if (aasOld == null || environment.FindAasById(newId) != null) + return null; + + // recurse? -> no? + + // rename old Asset + aasOld.Id = newId; + + // seems fine + return res; + } + else + //TODO:jtikekar support asset + if (typeof(T) == typeof(AssetInformation)) + { + // check, if exist or not exist + var assetOld = environment.FindAasWithAssetInformation(oldId); + if (assetOld == null || environment.FindAasWithAssetInformation(newId) != null) + return null; + + // recurse all possible Referenes in the aas env + foreach (var lr in environment.FindAllReferences()) + { + var r = lr?.Reference; + if (r != null) + for (int i = 0; i < r.Keys.Count; i++) + if (r.Keys[i].Matches(KeyTypes.GlobalReference, oldId)) + { + // directly replace + r.Keys[i].Value = newId; + if (res.Contains(lr.Identifiable)) + res.Add(lr.Identifiable); + } + } + + // rename old Asset + assetOld.AssetInformation.GlobalAssetId = new Reference(ReferenceTypes.GlobalReference, new List() { new Key(KeyTypes.GlobalReference, newId)}); + + // seems fine + return res; + } + + // no result is false, as well + return null; + } + + public static AssetAdministrationShell FindAasWithAssetInformation(this AasCore.Aas3_0_RC02.Environment environment, string globalAssetId) + { + if(string.IsNullOrEmpty(globalAssetId)) + { + return null; + } + + foreach(var aas in environment.AssetAdministrationShells) + { + if(aas.AssetInformation.GlobalAssetId.GetAsIdentifier().Equals(globalAssetId)) + { + return aas; + } + } + + return null; + } + + public static ComparerIndexed CreateIndexedComparerCdsForSmUsage(this AasCore.Aas3_0_RC02.Environment environment) + { + var cmp = new ComparerIndexed(); + int nr = 0; + foreach (var sm in environment.FindAllSubmodelGroupedByAAS()) + foreach (var sme in sm.FindDeep()) + { + if (sme.SemanticId == null) + continue; + var cd = environment.FindConceptDescriptionByReference(sme.SemanticId); + if (cd == null) + continue; + if (cmp.Index.ContainsKey(cd)) + continue; + cmp.Index[cd] = nr++; + } + return cmp; + } + + public static ISubmodelElement CopySubmodelElementAndCD(this AasCore.Aas3_0_RC02.Environment environment, + AasCore.Aas3_0_RC02.Environment srcEnv, ISubmodelElement srcElem, bool copyCD = false, bool shallowCopy = false) + { + // access + if (srcEnv == null || srcElem == null) + return null; + + // 1st result pretty easy (calling function will add this to the appropriate Submodel) + var res = srcElem.Copy(); + + // copy the CDs.. + if (copyCD) + environment.CopyConceptDescriptionsFrom(srcEnv, srcElem, shallowCopy); + + // give back + return res; + } + + public static Reference CopySubmodelRefAndCD( this AasCore.Aas3_0_RC02.Environment environment, + AasCore.Aas3_0_RC02.Environment srcEnv, Reference srcSubRef, bool copySubmodel = false, bool copyCD = false, + bool shallowCopy = false) + { + // access + if (srcEnv == null || srcSubRef == null) + return null; + + // need to have the source Submodel + var srcSub = srcEnv.FindSubmodel(srcSubRef); + if (srcSub == null) + return null; + + // 1st result pretty easy (calling function will add this to the appropriate AAS) + var dstSubRef =srcSubRef.Copy(); + + // get the destination and shall src != dst + var dstSub = environment.FindSubmodel(dstSubRef); + if (srcSub == dstSub) + return null; + + // maybe we need the Submodel in our environment, as well + if (dstSub == null && copySubmodel) + { + dstSub = srcSub.Copy(); + environment.Submodels.Add(dstSub); + } + else + if (dstSub != null) + { + // there is already an submodel, just add members + if (!shallowCopy && srcSub.SubmodelElements != null) + { + if (dstSub.SubmodelElements == null) + dstSub.SubmodelElements = new List(); + foreach (var smw in srcSub.SubmodelElements) + dstSub.SubmodelElements.Add( + smw.Copy()); + } + } + + // copy the CDs.. + if (copyCD && srcSub.SubmodelElements != null) + foreach (var smw in srcSub.SubmodelElements) + environment.CopyConceptDescriptionsFrom(srcEnv, smw, shallowCopy); + + // give back + return dstSubRef; + } + + private static void CopyConceptDescriptionsFrom(this AasCore.Aas3_0_RC02.Environment environment, + AasCore.Aas3_0_RC02.Environment srcEnv, ISubmodelElement src, bool shallowCopy = false) + { + // access + if (srcEnv == null || src == null || src.SemanticId == null) + return; + // check for this SubmodelElement in Source + var cdSrc = srcEnv.FindConceptDescriptionByReference(src.SemanticId); + if (cdSrc == null) + return; + // check for this SubmodelElement in Destnation (this!) + var cdDest = environment.FindConceptDescriptionByReference(src.SemanticId); + if (cdDest != null) + return; + // copy new + environment.ConceptDescriptions.Add(cdSrc.Copy()); + // recurse? + if (!shallowCopy && src is SubmodelElementCollection) + foreach (var m in (src as SubmodelElementCollection).Value) + environment.CopyConceptDescriptionsFrom(srcEnv, m, shallowCopy: false); + + } + #endregion + + } + + + +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendFile.cs b/src/AasxCsharpLibrary/Extensions/ExtendFile.cs new file mode 100644 index 000000000..8b8cc7576 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendFile.cs @@ -0,0 +1,68 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendFile + { + public static string ValueAsText(this File file) + { + return "" + file.Value; + } + + public static void Set(this File file, + string contentType = "", string value = "") + { + file.ContentType = contentType; + file.Value = value; + } + + public static File ConvertFromV10(this File file, AasxCompatibilityModels.AdminShellV10.File sourceFile) + { + file.ContentType = sourceFile.mimeType; + file.Value = sourceFile.value; + return file; + } + public static File ConvertFromV20(this File file, AasxCompatibilityModels.AdminShellV20.File sourceFile) + { + file.ContentType = sourceFile.mimeType; + file.Value = sourceFile.value; + return file; + } + + public static File UpdateFrom(this File elem, ISubmodelElement source) + { + if (source == null) + return elem; + + ((ISubmodelElement)elem).UpdateFrom(source); + + if (source is Property srcProp) + { + elem.Value = srcProp.Value; + } + + if (source is AasCore.Aas3_0_RC02.Range srcRng) + { + elem.Value = srcRng.Min; + } + + if (source is MultiLanguageProperty srcMlp) + { + elem.Value = "" + srcMlp.Value?.GetDefaultString(); + } + + if (source is File srcFile) + { + elem.Value = "" + srcFile.Value; + } + + return elem; + } + + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendHasDataSpecification.cs b/src/AasxCsharpLibrary/Extensions/ExtendHasDataSpecification.cs new file mode 100644 index 000000000..1a34c6d18 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendHasDataSpecification.cs @@ -0,0 +1,26 @@ +using AasCore.Aas3_0_RC02; +using AasxCompatibilityModels; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendHasDataSpecification + { + public static IHasDataSpecification ConvertFromV20(this IHasDataSpecification embeddedDataSpecifications, AasxCompatibilityModels.AdminShellV20.HasDataSpecification sourceSpecification) + { + foreach(var sourceSpec in sourceSpecification) + { + var newEmbeddedSpec = new EmbeddedDataSpecification(null, null); + newEmbeddedSpec.ConvertFromV20(sourceSpec); + embeddedDataSpecifications.EmbeddedDataSpecifications.Add(newEmbeddedSpec); + } + + return embeddedDataSpecifications; + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendIDataSpecificationContent.cs b/src/AasxCsharpLibrary/Extensions/ExtendIDataSpecificationContent.cs new file mode 100644 index 000000000..4f020cea9 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendIDataSpecificationContent.cs @@ -0,0 +1,68 @@ +using Extensions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AasCore.Aas3_0_RC02; +using AdminShellNS; + +namespace Extensions +{ + public static class ExtendIDataSpecificationContent + { + public enum ContentTypes { NoInfo, Iec61360, PhysicalUnit} + + public static Key GetKeyForIec61360() + { + return new Key(KeyTypes.GlobalReference, + "http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0"); + } + + public static Reference GetReferencForIec61360() + { + return new Reference(ReferenceTypes.GlobalReference, new List { GetKeyForIec61360() }); + } + + public static Key GetKeyForPhysicalUnit() + { + return new Key(KeyTypes.GlobalReference, + "http://admin-shell.io/DataSpecificationTemplates/DataSpecificationPhysicalUnit/3/0"); + } + + public static Key GetKeyFor(ContentTypes ct) + { + if (ct == ContentTypes.Iec61360) + return GetKeyForIec61360(); + if (ct == ContentTypes.PhysicalUnit) + return GetKeyForPhysicalUnit(); + return null; + } + + public static IDataSpecificationContent ContentFactoryFor(ContentTypes ct) + { + if (ct == ContentTypes.Iec61360) + return new DataSpecificationIec61360(null); + if (ct == ContentTypes.PhysicalUnit) + return new DataSpecificationPhysicalUnit("", "", null); + return null; + } + + public static ContentTypes GuessContentTypeFor(Reference rf) + { + foreach (var v in AdminShellUtil.GetEnumValues(new[] { ContentTypes.NoInfo })) + if (rf?.MatchesExactlyOneKey(GetKeyFor(v)) == true) + return v; + return ContentTypes.NoInfo; + } + + public static ContentTypes GuessContentTypeFor(IDataSpecificationContent content) + { + if (content is DataSpecificationIec61360) + return ContentTypes.Iec61360; + if (content is DataSpecificationPhysicalUnit) + return ContentTypes.PhysicalUnit; + return ContentTypes.NoInfo; + } + } +} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendIIdentifiable.cs b/src/AasxCsharpLibrary/Extensions/ExtendIIdentifiable.cs similarity index 60% rename from src/AasxServerStandardBib/Extenstions/ExtendIIdentifiable.cs rename to src/AasxCsharpLibrary/Extensions/ExtendIIdentifiable.cs index 7d92fae38..ad9927ea2 100644 --- a/src/AasxServerStandardBib/Extenstions/ExtendIIdentifiable.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendIIdentifiable.cs @@ -5,13 +5,22 @@ using System.Text; using System.Threading.Tasks; -namespace Extenstions +namespace Extensions { public static class ExtendIIdentifiable { + #region List of Identifiers + + public static string ToStringExtended(this List identifiables,string delimiter = ",") + { + return string.Join(delimiter, identifiables.Select((x) => x.Id)); + } + + #endregion public static Reference GetReference(this IIdentifiable identifiable) { var key = new Key(ExtensionsUtil.GetKeyType(identifiable), identifiable.Id); + //TODO:jtikekar if model or Global reference? var outputReference = new Reference(ReferenceTypes.ModelReference, new List() { key }); return outputReference; diff --git a/src/AasxCsharpLibrary/Extensions/ExtendIReferable.cs b/src/AasxCsharpLibrary/Extensions/ExtendIReferable.cs new file mode 100644 index 000000000..340900668 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendIReferable.cs @@ -0,0 +1,600 @@ +using AasCore.Aas3_0_RC02; +using AdminShellNS; +using AdminShellNS.Display; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net.Http.Headers; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendIReferable + { + #region AasxPackageExplorer + + public static void RecurseOnReferables(this IReferable referable, + object state, Func, IReferable, bool> lambda, + bool includeThis = false) + { + if(referable is Submodel submodel) + { + submodel.RecurseOnReferables(state, lambda, includeThis); + } + else if(referable is SubmodelElementCollection submodelElementCollection) + { + submodelElementCollection.RecurseOnReferables(state, lambda, includeThis); + } + else if(referable is SubmodelElementList submodelElementList) + { + submodelElementList.RecurseOnReferables(state, lambda, includeThis); + } + else if (includeThis) + lambda(state, null, referable); + } + + public static void Remove(this IReferable referable, ISubmodelElement submodelElement) + { + if(referable is Submodel submodel) + { + submodel.Remove(submodelElement); + } + else if(referable is AnnotatedRelationshipElement annotatedRelationshipElement) + { + annotatedRelationshipElement.Remove(submodelElement); + } + else if(referable is SubmodelElementCollection submodelElementCollection) + { + submodelElementCollection.Remove(submodelElement); + } + else if(referable is SubmodelElementList submodelElementList) + { + submodelElementList.Remove(submodelElement); + } + else if(referable is Entity entity) + { + entity.Remove(submodelElement); + } + } + + public static void Add(this IReferable referable, ISubmodelElement submodelElement) + { + if (referable is Submodel submodel) + { + submodel.Add(submodelElement); + } + else if (referable is AnnotatedRelationshipElement annotatedRelationshipElement) + { + annotatedRelationshipElement.Add(submodelElement); + } + else if (referable is SubmodelElementCollection submodelElementCollection) + { + submodelElementCollection.Add(submodelElement); + } + else if (referable is SubmodelElementList submodelElementList) + { + submodelElementList.Add(submodelElement); + } + else if (referable is Entity entity) + { + entity.Add(submodelElement); + } + } + + #region Display + + public static EnumerationPlacmentBase GetChildrenPlacement(this IReferable referable, ISubmodelElement submodelElement) + { + if(referable is Operation operation) + { + return operation.GetChildrenPlacement(submodelElement); + } + + return null; + } + + #endregion + + public static IIdentifiable FindParentFirstIdentifiable(this IReferable referable) + { + IReferable curr = referable; + while (curr != null) + { + if (curr is IIdentifiable curri) + return curri; + curr = curr.Parent as IReferable; + } + return null; + } + + #endregion + + #region ListOfReferables + public static Reference GetReference(this List referables) + { + return new Reference(ReferenceTypes.GlobalReference, referables.ToKeyList()); + } + + public static List ToKeyList(this List referables) + { + var res = new List(); + foreach (var rf in referables) + res.Add(new Key(rf.GetSelfDescription()?.KeyType ?? KeyTypes.GlobalReference, rf.IdShort)); + return res; + } + #endregion + + public static string ToIdShortString(this IReferable rf) + { + if (rf.IdShort == null || rf.IdShort.Trim().Length < 1) + return (""); + return rf.IdShort.Trim(); + } + + public static Reference GetReference(this IReferable referable) + { + if (referable is IIdentifiable identifiable) + { + return identifiable.GetReference(); + } + else if (referable is ISubmodelElement submodelElement) + { + return submodelElement.GetModelReference(); + } + else + return null; + } + public static void Validate(this IReferable referable,AasValidationRecordList results) + { + referable.BaseValidation(results); + + if(referable is ConceptDescription conceptDescription) + { + conceptDescription.Validate(results); + } + else if(referable is Submodel submodel) + { + submodel.Validate(results); + } + else if(referable is ISubmodelElement submodelElement) + { + submodelElement.Validate(results); + } + } + + public static void BaseValidation(this IReferable referable, AasValidationRecordList results) + { + // access + if (results == null) + return; + + // check + if (string.IsNullOrEmpty(referable.IdShort)) + results.Add(new AasValidationRecord( + AasValidationSeverity.SpecViolation, referable, + "Referable: missing idShort", + () => + { + referable.IdShort = "TO_FIX"; + })); + + if (referable.Description != null && (referable.Description.Count < 1)) + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, referable, + "Referable: existing description with missing langString", + () => + { + referable.Description = null; + })); + } + + /// + /// Tells, if the IReferable is used with an index instead of idShort. + /// + public static bool IsIndexed(this IReferable rf) + { + return rf is SubmodelElementList; + } + + public static AasElementSelfDescription GetSelfDescription(this IReferable referable) + { + if (referable is AssetAdministrationShell) + { + return new AasElementSelfDescription("AssetAdministrationShell", "AAS", + KeyTypes.AssetAdministrationShell, null); + } + else if (referable is ConceptDescription) + { + return new AasElementSelfDescription("ConceptDescription", "CD", + KeyTypes.ConceptDescription, null); + } + else if (referable is Submodel) + { + return new AasElementSelfDescription("Submodel", "SM", + KeyTypes.Submodel, null); + } + else if (referable is Property) + { + return new AasElementSelfDescription("Property", "Prop", + KeyTypes.Property, AasSubmodelElements.Property); + } + else if (referable is MultiLanguageProperty) + { + return new AasElementSelfDescription("MultiLanguageProperty", "MLP", + KeyTypes.MultiLanguageProperty, AasSubmodelElements.MultiLanguageProperty); + } + else if(referable is AasCore.Aas3_0_RC02.Range) + { + return new AasElementSelfDescription("Range", "Range", + KeyTypes.Range, AasSubmodelElements.Range); + } + else if(referable is Blob) + { + return new AasElementSelfDescription("Blob", "Blob", + KeyTypes.Blob, AasSubmodelElements.Blob); + } + else if(referable is AasCore.Aas3_0_RC02.File) + { + return new AasElementSelfDescription("File", "File", + KeyTypes.File, AasSubmodelElements.File); + } + else if(referable is ReferenceElement) + { + return new AasElementSelfDescription("ReferenceElement", "Ref", + KeyTypes.ReferenceElement, AasSubmodelElements.ReferenceElement); + } + else if(referable is RelationshipElement) + { + return new AasElementSelfDescription("RelationshipElement", "Rel", + KeyTypes.RelationshipElement, AasSubmodelElements.RelationshipElement); + } + else if(referable is AnnotatedRelationshipElement) + { + return new AasElementSelfDescription("AnnotatedRelationshipElement", "RelA", + KeyTypes.AnnotatedRelationshipElement, AasSubmodelElements.AnnotatedRelationshipElement); + } + else if(referable is Capability) + { + return new AasElementSelfDescription("Capability", "Cap", + KeyTypes.Capability, AasSubmodelElements.Capability); + } + else if(referable is SubmodelElementCollection) + { + return new AasElementSelfDescription("SubmodelElementCollection", "SMC", + KeyTypes.SubmodelElementCollection, AasSubmodelElements.SubmodelElementCollection); + } + else if(referable is SubmodelElementList) + { + return new AasElementSelfDescription("SubmodelElementList", "SML", + KeyTypes.SubmodelElementList, AasSubmodelElements.SubmodelElementList); + } + else if(referable is Operation) + { + return new AasElementSelfDescription("Operation", "Opr", + KeyTypes.Operation, AasSubmodelElements.Operation); + } + else if(referable is Entity) + { + return new AasElementSelfDescription("Entity", "Ent", + KeyTypes.Entity, AasSubmodelElements.Entity); + } + else if(referable is BasicEventElement) + { + return new AasElementSelfDescription("BasicEventElement", "Evt", + + KeyTypes.BasicEventElement, AasSubmodelElements.BasicEventElement); + } + else if(referable is IDataElement) + { + return new AasElementSelfDescription("DataElement", "DE", + KeyTypes.DataElement, AasSubmodelElements.DataElement); + } + else if(referable is ISubmodelElement) + { + return new AasElementSelfDescription("SubmodelElement", "SME", + KeyTypes.SubmodelElement, AasSubmodelElements.SubmodelElement); + } + else + { + return new AasElementSelfDescription("Referable", "Ref", + KeyTypes.Referable, null); + } + } + public static void CollectReferencesByParent(this IReferable referable, List refs) + { + // access + if (refs == null) + return; + + // check, if this is identifiable + if (referable is IIdentifiable) + { + var idf = referable as IIdentifiable; + if (idf != null) + { + //var k = Key.CreateNew( + // idf.GetElementName(), true, idf.identification?.idType, idf.identification?.id); + + var key = new Key((KeyTypes)Stringification.KeyTypesFromString(idf.GetType().Name), idf.Id); + refs.Insert(0, key); + } + } + else + { + //var k = Key.CreateNew(this.GetElementName(), true, "IdShort", referable.IdShort); + var key = new Key((KeyTypes)Stringification.KeyTypesFromString(referable.GetType().Name), referable.IdShort); + refs.Insert(0, key); + // recurse upwards! + if (referable.Parent is IReferable prf) + prf.CollectReferencesByParent(refs); + } + } + public static void SetTimeStamp(this IReferable referable, DateTime timeStamp) + { + IReferable newReferable = referable; + do + { + newReferable.TimeStamp = timeStamp; + if (newReferable != newReferable.Parent) + { + newReferable = (IReferable)newReferable.Parent; + } + else + newReferable = null; + } + while (newReferable != null); + } + + public static bool EnumeratesChildren(this ISubmodelElement elem) + { + var num = elem.EnumerateChildren().Count(); + return (num > 0); + } + + public static IEnumerable EnumerateChildren(this IReferable referable) + { + if (referable is Submodel submodel && submodel.SubmodelElements != null) + { + if (submodel.SubmodelElements != null) + { + foreach (var submodelElement in submodel.SubmodelElements) + { + yield return submodelElement; + } + } + } + else if (referable is SubmodelElementCollection submodelElementCollection) + { + if (submodelElementCollection.Value != null) + { + foreach (var submodelElement in submodelElementCollection.Value) + { + yield return submodelElement; + } + } + } + else if (referable is SubmodelElementList submodelElementList) + { + if (submodelElementList.Value != null) + { + foreach (var submodelElement in submodelElementList.Value) + { + yield return submodelElement; + } + } + } + else if (referable is AnnotatedRelationshipElement annotatedRelationshipElement) + { + if (annotatedRelationshipElement.Annotations != null) + { + foreach (var submodelElement in annotatedRelationshipElement.Annotations) + { + yield return submodelElement; + } + } + } + else if (referable is Entity entity) + { + if (entity.Statements != null) + { + foreach (var submodelElement in entity.Statements) + { + yield return submodelElement; + } + } + } + else if (referable is Operation operation) + { + if (operation.InputVariables != null) + foreach (var inputVariable in operation.InputVariables) + { + yield return inputVariable.Value; + } + + if (operation.OutputVariables != null) + foreach (var outputVariable in operation.OutputVariables) + { + yield return outputVariable.Value; + } + + if (operation.InoutputVariables != null) + foreach (var inOutVariable in operation.InoutputVariables) + { + yield return inOutVariable.Value; + } + } + else + { + yield break; + } + } + + + public static void SetAllParentsAndTimestamps(this IReferable referable, IReferable parent, DateTime timeStamp, DateTime timeStampCreate) + { + if (parent == null) + return; + + referable.Parent = parent; + referable.TimeStamp = timeStamp; + referable.TimeStampCreate = timeStampCreate; + + foreach (var submodelElement in referable.EnumerateChildren()) + { + submodelElement.SetAllParentsAndTimestamps(referable, timeStamp, timeStampCreate); + } + } + + public static Submodel GetParentSubmodel(this IReferable referable) + { + IReferable parent = referable; + while (parent is not Submodel && parent != null) + parent = (IReferable)parent.Parent; + return parent as Submodel; + } + + public static string CollectIdShortByParent(this IReferable referable) + { + // recurse first + var head = ""; + if (referable is not IIdentifiable && referable.Parent is IReferable parentReferable) + // can go up + head = parentReferable.CollectIdShortByParent() + "/"; + // add own + var myid = ""; + if (string.IsNullOrEmpty(referable.IdShort)) + myid = referable.IdShort.Trim(); + // together + return head + myid; + } + + public static void AddDescription(this IReferable referable,string language, string Text) + { + if (referable.Description == null) + referable.Description = new List(); + referable.Description.Add(new LangString(language, Text)); + } + + public static List ListOfIReferableFrom( + System.Text.Json.Nodes.JsonNode node) + { + var res = new List(); + if (node == null) + return res; + var array = node.AsArray(); + foreach (var it in array) + { + var ir = Jsonization.Deserialize.IReferableFrom(it); + res.Add(ir); + } + return res; + } + + public static Key ToKey(this IReferable rf) + { + var sd = rf.GetSelfDescription(); + if (sd == null || !sd.KeyType.HasValue) + return null; + if (rf is IIdentifiable rfi) + return new Key(sd.KeyType.Value, rfi.Id); + return new Key(sd.KeyType.Value, rf.IdShort); + } + + public static System.Text.Json.Nodes.JsonNode ToJsonObject(List classes) + { + var jar = new System.Text.Json.Nodes.JsonArray(); + if (classes != null) + foreach (var c in classes) + jar.Add(Jsonization.Serialize.ToJsonObject(c)); + return jar; + } + + public static IEnumerable FindAllQualifierType(this IReferable rf, string qualifierType) + { + if (!(rf is IQualifiable rfq) || rfq.Qualifiers == null || qualifierType == null) + yield break; + foreach (var q in rfq.Qualifiers) + if (q.Type.Trim().ToLower() == qualifierType.Trim().ToLower()) + yield return q; + } + + public static Qualifier HasQualifierOfType(this IReferable rf, string qualifierType) + { + if (!(rf is IQualifiable rfq) || rfq.Qualifiers == null) + return null; + foreach (var q in rfq.Qualifiers) + if (q.Type?.Trim().ToLower() == qualifierType?.Trim().ToLower()) + return q; + return null; + } + + public static Qualifier Add(this IReferable rf, Qualifier q) + { + if (!(rf is IQualifiable rfq)) + return null; + if (rfq.Qualifiers == null) + rfq.Qualifiers = new List(); + rfq.Qualifiers.Add(q); + return q; + } + + public static IEnumerable FindAllExtensionName(this IReferable rf, string extensionName) + { + if (!(rf is IHasExtensions rfe) || rfe.Extensions == null) + yield break; + foreach (var e in rfe.Extensions) + if (e.Name?.Trim().ToLower() == extensionName?.Trim().ToLower()) + yield return e; + } + + + public static Extension HasExtensionOfName(this IReferable rf, string extensionName) + { + if (!(rf is IHasExtensions rfe) || rfe.Extensions == null) + return null; + foreach (var e in rfe.Extensions) + if (e.Name?.Trim().ToLower() == extensionName?.Trim().ToLower()) + return e; + return null; + } + + public static Extension Add(this IReferable rf, Extension ext) + { + if (rf.Extensions == null) + rf.Extensions = new List(); + rf.Extensions.Add(ext); + return ext; + } + + public static void MigrateV20QualifiersToExtensions(this IReferable rf) + { + // access + if (!(rf is IQualifiable iq) || iq.Qualifiers == null || !(rf is IHasExtensions ihe)) + return; + + // Qualifiers to migrate + var toMigrate = new[] { + "Animate.Args", "Plotting.Args", "TimeSeries.Args", "BOM.Args", "ImageMap.Args" + }; + + List toMove = new List(); + foreach (var q in iq.Qualifiers) + foreach (var tm in toMigrate) + if (q?.Type?.Equals(tm, StringComparison.InvariantCultureIgnoreCase) == true) + toMove.Add(q); + + // now move these + for (int i=0; i ToCaptionInfo(this ISubmodelElement submodelElement) + { + var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", submodelElement.IdShort, ""); + var info = ""; + // TODO (MIHO, 2021-07-08): obvious error .. info should receive semanticId .. but would change + // display presentation .. therefore to be checked again + if (submodelElement.SemanticId != null) + AdminShellUtil.EvalToNonEmptyString("\u21e8 {0}", submodelElement.SemanticId.ToStringExtended(), ""); + return Tuple.Create(caption, info); + } + + public static void ValueFromText(this ISubmodelElement submodelElement, string text, string defaultLang = null) + { + switch(submodelElement) + { + case Property property: + { + property.ValueFromText(text); + break; + } + case MultiLanguageProperty multiLanguageProperty: + { + multiLanguageProperty.ValueFromText(text, defaultLang); + break; + } + default: + { + throw new Exception("Unhandled submodel element type"); + } + } + } + + #endregion + public static IEnumerable FindAllParents(this ISubmodelElement submodelElement, + Predicate p, + bool includeThis = false, bool includeSubmodel = false, + bool passOverMiss = false) + { + // call for this? + if (includeThis) + { + if (p == null || p.Invoke(submodelElement)) + yield return submodelElement; + else + if (!passOverMiss) + yield break; + } + + // daisy chain all parents .. + if (submodelElement.Parent != null) + { + if (submodelElement.Parent is ISubmodelElement psme) + { + foreach (var q in psme.FindAllParents(p, includeThis: true, + passOverMiss: passOverMiss)) + yield return q; + } + else if (includeSubmodel && submodelElement.Parent is Submodel psm) + { + if (p == null || p.Invoke(psm)) + yield return submodelElement; + } + } + } + + public static IEnumerable FindAllParentsWithSemanticId( + this ISubmodelElement submodelElement, Reference semId, + bool includeThis = false, bool includeSubmodel = false, bool passOverMiss = false) + { + return (FindAllParents(submodelElement, + (rf) => (true == (rf as IHasSemantics)?.SemanticId?.Matches(semId, + matchMode: MatchMode.Relaxed)), + includeThis: includeThis, includeSubmodel: includeSubmodel, passOverMiss: passOverMiss)); + } + + public static string ValueAsText(this ISubmodelElement submodelElement, string defaultLang = null) + { + //TODO:Need to check/test this logic again + if (submodelElement is Property property) + { + return property.ValueAsText(); + } + + if (submodelElement is MultiLanguageProperty multiLanguageProperty) + { + return multiLanguageProperty.ValueAsText(defaultLang); + } + + if (submodelElement is AasCore.Aas3_0_RC02.Range range) + { + return range.ValueAsText(); + } + + if (submodelElement is File file) + { + return file.ValueAsText(); + } + + return ""; + } + + public static Qualifier FindQualifierOfType(this ISubmodelElement submodelElement, string qualifierType) + { + if (submodelElement.Qualifiers == null || submodelElement.Qualifiers.Count == 0) + { + return null; + } + + foreach (var qualifier in submodelElement.Qualifiers) + { + if (qualifier.Type.Equals(qualifierType, StringComparison.OrdinalIgnoreCase)) + { + return qualifier; + } + } + + return null; + + } + + public static Reference GetModelReference(this ISubmodelElement sme, bool includeParents = true) + { + // this will be the tail of our chain + var keyList = new List(); + var keyType = ExtensionsUtil.GetKeyType(sme); + var key = new Key(keyType, sme.IdShort); + keyList.Add(key); + + // keys for Parents will be INSERTED in front, iteratively + var currentParent = sme.Parent; + while (includeParents && currentParent != null) + { + if (currentParent is IIdentifiable identifiable) + { + var currentParentKey = new Key(ExtensionsUtil.GetKeyType(identifiable), identifiable.Id); + keyList.Insert(0, currentParentKey); + currentParent = null; + } + else if (currentParent is IReferable referable) + { + var currentParentKey = new Key(ExtensionsUtil.GetKeyType(referable), referable.IdShort); + keyList.Insert(0, currentParentKey); + currentParent = referable.Parent; + } + + } + + var outputReference = new Reference(ReferenceTypes.ModelReference, keyList); + outputReference.ReferredSemanticId = sme.SemanticId; + return outputReference; + } + + public static IEnumerable FindDeep(this ISubmodelElement submodelElement) + { + if (submodelElement is T) + { + yield return (T)submodelElement; + } + + foreach (var x in submodelElement.Descend().OfType()) + yield return x; + + //if (submodelElement is SubmodelElementList sml && sml.Value != null) + // foreach (var ce in sml.Value) + // if (ce != null) + // foreach (var x in ce.FindDeep()) + // yield return x; + + //if (submodelElement is AnnotatedRelationshipElement arel && arel.Annotations != null) + // foreach (var x in arel.FindDeep()) + // yield return x; + + //if (submodelElement is Entity entity) + // foreach (var statement in entity.Statements) + // foreach (var x in statement.FindDeep()) + // yield return x; + + //if (submodelElement is Operation operation) + //{ + // var variableCollection = new SubmodelElementCollection(); + // variableCollection.Value = new List(); + // foreach (var inputVariable in operation.InputVariables) + // { + // variableCollection.Value.Add(inputVariable.Value); + // } + // foreach (var outputVariable in operation.OutputVariables) + // { + // variableCollection.Value.Add(outputVariable.Value); + // } + // foreach (var inOutVariable in operation.InoutputVariables) + // { + // variableCollection.Value.Add(inOutVariable.Value); + // } + // yield return (T)variableCollection.FindDeep(); + //} + } + + public static ISubmodelElement ConvertFromV10(this ISubmodelElement submodelElement, AdminShellV10.SubmodelElement sourceSubmodelElement, bool shallowCopy = false) + { + ISubmodelElement outputSubmodelElement = null; + if (sourceSubmodelElement != null) + { + if (sourceSubmodelElement is AdminShellV10.SubmodelElementCollection collection) + { + var newSmeCollection = new SubmodelElementCollection(); + outputSubmodelElement = newSmeCollection.ConvertFromV10(collection, shallowCopy); + } + else if (sourceSubmodelElement is AdminShellV10.Property sourceProperty) + { + var newProperty = new Property(DataTypeDefXsd.String); + outputSubmodelElement = newProperty.ConvertFromV10(sourceProperty); + } + else if (sourceSubmodelElement is AdminShellV10.File sourceFile) + { + var newFile = new File(""); + outputSubmodelElement = newFile.ConvertFromV10(sourceFile); + } + else if (sourceSubmodelElement is AdminShellV10.Blob blob) + { + var newBlob = new Blob(""); + outputSubmodelElement = newBlob.ConvertFromV10(blob); + } + else if (sourceSubmodelElement is AdminShellV10.ReferenceElement sourceReferenceElement) + { + outputSubmodelElement = new ReferenceElement(); + } + else if (sourceSubmodelElement is AdminShellV10.RelationshipElement sourceRelationshipElement) + { + var newFirst = ExtensionsUtil.ConvertReferenceFromV10(sourceRelationshipElement.first, ReferenceTypes.ModelReference); + var newSecond = ExtensionsUtil.ConvertReferenceFromV10(sourceRelationshipElement.second, ReferenceTypes.ModelReference); + outputSubmodelElement = new RelationshipElement(newFirst, newSecond); + } + + if (sourceSubmodelElement is AdminShellV10.Operation sourceOperation) + { + var newInputVariables = new List(); + var newOutputVariables = new List(); + if (sourceOperation.valueIn != null) + { + + foreach (var inputVariable in sourceOperation.valueIn) + { + if (inputVariable.value.submodelElement != null) + { + ISubmodelElement newSubmodelElement = null; + newSubmodelElement = newSubmodelElement.ConvertFromV10(inputVariable.value.submodelElement); + var newOpVariable = new OperationVariable(newSubmodelElement); + newInputVariables.Add(newOpVariable); + } + } + } + if (sourceOperation.valueOut != null) + { + foreach (var outputVariable in sourceOperation.valueOut) + { + if (outputVariable.value.submodelElement != null) + { + ISubmodelElement newSubmodelElement = null; + newSubmodelElement = newSubmodelElement.ConvertFromV10(outputVariable.value.submodelElement); + var newOpVariable = new OperationVariable(newSubmodelElement); + newOutputVariables.Add(newOpVariable); + } + } + } + + outputSubmodelElement = new Operation(inputVariables: newInputVariables, outputVariables: newOutputVariables); + } + + + outputSubmodelElement.BasicConversionFromV10(sourceSubmodelElement); + } + + return outputSubmodelElement; + } + + private static void BasicConversionFromV10(this ISubmodelElement submodelElement, AdminShellV10.SubmodelElement sourceSubmodelElement) + { + if (!string.IsNullOrEmpty(sourceSubmodelElement.idShort)) + { + submodelElement.IdShort = sourceSubmodelElement.idShort; + } + + if (!string.IsNullOrEmpty(sourceSubmodelElement.category)) + { + submodelElement.Category = sourceSubmodelElement.category; + } + + if (sourceSubmodelElement.description != null) + { + submodelElement.Description = ExtensionsUtil.ConvertDescriptionFromV10(sourceSubmodelElement.description); + } + + if (sourceSubmodelElement.semanticId != null) + { + var keyList = new List(); + foreach (var refKey in sourceSubmodelElement.semanticId.Keys) + { + var keyType = Stringification.KeyTypesFromString(refKey.type); + if (keyType != null) + { + keyList.Add(new Key((KeyTypes)keyType, refKey.value)); + } + else + { + Console.WriteLine($"KeyType value {refKey.type} not found."); + } + } + submodelElement.SemanticId = new Reference(ReferenceTypes.GlobalReference, keyList); + } + + if (sourceSubmodelElement.kind != null) + { + if (sourceSubmodelElement.kind.IsInstance) + { + submodelElement.Kind = ModelingKind.Instance; + } + else + { + submodelElement.Kind = ModelingKind.Template; + } + } + + if (sourceSubmodelElement.qualifiers != null && sourceSubmodelElement.qualifiers.Count != 0) + { + if (submodelElement.Qualifiers == null && submodelElement.Qualifiers.Count != 0) + { + submodelElement.Qualifiers = new List(); + } + + foreach (var sourceQualifier in sourceSubmodelElement.qualifiers) + { + var newQualifier = new Qualifier("", DataTypeDefXsd.String); + newQualifier = newQualifier.ConvertFromV10(sourceQualifier); + submodelElement.Qualifiers.Add(newQualifier); + } + } + + if (sourceSubmodelElement.hasDataSpecification != null) + { + //TODO: jtikekar : EmbeddedDataSpecification?? (as per old implementation) + if (submodelElement.EmbeddedDataSpecifications == null) + { + submodelElement.EmbeddedDataSpecifications = new List(); + } + foreach (var dataSpecification in sourceSubmodelElement.hasDataSpecification.reference) + { + submodelElement.EmbeddedDataSpecifications.Add( + new EmbeddedDataSpecification( + ExtensionsUtil.ConvertReferenceFromV10(dataSpecification, ReferenceTypes.GlobalReference), + null)); + } + } + } + + public static ISubmodelElement ConvertFromV20(this ISubmodelElement submodelElement, AdminShellV20.SubmodelElement sourceSubmodelElement, bool shallowCopy = false) + { + ISubmodelElement outputSubmodelElement = null; + if (sourceSubmodelElement != null) + { + if (sourceSubmodelElement is AdminShellV20.SubmodelElementCollection collection) + { + var newSmeCollection = new SubmodelElementCollection(); + outputSubmodelElement = newSmeCollection.ConvertFromV20(collection, shallowCopy); + } + else if (sourceSubmodelElement is AdminShellV20.Property sourceProperty) + { + var newProperty = new Property(DataTypeDefXsd.String); + outputSubmodelElement = newProperty.ConvertFromV20(sourceProperty); + } + else if (sourceSubmodelElement is AdminShellV20.MultiLanguageProperty sourceMultiLangProp) + { + var newMultiLangProperty = new MultiLanguageProperty(); + outputSubmodelElement = newMultiLangProperty.ConvertFromV20(sourceMultiLangProp); + } + else if (sourceSubmodelElement is AdminShellV20.Range sourceRange) + { + var newRange = new AasCore.Aas3_0_RC02.Range(DataTypeDefXsd.String); + outputSubmodelElement = newRange.ConvertFromV20(sourceRange); + } + else if (sourceSubmodelElement is AdminShellV20.File sourceFile) + { + var newFile = new File(""); + outputSubmodelElement = newFile.ConvertFromV20(sourceFile); + } + else if (sourceSubmodelElement is AdminShellV20.Blob blob) + { + var newBlob = new Blob(""); + outputSubmodelElement = newBlob.ConvertFromV20(blob); + } + else if (sourceSubmodelElement is AdminShellV20.ReferenceElement sourceReferenceElement) + { + var newReference = ExtensionsUtil.ConvertReferenceFromV20(sourceReferenceElement.value, ReferenceTypes.ModelReference); + outputSubmodelElement = new ReferenceElement(value: newReference); + } + else if (sourceSubmodelElement is AdminShellV20.AnnotatedRelationshipElement sourceAnnotedRelationshipElement) + { + var newFirst = ExtensionsUtil.ConvertReferenceFromV20(sourceAnnotedRelationshipElement.first, ReferenceTypes.ModelReference); + var newSecond = ExtensionsUtil.ConvertReferenceFromV20(sourceAnnotedRelationshipElement.second, ReferenceTypes.ModelReference); + var newAnnotedRelElement = new AnnotatedRelationshipElement(newFirst, newSecond); + outputSubmodelElement = newAnnotedRelElement.ConvertAnnotationsFromV20(sourceAnnotedRelationshipElement); + } + else if (sourceSubmodelElement is AdminShellV20.RelationshipElement sourceRelationshipElement) + { + var newFirst = ExtensionsUtil.ConvertReferenceFromV20(sourceRelationshipElement.first, ReferenceTypes.ModelReference); + var newSecond = ExtensionsUtil.ConvertReferenceFromV20(sourceRelationshipElement.second, ReferenceTypes.ModelReference); + outputSubmodelElement = new RelationshipElement(newFirst, newSecond); + } + else if (sourceSubmodelElement is AdminShellV20.BasicEvent sourceBasicEvent) + { + var newObserved = ExtensionsUtil.ConvertReferenceFromV20(sourceBasicEvent.observed, ReferenceTypes.ModelReference); + + outputSubmodelElement = new BasicEventElement(newObserved, Direction.Input, StateOfEvent.Off); //TODO: jtikekar default values of enums + } + else if (sourceSubmodelElement is AdminShellV20.Entity sourceEntity) + { + var entityType = Stringification.EntityTypeFromString(sourceEntity.entityType); + var newEntity = new Entity(entityType ?? EntityType.CoManagedEntity); + outputSubmodelElement = newEntity.ConvertFromV20(sourceEntity); + } + else if (sourceSubmodelElement is AdminShellV20.Operation sourceOperation) + { + var newInputVariables = new List(); + var newOutputVariables = new List(); + var newInOutVariables = new List(); + if (sourceOperation.inputVariable != null) + { + + foreach (var inputVariable in sourceOperation.inputVariable) + { + if (inputVariable.value.submodelElement != null) + { + ISubmodelElement newSubmodelElement = null; + newSubmodelElement = newSubmodelElement.ConvertFromV20(inputVariable.value.submodelElement); + var newOpVariable = new OperationVariable(newSubmodelElement); + newInputVariables.Add(newOpVariable); + } + } + } + if (sourceOperation.outputVariable != null) + { + foreach (var outputVariable in sourceOperation.outputVariable) + { + if (outputVariable.value.submodelElement != null) + { + ISubmodelElement newSubmodelElement = null; + newSubmodelElement = newSubmodelElement.ConvertFromV20(outputVariable.value.submodelElement); + var newOpVariable = new OperationVariable(newSubmodelElement); + newOutputVariables.Add(newOpVariable); + } + } + } + + if (sourceOperation.inoutputVariable != null) + { + foreach (var inOutVariable in sourceOperation.inoutputVariable) + { + if (inOutVariable.value.submodelElement != null) + { + ISubmodelElement newSubmodelElement = null; + newSubmodelElement = newSubmodelElement.ConvertFromV20(inOutVariable.value.submodelElement); + var newOpVariable = new OperationVariable(newSubmodelElement); + newInOutVariables.Add(newOpVariable); + } + } + } + + outputSubmodelElement = new Operation(inputVariables: newInputVariables, outputVariables: newOutputVariables, inoutputVariables: newInOutVariables); + } + + outputSubmodelElement.BasicConversionFromV20(sourceSubmodelElement); + } + + return outputSubmodelElement; + } + + private static void BasicConversionFromV20(this ISubmodelElement submodelElement, AdminShellV20.SubmodelElement sourceSubmodelElement) + { + if (!string.IsNullOrEmpty(sourceSubmodelElement.idShort)) + submodelElement.IdShort = sourceSubmodelElement.idShort; + + if (!string.IsNullOrEmpty(sourceSubmodelElement.category)) + submodelElement.Category = sourceSubmodelElement.category; + + if (sourceSubmodelElement.description != null) + submodelElement.Description = ExtensionsUtil.ConvertDescriptionFromV20(sourceSubmodelElement.description); + + if (sourceSubmodelElement.semanticId != null) + { + var keyList = new List(); + foreach (var refKey in sourceSubmodelElement.semanticId.Keys) + { + var keyType = Stringification.KeyTypesFromString(refKey.type); + if (keyType != null) + { + // DECISION: After phone call with Birgit, set all CD to GlobalReference + // assuming it is always a external concept + if (keyType == KeyTypes.ConceptDescription) + keyType = KeyTypes.GlobalReference; + + keyList.Add(new Key((KeyTypes)keyType, refKey.value)); + } + else + { + Console.WriteLine($"KeyType value {refKey.type} not found."); + } + } + submodelElement.SemanticId = new Reference(ReferenceTypes.GlobalReference, keyList); + } + + if (sourceSubmodelElement.kind != null) + { + if (sourceSubmodelElement.kind.IsInstance) + submodelElement.Kind = ModelingKind.Instance; + else + submodelElement.Kind = ModelingKind.Template; + } + + if (sourceSubmodelElement.qualifiers != null && sourceSubmodelElement.qualifiers.Count != 0) + { + if (submodelElement.Qualifiers == null || submodelElement.Qualifiers.Count == 0) + submodelElement.Qualifiers = new List(); + + foreach (var sourceQualifier in sourceSubmodelElement.qualifiers) + { + var newQualifier = new Qualifier("", DataTypeDefXsd.String); + newQualifier = newQualifier.ConvertFromV20(sourceQualifier); + submodelElement.Qualifiers.Add(newQualifier); + } + } + + if (sourceSubmodelElement.hasDataSpecification != null) + { + //TODO: jtikekar : EmbeddedDataSpecification?? (as per old implementation) + if (submodelElement.EmbeddedDataSpecifications == null) + submodelElement.EmbeddedDataSpecifications = new List(); + + //TODO: jtikekar: DataSpecificationContent?? (as per old implementation) + foreach (var sourceDataSpec in sourceSubmodelElement.hasDataSpecification) + { + submodelElement.EmbeddedDataSpecifications.Add( + new EmbeddedDataSpecification( + ExtensionsUtil.ConvertReferenceFromV20(sourceDataSpec.dataSpecification, ReferenceTypes.GlobalReference), + null)); + } + } + + // move Qualifiers to Extensions + submodelElement.MigrateV20QualifiersToExtensions(); + } + + #region List + + public static IReferable FindReferableByReference( + this List submodelElements, Reference rf, int keyIndex) + { + return FindReferableByReference(submodelElements, rf?.Keys, keyIndex); + } + + public static IReferable FindReferableByReference( + this List submodelElements, List keys, int keyIndex) + { + // first index needs to exist .. + if (submodelElements == null || keys == null || keyIndex >= keys.Count) + return null; + + + // over all wrappers + foreach (var smw in submodelElements) + if (smw != null && smw.IdShort.Equals(keys[keyIndex].Value, StringComparison.OrdinalIgnoreCase)) + { + // match on this level. Did we find a leaf element? + if ((keyIndex + 1) >= keys.Count) + return smw; + + // dive into SMC? + if (smw is SubmodelElementCollection smc) + { + var found = FindReferableByReference(smc.Value, keys, keyIndex + 1); + if (found != null) + return found; + } + // dive into SML? + if (smw is SubmodelElementList submodelElementList) + { + var found = FindReferableByReference(submodelElementList.Value, keys, keyIndex + 1); + if (found != null) + return found; + } + + // dive into AnnotedRelationshipElement? + if (smw is AnnotatedRelationshipElement annotatedRelationshipElement) + { + var annotations = new List(annotatedRelationshipElement.Annotations); + var found = FindReferableByReference(annotations, keys, keyIndex + 1); + if (found != null) + return found; + } + + // dive into Entity statements? + if (smw is Entity ent) + { + var found = FindReferableByReference(ent.Statements, keys, keyIndex + 1); + if (found != null) + return found; + } + + // else: + return null; + } + + // no? + return null; + } + + public static IEnumerable FindDeep(this List submodelElements, Predicate match = null) where T : ISubmodelElement + { + foreach (var smw in submodelElements) + { + var current = smw; + if (current == null) + continue; + + // call lambda for this element + if (current is T) + if (match == null || match.Invoke((T)current)) + yield return (T)current; + + // dive into? + // TODO (MIHO, 2020-07-31): would be nice to use IEnumerateChildren for this .. + if (current is SubmodelElementCollection smc && smc.Value != null) + foreach (var x in smc.Value.FindDeep(match)) + yield return x; + + if (current is AnnotatedRelationshipElement are && are.Annotations != null) + { + var annotationsList = new List(are.Annotations); + foreach (var x in annotationsList.FindDeep(match)) + yield return x; + } + + if (current is Entity ent && ent.Statements != null) + foreach (var x in ent.Statements.FindDeep(match)) + yield return x; + + if (current is Operation op) + { + var operationVariables = new List(); + foreach(var opVariable in op.InputVariables) + { + operationVariables.Add(opVariable.Value); + } + + foreach(var opVariable in op.InoutputVariables) + { + operationVariables.Add(opVariable.Value); + } + + foreach(var opVariable in op.OutputVariables) + { + operationVariables.Add(opVariable.Value); + } + + foreach (var x in operationVariables.FindDeep(match)) + yield return x; + } + } + } + + public static void CopyManySMEbyCopy(this List submodelElements, ConceptDescription destCD, + List sourceSmc, ConceptDescription sourceCD, + bool createDefault = false, Action setDefault = null, + MatchMode matchMode = MatchMode.Relaxed) where T : ISubmodelElement + { + submodelElements.CopyManySMEbyCopy(destCD.GetSingleKey(), sourceSmc, sourceCD.GetSingleKey(), + createDefault ? destCD : null, setDefault, matchMode); + } + + public static void CopyManySMEbyCopy(this List submodelElements, Key destSemanticId, + List sourceSmc, Key sourceSemanticId, + ConceptDescription createDefault = null, Action setDefault = null, + MatchMode matchMode = MatchMode.Relaxed) where T : ISubmodelElement + { + // bool find possible sources + bool foundSrc = false; + if (sourceSmc == null) + return; + foreach (var src in sourceSmc.FindAllSemanticIdAs(sourceSemanticId, matchMode)) + { + // type of found src? + AasSubmodelElements aeSrc = (AasSubmodelElements)Enum.Parse(typeof(AasSubmodelElements), src.GetType().Name); + + // ok? + if (src == null || aeSrc == AasSubmodelElements.SubmodelElement) + continue; + foundSrc = true; + + // ok, create new one + var dst = AdminShellNS.AdminShellUtil.CreateSubmodelElementFromEnum(aeSrc, src); + if (dst != null) + { + // make same things sure + dst.IdShort = src.IdShort; + dst.Category = src.Category; + dst.SemanticId = new Reference(ReferenceTypes.ModelReference, new List() { destSemanticId}); + + // instantanously add it? + submodelElements.Add(dst); + } + } + + // default? + if (createDefault != null && !foundSrc) + { + // ok, default + var dflt = submodelElements.CreateSMEForCD(createDefault, addSme: true); + + // set default? + setDefault?.Invoke(dflt); + } + } + + public static T CopyOneSMEbyCopy(this List submodelElements, ConceptDescription destCD, + List sourceSmc, Key[] sourceKeys, + bool createDefault = false, Action setDefault = null, + MatchMode matchMode = MatchMode.Relaxed, + string idShort = null, bool addSme = false) where T : ISubmodelElement + { + return submodelElements.CopyOneSMEbyCopy(destCD?.GetSingleKey(), sourceSmc, sourceKeys, + createDefault ? destCD : null, setDefault, matchMode, idShort, addSme); + } + + public static T CopyOneSMEbyCopy(this List submodelELements, ConceptDescription destCD, + List sourceSmc, ConceptDescription sourceCD, + bool createDefault = false, Action setDefault = null, + MatchMode matchMode = MatchMode.Relaxed, + string idShort = null, bool addSme = false) where T : ISubmodelElement + { + return submodelELements.CopyOneSMEbyCopy(destCD?.GetSingleKey(), sourceSmc, new[] { sourceCD?.GetSingleKey() }, + createDefault ? destCD : null, setDefault, matchMode, idShort, addSme); + } + + public static T CopyOneSMEbyCopy(this List submodelElements, Key destSemanticId, + List sourceSmc, Key[] sourceSemanticId, + ConceptDescription createDefault = null, Action setDefault = null, + MatchMode matchMode = MatchMode.Relaxed, + string idShort = null, bool addSme = false) where T : ISubmodelElement + { + // get source + var src = sourceSmc.FindFirstAnySemanticIdAs(sourceSemanticId, matchMode); + + // may be make an adaptive conversion + if (src == null) + { + var anySrc = sourceSmc?.FindFirstAnySemanticId(sourceSemanticId, matchMode: matchMode); + src = submodelElements.AdaptiveConvertTo(anySrc, createDefault, + idShort: idShort, addSme: false); + } + + // proceed + AasSubmodelElements aeSrc = (AasSubmodelElements)Enum.Parse(typeof(AasSubmodelElements), src?.GetType().Name); + if (src == null || aeSrc == AasSubmodelElements.SubmodelElement) + { + // create a default? + if (createDefault == null) + return default(T); + + // ok, default + var dflt = submodelElements.CreateSMEForCD(createDefault, idShort: idShort, addSme: addSme); + + // set default? + setDefault?.Invoke(dflt); + + // return + return dflt; + } + + // ok, create new one + var dst = AdminShellNS.AdminShellUtil.CreateSubmodelElementFromEnum(aeSrc, src); + if (dst == null) + return default(T); + + // make same things sure + dst.IdShort = src.IdShort; + dst.Category = src.Category; + dst.SemanticId = new Reference(ReferenceTypes.ModelReference, new List() { destSemanticId}); + + // instantanously add it? + if (addSme) + submodelElements.Add(dst); + + // give back + return (T)dst; + } + + public static T AdaptiveConvertTo(this List submodelElements, + ISubmodelElement anySrc, + ConceptDescription createDefault = null, + string idShort = null, bool addSme = false) where T : ISubmodelElement + { + if (typeof(T) == typeof(MultiLanguageProperty) + && anySrc is Property srcProp) + { + var res = submodelElements.CreateSMEForCD(createDefault, idShort: idShort, addSme: addSme); + if (res is MultiLanguageProperty mlp) + { + mlp.Value = new List() { new LangString("EN?", srcProp.Value) }; + mlp.ValueId = srcProp.ValueId; + return res; + } + } + + if (typeof(T) == typeof(Property) + && anySrc is MultiLanguageProperty srcMlp) + { + var res = submodelElements.CreateSMEForCD(createDefault, idShort: idShort, addSme: addSme); + if (res is Property prp) + { + prp.Value = "" + srcMlp.Value?.GetDefaultString(); + prp.ValueId = srcMlp.ValueId; + return res; + } + } + + return default(T); + } + + public static IEnumerable FindAllIdShort(this List submodelElements, + string idShort) + { + foreach (var smw in submodelElements) + if (smw != null) + if (smw.IdShort.Trim().ToLower() == idShort.Trim().ToLower()) + yield return smw; + } + + public static IEnumerable FindAllIdShortAs(this List submodelElements, + string idShort) where T : class, ISubmodelElement + { + foreach (var smw in submodelElements) + if (smw is T) + if (smw.IdShort.Trim().ToLower() == idShort.Trim().ToLower()) + yield return smw as T; + } + + public static ISubmodelElement FindFirstIdShort(this List submodelElements, + string idShort) + { + return submodelElements.FindAllIdShort(idShort)?.FirstOrDefault(); + } + + public static T FindFirstIdShortAs(this List submodelElements, + string idShort) where T : class, ISubmodelElement + { + return submodelElements.FindAllIdShortAs(idShort)?.FirstOrDefault(); + } + + + public static ISubmodelElement FindFirstAnySemanticId(this List submodelElements, + Key[] semId, Type[] allowedTypes = null, MatchMode matchMode = MatchMode.Strict) + { + if (semId == null) + return null; + foreach (var si in semId) + { + var found = submodelElements.FindAllSemanticId(si, allowedTypes, matchMode)? + .FirstOrDefault(); + if (found != null) + return found; + } + return null; + } + + public static T FindFirstAnySemanticIdAs(this List submodelElements, Key[] semId, MatchMode matchMode = MatchMode.Strict) + where T : ISubmodelElement + { + if (semId == null) + return default(T); + foreach (var si in semId) + { + var found = submodelElements.FindAllSemanticIdAs(si, matchMode).FirstOrDefault(); + if (found != null) + return found; + } + return default(T); + } + + public static T CreateNew(string idShort = null, string category = null, Reference semanticId = null) + where T : ISubmodelElement, new() + { + var res = new T(); + if (idShort != null) + res.IdShort = idShort; + if (category != null) + res.Category = category; + if (semanticId != null) + res.SemanticId = semanticId.Copy(); + return res; + } + + public static T CreateSMEForCD(this List submodelELements, ConceptDescription conceptDescription, string category = null, string idShort = null, + string idxTemplate = null, int maxNum = 999, bool addSme = false, bool isTemplate = false) + where T : ISubmodelElement + { + // access + if (conceptDescription == null) + return default(T); + + // fin type enum + var smeType = AdminShellUtil.AasSubmodelElementsFrom(); + if (!smeType.HasValue) + return default(T); + + // try to potentially figure out idShort + var ids = conceptDescription.IdShort; + + //TODO:jtikekar Temporarily removed + if ((ids == null || ids.Trim() == "") && conceptDescription.GetIEC61360() != null) + ids = conceptDescription.GetIEC61360().ShortName? + .GetDefaultString(); + + if (idShort != null) + ids = idShort; + + if (ids == null) + return default(T); + + // unique? + if (idxTemplate != null) + ids = submodelELements.IterateIdShortTemplateToBeUnique(idxTemplate, maxNum); + + // make a new instance + var semanticId = conceptDescription.GetCdReference(); + ISubmodelElement sme = AdminShellUtil.CreateSubmodelElementFromEnum(smeType.Value); + if (sme == null) + return default(T); + sme.IdShort = ids; + sme.SemanticId = semanticId.Copy(); + if (category != null) + sme.Category = category; + if (isTemplate) + sme.Kind = ModelingKind.Template; + + // if its a SMC, make sure its accessible + if (sme is SubmodelElementCollection smc) + smc.Value = new List(); + + // instantanously add it? + if (addSme) + submodelELements.Add(sme); + + // give back + return (T)sme; + } + + public static IEnumerable FindAllSemanticIdAs(this List submodelELements, Key semId, MatchMode matchMode = MatchMode.Strict) + where T : ISubmodelElement + { + foreach (var submodelElement in submodelELements) + if (submodelElement != null && submodelElement is T + && submodelElement.SemanticId != null) + if (submodelElement.SemanticId.MatchesExactlyOneKey(semId, matchMode)) + yield return (T)submodelElement; + } + + public static IEnumerable FindAllSemanticIdAs(this List submodelELements, + Reference semId, MatchMode matchMode = MatchMode.Strict) + where T : ISubmodelElement + { + foreach (var submodelElement in submodelELements) + if (submodelElement != null && submodelElement is T + && submodelElement.SemanticId != null) + if (submodelElement.SemanticId.Matches(semId, matchMode)) + yield return (T)submodelElement; + } + + public static T FindFirstSemanticIdAs(this List submodelElements, + Key semId, MatchMode matchMode = MatchMode.Strict) + where T : ISubmodelElement + { + return submodelElements.FindAllSemanticIdAs(semId, matchMode).FirstOrDefault(); + } + + public static T FindFirstSemanticIdAs(this List submodelElements, + Reference semId, MatchMode matchMode = MatchMode.Strict) + where T : ISubmodelElement + { + return submodelElements.FindAllSemanticIdAs(semId, matchMode).FirstOrDefault(); + } + + public static void RecurseOnReferables(this List submodelElements, object state, List parents, + Func, IReferable, bool> lambda) + { + if (lambda == null) + return; + if (parents == null) + parents = new List(); + + // over all elements + foreach (var submodelElement in submodelElements) + { + var current = submodelElement; + if (current == null) + continue; + + // call lambda for this element + // AND decide, if to recurse! + var goDeeper = lambda(state, parents, current); + + if (goDeeper) + { + // add to parents + parents.Add(current); + + // dive into? + if (current is SubmodelElementCollection smc) + smc.Value?.RecurseOnReferables(state, parents, lambda); + + if (current is Entity ent) + ent.Statements?.RecurseOnReferables(state, parents, lambda); + + if (current is Operation operation) + { + SubmodelElementCollection opVariableCollection = new SubmodelElementCollection(); + foreach (var inputVariable in operation.InputVariables) + { + opVariableCollection.Value.Add(inputVariable.Value); + } + + foreach (var outputVariable in operation.OutputVariables) + { + opVariableCollection.Value.Add(outputVariable.Value); + } + + foreach (var inOutVariable in operation.InoutputVariables) + { + opVariableCollection.Value.Add(inOutVariable.Value); + } + + opVariableCollection.Value.RecurseOnReferables(state, parents, lambda); + } + + if (current is AnnotatedRelationshipElement annotatedRelationshipElement) + { + var annotationElements = new List(); + if (annotatedRelationshipElement.Annotations != null) + foreach (var annotation in annotatedRelationshipElement.Annotations) + { + annotationElements.Add(annotation); + } + annotationElements.RecurseOnReferables(state, parents, lambda); + } + + // remove from parents + parents.RemoveAt(parents.Count - 1); + } + } + } + + public static void RecurseOnSubmodelElements(this List submodelElements, object state, List parents, Action, ISubmodelElement> lambda) + { + // trivial + if (lambda == null) + return; + if (parents == null) + parents = new List(); + + // over all elements + foreach (var smw in submodelElements) + { + var current = smw; + if (current == null) + continue; + + // call lambda for this element + lambda(state, parents, current); + + // add to parents + parents.Add(current); + + // dive into? + if (current is SubmodelElementCollection smc) + smc.Value?.RecurseOnSubmodelElements(state, parents, lambda); + + if (current is Entity ent) + ent.Statements?.RecurseOnSubmodelElements(state, parents, lambda); + + if (current is Operation operation) + { + SubmodelElementCollection opVariableCollection = new SubmodelElementCollection(); + foreach (var inputVariable in operation.InputVariables) + { + opVariableCollection.Value.Add(inputVariable.Value); + } + + foreach (var outputVariable in operation.OutputVariables) + { + opVariableCollection.Value.Add(outputVariable.Value); + } + + foreach (var inOutVariable in operation.InoutputVariables) + { + opVariableCollection.Value.Add(inOutVariable.Value); + } + + opVariableCollection.Value.RecurseOnSubmodelElements(state, parents, lambda); + } + + if (current is AnnotatedRelationshipElement annotatedRelationshipElement) + { + var annotationElements = new List(); + foreach (var annotation in annotatedRelationshipElement.Annotations) + { + annotationElements.Add(annotation); + } + annotationElements.RecurseOnSubmodelElements(state, parents, lambda); + } + + // remove from parents + parents.RemoveAt(parents.Count - 1); + } + } + + public static IEnumerable FindAllSemanticIdAs(this List submodelELements, string semanticId) where T : ISubmodelElement + { + foreach (var submodelElement in submodelELements) + { + if (submodelElement != null && submodelElement is T && submodelElement.SemanticId != null) + { + if (submodelElement.SemanticId.Matches(semanticId)) + { + yield return (T)submodelElement; + } + } + } + } + + public static T FindFirstSemanticIdAs(this List submodelELements, string semanticId) where T : ISubmodelElement + { + return submodelELements.FindAllSemanticIdAs(semanticId).FirstOrDefault(); + } + + public static T FindFirstAnySemanticIdAs(this List submodelELements, string[] semanticIds) where T : ISubmodelElement + { + if (semanticIds == null) + return default; + foreach (var semanticId in semanticIds) + { + var found = submodelELements.FindFirstSemanticIdAs(semanticId); + if (found != null) + return found; + } + return default; + } + + public static IEnumerable FindAllSemanticId( + this List smes, + string[] allowedSemanticIds, + bool invertedAllowed = false) where T : ISubmodelElement + { + if (allowedSemanticIds == null || allowedSemanticIds.Length < 1) + yield break; + + foreach (var sme in smes) + { + if (sme == null || !(sme is T)) + continue; + + if (sme.SemanticId == null || sme.SemanticId.Keys.Count < 1) + { + if (invertedAllowed) + yield return (T)sme; + continue; + } + + var found = false; + foreach (var semanticId in allowedSemanticIds) + if (sme.SemanticId.Matches(semanticId)) + { + found = true; + break; + } + + if (invertedAllowed) + found = !found; + + if (found) + yield return (T)sme; + } + } + + public static T FindFirstAnySemanticId(this List submodelElements, string[] allowedSemanticIds, bool invertAllowed = false) where T : ISubmodelElement + { + return submodelElements.FindAllSemanticId(allowedSemanticIds, invertAllowed).FirstOrDefault(); + } + + public static IEnumerable FindAllSemanticId( + this List smes, + Key[] allowedSemanticIds, MatchMode mm = MatchMode.Strict, + bool invertedAllowed = false) where T : ISubmodelElement + { + if (allowedSemanticIds == null || allowedSemanticIds.Length < 1) + yield break; + + foreach (var sme in smes) + { + if (sme == null || !(sme is T)) + continue; + + if (sme.SemanticId == null || sme.SemanticId.Keys.Count < 1) + { + if (invertedAllowed) + yield return (T)sme; + continue; + } + + var found = false; + foreach (var semanticId in allowedSemanticIds) + if (sme.SemanticId.MatchesExactlyOneKey(semanticId, mm)) + { + found = true; + break; + } + + if (invertedAllowed) + found = !found; + + if (found) + yield return (T)sme; + } + } + + public static T FindFirstAnySemanticId( + this List submodelElements, + Key[] allowedSemanticIds, MatchMode mm = MatchMode.Strict, + bool invertAllowed = false) where T : ISubmodelElement + { + return submodelElements.FindAllSemanticId(allowedSemanticIds, mm, invertAllowed).FirstOrDefault(); + } + + public static IEnumerable FindAllSemanticId( + this List submodelElements, Key semId, + Type[] allowedTypes = null, + MatchMode matchMode = MatchMode.Strict) + { + foreach (var smw in submodelElements) + if (smw != null && smw.SemanticId != null) + { + if (smw == null) + continue; + + if (allowedTypes != null) + { + var smwt = smw.GetType(); + if (!allowedTypes.Contains(smwt)) + continue; + } + + if (smw.SemanticId.MatchesExactlyOneKey(semId, matchMode)) + yield return smw; + } + } + + public static ISubmodelElement FindFirstSemanticId(this List submodelElements, Key semId, Type[] allowedTypes = null, MatchMode matchMode = MatchMode.Strict) + { + return submodelElements.FindAllSemanticId(semId, allowedTypes, matchMode)?.FirstOrDefault(); + } + + public static IEnumerable FindAllSemanticIdAs( + this List smes, + ConceptDescription cd, MatchMode matchMode = MatchMode.Strict) + where T : ISubmodelElement + { + foreach (var x in FindAllSemanticIdAs(smes, cd.GetReference(), matchMode)) + yield return x; + } + + public static T FindFirstSemanticIdAs( + this List smes, + ConceptDescription cd, MatchMode matchMode = MatchMode.Strict) + where T : ISubmodelElement + { + return smes.FindAllSemanticIdAs(cd, matchMode).FirstOrDefault(); + } + + + public static string IterateIdShortTemplateToBeUnique(this List submodelElements, string idShortTemplate, int maxNum) + { + if (idShortTemplate == null || maxNum < 1 || !idShortTemplate.Contains("{0")) + return null; + + int i = 1; + while (i < maxNum) + { + var ids = string.Format(idShortTemplate, i); + if (submodelElements.CheckIdShortIsUnique(ids)) + return ids; + i++; + } + + return null; + } + + public static bool CheckIdShortIsUnique(this List submodelElements, string idShort) + { + idShort = idShort?.Trim(); + if (idShort == null || idShort.Length < 1) + return false; + + var res = true; + foreach (var smw in submodelElements) + if (smw != null && smw.IdShort != null && smw.IdShort == idShort) + { + res = false; + break; + } + + return res; + } + + #endregion + + public static ISubmodelElement UpdateFrom(this ISubmodelElement elem, ISubmodelElement source) + { + if (source == null) + return elem; + + // IReferable + elem.Category = source.Category; + elem.IdShort = source.IdShort; + elem.DisplayName = source.DisplayName?.Copy(); + elem.Description = source.Description?.Copy(); + elem.Checksum = source.Checksum; + + // IHasKind + if (source.Kind.HasValue) + elem.Kind = source.Kind.Value; + + // IHasSemantics + if (source.SemanticId != null) + elem.SemanticId = source.SemanticId.Copy(); + if (source.SupplementalSemanticIds != null) + elem.SupplementalSemanticIds = source.SupplementalSemanticIds.Copy(); + + // IQualifiable + if (source.Qualifiers != null) + elem.Qualifiers = source.Qualifiers.Copy(); + + // IHasDataSpecification + if (source.EmbeddedDataSpecifications != null) + elem.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications.Copy(); + + return elem; + } + + // + // Factories + // + + private static readonly Dictionary AasSubmodelElementsToAbbrev = ( + new Dictionary() + { + { AasSubmodelElements.AnnotatedRelationshipElement, "RelA" }, + { AasSubmodelElements.BasicEventElement, "BEvt" }, + { AasSubmodelElements.Blob, "Blob" }, + { AasSubmodelElements.Capability, "Cap" }, + { AasSubmodelElements.DataElement, "DE" }, + { AasSubmodelElements.Entity, "Ent" }, + { AasSubmodelElements.EventElement, "Evt" }, + { AasSubmodelElements.File, "File" }, + { AasSubmodelElements.MultiLanguageProperty, "MLP" }, + { AasSubmodelElements.Operation, "Opr" }, + { AasSubmodelElements.Property, "Prop" }, + { AasSubmodelElements.Range, "Range" }, + { AasSubmodelElements.ReferenceElement, "Ref" }, + { AasSubmodelElements.RelationshipElement, "Rel" }, + { AasSubmodelElements.SubmodelElement, "SME" }, + { AasSubmodelElements.SubmodelElementList, "SML" }, + { AasSubmodelElements.SubmodelElementCollection, "SMC" } + }); + + /// + /// Retrieve the string abbreviation of . + /// + /// + /// If is not a valid literal, return null. + /// + public static string? ToString(AasSubmodelElements? that) + { + if (!that.HasValue) + { + return null; + } + else + { + if (AasSubmodelElementsToAbbrev.TryGetValue(that.Value, out string? value)) + { + return value; + } + else + { + return null; + } + } + } + + private static readonly Dictionary _aasSubmodelElementsFromAbbrev = ( + new Dictionary() + { + { "RelA", AasSubmodelElements.AnnotatedRelationshipElement }, + { "BEvt", AasSubmodelElements.BasicEventElement }, + { "Blob", AasSubmodelElements.Blob }, + { "Cap", AasSubmodelElements.Capability }, + { "DE", AasSubmodelElements.DataElement }, + { "Ent", AasSubmodelElements.Entity }, + { "Evt", AasSubmodelElements.EventElement }, + { "File", AasSubmodelElements.File }, + { "MLP", AasSubmodelElements.MultiLanguageProperty }, + { "Opr", AasSubmodelElements.Operation }, + { "Prop", AasSubmodelElements.Property }, + { "Range", AasSubmodelElements.Range }, + { "Ref", AasSubmodelElements.ReferenceElement }, + { "Rel", AasSubmodelElements.RelationshipElement }, + { "SME", AasSubmodelElements.SubmodelElement }, + { "SML", AasSubmodelElements.SubmodelElementList }, + { "SMC", AasSubmodelElements.SubmodelElementCollection } + }); + + /// + /// Parse the string abbreviation of . + /// + /// + /// If is not a valid string representation + /// of a literal of , + /// return null. + /// + public static AasSubmodelElements? AasSubmodelElementsFromAbbrev(string text) + { + if (_aasSubmodelElementsFromAbbrev.TryGetValue(text, out AasSubmodelElements value)) + { + return value; + } + else + { + return null; + } + } + + /// + /// Parse the string representation or the abbreviation of . + /// + /// + /// If is not a valid string representation + /// of a literal of , + /// return null. + /// + public static AasSubmodelElements? AasSubmodelElementsFromStringOrAbbrev(string text) + { + var res = Stringification.AasSubmodelElementsFromString(text); + if (res.HasValue) + return res; + + return AasSubmodelElementsFromAbbrev(text); + } + + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendKey.cs b/src/AasxCsharpLibrary/Extensions/ExtendKey.cs new file mode 100644 index 000000000..141308e50 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendKey.cs @@ -0,0 +1,229 @@ +using AasCore.Aas3_0_RC02; +using AasxCompatibilityModels; +using AdminShellNS; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.Serialization; +using System.Text.RegularExpressions; + +namespace Extensions +{ + public static class ExtendKey + { + public static Key CreateFrom(Reference r) + { + if (r == null || r.Count() != 1) + return null; + return r.Keys[0].Copy(); + } + + public static bool Matches(this Key key, + KeyTypes type, string id, MatchMode matchMode = MatchMode.Strict) + { + if (matchMode == MatchMode.Strict) + return key.Type == type && key.Value == id; + + if (matchMode == MatchMode.Relaxed) + return (key.Type == type || key.Type == KeyTypes.GlobalReference || type == KeyTypes.GlobalReference) + && key.Value == id; + + if (matchMode == MatchMode.Identification) + return key.Value == id; + + return false; + } + public static bool Matches(this Key key, Key otherKey) + { + if (otherKey == null) + { + return false; + } + + if (key.Type == otherKey.Type && key.Value.Equals(otherKey.Value)) + { + return true; + } + + return false; + } + + public static bool Matches(this Key key, Key otherKey, MatchMode matchMode = MatchMode.Strict) + { + if (matchMode == MatchMode.Strict) + return key.Type == otherKey.Type && key.Value == otherKey.Value; + + if (matchMode == MatchMode.Relaxed) + return (key.Type == otherKey.Type || key.Type == KeyTypes.GlobalReference || otherKey.Type == KeyTypes.GlobalReference) + && (key.Value == otherKey.Value); + + if (matchMode == MatchMode.Identification) + return key.Value == otherKey.Value; + + return false; + } + + public static bool MatchesSetOfTypes(this Key key, IEnumerable set) + { + foreach (var kt in set) + if (key.Type == kt) + return true; + return false; + } + + + public static AasValidationAction Validate(this Key key, AasValidationRecordList results, IReferable container) + { + // access + if (results == null || container == null) + return AasValidationAction.No; + + var res = AasValidationAction.No; + + // check + if (key == null) + { + // violation case + results.Add(new AasValidationRecord( + AasValidationSeverity.SpecViolation, container, + "Key: is null", + () => + { + res = AasValidationAction.ToBeDeleted; + })); + } + else + { + + // check type + var tf = AdminShellUtil.CheckIfInConstantStringArray(Enum.GetNames(typeof(KeyTypes)), Stringification.ToString(key.Type)); + if (tf == AdminShellUtil.ConstantFoundEnum.No) + // violation case + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, container, + "Key: type is not in allowed enumeration values", + () => + { + key.Type = KeyTypes.GlobalReference; + })); + if (tf == AdminShellUtil.ConstantFoundEnum.AnyCase) + // violation case + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, container, + "Key: type in wrong casing", + () => + { + //NO IdType in V3 + //key.idType = AdminShellUtil.CorrectCasingForConstantStringArray( + // KeyElements, key.type); + })); + } + + // may give result "to be deleted" + return res; + } + + + + public static string ToStringExtended(this Key key, int format = 1) + { + if (format == 2) + return "" + key.Value; + return $"[{key.Type}, {key.Value}]"; + } + + public static bool IsAbsolute(this Key key) + { + return key.Type == KeyTypes.GlobalReference || key.Type == KeyTypes.AssetAdministrationShell || key.Type == KeyTypes.Submodel; + } + + public static Key Parse(string cell, KeyTypes typeIfNotSet = KeyTypes.GlobalReference, + bool allowFmtAll = false, bool allowFmt0 = false, + bool allowFmt1 = false, bool allowFmt2 = false) + { + // access and defaults? + if (cell == null || cell.Trim().Length < 1) + return null; + + // format == 1 + if (allowFmtAll || allowFmt1) + { + var m = Regex.Match(cell, @"\((\w+)\)( ?)(.*)$"); + if (m.Success) + { + return new Key( + Stringification.KeyTypesFromString(m.Groups[1].ToString()) ?? KeyTypes.GlobalReference, + m.Groups[3].ToString()); + } + } + + // format == 2 + if (allowFmtAll || allowFmt2) + { + var m = Regex.Match(cell, @"( ?)(.*)$"); + if (m.Success) + { + return new Key( + typeIfNotSet, m.Groups[2].ToString()); + } + } + + // format == 0 + if (allowFmtAll || allowFmt0) + { + var m = Regex.Match(cell, @"\[(\w+),( ?)(.*)\]"); + if (m.Success) + { + return new Key( + Stringification.KeyTypesFromString(m.Groups[1].ToString()) ?? KeyTypes.GlobalReference, + m.Groups[3].ToString()); + } + } + + // no + return null; + } + + // ------------------------------------------------------------------------------------------------------------- + #region Handling with enums for KeyTypes + + // see: https://stackoverflow.com/questions/27372816/how-to-read-the-value-for-an-enummember-attribute + //public static string? GetEnumMemberValue(this T value) + // where T : Enum + //{ + // return typeof(T) + // .GetTypeInfo() + // .DeclaredMembers + // .SingleOrDefault(x => x.Name == value.ToString()) + // ?.GetCustomAttribute(false) + // ?.Value; + //} + + //public static KeyTypes? MapFrom(AasReferables input) + //{ + // var st = input.GetEnumMemberValue(); + // var res = Stringification.KeyTypesFromString(st); + // return res; + //} + + //public static List MapFrom(IEnumerable input) + //{ + // List res = new(); + // foreach (var i in input) + // { + // var x = MapFrom(i); + // if (x.HasValue) + // res.Add(x.Value); + // } + // return res; + //} + + //public static List GetAllKeyTypesForAasReferables() + // => ExtendKey.MapFrom(Enum.GetValues(typeof(AasReferables)).OfType()); + + #endregion + + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendKeyList.cs b/src/AasxCsharpLibrary/Extensions/ExtendKeyList.cs new file mode 100644 index 000000000..86d899062 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendKeyList.cs @@ -0,0 +1,183 @@ +using AasCore.Aas3_0_RC02; +using AasxCompatibilityModels; +using AdminShellNS; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.Serialization; +using System.Text.RegularExpressions; +using Extensions; + +namespace Extensions +{ + public static class ExtendKeyList + { + public static bool IsEmpty(this List keys) + { + return keys.Count < 1; + } + + public static bool Matches(this List keys, List other, MatchMode matchMode = MatchMode.Strict) + { + if (other == null || other.Count != keys.Count) + return false; + + var same = true; + for (int i = 0; i < keys.Count; i++) + same = same && keys[i].Matches(other[i], matchMode); + + return same; + } + + public static List ReplaceLastKey(this List keys,List newKeys) + { + var res = new List(keys); + if (res.Count < 1 || newKeys == null || newKeys.Count < 1) + return res; + + res.Remove(res.Last()); + res.AddRange(newKeys); + return res; + } + + public static bool StartsWith(this List keyList, List otherKeyList) + { + if (otherKeyList == null || otherKeyList.Count == 0) + return false; + + // simply test element-wise + for (int i = 0; i < otherKeyList.Count; i++) + { + // does head have more elements than this list? + if (i >= keyList.Count) + return false; + + if (!otherKeyList[i].Matches(keyList[i])) + return false; + } + + // ok! + return true; + } + + public static bool StartsWith(this List keyList,List head, bool emptyIsTrue = false, + MatchMode matchMode = MatchMode.Relaxed) + { + // access + if (head == null) + return false; + if (head.Count == 0) + return emptyIsTrue; + + // simply test element-wise + for (int i = 0; i < head.Count; i++) + { + // does head have more elements than this list? + if (i >= keyList.Count) + return false; + + if (!head[i].Matches(keyList[i], matchMode)) + return false; + } + + // ok! + return true; + } + + public static string ToStringExtended(this List keys, int format = 1, string delimiter = ",") + { + return string.Join(delimiter, keys.Select((k) => k.ToStringExtended(format))); + } + + public static void Validate(this List keys, AasValidationRecordList results, + IReferable container) + { + // access + if (results == null || keys == null || container == null) + return; + + // iterate thru + var idx = 0; + while (idx < keys.Count) + { + var act = keys[idx].Validate(results, container); + if (act == AasValidationAction.ToBeDeleted) + { + keys.RemoveAt(idx); + continue; + } + idx++; + } + } + + public static bool MatchesSetOfTypes(this List key, IEnumerable set) + { + var res = true; + foreach (var kt in key) + if (!key.MatchesSetOfTypes(set)) + res = false; + return res; + } + + public static List Parse(string input) + { + // access + if (input == null) + return null; + + // split + var parts = input.Split(',', ';'); + var kl = new List(); + + foreach (var p in parts) + { + var k = ExtendKey.Parse(p); + if (k != null) + kl.Add(k); + } + + return kl; + } + + /// + /// Take only idShort, ignore all other key-types and create a '/'-separated list + /// + /// Empty string or list of idShorts + public static string BuildIdShortPath(this List keyList, + int startPos = 0, int count = int.MaxValue) + { + if (keyList == null || startPos >= keyList.Count) + return ""; + int nr = 0; + var res = ""; + for (int i = startPos; i < keyList.Count && nr < count; i++) + { + nr++; + //// if (keyList[i].Type.Trim().ToLower() == Key.IdShort.Trim().ToLower()) + { + if (res != "") + res += "/"; + res += keyList[i].Value; + } + } + return res; + } + + public static List SubList(this List keyList, + int startPos, int count = int.MaxValue) + { + var res = new List(); + if (startPos >= keyList.Count()) + return res; + int nr = 0; + for (int i = startPos; i < keyList.Count() && nr < count; i++) + { + nr++; + res.Add(keyList[i]); + } + return res; + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendKeyTypes.cs b/src/AasxCsharpLibrary/Extensions/ExtendKeyTypes.cs new file mode 100644 index 000000000..2b00c5fd1 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendKeyTypes.cs @@ -0,0 +1,22 @@ +using AasCore.Aas3_0_RC02; +using AdminShellNS; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.Serialization; + +namespace Extensions +{ + public static class ExtendKeyTypes + { + public static bool IsSME(this KeyTypes keyType) + { + foreach (var kt in Constants.AasSubmodelElementsAsKeys) + if (kt.HasValue && kt.Value == keyType) + return true; + return false; + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendLangString.cs b/src/AasxCsharpLibrary/Extensions/ExtendLangString.cs new file mode 100644 index 000000000..1dc8f9504 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendLangString.cs @@ -0,0 +1,35 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendLangString + { + // constants + public static string LANG_DEFAULT = "en"; + + // MIHO: not required, see ExtendLangStringSte + //public static string GetDefaultString(this List langStrings, string defaultLang = null) + //{ + // // start + // if (defaultLang == null) + // defaultLang = "en"; + // defaultLang = defaultLang.Trim().ToLower(); + // string res = null; + + // // search + // foreach (var ls in langStrings) + // if (ls.Language.Trim().ToLower() == defaultLang) + // res = ls.Text; + // if (res == null && langStrings.Count > 0) + // res = langStrings[0].Text; + + // // found? + // return res; + //} + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendLangStringSet.cs b/src/AasxCsharpLibrary/Extensions/ExtendLangStringSet.cs new file mode 100644 index 000000000..3b9a74e3e --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendLangStringSet.cs @@ -0,0 +1,175 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Extensions +{ + public static class ExtendLangStringSet + { + #region AasxPackageExplorer + + public static bool IsValid(this List langStringSet) + { + if(langStringSet != null && langStringSet.Count >=1) + { + return true; + } + + return false; + } + + #endregion + public static bool IsEmpty(this List langStringSet) + { + if (langStringSet == null || langStringSet.Count == 0) + { + return true; + } + + return false; + } + public static string GetDefaultString(this List langStringSet, string defaultLang = null) + { + // start + if (defaultLang == null) + defaultLang = "en"; //Default Lang in old implementation is en + + string res = null; + + // search + foreach (var langString in langStringSet) + if (langString.Language.Equals(defaultLang, StringComparison.OrdinalIgnoreCase)) + res = langString.Text; + + if (res == null && langStringSet.Count > 0) + res = langStringSet[0].Text; + + // found? + return res; + } + + public static List Create(string language, string text) + { + return new List { new LangString(language, text) }; + } + + public static List CreateManyFromStringArray(string[] s) + { + if (s == null) + return null; + var r = new List(); + var i = 0; + while ((i + 1) < s.Length) + { + r.Add(new LangString(s[i], s[i + 1])); + i += 2; + } + return r; + } + + // TODO (Jui, 2023-01-05): Check why the generic Copy does not apply here?! + public static List Copy(this List original) + { + var res = new List(); + if (original != null) + foreach (var o in original) + res.Add(o.Copy()); + return res; + } + + public static List Set(this List lss, string lang, string text) + { + foreach (var ls in lss) + if (ls.Language.Trim().ToLower() == lang?.Trim().ToLower()) + { + ls.Text = text; + return lss; + } + lss.Add(new LangString(lang, text)); + return lss; + } + + public static List ConvertFromV20( + this List langStringSet, + AasxCompatibilityModels.AdminShellV20.LangStringSet sourceLangStrings) + { + + //if (!sourceLangStrings.langString.IsNullOrEmpty()) + if (sourceLangStrings.langString!= null && sourceLangStrings.langString.Count != 0) + { + langStringSet = new List(); + foreach (var sourceLangString in sourceLangStrings.langString) + { + var langString = new LangString(sourceLangString.lang, sourceLangString.str); + langStringSet.Add(langString); + } + } + return langStringSet; + } + + public static List ConvertFromV20( + this List lss, + AasxCompatibilityModels.AdminShellV20.LangStringSetIEC61360 src) + { + lss = new List(); + //if (!sourceLangStrings.langString.IsNullOrEmpty()) + if (src != null && src.Count != 0) + { + foreach (var sourceLangString in src) + { + //Remove ? in the end added by AdminShellV20, to avoid verification error + string lang= sourceLangString.lang; + if(!string.IsNullOrEmpty(sourceLangString.lang) && sourceLangString.lang.EndsWith("?")) + { + lang = sourceLangString.lang.Remove(sourceLangString.lang.Length -1); + } + var langString = new LangString(lang, sourceLangString.str); + lss.Add(langString); + } + } + else + { + //set default preferred name + lss.Add(new LangString("en", "")); + } + return lss; + } + + public static List Parse(string cell) + { + // access + if (cell == null) + return null; + + // iterative approach + var res = new List(); + while (true) + { + // trivial case and finite end + if (!cell.Contains("@")) + { + if (cell.Trim() != "") + res.Add(new LangString(ExtendLangString.LANG_DEFAULT, cell)); + break; + } + + // OK, pick the next couple + var m = Regex.Match(cell, @"(.*?)@(\w+)", RegexOptions.Singleline); + if (!m.Success) + { + // take emergency exit? + res.Add(new LangString("??", cell)); + break; + } + + // use the match and shorten cell .. + res.Add(new LangString(m.Groups[2].ToString(), m.Groups[1].ToString().Trim())); + cell = cell.Substring(m.Index + m.Length); + } + + return res; + } + + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendModelKind.cs b/src/AasxCsharpLibrary/Extensions/ExtendModelKind.cs new file mode 100644 index 000000000..142f91c65 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendModelKind.cs @@ -0,0 +1,33 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AdminShellNS; + +namespace Extensions +{ + public static class ExtendModelKind + { + public static void Validate(this ModelingKind modelingKind, AasValidationRecordList results, IReferable container) + { + // access + if (results == null || container == null) + return; + + // check + if (modelingKind != ModelingKind.Template && modelingKind != ModelingKind.Instance) + { + // violation case + results.Add(new AasValidationRecord( + AasValidationSeverity.SchemaViolation, container, + $"ModelingKind: enumeration value neither Template nor Instance", + () => + { + modelingKind = ModelingKind.Instance; + })); + } + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendMultiLanguageProperty.cs b/src/AasxCsharpLibrary/Extensions/ExtendMultiLanguageProperty.cs new file mode 100644 index 000000000..6dd634852 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendMultiLanguageProperty.cs @@ -0,0 +1,127 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendMultiLanguageProperty + { + #region AasxPackageExplorer + + public static void ValueFromText(this MultiLanguageProperty multiLanguageProperty, string text, string defaultLang) + { + multiLanguageProperty.Value ??= new List(); + + multiLanguageProperty.Value.Add(new LangString(defaultLang == null? "en" : defaultLang, text)); + } + + #endregion + + public static string ValueAsText(this MultiLanguageProperty multiLanguageProperty, string defaultLang = null) + { + //TODO: need to check/test again + //return "" + multiLanguageProperty.Value?.LangStrings.FirstOrDefault().Text; + return "" + multiLanguageProperty.Value?.GetDefaultString(defaultLang); + } + + public static MultiLanguageProperty ConvertFromV20(this MultiLanguageProperty property, AasxCompatibilityModels.AdminShellV20.MultiLanguageProperty sourceProperty) + { + if (sourceProperty == null) + { + return null; + } + + if (sourceProperty.valueId != null) + { + var keyList = new List(); + foreach (var refKey in sourceProperty.valueId.Keys) + { + //keyList.Add(new Key(ExtensionsUtil.GetKeyTypeFromString(refKey.type), refKey.value)); + var keyType = Stringification.KeyTypesFromString(refKey.type); + if (keyType != null) + { + keyList.Add(new Key((KeyTypes)keyType, refKey.value)); + } + else + { + Console.WriteLine($"KeyType value not found for property {property.IdShort}"); + } + } + property.ValueId = new Reference(ReferenceTypes.GlobalReference, keyList); + } + + var newLangStrings = new List(); + + List newLangStringSet = new(newLangStrings); + + property.Value = newLangStringSet.ConvertFromV20(sourceProperty.value); + + return property; + + } + + public static MultiLanguageProperty UpdateFrom( + this MultiLanguageProperty elem, ISubmodelElement source) + { + if (source == null) + return elem; + + ((ISubmodelElement)elem).UpdateFrom(source); + + if (source is Property srcProp) + { + elem.Value = new List { new LangString("EN?", srcProp.Value) }; + if (srcProp.ValueId != null) + elem.ValueId = srcProp.ValueId.Copy(); + } + + if (source is MultiLanguageProperty srcMlp) + { + if (srcMlp.Value != null) + elem.Value = srcMlp.Value.Copy(); + if (srcMlp.ValueId != null) + elem.ValueId = srcMlp.ValueId.Copy(); + } + + if (source is AasCore.Aas3_0_RC02.Range srcRng) + { + if (srcRng.Min != null) + elem.Value = new List { new LangString("EN?", srcRng.Min) }; + } + + if (source is File srcFile) + { + elem.Value = new List { new LangString("EN?", srcFile.Value) }; + } + + return elem; + } + + public static MultiLanguageProperty Set(this MultiLanguageProperty mlp, + List ls) + { + mlp.Value = ls; + return mlp; + } + + public static MultiLanguageProperty Set(this MultiLanguageProperty mlp, + LangString ls) + { + if (ls == null) + return mlp; + if (mlp.Value == null) + mlp.Value = new List(); + mlp.Value.Set(ls.Language, ls.Text); + return mlp; + } + + public static MultiLanguageProperty Set(this MultiLanguageProperty mlp, + string lang, string str) + { + return mlp.Set(new LangString(lang, str)); + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendObject.cs b/src/AasxCsharpLibrary/Extensions/ExtendObject.cs new file mode 100644 index 000000000..2f0db29c2 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendObject.cs @@ -0,0 +1,137 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Extensions.ArrayExtensions; + +namespace Extensions +{ + public static class ExtendObject + { + private static readonly MethodInfo CloneMethod = typeof(Object).GetMethod("MemberwiseClone", BindingFlags.NonPublic | BindingFlags.Instance); + + public static bool IsPrimitive(this Type type) + { + if (type == typeof(String)) return true; + return (type.IsValueType & type.IsPrimitive); + } + + public static Object Copy(this Object originalObject) + { + return InternalCopy(originalObject, new Dictionary(new ReferenceEqualityComparer())); + } + + private static Object InternalCopy(Object originalObject, IDictionary visited) + { + if (originalObject == null) return null; + var typeToReflect = originalObject.GetType(); + if (IsPrimitive(typeToReflect)) return originalObject; + if (visited.ContainsKey(originalObject)) return visited[originalObject]; + if (typeof(Delegate).IsAssignableFrom(typeToReflect)) return null; + var cloneObject = CloneMethod.Invoke(originalObject, null); + if (typeToReflect.IsArray) + { + var arrayType = typeToReflect.GetElementType(); + if (IsPrimitive(arrayType) == false) + { + Array clonedArray = (Array)cloneObject; + clonedArray.ForEach((array, indices) => array.SetValue(InternalCopy(clonedArray.GetValue(indices), visited), indices)); + } + + } + visited.Add(originalObject, cloneObject); + CopyFields(originalObject, visited, cloneObject, typeToReflect); + RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect); + return cloneObject; + } + + private static void RecursiveCopyBaseTypePrivateFields(object originalObject, IDictionary visited, object cloneObject, Type typeToReflect) + { + if (typeToReflect.BaseType != null) + { + RecursiveCopyBaseTypePrivateFields(originalObject, visited, cloneObject, typeToReflect.BaseType); + CopyFields(originalObject, visited, cloneObject, typeToReflect.BaseType, BindingFlags.Instance | BindingFlags.NonPublic, info => info.IsPrivate); + } + } + + private static void CopyFields(object originalObject, IDictionary visited, object cloneObject, Type typeToReflect, BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.FlattenHierarchy, Func filter = null) + { + foreach (FieldInfo fieldInfo in typeToReflect.GetFields(bindingFlags)) + { + if (filter != null && filter(fieldInfo) == false) continue; + if (IsPrimitive(fieldInfo.FieldType)) continue; + var originalFieldValue = fieldInfo.GetValue(originalObject); + var clonedFieldValue = InternalCopy(originalFieldValue, visited); + fieldInfo.SetValue(cloneObject, clonedFieldValue); + } + } + public static T Copy(this T original) + { + return (T)Copy((Object)original); + } + } + + public class ReferenceEqualityComparer : EqualityComparer + { + public override bool Equals(object x, object y) + { + return ReferenceEquals(x, y); + } + public override int GetHashCode(object obj) + { + if (obj == null) return 0; + return obj.GetHashCode(); + } + } + + namespace ArrayExtensions + { + public static class ArrayExtensions + { + public static void ForEach(this Array array, Action action) + { + if (array.LongLength == 0) return; + ArrayTraverse walker = new ArrayTraverse(array); + do action(array, walker.Position); + while (walker.Step()); + } + } + + internal class ArrayTraverse + { + public int[] Position; + private int[] maxLengths; + + public ArrayTraverse(Array array) + { + maxLengths = new int[array.Rank]; + for (int i = 0; i < array.Rank; ++i) + { + maxLengths[i] = array.GetLength(i) - 1; + } + Position = new int[array.Rank]; + } + + public bool Step() + { + for (int i = 0; i < Position.Length; ++i) + { + if (Position[i] < maxLengths[i]) + { + Position[i]++; + for (int j = 0; j < i; j++) + { + Position[j] = 0; + } + return true; + } + } + return false; + } + } + } + +} + diff --git a/src/AasxCsharpLibrary/Extensions/ExtendOperation.cs b/src/AasxCsharpLibrary/Extensions/ExtendOperation.cs new file mode 100644 index 000000000..12ad52979 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendOperation.cs @@ -0,0 +1,148 @@ +using AasCore.Aas3_0_RC02; +using AdminShellNS.Display; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendOperation + { + #region AasxPackageExplorer + + public static object AddChild(this Operation operation, ISubmodelElement childSubmodelElement, EnumerationPlacmentBase placement = null) + { + // not enough information to select list of children? + var pl = placement as EnumerationPlacmentOperationVariable; + if (childSubmodelElement == null || pl == null) + return null; + + // ok, use information + var ov = new OperationVariable(childSubmodelElement); + + if (childSubmodelElement != null) + childSubmodelElement.Parent = operation; + + if (pl.Direction == OperationVariableDirection.In) + { + operation.InputVariables ??= new List(); + operation.InputVariables.Add(ov); + } + + if (pl.Direction == OperationVariableDirection.Out) + { + operation.OutputVariables ??= new List(); + operation.OutputVariables.Add(ov); + } + + if (pl.Direction == OperationVariableDirection.InOut) + { + operation.InoutputVariables ??= new List(); + operation.InoutputVariables.Add(ov); + } + + return ov; + } + + public static EnumerationPlacmentBase GetChildrenPlacement(this Operation operation, ISubmodelElement child) + { + // trivial + if (child == null) + return null; + + // search + OperationVariableDirection? dir = null; + OperationVariable opvar = null; + if (operation.InputVariables != null) + foreach (var ov in operation.InputVariables) + if (ov?.Value == child) + { + dir = OperationVariableDirection.In; + opvar = ov; + } + + if (operation.OutputVariables != null) + foreach (var ov in operation.OutputVariables) + if (ov?.Value == child) + { + dir = OperationVariableDirection.Out; + opvar = ov; + } + + if (operation.InoutputVariables != null) + foreach (var ov in operation.InoutputVariables) + if (ov?.Value == child) + { + dir = OperationVariableDirection.InOut; + opvar = ov; + } + + // found + if (!dir.HasValue) + return null; + return new EnumerationPlacmentOperationVariable() + { + Direction = dir.Value, + OperationVariable = opvar + }; + } + + public static List GetVars(this Operation op, OperationVariableDirection dir) + { + if (dir == OperationVariableDirection.In) + return op.InputVariables; + if (dir == OperationVariableDirection.Out) + return op.OutputVariables; + return op.InoutputVariables; + } + + public static List SetVars( + this Operation op, OperationVariableDirection dir, List value) + { + if (dir == OperationVariableDirection.In) + { + op.InputVariables = value; + return op.InputVariables; + } + if (dir == OperationVariableDirection.Out) + { + op.OutputVariables = value; + return op.OutputVariables; + } + + op.InoutputVariables = value; + return op.InoutputVariables; + } + + #endregion + + public static Operation UpdateFrom( + this Operation elem, ISubmodelElement source) + { + if (source == null) + return elem; + + ((ISubmodelElement)elem).UpdateFrom(source); + + if (source is SubmodelElementCollection srcColl) + { + if (srcColl.Value != null) + elem.InputVariables = srcColl.Value.Copy().Select( + (isme) => new OperationVariable(isme)).ToList(); + } + + if (source is SubmodelElementCollection srcList) + { + if (srcList.Value != null) + elem.InputVariables = srcList.Value.Copy().Select( + (isme) => new OperationVariable(isme)).ToList(); + } + + return elem; + } + } +} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendProperty.cs b/src/AasxCsharpLibrary/Extensions/ExtendProperty.cs similarity index 61% rename from src/AasxServerStandardBib/Extenstions/ExtendProperty.cs rename to src/AasxCsharpLibrary/Extensions/ExtendProperty.cs index ff32d18be..b9e9d4e4d 100644 --- a/src/AasxServerStandardBib/Extenstions/ExtendProperty.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendProperty.cs @@ -1,19 +1,58 @@ using AasCore.Aas3_0_RC02; using System; using System.Collections.Generic; +using System.Globalization; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Extenstions +namespace Extensions { public static class ExtendProperty { + #region AasxPackageExplorer + + public static void ValueFromText(this Property property, string text) + { + property.Value = text; + } + + #endregion + public static bool IsValueTrue(this Property property) + { + if(property.ValueType == DataTypeDefXsd.Boolean) + { + if(property.Value.Equals("true", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + + return false; + } + public static string ValueAsText(this Property property) { return "" + property.Value; } + public static double? ValueAsDouble(this Property prop) + { + // pointless + if (prop.Value == null || prop.Value.Trim() == "") + return null; + + // type? + if (!ExtendDataElement.ValueTypes_Number.Contains(prop.ValueType)) + return null; + + // try convert + if (double.TryParse(prop.Value, NumberStyles.Any, CultureInfo.InvariantCulture, out double dbl)) + return dbl; + + // no + return null; + } public static Property ConvertFromV10(this Property property, AasxCompatibilityModels.AdminShellV10.Property sourceProperty) { if (sourceProperty == null) @@ -91,6 +130,47 @@ public static Property ConvertFromV20(this Property property, AasxCompatibilityM return property; } + public static Property UpdateFrom(this Property elem, ISubmodelElement source) + { + if (source == null) + return elem; + + ((ISubmodelElement)elem).UpdateFrom(source); + + if (source is Property srcProp) + { + elem.ValueType = srcProp.ValueType; + elem.Value = srcProp.Value; + if (srcProp.ValueId != null) + elem.ValueId = srcProp.ValueId.Copy(); + } + + if (source is AasCore.Aas3_0_RC02.Range srcRng) + { + elem.ValueType = srcRng.ValueType; + elem.Value = srcRng.Min; + } + + if (source is MultiLanguageProperty srcMlp) + { + elem.ValueType = DataTypeDefXsd.String; + elem.Value = "" + srcMlp.Value?.GetDefaultString(); + if (srcMlp.ValueId != null) + elem.ValueId = srcMlp.ValueId.Copy(); + } + + if (source is File srcFile) + { + elem.ValueType = DataTypeDefXsd.String; + elem.Value = "" + srcFile.Value; + } + + return elem; + } + + // MIHO: Jui, why was this required? +#if OLD + public static void UpdatePropertyFrom(this Property property, Property sourceProperty) { if (sourceProperty.Extensions != null) @@ -133,11 +213,11 @@ public static void UpdatePropertyFrom(this Property property, Property sourcePro { property.Qualifiers = sourceProperty.Qualifiers; } - if (sourceProperty.DataSpecifications != null) + if (sourceProperty.EmbeddedDataSpecifications != null) { - property.DataSpecifications = sourceProperty.DataSpecifications; + property.EmbeddedDataSpecifications = sourceProperty.EmbeddedDataSpecifications; } - if (sourceProperty.ValueType != null) + if (true) { property.ValueType = sourceProperty.ValueType; } @@ -150,5 +230,37 @@ public static void UpdatePropertyFrom(this Property property, Property sourcePro property.Value = sourceProperty.Value; } } +#endif + + public static Property Set(this Property prop, + DataTypeDefXsd valueType = DataTypeDefXsd.String, string value = "") + { + prop.ValueType = valueType; + prop.Value = value; + return prop; + } + + public static Property Set(this Property prop, + KeyTypes type, string value) + { + prop.ValueId = ExtendReference.CreateFromKey(new Key(type, value)); + return prop; + } + + public static Property Set(this Property prop, + Qualifier q) + { + if (q != null) + prop.Add(q); + return prop; + } + + public static Property Set(this Property prop, + Extension ext) + { + if (ext != null) + prop.Add(ext); + return prop; + } } } diff --git a/src/AasxServerStandardBib/Extenstions/ExtendQualifier.cs b/src/AasxCsharpLibrary/Extensions/ExtendQualifier.cs similarity index 54% rename from src/AasxServerStandardBib/Extenstions/ExtendQualifier.cs rename to src/AasxCsharpLibrary/Extensions/ExtendQualifier.cs index d2cf2e309..44a495d65 100644 --- a/src/AasxServerStandardBib/Extenstions/ExtendQualifier.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendQualifier.cs @@ -1,11 +1,13 @@ using AasCore.Aas3_0_RC02; +using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; +using System.Text.RegularExpressions; using System.Threading.Tasks; -namespace Extenstions +namespace Extensions { public static class ExtendQualifier { @@ -97,5 +99,94 @@ public static Qualifier ConvertFromV20(this Qualifier qualifier, AasxCompatibili return qualifier; } + + // ReSharper disable MethodOverloadWithOptionalParameter .. this seems to work, anyhow + // ReSharper disable RedundantArgumentDefaultValue + public static string ToStringExtended(this Qualifier q, + int format = 0, string delimiter = ",") + { + var res = "" + q.Type; + if (res == "") + res += "" + q.SemanticId?.ToStringExtended(format, delimiter); + + if (q.Value != null) + res += " = " + q.Value; + else if (q.ValueId != null) + res += " = " + q.ValueId?.ToStringExtended(format, delimiter); + + return res; + } + // ReSharper enable MethodOverloadWithOptionalParameter + // ReSharper enable RedundantArgumentDefaultValue + + // + // + // List + // + // + + #region QualifierCollection + + public static Qualifier FindQualifierOfType(this List qualifiers, string qualifierType) + { + if(qualifierType == null) + { + return null; + } + + foreach(var qualifier in qualifiers) + { + if(qualifier != null && qualifierType.Equals(qualifier.Type)) + { + return qualifier; + } + } + + return null; + } + + // ReSharper disable MethodOverloadWithOptionalParameter .. this seems to work, anyhow + // ReSharper disable RedundantArgumentDefaultValue + public static string ToStringExtended(this List qualifiers, + int format = 0, string delimiter = ";", string referencesDelimiter = ",") + { + var res = ""; + foreach (var q in qualifiers) + { + if (res != "") + res += delimiter; + res += q.ToStringExtended(format, referencesDelimiter); + } + return res; + } + // ReSharper enable MethodOverloadWithOptionalParameter + // ReSharper enable RedundantArgumentDefaultValue + + public static Qualifier FindType(this List qualifiers, string type) + { + if (type == null || qualifiers == null) + return null; + foreach (var q in qualifiers) + if (q != null && q.Type != null && q.Type.Trim() == type.Trim()) + return q; + return null; + } + + public static Qualifier Parse(string input) + { + var m = Regex.Match(input, @"\s*([^,]*)(,[^=]+){0,1}\s*=\s*([^,]*)(,.+){0,1}\s*"); + if (!m.Success) + return null; + + return new Qualifier( + valueType: DataTypeDefXsd.String, + type: m.Groups[1].ToString().Trim(), + semanticId: ExtendReference.Parse(m.Groups[1].ToString().Trim()), + value: m.Groups[3].ToString().Trim(), + valueId: ExtendReference.Parse(m.Groups[1].ToString().Trim()) + ); + } + + #endregion } } diff --git a/src/AasxCsharpLibrary/Extensions/ExtendRange.cs b/src/AasxCsharpLibrary/Extensions/ExtendRange.cs new file mode 100644 index 000000000..e67c7b40c --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendRange.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AAS = AasCore.Aas3_0_RC02; + +namespace Extensions +{ + public static class ExtendRange + { + public static string ValueAsText(this AasCore.Aas3_0_RC02.Range range) + { + return "" + range.Min + " .. " + range.Max; + } + + public static AasCore.Aas3_0_RC02.Range ConvertFromV20(this AasCore.Aas3_0_RC02.Range range, AasxCompatibilityModels.AdminShellV20.Range sourceRange) + { + if (sourceRange == null) + { + return null; + } + + var propertyType = AAS.Stringification.DataTypeDefXsdFromString("xs:" + sourceRange.valueType); + if (propertyType != null) + { + range.ValueType = (AAS.DataTypeDefXsd)propertyType; + } + else + { + Console.WriteLine($"ValueType {sourceRange.valueType} not found for property {range.IdShort}"); + } + + range.Max = sourceRange.max; + range.Min = sourceRange.min; + + return range; + } + + public static AAS.Range UpdateFrom(this AAS.Range elem, AAS.ISubmodelElement source) + { + if (source == null) + return elem; + + ((AAS.ISubmodelElement)elem).UpdateFrom(source); + + if (source is AAS.Property srcProp) + { + elem.ValueType = srcProp.ValueType; + elem.Min = srcProp.Value; + elem.Max = elem.Min; + } + + if (source is AAS.MultiLanguageProperty srcMlp) + { + elem.ValueType = AAS.DataTypeDefXsd.String; + elem.Min = "" + srcMlp.Value?.GetDefaultString(); + elem.Max = elem.Min; + } + + if (source is AAS.File srcFile) + { + elem.ValueType = AAS.DataTypeDefXsd.String; + elem.Min = "" + srcFile.Value; + elem.Max = elem.Min; + } + + return elem; + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendReference.cs b/src/AasxCsharpLibrary/Extensions/ExtendReference.cs new file mode 100644 index 000000000..ad4870212 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendReference.cs @@ -0,0 +1,263 @@ +using AasCore.Aas3_0_RC02; +using AdminShellNS.Exceptions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendReference + { + #region AasxPackageExplorer + + public static AasElementSelfDescription GetSelfDescription(this Reference reference) + { + return new AasElementSelfDescription("Reference", "Rfc", null, null); + } + + public static bool IsValid(this Reference reference) + { + return reference.Keys != null && !reference.Keys.IsEmpty(); + } + + /// + /// Formaly a static constructor. + /// Creates a Reference from a key, guessing Reference.Type. + /// + /// Given single Key + /// Reference with guessed type + public static Reference CreateFromKey(Key k) + { + var res = new Reference(ReferenceTypes.GlobalReference, new List { k }); + res.Type = res.GuessType(); + return res; + } + + /// + /// Formaly a static constructor. + /// Creates a Reference from a key, guessing Reference.Type. + /// + public static Reference CreateFromKey(KeyTypes type, + string value) + { + var res = new Reference(ReferenceTypes.GlobalReference, + new List { new Key(type, value) }); + res.Type = res.GuessType(); + return res; + } + + /// + /// Formaly a static constructor. + /// Creates a Reference from a list of keys, guessing Reference.Type. + /// + /// + /// + public static Reference CreateNew(List lk) + { + var res = new Reference(ReferenceTypes.GlobalReference, new List()); + if (lk == null) + return res; + res.Keys.AddRange(lk.Copy()); + res.Type = res.GuessType(); + return res; + } + + // TODO (Jui, 2023-01-05): Check why the generic Copy does not apply here?! + public static Reference Copy(this Reference original) + { + var res = new Reference(original.Type, new List()); + if (original != null) + foreach (var o in original.Keys) + res.Add(o.Copy()); + return res; + } + + + public static Reference Parse(string input) + { + var res = new Reference(ReferenceTypes.GlobalReference, new List()); + if (input == null) + return res; + + res.Keys = ExtendKeyList.Parse(input); + res.Type = res.GuessType(); + return res; + } + + //This is alternative for operator overloding method +, as operator overloading cannot be done in extension classes + public static Reference Add(this Reference a, Reference b) + { + a.Keys?.AddRange(b?.Keys); + return a; + } + + public static Reference Add(this Reference a, Key k) + { + if (k != null) + a.Keys?.Add(k); + return a; + } + + public static bool IsEmpty(this Reference reference) + { + if (reference == null || reference.Keys == null || reference.Keys.Count < 1) + { + return true; + } + + return false; + } + + #endregion + + public static bool Matches (this Reference reference, KeyTypes keyType, string id, MatchMode matchMode = MatchMode.Strict) + { + if(reference.IsEmpty()) + { + return false; + } + + if(reference.Keys.Count == 1) + { + var key = reference.Keys[0]; + return key.Matches(new Key(keyType, id), matchMode); + } + + return false; + } + + public static bool Matches(this Reference reference, string id) + { + if (string.IsNullOrEmpty(id)) + { + return false; + } + + if (reference.Keys.Count == 1) // As per old implementation + { + if (reference.Keys[0].Value == id) + return true; + } + + return false; + } + + public static bool Matches(this Reference reference, Reference otherReference, MatchMode matchMode = MatchMode.Strict) + { + if (reference.Keys == null || reference.Keys.Count == 0 || otherReference?.Keys == null || otherReference.Keys.Count == 0) + { + return false; + } + + bool match = true; + for (int i = 0; i < reference.Keys.Count; i++) + { + match = match && reference.Keys[i].Matches(otherReference.Keys[i], matchMode); + } + + return match; + } + + public static bool MatchesExactlyOneKey(this Reference reference, Key key, MatchMode matchMode = MatchMode.Strict) + { + if(key == null || reference.Keys == null || reference.Keys.Count != 1) + { + return false; + } + + var referenceKey = reference.Keys[0]; + return referenceKey.Matches(key, matchMode); + } + + public static string GetAsIdentifier(this Reference reference) + { + if (reference.Type == ReferenceTypes.GlobalReference) // Applying only to Global Reference, based on older implementation, TODO:Make it Generic + { + if (reference.Keys == null || reference.Keys.Count < 1) + { + return null; + } + + return reference.Keys[0].Value; + } + + return null; + } + + public static string MostSignificantInfo(this Reference reference) + { + if (reference.Keys.Count < 1) + { + return "-"; + } + + var i = reference.Keys.Count - 1; + var output = reference.Keys[i].Value; + if (reference.Keys[i].Type == KeyTypes.FragmentReference && i > 0) + output += reference.Keys[i - 1].Value; + return output; + } + + public static Key GetAsExactlyOneKey(this Reference reference) + { + if (reference.Keys == null || reference.Keys.Count != 1) + { + return null; + } + + var key = reference.Keys[0]; + return new Key(key.Type, key.Value); + } + + public static string ToStringExtended(this Reference reference, int format = 1, string delimiter = ",") + { + if(reference.Keys == null) + { + throw new NullValueException("Keys"); + } + + return reference.Keys.ToStringExtended(format, delimiter); + } + + public static ReferenceTypes GuessType(this Reference reference) + { + var setAasRefs = Constants.AasReferables.Where((kt) => kt != null).Select(kt => kt.Value).ToArray(); + var allAasRefs = true; + foreach (var k in reference.Keys) + if (!k.MatchesSetOfTypes(setAasRefs)) + allAasRefs = false; + if (allAasRefs) + return ReferenceTypes.ModelReference; + else + return ReferenceTypes.GlobalReference; + } + + public static int Count(this Reference rf) + { + return rf.Keys.Count; + } + + public static Key Last(this Reference rf) + { + return rf.Keys.Last(); + } + + public static string ListOfValues(this Reference rf, string delim) + { + string res = ""; + if (rf.Keys != null) + foreach (var x in rf.Keys) + { + if (x == null) + continue; + if (res != "") res += delim; + res += x.Value; + } + return res; + } + } + +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendReferenceElement.cs b/src/AasxCsharpLibrary/Extensions/ExtendReferenceElement.cs new file mode 100644 index 000000000..4fdc888a0 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendReferenceElement.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AAS = AasCore.Aas3_0_RC02; +using AasCore.Aas3_0_RC02; + +namespace Extensions +{ + public static class ExtendReferenceElement + { + public static AAS.ReferenceElement Set(this AAS.ReferenceElement elem, + Reference rf) + { + elem.Value = rf; + return elem; + } + + public static AAS.ReferenceElement UpdateFrom( + this AAS.ReferenceElement elem, AAS.ISubmodelElement source) + { + if (source == null) + return elem; + + ((AAS.ISubmodelElement)elem).UpdateFrom(source); + + if (source is AAS.RelationshipElement srcRel) + { + if (srcRel.First != null) + elem.Value = srcRel.First.Copy(); + } + + if (source is AAS.AnnotatedRelationshipElement srcRelA) + { + if (srcRelA.First != null) + elem.Value = srcRelA.First.Copy(); + } + + return elem; + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendRelationshipElement.cs b/src/AasxCsharpLibrary/Extensions/ExtendRelationshipElement.cs new file mode 100644 index 000000000..45dfa17b3 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendRelationshipElement.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using AAS = AasCore.Aas3_0_RC02; + +namespace Extensions +{ + public static class ExtendRelationshipElement + { + public static AAS.RelationshipElement Set(this AAS.RelationshipElement elem, + AAS.Reference first, AAS.Reference second) + { + elem.First = first; + elem.Second = second; + return elem; + } + + public static AAS.RelationshipElement UpdateFrom( + this AAS.RelationshipElement elem, AAS.ISubmodelElement source) + { + if (source == null) + return elem; + + ((AAS.ISubmodelElement)elem).UpdateFrom(source); + + if (source is AAS.ReferenceElement srcRef) + { + if (srcRef.Value != null) + elem.First = srcRef.Value.Copy(); + } + + if (source is AAS.AnnotatedRelationshipElement srcRelA) + { + if (srcRelA.First != null) + elem.First = srcRelA.First.Copy(); + } + + return elem; + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendSpecificAssetId.cs b/src/AasxCsharpLibrary/Extensions/ExtendSpecificAssetId.cs new file mode 100644 index 000000000..f52ac3bbd --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendSpecificAssetId.cs @@ -0,0 +1,45 @@ +using AasCore.Aas3_0_RC02; +using Extensions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Text; +using System.Threading.Tasks; + +namespace AdminShellNS.Extensions +{ + public static class ExtendSpecificAssetId + { + public static bool Matches(this SpecificAssetId specificAssetId, SpecificAssetId other) + { + if(specificAssetId == null) return false; + if(other == null) return false; + + //check mandatory parameters first + if(specificAssetId.Name != other.Name) return false; + if(specificAssetId.Value != other.Value) return false; + if(!specificAssetId.ExternalSubjectId.Matches(other.ExternalSubjectId)) return false; + + //TODO: jtikekar Check optional parameter i.e., Semantic Id and supplementatry semantic id + + return true; + } + + #region ListOfSpecificAssetIds + + public static bool ContainsSpecificAssetId(this List specificAssetIds, SpecificAssetId other) + { + if (specificAssetIds == null) return false; + if (other == null) return false; + + var foundIds = specificAssetIds.Where(assetId => assetId.Matches(other)); + if(foundIds.Any()) return true; + + return false; + } + + #endregion + + } +} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendStream.cs b/src/AasxCsharpLibrary/Extensions/ExtendStream.cs similarity index 95% rename from src/AasxServerStandardBib/Extenstions/ExtendStream.cs rename to src/AasxCsharpLibrary/Extensions/ExtendStream.cs index c69935c3b..fefe4af1f 100644 --- a/src/AasxServerStandardBib/Extenstions/ExtendStream.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendStream.cs @@ -5,7 +5,7 @@ using System.Text; using System.Threading.Tasks; -namespace Extenstions +namespace Extensions { public static class ExtendStream { diff --git a/src/AasxCsharpLibrary/Extensions/ExtendStringification.cs b/src/AasxCsharpLibrary/Extensions/ExtendStringification.cs new file mode 100644 index 000000000..cb554c921 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendStringification.cs @@ -0,0 +1,15 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendStringification + { + public static IEnumerable DataTypeXsdToStringArray() => + Enum.GetValues(typeof(DataTypeDefXsd)).OfType().Select((dt) => Stringification.ToString(dt)); + } +} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendSubmodel.cs b/src/AasxCsharpLibrary/Extensions/ExtendSubmodel.cs similarity index 56% rename from src/AasxServerStandardBib/Extenstions/ExtendSubmodel.cs rename to src/AasxCsharpLibrary/Extensions/ExtendSubmodel.cs index e3b63a949..3f07b4ff9 100644 --- a/src/AasxServerStandardBib/Extenstions/ExtendSubmodel.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendSubmodel.cs @@ -1,14 +1,113 @@ using AasCore.Aas3_0_RC02; +using AdminShellNS; +using AdminShellNS.Display; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace Extenstions +namespace Extensions { public static class ExtendSubmodel { + #region AasxPackageExplorer + + /// + /// Recurses on all Submodel elements of a Submodel or SME, which allows children. + /// The state object will be passed to the lambda function in order to provide + /// stateful approaches. Include this element, as well. + /// + /// State object to be provided to lambda. Could be null. + /// The lambda function as (state, parents, SME) + /// The lambda shall return TRUE in order to deep into recursion. + /// Include this element as well. parents will then + /// include this element as well! + public static void RecurseOnReferables(this Submodel submodel, + object state, Func, IReferable, bool> lambda, + bool includeThis = false) + { + var parents = new List(); + if (includeThis) + { + lambda(state, null, submodel); + parents.Add(submodel); + } + submodel.SubmodelElements?.RecurseOnReferables(state, parents, lambda); + } + + public static void Remove(this Submodel submodel, ISubmodelElement submodelElement) + { + if(submodel != null) + { + if(submodel.SubmodelElements != null) + { + submodel.SubmodelElements.Remove(submodelElement); + } + } + } + + public static object AddChild(this Submodel submodel,ISubmodelElement childSubmodelElement, EnumerationPlacmentBase placement = null) + { + if (childSubmodelElement == null) + return null; + submodel.SubmodelElements ??= new (); + if (childSubmodelElement != null) + childSubmodelElement.Parent = submodel; + submodel.SubmodelElements.Add(childSubmodelElement); + return childSubmodelElement; + } + + public static Tuple ToCaptionInfo(this Submodel submodel) + { + var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", submodel.IdShort, ""); + if (submodel.Administration != null) + caption += "V" + submodel.Administration.Version + "." + submodel.Administration.Revision; + var info = ""; + if (submodel.Id != null) + info = $"[{submodel.Id}]"; + return Tuple.Create(caption, info); + } + + public static IEnumerable FindAllReferences(this Submodel submodel) + { + // not nice: use temp list + var temp = new List(); + + // recurse + submodel.RecurseOnSubmodelElements(null, (state, parents, sme) => + { + if (sme is ReferenceElement re) + if (re.Value != null) + temp.Add(re.Value); + if (sme is RelationshipElement rl) + { + if (rl.First != null) + temp.Add(rl.First); + if (rl.Second != null) + temp.Add(rl.Second); + } + // recurse + return true; + }); + + // now, give back + foreach (var r in temp) + yield return new LocatedReference(submodel, r); + } + + #endregion + public static void Validate(this Submodel submodel,AasValidationRecordList results) + { + // access + if (results == null) + return; + + // check + submodel.BaseValidation(results); + submodel.Kind.Value.Validate(results,submodel); + submodel.SemanticId.Keys.Validate(results, submodel); + } public static Submodel ConvertFromV10(this Submodel submodel, AasxCompatibilityModels.AdminShellV10.Submodel sourceSubmodel, bool shallowCopy = false) { if (sourceSubmodel == null) @@ -104,36 +203,30 @@ public static Submodel ConvertFromV10(this Submodel submodel, AasxCompatibilityM } - public static Submodel ConvertFromV20(this Submodel submodel, AasxCompatibilityModels.AdminShellV20.Submodel sourceSubmodel, bool shallowCopy = false) + public static Submodel ConvertFromV20(this Submodel sm, AasxCompatibilityModels.AdminShellV20.Submodel srcSM, bool shallowCopy = false) { - if (sourceSubmodel == null) - { + if (srcSM == null) return null; - } - if (string.IsNullOrEmpty(sourceSubmodel.idShort)) - { - submodel.IdShort = ""; - } + if (string.IsNullOrEmpty(srcSM.idShort)) + sm.IdShort = ""; else - { - submodel.IdShort = sourceSubmodel.idShort; - } + sm.IdShort = srcSM.idShort; - if (sourceSubmodel.description != null) - { - submodel.Description = ExtensionsUtil.ConvertDescriptionFromV20(sourceSubmodel.description); - } + if (srcSM.identification?.id != null) + sm.Id = srcSM.identification.id; - if (sourceSubmodel.administration != null) - { - submodel.Administration = new AdministrativeInformation(version: sourceSubmodel.administration.version, revision: sourceSubmodel.administration.revision); - } + if (srcSM.description != null) + sm.Description = ExtensionsUtil.ConvertDescriptionFromV20(srcSM.description); - if (sourceSubmodel.semanticId != null) + if (srcSM.administration != null) + sm.Administration = new AdministrativeInformation( + version: srcSM.administration.version, revision: srcSM.administration.revision); + + if (srcSM.semanticId != null) { var keyList = new List(); - foreach (var refKey in sourceSubmodel.semanticId.Keys) + foreach (var refKey in srcSM.semanticId.Keys) { var keyType = Stringification.KeyTypesFromString(refKey.type); if (keyType != null) @@ -145,58 +238,60 @@ public static Submodel ConvertFromV20(this Submodel submodel, AasxCompatibilityM Console.WriteLine($"KeyType value {refKey.type} not found."); } } - submodel.SemanticId = new Reference(ReferenceTypes.GlobalReference, keyList); + sm.SemanticId = new Reference(ReferenceTypes.GlobalReference, keyList); } - if (sourceSubmodel.kind != null) + if (srcSM.kind != null) { - if (sourceSubmodel.kind.IsInstance) + if (srcSM.kind.IsInstance) { - submodel.Kind = ModelingKind.Instance; + sm.Kind = ModelingKind.Instance; } else { - submodel.Kind = ModelingKind.Template; + sm.Kind = ModelingKind.Template; } } - if (sourceSubmodel.qualifiers != null && sourceSubmodel.qualifiers.Count != 0) + if (srcSM.qualifiers != null && srcSM.qualifiers.Count != 0) { - if (submodel.Qualifiers == null) + if (sm.Qualifiers == null) { - submodel.Qualifiers = new List(); + sm.Qualifiers = new List(); } - foreach (var sourceQualifier in sourceSubmodel.qualifiers) + foreach (var sourceQualifier in srcSM.qualifiers) { var newQualifier = new Qualifier("", DataTypeDefXsd.String); newQualifier = newQualifier.ConvertFromV20(sourceQualifier); - submodel.Qualifiers.Add(newQualifier); + sm.Qualifiers.Add(newQualifier); } } - if (!shallowCopy && sourceSubmodel.submodelElements != null) + if (!shallowCopy && srcSM.submodelElements != null) { - if (submodel.SubmodelElements == null) + if (sm.SubmodelElements == null) { - submodel.SubmodelElements = new List(); + sm.SubmodelElements = new List(); } - foreach (var submodelElementWrapper in sourceSubmodel.submodelElements) + foreach (var submodelElementWrapper in srcSM.submodelElements) { var sourceSubmodelELement = submodelElementWrapper.submodelElement; ISubmodelElement outputSubmodelElement = null; if (sourceSubmodelELement != null) { outputSubmodelElement = outputSubmodelElement.ConvertFromV20(sourceSubmodelELement, shallowCopy); - submodel.SubmodelElements.Add(outputSubmodelElement); + sm.SubmodelElements.Add(outputSubmodelElement); } } } - return submodel; + // move Qualifiers to Extensions + sm.MigrateV20QualifiersToExtensions(); + return sm; } public static T FindFirstIdShortAs(this Submodel submodel, string idShort) where T : ISubmodelElement @@ -216,7 +311,8 @@ public static IEnumerable FindDeep(this Submodel submodel) foreach (var submodelElement in submodel.SubmodelElements) { - submodelElement.FindDeep(); + foreach (var x in submodelElement.FindDeep()) + yield return x; } } @@ -231,6 +327,25 @@ public static Reference GetModelReference(this Submodel submodel) return outputReference; } + /// + /// If instance, return semanticId as one key. + /// If template, return identification as key. + /// + public static Key GetSemanticKey(this Submodel submodel) + { + if (submodel.Kind == ModelingKind.Instance) + return submodel.SemanticId.GetAsExactlyOneKey(); + else + return new Key(KeyTypes.Submodel, submodel.Id); + } + + public static List SmeForWrite(this Submodel submodel) + { + if (submodel.SubmodelElements == null) + submodel.SubmodelElements = new(); + return submodel.SubmodelElements; + } + public static void RecurseOnSubmodelElements(this Submodel submodel, object state, Func, ISubmodelElement, bool> lambda) { submodel.SubmodelElements?.RecurseOnReferables(state, null, (o, par, rf) => @@ -267,7 +382,7 @@ public static void SetAllParents(this Submodel submodel, DateTime timestamp) SetParentsForSME(submodel, sme, timestamp); } - private static void SetParentsForSME(IReferable parent, ISubmodelElement submodelElement, DateTime timestamp) + public static void SetParentsForSME(IReferable parent, ISubmodelElement submodelElement, DateTime timestamp) { if (submodelElement == null) return; @@ -282,7 +397,7 @@ private static void SetParentsForSME(IReferable parent, ISubmodelElement submode } } - private static void SetParentsForSME(IReferable parent, ISubmodelElement submodelElement) + public static void SetParentsForSME(IReferable parent, ISubmodelElement submodelElement) { if (submodelElement == null) return; @@ -324,5 +439,17 @@ public static void Insert(this Submodel submodel, int index, ISubmodelElement su submodel.SubmodelElements.Insert(index, submodelElement); } + public static T CreateSMEForCD( + this Submodel sm, + ConceptDescription conceptDescription, string category = null, string idShort = null, + string idxTemplate = null, int maxNum = 999, bool addSme = false, bool isTemplate = false) + where T : ISubmodelElement + { + if (sm.SubmodelElements == null) + sm.SubmodelElements = new List(); + return sm.SubmodelElements.CreateSMEForCD( + conceptDescription, category, idShort, idxTemplate, maxNum, addSme, isTemplate); + } + } } diff --git a/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementCollection.cs b/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementCollection.cs new file mode 100644 index 000000000..c5ca34340 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementCollection.cs @@ -0,0 +1,194 @@ +using AasCore.Aas3_0_RC02; +using AdminShellNS.Display; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendSubmodelElementCollection + { + #region AasxPackageExplorer + + /// + /// Recurses on all Submodel elements of a Submodel or SME, which allows children. + /// The state object will be passed to the lambda function in order to provide + /// stateful approaches. Include this element, as well. + /// + /// State object to be provided to lambda. Could be null. + /// The lambda function as (state, parents, SME) + /// The lambda shall return TRUE in order to deep into recursion. + /// Include this element as well. parents will then + /// include this element as well! + public static void RecurseOnReferables(this SubmodelElementCollection submodelElementCollection, + object state, Func, IReferable, bool> lambda, + bool includeThis = false) + { + var parents = new List(); + if (includeThis) + { + lambda(state, null, submodelElementCollection); + parents.Add(submodelElementCollection); + } + submodelElementCollection.Value?.RecurseOnReferables(state, parents, lambda); + } + + public static void Remove(this SubmodelElementCollection submodelElementCollection, ISubmodelElement submodelElement) + { + if(submodelElementCollection != null) + { + if(submodelElementCollection.Value != null) + { + submodelElementCollection.Value.Remove(submodelElement); + } + } + } + + public static object AddChild(this SubmodelElementCollection submodelElementCollection, ISubmodelElement childSubmodelElement, EnumerationPlacmentBase placement = null) + { + if (childSubmodelElement == null) + return null; + if (submodelElementCollection.Value == null) + submodelElementCollection.Value = new (); + if (childSubmodelElement != null) + childSubmodelElement.Parent = submodelElementCollection; + submodelElementCollection.Value.Add(childSubmodelElement); + return childSubmodelElement; + } + + #endregion + public static T FindFirstIdShortAs(this SubmodelElementCollection submodelElementCollection, string idShort) where T : ISubmodelElement + { + + var submodelElement = submodelElementCollection.Value.Where(sme => (sme != null) && (sme is T) && sme.IdShort.Equals(idShort, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); + + return (T)submodelElement; + } + + public static SubmodelElementCollection ConvertFromV10(this SubmodelElementCollection submodelElementCollection, AasxCompatibilityModels.AdminShellV10.SubmodelElementCollection sourceSmeCollection, bool shallowCopy = false) + { + if (sourceSmeCollection == null) + return null; + + if (submodelElementCollection.Value == null) + { + submodelElementCollection.Value = new List(); + } + + if (!shallowCopy) + { + foreach (var submodelElementWrapper in sourceSmeCollection.value) + { + var sourceSubmodelElement = submodelElementWrapper.submodelElement; + ISubmodelElement outputSubmodelElement = null; + if (sourceSubmodelElement != null) + { + outputSubmodelElement = outputSubmodelElement.ConvertFromV10(sourceSubmodelElement, shallowCopy); + } + + submodelElementCollection.Value.Add(outputSubmodelElement); + } + } + + return submodelElementCollection; + } + + public static SubmodelElementCollection ConvertFromV20(this SubmodelElementCollection submodelElementCollection, AasxCompatibilityModels.AdminShellV20.SubmodelElementCollection sourceSmeCollection, bool shallowCopy = false) + { + if (sourceSmeCollection == null) + return null; + + if (submodelElementCollection.Value == null) + { + submodelElementCollection.Value = new List(); + } + + if (!shallowCopy) + { + foreach (var submodelElementWrapper in sourceSmeCollection.value) + { + var sourceSubmodelElement = submodelElementWrapper.submodelElement; + ISubmodelElement outputSubmodelElement = null; + if (sourceSubmodelElement != null) + { + outputSubmodelElement = outputSubmodelElement.ConvertFromV20(sourceSubmodelElement, shallowCopy); + } + + submodelElementCollection.Value.Add(outputSubmodelElement); + } + } + + return submodelElementCollection; + } + + public static void Add(this SubmodelElementCollection submodelElementCollection, ISubmodelElement submodelElement) + { + submodelElementCollection.Value ??= new List(); + + submodelElement.Parent = submodelElementCollection; + submodelElementCollection.Value.Add(submodelElement); + } + + public static void Insert(this SubmodelElementCollection submodelElementCollection, int index, ISubmodelElement submodelElement) + { + if (submodelElementCollection.Value == null) + { + submodelElementCollection.Value = new List(); + } + + submodelElement.Parent = submodelElementCollection; + submodelElementCollection.Value.Insert(index, submodelElement); + } + + public static T CreateSMEForCD( + this SubmodelElementCollection smc, + ConceptDescription conceptDescription, string category = null, string idShort = null, + string idxTemplate = null, int maxNum = 999, bool addSme = false, bool isTemplate = false) + where T : ISubmodelElement + { + if (smc.Value == null) + smc.Value = new List(); + return smc.Value.CreateSMEForCD( + conceptDescription, category, idShort, idxTemplate, maxNum, addSme, isTemplate); + } + + public static SubmodelElementCollection UpdateFrom( + this SubmodelElementCollection elem, ISubmodelElement source) + { + if (source == null) + return elem; + + ((ISubmodelElement)elem).UpdateFrom(source); + + if (source is SubmodelElementList srcList) + { + if (srcList.Value != null) + elem.Value = srcList.Value.Copy(); + } + + if (source is Operation srcOp) + { + Action, List> appov = (dst, src) => + { + if (src == null) + return; + foreach (var ov in src) + if (ov.Value != null) + dst.Append(ov.Value.Copy()); + }; + + elem.Value = new(); + appov(elem.Value, srcOp.InputVariables); + appov(elem.Value, srcOp.InoutputVariables); + appov(elem.Value, srcOp.OutputVariables); + if (elem.Value.Count < 1) + elem.Value = null; + } + + return elem; + } + + } +} diff --git a/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementList.cs b/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementList.cs new file mode 100644 index 000000000..4d700549f --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/ExtendSubmodelElementList.cs @@ -0,0 +1,200 @@ +using AasCore.Aas3_0_RC02; +using AdminShellNS.Display; +using Newtonsoft.Json.Linq; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public static class ExtendSubmodelElementList + { + #region AasxPackageExplorer + + /// + /// Recurses on all Submodel elements of a Submodel or SME, which allows children. + /// The state object will be passed to the lambda function in order to provide + /// stateful approaches. Include this element, as well. + /// + /// State object to be provided to lambda. Could be null. + /// The lambda function as (state, parents, SME) + /// The lambda shall return TRUE in order to deep into recursion. + /// Include this element as well. parents will then + /// include this element as well! + public static void RecurseOnReferables(this SubmodelElementList submodelElementList, + object state, Func, IReferable, bool> lambda, + bool includeThis = false) + { + var parents = new List(); + if (includeThis) + { + lambda(state, null, submodelElementList); + parents.Add(submodelElementList); + } + submodelElementList.Value?.RecurseOnReferables(state, parents, lambda); + } + + public static void Add(this SubmodelElementList submodelElementList, ISubmodelElement submodelElement) + { + if (submodelElementList != null) + { + submodelElementList.Value ??= new(); + + submodelElement.Parent = submodelElementList; + + submodelElementList.Value.Add(submodelElement); + } + } + + public static void Remove(this SubmodelElementList submodelElementList, ISubmodelElement submodelElement) + { + if (submodelElementList != null) + { + if (submodelElementList.Value != null) + { + submodelElementList.Value.Remove(submodelElement); + } + } + } + + public static object AddChild(this SubmodelElementList submodelElementList, ISubmodelElement childSubmodelElement, EnumerationPlacmentBase placement = null) + { + if (childSubmodelElement == null) + return null; + if (submodelElementList.Value == null) + submodelElementList.Value = new(); + if (childSubmodelElement != null) + childSubmodelElement.Parent = submodelElementList; + submodelElementList.Value.Add(childSubmodelElement); + return childSubmodelElement; + } + + #endregion + public static T FindFirstIdShortAs(this SubmodelElementList submodelElementList, string idShort) where T : ISubmodelElement + { + + var submodelElements = submodelElementList.Value.Where(sme => sme != null && sme is T && sme.IdShort.Equals(idShort, StringComparison.OrdinalIgnoreCase)); + + if (submodelElements.Any()) + { + return (T)submodelElements.First(); + } + + return default; + } + + public static SubmodelElementList UpdateFrom( + this SubmodelElementList elem, ISubmodelElement source) + { + if (source == null) + return elem; + + ((ISubmodelElement)elem).UpdateFrom(source); + + if (source is SubmodelElementCollection srcColl) + { + if (srcColl.Value != null) + elem.Value = srcColl.Value.Copy(); + } + + if (source is Operation srcOp) + { + Action, List> appov = (dst, src) => + { + if (src == null) + return; + foreach (var ov in src) + if (ov.Value != null) + dst.Append(ov.Value.Copy()); + }; + + elem.Value = new(); + appov(elem.Value, srcOp.InputVariables); + appov(elem.Value, srcOp.InoutputVariables); + appov(elem.Value, srcOp.OutputVariables); + if (elem.Value.Count < 1) + elem.Value = null; + } + + return elem; + } + + // advanced checks + + public class ConstraintStat + { + /// + /// Constraint AASd-107: If a first level child element in a SubmodelElementList has a semanticId + /// it shall be identical to SubmodelElementList/semanticIdListElement. + /// + public bool AllChildSemIdMatch = true; + + /// + /// Constraint AASd-108: All first level child elements in a SubmodelElementList shall have the + /// same submodel element type as specified in SubmodelElementList/typeValueListElement. + /// + public bool AllChildSmeTypeMatch = true; + + /// + /// Constraint AASd-109: If SubmodelElementList/typeValueListElement equal to Property or Range, + /// SubmodelElementList/valueTypeListElement shall be set and all first level child elements in + /// the SubmodelElementList shall have the the value type as specified in + /// SubmodelElementList/valueTypeListElement + /// + public bool AllChildValueTypeMatch = true; + } + + public static ConstraintStat EvalConstraintStat(this SubmodelElementList list) + { + // access + var res = new ConstraintStat(); + if (list.Value == null) + return res; + + // prepare SME type + var smeTypeToCheck = list.TypeValueListElement; + + // prepare value type + var valueTypeToCheck = list.ValueTypeListElement; + + // eval + foreach (var sme in list.Value) + { + // need self description + var smesd = sme.GetSelfDescription(); + if (smesd == null) + continue; + + // sem id? + if (res.AllChildSemIdMatch + && list.SemanticIdListElement?.IsValid() == true + && sme.SemanticId?.IsValid() == true + && !list.SemanticIdListElement.Matches(sme.SemanticId)) + res.AllChildSemIdMatch = false; + + // type of SME? + if (res.AllChildSmeTypeMatch + && smesd.SmeType != smeTypeToCheck) + res.AllChildSmeTypeMatch = false; + + // value type to check + if (valueTypeToCheck.HasValue + && res.AllChildValueTypeMatch + && sme is Property prop + && prop.ValueType != valueTypeToCheck.Value) + res.AllChildValueTypeMatch = false; + + if (valueTypeToCheck.HasValue + && res.AllChildValueTypeMatch + && sme is AasCore.Aas3_0_RC02.Range range + && range.ValueType != valueTypeToCheck.Value) + res.AllChildValueTypeMatch = false; + } + + // ok + return res; + } + } +} diff --git a/src/AasxServerStandardBib/Extenstions/ExtensionsUtil.cs b/src/AasxCsharpLibrary/Extensions/ExtensionsUtil.cs similarity index 81% rename from src/AasxServerStandardBib/Extenstions/ExtensionsUtil.cs rename to src/AasxCsharpLibrary/Extensions/ExtensionsUtil.cs index 230f3b2a7..fc2940ab2 100644 --- a/src/AasxServerStandardBib/Extenstions/ExtensionsUtil.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtensionsUtil.cs @@ -6,7 +6,7 @@ using System.Text; using System.Threading.Tasks; -namespace Extenstions +namespace Extensions { public static class ExtensionsUtil { @@ -43,6 +43,10 @@ public static Reference ConvertReferenceFromV20(AdminShellV20.Reference sourceRe var keyList = new List(); foreach (var refKey in sourceReference.Keys) { + // Fix, as Asset does not exist anymore + if (refKey.type?.Trim().Equals("Asset", StringComparison.InvariantCultureIgnoreCase) == true) + refKey.type = "GlobalReference"; + var keyType = Stringification.KeyTypesFromString(refKey.type); if (keyType != null) { @@ -50,15 +54,7 @@ public static Reference ConvertReferenceFromV20(AdminShellV20.Reference sourceRe } else { - if (refKey.type.Equals("Asset", StringComparison.OrdinalIgnoreCase)) - { - Console.WriteLine($"KeyType value {refKey.type} not found. Setting KeyType to GlobalReference"); - keyList.Add(new Key(KeyTypes.GlobalReference, refKey.value)); - } - else - { - Console.WriteLine($"KeyType value {refKey.type} not found."); - } + Console.WriteLine($"KeyType value {refKey.type} not found."); } } outputReference = new Reference(referenceTypes, keyList); @@ -67,7 +63,7 @@ public static Reference ConvertReferenceFromV20(AdminShellV20.Reference sourceRe return outputReference; } - internal static LangStringSet ConvertDescriptionFromV10(AdminShellV10.Description sourceDescription) + internal static List ConvertDescriptionFromV10(AdminShellV10.Description sourceDescription) { var newLangStrList = new List(); foreach (var ls in sourceDescription.langString) @@ -75,10 +71,10 @@ internal static LangStringSet ConvertDescriptionFromV10(AdminShellV10.Descriptio newLangStrList.Add(new LangString(ls.lang, ls.str)); } - return new LangStringSet(newLangStrList); + return new List(newLangStrList); } - internal static LangStringSet ConvertDescriptionFromV20(AdminShellV20.Description sourceDescription) + internal static List ConvertDescriptionFromV20(AdminShellV20.Description sourceDescription) { var newLangStrList = new List(); foreach (var ls in sourceDescription.langString) @@ -86,7 +82,7 @@ internal static LangStringSet ConvertDescriptionFromV20(AdminShellV20.Descriptio newLangStrList.Add(new LangString(ls.lang, ls.str)); } - return new LangStringSet(newLangStrList); + return new List(newLangStrList); } internal static KeyTypes GetKeyType(IClass aasElement) diff --git a/src/AasxCsharpLibrary/Extensions/LocatedReference.cs b/src/AasxCsharpLibrary/Extensions/LocatedReference.cs new file mode 100644 index 000000000..433578d61 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/LocatedReference.cs @@ -0,0 +1,22 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public class LocatedReference + { + public IIdentifiable Identifiable; + public Reference Reference; + + public LocatedReference() { } + public LocatedReference(IIdentifiable identifiable, Reference reference) + { + Identifiable = identifiable; + Reference = reference; + } + } +} diff --git a/src/AasxCsharpLibrary/Extensions/MatchMode.cs b/src/AasxCsharpLibrary/Extensions/MatchMode.cs new file mode 100644 index 000000000..f30029657 --- /dev/null +++ b/src/AasxCsharpLibrary/Extensions/MatchMode.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Extensions +{ + public enum MatchMode + { + Strict, //may be not needed in future, as no local flag in V3 + Relaxed, //should be as default + Identification + } +} diff --git a/src/AasxServerStandardBib/IAasxOnlineConnection.cs b/src/AasxCsharpLibrary/IAasxOnlineConnection.cs similarity index 53% rename from src/AasxServerStandardBib/IAasxOnlineConnection.cs rename to src/AasxCsharpLibrary/IAasxOnlineConnection.cs index f2ce7668f..7ce13b014 100644 --- a/src/AasxServerStandardBib/IAasxOnlineConnection.cs +++ b/src/AasxCsharpLibrary/IAasxOnlineConnection.cs @@ -1,4 +1,13 @@ -using System; +/* +Copyright (c) 2018-2021 Festo AG & Co. KG +Author: Michael Hoffmeister + +This source code is licensed under the Apache License 2.0 (see LICENSE.txt). + +This source code may use other Open Source software components (see LICENSE.txt). +*/ + +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -18,6 +27,7 @@ public interface IAasxOnlineConnection bool IsConnected(); string GetInfo(); Stream GetThumbnailStream(); - string UpdatePropertyValue(AasCore.Aas3_0_RC02.Environment env, Submodel submodel, ISubmodelElement sme); + string UpdatePropertyValue( + AasCore.Aas3_0_RC02.Environment env, Submodel submodel, ISubmodelElement sme); } } diff --git a/src/AasxCsharpLibrary/LICENSE.txt b/src/AasxCsharpLibrary/LICENSE.txt new file mode 100644 index 000000000..cd3ff93ed --- /dev/null +++ b/src/AasxCsharpLibrary/LICENSE.txt @@ -0,0 +1,1266 @@ +Copyright (c) 2018-2021 Festo AG & 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). + +------------------------------------------------------------------------------- + + +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. \ No newline at end of file diff --git a/src/AasxServerStandardBib/LogInternally.cs b/src/AasxCsharpLibrary/LogInternally.cs similarity index 61% rename from src/AasxServerStandardBib/LogInternally.cs rename to src/AasxCsharpLibrary/LogInternally.cs index 589f30eda..f5a9bfad9 100644 --- a/src/AasxServerStandardBib/LogInternally.cs +++ b/src/AasxCsharpLibrary/LogInternally.cs @@ -7,19 +7,39 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt). This source code may use other Open Source software components (see LICENSE.txt). */ +using System; using Exception = System.Exception; namespace AdminShellNS { public static class Logging { + // see: https://stackoverflow.com/questions/9314172/getting-all-messages-from-innerexceptions + private static string GetExceptionMessages(this Exception e, string msgs = "") + { + if (e == null) return string.Empty; + if (msgs == "") msgs = e.Message; + if (e.InnerException != null) + msgs += "\r\nInnerException: " + GetExceptionMessages(e.InnerException); + return msgs; + } + public static string FormatError(Exception ex, string where) { - return string.Format("Error: {0}: {1} {2} at {3}.", + var res = string.Format("Error: {0}: {1} {2} at {3}.", where, ex.Message, - (ex.InnerException != null) ? ex.InnerException.Message : "", + ex.GetExceptionMessages(), ex.StackTrace); + + var inner = ex.InnerException; + while (inner != null) + { + res += $"Inner message: {inner.Message}" + Environment.NewLine; + inner = inner.InnerException; + } + + return res; } } @@ -43,6 +63,13 @@ public void SilentlyIgnoredError(Exception ex) ((ex.InnerException != null) ? ex.InnerException.Message : ""), ex.StackTrace); } + + /// + /// Does no logging at all. Allows to have non-empty catch clauses. + /// + public void CompletelyIgnoredError(Exception ex) + { + } } /// diff --git a/src/AasxCsharpLibrary/Properties/AssemblyInfo.cs b/src/AasxCsharpLibrary/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..9aa23c08b --- /dev/null +++ b/src/AasxCsharpLibrary/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über die folgenden +// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern, +// die einer Assembly zugeordnet sind. +[assembly: AssemblyTitle("AasxCsharpLibrary")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("AasxCsharpLibrary")] +[assembly: AssemblyCopyright("Copyright © 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Durch Festlegen von ComVisible auf FALSE werden die Typen in dieser Assembly +// für COM-Komponenten unsichtbar. Wenn Sie auf einen Typ in dieser Assembly von +// COM aus zugreifen müssen, sollten Sie das ComVisible-Attribut für diesen Typ auf "True" festlegen. +[assembly: ComVisible(false)] + +// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird +[assembly: Guid("9863799b-4e44-4da2-9120-c85c7985bc6d")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Hauptversion +// Nebenversion +// Buildnummer +// Revision +// +// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden, +// indem Sie "*" wie unten gezeigt eingeben: +//// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/AasxCsharpLibrary/Resources/schemaV201/AAS.xsd b/src/AasxCsharpLibrary/Resources/schemaV201/AAS.xsd new file mode 100644 index 000000000..2e6c24f6b --- /dev/null +++ b/src/AasxCsharpLibrary/Resources/schemaV201/AAS.xsd @@ -0,0 +1,555 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/AasxCsharpLibrary/Resources/schemaV201/AAS_ABAC.xsd b/src/AasxCsharpLibrary/Resources/schemaV201/AAS_ABAC.xsd new file mode 100644 index 000000000..4048a5746 --- /dev/null +++ b/src/AasxCsharpLibrary/Resources/schemaV201/AAS_ABAC.xsd @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AasxCsharpLibrary/Resources/schemaV201/IEC61360.xsd b/src/AasxCsharpLibrary/Resources/schemaV201/IEC61360.xsd new file mode 100644 index 000000000..d52f04f1e --- /dev/null +++ b/src/AasxCsharpLibrary/Resources/schemaV201/IEC61360.xsd @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/AasxCsharpLibrary/Resources/schemaV201/aas.json b/src/AasxCsharpLibrary/Resources/schemaV201/aas.json new file mode 100644 index 000000000..9583c2b1f --- /dev/null +++ b/src/AasxCsharpLibrary/Resources/schemaV201/aas.json @@ -0,0 +1,1148 @@ +{ + "$schema": "https://json-schema.org/draft/2019-09/schema", + "title": "AssetAdministrationShellEnvironment", + "$id": "http://www.admin-shell.io/schema/json/v2.0.1", + "type": "object", + "required": ["assetAdministrationShells", "submodels", "assets", "conceptDescriptions"], + "properties": { + "assetAdministrationShells": { + "type": "array", + "items": { + "$ref": "#/definitions/AssetAdministrationShell" + } + }, + "submodels": { + "type": "array", + "items": { + "$ref": "#/definitions/Submodel" + } + }, + "assets": { + "type": "array", + "items": { + "$ref": "#/definitions/Asset" + } + }, + "conceptDescriptions": { + "type": "array", + "items": { + "$ref": "#/definitions/ConceptDescription" + } + } + }, + "definitions": { + "Referable": { + "type": "object", + "properties": { + "idShort": { + "type": "string" + }, + "category": { + "type": "string" + }, + "description": { + "type": "array", + "items": { + "$ref": "#/definitions/LangString" + } + }, + "parent": { + "$ref": "#/definitions/Reference" + }, + "modelType": { + "$ref": "#/definitions/ModelType" + } + }, + "required": [ "idShort", "modelType" ] + }, + "Identifiable": { + "allOf": [ + { "$ref": "#/definitions/Referable" }, + { "properties": { + "identification": { + "$ref": "#/definitions/Identifier" + }, + "administration": { + "$ref": "#/definitions/AdministrativeInformation" + } + }, + "required": [ "identification" ] + } + ] + }, + "Qualifiable": { + "type": "object", + "properties": { + "qualifiers": { + "type": "array", + "items": { + "$ref": "#/definitions/Constraint" + } + } + } + }, + "HasSemantics": { + "type": "object", + "properties": { + "semanticId": { + "$ref": "#/definitions/Reference" + } + } + }, + "HasDataSpecification": { + "type": "object", + "properties": { + "embeddedDataSpecifications": { + "type": "array", + "items": { + "$ref": "#/definitions/EmbeddedDataSpecification" + } + } + } + }, + "AssetAdministrationShell": { + "allOf": [ + { "$ref": "#/definitions/Identifiable" }, + { "$ref": "#/definitions/HasDataSpecification" }, + { "properties": { + "derivedFrom": { + "$ref": "#/definitions/Reference" + }, + "asset": { + "$ref": "#/definitions/Reference" + }, + "submodels": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + }, + "views": { + "type": "array", + "items": { + "$ref": "#/definitions/View" + } + }, + "conceptDictionaries": { + "type": "array", + "items": { + "$ref": "#/definitions/ConceptDictionary" + } + }, + "security": { + "$ref": "#/definitions/Security" + } + }, + "required": [ "asset" ] + } + ] + }, + "Identifier": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "idType": { + "$ref": "#/definitions/KeyType" + } + }, + "required": [ "id", "idType" ] + }, + "KeyType": { + "type": "string", + "enum": ["Custom", "IRDI", "IRI", "IdShort", "FragmentId"] + }, + "AdministrativeInformation": { + "type": "object", + "properties": { + "version": { + "type": "string" + }, + "revision": { + "type": "string" + } + } + }, + "LangString": { + "type": "object", + "properties": { + "language": { + "type": "string" + }, + "text": { + "type": "string" + } + }, + "required": [ "language", "text" ] + }, + "Reference": { + "type": "object", + "properties": { + "keys": { + "type": "array", + "items": { + "$ref": "#/definitions/Key" + } + } + }, + "required": [ "keys" ] + }, + "Key": { + "type": "object", + "properties": { + "type": { + "$ref": "#/definitions/KeyElements" + }, + "idType": { + "$ref": "#/definitions/KeyType" + }, + "value": { + "type": "string" + }, + "local": { + "type": "boolean" + } + }, + "required": [ "type", "idType", "value", "local" ] + }, + "KeyElements": { + "type": "string", + "enum": [ + "Asset", + "AssetAdministrationShell", + "ConceptDescription", + "Submodel", + "AccessPermissionRule", + "AnnotatedRelationshipElement", + "BasicEvent", + "Blob", + "Capability", + "ConceptDictionary", + "DataElement", + "File", + "Entity", + "Event", + "MultiLanguageProperty", + "Operation", + "Property", + "Range", + "ReferenceElement", + "RelationshipElement", + "SubmodelElement", + "SubmodelElementCollection", + "View", + "GlobalReference", + "FragmentReference" + ] + }, + "ModelTypes": { + "type": "string", + "enum": [ + "Asset", + "AssetAdministrationShell", + "ConceptDescription", + "Submodel", + "AccessPermissionRule", + "AnnotatedRelationshipElement", + "BasicEvent", + "Blob", + "Capability", + "ConceptDictionary", + "DataElement", + "File", + "Entity", + "Event", + "MultiLanguageProperty", + "Operation", + "Property", + "Range", + "ReferenceElement", + "RelationshipElement", + "SubmodelElement", + "SubmodelElementCollection", + "View", + "GlobalReference", + "FragmentReference", + "Constraint", + "Formula", + "Qualifier" + ] + }, + "ModelType": { + "type": "object", + "properties": { + "name": { + "$ref": "#/definitions/ModelTypes" + } + }, + "required": [ "name" ] + }, + "EmbeddedDataSpecification": { + "type": "object", + "properties": { + "dataSpecification": { + "$ref": "#/definitions/Reference" + }, + "dataSpecificationContent": { + "$ref": "#/definitions/DataSpecificationContent" + } + }, + "required": [ "dataSpecification", "dataSpecificationContent" ] + }, + "DataSpecificationContent": { + "oneOf": [ + { "$ref": "#/definitions/DataSpecificationIEC61360Content" }, + { "$ref": "#/definitions/DataSpecificationPhysicalUnitContent" } + ] + }, + "DataSpecificationPhysicalUnitContent": { + "type": "object", + "properties": { + "unitName": { + "type": "string" + }, + "unitSymbol": { + "type": "string" + }, + "definition": { + "type": "array", + "items": { + "$ref": "#/definitions/LangString" + } + }, + "siNotation": { + "type": "string" + }, + "siName": { + "type": "string" + }, + "dinNotation": { + "type": "string" + }, + "eceName": { + "type": "string" + }, + "eceCode": { + "type": "string" + }, + "nistName": { + "type": "string" + }, + "sourceOfDefinition": { + "type": "string" + }, + "conversionFactor": { + "type": "string" + }, + "registrationAuthorityId": { + "type": "string" + }, + "supplier": { + "type": "string" + } + }, + "required": [ "unitName", "unitSymbol", "definition" ] + }, + "DataSpecificationIEC61360Content": { + "allOf": [ + { "$ref": "#/definitions/ValueObject" }, + { + "type": "object", + "properties": { + "dataType": { + "enum": [ + "DATE", + "STRING", + "STRING_TRANSLATABLE", + "REAL_MEASURE", + "REAL_COUNT", + "REAL_CURRENCY", + "BOOLEAN", + "URL", + "RATIONAL", + "RATIONAL_MEASURE", + "TIME", + "TIMESTAMP", + "INTEGER_COUNT", + "INTEGER_MEASURE", + "INTEGER_CURRENCY" + ] + }, + "definition": { + "type": "array", + "items": { + "$ref": "#/definitions/LangString" + } + }, + "preferredName": { + "type": "array", + "items": { + "$ref": "#/definitions/LangString" + } + }, + "shortName": { + "type": "array", + "items": { + "$ref": "#/definitions/LangString" + } + }, + "sourceOfDefinition": { + "type": "string" + }, + "symbol": { + "type": "string" + }, + "unit": { + "type": "string" + }, + "unitId": { + "$ref": "#/definitions/Reference" + }, + "valueFormat": { + "type": "string" + }, + "valueList": { + "$ref": "#/definitions/ValueList" + }, + "levelType": { + "type": "array", + "items": { + "$ref": "#/definitions/LevelType" + } + } + }, + "required": [ "preferredName" ] + } + ] + }, + "LevelType": { + "type": "string", + "enum": [ "Min", "Max", "Nom", "Typ" ] + }, + "ValueList": { + "type": "object", + "properties": { + "valueReferencePairTypes": { + "type": "array", + "minItems": 1, + "items": { + "$ref": "#/definitions/ValueReferencePairType" + } + } + }, + "required": [ "valueReferencePairTypes" ] + }, + "ValueReferencePairType": { + "allOf": [ + { "$ref": "#/definitions/ValueObject" } + ] + }, + "ValueObject": { + "type": "object", + "properties": { + "value": { "type": "string" }, + "valueId": { + "$ref": "#/definitions/Reference" + }, + "valueType": { + "type": "string", + "enum": [ + "anyUri", + "base64Binary", + "boolean", + "date", + "dateTime", + "dateTimeStamp", + "decimal", + "integer", + "long", + "int", + "short", + "byte", + "nonNegativeInteger", + "positiveInteger", + "unsignedLong", + "unsignedInt", + "unsignedShort", + "unsignedByte", + "nonPositiveInteger", + "negativeInteger", + "double", + "duration", + "dayTimeDuration", + "yearMonthDuration", + "float", + "gDay", + "gMonth", + "gMonthDay", + "gYear", + "gYearMonth", + "hexBinary", + "NOTATION", + "QName", + "string", + "normalizedString", + "token", + "language", + "Name", + "NCName", + "ENTITY", + "ID", + "IDREF", + "NMTOKEN", + "time" + ]} + } + }, + "Asset": { + "allOf": [ + { "$ref": "#/definitions/Identifiable" }, + { "$ref": "#/definitions/HasDataSpecification" }, + { "properties": { + "kind": { + "$ref": "#/definitions/AssetKind" + }, + "assetIdentificationModel": { + "$ref": "#/definitions/Reference" + }, + "billOfMaterial": { + "$ref": "#/definitions/Reference" + } + }, + "required": [ "kind" ] + } + ] + }, + "AssetKind": { + "type": "string", + "enum": ["Type", "Instance"] + }, + "ModelingKind": { + "type": "string", + "enum": ["Template", "Instance"] + }, + "Submodel": { + "allOf": [ + { "$ref": "#/definitions/Identifiable" }, + { "$ref": "#/definitions/HasDataSpecification" }, + { "$ref": "#/definitions/Qualifiable" }, + { "$ref": "#/definitions/HasSemantics" }, + { "properties": { + "kind": { + "$ref": "#/definitions/ModelingKind" + }, + "submodelElements": { + "type": "array", + "items": { + "$ref": "#/definitions/SubmodelElement" + } + } + } + } + ] + }, + "Constraint": { + "type": "object", + "properties": { + "modelType": { + "$ref": "#/definitions/ModelType" + } + }, + "required": [ "modelType" ] + }, + "Operation": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" }, + { "properties": { + "inputVariable": { + "type": "array", + "items": { + "$ref": "#/definitions/OperationVariable" + } + }, + "outputVariable": { + "type": "array", + "items": { + "$ref": "#/definitions/OperationVariable" + } + }, + "inoutputVariable": { + "type": "array", + "items": { + "$ref": "#/definitions/OperationVariable" + } + } + } + } + ] + }, + "OperationVariable": { + "type": "object", + "properties": { + "value": { + "oneOf": [ + { "$ref": "#/definitions/Blob" }, + { "$ref": "#/definitions/File" }, + { "$ref": "#/definitions/Capability" }, + { "$ref": "#/definitions/Entity" }, + { "$ref": "#/definitions/Event" }, + { "$ref": "#/definitions/BasicEvent" }, + { "$ref": "#/definitions/MultiLanguageProperty" }, + { "$ref": "#/definitions/Operation" }, + { "$ref": "#/definitions/Property" }, + { "$ref": "#/definitions/Range" }, + { "$ref": "#/definitions/ReferenceElement" }, + { "$ref": "#/definitions/RelationshipElement" }, + { "$ref": "#/definitions/SubmodelElementCollection" } + ] + } + }, + "required": [ "value" ] + }, + "SubmodelElement": { + "allOf": [ + { "$ref": "#/definitions/Referable" }, + { "$ref": "#/definitions/HasDataSpecification" }, + { "$ref": "#/definitions/HasSemantics" }, + { "$ref": "#/definitions/Qualifiable" }, + { "properties": { + "kind": { + "$ref": "#/definitions/ModelingKind" + } + } + } + ] + }, + "Event": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" } + ] + }, + "BasicEvent": { + "allOf": [ + { "$ref": "#/definitions/Event" }, + { "properties": { + "observed": { + "$ref": "#/definitions/Reference" + } + }, + "required": [ "observed" ] + } + ] + }, + "EntityType": { + "type": "string", + "enum": ["CoManagedEntity", "SelfManagedEntity"] + }, + "Entity": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" }, + { "properties": { + "statements": { + "type": "array", + "items": { + "$ref": "#/definitions/SubmodelElement" + } + }, + "entityType": { + "$ref": "#/definitions/EntityType" + }, + "asset": { + "$ref": "#/definitions/Reference" + } + }, + "required": [ "entityType" ] + } + ] + }, + "View": { + "allOf": [ + { "$ref": "#/definitions/Referable" }, + { "$ref": "#/definitions/HasDataSpecification" }, + { "$ref": "#/definitions/HasSemantics" }, + { "properties": { + "containedElements": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + } + } + } + ] + }, + "ConceptDictionary": { + "allOf": [ + { "$ref": "#/definitions/Referable" }, + { "$ref": "#/definitions/HasDataSpecification" }, + { "properties": { + "conceptDescriptions": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + } + } + } + ] + }, + "ConceptDescription": { + "allOf": [ + { "$ref": "#/definitions/Identifiable" }, + { "$ref": "#/definitions/HasDataSpecification" }, + { "properties": { + "isCaseOf": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + } + } + } + ] + }, + "Capability": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" } + ] + }, + "Property": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" }, + { "$ref": "#/definitions/ValueObject" } + ] + }, + "Range": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" }, + { "properties": { + "valueType": { + "type": "string", + "enum": [ + "anyUri", + "base64Binary", + "boolean", + "date", + "dateTime", + "dateTimeStamp", + "decimal", + "integer", + "long", + "int", + "short", + "byte", + "nonNegativeInteger", + "positiveInteger", + "unsignedLong", + "unsignedInt", + "unsignedShort", + "unsignedByte", + "nonPositiveInteger", + "negativeInteger", + "double", + "duration", + "dayTimeDuration", + "yearMonthDuration", + "float", + "gDay", + "gMonth", + "gMonthDay", + "gYear", + "gYearMonth", + "hexBinary", + "NOTATION", + "QName", + "string", + "normalizedString", + "token", + "language", + "Name", + "NCName", + "ENTITY", + "ID", + "IDREF", + "NMTOKEN", + "time" + ] + }, + "min": { "type": "string" }, + "max": { "type": "string" } + }, + "required": [ "valueType"] + } + ] + }, + "MultiLanguageProperty": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" }, + { "properties": { + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/LangString" + } + }, + "valueId": { + "$ref": "#/definitions/Reference" + } + } + } + ] + }, + "File": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" }, + { "properties": { + "value": { + "type": "string" + }, + "mimeType": { + "type": "string" + } + }, + "required": [ "mimeType" ] + } + ] + }, + "Blob": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" }, + { "properties": { + "value": { + "type": "string" + }, + "mimeType": { + "type": "string" + } + }, + "required": [ "mimeType" ] + } + ] + }, + "ReferenceElement": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" }, + { "properties": { + "value": { + "$ref": "#/definitions/Reference" + } + } + } + ] + }, + "SubmodelElementCollection": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" }, + { "properties": { + "value": { + "type": "array", + "items": { + "oneOf": [ + { "$ref": "#/definitions/Blob" }, + { "$ref": "#/definitions/File" }, + { "$ref": "#/definitions/Capability" }, + { "$ref": "#/definitions/Entity" }, + { "$ref": "#/definitions/Event" }, + { "$ref": "#/definitions/BasicEvent" }, + { "$ref": "#/definitions/MultiLanguageProperty" }, + { "$ref": "#/definitions/Operation" }, + { "$ref": "#/definitions/Property" }, + { "$ref": "#/definitions/Range" }, + { "$ref": "#/definitions/ReferenceElement" }, + { "$ref": "#/definitions/RelationshipElement" }, + { "$ref": "#/definitions/SubmodelElementCollection" } + ] + } + }, + "allowDuplicates": { + "type": "boolean" + }, + "ordered": { + "type": "boolean" + } + } + } + ] + }, + "RelationshipElement": { + "allOf": [ + { "$ref": "#/definitions/SubmodelElement" }, + { "properties": { + "first": { + "$ref": "#/definitions/Reference" + }, + "second": { + "$ref": "#/definitions/Reference" + } + }, + "required": [ "first", "second" ] + } + ] + }, + "AnnotatedRelationshipElement": { + "allOf": [ + { "$ref": "#/definitions/RelationshipElement" }, + { "properties": { + "annotation": { + "type": "array", + "items": { + "oneOf": [ + { "$ref": "#/definitions/Blob" }, + { "$ref": "#/definitions/File" }, + { "$ref": "#/definitions/MultiLanguageProperty" }, + { "$ref": "#/definitions/Property" }, + { "$ref": "#/definitions/Range" }, + { "$ref": "#/definitions/ReferenceElement" } + ] + } + } + } + } + ] + }, + "Qualifier": { + "allOf": [ + { "$ref": "#/definitions/Constraint" }, + { "$ref": "#/definitions/HasSemantics" }, + { "$ref": "#/definitions/ValueObject" }, + { "properties": { + "type": { + "type": "string" + } + }, + "required": [ "type" ] + } + ] + }, + "Formula": { + "allOf": [ + { "$ref": "#/definitions/Constraint" }, + { "properties": { + "dependsOn": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + } + } + } + ] + }, + "Security": { + "type": "object", + "properties": { + "accessControlPolicyPoints": { + "$ref": "#/definitions/AccessControlPolicyPoints" + }, + "certificate": { + "type": "array", + "items": { + "oneOf": [ + { "$ref": "#/definitions/BlobCertificate" } + ] + } + }, + "requiredCertificateExtension": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + } + }, + "required": [ "accessControlPolicyPoints" ] + }, + "Certificate": { + "type": "object" + }, + "BlobCertificate": { + "allOf": [ + { "$ref": "#/definitions/Certificate" }, + { "properties": { + "blobCertificate": { + "$ref": "#/definitions/Blob" + }, + "containedExtension": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + }, + "lastCertificate": { + "type": "boolean" + } + } + } + ] + }, + "AccessControlPolicyPoints": { + "type": "object", + "properties": { + "policyAdministrationPoint": { + "$ref": "#/definitions/PolicyAdministrationPoint" + }, + "policyDecisionPoint": { + "$ref": "#/definitions/PolicyDecisionPoint" + }, + "policyEnforcementPoint": { + "$ref": "#/definitions/PolicyEnforcementPoint" + }, + "policyInformationPoints": { + "$ref": "#/definitions/PolicyInformationPoints" + } + }, + "required": [ "policyAdministrationPoint", "policyDecisionPoint", "policyEnforcementPoint" ] + }, + "PolicyAdministrationPoint": { + "type": "object", + "properties": { + "localAccessControl": { + "$ref": "#/definitions/AccessControl" + }, + "externalAccessControl": { + "type": "boolean" + } + }, + "required": [ "externalAccessControl" ] + }, + "PolicyInformationPoints": { + "type": "object", + "properties": { + "internalInformationPoint": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + } + }, + "externalInformationPoint": { + "type": "boolean" + } + }, + "required": [ "externalInformationPoint" ] + }, + "PolicyEnforcementPoint": { + "type": "object", + "properties": { + "externalPolicyEnforcementPoint": { + "type": "boolean" + } + }, + "required": [ "externalPolicyEnforcementPoint" ] + }, + "PolicyDecisionPoint": { + "type": "object", + "properties": { + "externalPolicyDecisionPoints": { + "type": "boolean" + } + }, + "required": [ "externalPolicyDecisionPoints" ] + }, + "AccessControl": { + "type": "object", + "properties": { + "selectableSubjectAttributes": { + "$ref": "#/definitions/Reference" + }, + "defaultSubjectAttributes": { + "$ref": "#/definitions/Reference" + }, + "selectablePermissions": { + "$ref": "#/definitions/Reference" + }, + "defaultPermissions": { + "$ref": "#/definitions/Reference" + }, + "selectableEnvironmentAttributes": { + "$ref": "#/definitions/Reference" + }, + "defaultEnvironmentAttributes": { + "$ref": "#/definitions/Reference" + }, + "accessPermissionRule": { + "type": "array", + "items": { + "$ref": "#/definitions/AccessPermissionRule" + } + } + } + }, + "AccessPermissionRule": { + "allOf": [ + { "$ref": "#/definitions/Referable" }, + { "$ref": "#/definitions/Qualifiable" }, + { "properties": { + "targetSubjectAttributes": { + "type": "array", + "items": { + "$ref": "#/definitions/SubjectAttributes" + }, + "minItems": 1 + }, + "permissionsPerObject": { + "type": "array", + "items": { + "$ref": "#/definitions/PermissionsPerObject" + } + } + }, + "required": [ "targetSubjectAttributes" ] + } + ] + }, + "SubjectAttributes": { + "type": "object", + "properties": { + "subjectAttributes": { + "type": "array", + "items": { + "$ref": "#/definitions/Reference" + }, + "minItems": 1 + } + } + }, + "PermissionsPerObject": { + "type": "object", + "properties": { + "object": { + "$ref": "#/definitions/Reference" + }, + "targetObjectAttributes": { + "$ref": "#/definitions/ObjectAttributes" + }, + "permission": { + "type": "array", + "items": { + "$ref": "#/definitions/Permission" + } + } + } + }, + "ObjectAttributes": { + "type": "object", + "properties": { + "objectAttribute": { + "type": "array", + "items": { + "$ref": "#/definitions/Property" + }, + "minItems": 1 + } + } + }, + "Permission": { + "type": "object", + "properties": { + "permission": { + "$ref": "#/definitions/Reference" + }, + "kindOfPermission": { + "type": "string", + "enum": ["Allow", "Deny", "NotApplicable", "Undefined"] + } + }, + "required": [ "permission", "kindOfPermission" ] + } + } +} diff --git a/src/AasxServer.DomainModelV3_0_RC02/Attributes/CountForHash.cs b/src/AasxServer.DomainModelV3_0_RC02/Attributes/CountForHash.cs new file mode 100644 index 000000000..529fea91a --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/Attributes/CountForHash.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AasCore.Aas3_0_RC02.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/AasxServer.DomainModelV3_0_RC02/Attributes/MetaModelName.cs b/src/AasxServer.DomainModelV3_0_RC02/Attributes/MetaModelName.cs new file mode 100644 index 000000000..d433de107 --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/Attributes/MetaModelName.cs @@ -0,0 +1,15 @@ +namespace AasCore.Aas3_0_RC02.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/AasxServer.DomainModelV3_0_RC02/Attributes/SkipForReflection.cs b/src/AasxServer.DomainModelV3_0_RC02/Attributes/SkipForReflection.cs new file mode 100644 index 000000000..434d8ed7e --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/Attributes/SkipForReflection.cs @@ -0,0 +1,11 @@ +namespace AasCore.Aas3_0_RC02.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/AasxServer.DomainModelV3_0_RC02/Attributes/SkipForSearch.cs b/src/AasxServer.DomainModelV3_0_RC02/Attributes/SkipForSearch.cs new file mode 100644 index 000000000..b1bfdb505 --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/Attributes/SkipForSearch.cs @@ -0,0 +1,11 @@ +namespace AasCore.Aas3_0_RC02.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/AasxServer.DomainModelV3_0_RC02/Attributes/TextSearchable.cs b/src/AasxServer.DomainModelV3_0_RC02/Attributes/TextSearchable.cs new file mode 100644 index 000000000..0b585585b --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/Attributes/TextSearchable.cs @@ -0,0 +1,10 @@ +namespace AasCore.Aas3_0_RC02.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/AasxServer.DomainModelV3_0_RC02/DataSpecification/DataSpecificationContent.cs b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/DataSpecificationContent.cs new file mode 100644 index 000000000..17ba18304 --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/DataSpecificationContent.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AasCore.Aas3_0_RC02.HasDataSpecification +{ + +} diff --git a/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/DataSpecificationIEC61360.cs b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/DataSpecificationIEC61360.cs new file mode 100644 index 000000000..332eb124e --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/DataSpecificationIEC61360.cs @@ -0,0 +1,11 @@ +using AasCore.Aas3_0_RC02.Attributes; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace AasCore.Aas3_0_RC02.HasDataSpecification +{ +} diff --git a/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/DataSpecificationISO99999.cs b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/DataSpecificationISO99999.cs new file mode 100644 index 000000000..e7693473c --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/DataSpecificationISO99999.cs @@ -0,0 +1,3 @@ +namespace AasCore.Aas3_0_RC02.HasDataSpecification +{ +} \ No newline at end of file diff --git a/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/EmbeddedDataSpecification.cs b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/EmbeddedDataSpecification.cs new file mode 100644 index 000000000..e71f2af59 --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/EmbeddedDataSpecification.cs @@ -0,0 +1,7 @@ +using Newtonsoft.Json; +using System.Collections.Generic; +using System.Xml.Serialization; + +namespace AasCore.Aas3_0_RC02.HasDataSpecification +{ +} \ No newline at end of file diff --git a/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/HasDataSpecification.cs b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/HasDataSpecification.cs new file mode 100644 index 000000000..27cd04edb --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/HasDataSpecification.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace AasCore.Aas3_0_RC02.HasDataSpecification +{ +} diff --git a/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/LangStringSetIEC61360.cs b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/LangStringSetIEC61360.cs new file mode 100644 index 000000000..b9a9001a6 --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/DataSpecification/LangStringSetIEC61360.cs @@ -0,0 +1,9 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AasCore.Aas3_0_RC02.HasDataSpecification +{ +} diff --git a/src/AasxServer.DomainModelV3_0_RC02/DiaryData/DiaryDataDef.cs b/src/AasxServer.DomainModelV3_0_RC02/DiaryData/DiaryDataDef.cs new file mode 100644 index 000000000..5462498dd --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/DiaryData/DiaryDataDef.cs @@ -0,0 +1,61 @@ +using AasCore.Aas3_0_RC02; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +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/AasxServer.DomainModelV3_0_RC02/DiaryData/IAasDiaryEntry.cs b/src/AasxServer.DomainModelV3_0_RC02/DiaryData/IAasDiaryEntry.cs new file mode 100644 index 000000000..70ca4eba7 --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/DiaryData/IAasDiaryEntry.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AdminShellNS.DiaryData +{ + public interface IAasDiaryEntry + { + } +} diff --git a/src/AasxServer.DomainModelV3_0_RC02/DiaryData/IDiaryData.cs b/src/AasxServer.DomainModelV3_0_RC02/DiaryData/IDiaryData.cs new file mode 100644 index 000000000..4c9c0f896 --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/DiaryData/IDiaryData.cs @@ -0,0 +1,13 @@ +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/AasxServer.DomainModelV3_0_RC02/constants.cs b/src/AasxServer.DomainModelV3_0_RC02/constants.cs new file mode 100644 index 000000000..20f76dee7 --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/constants.cs @@ -0,0 +1,216 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +using System.Collections.Generic; // can't alias + +namespace AasCore.Aas3_0_RC02 +{ + /// + /// Provide constant values of the meta-model. + /// + public static class Constants + { + public static readonly HashSet ValidCategoriesForDataElement = ( + new HashSet() + { + "CONSTANT", + "PARAMETER", + "VARIABLE" + }); + + public static readonly HashSet ValidCategoriesForConceptDescription = ( + new HashSet() + { + "VALUE", + "PROPERTY", + "REFERENCE", + "DOCUMENT", + "CAPABILITY", + "RELATIONSHIP", + "COLLECTION", + "FUNCTION", + "EVENT", + "ENTITY", + "APPLICATION_CLASS", + "QUALIFIER", + "VIEW" + }); + + public static readonly HashSet GenericFragmentKeys = ( + new HashSet() + { + KeyTypes.FragmentReference + }); + + public static readonly HashSet GenericGloballyIdentifiables = ( + new HashSet() + { + KeyTypes.GlobalReference + }); + + public static readonly HashSet AasIdentifiables = ( + new HashSet() + { + KeyTypes.AssetAdministrationShell, + KeyTypes.ConceptDescription, + KeyTypes.Identifiable, + KeyTypes.Submodel + }); + + public static readonly HashSet AasSubmodelElementsAsKeys = ( + new HashSet() + { + KeyTypes.AnnotatedRelationshipElement, + KeyTypes.BasicEventElement, + KeyTypes.Blob, + KeyTypes.Capability, + KeyTypes.DataElement, + KeyTypes.Entity, + KeyTypes.EventElement, + KeyTypes.File, + KeyTypes.MultiLanguageProperty, + KeyTypes.Operation, + KeyTypes.Property, + KeyTypes.Range, + KeyTypes.ReferenceElement, + KeyTypes.RelationshipElement, + KeyTypes.SubmodelElement, + KeyTypes.SubmodelElementList, + KeyTypes.SubmodelElementCollection + }); + + public static readonly HashSet AasReferableNonIdentifiables = ( + new HashSet() + { + KeyTypes.AnnotatedRelationshipElement, + KeyTypes.BasicEventElement, + KeyTypes.Blob, + KeyTypes.Capability, + KeyTypes.DataElement, + KeyTypes.Entity, + KeyTypes.EventElement, + KeyTypes.File, + KeyTypes.MultiLanguageProperty, + KeyTypes.Operation, + KeyTypes.Property, + KeyTypes.Range, + KeyTypes.ReferenceElement, + KeyTypes.RelationshipElement, + KeyTypes.SubmodelElement, + KeyTypes.SubmodelElementCollection, + KeyTypes.SubmodelElementList + }); + + public static readonly HashSet AasReferables = ( + new HashSet() + { + KeyTypes.AssetAdministrationShell, + KeyTypes.ConceptDescription, + KeyTypes.Identifiable, + KeyTypes.Submodel, + KeyTypes.AnnotatedRelationshipElement, + KeyTypes.BasicEventElement, + KeyTypes.Blob, + KeyTypes.Capability, + KeyTypes.DataElement, + KeyTypes.Entity, + KeyTypes.EventElement, + KeyTypes.File, + KeyTypes.MultiLanguageProperty, + KeyTypes.Operation, + KeyTypes.Property, + KeyTypes.Range, + KeyTypes.ReferenceElement, + KeyTypes.Referable, + KeyTypes.RelationshipElement, + KeyTypes.SubmodelElement, + KeyTypes.SubmodelElementCollection, + KeyTypes.SubmodelElementList + }); + + public static readonly HashSet GloballyIdentifiables = ( + new HashSet() + { + KeyTypes.GlobalReference, + KeyTypes.AssetAdministrationShell, + KeyTypes.ConceptDescription, + KeyTypes.Identifiable, + KeyTypes.Submodel + }); + + public static readonly HashSet FragmentKeys = ( + new HashSet() + { + KeyTypes.FragmentReference, + KeyTypes.AnnotatedRelationshipElement, + KeyTypes.BasicEventElement, + KeyTypes.Blob, + KeyTypes.Capability, + KeyTypes.DataElement, + KeyTypes.Entity, + KeyTypes.EventElement, + KeyTypes.File, + KeyTypes.MultiLanguageProperty, + KeyTypes.Operation, + KeyTypes.Property, + KeyTypes.Range, + KeyTypes.ReferenceElement, + KeyTypes.RelationshipElement, + KeyTypes.SubmodelElement, + KeyTypes.SubmodelElementList, + KeyTypes.SubmodelElementCollection + }); + + public static readonly HashSet DataTypeIec61360ForPropertyOrValue = ( + new HashSet() + { + DataTypeIec61360.Date, + DataTypeIec61360.String, + DataTypeIec61360.StringTranslatable, + DataTypeIec61360.IntegerMeasure, + DataTypeIec61360.IntegerCount, + DataTypeIec61360.IntegerCurrency, + DataTypeIec61360.RealMeasure, + DataTypeIec61360.RealCount, + DataTypeIec61360.RealCurrency, + DataTypeIec61360.Boolean, + DataTypeIec61360.Rational, + DataTypeIec61360.RationalMeasure, + DataTypeIec61360.Time, + DataTypeIec61360.Timestamp + }); + + public static readonly HashSet DataTypeIec61360ForReference = ( + new HashSet() + { + DataTypeIec61360.String, + DataTypeIec61360.Iri, + DataTypeIec61360.Irdi + }); + + public static readonly HashSet DataTypeIec61360ForDocument = ( + new HashSet() + { + DataTypeIec61360.File, + DataTypeIec61360.Blob, + DataTypeIec61360.Html + }); + + public static readonly HashSet Iec61360DataTypesWithUnit = ( + new HashSet() + { + DataTypeIec61360.IntegerMeasure, + DataTypeIec61360.RealMeasure, + DataTypeIec61360.RationalMeasure, + DataTypeIec61360.IntegerCurrency, + DataTypeIec61360.RealCurrency + }); + } // public static class Constants +} // namespace AasCore.Aas3_0_RC02 + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/src/AasxServer.DomainModelV3_0_RC02/copying.cs b/src/AasxServer.DomainModelV3_0_RC02/copying.cs new file mode 100644 index 000000000..3e58e7493 --- /dev/null +++ b/src/AasxServer.DomainModelV3_0_RC02/copying.cs @@ -0,0 +1,2449 @@ +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ + +using Aas = AasCore.Aas3_0_RC02; // renamed +using System.Collections.Generic; // can't alias + +namespace AasCore.Aas3_0_RC02 +{ + /// + /// Allow for making shallow and deep copies of AAS model instances. + /// + public static class Copying + { + private static readonly ShallowCopier ShallowCopierInstance = ( + new ShallowCopier()); + + private static readonly DeepCopier DeepCopierInstance = ( + new DeepCopier()); + + /// + /// Make a shallow copy of . + /// + /// + /// All the properties are copied by reference. This includes also the lists. + /// Hence, a list property is copied by reference, and not, as sometimes might be + /// expected, as a new list of underlying references. + /// . + /// to be copied in a shallow manner + /// type to cast the result to + public static T Shallow(T that) where T : Aas.IClass + { + return (T)ShallowCopierInstance.Transform(that); + } + + /// + /// Make a recursively a deep copy of . + /// + /// to be deeply copied in a recursive manner + /// type to cast the result to + public static T Deep(T that) where T : Aas.IClass + { + return (T)DeepCopierInstance.Transform(that); + } + + /// Dispatch the making of shallow copies. + internal class ShallowCopier : Visitation.AbstractTransformer + { + public override Aas.IClass Transform(Aas.Extension that) + { + return new Aas.Extension( + that.Name, + that.SemanticId, + that.SupplementalSemanticIds, + that.ValueType, + that.Value, + that.RefersTo); + } + + public override Aas.IClass Transform(Aas.AdministrativeInformation that) + { + return new Aas.AdministrativeInformation( + that.EmbeddedDataSpecifications, + that.Version, + that.Revision); + } + + public override Aas.IClass Transform(Aas.Qualifier that) + { + return new Aas.Qualifier( + that.Type, + that.ValueType, + that.SemanticId, + that.SupplementalSemanticIds, + that.Kind, + that.Value, + that.ValueId); + } + + public override Aas.IClass Transform(Aas.AssetAdministrationShell that) + { + return new Aas.AssetAdministrationShell( + that.Id, + that.AssetInformation, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Administration, + that.EmbeddedDataSpecifications, + that.DerivedFrom, + that.Submodels); + } + + public override Aas.IClass Transform(Aas.AssetInformation that) + { + return new Aas.AssetInformation( + that.AssetKind, + that.GlobalAssetId, + that.SpecificAssetIds, + that.DefaultThumbnail); + } + + public override Aas.IClass Transform(Aas.Resource that) + { + return new Aas.Resource(that.Path, that.ContentType); + } + + public override Aas.IClass Transform(Aas.SpecificAssetId that) + { + return new Aas.SpecificAssetId( + that.Name, + that.Value, + that.ExternalSubjectId, + that.SemanticId, + that.SupplementalSemanticIds); + } + + public override Aas.IClass Transform(Aas.Submodel that) + { + return new Aas.Submodel( + that.Id, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Administration, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.SubmodelElements); + } + + public override Aas.IClass Transform(Aas.RelationshipElement that) + { + return new Aas.RelationshipElement( + that.First, + that.Second, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications); + } + + public override Aas.IClass Transform(Aas.SubmodelElementList that) + { + return new Aas.SubmodelElementList( + that.TypeValueListElement, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.OrderRelevant, + that.Value, + that.SemanticIdListElement, + that.ValueTypeListElement); + } + + public override Aas.IClass Transform(Aas.SubmodelElementCollection that) + { + return new Aas.SubmodelElementCollection( + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.Value); + } + + public override Aas.IClass Transform(Aas.Property that) + { + return new Aas.Property( + that.ValueType, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.Value, + that.ValueId); + } + + public override Aas.IClass Transform(Aas.MultiLanguageProperty that) + { + return new Aas.MultiLanguageProperty( + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.Value, + that.ValueId); + } + + public override Aas.IClass Transform(Aas.Range that) + { + return new Aas.Range( + that.ValueType, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.Min, + that.Max); + } + + public override Aas.IClass Transform(Aas.ReferenceElement that) + { + return new Aas.ReferenceElement( + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.Value); + } + + public override Aas.IClass Transform(Aas.Blob that) + { + return new Aas.Blob( + that.ContentType, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.Value); + } + + public override Aas.IClass Transform(Aas.File that) + { + return new Aas.File( + that.ContentType, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.Value); + } + + public override Aas.IClass Transform(Aas.AnnotatedRelationshipElement that) + { + return new Aas.AnnotatedRelationshipElement( + that.First, + that.Second, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.Annotations); + } + + public override Aas.IClass Transform(Aas.Entity that) + { + return new Aas.Entity( + that.EntityType, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.Statements, + that.GlobalAssetId, + that.SpecificAssetId); + } + + public override Aas.IClass Transform(Aas.EventPayload that) + { + return new Aas.EventPayload( + that.Source, + that.ObservableReference, + that.TimeStamp, + that.SourceSemanticId, + that.ObservableSemanticId, + that.Topic, + that.SubjectId, + that.Payload); + } + + public override Aas.IClass Transform(Aas.BasicEventElement that) + { + return new Aas.BasicEventElement( + that.Observed, + that.Direction, + that.State, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.MessageTopic, + that.MessageBroker, + that.LastUpdate, + that.MinInterval, + that.MaxInterval); + } + + public override Aas.IClass Transform(Aas.Operation that) + { + return new Aas.Operation( + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications, + that.InputVariables, + that.OutputVariables, + that.InoutputVariables); + } + + public override Aas.IClass Transform(Aas.OperationVariable that) + { + return new Aas.OperationVariable(that.Value); + } + + public override Aas.IClass Transform(Aas.Capability that) + { + return new Aas.Capability( + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Kind, + that.SemanticId, + that.SupplementalSemanticIds, + that.Qualifiers, + that.EmbeddedDataSpecifications); + } + + public override Aas.IClass Transform(Aas.ConceptDescription that) + { + return new Aas.ConceptDescription( + that.Id, + that.Extensions, + that.Category, + that.IdShort, + that.DisplayName, + that.Description, + that.Checksum, + that.Administration, + that.EmbeddedDataSpecifications, + that.IsCaseOf); + } + + public override Aas.IClass Transform(Aas.Reference that) + { + return new Aas.Reference( + that.Type, + that.Keys, + that.ReferredSemanticId); + } + + public override Aas.IClass Transform(Aas.Key that) + { + return new Aas.Key(that.Type, that.Value); + } + + public override Aas.IClass Transform(Aas.LangString that) + { + return new Aas.LangString(that.Language, that.Text); + } + + public override Aas.IClass Transform(Aas.Environment that) + { + return new Aas.Environment( + that.AssetAdministrationShells, + that.Submodels, + that.ConceptDescriptions); + } + + public override Aas.IClass Transform(Aas.EmbeddedDataSpecification that) + { + return new Aas.EmbeddedDataSpecification( + that.DataSpecification, + that.DataSpecificationContent); + } + + public override Aas.IClass Transform(Aas.ValueReferencePair that) + { + return new Aas.ValueReferencePair(that.Value, that.ValueId); + } + + public override Aas.IClass Transform(Aas.ValueList that) + { + return new Aas.ValueList(that.ValueReferencePairs); + } + + public override Aas.IClass Transform(Aas.DataSpecificationIec61360 that) + { + return new Aas.DataSpecificationIec61360( + that.PreferredName, + that.ShortName, + that.Unit, + that.UnitId, + that.SourceOfDefinition, + that.Symbol, + that.DataType, + that.Definition, + that.ValueFormat, + that.ValueList, + that.Value, + that.LevelType); + } + + public override Aas.IClass Transform(Aas.DataSpecificationPhysicalUnit that) + { + return new Aas.DataSpecificationPhysicalUnit( + that.UnitName, + that.UnitSymbol, + that.Definition, + that.SiNotation, + that.SiName, + that.DinNotation, + that.EceName, + that.EceCode, + that.NistName, + that.SourceOfDefinition, + that.ConversionFactor, + that.RegistrationAuthorityId, + that.Supplier); + } + } // internal class ShallowCopier + + /// Dispatch the making of deep copies. + internal class DeepCopier : Visitation.AbstractTransformer + { + public override Aas.IClass Transform(Aas.Extension that) + { + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + return new Aas.Extension( + that.Name, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + that.ValueType, + that.Value, + (that.RefersTo != null) + ? Deep(that.RefersTo) + : null + ); + } + + public override Aas.IClass Transform(Aas.AdministrativeInformation that) + { + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + return new Aas.AdministrativeInformation( + theEmbeddedDataSpecifications, + that.Version, + that.Revision + ); + } + + public override Aas.IClass Transform(Aas.Qualifier that) + { + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + return new Aas.Qualifier( + that.Type, + that.ValueType, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + that.Kind, + that.Value, + (that.ValueId != null) + ? Deep(that.ValueId) + : null + ); + } + + public override Aas.IClass Transform(Aas.AssetAdministrationShell that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + List? theSubmodels = null; + if (that.Submodels != null) + { + theSubmodels = new List( + that.Submodels.Count); + foreach (var item in that.Submodels) + { + theSubmodels.Add(Deep(item)); + } + } + + return new Aas.AssetAdministrationShell( + that.Id, + Deep(that.AssetInformation), + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + (that.Administration != null) + ? Deep(that.Administration) + : null, + theEmbeddedDataSpecifications, + (that.DerivedFrom != null) + ? Deep(that.DerivedFrom) + : null, + theSubmodels + ); + } + + public override Aas.IClass Transform(Aas.AssetInformation that) + { + List? theSpecificAssetIds = null; + if (that.SpecificAssetIds != null) + { + theSpecificAssetIds = new List( + that.SpecificAssetIds.Count); + foreach (var item in that.SpecificAssetIds) + { + theSpecificAssetIds.Add(Deep(item)); + } + } + + return new Aas.AssetInformation( + that.AssetKind, + (that.GlobalAssetId != null) + ? Deep(that.GlobalAssetId) + : null, + theSpecificAssetIds, + (that.DefaultThumbnail != null) + ? Deep(that.DefaultThumbnail) + : null + ); + } + + public override Aas.IClass Transform(Aas.Resource that) + { + return new Aas.Resource( + that.Path, + that.ContentType + ); + } + + public override Aas.IClass Transform(Aas.SpecificAssetId that) + { + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + return new Aas.SpecificAssetId( + that.Name, + that.Value, + Deep(that.ExternalSubjectId), + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds + ); + } + + public override Aas.IClass Transform(Aas.Submodel that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + List? theSubmodelElements = null; + if (that.SubmodelElements != null) + { + theSubmodelElements = new List( + that.SubmodelElements.Count); + foreach (var item in that.SubmodelElements) + { + theSubmodelElements.Add(Deep(item)); + } + } + + return new Aas.Submodel( + that.Id, + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + (that.Administration != null) + ? Deep(that.Administration) + : null, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theSubmodelElements + ); + } + + public override Aas.IClass Transform(Aas.RelationshipElement that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + return new Aas.RelationshipElement( + Deep(that.First), + Deep(that.Second), + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications + ); + } + + public override Aas.IClass Transform(Aas.SubmodelElementList that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + List? theValue = null; + if (that.Value != null) + { + theValue = new List( + that.Value.Count); + foreach (var item in that.Value) + { + theValue.Add(Deep(item)); + } + } + + return new Aas.SubmodelElementList( + that.TypeValueListElement, + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.OrderRelevant, + theValue, + (that.SemanticIdListElement != null) + ? Deep(that.SemanticIdListElement) + : null, + that.ValueTypeListElement + ); + } + + public override Aas.IClass Transform(Aas.SubmodelElementCollection that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + List? theValue = null; + if (that.Value != null) + { + theValue = new List( + that.Value.Count); + foreach (var item in that.Value) + { + theValue.Add(Deep(item)); + } + } + + return new Aas.SubmodelElementCollection( + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue + ); + } + + public override Aas.IClass Transform(Aas.Property that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + return new Aas.Property( + that.ValueType, + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.Value, + (that.ValueId != null) + ? Deep(that.ValueId) + : null + ); + } + + public override Aas.IClass Transform(Aas.MultiLanguageProperty that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + List? theValue = null; + if (that.Value != null) + { + theValue = new List( + that.Value.Count); + foreach (var item in that.Value) + { + theValue.Add(Deep(item)); + } + } + + return new Aas.MultiLanguageProperty( + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue, + (that.ValueId != null) + ? Deep(that.ValueId) + : null + ); + } + + public override Aas.IClass Transform(Aas.Range that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + return new Aas.Range( + that.ValueType, + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.Min, + that.Max + ); + } + + public override Aas.IClass Transform(Aas.ReferenceElement that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + return new Aas.ReferenceElement( + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + (that.Value != null) + ? Deep(that.Value) + : null + ); + } + + public override Aas.IClass Transform(Aas.Blob that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + return new Aas.Blob( + that.ContentType, + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.Value + ); + } + + public override Aas.IClass Transform(Aas.File that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + return new Aas.File( + that.ContentType, + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.Value + ); + } + + public override Aas.IClass Transform(Aas.AnnotatedRelationshipElement that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + List? theAnnotations = null; + if (that.Annotations != null) + { + theAnnotations = new List( + that.Annotations.Count); + foreach (var item in that.Annotations) + { + theAnnotations.Add(Deep(item)); + } + } + + return new Aas.AnnotatedRelationshipElement( + Deep(that.First), + Deep(that.Second), + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theAnnotations + ); + } + + public override Aas.IClass Transform(Aas.Entity that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + List? theStatements = null; + if (that.Statements != null) + { + theStatements = new List( + that.Statements.Count); + foreach (var item in that.Statements) + { + theStatements.Add(Deep(item)); + } + } + + return new Aas.Entity( + that.EntityType, + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theStatements, + (that.GlobalAssetId != null) + ? Deep(that.GlobalAssetId) + : null, + (that.SpecificAssetId != null) + ? Deep(that.SpecificAssetId) + : null + ); + } + + public override Aas.IClass Transform(Aas.EventPayload that) + { + return new Aas.EventPayload( + Deep(that.Source), + Deep(that.ObservableReference), + that.TimeStamp, + (that.SourceSemanticId != null) + ? Deep(that.SourceSemanticId) + : null, + (that.ObservableSemanticId != null) + ? Deep(that.ObservableSemanticId) + : null, + that.Topic, + (that.SubjectId != null) + ? Deep(that.SubjectId) + : null, + that.Payload + ); + } + + public override Aas.IClass Transform(Aas.BasicEventElement that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + return new Aas.BasicEventElement( + Deep(that.Observed), + that.Direction, + that.State, + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + that.MessageTopic, + (that.MessageBroker != null) + ? Deep(that.MessageBroker) + : null, + that.LastUpdate, + that.MinInterval, + that.MaxInterval + ); + } + + public override Aas.IClass Transform(Aas.Operation that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + List? theInputVariables = null; + if (that.InputVariables != null) + { + theInputVariables = new List( + that.InputVariables.Count); + foreach (var item in that.InputVariables) + { + theInputVariables.Add(Deep(item)); + } + } + + List? theOutputVariables = null; + if (that.OutputVariables != null) + { + theOutputVariables = new List( + that.OutputVariables.Count); + foreach (var item in that.OutputVariables) + { + theOutputVariables.Add(Deep(item)); + } + } + + List? theInoutputVariables = null; + if (that.InoutputVariables != null) + { + theInoutputVariables = new List( + that.InoutputVariables.Count); + foreach (var item in that.InoutputVariables) + { + theInoutputVariables.Add(Deep(item)); + } + } + + return new Aas.Operation( + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theInputVariables, + theOutputVariables, + theInoutputVariables + ); + } + + public override Aas.IClass Transform(Aas.OperationVariable that) + { + return new Aas.OperationVariable( + Deep(that.Value) + ); + } + + public override Aas.IClass Transform(Aas.Capability that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theSupplementalSemanticIds = null; + if (that.SupplementalSemanticIds != null) + { + theSupplementalSemanticIds = new List( + that.SupplementalSemanticIds.Count); + foreach (var item in that.SupplementalSemanticIds) + { + theSupplementalSemanticIds.Add(Deep(item)); + } + } + + List? theQualifiers = null; + if (that.Qualifiers != null) + { + theQualifiers = new List( + that.Qualifiers.Count); + foreach (var item in that.Qualifiers) + { + theQualifiers.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + return new Aas.Capability( + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + that.Kind, + (that.SemanticId != null) + ? Deep(that.SemanticId) + : null, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications + ); + } + + public override Aas.IClass Transform(Aas.ConceptDescription that) + { + List? theExtensions = null; + if (that.Extensions != null) + { + theExtensions = new List( + that.Extensions.Count); + foreach (var item in that.Extensions) + { + theExtensions.Add(Deep(item)); + } + } + + List? theDisplayName = null; + if (that.DisplayName != null) + { + theDisplayName = new List( + that.DisplayName.Count); + foreach (var item in that.DisplayName) + { + theDisplayName.Add(Deep(item)); + } + } + + List? theDescription = null; + if (that.Description != null) + { + theDescription = new List( + that.Description.Count); + foreach (var item in that.Description) + { + theDescription.Add(Deep(item)); + } + } + + List? theEmbeddedDataSpecifications = null; + if (that.EmbeddedDataSpecifications != null) + { + theEmbeddedDataSpecifications = new List( + that.EmbeddedDataSpecifications.Count); + foreach (var item in that.EmbeddedDataSpecifications) + { + theEmbeddedDataSpecifications.Add(Deep(item)); + } + } + + List? theIsCaseOf = null; + if (that.IsCaseOf != null) + { + theIsCaseOf = new List( + that.IsCaseOf.Count); + foreach (var item in that.IsCaseOf) + { + theIsCaseOf.Add(Deep(item)); + } + } + + return new Aas.ConceptDescription( + that.Id, + theExtensions, + that.Category, + that.IdShort, + theDisplayName, + theDescription, + that.Checksum, + (that.Administration != null) + ? Deep(that.Administration) + : null, + theEmbeddedDataSpecifications, + theIsCaseOf + ); + } + + public override Aas.IClass Transform(Aas.Reference that) + { + var theKeys = new List( + that.Keys.Count); + foreach (var item in that.Keys) + { + theKeys.Add(Deep(item)); + } + + return new Aas.Reference( + that.Type, + theKeys, + (that.ReferredSemanticId != null) + ? Deep(that.ReferredSemanticId) + : null + ); + } + + public override Aas.IClass Transform(Aas.Key that) + { + return new Aas.Key( + that.Type, + that.Value + ); + } + + public override Aas.IClass Transform(Aas.LangString that) + { + return new Aas.LangString( + that.Language, + that.Text + ); + } + + public override Aas.IClass Transform(Aas.Environment that) + { + List? theAssetAdministrationShells = null; + if (that.AssetAdministrationShells != null) + { + theAssetAdministrationShells = new List( + that.AssetAdministrationShells.Count); + foreach (var item in that.AssetAdministrationShells) + { + theAssetAdministrationShells.Add(Deep(item)); + } + } + + List? theSubmodels = null; + if (that.Submodels != null) + { + theSubmodels = new List( + that.Submodels.Count); + foreach (var item in that.Submodels) + { + theSubmodels.Add(Deep(item)); + } + } + + List? theConceptDescriptions = null; + if (that.ConceptDescriptions != null) + { + theConceptDescriptions = new List( + that.ConceptDescriptions.Count); + foreach (var item in that.ConceptDescriptions) + { + theConceptDescriptions.Add(Deep(item)); + } + } + + return new Aas.Environment( + theAssetAdministrationShells, + theSubmodels, + theConceptDescriptions + ); + } + + public override Aas.IClass Transform(Aas.EmbeddedDataSpecification that) + { + return new Aas.EmbeddedDataSpecification( + Deep(that.DataSpecification), + Deep(that.DataSpecificationContent) + ); + } + + public override Aas.IClass Transform(Aas.ValueReferencePair that) + { + return new Aas.ValueReferencePair( + that.Value, + Deep(that.ValueId) + ); + } + + public override Aas.IClass Transform(Aas.ValueList that) + { + var theValueReferencePairs = new List( + that.ValueReferencePairs.Count); + foreach (var item in that.ValueReferencePairs) + { + theValueReferencePairs.Add(Deep(item)); + } + + return new Aas.ValueList( + theValueReferencePairs + ); + } + + public override Aas.IClass Transform(Aas.DataSpecificationIec61360 that) + { + var thePreferredName = new List( + that.PreferredName.Count); + foreach (var item in that.PreferredName) + { + thePreferredName.Add(Deep(item)); + } + + List? theShortName = null; + if (that.ShortName != null) + { + theShortName = new List( + that.ShortName.Count); + foreach (var item in that.ShortName) + { + theShortName.Add(Deep(item)); + } + } + + List? theDefinition = null; + if (that.Definition != null) + { + theDefinition = new List( + that.Definition.Count); + foreach (var item in that.Definition) + { + theDefinition.Add(Deep(item)); + } + } + + return new Aas.DataSpecificationIec61360( + thePreferredName, + theShortName, + that.Unit, + (that.UnitId != null) + ? Deep(that.UnitId) + : null, + that.SourceOfDefinition, + that.Symbol, + that.DataType, + theDefinition, + that.ValueFormat, + (that.ValueList != null) + ? Deep(that.ValueList) + : null, + that.Value, + that.LevelType + ); + } + + public override Aas.IClass Transform(Aas.DataSpecificationPhysicalUnit that) + { + var theDefinition = new List( + that.Definition.Count); + foreach (var item in that.Definition) + { + theDefinition.Add(Deep(item)); + } + + return new Aas.DataSpecificationPhysicalUnit( + that.UnitName, + that.UnitSymbol, + theDefinition, + that.SiNotation, + that.SiName, + that.DinNotation, + that.EceName, + that.EceCode, + that.NistName, + that.SourceOfDefinition, + that.ConversionFactor, + that.RegistrationAuthorityId, + that.Supplier + ); + } + } // internal class DeepCopier + } // public static class Copying +} // namespace AasCore.Aas3_0_RC02 + +/* + * This code has been automatically generated by aas-core-codegen. + * Do NOT edit or append. + */ diff --git a/src/AasxServer.DomainModelV3_0_RC02/jsonization.cs b/src/AasxServer.DomainModelV3_0_RC02/jsonization.cs index e1b33bda0..9f08137cd 100644 --- a/src/AasxServer.DomainModelV3_0_RC02/jsonization.cs +++ b/src/AasxServer.DomainModelV3_0_RC02/jsonization.cs @@ -3,11 +3,11 @@ * Do NOT edit or append. */ +using Aas = AasCore.Aas3_0_RC02; // renamed using CodeAnalysis = System.Diagnostics.CodeAnalysis; using Nodes = System.Text.Json.Nodes; -using System.Collections.Generic; // can't alias -using Aas = AasCore.Aas3_0_RC02; +using System.Collections.Generic; // can't alias namespace AasCore.Aas3_0_RC02 { @@ -326,164 +326,205 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; + string? theName = null; + Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { + DataTypeDefXsd? theValueType = null; + string? theValue = null; + Reference? theRefersTo = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "name": + { + if (keyValue.Value == null) + { + continue; + } + + theName = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "name")); + return null; + } + if (theName == null) + { + throw new System.InvalidOperationException( + "Unexpected theName null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "valueType": + { + if (keyValue.Value == null) + { + continue; + } + + theValueType = DeserializeImplementation.DataTypeDefXsdFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueType")); + return null; + } + if (theValueType == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueType null when error is also null"); + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + case "refersTo": + { + if (keyValue.Value == null) + { + continue; + } + + theRefersTo = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "refersTo")); + return null; + } + if (theRefersTo == null) + { + throw new System.InvalidOperationException( + "Unexpected theRefersTo null when error is also null"); + } + break; + } + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); + $"Unexpected property: {keyValue.Key}"); return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; } } - Nodes.JsonNode? nodeName = obj["name"]; - if (nodeName == null) + if (theName == null) { error = new Reporting.Error( - "Required property \"name\" is missing "); - return null; - } - string? theName = DeserializeImplementation.StringFrom( - nodeName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "name")); + "Required property \"name\" is missing"); return null; } - if (theName == null) - { - throw new System.InvalidOperationException( - "Unexpected theName null when error is also null"); - } - - Nodes.JsonNode? nodeValueType = obj["valueType"]; - Aas.DataTypeDefXsd? theValueType = null; - if (nodeValueType != null) - { - theValueType = DeserializeImplementation.DataTypeDefXsdFrom( - nodeValueType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "valueType")); - return null; - } - if (theValueType == null) - { - throw new System.InvalidOperationException( - "Unexpected theValueType null when error is also null"); - } - } - - Nodes.JsonNode? nodeValue = obj["value"]; - string? theValue = null; - if (nodeValue != null) - { - theValue = DeserializeImplementation.StringFrom( - nodeValue, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - if (theValue == null) - { - throw new System.InvalidOperationException( - "Unexpected theValue null when error is also null"); - } - } - - Nodes.JsonNode? nodeRefersTo = obj["refersTo"]; - Aas.Reference? theRefersTo = null; - if (nodeRefersTo != null) - { - theRefersTo = DeserializeImplementation.ReferenceFrom( - nodeRefersTo, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "refersTo")); - return null; - } - if (theRefersTo == null) - { - throw new System.InvalidOperationException( - "Unexpected theRefersTo null when error is also null"); - } - } return new Aas.Extension( theName @@ -794,7 +835,7 @@ internal static class DeserializeImplementation if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of ModelingKind "); + "Not a valid JSON representation of ModelingKind"); } return result; } // internal static ModelingKindFrom @@ -1025,102 +1066,128 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + List? theEmbeddedDataSpecifications = null; + string? theVersion = null; + string? theRevision = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "version": + { + if (keyValue.Value == null) + { + continue; + } + + theVersion = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "version")); + return null; + } + if (theVersion == null) + { + throw new System.InvalidOperationException( + "Unexpected theVersion null when error is also null"); + } + break; + } + case "revision": + { + if (keyValue.Value == null) + { + continue; + } + + theRevision = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "revision")); + return null; + } + if (theRevision == null) + { + throw new System.InvalidOperationException( + "Unexpected theRevision null when error is also null"); + } + break; + } + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; } } - Nodes.JsonNode? nodeVersion = obj["version"]; - string? theVersion = null; - if (nodeVersion != null) - { - theVersion = DeserializeImplementation.StringFrom( - nodeVersion, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "version")); - return null; - } - if (theVersion == null) - { - throw new System.InvalidOperationException( - "Unexpected theVersion null when error is also null"); - } - } - Nodes.JsonNode? nodeRevision = obj["revision"]; - string? theRevision = null; - if (nodeRevision != null) - { - theRevision = DeserializeImplementation.StringFrom( - nodeRevision, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "revision")); - return null; - } - if (theRevision == null) - { - throw new System.InvalidOperationException( - "Unexpected theRevision null when error is also null"); - } - } return new Aas.AdministrativeInformation( - theDataSpecifications, + theEmbeddedDataSpecifications, theVersion, theRevision); } // internal static AdministrativeInformationFrom @@ -1249,7 +1316,7 @@ internal static class DeserializeImplementation if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of QualifierKind "); + "Not a valid JSON representation of QualifierKind"); } return result; } // internal static QualifierKindFrom @@ -1273,187 +1340,237 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; + string? theType = null; + DataTypeDefXsd? theValueType = null; + Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { + QualifierKind? theKind = null; + string? theValue = null; + Reference? theValueId = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "type": + { + if (keyValue.Value == null) + { + continue; + } + + theType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "type")); + return null; + } + if (theType == null) + { + throw new System.InvalidOperationException( + "Unexpected theType null when error is also null"); + } + break; + } + case "valueType": + { + if (keyValue.Value == null) + { + continue; + } + + theValueType = DeserializeImplementation.DataTypeDefXsdFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueType")); + return null; + } + if (theValueType == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueType null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.QualifierKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + case "valueId": + { + if (keyValue.Value == null) + { + continue; + } + + theValueId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueId")); + return null; + } + if (theValueId == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueId null when error is also null"); + } + break; + } + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); + $"Unexpected property: {keyValue.Key}"); return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.QualifierKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.QualifierKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); } } - Nodes.JsonNode? nodeType = obj["type"]; - if (nodeType == null) + if (theType == null) { error = new Reporting.Error( - "Required property \"type\" is missing "); - return null; - } - string? theType = DeserializeImplementation.StringFrom( - nodeType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "type")); + "Required property \"type\" is missing"); return null; } - if (theType == null) - { - throw new System.InvalidOperationException( - "Unexpected theType null when error is also null"); - } - Nodes.JsonNode? nodeValueType = obj["valueType"]; - if (nodeValueType == null) + if (theValueType == null) { error = new Reporting.Error( - "Required property \"valueType\" is missing "); + "Required property \"valueType\" is missing"); return null; } - Aas.DataTypeDefXsd? theValueType = DeserializeImplementation.DataTypeDefXsdFrom( - nodeValueType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "valueType")); - return null; - } - if (theValueType == null) - { - throw new System.InvalidOperationException( - "Unexpected theValueType null when error is also null"); - } - - Nodes.JsonNode? nodeValue = obj["value"]; - string? theValue = null; - if (nodeValue != null) - { - theValue = DeserializeImplementation.StringFrom( - nodeValue, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - if (theValue == null) - { - throw new System.InvalidOperationException( - "Unexpected theValue null when error is also null"); - } - } - - Nodes.JsonNode? nodeValueId = obj["valueId"]; - Aas.Reference? theValueId = null; - if (nodeValueId != null) - { - theValueId = DeserializeImplementation.ReferenceFrom( - nodeValueId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "valueId")); - return null; - } - if (theValueId == null) - { - throw new System.InvalidOperationException( - "Unexpected theValueId null when error is also null"); - } - } return new Aas.Qualifier( theType @@ -1488,353 +1605,487 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; + string? theId = null; + AssetInformation? theAssetInformation = null; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeAdministration = obj["administration"]; - Aas.AdministrativeInformation? theAdministration = null; - if (nodeAdministration != null) - { - theAdministration = DeserializeImplementation.AdministrativeInformationFrom( - nodeAdministration, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "administration")); - return null; - } - if (theAdministration == null) - { - throw new System.InvalidOperationException( - "Unexpected theAdministration null when error is also null"); - } - } - - Nodes.JsonNode? nodeId = obj["id"]; - if (nodeId == null) - { - error = new Reporting.Error( - "Required property \"id\" is missing "); - return null; - } - string? theId = DeserializeImplementation.StringFrom( - nodeId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "id")); - return null; - } - if (theId == null) - { - throw new System.InvalidOperationException( - "Unexpected theId null when error is also null"); - } + AdministrativeInformation? theAdministration = null; + List? theEmbeddedDataSpecifications = null; + Reference? theDerivedFrom = null; + List? theSubmodels = null; - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "id": + { + if (keyValue.Value == null) + { + continue; + } + + theId = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "id")); + return null; + } + if (theId == null) + { + throw new System.InvalidOperationException( + "Unexpected theId null when error is also null"); + } + break; + } + case "assetInformation": + { + if (keyValue.Value == null) + { + continue; + } + + theAssetInformation = DeserializeImplementation.AssetInformationFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "assetInformation")); + return null; + } + if (theAssetInformation == null) + { + throw new System.InvalidOperationException( + "Unexpected theAssetInformation null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "administration": + { + if (keyValue.Value == null) + { + continue; + } + + theAdministration = DeserializeImplementation.AdministrativeInformationFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "administration")); + return null; + } + if (theAdministration == null) + { + throw new System.InvalidOperationException( + "Unexpected theAdministration null when error is also null"); + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "derivedFrom": + { + if (keyValue.Value == null) + { + continue; + } + + theDerivedFrom = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "derivedFrom")); + return null; + } + if (theDerivedFrom == null) + { + throw new System.InvalidOperationException( + "Unexpected theDerivedFrom null when error is also null"); + } + break; + } + case "submodels": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySubmodels = keyValue.Value as Nodes.JsonArray; + if (arraySubmodels == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "submodels")); + return null; + } + theSubmodels = new List( + arraySubmodels.Count); + int indexSubmodels = 0; + foreach (Nodes.JsonNode? item in arraySubmodels) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSubmodels)); + error.PrependSegment( + new Reporting.NameSegment( + "submodels")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSubmodels)); + error.PrependSegment( + new Reporting.NameSegment( + "submodels")); + return null; + } + theSubmodels.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSubmodels++; + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } - } - - Nodes.JsonNode? nodeDerivedFrom = obj["derivedFrom"]; - Aas.Reference? theDerivedFrom = null; - if (nodeDerivedFrom != null) - { - theDerivedFrom = DeserializeImplementation.ReferenceFrom( - nodeDerivedFrom, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "derivedFrom")); - return null; - } - if (theDerivedFrom == null) - { - throw new System.InvalidOperationException( - "Unexpected theDerivedFrom null when error is also null"); } } - Nodes.JsonNode? nodeAssetInformation = obj["assetInformation"]; - if (nodeAssetInformation == null) + if (theId == null) { error = new Reporting.Error( - "Required property \"assetInformation\" is missing "); - return null; - } - Aas.AssetInformation? theAssetInformation = DeserializeImplementation.AssetInformationFrom( - nodeAssetInformation, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "assetInformation")); + "Required property \"id\" is missing"); return null; } - if (theAssetInformation == null) - { - throw new System.InvalidOperationException( - "Unexpected theAssetInformation null when error is also null"); - } - Nodes.JsonNode? nodeSubmodels = obj["submodels"]; - List? theSubmodels = null; - if (nodeSubmodels != null) + if (theAssetInformation == null) { - Nodes.JsonArray? arraySubmodels = nodeSubmodels as Nodes.JsonArray; - if (arraySubmodels == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSubmodels.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "submodels")); - return null; - } - theSubmodels = new List( - arraySubmodels.Count); - int indexSubmodels = 0; - foreach (Nodes.JsonNode? item in arraySubmodels) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSubmodels)); - error.PrependSegment( - new Reporting.NameSegment( - "submodels")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSubmodels)); - error.PrependSegment( - new Reporting.NameSegment( - "submodels")); - return null; - } - theSubmodels.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSubmodels++; - } + error = new Reporting.Error( + "Required property \"assetInformation\" is missing"); + return null; } return new Aas.AssetAdministrationShell( @@ -1851,7 +2102,7 @@ internal static class DeserializeImplementation theDescription, theChecksum, theAdministration, - theDataSpecifications, + theEmbeddedDataSpecifications, theDerivedFrom, theSubmodels); } // internal static AssetAdministrationShellFrom @@ -1875,122 +2126,155 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeAssetKind = obj["assetKind"]; - if (nodeAssetKind == null) + AssetKind? theAssetKind = null; + Reference? theGlobalAssetId = null; + List? theSpecificAssetIds = null; + Resource? theDefaultThumbnail = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "assetKind": + { + if (keyValue.Value == null) + { + continue; + } + + theAssetKind = DeserializeImplementation.AssetKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "assetKind")); + return null; + } + if (theAssetKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theAssetKind null when error is also null"); + } + break; + } + case "globalAssetId": + { + if (keyValue.Value == null) + { + continue; + } + + theGlobalAssetId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "globalAssetId")); + return null; + } + if (theGlobalAssetId == null) + { + throw new System.InvalidOperationException( + "Unexpected theGlobalAssetId null when error is also null"); + } + break; + } + case "specificAssetIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySpecificAssetIds = keyValue.Value as Nodes.JsonArray; + if (arraySpecificAssetIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "specificAssetIds")); + return null; + } + theSpecificAssetIds = new List( + arraySpecificAssetIds.Count); + int indexSpecificAssetIds = 0; + foreach (Nodes.JsonNode? item in arraySpecificAssetIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSpecificAssetIds)); + error.PrependSegment( + new Reporting.NameSegment( + "specificAssetIds")); + return null; + } + SpecificAssetId? parsedItem = DeserializeImplementation.SpecificAssetIdFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSpecificAssetIds)); + error.PrependSegment( + new Reporting.NameSegment( + "specificAssetIds")); + return null; + } + theSpecificAssetIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSpecificAssetIds++; + } + break; + } + case "defaultThumbnail": + { + if (keyValue.Value == null) + { + continue; + } + + theDefaultThumbnail = DeserializeImplementation.ResourceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "defaultThumbnail")); + return null; + } + if (theDefaultThumbnail == null) + { + throw new System.InvalidOperationException( + "Unexpected theDefaultThumbnail null when error is also null"); + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; + } + } + + if (theAssetKind == null) { error = new Reporting.Error( - "Required property \"assetKind\" is missing "); + "Required property \"assetKind\" is missing"); return null; } - Aas.AssetKind? theAssetKind = DeserializeImplementation.AssetKindFrom( - nodeAssetKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "assetKind")); - return null; - } - if (theAssetKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theAssetKind null when error is also null"); - } - - Nodes.JsonNode? nodeGlobalAssetId = obj["globalAssetId"]; - Aas.Reference? theGlobalAssetId = null; - if (nodeGlobalAssetId != null) - { - theGlobalAssetId = DeserializeImplementation.ReferenceFrom( - nodeGlobalAssetId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "globalAssetId")); - return null; - } - if (theGlobalAssetId == null) - { - throw new System.InvalidOperationException( - "Unexpected theGlobalAssetId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSpecificAssetIds = obj["specificAssetIds"]; - List? theSpecificAssetIds = null; - if (nodeSpecificAssetIds != null) - { - Nodes.JsonArray? arraySpecificAssetIds = nodeSpecificAssetIds as Nodes.JsonArray; - if (arraySpecificAssetIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSpecificAssetIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "specificAssetIds")); - return null; - } - theSpecificAssetIds = new List( - arraySpecificAssetIds.Count); - int indexSpecificAssetIds = 0; - foreach (Nodes.JsonNode? item in arraySpecificAssetIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSpecificAssetIds)); - error.PrependSegment( - new Reporting.NameSegment( - "specificAssetIds")); - return null; - } - SpecificAssetId? parsedItem = DeserializeImplementation.SpecificAssetIdFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSpecificAssetIds)); - error.PrependSegment( - new Reporting.NameSegment( - "specificAssetIds")); - return null; - } - theSpecificAssetIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSpecificAssetIds++; - } - } - - Nodes.JsonNode? nodeDefaultThumbnail = obj["defaultThumbnail"]; - Aas.Resource? theDefaultThumbnail = null; - if (nodeDefaultThumbnail != null) - { - theDefaultThumbnail = DeserializeImplementation.ResourceFrom( - nodeDefaultThumbnail, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "defaultThumbnail")); - return null; - } - if (theDefaultThumbnail == null) - { - throw new System.InvalidOperationException( - "Unexpected theDefaultThumbnail null when error is also null"); - } - } return new Aas.AssetInformation( theAssetKind @@ -2020,48 +2304,73 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodePath = obj["path"]; - if (nodePath == null) - { - error = new Reporting.Error( - "Required property \"path\" is missing "); - return null; - } - string? thePath = DeserializeImplementation.StringFrom( - nodePath, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "path")); - return null; - } - if (thePath == null) - { - throw new System.InvalidOperationException( - "Unexpected thePath null when error is also null"); + string? thePath = null; + string? theContentType = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "path": + { + if (keyValue.Value == null) + { + continue; + } + + thePath = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "path")); + return null; + } + if (thePath == null) + { + throw new System.InvalidOperationException( + "Unexpected thePath null when error is also null"); + } + break; + } + case "contentType": + { + if (keyValue.Value == null) + { + continue; + } + + theContentType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "contentType")); + return null; + } + if (theContentType == null) + { + throw new System.InvalidOperationException( + "Unexpected theContentType null when error is also null"); + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; + } } - Nodes.JsonNode? nodeContentType = obj["contentType"]; - string? theContentType = null; - if (nodeContentType != null) + if (thePath == null) { - theContentType = DeserializeImplementation.StringFrom( - nodeContentType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "contentType")); - return null; - } - if (theContentType == null) - { - throw new System.InvalidOperationException( - "Unexpected theContentType null when error is also null"); - } + error = new Reporting.Error( + "Required property \"path\" is missing"); + return null; } return new Aas.Resource( @@ -2096,7 +2405,7 @@ internal static class DeserializeImplementation if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of AssetKind "); + "Not a valid JSON representation of AssetKind"); } return result; } // internal static AssetKindFrom @@ -2120,147 +2429,194 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; + string? theName = null; + string? theValue = null; + Reference? theExternalSubjectId = null; + Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "name": + { + if (keyValue.Value == null) + { + continue; + } + + theName = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "name")); + return null; + } + if (theName == null) + { + throw new System.InvalidOperationException( + "Unexpected theName null when error is also null"); + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + case "externalSubjectId": + { + if (keyValue.Value == null) + { + continue; + } + + theExternalSubjectId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "externalSubjectId")); + return null; + } + if (theExternalSubjectId == null) + { + throw new System.InvalidOperationException( + "Unexpected theExternalSubjectId null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); + $"Unexpected property: {keyValue.Key}"); return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; } } - Nodes.JsonNode? nodeName = obj["name"]; - if (nodeName == null) + if (theName == null) { error = new Reporting.Error( - "Required property \"name\" is missing "); - return null; - } - string? theName = DeserializeImplementation.StringFrom( - nodeName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "name")); + "Required property \"name\" is missing"); return null; } - if (theName == null) - { - throw new System.InvalidOperationException( - "Unexpected theName null when error is also null"); - } - Nodes.JsonNode? nodeValue = obj["value"]; - if (nodeValue == null) + if (theValue == null) { error = new Reporting.Error( - "Required property \"value\" is missing "); - return null; - } - string? theValue = DeserializeImplementation.StringFrom( - nodeValue, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "value")); + "Required property \"value\" is missing"); return null; } - if (theValue == null) - { - throw new System.InvalidOperationException( - "Unexpected theValue null when error is also null"); - } - Nodes.JsonNode? nodeExternalSubjectId = obj["externalSubjectId"]; - if (nodeExternalSubjectId == null) + if (theExternalSubjectId == null) { error = new Reporting.Error( - "Required property \"externalSubjectId\" is missing "); + "Required property \"externalSubjectId\" is missing"); return null; } - Aas.Reference? theExternalSubjectId = DeserializeImplementation.ReferenceFrom( - nodeExternalSubjectId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "externalSubjectId")); - return null; - } - if (theExternalSubjectId == null) - { - throw new System.InvalidOperationException( - "Unexpected theExternalSubjectId null when error is also null"); - } return new Aas.SpecificAssetId( theName @@ -2295,455 +2651,592 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; + string? theId = null; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeAdministration = obj["administration"]; - Aas.AdministrativeInformation? theAdministration = null; - if (nodeAdministration != null) - { - theAdministration = DeserializeImplementation.AdministrativeInformationFrom( - nodeAdministration, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "administration")); - return null; - } - if (theAdministration == null) - { - throw new System.InvalidOperationException( - "Unexpected theAdministration null when error is also null"); - } - } - - Nodes.JsonNode? nodeId = obj["id"]; - if (nodeId == null) - { - error = new Reporting.Error( - "Required property \"id\" is missing "); - return null; - } - string? theId = DeserializeImplementation.StringFrom( - nodeId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "id")); - return null; - } - if (theId == null) - { - throw new System.InvalidOperationException( - "Unexpected theId null when error is also null"); - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; + AdministrativeInformation? theAdministration = null; + ModelingKind? theKind = null; + Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } + List? theEmbeddedDataSpecifications = null; + List? theSubmodelElements = null; - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "id": + { + if (keyValue.Value == null) + { + continue; + } + + theId = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "id")); + return null; + } + if (theId == null) + { + throw new System.InvalidOperationException( + "Unexpected theId null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "administration": + { + if (keyValue.Value == null) + { + continue; + } + + theAdministration = DeserializeImplementation.AdministrativeInformationFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "administration")); + return null; + } + if (theAdministration == null) + { + throw new System.InvalidOperationException( + "Unexpected theAdministration null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "submodelElements": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySubmodelElements = keyValue.Value as Nodes.JsonArray; + if (arraySubmodelElements == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "submodelElements")); + return null; + } + theSubmodelElements = new List( + arraySubmodelElements.Count); + int indexSubmodelElements = 0; + foreach (Nodes.JsonNode? item in arraySubmodelElements) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSubmodelElements)); + error.PrependSegment( + new Reporting.NameSegment( + "submodelElements")); + return null; + } + ISubmodelElement? parsedItem = DeserializeImplementation.ISubmodelElementFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSubmodelElements)); + error.PrependSegment( + new Reporting.NameSegment( + "submodelElements")); + return null; + } + theSubmodelElements.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSubmodelElements++; + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; } } - Nodes.JsonNode? nodeSubmodelElements = obj["submodelElements"]; - List? theSubmodelElements = null; - if (nodeSubmodelElements != null) + if (theId == null) { - Nodes.JsonArray? arraySubmodelElements = nodeSubmodelElements as Nodes.JsonArray; - if (arraySubmodelElements == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSubmodelElements.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "submodelElements")); - return null; - } - theSubmodelElements = new List( - arraySubmodelElements.Count); - int indexSubmodelElements = 0; - foreach (Nodes.JsonNode? item in arraySubmodelElements) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSubmodelElements)); - error.PrependSegment( - new Reporting.NameSegment( - "submodelElements")); - return null; - } - ISubmodelElement? parsedItem = DeserializeImplementation.ISubmodelElementFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSubmodelElements)); - error.PrependSegment( - new Reporting.NameSegment( - "submodelElements")); - return null; - } - theSubmodelElements.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSubmodelElements++; - } + error = new Reporting.Error( + "Required property \"id\" is missing"); + return null; } return new Aas.Submodel( @@ -2761,7 +3254,7 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theSubmodelElements); } // internal static SubmodelFrom @@ -2940,412 +3433,1254 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; + Reference? theFirst = null; + Reference? theSecond = null; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + string? theChecksum = null; + ModelingKind? theKind = null; + Reference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; + List? theEmbeddedDataSpecifications = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "first": + { + if (keyValue.Value == null) + { + continue; + } + + theFirst = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "first")); + return null; + } + if (theFirst == null) + { + throw new System.InvalidOperationException( + "Unexpected theFirst null when error is also null"); + } + break; + } + case "second": + { + if (keyValue.Value == null) + { + continue; + } + + theSecond = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "second")); + return null; + } + if (theSecond == null) + { + throw new System.InvalidOperationException( + "Unexpected theSecond null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); + $"Unexpected property: {keyValue.Key}"); return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; } } - Nodes.JsonNode? nodeCategory = obj["category"]; - string? theCategory = null; - if (nodeCategory != null) + if (theFirst == null) { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } + error = new Reporting.Error( + "Required property \"first\" is missing"); + return null; } - Nodes.JsonNode? nodeIdShort = obj["idShort"]; - string? theIdShort = null; - if (nodeIdShort != null) + if (theSecond == null) { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } + error = new Reporting.Error( + "Required property \"second\" is missing"); + return null; } - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } + return new Aas.RelationshipElement( + theFirst + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theSecond + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theChecksum, + theKind, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications); + } // internal static RelationshipElementFrom - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) + /// + /// Deserialize the enumeration AasSubmodelElements from the . + /// + /// JSON node to be parsed + /// Error, if any, during the deserialization + internal static Aas.AasSubmodelElements? AasSubmodelElementsFrom( + Nodes.JsonNode node, + out Reporting.Error? error) + { + error = null; + string? text = DeserializeImplementation.StringFrom( + node, out error); + if (error != null) { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } + return null; } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; - string? theChecksum = null; - if (nodeChecksum != null) + if (text == null) { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } + throw new System.InvalidOperationException( + "Unexpected text null if error null"); } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) + Aas.AasSubmodelElements? result = Stringification.AasSubmodelElementsFromString(text); + if (result == null) { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } + error = new Reporting.Error( + "Not a valid JSON representation of AasSubmodelElements"); } + return result; + } // internal static AasSubmodelElementsFrom - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } + /// + /// Deserialize an instance of SubmodelElementList from . + /// + /// JSON node to be parsed + /// Error, if any, during the deserialization + internal static Aas.SubmodelElementList? SubmodelElementListFrom( + Nodes.JsonNode node, + out Reporting.Error? error) + { + error = null; - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; - List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) + Nodes.JsonObject? obj = node as Nodes.JsonObject; + if (obj == null) { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } + error = new Reporting.Error( + $"Expected a JsonObject, but got {node.GetType()}"); + return null; } - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; + AasSubmodelElements? theTypeValueListElement = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + string? theChecksum = null; + ModelingKind? theKind = null; + Reference? theSemanticId = null; + List? theSupplementalSemanticIds = null; List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } - - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + List? theEmbeddedDataSpecifications = null; + bool? theOrderRelevant = null; + List? theValue = null; + Reference? theSemanticIdListElement = null; + DataTypeDefXsd? theValueTypeListElement = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "typeValueListElement": + { + if (keyValue.Value == null) + { + continue; + } + + theTypeValueListElement = DeserializeImplementation.AasSubmodelElementsFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "typeValueListElement")); + return null; + } + if (theTypeValueListElement == null) + { + throw new System.InvalidOperationException( + "Unexpected theTypeValueListElement null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "orderRelevant": + { + if (keyValue.Value == null) + { + continue; + } + + theOrderRelevant = DeserializeImplementation.BoolFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "orderRelevant")); + return null; + } + if (theOrderRelevant == null) + { + throw new System.InvalidOperationException( + "Unexpected theOrderRelevant null when error is also null"); + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayValue = keyValue.Value as Nodes.JsonArray; + if (arrayValue == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + theValue = new List( + arrayValue.Count); + int indexValue = 0; + foreach (Nodes.JsonNode? item in arrayValue) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexValue)); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + ISubmodelElement? parsedItem = DeserializeImplementation.ISubmodelElementFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexValue)); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + theValue.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexValue++; + } + break; + } + case "semanticIdListElement": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticIdListElement = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticIdListElement")); + return null; + } + if (theSemanticIdListElement == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticIdListElement null when error is also null"); + } + break; + } + case "valueTypeListElement": + { + if (keyValue.Value == null) + { + continue; + } + + theValueTypeListElement = DeserializeImplementation.DataTypeDefXsdFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueTypeListElement")); + return null; + } + if (theValueTypeListElement == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueTypeListElement null when error is also null"); + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; } } - Nodes.JsonNode? nodeFirst = obj["first"]; - if (nodeFirst == null) - { - error = new Reporting.Error( - "Required property \"first\" is missing "); - return null; - } - Aas.Reference? theFirst = DeserializeImplementation.ReferenceFrom( - nodeFirst, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "first")); - return null; - } - if (theFirst == null) - { - throw new System.InvalidOperationException( - "Unexpected theFirst null when error is also null"); - } - - Nodes.JsonNode? nodeSecond = obj["second"]; - if (nodeSecond == null) + if (theTypeValueListElement == null) { error = new Reporting.Error( - "Required property \"second\" is missing "); - return null; - } - Aas.Reference? theSecond = DeserializeImplementation.ReferenceFrom( - nodeSecond, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "second")); + "Required property \"typeValueListElement\" is missing"); return null; } - if (theSecond == null) - { - throw new System.InvalidOperationException( - "Unexpected theSecond null when error is also null"); - } - return new Aas.RelationshipElement( - theFirst - ?? throw new System.InvalidOperationException( - "Unexpected null, had to be handled before"), - theSecond + return new Aas.SubmodelElementList( + theTypeValueListElement ?? throw new System.InvalidOperationException( "Unexpected null, had to be handled before"), theExtensions, @@ -3358,15 +4693,19 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications); - } // internal static RelationshipElementFrom + theEmbeddedDataSpecifications, + theOrderRelevant, + theValue, + theSemanticIdListElement, + theValueTypeListElement); + } // internal static SubmodelElementListFrom /// - /// Deserialize an instance of SubmodelElementList from . + /// Deserialize an instance of SubmodelElementCollection from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.SubmodelElementList? SubmodelElementListFrom( + internal static Aas.SubmodelElementCollection? SubmodelElementCollectionFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -3380,526 +4719,632 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + string? theChecksum = null; + ModelingKind? theKind = null; + Reference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; + List? theEmbeddedDataSpecifications = null; + List? theValue = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayValue = keyValue.Value as Nodes.JsonArray; + if (arrayValue == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + theValue = new List( + arrayValue.Count); + int indexValue = 0; + foreach (Nodes.JsonNode? item in arrayValue) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexValue)); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + ISubmodelElement? parsedItem = DeserializeImplementation.ISubmodelElementFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexValue)); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + theValue.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexValue++; + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); + $"Unexpected property: {keyValue.Key}"); return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; } } - Nodes.JsonNode? nodeCategory = obj["category"]; - string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - Nodes.JsonNode? nodeIdShort = obj["idShort"]; - string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } + return new Aas.SubmodelElementCollection( + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theChecksum, + theKind, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue); + } // internal static SubmodelElementCollectionFrom - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } + /// + /// Deserialize an instance of IDataElement by dispatching + /// based on modelType property of the . + /// + /// JSON node to be parsed + /// Error, if any, during the deserialization + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static Aas.IDataElement? IDataElementFrom( + Nodes.JsonNode node, + out Reporting.Error? error) + { + error = null; - Nodes.JsonNode? nodeChecksum = obj["checksum"]; - string? theChecksum = null; - if (nodeChecksum != null) + var obj = node as Nodes.JsonObject; + if (obj == null) { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } + error = new Reporting.Error( + "Expected Nodes.JsonObject, but got {node.GetType()}"); + return null; } - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; - List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; - List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } - - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } - } - - Nodes.JsonNode? nodeOrderRelevant = obj["orderRelevant"]; - bool? theOrderRelevant = null; - if (nodeOrderRelevant != null) - { - theOrderRelevant = DeserializeImplementation.BoolFrom( - nodeOrderRelevant, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "orderRelevant")); - return null; - } - if (theOrderRelevant == null) - { - throw new System.InvalidOperationException( - "Unexpected theOrderRelevant null when error is also null"); - } - } - - Nodes.JsonNode? nodeValue = obj["value"]; - List? theValue = null; - if (nodeValue != null) - { - Nodes.JsonArray? arrayValue = nodeValue as Nodes.JsonArray; - if (arrayValue == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeValue.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - theValue = new List( - arrayValue.Count); - int indexValue = 0; - foreach (Nodes.JsonNode? item in arrayValue) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexValue)); - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - ISubmodelElement? parsedItem = DeserializeImplementation.ISubmodelElementFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexValue)); - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - theValue.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexValue++; - } - } - - Nodes.JsonNode? nodeSemanticIdListElement = obj["semanticIdListElement"]; - Aas.Reference? theSemanticIdListElement = null; - if (nodeSemanticIdListElement != null) - { - theSemanticIdListElement = DeserializeImplementation.ReferenceFrom( - nodeSemanticIdListElement, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticIdListElement")); - return null; - } - if (theSemanticIdListElement == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticIdListElement null when error is also null"); - } - } - - Nodes.JsonNode? nodeTypeValueListElement = obj["typeValueListElement"]; - if (nodeTypeValueListElement == null) + Nodes.JsonNode? modelTypeNode = obj["modelType"]; + if (modelTypeNode == null) { error = new Reporting.Error( - "Required property \"typeValueListElement\" is missing "); + "Expected a model type, but none is present"); return null; } - Aas.AasSubmodelElements? theTypeValueListElement = DeserializeImplementation.AasSubmodelElementsFrom( - nodeTypeValueListElement, - out error); - if (error != null) + Nodes.JsonValue? modelTypeValue = modelTypeNode as Nodes.JsonValue; + if (modelTypeValue == null) { - error.PrependSegment( - new Reporting.NameSegment( - "typeValueListElement")); + error = new Reporting.Error( + "Expected JsonValue, " + + $"but got {modelTypeNode.GetType()}"); return null; } - if (theTypeValueListElement == null) + modelTypeValue.TryGetValue(out string? modelType); + if (modelType == null) { - throw new System.InvalidOperationException( - "Unexpected theTypeValueListElement null when error is also null"); + error = new Reporting.Error( + "Expected a string, " + + $"but the conversion failed from {modelTypeValue}"); + return null; } - Nodes.JsonNode? nodeValueTypeListElement = obj["valueTypeListElement"]; - Aas.DataTypeDefXsd? theValueTypeListElement = null; - if (nodeValueTypeListElement != null) + switch (modelType) { - theValueTypeListElement = DeserializeImplementation.DataTypeDefXsdFrom( - nodeValueTypeListElement, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "valueTypeListElement")); + case "Blob": + return BlobFrom( + node, out error); + case "File": + return FileFrom( + node, out error); + case "MultiLanguageProperty": + return MultiLanguagePropertyFrom( + node, out error); + case "Property": + return PropertyFrom( + node, out error); + case "Range": + return RangeFrom( + node, out error); + case "ReferenceElement": + return ReferenceElementFrom( + node, out error); + default: + error = new Reporting.Error( + $"Unexpected model type for IDataElement: {modelType}"); return null; - } - if (theValueTypeListElement == null) - { - throw new System.InvalidOperationException( - "Unexpected theValueTypeListElement null when error is also null"); - } } - - return new Aas.SubmodelElementList( - theTypeValueListElement - ?? throw new System.InvalidOperationException( - "Unexpected null, had to be handled before"), - theExtensions, - theCategory, - theIdShort, - theDisplayName, - theDescription, - theChecksum, - theKind, - theSemanticId, - theSupplementalSemanticIds, - theQualifiers, - theDataSpecifications, - theOrderRelevant, - theValue, - theSemanticIdListElement, - theValueTypeListElement); - } // internal static SubmodelElementListFrom + } // public static Aas.IDataElement IDataElementFrom /// - /// Deserialize an instance of SubmodelElementCollection from . + /// Deserialize an instance of Property from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.SubmodelElementCollection? SubmodelElementCollectionFrom( + internal static Aas.Property? PropertyFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -3913,1830 +5358,564 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; + DataTypeDefXsd? theValueType = null; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; + ModelingKind? theKind = null; + Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } - - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } - } - - Nodes.JsonNode? nodeValue = obj["value"]; - List? theValue = null; - if (nodeValue != null) - { - Nodes.JsonArray? arrayValue = nodeValue as Nodes.JsonArray; - if (arrayValue == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeValue.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - theValue = new List( - arrayValue.Count); - int indexValue = 0; - foreach (Nodes.JsonNode? item in arrayValue) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexValue)); - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - ISubmodelElement? parsedItem = DeserializeImplementation.ISubmodelElementFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexValue)); - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - theValue.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexValue++; - } - } - - return new Aas.SubmodelElementCollection( - theExtensions, - theCategory, - theIdShort, - theDisplayName, - theDescription, - theChecksum, - theKind, - theSemanticId, - theSupplementalSemanticIds, - theQualifiers, - theDataSpecifications, - theValue); - } // internal static SubmodelElementCollectionFrom - - /// - /// Deserialize an instance of IDataElement by dispatching - /// based on modelType property of the . - /// - /// JSON node to be parsed - /// Error, if any, during the deserialization - [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - public static Aas.IDataElement? IDataElementFrom( - Nodes.JsonNode node, - out Reporting.Error? error) - { - error = null; - - var obj = node as Nodes.JsonObject; - if (obj == null) - { - error = new Reporting.Error( - "Expected Nodes.JsonObject, but got {node.GetType()}"); - return null; - } - - Nodes.JsonNode? modelTypeNode = obj["modelType"]; - if (modelTypeNode == null) - { - error = new Reporting.Error( - "Expected a model type, but none is present"); - return null; - } - Nodes.JsonValue? modelTypeValue = modelTypeNode as Nodes.JsonValue; - if (modelTypeValue == null) - { - error = new Reporting.Error( - "Expected JsonValue, " + - $"but got {modelTypeNode.GetType()}"); - return null; - } - modelTypeValue.TryGetValue(out string? modelType); - if (modelType == null) - { - error = new Reporting.Error( - "Expected a string, " + - $"but the conversion failed from {modelTypeValue}"); - return null; - } - - switch (modelType) - { - case "Blob": - return BlobFrom( - node, out error); - case "File": - return FileFrom( - node, out error); - case "MultiLanguageProperty": - return MultiLanguagePropertyFrom( - node, out error); - case "Property": - return PropertyFrom( - node, out error); - case "Range": - return RangeFrom( - node, out error); - case "ReferenceElement": - return ReferenceElementFrom( - node, out error); - default: - error = new Reporting.Error( - $"Unexpected model type for IDataElement: {modelType}"); - return null; - } - } // public static Aas.IDataElement IDataElementFrom - - /// - /// Deserialize an instance of Property from . - /// - /// JSON node to be parsed - /// Error, if any, during the deserialization - internal static Aas.Property? PropertyFrom( - Nodes.JsonNode node, - out Reporting.Error? error) - { - error = null; - - Nodes.JsonObject? obj = node as Nodes.JsonObject; - if (obj == null) - { - error = new Reporting.Error( - $"Expected a JsonObject, but got {node.GetType()}"); - return null; - } - - Nodes.JsonNode? nodeExtensions = obj["extensions"]; - List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; - string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; - string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; - string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; - List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; - List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } - - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } - } - - Nodes.JsonNode? nodeValueType = obj["valueType"]; - if (nodeValueType == null) - { - error = new Reporting.Error( - "Required property \"valueType\" is missing "); - return null; - } - Aas.DataTypeDefXsd? theValueType = DeserializeImplementation.DataTypeDefXsdFrom( - nodeValueType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "valueType")); - return null; - } - if (theValueType == null) - { - throw new System.InvalidOperationException( - "Unexpected theValueType null when error is also null"); - } - - Nodes.JsonNode? nodeValue = obj["value"]; - string? theValue = null; - if (nodeValue != null) - { - theValue = DeserializeImplementation.StringFrom( - nodeValue, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - if (theValue == null) - { - throw new System.InvalidOperationException( - "Unexpected theValue null when error is also null"); - } - } - - Nodes.JsonNode? nodeValueId = obj["valueId"]; - Aas.Reference? theValueId = null; - if (nodeValueId != null) - { - theValueId = DeserializeImplementation.ReferenceFrom( - nodeValueId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "valueId")); - return null; - } - if (theValueId == null) - { - throw new System.InvalidOperationException( - "Unexpected theValueId null when error is also null"); - } - } - - return new Aas.Property( - theValueType - ?? throw new System.InvalidOperationException( - "Unexpected null, had to be handled before"), - theExtensions, - theCategory, - theIdShort, - theDisplayName, - theDescription, - theChecksum, - theKind, - theSemanticId, - theSupplementalSemanticIds, - theQualifiers, - theDataSpecifications, - theValue, - theValueId); - } // internal static PropertyFrom - - /// - /// Deserialize an instance of MultiLanguageProperty from . - /// - /// JSON node to be parsed - /// Error, if any, during the deserialization - internal static Aas.MultiLanguageProperty? MultiLanguagePropertyFrom( - Nodes.JsonNode node, - out Reporting.Error? error) - { - error = null; - - Nodes.JsonObject? obj = node as Nodes.JsonObject; - if (obj == null) - { - error = new Reporting.Error( - $"Expected a JsonObject, but got {node.GetType()}"); - return null; - } - - Nodes.JsonNode? nodeExtensions = obj["extensions"]; - List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; - string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; - string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; - string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; - List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; - List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } - - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } - } - - Nodes.JsonNode? nodeValue = obj["value"]; - Aas.LangStringSet? theValue = null; - if (nodeValue != null) - { - theValue = DeserializeImplementation.LangStringSetFrom( - nodeValue, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - if (theValue == null) - { - throw new System.InvalidOperationException( - "Unexpected theValue null when error is also null"); - } - } - - Nodes.JsonNode? nodeValueId = obj["valueId"]; - Aas.Reference? theValueId = null; - if (nodeValueId != null) - { - theValueId = DeserializeImplementation.ReferenceFrom( - nodeValueId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "valueId")); - return null; - } - if (theValueId == null) - { - throw new System.InvalidOperationException( - "Unexpected theValueId null when error is also null"); - } - } - - return new Aas.MultiLanguageProperty( - theExtensions, - theCategory, - theIdShort, - theDisplayName, - theDescription, - theChecksum, - theKind, - theSemanticId, - theSupplementalSemanticIds, - theQualifiers, - theDataSpecifications, - theValue, - theValueId); - } // internal static MultiLanguagePropertyFrom - - /// - /// Deserialize an instance of Range from . - /// - /// JSON node to be parsed - /// Error, if any, during the deserialization - internal static Aas.Range? RangeFrom( - Nodes.JsonNode node, - out Reporting.Error? error) - { - error = null; - - Nodes.JsonObject? obj = node as Nodes.JsonObject; - if (obj == null) - { - error = new Reporting.Error( - $"Expected a JsonObject, but got {node.GetType()}"); - return null; - } - - Nodes.JsonNode? nodeExtensions = obj["extensions"]; - List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; - string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; - string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; - string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; - List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; - List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } - - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + List? theEmbeddedDataSpecifications = null; + string? theValue = null; + Reference? theValueId = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "valueType": + { + if (keyValue.Value == null) + { + continue; + } + + theValueType = DeserializeImplementation.DataTypeDefXsdFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueType")); + return null; + } + if (theValueType == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueType null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + case "valueId": + { + if (keyValue.Value == null) + { + continue; + } + + theValueId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueId")); + return null; + } + if (theValueId == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueId null when error is also null"); + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; } } - Nodes.JsonNode? nodeValueType = obj["valueType"]; - if (nodeValueType == null) + if (theValueType == null) { error = new Reporting.Error( - "Required property \"valueType\" is missing "); - return null; - } - Aas.DataTypeDefXsd? theValueType = DeserializeImplementation.DataTypeDefXsdFrom( - nodeValueType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "valueType")); + "Required property \"valueType\" is missing"); return null; } - if (theValueType == null) - { - throw new System.InvalidOperationException( - "Unexpected theValueType null when error is also null"); - } - - Nodes.JsonNode? nodeMin = obj["min"]; - string? theMin = null; - if (nodeMin != null) - { - theMin = DeserializeImplementation.StringFrom( - nodeMin, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "min")); - return null; - } - if (theMin == null) - { - throw new System.InvalidOperationException( - "Unexpected theMin null when error is also null"); - } - } - - Nodes.JsonNode? nodeMax = obj["max"]; - string? theMax = null; - if (nodeMax != null) - { - theMax = DeserializeImplementation.StringFrom( - nodeMax, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "max")); - return null; - } - if (theMax == null) - { - throw new System.InvalidOperationException( - "Unexpected theMax null when error is also null"); - } - } - return new Aas.Range( + return new Aas.Property( theValueType ?? throw new System.InvalidOperationException( "Unexpected null, had to be handled before"), @@ -5750,17 +5929,17 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, - theMin, - theMax); - } // internal static RangeFrom + theEmbeddedDataSpecifications, + theValue, + theValueId); + } // internal static PropertyFrom /// - /// Deserialize an instance of ReferenceElement from . + /// Deserialize an instance of MultiLanguageProperty from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.ReferenceElement? ReferenceElementFrom( + internal static Aas.MultiLanguageProperty? MultiLanguagePropertyFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -5774,383 +5953,565 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; + ModelingKind? theKind = null; + Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { + List? theEmbeddedDataSpecifications = null; + List? theValue = null; + Reference? theValueId = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayValue = keyValue.Value as Nodes.JsonArray; + if (arrayValue == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + theValue = new List( + arrayValue.Count); + int indexValue = 0; + foreach (Nodes.JsonNode? item in arrayValue) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexValue)); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexValue)); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + theValue.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexValue++; + } + break; + } + case "valueId": + { + if (keyValue.Value == null) + { + continue; + } + + theValueId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueId")); + return null; + } + if (theValueId == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueId null when error is also null"); + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); + $"Unexpected property: {keyValue.Key}"); return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; } } - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } - } - Nodes.JsonNode? nodeValue = obj["value"]; - Aas.Reference? theValue = null; - if (nodeValue != null) - { - theValue = DeserializeImplementation.ReferenceFrom( - nodeValue, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - if (theValue == null) - { - throw new System.InvalidOperationException( - "Unexpected theValue null when error is also null"); - } - } - return new Aas.ReferenceElement( + return new Aas.MultiLanguageProperty( theExtensions, theCategory, theIdShort, @@ -6161,16 +6522,17 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, - theValue); - } // internal static ReferenceElementFrom + theEmbeddedDataSpecifications, + theValue, + theValueId); + } // internal static MultiLanguagePropertyFrom /// - /// Deserialize an instance of Blob from . + /// Deserialize an instance of Range from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.Blob? BlobFrom( + internal static Aas.Range? RangeFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -6184,407 +6546,565 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; + DataTypeDefXsd? theValueType = null; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; + ModelingKind? theKind = null; + Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } - - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + List? theEmbeddedDataSpecifications = null; + string? theMin = null; + string? theMax = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "valueType": + { + if (keyValue.Value == null) + { + continue; + } + + theValueType = DeserializeImplementation.DataTypeDefXsdFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueType")); + return null; + } + if (theValueType == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueType null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "min": + { + if (keyValue.Value == null) + { + continue; + } + + theMin = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "min")); + return null; + } + if (theMin == null) + { + throw new System.InvalidOperationException( + "Unexpected theMin null when error is also null"); + } + break; + } + case "max": + { + if (keyValue.Value == null) + { + continue; + } + + theMax = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "max")); + return null; + } + if (theMax == null) + { + throw new System.InvalidOperationException( + "Unexpected theMax null when error is also null"); + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } - } - - Nodes.JsonNode? nodeValue = obj["value"]; - byte[]? theValue = null; - if (nodeValue != null) - { - theValue = DeserializeImplementation.BytesFrom( - nodeValue, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - if (theValue == null) - { - throw new System.InvalidOperationException( - "Unexpected theValue null when error is also null"); } } - Nodes.JsonNode? nodeContentType = obj["contentType"]; - if (nodeContentType == null) + if (theValueType == null) { error = new Reporting.Error( - "Required property \"contentType\" is missing "); - return null; - } - string? theContentType = DeserializeImplementation.StringFrom( - nodeContentType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "contentType")); + "Required property \"valueType\" is missing"); return null; } - if (theContentType == null) - { - throw new System.InvalidOperationException( - "Unexpected theContentType null when error is also null"); - } - return new Aas.Blob( - theContentType + return new Aas.Range( + theValueType ?? throw new System.InvalidOperationException( "Unexpected null, had to be handled before"), theExtensions, @@ -6597,16 +7117,17 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, - theValue); - } // internal static BlobFrom + theEmbeddedDataSpecifications, + theMin, + theMax); + } // internal static RangeFrom /// - /// Deserialize an instance of File from . + /// Deserialize an instance of ReferenceElement from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.File? FileFrom( + internal static Aas.ReferenceElement? ReferenceElementFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -6620,409 +7141,509 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; + ModelingKind? theKind = null; + Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } - - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + List? theEmbeddedDataSpecifications = null; + Reference? theValue = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; } } - Nodes.JsonNode? nodeValue = obj["value"]; - string? theValue = null; - if (nodeValue != null) - { - theValue = DeserializeImplementation.StringFrom( - nodeValue, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - if (theValue == null) - { - throw new System.InvalidOperationException( - "Unexpected theValue null when error is also null"); - } - } - Nodes.JsonNode? nodeContentType = obj["contentType"]; - if (nodeContentType == null) - { - error = new Reporting.Error( - "Required property \"contentType\" is missing "); - return null; - } - string? theContentType = DeserializeImplementation.StringFrom( - nodeContentType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "contentType")); - return null; - } - if (theContentType == null) - { - throw new System.InvalidOperationException( - "Unexpected theContentType null when error is also null"); - } - return new Aas.File( - theContentType - ?? throw new System.InvalidOperationException( - "Unexpected null, had to be handled before"), + return new Aas.ReferenceElement( theExtensions, theCategory, theIdShort, @@ -7033,16 +7654,16 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theValue); - } // internal static FileFrom + } // internal static ReferenceElementFrom /// - /// Deserialize an instance of AnnotatedRelationshipElement from . + /// Deserialize an instance of Blob from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.AnnotatedRelationshipElement? AnnotatedRelationshipElementFrom( + internal static Aas.Blob? BlobFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -7056,457 +7677,1737 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; + string? theContentType = null; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } + List? theDisplayName = null; + List? theDescription = null; + string? theChecksum = null; + ModelingKind? theKind = null; + Reference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; + List? theEmbeddedDataSpecifications = null; + byte[]? theValue = null; - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "contentType": + { + if (keyValue.Value == null) + { + continue; + } + + theContentType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "contentType")); + return null; + } + if (theContentType == null) + { + throw new System.InvalidOperationException( + "Unexpected theContentType null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.BytesFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + case "modelType": + continue; + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; } } - Nodes.JsonNode? nodeChecksum = obj["checksum"]; - string? theChecksum = null; - if (nodeChecksum != null) + if (theContentType == null) { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } + error = new Reporting.Error( + "Required property \"contentType\" is missing"); + return null; } - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } + return new Aas.Blob( + theContentType + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theChecksum, + theKind, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue); + } // internal static BlobFrom - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } + /// + /// Deserialize an instance of File from . + /// + /// JSON node to be parsed + /// Error, if any, during the deserialization + internal static Aas.File? FileFrom( + Nodes.JsonNode node, + out Reporting.Error? error) + { + error = null; - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; - List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) + Nodes.JsonObject? obj = node as Nodes.JsonObject; + if (obj == null) { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } + error = new Reporting.Error( + $"Expected a JsonObject, but got {node.GetType()}"); + return null; } - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; + string? theContentType = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + string? theChecksum = null; + ModelingKind? theKind = null; + Reference? theSemanticId = null; + List? theSupplementalSemanticIds = null; List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } + List? theEmbeddedDataSpecifications = null; + string? theValue = null; - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "contentType": + { + if (keyValue.Value == null) + { + continue; + } + + theContentType = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "contentType")); + return null; + } + if (theContentType == null) + { + throw new System.InvalidOperationException( + "Unexpected theContentType null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; } } - Nodes.JsonNode? nodeFirst = obj["first"]; - if (nodeFirst == null) + if (theContentType == null) { error = new Reporting.Error( - "Required property \"first\" is missing "); + "Required property \"contentType\" is missing"); return null; } - Aas.Reference? theFirst = DeserializeImplementation.ReferenceFrom( - nodeFirst, - out error); - if (error != null) + + return new Aas.File( + theContentType + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theExtensions, + theCategory, + theIdShort, + theDisplayName, + theDescription, + theChecksum, + theKind, + theSemanticId, + theSupplementalSemanticIds, + theQualifiers, + theEmbeddedDataSpecifications, + theValue); + } // internal static FileFrom + + /// + /// Deserialize an instance of AnnotatedRelationshipElement from . + /// + /// JSON node to be parsed + /// Error, if any, during the deserialization + internal static Aas.AnnotatedRelationshipElement? AnnotatedRelationshipElementFrom( + Nodes.JsonNode node, + out Reporting.Error? error) + { + error = null; + + Nodes.JsonObject? obj = node as Nodes.JsonObject; + if (obj == null) { - error.PrependSegment( - new Reporting.NameSegment( - "first")); + error = new Reporting.Error( + $"Expected a JsonObject, but got {node.GetType()}"); return null; } - if (theFirst == null) - { - throw new System.InvalidOperationException( - "Unexpected theFirst null when error is also null"); + + Reference? theFirst = null; + Reference? theSecond = null; + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + string? theChecksum = null; + ModelingKind? theKind = null; + Reference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; + List? theEmbeddedDataSpecifications = null; + List? theAnnotations = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "first": + { + if (keyValue.Value == null) + { + continue; + } + + theFirst = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "first")); + return null; + } + if (theFirst == null) + { + throw new System.InvalidOperationException( + "Unexpected theFirst null when error is also null"); + } + break; + } + case "second": + { + if (keyValue.Value == null) + { + continue; + } + + theSecond = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "second")); + return null; + } + if (theSecond == null) + { + throw new System.InvalidOperationException( + "Unexpected theSecond null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "annotations": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayAnnotations = keyValue.Value as Nodes.JsonArray; + if (arrayAnnotations == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "annotations")); + return null; + } + theAnnotations = new List( + arrayAnnotations.Count); + int indexAnnotations = 0; + foreach (Nodes.JsonNode? item in arrayAnnotations) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexAnnotations)); + error.PrependSegment( + new Reporting.NameSegment( + "annotations")); + return null; + } + IDataElement? parsedItem = DeserializeImplementation.IDataElementFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexAnnotations)); + error.PrependSegment( + new Reporting.NameSegment( + "annotations")); + return null; + } + theAnnotations.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexAnnotations++; + } + break; + } + case "modelType": + continue; + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; + } } - Nodes.JsonNode? nodeSecond = obj["second"]; - if (nodeSecond == null) + if (theFirst == null) { error = new Reporting.Error( - "Required property \"second\" is missing "); - return null; - } - Aas.Reference? theSecond = DeserializeImplementation.ReferenceFrom( - nodeSecond, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "second")); + "Required property \"first\" is missing"); return null; } - if (theSecond == null) - { - throw new System.InvalidOperationException( - "Unexpected theSecond null when error is also null"); - } - Nodes.JsonNode? nodeAnnotations = obj["annotations"]; - List? theAnnotations = null; - if (nodeAnnotations != null) + if (theSecond == null) { - Nodes.JsonArray? arrayAnnotations = nodeAnnotations as Nodes.JsonArray; - if (arrayAnnotations == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeAnnotations.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "annotations")); - return null; - } - theAnnotations = new List( - arrayAnnotations.Count); - int indexAnnotations = 0; - foreach (Nodes.JsonNode? item in arrayAnnotations) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexAnnotations)); - error.PrependSegment( - new Reporting.NameSegment( - "annotations")); - return null; - } - IDataElement? parsedItem = DeserializeImplementation.IDataElementFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexAnnotations)); - error.PrependSegment( - new Reporting.NameSegment( - "annotations")); - return null; - } - theAnnotations.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexAnnotations++; - } + error = new Reporting.Error( + "Required property \"second\" is missing"); + return null; } return new Aas.AnnotatedRelationshipElement( @@ -7526,7 +9427,7 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theAnnotations); } // internal static AnnotatedRelationshipElementFrom @@ -7555,7 +9456,7 @@ internal static class DeserializeImplementation if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of EntityType "); + "Not a valid JSON representation of EntityType"); } return result; } // internal static EntityTypeFrom @@ -7579,476 +9480,617 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; + EntityType? theEntityType = null; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; - string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; - string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; - string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; - List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; - List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } - - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } - } - - Nodes.JsonNode? nodeStatements = obj["statements"]; - List? theStatements = null; - if (nodeStatements != null) - { - Nodes.JsonArray? arrayStatements = nodeStatements as Nodes.JsonArray; - if (arrayStatements == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeStatements.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "statements")); - return null; - } - theStatements = new List( - arrayStatements.Count); - int indexStatements = 0; - foreach (Nodes.JsonNode? item in arrayStatements) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexStatements)); - error.PrependSegment( - new Reporting.NameSegment( - "statements")); - return null; - } - ISubmodelElement? parsedItem = DeserializeImplementation.ISubmodelElementFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexStatements)); - error.PrependSegment( - new Reporting.NameSegment( - "statements")); - return null; - } - theStatements.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexStatements++; - } - } - - Nodes.JsonNode? nodeEntityType = obj["entityType"]; - if (nodeEntityType == null) - { - error = new Reporting.Error( - "Required property \"entityType\" is missing "); - return null; - } - Aas.EntityType? theEntityType = DeserializeImplementation.EntityTypeFrom( - nodeEntityType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "entityType")); - return null; - } - if (theEntityType == null) - { - throw new System.InvalidOperationException( - "Unexpected theEntityType null when error is also null"); - } - - Nodes.JsonNode? nodeGlobalAssetId = obj["globalAssetId"]; - Aas.Reference? theGlobalAssetId = null; - if (nodeGlobalAssetId != null) - { - theGlobalAssetId = DeserializeImplementation.ReferenceFrom( - nodeGlobalAssetId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "globalAssetId")); - return null; - } - if (theGlobalAssetId == null) - { - throw new System.InvalidOperationException( - "Unexpected theGlobalAssetId null when error is also null"); + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + string? theChecksum = null; + ModelingKind? theKind = null; + Reference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; + List? theEmbeddedDataSpecifications = null; + List? theStatements = null; + Reference? theGlobalAssetId = null; + SpecificAssetId? theSpecificAssetId = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "entityType": + { + if (keyValue.Value == null) + { + continue; + } + + theEntityType = DeserializeImplementation.EntityTypeFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "entityType")); + return null; + } + if (theEntityType == null) + { + throw new System.InvalidOperationException( + "Unexpected theEntityType null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "statements": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayStatements = keyValue.Value as Nodes.JsonArray; + if (arrayStatements == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "statements")); + return null; + } + theStatements = new List( + arrayStatements.Count); + int indexStatements = 0; + foreach (Nodes.JsonNode? item in arrayStatements) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexStatements)); + error.PrependSegment( + new Reporting.NameSegment( + "statements")); + return null; + } + ISubmodelElement? parsedItem = DeserializeImplementation.ISubmodelElementFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexStatements)); + error.PrependSegment( + new Reporting.NameSegment( + "statements")); + return null; + } + theStatements.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexStatements++; + } + break; + } + case "globalAssetId": + { + if (keyValue.Value == null) + { + continue; + } + + theGlobalAssetId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "globalAssetId")); + return null; + } + if (theGlobalAssetId == null) + { + throw new System.InvalidOperationException( + "Unexpected theGlobalAssetId null when error is also null"); + } + break; + } + case "specificAssetId": + { + if (keyValue.Value == null) + { + continue; + } + + theSpecificAssetId = DeserializeImplementation.SpecificAssetIdFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "specificAssetId")); + return null; + } + if (theSpecificAssetId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSpecificAssetId null when error is also null"); + } + break; + } + case "modelType": + continue; + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; } } - Nodes.JsonNode? nodeSpecificAssetId = obj["specificAssetId"]; - Aas.SpecificAssetId? theSpecificAssetId = null; - if (nodeSpecificAssetId != null) + if (theEntityType == null) { - theSpecificAssetId = DeserializeImplementation.SpecificAssetIdFrom( - nodeSpecificAssetId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "specificAssetId")); - return null; - } - if (theSpecificAssetId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSpecificAssetId null when error is also null"); - } + error = new Reporting.Error( + "Required property \"entityType\" is missing"); + return null; } return new Aas.Entity( @@ -8065,7 +10107,7 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theStatements, theGlobalAssetId, theSpecificAssetId); @@ -8096,7 +10138,7 @@ internal static class DeserializeImplementation if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of Direction "); + "Not a valid JSON representation of Direction"); } return result; } // internal static DirectionFrom @@ -8126,7 +10168,7 @@ internal static class DeserializeImplementation if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of StateOfEvent "); + "Not a valid JSON representation of StateOfEvent"); } return result; } // internal static StateOfEventFrom @@ -8150,178 +10192,237 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeSource = obj["source"]; - if (nodeSource == null) - { - error = new Reporting.Error( - "Required property \"source\" is missing "); - return null; - } - Aas.Reference? theSource = DeserializeImplementation.ReferenceFrom( - nodeSource, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "source")); - return null; - } - if (theSource == null) - { - throw new System.InvalidOperationException( - "Unexpected theSource null when error is also null"); - } + Reference? theSource = null; + Reference? theObservableReference = null; + string? theTimeStamp = null; + Reference? theSourceSemanticId = null; + Reference? theObservableSemanticId = null; + string? theTopic = null; + Reference? theSubjectId = null; + string? thePayload = null; - Nodes.JsonNode? nodeSourceSemanticId = obj["sourceSemanticId"]; - Aas.Reference? theSourceSemanticId = null; - if (nodeSourceSemanticId != null) - { - theSourceSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSourceSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "sourceSemanticId")); - return null; - } - if (theSourceSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSourceSemanticId null when error is also null"); + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "source": + { + if (keyValue.Value == null) + { + continue; + } + + theSource = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "source")); + return null; + } + if (theSource == null) + { + throw new System.InvalidOperationException( + "Unexpected theSource null when error is also null"); + } + break; + } + case "observableReference": + { + if (keyValue.Value == null) + { + continue; + } + + theObservableReference = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "observableReference")); + return null; + } + if (theObservableReference == null) + { + throw new System.InvalidOperationException( + "Unexpected theObservableReference null when error is also null"); + } + break; + } + case "timeStamp": + { + if (keyValue.Value == null) + { + continue; + } + + theTimeStamp = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "timeStamp")); + return null; + } + if (theTimeStamp == null) + { + throw new System.InvalidOperationException( + "Unexpected theTimeStamp null when error is also null"); + } + break; + } + case "sourceSemanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSourceSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "sourceSemanticId")); + return null; + } + if (theSourceSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSourceSemanticId null when error is also null"); + } + break; + } + case "observableSemanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theObservableSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "observableSemanticId")); + return null; + } + if (theObservableSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theObservableSemanticId null when error is also null"); + } + break; + } + case "topic": + { + if (keyValue.Value == null) + { + continue; + } + + theTopic = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "topic")); + return null; + } + if (theTopic == null) + { + throw new System.InvalidOperationException( + "Unexpected theTopic null when error is also null"); + } + break; + } + case "subjectId": + { + if (keyValue.Value == null) + { + continue; + } + + theSubjectId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "subjectId")); + return null; + } + if (theSubjectId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSubjectId null when error is also null"); + } + break; + } + case "payload": + { + if (keyValue.Value == null) + { + continue; + } + + thePayload = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "payload")); + return null; + } + if (thePayload == null) + { + throw new System.InvalidOperationException( + "Unexpected thePayload null when error is also null"); + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; } } - Nodes.JsonNode? nodeObservableReference = obj["observableReference"]; - if (nodeObservableReference == null) + if (theSource == null) { error = new Reporting.Error( - "Required property \"observableReference\" is missing "); - return null; - } - Aas.Reference? theObservableReference = DeserializeImplementation.ReferenceFrom( - nodeObservableReference, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "observableReference")); + "Required property \"source\" is missing"); return null; } - if (theObservableReference == null) - { - throw new System.InvalidOperationException( - "Unexpected theObservableReference null when error is also null"); - } - - Nodes.JsonNode? nodeObservableSemanticId = obj["observableSemanticId"]; - Aas.Reference? theObservableSemanticId = null; - if (nodeObservableSemanticId != null) - { - theObservableSemanticId = DeserializeImplementation.ReferenceFrom( - nodeObservableSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "observableSemanticId")); - return null; - } - if (theObservableSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theObservableSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeTopic = obj["topic"]; - string? theTopic = null; - if (nodeTopic != null) - { - theTopic = DeserializeImplementation.StringFrom( - nodeTopic, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "topic")); - return null; - } - if (theTopic == null) - { - throw new System.InvalidOperationException( - "Unexpected theTopic null when error is also null"); - } - } - - Nodes.JsonNode? nodeSubjectId = obj["subjectId"]; - Aas.Reference? theSubjectId = null; - if (nodeSubjectId != null) - { - theSubjectId = DeserializeImplementation.ReferenceFrom( - nodeSubjectId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "subjectId")); - return null; - } - if (theSubjectId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSubjectId null when error is also null"); - } - } - Nodes.JsonNode? nodeTimeStamp = obj["timeStamp"]; - if (nodeTimeStamp == null) + if (theObservableReference == null) { error = new Reporting.Error( - "Required property \"timeStamp\" is missing "); + "Required property \"observableReference\" is missing"); return null; } - string? theTimeStamp = DeserializeImplementation.StringFrom( - nodeTimeStamp, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "timeStamp")); - return null; - } - if (theTimeStamp == null) - { - throw new System.InvalidOperationException( - "Unexpected theTimeStamp null when error is also null"); - } - Nodes.JsonNode? nodePayload = obj["payload"]; - string? thePayload = null; - if (nodePayload != null) + if (theTimeStamp == null) { - thePayload = DeserializeImplementation.StringFrom( - nodePayload, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "payload")); - return null; - } - if (thePayload == null) - { - throw new System.InvalidOperationException( - "Unexpected thePayload null when error is also null"); - } + error = new Reporting.Error( + "Required property \"timeStamp\" is missing"); + return null; } return new Aas.EventPayload( @@ -8417,533 +10518,700 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; + Reference? theObserved = null; + Direction? theDirection = null; + StateOfEvent? theState = null; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; + ModelingKind? theKind = null; + Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } + List? theEmbeddedDataSpecifications = null; + string? theMessageTopic = null; + Reference? theMessageBroker = null; + string? theLastUpdate = null; + string? theMinInterval = null; + string? theMaxInterval = null; - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "observed": + { + if (keyValue.Value == null) + { + continue; + } + + theObserved = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "observed")); + return null; + } + if (theObserved == null) + { + throw new System.InvalidOperationException( + "Unexpected theObserved null when error is also null"); + } + break; + } + case "direction": + { + if (keyValue.Value == null) + { + continue; + } + + theDirection = DeserializeImplementation.DirectionFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "direction")); + return null; + } + if (theDirection == null) + { + throw new System.InvalidOperationException( + "Unexpected theDirection null when error is also null"); + } + break; + } + case "state": + { + if (keyValue.Value == null) + { + continue; + } + + theState = DeserializeImplementation.StateOfEventFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "state")); + return null; + } + if (theState == null) + { + throw new System.InvalidOperationException( + "Unexpected theState null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "messageTopic": + { + if (keyValue.Value == null) + { + continue; + } + + theMessageTopic = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "messageTopic")); + return null; + } + if (theMessageTopic == null) + { + throw new System.InvalidOperationException( + "Unexpected theMessageTopic null when error is also null"); + } + break; + } + case "messageBroker": + { + if (keyValue.Value == null) + { + continue; + } + + theMessageBroker = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "messageBroker")); + return null; + } + if (theMessageBroker == null) + { + throw new System.InvalidOperationException( + "Unexpected theMessageBroker null when error is also null"); + } + break; + } + case "lastUpdate": + { + if (keyValue.Value == null) + { + continue; + } + + theLastUpdate = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "lastUpdate")); + return null; + } + if (theLastUpdate == null) + { + throw new System.InvalidOperationException( + "Unexpected theLastUpdate null when error is also null"); + } + break; + } + case "minInterval": + { + if (keyValue.Value == null) + { + continue; + } + + theMinInterval = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "minInterval")); + return null; + } + if (theMinInterval == null) + { + throw new System.InvalidOperationException( + "Unexpected theMinInterval null when error is also null"); + } + break; + } + case "maxInterval": + { + if (keyValue.Value == null) + { + continue; + } + + theMaxInterval = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "maxInterval")); + return null; + } + if (theMaxInterval == null) + { + throw new System.InvalidOperationException( + "Unexpected theMaxInterval null when error is also null"); + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; } } - Nodes.JsonNode? nodeObserved = obj["observed"]; - if (nodeObserved == null) - { - error = new Reporting.Error( - "Required property \"observed\" is missing "); - return null; - } - Aas.Reference? theObserved = DeserializeImplementation.ReferenceFrom( - nodeObserved, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "observed")); - return null; - } if (theObserved == null) - { - throw new System.InvalidOperationException( - "Unexpected theObserved null when error is also null"); - } - - Nodes.JsonNode? nodeDirection = obj["direction"]; - if (nodeDirection == null) { error = new Reporting.Error( - "Required property \"direction\" is missing "); - return null; - } - Aas.Direction? theDirection = DeserializeImplementation.DirectionFrom( - nodeDirection, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "direction")); + "Required property \"observed\" is missing"); return null; } - if (theDirection == null) - { - throw new System.InvalidOperationException( - "Unexpected theDirection null when error is also null"); - } - Nodes.JsonNode? nodeState = obj["state"]; - if (nodeState == null) + if (theDirection == null) { error = new Reporting.Error( - "Required property \"state\" is missing "); - return null; - } - Aas.StateOfEvent? theState = DeserializeImplementation.StateOfEventFrom( - nodeState, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "state")); - return null; - } - if (theState == null) - { - throw new System.InvalidOperationException( - "Unexpected theState null when error is also null"); - } - - Nodes.JsonNode? nodeMessageTopic = obj["messageTopic"]; - string? theMessageTopic = null; - if (nodeMessageTopic != null) - { - theMessageTopic = DeserializeImplementation.StringFrom( - nodeMessageTopic, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "messageTopic")); - return null; - } - if (theMessageTopic == null) - { - throw new System.InvalidOperationException( - "Unexpected theMessageTopic null when error is also null"); - } - } - - Nodes.JsonNode? nodeMessageBroker = obj["messageBroker"]; - Aas.Reference? theMessageBroker = null; - if (nodeMessageBroker != null) - { - theMessageBroker = DeserializeImplementation.ReferenceFrom( - nodeMessageBroker, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "messageBroker")); - return null; - } - if (theMessageBroker == null) - { - throw new System.InvalidOperationException( - "Unexpected theMessageBroker null when error is also null"); - } - } - - Nodes.JsonNode? nodeLastUpdate = obj["lastUpdate"]; - string? theLastUpdate = null; - if (nodeLastUpdate != null) - { - theLastUpdate = DeserializeImplementation.StringFrom( - nodeLastUpdate, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "lastUpdate")); - return null; - } - if (theLastUpdate == null) - { - throw new System.InvalidOperationException( - "Unexpected theLastUpdate null when error is also null"); - } - } - - Nodes.JsonNode? nodeMinInterval = obj["minInterval"]; - string? theMinInterval = null; - if (nodeMinInterval != null) - { - theMinInterval = DeserializeImplementation.StringFrom( - nodeMinInterval, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "minInterval")); - return null; - } - if (theMinInterval == null) - { - throw new System.InvalidOperationException( - "Unexpected theMinInterval null when error is also null"); - } + "Required property \"direction\" is missing"); + return null; } - Nodes.JsonNode? nodeMaxInterval = obj["maxInterval"]; - string? theMaxInterval = null; - if (nodeMaxInterval != null) + if (theState == null) { - theMaxInterval = DeserializeImplementation.StringFrom( - nodeMaxInterval, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "maxInterval")); - return null; - } - if (theMaxInterval == null) - { - throw new System.InvalidOperationException( - "Unexpected theMaxInterval null when error is also null"); - } + error = new Reporting.Error( + "Required property \"state\" is missing"); + return null; } return new Aas.BasicEventElement( @@ -8966,7 +11234,7 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theMessageTopic, theMessageBroker, theLastUpdate, @@ -8993,517 +11261,651 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; + ModelingKind? theKind = null; + Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } - - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; List? theQualifiers = null; - if (nodeQualifiers != null) - { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } - } - - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } - } - - Nodes.JsonNode? nodeInputVariables = obj["inputVariables"]; + List? theEmbeddedDataSpecifications = null; List? theInputVariables = null; - if (nodeInputVariables != null) - { - Nodes.JsonArray? arrayInputVariables = nodeInputVariables as Nodes.JsonArray; - if (arrayInputVariables == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeInputVariables.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "inputVariables")); - return null; - } - theInputVariables = new List( - arrayInputVariables.Count); - int indexInputVariables = 0; - foreach (Nodes.JsonNode? item in arrayInputVariables) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexInputVariables)); - error.PrependSegment( - new Reporting.NameSegment( - "inputVariables")); - return null; - } - OperationVariable? parsedItem = DeserializeImplementation.OperationVariableFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexInputVariables)); - error.PrependSegment( - new Reporting.NameSegment( - "inputVariables")); - return null; - } - theInputVariables.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexInputVariables++; - } - } - - Nodes.JsonNode? nodeOutputVariables = obj["outputVariables"]; List? theOutputVariables = null; - if (nodeOutputVariables != null) - { - Nodes.JsonArray? arrayOutputVariables = nodeOutputVariables as Nodes.JsonArray; - if (arrayOutputVariables == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeOutputVariables.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "outputVariables")); - return null; - } - theOutputVariables = new List( - arrayOutputVariables.Count); - int indexOutputVariables = 0; - foreach (Nodes.JsonNode? item in arrayOutputVariables) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexOutputVariables)); - error.PrependSegment( - new Reporting.NameSegment( - "outputVariables")); - return null; - } - OperationVariable? parsedItem = DeserializeImplementation.OperationVariableFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexOutputVariables)); - error.PrependSegment( - new Reporting.NameSegment( - "outputVariables")); - return null; - } - theOutputVariables.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexOutputVariables++; - } - } - - Nodes.JsonNode? nodeInoutputVariables = obj["inoutputVariables"]; List? theInoutputVariables = null; - if (nodeInoutputVariables != null) - { - Nodes.JsonArray? arrayInoutputVariables = nodeInoutputVariables as Nodes.JsonArray; - if (arrayInoutputVariables == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeInoutputVariables.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "inoutputVariables")); - return null; - } - theInoutputVariables = new List( - arrayInoutputVariables.Count); - int indexInoutputVariables = 0; - foreach (Nodes.JsonNode? item in arrayInoutputVariables) - { - if (item == null) - { + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "inputVariables": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayInputVariables = keyValue.Value as Nodes.JsonArray; + if (arrayInputVariables == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "inputVariables")); + return null; + } + theInputVariables = new List( + arrayInputVariables.Count); + int indexInputVariables = 0; + foreach (Nodes.JsonNode? item in arrayInputVariables) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexInputVariables)); + error.PrependSegment( + new Reporting.NameSegment( + "inputVariables")); + return null; + } + OperationVariable? parsedItem = DeserializeImplementation.OperationVariableFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexInputVariables)); + error.PrependSegment( + new Reporting.NameSegment( + "inputVariables")); + return null; + } + theInputVariables.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexInputVariables++; + } + break; + } + case "outputVariables": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayOutputVariables = keyValue.Value as Nodes.JsonArray; + if (arrayOutputVariables == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "outputVariables")); + return null; + } + theOutputVariables = new List( + arrayOutputVariables.Count); + int indexOutputVariables = 0; + foreach (Nodes.JsonNode? item in arrayOutputVariables) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexOutputVariables)); + error.PrependSegment( + new Reporting.NameSegment( + "outputVariables")); + return null; + } + OperationVariable? parsedItem = DeserializeImplementation.OperationVariableFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexOutputVariables)); + error.PrependSegment( + new Reporting.NameSegment( + "outputVariables")); + return null; + } + theOutputVariables.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexOutputVariables++; + } + break; + } + case "inoutputVariables": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayInoutputVariables = keyValue.Value as Nodes.JsonArray; + if (arrayInoutputVariables == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "inoutputVariables")); + return null; + } + theInoutputVariables = new List( + arrayInoutputVariables.Count); + int indexInoutputVariables = 0; + foreach (Nodes.JsonNode? item in arrayInoutputVariables) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexInoutputVariables)); + error.PrependSegment( + new Reporting.NameSegment( + "inoutputVariables")); + return null; + } + OperationVariable? parsedItem = DeserializeImplementation.OperationVariableFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexInoutputVariables)); + error.PrependSegment( + new Reporting.NameSegment( + "inoutputVariables")); + return null; + } + theInoutputVariables.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexInoutputVariables++; + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexInoutputVariables)); - error.PrependSegment( - new Reporting.NameSegment( - "inoutputVariables")); - return null; - } - OperationVariable? parsedItem = DeserializeImplementation.OperationVariableFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexInoutputVariables)); - error.PrependSegment( - new Reporting.NameSegment( - "inoutputVariables")); + $"Unexpected property: {keyValue.Key}"); return null; - } - theInoutputVariables.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexInoutputVariables++; } } + + return new Aas.Operation( theExtensions, theCategory, @@ -9515,7 +11917,7 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theInputVariables, theOutputVariables, theInoutputVariables); @@ -9540,27 +11942,48 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeValue = obj["value"]; - if (nodeValue == null) - { - error = new Reporting.Error( - "Required property \"value\" is missing "); - return null; - } - Aas.ISubmodelElement? theValue = DeserializeImplementation.ISubmodelElementFrom( - nodeValue, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; + ISubmodelElement? theValue = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.ISubmodelElementFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; + } } + if (theValue == null) { - throw new System.InvalidOperationException( - "Unexpected theValue null when error is also null"); + error = new Reporting.Error( + "Required property \"value\" is missing"); + return null; } return new Aas.OperationVariable( @@ -9578,371 +12001,493 @@ internal static class DeserializeImplementation Nodes.JsonNode node, out Reporting.Error? error) { - error = null; - - Nodes.JsonObject? obj = node as Nodes.JsonObject; - if (obj == null) - { - error = new Reporting.Error( - $"Expected a JsonObject, but got {node.GetType()}"); - return null; - } - - Nodes.JsonNode? nodeExtensions = obj["extensions"]; - List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; - string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; - string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; - string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeKind = obj["kind"]; - Aas.ModelingKind? theKind = null; - if (nodeKind != null) - { - theKind = DeserializeImplementation.ModelingKindFrom( - nodeKind, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "kind")); - return null; - } - if (theKind == null) - { - throw new System.InvalidOperationException( - "Unexpected theKind null when error is also null"); - } - } - - Nodes.JsonNode? nodeSemanticId = obj["semanticId"]; - Aas.Reference? theSemanticId = null; - if (nodeSemanticId != null) - { - theSemanticId = DeserializeImplementation.ReferenceFrom( - nodeSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "semanticId")); - return null; - } - if (theSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theSemanticId null when error is also null"); - } - } - - Nodes.JsonNode? nodeSupplementalSemanticIds = obj["supplementalSemanticIds"]; - List? theSupplementalSemanticIds = null; - if (nodeSupplementalSemanticIds != null) - { - Nodes.JsonArray? arraySupplementalSemanticIds = nodeSupplementalSemanticIds as Nodes.JsonArray; - if (arraySupplementalSemanticIds == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSupplementalSemanticIds.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds = new List( - arraySupplementalSemanticIds.Count); - int indexSupplementalSemanticIds = 0; - foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSupplementalSemanticIds)); - error.PrependSegment( - new Reporting.NameSegment( - "supplementalSemanticIds")); - return null; - } - theSupplementalSemanticIds.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSupplementalSemanticIds++; - } - } + error = null; - Nodes.JsonNode? nodeQualifiers = obj["qualifiers"]; - List? theQualifiers = null; - if (nodeQualifiers != null) + Nodes.JsonObject? obj = node as Nodes.JsonObject; + if (obj == null) { - Nodes.JsonArray? arrayQualifiers = nodeQualifiers as Nodes.JsonArray; - if (arrayQualifiers == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeQualifiers.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers = new List( - arrayQualifiers.Count); - int indexQualifiers = 0; - foreach (Nodes.JsonNode? item in arrayQualifiers) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexQualifiers)); - error.PrependSegment( - new Reporting.NameSegment( - "qualifiers")); - return null; - } - theQualifiers.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexQualifiers++; - } + error = new Reporting.Error( + $"Expected a JsonObject, but got {node.GetType()}"); + return null; } - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + List? theExtensions = null; + string? theCategory = null; + string? theIdShort = null; + List? theDisplayName = null; + List? theDescription = null; + string? theChecksum = null; + ModelingKind? theKind = null; + Reference? theSemanticId = null; + List? theSupplementalSemanticIds = null; + List? theQualifiers = null; + List? theEmbeddedDataSpecifications = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "kind": + { + if (keyValue.Value == null) + { + continue; + } + + theKind = DeserializeImplementation.ModelingKindFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "kind")); + return null; + } + if (theKind == null) + { + throw new System.InvalidOperationException( + "Unexpected theKind null when error is also null"); + } + break; + } + case "semanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "semanticId")); + return null; + } + if (theSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theSemanticId null when error is also null"); + } + break; + } + case "supplementalSemanticIds": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySupplementalSemanticIds = keyValue.Value as Nodes.JsonArray; + if (arraySupplementalSemanticIds == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds = new List( + arraySupplementalSemanticIds.Count); + int indexSupplementalSemanticIds = 0; + foreach (Nodes.JsonNode? item in arraySupplementalSemanticIds) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); + return null; + } + theSupplementalSemanticIds.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSupplementalSemanticIds++; + } + break; + } + case "qualifiers": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayQualifiers = keyValue.Value as Nodes.JsonArray; + if (arrayQualifiers == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers = new List( + arrayQualifiers.Count); + int indexQualifiers = 0; + foreach (Nodes.JsonNode? item in arrayQualifiers) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + Qualifier? parsedItem = DeserializeImplementation.QualifierFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); + return null; + } + theQualifiers.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexQualifiers++; + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; } } + + return new Aas.Capability( theExtensions, theCategory, @@ -9954,7 +12499,7 @@ internal static class DeserializeImplementation theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications); + theEmbeddedDataSpecifications); } // internal static CapabilityFrom /// @@ -9976,309 +12521,430 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeExtensions = obj["extensions"]; + string? theId = null; List? theExtensions = null; - if (nodeExtensions != null) - { - Nodes.JsonArray? arrayExtensions = nodeExtensions as Nodes.JsonArray; - if (arrayExtensions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeExtensions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions = new List( - arrayExtensions.Count); - int indexExtensions = 0; - foreach (Nodes.JsonNode? item in arrayExtensions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - Extension? parsedItem = DeserializeImplementation.ExtensionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - return null; - } - theExtensions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexExtensions++; - } - } - - Nodes.JsonNode? nodeCategory = obj["category"]; string? theCategory = null; - if (nodeCategory != null) - { - theCategory = DeserializeImplementation.StringFrom( - nodeCategory, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - return null; - } - if (theCategory == null) - { - throw new System.InvalidOperationException( - "Unexpected theCategory null when error is also null"); - } - } - - Nodes.JsonNode? nodeIdShort = obj["idShort"]; string? theIdShort = null; - if (nodeIdShort != null) - { - theIdShort = DeserializeImplementation.StringFrom( - nodeIdShort, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - return null; - } - if (theIdShort == null) - { - throw new System.InvalidOperationException( - "Unexpected theIdShort null when error is also null"); - } - } - - Nodes.JsonNode? nodeDisplayName = obj["displayName"]; - Aas.LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) - { - theDisplayName = DeserializeImplementation.LangStringSetFrom( - nodeDisplayName, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - if (theDisplayName == null) - { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - - Nodes.JsonNode? nodeChecksum = obj["checksum"]; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; - if (nodeChecksum != null) - { - theChecksum = DeserializeImplementation.StringFrom( - nodeChecksum, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - return null; - } - if (theChecksum == null) - { - throw new System.InvalidOperationException( - "Unexpected theChecksum null when error is also null"); - } - } - - Nodes.JsonNode? nodeAdministration = obj["administration"]; - Aas.AdministrativeInformation? theAdministration = null; - if (nodeAdministration != null) - { - theAdministration = DeserializeImplementation.AdministrativeInformationFrom( - nodeAdministration, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "administration")); - return null; - } - if (theAdministration == null) - { - throw new System.InvalidOperationException( - "Unexpected theAdministration null when error is also null"); - } - } - - Nodes.JsonNode? nodeId = obj["id"]; - if (nodeId == null) - { - error = new Reporting.Error( - "Required property \"id\" is missing "); - return null; - } - string? theId = DeserializeImplementation.StringFrom( - nodeId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "id")); - return null; - } - if (theId == null) - { - throw new System.InvalidOperationException( - "Unexpected theId null when error is also null"); - } + AdministrativeInformation? theAdministration = null; + List? theEmbeddedDataSpecifications = null; + List? theIsCaseOf = null; - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) - { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "id": + { + if (keyValue.Value == null) + { + continue; + } + + theId = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "id")); + return null; + } + if (theId == null) + { + throw new System.InvalidOperationException( + "Unexpected theId null when error is also null"); + } + break; + } + case "extensions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayExtensions = keyValue.Value as Nodes.JsonArray; + if (arrayExtensions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions = new List( + arrayExtensions.Count); + int indexExtensions = 0; + foreach (Nodes.JsonNode? item in arrayExtensions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + Extension? parsedItem = DeserializeImplementation.ExtensionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + return null; + } + theExtensions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexExtensions++; + } + break; + } + case "category": + { + if (keyValue.Value == null) + { + continue; + } + + theCategory = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + return null; + } + if (theCategory == null) + { + throw new System.InvalidOperationException( + "Unexpected theCategory null when error is also null"); + } + break; + } + case "idShort": + { + if (keyValue.Value == null) + { + continue; + } + + theIdShort = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + return null; + } + if (theIdShort == null) + { + throw new System.InvalidOperationException( + "Unexpected theIdShort null when error is also null"); + } + break; + } + case "displayName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDisplayName = keyValue.Value as Nodes.JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (Nodes.JsonNode? item in arrayDisplayName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; + } + break; + } + case "description": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDescription = keyValue.Value as Nodes.JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (Nodes.JsonNode? item in arrayDescription) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; + } + break; + } + case "checksum": + { + if (keyValue.Value == null) + { + continue; + } + + theChecksum = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + return null; + } + if (theChecksum == null) + { + throw new System.InvalidOperationException( + "Unexpected theChecksum null when error is also null"); + } + break; + } + case "administration": + { + if (keyValue.Value == null) + { + continue; + } + + theAdministration = DeserializeImplementation.AdministrativeInformationFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "administration")); + return null; + } + if (theAdministration == null) + { + throw new System.InvalidOperationException( + "Unexpected theAdministration null when error is also null"); + } + break; + } + case "embeddedDataSpecifications": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayEmbeddedDataSpecifications = keyValue.Value as Nodes.JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (Nodes.JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + EmbeddedDataSpecification? parsedItem = DeserializeImplementation.EmbeddedDataSpecificationFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; + } + break; + } + case "isCaseOf": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayIsCaseOf = keyValue.Value as Nodes.JsonArray; + if (arrayIsCaseOf == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "isCaseOf")); + return null; + } + theIsCaseOf = new List( + arrayIsCaseOf.Count); + int indexIsCaseOf = 0; + foreach (Nodes.JsonNode? item in arrayIsCaseOf) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexIsCaseOf)); + error.PrependSegment( + new Reporting.NameSegment( + "isCaseOf")); + return null; + } + Reference? parsedItem = DeserializeImplementation.ReferenceFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexIsCaseOf)); + error.PrependSegment( + new Reporting.NameSegment( + "isCaseOf")); + return null; + } + theIsCaseOf.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexIsCaseOf++; + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); + $"Unexpected property: {keyValue.Key}"); return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; } } - Nodes.JsonNode? nodeIsCaseOf = obj["isCaseOf"]; - List? theIsCaseOf = null; - if (nodeIsCaseOf != null) + if (theId == null) { - Nodes.JsonArray? arrayIsCaseOf = nodeIsCaseOf as Nodes.JsonArray; - if (arrayIsCaseOf == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeIsCaseOf.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "isCaseOf")); - return null; - } - theIsCaseOf = new List( - arrayIsCaseOf.Count); - int indexIsCaseOf = 0; - foreach (Nodes.JsonNode? item in arrayIsCaseOf) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexIsCaseOf)); - error.PrependSegment( - new Reporting.NameSegment( - "isCaseOf")); - return null; - } - Reference? parsedItem = DeserializeImplementation.ReferenceFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexIsCaseOf)); - error.PrependSegment( - new Reporting.NameSegment( - "isCaseOf")); - return null; - } - theIsCaseOf.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexIsCaseOf++; - } + error = new Reporting.Error( + "Required property \"id\" is missing"); + return null; } return new Aas.ConceptDescription( @@ -10292,7 +12958,7 @@ internal static class DeserializeImplementation theDescription, theChecksum, theAdministration, - theDataSpecifications, + theEmbeddedDataSpecifications, theIsCaseOf); } // internal static ConceptDescriptionFrom @@ -10321,7 +12987,7 @@ internal static class DeserializeImplementation if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of ReferenceTypes "); + "Not a valid JSON representation of ReferenceTypes"); } return result; } // internal static ReferenceTypesFrom @@ -10345,103 +13011,137 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeType = obj["type"]; - if (nodeType == null) - { - error = new Reporting.Error( - "Required property \"type\" is missing "); - return null; - } - Aas.ReferenceTypes? theType = DeserializeImplementation.ReferenceTypesFrom( - nodeType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "type")); - return null; - } - if (theType == null) - { - throw new System.InvalidOperationException( - "Unexpected theType null when error is also null"); - } - - Nodes.JsonNode? nodeReferredSemanticId = obj["referredSemanticId"]; - Aas.Reference? theReferredSemanticId = null; - if (nodeReferredSemanticId != null) - { - theReferredSemanticId = DeserializeImplementation.ReferenceFrom( - nodeReferredSemanticId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "referredSemanticId")); - return null; - } - if (theReferredSemanticId == null) - { - throw new System.InvalidOperationException( - "Unexpected theReferredSemanticId null when error is also null"); + ReferenceTypes? theType = null; + List? theKeys = null; + Reference? theReferredSemanticId = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "type": + { + if (keyValue.Value == null) + { + continue; + } + + theType = DeserializeImplementation.ReferenceTypesFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "type")); + return null; + } + if (theType == null) + { + throw new System.InvalidOperationException( + "Unexpected theType null when error is also null"); + } + break; + } + case "keys": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayKeys = keyValue.Value as Nodes.JsonArray; + if (arrayKeys == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "keys")); + return null; + } + theKeys = new List( + arrayKeys.Count); + int indexKeys = 0; + foreach (Nodes.JsonNode? item in arrayKeys) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexKeys)); + error.PrependSegment( + new Reporting.NameSegment( + "keys")); + return null; + } + Key? parsedItem = DeserializeImplementation.KeyFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexKeys)); + error.PrependSegment( + new Reporting.NameSegment( + "keys")); + return null; + } + theKeys.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexKeys++; + } + break; + } + case "referredSemanticId": + { + if (keyValue.Value == null) + { + continue; + } + + theReferredSemanticId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "referredSemanticId")); + return null; + } + if (theReferredSemanticId == null) + { + throw new System.InvalidOperationException( + "Unexpected theReferredSemanticId null when error is also null"); + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; } } - Nodes.JsonNode? nodeKeys = obj["keys"]; - if (nodeKeys == null) + if (theType == null) { error = new Reporting.Error( - "Required property \"keys\" is missing "); + "Required property \"type\" is missing"); return null; } - Nodes.JsonArray? arrayKeys = nodeKeys as Nodes.JsonArray; - if (arrayKeys == null) + + if (theKeys == null) { error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeKeys.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "keys")); + "Required property \"keys\" is missing"); return null; } - var theKeys = new List( - arrayKeys.Count); - int indexKeys = 0; - foreach (Nodes.JsonNode? item in arrayKeys) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexKeys)); - error.PrependSegment( - new Reporting.NameSegment( - "keys")); - return null; - } - Key? parsedItem = DeserializeImplementation.KeyFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexKeys)); - error.PrependSegment( - new Reporting.NameSegment( - "keys")); - return null; - } - theKeys.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexKeys++; - } return new Aas.Reference( theType @@ -10472,157 +13172,97 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeType = obj["type"]; - if (nodeType == null) - { - error = new Reporting.Error( - "Required property \"type\" is missing "); - return null; - } - Aas.KeyTypes? theType = DeserializeImplementation.KeyTypesFrom( - nodeType, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "type")); - return null; - } - if (theType == null) - { - throw new System.InvalidOperationException( - "Unexpected theType null when error is also null"); - } - - Nodes.JsonNode? nodeValue = obj["value"]; - if (nodeValue == null) - { - error = new Reporting.Error( - "Required property \"value\" is missing "); - return null; - } - string? theValue = DeserializeImplementation.StringFrom( - nodeValue, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - if (theValue == null) - { - throw new System.InvalidOperationException( - "Unexpected theValue null when error is also null"); - } - - return new Aas.Key( - theType - ?? throw new System.InvalidOperationException( - "Unexpected null, had to be handled before"), - theValue - ?? throw new System.InvalidOperationException( - "Unexpected null, had to be handled before")); - } // internal static KeyFrom - - /// - /// Deserialize the enumeration GenericFragmentKeys from the . - /// - /// JSON node to be parsed - /// Error, if any, during the deserialization - internal static Aas.GenericFragmentKeys? GenericFragmentKeysFrom( - Nodes.JsonNode node, - out Reporting.Error? error) - { - error = null; - string? text = DeserializeImplementation.StringFrom( - node, out error); - if (error != null) - { - return null; - } - if (text == null) - { - throw new System.InvalidOperationException( - "Unexpected text null if error null"); - } - Aas.GenericFragmentKeys? result = Stringification.GenericFragmentKeysFromString(text); - if (result == null) - { - error = new Reporting.Error( - "Not a valid JSON representation of GenericFragmentKeys "); - } - return result; - } // internal static GenericFragmentKeysFrom + KeyTypes? theType = null; + string? theValue = null; - /// - /// Deserialize the enumeration GenericGloballyIdentifiables from the . - /// - /// JSON node to be parsed - /// Error, if any, during the deserialization - internal static Aas.GenericGloballyIdentifiables? GenericGloballyIdentifiablesFrom( - Nodes.JsonNode node, - out Reporting.Error? error) - { - error = null; - string? text = DeserializeImplementation.StringFrom( - node, out error); - if (error != null) - { - return null; - } - if (text == null) - { - throw new System.InvalidOperationException( - "Unexpected text null if error null"); - } - Aas.GenericGloballyIdentifiables? result = Stringification.GenericGloballyIdentifiablesFromString(text); - if (result == null) - { - error = new Reporting.Error( - "Not a valid JSON representation of GenericGloballyIdentifiables "); + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "type": + { + if (keyValue.Value == null) + { + continue; + } + + theType = DeserializeImplementation.KeyTypesFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "type")); + return null; + } + if (theType == null) + { + throw new System.InvalidOperationException( + "Unexpected theType null when error is also null"); + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; + } } - return result; - } // internal static GenericGloballyIdentifiablesFrom - /// - /// Deserialize the enumeration AasIdentifiables from the . - /// - /// JSON node to be parsed - /// Error, if any, during the deserialization - internal static Aas.AasIdentifiables? AasIdentifiablesFrom( - Nodes.JsonNode node, - out Reporting.Error? error) - { - error = null; - string? text = DeserializeImplementation.StringFrom( - node, out error); - if (error != null) - { - return null; - } - if (text == null) + if (theType == null) { - throw new System.InvalidOperationException( - "Unexpected text null if error null"); + error = new Reporting.Error( + "Required property \"type\" is missing"); + return null; } - Aas.AasIdentifiables? result = Stringification.AasIdentifiablesFromString(text); - if (result == null) + + if (theValue == null) { error = new Reporting.Error( - "Not a valid JSON representation of AasIdentifiables "); + "Required property \"value\" is missing"); + return null; } - return result; - } // internal static AasIdentifiablesFrom + + return new Aas.Key( + theType + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theValue + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before")); + } // internal static KeyFrom /// - /// Deserialize the enumeration AasSubmodelElements from the . + /// Deserialize the enumeration KeyTypes from the . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.AasSubmodelElements? AasSubmodelElementsFrom( + internal static Aas.KeyTypes? KeyTypesFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -10638,21 +13278,21 @@ internal static class DeserializeImplementation throw new System.InvalidOperationException( "Unexpected text null if error null"); } - Aas.AasSubmodelElements? result = Stringification.AasSubmodelElementsFromString(text); + Aas.KeyTypes? result = Stringification.KeyTypesFromString(text); if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of AasSubmodelElements "); + "Not a valid JSON representation of KeyTypes"); } return result; - } // internal static AasSubmodelElementsFrom + } // internal static KeyTypesFrom /// - /// Deserialize the enumeration AasReferableNonIdentifiables from the . + /// Deserialize the enumeration DataTypeDefXsd from the . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.AasReferableNonIdentifiables? AasReferableNonIdentifiablesFrom( + internal static Aas.DataTypeDefXsd? DataTypeDefXsdFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -10668,171 +13308,496 @@ internal static class DeserializeImplementation throw new System.InvalidOperationException( "Unexpected text null if error null"); } - Aas.AasReferableNonIdentifiables? result = Stringification.AasReferableNonIdentifiablesFromString(text); + Aas.DataTypeDefXsd? result = Stringification.DataTypeDefXsdFromString(text); if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of AasReferableNonIdentifiables "); + "Not a valid JSON representation of DataTypeDefXsd"); } return result; - } // internal static AasReferableNonIdentifiablesFrom + } // internal static DataTypeDefXsdFrom /// - /// Deserialize the enumeration AasReferables from the . + /// Deserialize an instance of LangString from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.AasReferables? AasReferablesFrom( + internal static Aas.LangString? LangStringFrom( Nodes.JsonNode node, out Reporting.Error? error) { error = null; - string? text = DeserializeImplementation.StringFrom( - node, out error); - if (error != null) + + Nodes.JsonObject? obj = node as Nodes.JsonObject; + if (obj == null) { + error = new Reporting.Error( + $"Expected a JsonObject, but got {node.GetType()}"); return null; } - if (text == null) + + string? theLanguage = null; + string? theText = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "language": + { + if (keyValue.Value == null) + { + continue; + } + + theLanguage = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "language")); + return null; + } + if (theLanguage == null) + { + throw new System.InvalidOperationException( + "Unexpected theLanguage null when error is also null"); + } + break; + } + case "text": + { + if (keyValue.Value == null) + { + continue; + } + + theText = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "text")); + return null; + } + if (theText == null) + { + throw new System.InvalidOperationException( + "Unexpected theText null when error is also null"); + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; + } + } + + if (theLanguage == null) { - throw new System.InvalidOperationException( - "Unexpected text null if error null"); + error = new Reporting.Error( + "Required property \"language\" is missing"); + return null; } - Aas.AasReferables? result = Stringification.AasReferablesFromString(text); - if (result == null) + + if (theText == null) { error = new Reporting.Error( - "Not a valid JSON representation of AasReferables "); + "Required property \"text\" is missing"); + return null; } - return result; - } // internal static AasReferablesFrom + + return new Aas.LangString( + theLanguage + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theText + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before")); + } // internal static LangStringFrom /// - /// Deserialize the enumeration GloballyIdentifiables from the . + /// Deserialize an instance of Environment from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.GloballyIdentifiables? GloballyIdentifiablesFrom( + internal static Aas.Environment? EnvironmentFrom( Nodes.JsonNode node, out Reporting.Error? error) { error = null; - string? text = DeserializeImplementation.StringFrom( - node, out error); - if (error != null) + + Nodes.JsonObject? obj = node as Nodes.JsonObject; + if (obj == null) { + error = new Reporting.Error( + $"Expected a JsonObject, but got {node.GetType()}"); return null; } - if (text == null) - { - throw new System.InvalidOperationException( - "Unexpected text null if error null"); - } - Aas.GloballyIdentifiables? result = Stringification.GloballyIdentifiablesFromString(text); - if (result == null) - { - error = new Reporting.Error( - "Not a valid JSON representation of GloballyIdentifiables "); + + List? theAssetAdministrationShells = null; + List? theSubmodels = null; + List? theConceptDescriptions = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "assetAdministrationShells": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayAssetAdministrationShells = keyValue.Value as Nodes.JsonArray; + if (arrayAssetAdministrationShells == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "assetAdministrationShells")); + return null; + } + theAssetAdministrationShells = new List( + arrayAssetAdministrationShells.Count); + int indexAssetAdministrationShells = 0; + foreach (Nodes.JsonNode? item in arrayAssetAdministrationShells) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexAssetAdministrationShells)); + error.PrependSegment( + new Reporting.NameSegment( + "assetAdministrationShells")); + return null; + } + AssetAdministrationShell? parsedItem = DeserializeImplementation.AssetAdministrationShellFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexAssetAdministrationShells)); + error.PrependSegment( + new Reporting.NameSegment( + "assetAdministrationShells")); + return null; + } + theAssetAdministrationShells.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexAssetAdministrationShells++; + } + break; + } + case "submodels": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arraySubmodels = keyValue.Value as Nodes.JsonArray; + if (arraySubmodels == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "submodels")); + return null; + } + theSubmodels = new List( + arraySubmodels.Count); + int indexSubmodels = 0; + foreach (Nodes.JsonNode? item in arraySubmodels) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexSubmodels)); + error.PrependSegment( + new Reporting.NameSegment( + "submodels")); + return null; + } + Submodel? parsedItem = DeserializeImplementation.SubmodelFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSubmodels)); + error.PrependSegment( + new Reporting.NameSegment( + "submodels")); + return null; + } + theSubmodels.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexSubmodels++; + } + break; + } + case "conceptDescriptions": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayConceptDescriptions = keyValue.Value as Nodes.JsonArray; + if (arrayConceptDescriptions == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "conceptDescriptions")); + return null; + } + theConceptDescriptions = new List( + arrayConceptDescriptions.Count); + int indexConceptDescriptions = 0; + foreach (Nodes.JsonNode? item in arrayConceptDescriptions) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexConceptDescriptions)); + error.PrependSegment( + new Reporting.NameSegment( + "conceptDescriptions")); + return null; + } + ConceptDescription? parsedItem = DeserializeImplementation.ConceptDescriptionFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexConceptDescriptions)); + error.PrependSegment( + new Reporting.NameSegment( + "conceptDescriptions")); + return null; + } + theConceptDescriptions.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexConceptDescriptions++; + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; + } } - return result; - } // internal static GloballyIdentifiablesFrom + + + + return new Aas.Environment( + theAssetAdministrationShells, + theSubmodels, + theConceptDescriptions); + } // internal static EnvironmentFrom /// - /// Deserialize the enumeration FragmentKeys from the . + /// Deserialize an instance of IDataSpecificationContent by dispatching + /// based on modelType property of the . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.FragmentKeys? FragmentKeysFrom( + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static Aas.IDataSpecificationContent? IDataSpecificationContentFrom( Nodes.JsonNode node, out Reporting.Error? error) { error = null; - string? text = DeserializeImplementation.StringFrom( - node, out error); - if (error != null) + + var obj = node as Nodes.JsonObject; + if (obj == null) { + error = new Reporting.Error( + "Expected Nodes.JsonObject, but got {node.GetType()}"); return null; } - if (text == null) - { - throw new System.InvalidOperationException( - "Unexpected text null if error null"); - } - Aas.FragmentKeys? result = Stringification.FragmentKeysFromString(text); - if (result == null) + + Nodes.JsonNode? modelTypeNode = obj["modelType"]; + if (modelTypeNode == null) { error = new Reporting.Error( - "Not a valid JSON representation of FragmentKeys "); + "Expected a model type, but none is present"); + return null; } - return result; - } // internal static FragmentKeysFrom - - /// - /// Deserialize the enumeration KeyTypes from the . - /// - /// JSON node to be parsed - /// Error, if any, during the deserialization - internal static Aas.KeyTypes? KeyTypesFrom( - Nodes.JsonNode node, - out Reporting.Error? error) - { - error = null; - string? text = DeserializeImplementation.StringFrom( - node, out error); - if (error != null) + Nodes.JsonValue? modelTypeValue = modelTypeNode as Nodes.JsonValue; + if (modelTypeValue == null) { + error = new Reporting.Error( + "Expected JsonValue, " + + $"but got {modelTypeNode.GetType()}"); return null; } - if (text == null) + modelTypeValue.TryGetValue(out string? modelType); + if (modelType == null) { - throw new System.InvalidOperationException( - "Unexpected text null if error null"); + error = new Reporting.Error( + "Expected a string, " + + $"but the conversion failed from {modelTypeValue}"); + return null; } - Aas.KeyTypes? result = Stringification.KeyTypesFromString(text); - if (result == null) + + switch (modelType) { - error = new Reporting.Error( - "Not a valid JSON representation of KeyTypes "); + case "DataSpecificationIEC61360": + return DataSpecificationIec61360From( + node, out error); + case "DataSpecificationPhysicalUnit": + return DataSpecificationPhysicalUnitFrom( + node, out error); + default: + error = new Reporting.Error( + $"Unexpected model type for IDataSpecificationContent: {modelType}"); + return null; } - return result; - } // internal static KeyTypesFrom + } // public static Aas.IDataSpecificationContent IDataSpecificationContentFrom /// - /// Deserialize the enumeration DataTypeDefXsd from the . + /// Deserialize an instance of EmbeddedDataSpecification from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.DataTypeDefXsd? DataTypeDefXsdFrom( + internal static Aas.EmbeddedDataSpecification? EmbeddedDataSpecificationFrom( Nodes.JsonNode node, out Reporting.Error? error) { error = null; - string? text = DeserializeImplementation.StringFrom( - node, out error); - if (error != null) + + Nodes.JsonObject? obj = node as Nodes.JsonObject; + if (obj == null) { + error = new Reporting.Error( + $"Expected a JsonObject, but got {node.GetType()}"); return null; } - if (text == null) + + Reference? theDataSpecification = null; + IDataSpecificationContent? theDataSpecificationContent = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "dataSpecification": + { + if (keyValue.Value == null) + { + continue; + } + + theDataSpecification = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "dataSpecification")); + return null; + } + if (theDataSpecification == null) + { + throw new System.InvalidOperationException( + "Unexpected theDataSpecification null when error is also null"); + } + break; + } + case "dataSpecificationContent": + { + if (keyValue.Value == null) + { + continue; + } + + theDataSpecificationContent = DeserializeImplementation.IDataSpecificationContentFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "dataSpecificationContent")); + return null; + } + if (theDataSpecificationContent == null) + { + throw new System.InvalidOperationException( + "Unexpected theDataSpecificationContent null when error is also null"); + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; + } + } + + if (theDataSpecification == null) { - throw new System.InvalidOperationException( - "Unexpected text null if error null"); + error = new Reporting.Error( + "Required property \"dataSpecification\" is missing"); + return null; } - Aas.DataTypeDefXsd? result = Stringification.DataTypeDefXsdFromString(text); - if (result == null) + + if (theDataSpecificationContent == null) { error = new Reporting.Error( - "Not a valid JSON representation of DataTypeDefXsd "); + "Required property \"dataSpecificationContent\" is missing"); + return null; } - return result; - } // internal static DataTypeDefXsdFrom + + 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")); + } // internal static EmbeddedDataSpecificationFrom /// - /// Deserialize the enumeration DataTypeDefRdf from the . + /// Deserialize the enumeration DataTypeIec61360 from the . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.DataTypeDefRdf? DataTypeDefRdfFrom( + internal static Aas.DataTypeIec61360? DataTypeIec61360From( Nodes.JsonNode node, out Reporting.Error? error) { @@ -10848,21 +13813,21 @@ internal static class DeserializeImplementation throw new System.InvalidOperationException( "Unexpected text null if error null"); } - Aas.DataTypeDefRdf? result = Stringification.DataTypeDefRdfFromString(text); + Aas.DataTypeIec61360? result = Stringification.DataTypeIec61360FromString(text); if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of DataTypeDefRdf "); + "Not a valid JSON representation of DataTypeIec61360"); } return result; - } // internal static DataTypeDefRdfFrom + } // internal static DataTypeIec61360From /// - /// Deserialize the enumeration DataTypeDef from the . + /// Deserialize the enumeration LevelType from the . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.DataTypeDef? DataTypeDefFrom( + internal static Aas.LevelType? LevelTypeFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -10878,21 +13843,21 @@ internal static class DeserializeImplementation throw new System.InvalidOperationException( "Unexpected text null if error null"); } - Aas.DataTypeDef? result = Stringification.DataTypeDefFromString(text); + Aas.LevelType? result = Stringification.LevelTypeFromString(text); if (result == null) { error = new Reporting.Error( - "Not a valid JSON representation of DataTypeDef "); + "Not a valid JSON representation of LevelType"); } return result; - } // internal static DataTypeDefFrom + } // internal static LevelTypeFrom /// - /// Deserialize an instance of LangString from . + /// Deserialize an instance of ValueReferencePair from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.LangString? LangStringFrom( + internal static Aas.ValueReferencePair? ValueReferencePairFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -10906,67 +13871,97 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeLanguage = obj["language"]; - if (nodeLanguage == null) - { - error = new Reporting.Error( - "Required property \"language\" is missing "); - return null; - } - string? theLanguage = DeserializeImplementation.StringFrom( - nodeLanguage, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "language")); - return null; - } - if (theLanguage == null) - { - throw new System.InvalidOperationException( - "Unexpected theLanguage null when error is also null"); + string? theValue = null; + Reference? theValueId = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + case "valueId": + { + if (keyValue.Value == null) + { + continue; + } + + theValueId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueId")); + return null; + } + if (theValueId == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueId null when error is also null"); + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; + } } - Nodes.JsonNode? nodeText = obj["text"]; - if (nodeText == null) + if (theValue == null) { error = new Reporting.Error( - "Required property \"text\" is missing "); + "Required property \"value\" is missing"); return null; } - string? theText = DeserializeImplementation.StringFrom( - nodeText, - out error); - if (error != null) + + if (theValueId == null) { - error.PrependSegment( - new Reporting.NameSegment( - "text")); + error = new Reporting.Error( + "Required property \"valueId\" is missing"); return null; } - if (theText == null) - { - throw new System.InvalidOperationException( - "Unexpected theText null when error is also null"); - } - return new Aas.LangString( - theLanguage + return new Aas.ValueReferencePair( + theValue ?? throw new System.InvalidOperationException( "Unexpected null, had to be handled before"), - theText + theValueId ?? throw new System.InvalidOperationException( "Unexpected null, had to be handled before")); - } // internal static LangStringFrom + } // internal static ValueReferencePairFrom /// - /// Deserialize an instance of LangStringSet from . + /// Deserialize an instance of ValueList from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.LangStringSet? LangStringSetFrom( + internal static Aas.ValueList? ValueListFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -10980,94 +13975,93 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeLangStrings = obj["langStrings"]; - if (nodeLangStrings == null) - { - error = new Reporting.Error( - "Required property \"langStrings\" is missing "); - return null; - } - Nodes.JsonArray? arrayLangStrings = nodeLangStrings as Nodes.JsonArray; - if (arrayLangStrings == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeLangStrings.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "langStrings")); - return null; - } - var theLangStrings = new List( - arrayLangStrings.Count); - int indexLangStrings = 0; - foreach (Nodes.JsonNode? item in arrayLangStrings) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexLangStrings)); - error.PrependSegment( - new Reporting.NameSegment( - "langStrings")); - return null; - } - LangString? parsedItem = DeserializeImplementation.LangStringFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexLangStrings)); - error.PrependSegment( - new Reporting.NameSegment( - "langStrings")); - return null; + List? theValueReferencePairs = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "valueReferencePairs": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayValueReferencePairs = keyValue.Value as Nodes.JsonArray; + if (arrayValueReferencePairs == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "valueReferencePairs")); + return null; + } + theValueReferencePairs = new List( + arrayValueReferencePairs.Count); + int indexValueReferencePairs = 0; + foreach (Nodes.JsonNode? item in arrayValueReferencePairs) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexValueReferencePairs)); + error.PrependSegment( + new Reporting.NameSegment( + "valueReferencePairs")); + return null; + } + ValueReferencePair? parsedItem = DeserializeImplementation.ValueReferencePairFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexValueReferencePairs)); + error.PrependSegment( + new Reporting.NameSegment( + "valueReferencePairs")); + return null; + } + theValueReferencePairs.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexValueReferencePairs++; + } + break; + } + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; } - theLangStrings.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexLangStrings++; } - return new Aas.LangStringSet( - theLangStrings - ?? throw new System.InvalidOperationException( - "Unexpected null, had to be handled before")); - } // internal static LangStringSetFrom - - /// - /// Deserialize an instance of DataSpecificationContent from . - /// - /// JSON node to be parsed - /// Error, if any, during the deserialization - internal static Aas.DataSpecificationContent? DataSpecificationContentFrom( - Nodes.JsonNode node, - out Reporting.Error? error) - { - error = null; - - Nodes.JsonObject? obj = node as Nodes.JsonObject; - if (obj == null) + if (theValueReferencePairs == null) { error = new Reporting.Error( - $"Expected a JsonObject, but got {node.GetType()}"); + "Required property \"valueReferencePairs\" is missing"); return null; } - return new Aas.DataSpecificationContent(); - } // internal static DataSpecificationContentFrom + return new Aas.ValueList( + theValueReferencePairs + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before")); + } // internal static ValueListFrom /// - /// Deserialize an instance of DataSpecification from . + /// Deserialize an instance of DataSpecificationIec61360 from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.DataSpecification? DataSpecificationFrom( + internal static Aas.DataSpecificationIec61360? DataSpecificationIec61360From( Nodes.JsonNode node, out Reporting.Error? error) { @@ -11081,111 +14075,443 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeId = obj["id"]; - if (nodeId == null) - { - error = new Reporting.Error( - "Required property \"id\" is missing "); - return null; - } - string? theId = DeserializeImplementation.StringFrom( - nodeId, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "id")); - return null; - } - if (theId == null) - { - throw new System.InvalidOperationException( - "Unexpected theId null when error is also null"); + List? thePreferredName = null; + List? theShortName = null; + string? theUnit = null; + Reference? theUnitId = null; + string? theSourceOfDefinition = null; + string? theSymbol = null; + DataTypeIec61360? theDataType = null; + List? theDefinition = null; + string? theValueFormat = null; + ValueList? theValueList = null; + string? theValue = null; + LevelType? theLevelType = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "preferredName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayPreferredName = keyValue.Value as Nodes.JsonArray; + if (arrayPreferredName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "preferredName")); + return null; + } + thePreferredName = new List( + arrayPreferredName.Count); + int indexPreferredName = 0; + foreach (Nodes.JsonNode? item in arrayPreferredName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexPreferredName)); + error.PrependSegment( + new Reporting.NameSegment( + "preferredName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexPreferredName)); + error.PrependSegment( + new Reporting.NameSegment( + "preferredName")); + return null; + } + thePreferredName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexPreferredName++; + } + break; + } + case "shortName": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayShortName = keyValue.Value as Nodes.JsonArray; + if (arrayShortName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "shortName")); + return null; + } + theShortName = new List( + arrayShortName.Count); + int indexShortName = 0; + foreach (Nodes.JsonNode? item in arrayShortName) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexShortName)); + error.PrependSegment( + new Reporting.NameSegment( + "shortName")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexShortName)); + error.PrependSegment( + new Reporting.NameSegment( + "shortName")); + return null; + } + theShortName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexShortName++; + } + break; + } + case "unit": + { + if (keyValue.Value == null) + { + continue; + } + + theUnit = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "unit")); + return null; + } + if (theUnit == null) + { + throw new System.InvalidOperationException( + "Unexpected theUnit null when error is also null"); + } + break; + } + case "unitId": + { + if (keyValue.Value == null) + { + continue; + } + + theUnitId = DeserializeImplementation.ReferenceFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "unitId")); + return null; + } + if (theUnitId == null) + { + throw new System.InvalidOperationException( + "Unexpected theUnitId null when error is also null"); + } + break; + } + case "sourceOfDefinition": + { + if (keyValue.Value == null) + { + continue; + } + + theSourceOfDefinition = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "sourceOfDefinition")); + return null; + } + if (theSourceOfDefinition == null) + { + throw new System.InvalidOperationException( + "Unexpected theSourceOfDefinition null when error is also null"); + } + break; + } + case "symbol": + { + if (keyValue.Value == null) + { + continue; + } + + theSymbol = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "symbol")); + return null; + } + if (theSymbol == null) + { + throw new System.InvalidOperationException( + "Unexpected theSymbol null when error is also null"); + } + break; + } + case "dataType": + { + if (keyValue.Value == null) + { + continue; + } + + theDataType = DeserializeImplementation.DataTypeIec61360From( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "dataType")); + return null; + } + if (theDataType == null) + { + throw new System.InvalidOperationException( + "Unexpected theDataType null when error is also null"); + } + break; + } + case "definition": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDefinition = keyValue.Value as Nodes.JsonArray; + if (arrayDefinition == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "definition")); + return null; + } + theDefinition = new List( + arrayDefinition.Count); + int indexDefinition = 0; + foreach (Nodes.JsonNode? item in arrayDefinition) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDefinition)); + error.PrependSegment( + new Reporting.NameSegment( + "definition")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDefinition)); + error.PrependSegment( + new Reporting.NameSegment( + "definition")); + return null; + } + theDefinition.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDefinition++; + } + break; + } + case "valueFormat": + { + if (keyValue.Value == null) + { + continue; + } + + theValueFormat = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueFormat")); + return null; + } + if (theValueFormat == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueFormat null when error is also null"); + } + break; + } + case "valueList": + { + if (keyValue.Value == null) + { + continue; + } + + theValueList = DeserializeImplementation.ValueListFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueList")); + return null; + } + if (theValueList == null) + { + throw new System.InvalidOperationException( + "Unexpected theValueList null when error is also null"); + } + break; + } + case "value": + { + if (keyValue.Value == null) + { + continue; + } + + theValue = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + if (theValue == null) + { + throw new System.InvalidOperationException( + "Unexpected theValue null when error is also null"); + } + break; + } + case "levelType": + { + if (keyValue.Value == null) + { + continue; + } + + theLevelType = DeserializeImplementation.LevelTypeFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "levelType")); + return null; + } + if (theLevelType == null) + { + throw new System.InvalidOperationException( + "Unexpected theLevelType null when error is also null"); + } + break; + } + case "modelType": + continue; + default: + error = new Reporting.Error( + $"Unexpected property: {keyValue.Key}"); + return null; + } } - Nodes.JsonNode? nodeDataSpecificationContent = obj["dataSpecificationContent"]; - if (nodeDataSpecificationContent == null) + if (thePreferredName == null) { error = new Reporting.Error( - "Required property \"dataSpecificationContent\" is missing "); - return null; - } - Aas.DataSpecificationContent? theDataSpecificationContent = DeserializeImplementation.DataSpecificationContentFrom( - nodeDataSpecificationContent, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecificationContent")); + "Required property \"preferredName\" is missing"); return null; } - if (theDataSpecificationContent == null) - { - throw new System.InvalidOperationException( - "Unexpected theDataSpecificationContent null when error is also null"); - } - - Nodes.JsonNode? nodeAdministration = obj["administration"]; - Aas.AdministrativeInformation? theAdministration = null; - if (nodeAdministration != null) - { - theAdministration = DeserializeImplementation.AdministrativeInformationFrom( - nodeAdministration, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "administration")); - return null; - } - if (theAdministration == null) - { - throw new System.InvalidOperationException( - "Unexpected theAdministration null when error is also null"); - } - } - - Nodes.JsonNode? nodeDescription = obj["description"]; - Aas.LangStringSet? theDescription = null; - if (nodeDescription != null) - { - theDescription = DeserializeImplementation.LangStringSetFrom( - nodeDescription, - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - if (theDescription == null) - { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); - } - } - return new Aas.DataSpecification( - theId - ?? throw new System.InvalidOperationException( - "Unexpected null, had to be handled before"), - theDataSpecificationContent + return new Aas.DataSpecificationIec61360( + thePreferredName ?? throw new System.InvalidOperationException( "Unexpected null, had to be handled before"), - theAdministration, - theDescription); - } // internal static DataSpecificationFrom + theShortName, + theUnit, + theUnitId, + theSourceOfDefinition, + theSymbol, + theDataType, + theDefinition, + theValueFormat, + theValueList, + theValue, + theLevelType); + } // internal static DataSpecificationIec61360From /// - /// Deserialize an instance of Environment from . + /// Deserialize an instance of DataSpecificationPhysicalUnit from . /// /// JSON node to be parsed /// Error, if any, during the deserialization - internal static Aas.Environment? EnvironmentFrom( + internal static Aas.DataSpecificationPhysicalUnit? DataSpecificationPhysicalUnitFrom( Nodes.JsonNode node, out Reporting.Error? error) { @@ -11199,220 +14525,418 @@ internal static class DeserializeImplementation return null; } - Nodes.JsonNode? nodeAssetAdministrationShells = obj["assetAdministrationShells"]; - List? theAssetAdministrationShells = null; - if (nodeAssetAdministrationShells != null) - { - Nodes.JsonArray? arrayAssetAdministrationShells = nodeAssetAdministrationShells as Nodes.JsonArray; - if (arrayAssetAdministrationShells == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeAssetAdministrationShells.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "assetAdministrationShells")); - return null; - } - theAssetAdministrationShells = new List( - arrayAssetAdministrationShells.Count); - int indexAssetAdministrationShells = 0; - foreach (Nodes.JsonNode? item in arrayAssetAdministrationShells) - { - if (item == null) - { + string? theUnitName = null; + string? theUnitSymbol = null; + List? theDefinition = null; + string? theSiNotation = null; + string? theSiName = null; + string? theDinNotation = null; + string? theEceName = null; + string? theEceCode = null; + string? theNistName = null; + string? theSourceOfDefinition = null; + string? theConversionFactor = null; + string? theRegistrationAuthorityId = null; + string? theSupplier = null; + + foreach (var keyValue in obj) + { + switch (keyValue.Key) + { + case "unitName": + { + if (keyValue.Value == null) + { + continue; + } + + theUnitName = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "unitName")); + return null; + } + if (theUnitName == null) + { + throw new System.InvalidOperationException( + "Unexpected theUnitName null when error is also null"); + } + break; + } + case "unitSymbol": + { + if (keyValue.Value == null) + { + continue; + } + + theUnitSymbol = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "unitSymbol")); + return null; + } + if (theUnitSymbol == null) + { + throw new System.InvalidOperationException( + "Unexpected theUnitSymbol null when error is also null"); + } + break; + } + case "definition": + { + if (keyValue.Value == null) + { + continue; + } + + Nodes.JsonArray? arrayDefinition = keyValue.Value as Nodes.JsonArray; + if (arrayDefinition == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {keyValue.Value.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "definition")); + return null; + } + theDefinition = new List( + arrayDefinition.Count); + int indexDefinition = 0; + foreach (Nodes.JsonNode? item in arrayDefinition) + { + if (item == null) + { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDefinition)); + error.PrependSegment( + new Reporting.NameSegment( + "definition")); + return null; + } + LangString? parsedItem = DeserializeImplementation.LangStringFrom( + item ?? throw new System.InvalidOperationException(), + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDefinition)); + error.PrependSegment( + new Reporting.NameSegment( + "definition")); + return null; + } + theDefinition.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDefinition++; + } + break; + } + case "siNotation": + { + if (keyValue.Value == null) + { + continue; + } + + theSiNotation = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "siNotation")); + return null; + } + if (theSiNotation == null) + { + throw new System.InvalidOperationException( + "Unexpected theSiNotation null when error is also null"); + } + break; + } + case "siName": + { + if (keyValue.Value == null) + { + continue; + } + + theSiName = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "siName")); + return null; + } + if (theSiName == null) + { + throw new System.InvalidOperationException( + "Unexpected theSiName null when error is also null"); + } + break; + } + case "dinNotation": + { + if (keyValue.Value == null) + { + continue; + } + + theDinNotation = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "dinNotation")); + return null; + } + if (theDinNotation == null) + { + throw new System.InvalidOperationException( + "Unexpected theDinNotation null when error is also null"); + } + break; + } + case "eceName": + { + if (keyValue.Value == null) + { + continue; + } + + theEceName = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "eceName")); + return null; + } + if (theEceName == null) + { + throw new System.InvalidOperationException( + "Unexpected theEceName null when error is also null"); + } + break; + } + case "eceCode": + { + if (keyValue.Value == null) + { + continue; + } + + theEceCode = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "eceCode")); + return null; + } + if (theEceCode == null) + { + throw new System.InvalidOperationException( + "Unexpected theEceCode null when error is also null"); + } + break; + } + case "nistName": + { + if (keyValue.Value == null) + { + continue; + } + + theNistName = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "nistName")); + return null; + } + if (theNistName == null) + { + throw new System.InvalidOperationException( + "Unexpected theNistName null when error is also null"); + } + break; + } + case "sourceOfDefinition": + { + if (keyValue.Value == null) + { + continue; + } + + theSourceOfDefinition = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "sourceOfDefinition")); + return null; + } + if (theSourceOfDefinition == null) + { + throw new System.InvalidOperationException( + "Unexpected theSourceOfDefinition null when error is also null"); + } + break; + } + case "conversionFactor": + { + if (keyValue.Value == null) + { + continue; + } + + theConversionFactor = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "conversionFactor")); + return null; + } + if (theConversionFactor == null) + { + throw new System.InvalidOperationException( + "Unexpected theConversionFactor null when error is also null"); + } + break; + } + case "registrationAuthorityId": + { + if (keyValue.Value == null) + { + continue; + } + + theRegistrationAuthorityId = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "registrationAuthorityId")); + return null; + } + if (theRegistrationAuthorityId == null) + { + throw new System.InvalidOperationException( + "Unexpected theRegistrationAuthorityId null when error is also null"); + } + break; + } + case "supplier": + { + if (keyValue.Value == null) + { + continue; + } + + theSupplier = DeserializeImplementation.StringFrom( + keyValue.Value, + out error); + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "supplier")); + return null; + } + if (theSupplier == null) + { + throw new System.InvalidOperationException( + "Unexpected theSupplier null when error is also null"); + } + break; + } + case "modelType": + continue; + default: error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexAssetAdministrationShells)); - error.PrependSegment( - new Reporting.NameSegment( - "assetAdministrationShells")); - return null; - } - AssetAdministrationShell? parsedItem = DeserializeImplementation.AssetAdministrationShellFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexAssetAdministrationShells)); - error.PrependSegment( - new Reporting.NameSegment( - "assetAdministrationShells")); + $"Unexpected property: {keyValue.Key}"); return null; - } - theAssetAdministrationShells.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexAssetAdministrationShells++; } } - Nodes.JsonNode? nodeSubmodels = obj["submodels"]; - List? theSubmodels = null; - if (nodeSubmodels != null) + if (theUnitName == null) { - Nodes.JsonArray? arraySubmodels = nodeSubmodels as Nodes.JsonArray; - if (arraySubmodels == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeSubmodels.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "submodels")); - return null; - } - theSubmodels = new List( - arraySubmodels.Count); - int indexSubmodels = 0; - foreach (Nodes.JsonNode? item in arraySubmodels) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexSubmodels)); - error.PrependSegment( - new Reporting.NameSegment( - "submodels")); - return null; - } - Submodel? parsedItem = DeserializeImplementation.SubmodelFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSubmodels)); - error.PrependSegment( - new Reporting.NameSegment( - "submodels")); - return null; - } - theSubmodels.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexSubmodels++; - } + error = new Reporting.Error( + "Required property \"unitName\" is missing"); + return null; } - Nodes.JsonNode? nodeConceptDescriptions = obj["conceptDescriptions"]; - List? theConceptDescriptions = null; - if (nodeConceptDescriptions != null) + if (theUnitSymbol == null) { - Nodes.JsonArray? arrayConceptDescriptions = nodeConceptDescriptions as Nodes.JsonArray; - if (arrayConceptDescriptions == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeConceptDescriptions.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "conceptDescriptions")); - return null; - } - theConceptDescriptions = new List( - arrayConceptDescriptions.Count); - int indexConceptDescriptions = 0; - foreach (Nodes.JsonNode? item in arrayConceptDescriptions) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexConceptDescriptions)); - error.PrependSegment( - new Reporting.NameSegment( - "conceptDescriptions")); - return null; - } - ConceptDescription? parsedItem = DeserializeImplementation.ConceptDescriptionFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexConceptDescriptions)); - error.PrependSegment( - new Reporting.NameSegment( - "conceptDescriptions")); - return null; - } - theConceptDescriptions.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexConceptDescriptions++; - } + error = new Reporting.Error( + "Required property \"unitSymbol\" is missing"); + return null; } - Nodes.JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) + if (theDefinition == null) { - Nodes.JsonArray? arrayDataSpecifications = nodeDataSpecifications as Nodes.JsonArray; - if (arrayDataSpecifications == null) - { - error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (Nodes.JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - DataSpecification? parsedItem = DeserializeImplementation.DataSpecificationFrom( - item ?? throw new System.InvalidOperationException(), - out error); - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } + error = new Reporting.Error( + "Required property \"definition\" is missing"); + return null; } - return new Aas.Environment( - theAssetAdministrationShells, - theSubmodels, - theConceptDescriptions, - theDataSpecifications); - } // internal static EnvironmentFrom + return new Aas.DataSpecificationPhysicalUnit( + theUnitName + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theUnitSymbol + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theDefinition + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theSiNotation, + theSiName, + theDinNotation, + theEceName, + theEceCode, + theNistName, + theSourceOfDefinition, + theConversionFactor, + theRegistrationAuthorityId, + theSupplier); + } // internal static DataSpecificationPhysicalUnitFrom } // public static class DeserializeImplementation /// @@ -11978,6 +15502,31 @@ public static Aas.RelationshipElement RelationshipElementFrom( "Unexpected output null when error is null"); } + /// + /// Deserialize an instance of AasSubmodelElements from . + /// + /// JSON node to be parsed + /// + /// Thrown when is not a valid JSON + /// representation of AasSubmodelElements. + /// + public static Aas.AasSubmodelElements AasSubmodelElementsFrom( + Nodes.JsonNode node) + { + Aas.AasSubmodelElements? result = DeserializeImplementation.AasSubmodelElementsFrom( + node, + out Reporting.Error? error); + if (error != null) + { + throw new Jsonization.Exception( + Reporting.GenerateJsonPath(error.PathSegments), + error.Cause); + } + return result + ?? throw new System.InvalidOperationException( + "Unexpected output null when error is null"); + } + /// /// Deserialize an instance of SubmodelElementList from . /// @@ -12236,137 +15785,11 @@ public static Aas.AnnotatedRelationshipElement AnnotatedRelationshipElementFrom( /// /// Thrown when is not a valid JSON /// representation of EntityType. - /// - public static Aas.EntityType EntityTypeFrom( - Nodes.JsonNode node) - { - Aas.EntityType? result = DeserializeImplementation.EntityTypeFrom( - node, - out Reporting.Error? error); - if (error != null) - { - throw new Jsonization.Exception( - Reporting.GenerateJsonPath(error.PathSegments), - error.Cause); - } - return result - ?? throw new System.InvalidOperationException( - "Unexpected output null when error is null"); - } - - /// - /// Deserialize an instance of Entity from . - /// - /// JSON node to be parsed - /// - /// Thrown when is not a valid JSON - /// representation of Entity. - /// - public static Aas.Entity EntityFrom( - Nodes.JsonNode node) - { - Aas.Entity? result = DeserializeImplementation.EntityFrom( - node, - out Reporting.Error? error); - if (error != null) - { - throw new Jsonization.Exception( - Reporting.GenerateJsonPath(error.PathSegments), - error.Cause); - } - return result - ?? throw new System.InvalidOperationException( - "Unexpected output null when error is null"); - } - - /// - /// Deserialize an instance of Direction from . - /// - /// JSON node to be parsed - /// - /// Thrown when is not a valid JSON - /// representation of Direction. - /// - public static Aas.Direction DirectionFrom( - Nodes.JsonNode node) - { - Aas.Direction? result = DeserializeImplementation.DirectionFrom( - node, - out Reporting.Error? error); - if (error != null) - { - throw new Jsonization.Exception( - Reporting.GenerateJsonPath(error.PathSegments), - error.Cause); - } - return result - ?? throw new System.InvalidOperationException( - "Unexpected output null when error is null"); - } - - /// - /// Deserialize an instance of StateOfEvent from . - /// - /// JSON node to be parsed - /// - /// Thrown when is not a valid JSON - /// representation of StateOfEvent. - /// - public static Aas.StateOfEvent StateOfEventFrom( - Nodes.JsonNode node) - { - Aas.StateOfEvent? result = DeserializeImplementation.StateOfEventFrom( - node, - out Reporting.Error? error); - if (error != null) - { - throw new Jsonization.Exception( - Reporting.GenerateJsonPath(error.PathSegments), - error.Cause); - } - return result - ?? throw new System.InvalidOperationException( - "Unexpected output null when error is null"); - } - - /// - /// Deserialize an instance of EventPayload from . - /// - /// JSON node to be parsed - /// - /// Thrown when is not a valid JSON - /// representation of EventPayload. - /// - public static Aas.EventPayload EventPayloadFrom( - Nodes.JsonNode node) - { - Aas.EventPayload? result = DeserializeImplementation.EventPayloadFrom( - node, - out Reporting.Error? error); - if (error != null) - { - throw new Jsonization.Exception( - Reporting.GenerateJsonPath(error.PathSegments), - error.Cause); - } - return result - ?? throw new System.InvalidOperationException( - "Unexpected output null when error is null"); - } - - /// - /// Deserialize an instance of IEventElement from . - /// - /// JSON node to be parsed - /// - /// Thrown when is not a valid JSON - /// representation of IEventElement. - /// - [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - public static Aas.IEventElement IEventElementFrom( + /// + public static Aas.EntityType EntityTypeFrom( Nodes.JsonNode node) { - Aas.IEventElement? result = DeserializeImplementation.IEventElementFrom( + Aas.EntityType? result = DeserializeImplementation.EntityTypeFrom( node, out Reporting.Error? error); if (error != null) @@ -12381,17 +15804,17 @@ public static Aas.IEventElement IEventElementFrom( } /// - /// Deserialize an instance of BasicEventElement from . + /// Deserialize an instance of Entity from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of BasicEventElement. + /// representation of Entity. /// - public static Aas.BasicEventElement BasicEventElementFrom( + public static Aas.Entity EntityFrom( Nodes.JsonNode node) { - Aas.BasicEventElement? result = DeserializeImplementation.BasicEventElementFrom( + Aas.Entity? result = DeserializeImplementation.EntityFrom( node, out Reporting.Error? error); if (error != null) @@ -12406,17 +15829,17 @@ public static Aas.BasicEventElement BasicEventElementFrom( } /// - /// Deserialize an instance of Operation from . + /// Deserialize an instance of Direction from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of Operation. + /// representation of Direction. /// - public static Aas.Operation OperationFrom( + public static Aas.Direction DirectionFrom( Nodes.JsonNode node) { - Aas.Operation? result = DeserializeImplementation.OperationFrom( + Aas.Direction? result = DeserializeImplementation.DirectionFrom( node, out Reporting.Error? error); if (error != null) @@ -12431,17 +15854,17 @@ public static Aas.Operation OperationFrom( } /// - /// Deserialize an instance of OperationVariable from . + /// Deserialize an instance of StateOfEvent from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of OperationVariable. + /// representation of StateOfEvent. /// - public static Aas.OperationVariable OperationVariableFrom( + public static Aas.StateOfEvent StateOfEventFrom( Nodes.JsonNode node) { - Aas.OperationVariable? result = DeserializeImplementation.OperationVariableFrom( + Aas.StateOfEvent? result = DeserializeImplementation.StateOfEventFrom( node, out Reporting.Error? error); if (error != null) @@ -12456,17 +15879,17 @@ public static Aas.OperationVariable OperationVariableFrom( } /// - /// Deserialize an instance of Capability from . + /// Deserialize an instance of EventPayload from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of Capability. + /// representation of EventPayload. /// - public static Aas.Capability CapabilityFrom( + public static Aas.EventPayload EventPayloadFrom( Nodes.JsonNode node) { - Aas.Capability? result = DeserializeImplementation.CapabilityFrom( + Aas.EventPayload? result = DeserializeImplementation.EventPayloadFrom( node, out Reporting.Error? error); if (error != null) @@ -12481,17 +15904,18 @@ public static Aas.Capability CapabilityFrom( } /// - /// Deserialize an instance of ConceptDescription from . + /// Deserialize an instance of IEventElement from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of ConceptDescription. + /// representation of IEventElement. /// - public static Aas.ConceptDescription ConceptDescriptionFrom( + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static Aas.IEventElement IEventElementFrom( Nodes.JsonNode node) { - Aas.ConceptDescription? result = DeserializeImplementation.ConceptDescriptionFrom( + Aas.IEventElement? result = DeserializeImplementation.IEventElementFrom( node, out Reporting.Error? error); if (error != null) @@ -12506,17 +15930,17 @@ public static Aas.ConceptDescription ConceptDescriptionFrom( } /// - /// Deserialize an instance of ReferenceTypes from . + /// Deserialize an instance of BasicEventElement from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of ReferenceTypes. + /// representation of BasicEventElement. /// - public static Aas.ReferenceTypes ReferenceTypesFrom( + public static Aas.BasicEventElement BasicEventElementFrom( Nodes.JsonNode node) { - Aas.ReferenceTypes? result = DeserializeImplementation.ReferenceTypesFrom( + Aas.BasicEventElement? result = DeserializeImplementation.BasicEventElementFrom( node, out Reporting.Error? error); if (error != null) @@ -12531,17 +15955,17 @@ public static Aas.ReferenceTypes ReferenceTypesFrom( } /// - /// Deserialize an instance of Reference from . + /// Deserialize an instance of Operation from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of Reference. + /// representation of Operation. /// - public static Aas.Reference ReferenceFrom( + public static Aas.Operation OperationFrom( Nodes.JsonNode node) { - Aas.Reference? result = DeserializeImplementation.ReferenceFrom( + Aas.Operation? result = DeserializeImplementation.OperationFrom( node, out Reporting.Error? error); if (error != null) @@ -12556,17 +15980,17 @@ public static Aas.Reference ReferenceFrom( } /// - /// Deserialize an instance of Key from . + /// Deserialize an instance of OperationVariable from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of Key. + /// representation of OperationVariable. /// - public static Aas.Key KeyFrom( + public static Aas.OperationVariable OperationVariableFrom( Nodes.JsonNode node) { - Aas.Key? result = DeserializeImplementation.KeyFrom( + Aas.OperationVariable? result = DeserializeImplementation.OperationVariableFrom( node, out Reporting.Error? error); if (error != null) @@ -12581,17 +16005,17 @@ public static Aas.Key KeyFrom( } /// - /// Deserialize an instance of GenericFragmentKeys from . + /// Deserialize an instance of Capability from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of GenericFragmentKeys. + /// representation of Capability. /// - public static Aas.GenericFragmentKeys GenericFragmentKeysFrom( + public static Aas.Capability CapabilityFrom( Nodes.JsonNode node) { - Aas.GenericFragmentKeys? result = DeserializeImplementation.GenericFragmentKeysFrom( + Aas.Capability? result = DeserializeImplementation.CapabilityFrom( node, out Reporting.Error? error); if (error != null) @@ -12606,17 +16030,17 @@ public static Aas.GenericFragmentKeys GenericFragmentKeysFrom( } /// - /// Deserialize an instance of GenericGloballyIdentifiables from . + /// Deserialize an instance of ConceptDescription from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of GenericGloballyIdentifiables. + /// representation of ConceptDescription. /// - public static Aas.GenericGloballyIdentifiables GenericGloballyIdentifiablesFrom( + public static Aas.ConceptDescription ConceptDescriptionFrom( Nodes.JsonNode node) { - Aas.GenericGloballyIdentifiables? result = DeserializeImplementation.GenericGloballyIdentifiablesFrom( + Aas.ConceptDescription? result = DeserializeImplementation.ConceptDescriptionFrom( node, out Reporting.Error? error); if (error != null) @@ -12631,17 +16055,17 @@ public static Aas.GenericGloballyIdentifiables GenericGloballyIdentifiablesFrom( } /// - /// Deserialize an instance of AasIdentifiables from . + /// Deserialize an instance of ReferenceTypes from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of AasIdentifiables. + /// representation of ReferenceTypes. /// - public static Aas.AasIdentifiables AasIdentifiablesFrom( + public static Aas.ReferenceTypes ReferenceTypesFrom( Nodes.JsonNode node) { - Aas.AasIdentifiables? result = DeserializeImplementation.AasIdentifiablesFrom( + Aas.ReferenceTypes? result = DeserializeImplementation.ReferenceTypesFrom( node, out Reporting.Error? error); if (error != null) @@ -12656,17 +16080,17 @@ public static Aas.AasIdentifiables AasIdentifiablesFrom( } /// - /// Deserialize an instance of AasSubmodelElements from . + /// Deserialize an instance of Reference from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of AasSubmodelElements. + /// representation of Reference. /// - public static Aas.AasSubmodelElements AasSubmodelElementsFrom( + public static Aas.Reference ReferenceFrom( Nodes.JsonNode node) { - Aas.AasSubmodelElements? result = DeserializeImplementation.AasSubmodelElementsFrom( + Aas.Reference? result = DeserializeImplementation.ReferenceFrom( node, out Reporting.Error? error); if (error != null) @@ -12681,17 +16105,17 @@ public static Aas.AasSubmodelElements AasSubmodelElementsFrom( } /// - /// Deserialize an instance of AasReferableNonIdentifiables from . + /// Deserialize an instance of Key from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of AasReferableNonIdentifiables. + /// representation of Key. /// - public static Aas.AasReferableNonIdentifiables AasReferableNonIdentifiablesFrom( + public static Aas.Key KeyFrom( Nodes.JsonNode node) { - Aas.AasReferableNonIdentifiables? result = DeserializeImplementation.AasReferableNonIdentifiablesFrom( + Aas.Key? result = DeserializeImplementation.KeyFrom( node, out Reporting.Error? error); if (error != null) @@ -12706,17 +16130,17 @@ public static Aas.AasReferableNonIdentifiables AasReferableNonIdentifiablesFrom( } /// - /// Deserialize an instance of AasReferables from . + /// Deserialize an instance of KeyTypes from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of AasReferables. + /// representation of KeyTypes. /// - public static Aas.AasReferables AasReferablesFrom( + public static Aas.KeyTypes KeyTypesFrom( Nodes.JsonNode node) { - Aas.AasReferables? result = DeserializeImplementation.AasReferablesFrom( + Aas.KeyTypes? result = DeserializeImplementation.KeyTypesFrom( node, out Reporting.Error? error); if (error != null) @@ -12731,17 +16155,17 @@ public static Aas.AasReferables AasReferablesFrom( } /// - /// Deserialize an instance of GloballyIdentifiables from . + /// Deserialize an instance of DataTypeDefXsd from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of GloballyIdentifiables. + /// representation of DataTypeDefXsd. /// - public static Aas.GloballyIdentifiables GloballyIdentifiablesFrom( + public static Aas.DataTypeDefXsd DataTypeDefXsdFrom( Nodes.JsonNode node) { - Aas.GloballyIdentifiables? result = DeserializeImplementation.GloballyIdentifiablesFrom( + Aas.DataTypeDefXsd? result = DeserializeImplementation.DataTypeDefXsdFrom( node, out Reporting.Error? error); if (error != null) @@ -12756,17 +16180,17 @@ public static Aas.GloballyIdentifiables GloballyIdentifiablesFrom( } /// - /// Deserialize an instance of FragmentKeys from . + /// Deserialize an instance of LangString from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of FragmentKeys. + /// representation of LangString. /// - public static Aas.FragmentKeys FragmentKeysFrom( + public static Aas.LangString LangStringFrom( Nodes.JsonNode node) { - Aas.FragmentKeys? result = DeserializeImplementation.FragmentKeysFrom( + Aas.LangString? result = DeserializeImplementation.LangStringFrom( node, out Reporting.Error? error); if (error != null) @@ -12781,17 +16205,17 @@ public static Aas.FragmentKeys FragmentKeysFrom( } /// - /// Deserialize an instance of KeyTypes from . + /// Deserialize an instance of Environment from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of KeyTypes. + /// representation of Environment. /// - public static Aas.KeyTypes KeyTypesFrom( + public static Aas.Environment EnvironmentFrom( Nodes.JsonNode node) { - Aas.KeyTypes? result = DeserializeImplementation.KeyTypesFrom( + Aas.Environment? result = DeserializeImplementation.EnvironmentFrom( node, out Reporting.Error? error); if (error != null) @@ -12806,17 +16230,18 @@ public static Aas.KeyTypes KeyTypesFrom( } /// - /// Deserialize an instance of DataTypeDefXsd from . + /// Deserialize an instance of IDataSpecificationContent from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of DataTypeDefXsd. + /// representation of IDataSpecificationContent. /// - public static Aas.DataTypeDefXsd DataTypeDefXsdFrom( + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static Aas.IDataSpecificationContent IDataSpecificationContentFrom( Nodes.JsonNode node) { - Aas.DataTypeDefXsd? result = DeserializeImplementation.DataTypeDefXsdFrom( + Aas.IDataSpecificationContent? result = DeserializeImplementation.IDataSpecificationContentFrom( node, out Reporting.Error? error); if (error != null) @@ -12831,17 +16256,17 @@ public static Aas.DataTypeDefXsd DataTypeDefXsdFrom( } /// - /// Deserialize an instance of DataTypeDefRdf from . + /// Deserialize an instance of EmbeddedDataSpecification from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of DataTypeDefRdf. + /// representation of EmbeddedDataSpecification. /// - public static Aas.DataTypeDefRdf DataTypeDefRdfFrom( + public static Aas.EmbeddedDataSpecification EmbeddedDataSpecificationFrom( Nodes.JsonNode node) { - Aas.DataTypeDefRdf? result = DeserializeImplementation.DataTypeDefRdfFrom( + Aas.EmbeddedDataSpecification? result = DeserializeImplementation.EmbeddedDataSpecificationFrom( node, out Reporting.Error? error); if (error != null) @@ -12856,17 +16281,17 @@ public static Aas.DataTypeDefRdf DataTypeDefRdfFrom( } /// - /// Deserialize an instance of DataTypeDef from . + /// Deserialize an instance of DataTypeIec61360 from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of DataTypeDef. + /// representation of DataTypeIec61360. /// - public static Aas.DataTypeDef DataTypeDefFrom( + public static Aas.DataTypeIec61360 DataTypeIec61360From( Nodes.JsonNode node) { - Aas.DataTypeDef? result = DeserializeImplementation.DataTypeDefFrom( + Aas.DataTypeIec61360? result = DeserializeImplementation.DataTypeIec61360From( node, out Reporting.Error? error); if (error != null) @@ -12881,17 +16306,17 @@ public static Aas.DataTypeDef DataTypeDefFrom( } /// - /// Deserialize an instance of LangString from . + /// Deserialize an instance of LevelType from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of LangString. + /// representation of LevelType. /// - public static Aas.LangString LangStringFrom( + public static Aas.LevelType LevelTypeFrom( Nodes.JsonNode node) { - Aas.LangString? result = DeserializeImplementation.LangStringFrom( + Aas.LevelType? result = DeserializeImplementation.LevelTypeFrom( node, out Reporting.Error? error); if (error != null) @@ -12906,17 +16331,17 @@ public static Aas.LangString LangStringFrom( } /// - /// Deserialize an instance of LangStringSet from . + /// Deserialize an instance of ValueReferencePair from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of LangStringSet. + /// representation of ValueReferencePair. /// - public static Aas.LangStringSet LangStringSetFrom( + public static Aas.ValueReferencePair ValueReferencePairFrom( Nodes.JsonNode node) { - Aas.LangStringSet? result = DeserializeImplementation.LangStringSetFrom( + Aas.ValueReferencePair? result = DeserializeImplementation.ValueReferencePairFrom( node, out Reporting.Error? error); if (error != null) @@ -12931,17 +16356,17 @@ public static Aas.LangStringSet LangStringSetFrom( } /// - /// Deserialize an instance of DataSpecificationContent from . + /// Deserialize an instance of ValueList from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of DataSpecificationContent. + /// representation of ValueList. /// - public static Aas.DataSpecificationContent DataSpecificationContentFrom( + public static Aas.ValueList ValueListFrom( Nodes.JsonNode node) { - Aas.DataSpecificationContent? result = DeserializeImplementation.DataSpecificationContentFrom( + Aas.ValueList? result = DeserializeImplementation.ValueListFrom( node, out Reporting.Error? error); if (error != null) @@ -12956,17 +16381,17 @@ public static Aas.DataSpecificationContent DataSpecificationContentFrom( } /// - /// Deserialize an instance of DataSpecification from . + /// Deserialize an instance of DataSpecificationIec61360 from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of DataSpecification. + /// representation of DataSpecificationIec61360. /// - public static Aas.DataSpecification DataSpecificationFrom( + public static Aas.DataSpecificationIec61360 DataSpecificationIec61360From( Nodes.JsonNode node) { - Aas.DataSpecification? result = DeserializeImplementation.DataSpecificationFrom( + Aas.DataSpecificationIec61360? result = DeserializeImplementation.DataSpecificationIec61360From( node, out Reporting.Error? error); if (error != null) @@ -12981,17 +16406,17 @@ public static Aas.DataSpecification DataSpecificationFrom( } /// - /// Deserialize an instance of Environment from . + /// Deserialize an instance of DataSpecificationPhysicalUnit from . /// /// JSON node to be parsed /// /// Thrown when is not a valid JSON - /// representation of Environment. + /// representation of DataSpecificationPhysicalUnit. /// - public static Aas.Environment EnvironmentFrom( + public static Aas.DataSpecificationPhysicalUnit DataSpecificationPhysicalUnitFrom( Nodes.JsonNode node) { - Aas.Environment? result = DeserializeImplementation.EnvironmentFrom( + Aas.DataSpecificationPhysicalUnit? result = DeserializeImplementation.DataSpecificationPhysicalUnitFrom( node, out Reporting.Error? error); if (error != null) @@ -13082,16 +16507,16 @@ public override Nodes.JsonObject Transform(Aas.AdministrativeInformation that) { var result = new Nodes.JsonObject(); - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Version != null) @@ -13191,14 +16616,26 @@ public override Nodes.JsonObject Transform(Aas.AssetAdministrationShell that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -13216,16 +16653,16 @@ public override Nodes.JsonObject Transform(Aas.AssetAdministrationShell that) result["id"] = Nodes.JsonValue.Create( that.Id); - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.DerivedFrom != null) @@ -13368,14 +16805,26 @@ public override Nodes.JsonObject Transform(Aas.Submodel that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -13432,16 +16881,16 @@ public override Nodes.JsonObject Transform(Aas.Submodel that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.SubmodelElements != null) @@ -13491,14 +16940,26 @@ public override Nodes.JsonObject Transform(Aas.RelationshipElement that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -13546,16 +17007,16 @@ public override Nodes.JsonObject Transform(Aas.RelationshipElement that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["first"] = Transform( @@ -13599,14 +17060,26 @@ public override Nodes.JsonObject Transform(Aas.SubmodelElementList that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -13654,16 +17127,16 @@ public override Nodes.JsonObject Transform(Aas.SubmodelElementList that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.OrderRelevant != null) @@ -13737,14 +17210,26 @@ public override Nodes.JsonObject Transform(Aas.SubmodelElementCollection that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -13792,16 +17277,16 @@ public override Nodes.JsonObject Transform(Aas.SubmodelElementCollection that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Value != null) @@ -13851,14 +17336,26 @@ public override Nodes.JsonObject Transform(Aas.Property that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -13906,16 +17403,16 @@ public override Nodes.JsonObject Transform(Aas.Property that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["valueType"] = Serialize.DataTypeDefXsdToJsonValue( @@ -13968,14 +17465,26 @@ public override Nodes.JsonObject Transform(Aas.MultiLanguageProperty that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -14023,22 +17532,28 @@ public override Nodes.JsonObject Transform(Aas.MultiLanguageProperty that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Value != null) { - result["value"] = Transform( - that.Value); + var arrayValue = new Nodes.JsonArray(); + foreach (LangString item in that.Value) + { + arrayValue.Add( + Transform( + item)); + } + result["value"] = arrayValue; } if (that.ValueId != null) @@ -14082,14 +17597,26 @@ public override Nodes.JsonObject Transform(Aas.Range that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -14137,16 +17664,16 @@ public override Nodes.JsonObject Transform(Aas.Range that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["valueType"] = Serialize.DataTypeDefXsdToJsonValue( @@ -14199,14 +17726,26 @@ public override Nodes.JsonObject Transform(Aas.ReferenceElement that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -14254,16 +17793,16 @@ public override Nodes.JsonObject Transform(Aas.ReferenceElement that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Value != null) @@ -14307,14 +17846,26 @@ public override Nodes.JsonObject Transform(Aas.Blob that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -14362,16 +17913,16 @@ public override Nodes.JsonObject Transform(Aas.Blob that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Value != null) @@ -14419,14 +17970,26 @@ public override Nodes.JsonObject Transform(Aas.File that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -14474,16 +18037,16 @@ public override Nodes.JsonObject Transform(Aas.File that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Value != null) @@ -14530,14 +18093,26 @@ public override Nodes.JsonObject Transform(Aas.AnnotatedRelationshipElement that if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -14585,16 +18160,16 @@ public override Nodes.JsonObject Transform(Aas.AnnotatedRelationshipElement that result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["first"] = Transform( @@ -14650,14 +18225,26 @@ public override Nodes.JsonObject Transform(Aas.Entity that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -14705,16 +18292,16 @@ public override Nodes.JsonObject Transform(Aas.Entity that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Statements != null) @@ -14825,14 +18412,26 @@ public override Nodes.JsonObject Transform(Aas.BasicEventElement that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -14880,16 +18479,16 @@ public override Nodes.JsonObject Transform(Aas.BasicEventElement that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["observed"] = Transform( @@ -14966,14 +18565,26 @@ public override Nodes.JsonObject Transform(Aas.Operation that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -15021,16 +18632,16 @@ public override Nodes.JsonObject Transform(Aas.Operation that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.InputVariables != null) @@ -15114,14 +18725,26 @@ public override Nodes.JsonObject Transform(Aas.Capability that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -15169,16 +18792,16 @@ public override Nodes.JsonObject Transform(Aas.Capability that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["modelType"] = "Capability"; @@ -15216,14 +18839,26 @@ public override Nodes.JsonObject Transform(Aas.ConceptDescription that) if (that.DisplayName != null) { - result["displayName"] = Transform( - that.DisplayName); + var arrayDisplayName = new Nodes.JsonArray(); + foreach (LangString item in that.DisplayName) + { + arrayDisplayName.Add( + Transform( + item)); + } + result["displayName"] = arrayDisplayName; } if (that.Description != null) { - result["description"] = Transform( - that.Description); + var arrayDescription = new Nodes.JsonArray(); + foreach (LangString item in that.Description) + { + arrayDescription.Add( + Transform( + item)); + } + result["description"] = arrayDescription; } if (that.Checksum != null) @@ -15241,16 +18876,16 @@ public override Nodes.JsonObject Transform(Aas.ConceptDescription that) result["id"] = Nodes.JsonValue.Create( that.Id); - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.IsCaseOf != null) @@ -15321,106 +18956,274 @@ public override Nodes.JsonObject Transform(Aas.LangString that) return result; } - public override Nodes.JsonObject Transform(Aas.LangStringSet that) + public override Nodes.JsonObject Transform(Aas.Environment that) { var result = new Nodes.JsonObject(); - var arrayLangStrings = new Nodes.JsonArray(); - foreach (LangString item in that.LangStrings) + if (that.AssetAdministrationShells != null) { - arrayLangStrings.Add( - Transform( - item)); + var arrayAssetAdministrationShells = new Nodes.JsonArray(); + foreach (AssetAdministrationShell item in that.AssetAdministrationShells) + { + arrayAssetAdministrationShells.Add( + Transform( + item)); + } + result["assetAdministrationShells"] = arrayAssetAdministrationShells; + } + + if (that.Submodels != null) + { + var arraySubmodels = new Nodes.JsonArray(); + foreach (Submodel item in that.Submodels) + { + arraySubmodels.Add( + Transform( + item)); + } + result["submodels"] = arraySubmodels; + } + + if (that.ConceptDescriptions != null) + { + var arrayConceptDescriptions = new Nodes.JsonArray(); + foreach (ConceptDescription item in that.ConceptDescriptions) + { + arrayConceptDescriptions.Add( + Transform( + item)); + } + result["conceptDescriptions"] = arrayConceptDescriptions; } - result["langStrings"] = arrayLangStrings; return result; } - public override Nodes.JsonObject Transform(Aas.DataSpecificationContent that) + public override Nodes.JsonObject Transform(Aas.EmbeddedDataSpecification that) { var result = new Nodes.JsonObject(); + result["dataSpecification"] = Transform( + that.DataSpecification); + + result["dataSpecificationContent"] = Transform( + that.DataSpecificationContent); + return result; } - public override Nodes.JsonObject Transform(Aas.DataSpecification that) + public override Nodes.JsonObject Transform(Aas.ValueReferencePair that) { var result = new Nodes.JsonObject(); - result["id"] = Nodes.JsonValue.Create( - that.Id); + result["value"] = Nodes.JsonValue.Create( + that.Value); - result["dataSpecificationContent"] = Transform( - that.DataSpecificationContent); + result["valueId"] = Transform( + that.ValueId); - if (that.Administration != null) - { - result["administration"] = Transform( - that.Administration); - } + return result; + } - if (that.Description != null) + public override Nodes.JsonObject Transform(Aas.ValueList that) + { + var result = new Nodes.JsonObject(); + + var arrayValueReferencePairs = new Nodes.JsonArray(); + foreach (ValueReferencePair item in that.ValueReferencePairs) { - result["description"] = Transform( - that.Description); + arrayValueReferencePairs.Add( + Transform( + item)); } + result["valueReferencePairs"] = arrayValueReferencePairs; return result; } - public override Nodes.JsonObject Transform(Aas.Environment that) + public override Nodes.JsonObject Transform(Aas.DataSpecificationIec61360 that) { var result = new Nodes.JsonObject(); - if (that.AssetAdministrationShells != null) + var arrayPreferredName = new Nodes.JsonArray(); + foreach (LangString item in that.PreferredName) { - var arrayAssetAdministrationShells = new Nodes.JsonArray(); - foreach (AssetAdministrationShell item in that.AssetAdministrationShells) - { - arrayAssetAdministrationShells.Add( - Transform( - item)); - } - result["assetAdministrationShells"] = arrayAssetAdministrationShells; + arrayPreferredName.Add( + Transform( + item)); } + result["preferredName"] = arrayPreferredName; - if (that.Submodels != null) + if (that.ShortName != null) { - var arraySubmodels = new Nodes.JsonArray(); - foreach (Submodel item in that.Submodels) + var arrayShortName = new Nodes.JsonArray(); + foreach (LangString item in that.ShortName) { - arraySubmodels.Add( + arrayShortName.Add( Transform( item)); } - result["submodels"] = arraySubmodels; + result["shortName"] = arrayShortName; } - if (that.ConceptDescriptions != null) + if (that.Unit != null) { - var arrayConceptDescriptions = new Nodes.JsonArray(); - foreach (ConceptDescription item in that.ConceptDescriptions) - { - arrayConceptDescriptions.Add( - Transform( - item)); - } - result["conceptDescriptions"] = arrayConceptDescriptions; + result["unit"] = Nodes.JsonValue.Create( + that.Unit); + } + + if (that.UnitId != null) + { + result["unitId"] = Transform( + that.UnitId); + } + + if (that.SourceOfDefinition != null) + { + result["sourceOfDefinition"] = Nodes.JsonValue.Create( + that.SourceOfDefinition); + } + + if (that.Symbol != null) + { + result["symbol"] = Nodes.JsonValue.Create( + that.Symbol); + } + + if (that.DataType != null) + { + // We need to help the static analyzer with a null coalescing. + Aas.DataTypeIec61360 value = that.DataType + ?? throw new System.InvalidOperationException(); + result["dataType"] = Serialize.DataTypeIec61360ToJsonValue( + value); } - if (that.DataSpecifications != null) + if (that.Definition != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (DataSpecification item in that.DataSpecifications) + var arrayDefinition = new Nodes.JsonArray(); + foreach (LangString item in that.Definition) { - arrayDataSpecifications.Add( + arrayDefinition.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["definition"] = arrayDefinition; + } + + if (that.ValueFormat != null) + { + result["valueFormat"] = Nodes.JsonValue.Create( + that.ValueFormat); + } + + if (that.ValueList != null) + { + result["valueList"] = Transform( + that.ValueList); + } + + if (that.Value != null) + { + result["value"] = Nodes.JsonValue.Create( + that.Value); + } + + if (that.LevelType != null) + { + // We need to help the static analyzer with a null coalescing. + Aas.LevelType value = that.LevelType + ?? throw new System.InvalidOperationException(); + result["levelType"] = Serialize.LevelTypeToJsonValue( + value); + } + + result["modelType"] = "DataSpecificationIEC61360"; + + return result; + } + + public override Nodes.JsonObject Transform(Aas.DataSpecificationPhysicalUnit that) + { + var result = new Nodes.JsonObject(); + + result["unitName"] = Nodes.JsonValue.Create( + that.UnitName); + + result["unitSymbol"] = Nodes.JsonValue.Create( + that.UnitSymbol); + + var arrayDefinition = new Nodes.JsonArray(); + foreach (LangString item in that.Definition) + { + arrayDefinition.Add( + Transform( + item)); + } + result["definition"] = arrayDefinition; + + if (that.SiNotation != null) + { + result["siNotation"] = Nodes.JsonValue.Create( + that.SiNotation); + } + + if (that.SiName != null) + { + result["siName"] = Nodes.JsonValue.Create( + that.SiName); + } + + if (that.DinNotation != null) + { + result["dinNotation"] = Nodes.JsonValue.Create( + that.DinNotation); + } + + if (that.EceName != null) + { + result["eceName"] = Nodes.JsonValue.Create( + that.EceName); + } + + if (that.EceCode != null) + { + result["eceCode"] = Nodes.JsonValue.Create( + that.EceCode); + } + + if (that.NistName != null) + { + result["nistName"] = Nodes.JsonValue.Create( + that.NistName); + } + + if (that.SourceOfDefinition != null) + { + result["sourceOfDefinition"] = Nodes.JsonValue.Create( + that.SourceOfDefinition); + } + + if (that.ConversionFactor != null) + { + result["conversionFactor"] = Nodes.JsonValue.Create( + that.ConversionFactor); + } + + if (that.RegistrationAuthorityId != null) + { + result["registrationAuthorityId"] = Nodes.JsonValue.Create( + that.RegistrationAuthorityId); + } + + if (that.Supplier != null) + { + result["supplier"] = Nodes.JsonValue.Create( + that.Supplier); } + result["modelType"] = "DataSpecificationPhysicalUnit"; + return result; } } // internal class Transformer @@ -15484,6 +19287,17 @@ public static Nodes.JsonValue AssetKindToJsonValue(Aas.AssetKind that) $"Invalid AssetKind: {that}"); } + /// + /// Serialize a literal of AasSubmodelElements into a JSON string. + /// + public static Nodes.JsonValue AasSubmodelElementsToJsonValue(Aas.AasSubmodelElements that) + { + string? text = Stringification.ToString(that); + return Nodes.JsonValue.Create(text) + ?? throw new System.ArgumentException( + $"Invalid AasSubmodelElements: {that}"); + } + /// /// Serialize a literal of EntityType into a JSON string. /// @@ -15528,94 +19342,6 @@ public static Nodes.JsonValue ReferenceTypesToJsonValue(Aas.ReferenceTypes that) $"Invalid ReferenceTypes: {that}"); } - /// - /// Serialize a literal of GenericFragmentKeys into a JSON string. - /// - public static Nodes.JsonValue GenericFragmentKeysToJsonValue(Aas.GenericFragmentKeys that) - { - string? text = Stringification.ToString(that); - return Nodes.JsonValue.Create(text) - ?? throw new System.ArgumentException( - $"Invalid GenericFragmentKeys: {that}"); - } - - /// - /// Serialize a literal of GenericGloballyIdentifiables into a JSON string. - /// - public static Nodes.JsonValue GenericGloballyIdentifiablesToJsonValue(Aas.GenericGloballyIdentifiables that) - { - string? text = Stringification.ToString(that); - return Nodes.JsonValue.Create(text) - ?? throw new System.ArgumentException( - $"Invalid GenericGloballyIdentifiables: {that}"); - } - - /// - /// Serialize a literal of AasIdentifiables into a JSON string. - /// - public static Nodes.JsonValue AasIdentifiablesToJsonValue(Aas.AasIdentifiables that) - { - string? text = Stringification.ToString(that); - return Nodes.JsonValue.Create(text) - ?? throw new System.ArgumentException( - $"Invalid AasIdentifiables: {that}"); - } - - /// - /// Serialize a literal of AasSubmodelElements into a JSON string. - /// - public static Nodes.JsonValue AasSubmodelElementsToJsonValue(Aas.AasSubmodelElements that) - { - string? text = Stringification.ToString(that); - return Nodes.JsonValue.Create(text) - ?? throw new System.ArgumentException( - $"Invalid AasSubmodelElements: {that}"); - } - - /// - /// Serialize a literal of AasReferableNonIdentifiables into a JSON string. - /// - public static Nodes.JsonValue AasReferableNonIdentifiablesToJsonValue(Aas.AasReferableNonIdentifiables that) - { - string? text = Stringification.ToString(that); - return Nodes.JsonValue.Create(text) - ?? throw new System.ArgumentException( - $"Invalid AasReferableNonIdentifiables: {that}"); - } - - /// - /// Serialize a literal of AasReferables into a JSON string. - /// - public static Nodes.JsonValue AasReferablesToJsonValue(Aas.AasReferables that) - { - string? text = Stringification.ToString(that); - return Nodes.JsonValue.Create(text) - ?? throw new System.ArgumentException( - $"Invalid AasReferables: {that}"); - } - - /// - /// Serialize a literal of GloballyIdentifiables into a JSON string. - /// - public static Nodes.JsonValue GloballyIdentifiablesToJsonValue(Aas.GloballyIdentifiables that) - { - string? text = Stringification.ToString(that); - return Nodes.JsonValue.Create(text) - ?? throw new System.ArgumentException( - $"Invalid GloballyIdentifiables: {that}"); - } - - /// - /// Serialize a literal of FragmentKeys into a JSON string. - /// - public static Nodes.JsonValue FragmentKeysToJsonValue(Aas.FragmentKeys that) - { - string? text = Stringification.ToString(that); - return Nodes.JsonValue.Create(text) - ?? throw new System.ArgumentException( - $"Invalid FragmentKeys: {that}"); - } - /// /// Serialize a literal of KeyTypes into a JSON string. /// @@ -15639,25 +19365,25 @@ public static Nodes.JsonValue DataTypeDefXsdToJsonValue(Aas.DataTypeDefXsd that) } /// - /// Serialize a literal of DataTypeDefRdf into a JSON string. + /// Serialize a literal of DataTypeIec61360 into a JSON string. /// - public static Nodes.JsonValue DataTypeDefRdfToJsonValue(Aas.DataTypeDefRdf that) + public static Nodes.JsonValue DataTypeIec61360ToJsonValue(Aas.DataTypeIec61360 that) { string? text = Stringification.ToString(that); return Nodes.JsonValue.Create(text) ?? throw new System.ArgumentException( - $"Invalid DataTypeDefRdf: {that}"); + $"Invalid DataTypeIec61360: {that}"); } /// - /// Serialize a literal of DataTypeDef into a JSON string. + /// Serialize a literal of LevelType into a JSON string. /// - public static Nodes.JsonValue DataTypeDefToJsonValue(Aas.DataTypeDef that) + public static Nodes.JsonValue LevelTypeToJsonValue(Aas.LevelType that) { string? text = Stringification.ToString(that); return Nodes.JsonValue.Create(text) ?? throw new System.ArgumentException( - $"Invalid DataTypeDef: {that}"); + $"Invalid LevelType: {that}"); } } // public static class Serialize } // public static class Jsonization diff --git a/src/AasxServer.DomainModelV3_0_RC02/reporting.cs b/src/AasxServer.DomainModelV3_0_RC02/reporting.cs index b71e0e1c0..64d69b510 100644 --- a/src/AasxServer.DomainModelV3_0_RC02/reporting.cs +++ b/src/AasxServer.DomainModelV3_0_RC02/reporting.cs @@ -3,10 +3,10 @@ * Do NOT edit or append. */ +using Aas = AasCore.Aas3_0_RC02; // renamed using CodeAnalysis = System.Diagnostics.CodeAnalysis; -using System.Collections.Generic; // can't alias -using Aas = AasCore.Aas3_0_RC02; +using System.Collections.Generic; // can't alias namespace AasCore.Aas3_0_RC02 { @@ -94,9 +94,9 @@ public static string GenerateJsonPath( } /// - /// Escape special characters according to XML. + /// Escape special characters for XPath. /// - private static string EscapeXmlCharacters( + private static string EscapeForXPath( string text) { // Mind the order, as we need to replace '&' first. @@ -105,7 +105,10 @@ private static string EscapeXmlCharacters( // https://stackoverflow.com/questions/1321331/replace-multiple-string-elements-in-c-sharp return ( text + // Even though ampersand, less-then etc. can not occur in valid element names, + // we escape them here for easier debugging and better bug reports. .Replace("&", "&") + .Replace("/", "/") .Replace("<", "<") .Replace(">", ">") .Replace("\"", """) @@ -130,7 +133,7 @@ public static string GenerateRelativeXPath( switch (segment) { case NameSegment nameSegment: - part = EscapeXmlCharacters(nameSegment.Name); + part = EscapeForXPath(nameSegment.Name); break; case IndexSegment indexSegment: part = $"*[{indexSegment.Index}]"; diff --git a/src/AasxServer.DomainModelV3_0_RC02/stringification.cs b/src/AasxServer.DomainModelV3_0_RC02/stringification.cs index 865bee6ca..b55aeec69 100644 --- a/src/AasxServer.DomainModelV3_0_RC02/stringification.cs +++ b/src/AasxServer.DomainModelV3_0_RC02/stringification.cs @@ -3,10 +3,10 @@ * Do NOT edit or append. */ +using Aas = AasCore.Aas3_0_RC02; // renamed using CodeAnalysis = System.Diagnostics.CodeAnalysis; -using System.Collections.Generic; // can't alias -using Aas = AasCore.Aas3_0_RC02; +using System.Collections.Generic; // can't alias namespace AasCore.Aas3_0_RC02 { @@ -194,426 +194,6 @@ public static class Stringification } } - private static readonly Dictionary EntityTypeToString = ( - new Dictionary() - { - { Aas.EntityType.CoManagedEntity, "CoManagedEntity" }, - { Aas.EntityType.SelfManagedEntity, "SelfManagedEntity" } - }); - - /// - /// Retrieve the string representation of . - /// - /// - /// If is not a valid literal, return null. - /// - public static string? ToString(Aas.EntityType? that) - { - if (!that.HasValue) - { - return null; - } - else - { - if (EntityTypeToString.TryGetValue(that.Value, out string? value)) - { - return value; - } - else - { - return null; - } - } - } - - [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _entityTypeFromString = ( - new Dictionary() - { - { "CoManagedEntity", Aas.EntityType.CoManagedEntity }, - { "SelfManagedEntity", Aas.EntityType.SelfManagedEntity } - }); - - /// - /// Parse the string representation of . - /// - /// - /// If is not a valid string representation - /// of a literal of , - /// return null. - /// - public static Aas.EntityType? EntityTypeFromString(string text) - { - if (_entityTypeFromString.TryGetValue(text, out EntityType value)) - { - return value; - } - else - { - return null; - } - } - - private static readonly Dictionary DirectionToString = ( - new Dictionary() - { - { Aas.Direction.Input, "INPUT" }, - { Aas.Direction.Output, "OUTPUT" } - }); - - /// - /// Retrieve the string representation of . - /// - /// - /// If is not a valid literal, return null. - /// - public static string? ToString(Aas.Direction? that) - { - if (!that.HasValue) - { - return null; - } - else - { - if (DirectionToString.TryGetValue(that.Value, out string? value)) - { - return value; - } - else - { - return null; - } - } - } - - [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _directionFromString = ( - new Dictionary() - { - { "INPUT", Aas.Direction.Input }, - { "OUTPUT", Aas.Direction.Output } - }); - - /// - /// Parse the string representation of . - /// - /// - /// If is not a valid string representation - /// of a literal of , - /// return null. - /// - public static Aas.Direction? DirectionFromString(string text) - { - if (_directionFromString.TryGetValue(text, out Direction value)) - { - return value; - } - else - { - return null; - } - } - - private static readonly Dictionary StateOfEventToString = ( - new Dictionary() - { - { Aas.StateOfEvent.On, "ON" }, - { Aas.StateOfEvent.Off, "OFF" } - }); - - /// - /// Retrieve the string representation of . - /// - /// - /// If is not a valid literal, return null. - /// - public static string? ToString(Aas.StateOfEvent? that) - { - if (!that.HasValue) - { - return null; - } - else - { - if (StateOfEventToString.TryGetValue(that.Value, out string? value)) - { - return value; - } - else - { - return null; - } - } - } - - [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _stateOfEventFromString = ( - new Dictionary() - { - { "ON", Aas.StateOfEvent.On }, - { "OFF", Aas.StateOfEvent.Off } - }); - - /// - /// Parse the string representation of . - /// - /// - /// If is not a valid string representation - /// of a literal of , - /// return null. - /// - public static Aas.StateOfEvent? StateOfEventFromString(string text) - { - if (_stateOfEventFromString.TryGetValue(text, out StateOfEvent value)) - { - return value; - } - else - { - return null; - } - } - - private static readonly Dictionary ReferenceTypesToString = ( - new Dictionary() - { - { Aas.ReferenceTypes.GlobalReference, "GlobalReference" }, - { Aas.ReferenceTypes.ModelReference, "ModelReference" } - }); - - /// - /// Retrieve the string representation of . - /// - /// - /// If is not a valid literal, return null. - /// - public static string? ToString(Aas.ReferenceTypes? that) - { - if (!that.HasValue) - { - return null; - } - else - { - if (ReferenceTypesToString.TryGetValue(that.Value, out string? value)) - { - return value; - } - else - { - return null; - } - } - } - - [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _referenceTypesFromString = ( - new Dictionary() - { - { "GlobalReference", Aas.ReferenceTypes.GlobalReference }, - { "ModelReference", Aas.ReferenceTypes.ModelReference } - }); - - /// - /// Parse the string representation of . - /// - /// - /// If is not a valid string representation - /// of a literal of , - /// return null. - /// - public static Aas.ReferenceTypes? ReferenceTypesFromString(string text) - { - if (_referenceTypesFromString.TryGetValue(text, out ReferenceTypes value)) - { - return value; - } - else - { - return null; - } - } - - private static readonly Dictionary GenericFragmentKeysToString = ( - new Dictionary() - { - { Aas.GenericFragmentKeys.FragmentReference, "FragmentReference" } - }); - - /// - /// Retrieve the string representation of . - /// - /// - /// If is not a valid literal, return null. - /// - public static string? ToString(Aas.GenericFragmentKeys? that) - { - if (!that.HasValue) - { - return null; - } - else - { - if (GenericFragmentKeysToString.TryGetValue(that.Value, out string? value)) - { - return value; - } - else - { - return null; - } - } - } - - [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _genericFragmentKeysFromString = ( - new Dictionary() - { - { "FragmentReference", Aas.GenericFragmentKeys.FragmentReference } - }); - - /// - /// Parse the string representation of . - /// - /// - /// If is not a valid string representation - /// of a literal of , - /// return null. - /// - public static Aas.GenericFragmentKeys? GenericFragmentKeysFromString(string text) - { - if (_genericFragmentKeysFromString.TryGetValue(text, out GenericFragmentKeys value)) - { - return value; - } - else - { - return null; - } - } - - private static readonly Dictionary GenericGloballyIdentifiablesToString = ( - new Dictionary() - { - { Aas.GenericGloballyIdentifiables.GlobalReference, "GlobalReference" } - }); - - /// - /// Retrieve the string representation of . - /// - /// - /// If is not a valid literal, return null. - /// - public static string? ToString(Aas.GenericGloballyIdentifiables? that) - { - if (!that.HasValue) - { - return null; - } - else - { - if (GenericGloballyIdentifiablesToString.TryGetValue(that.Value, out string? value)) - { - return value; - } - else - { - return null; - } - } - } - - [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _genericGloballyIdentifiablesFromString = ( - new Dictionary() - { - { "GlobalReference", Aas.GenericGloballyIdentifiables.GlobalReference } - }); - - /// - /// Parse the string representation of . - /// - /// - /// If is not a valid string representation - /// of a literal of , - /// return null. - /// - public static Aas.GenericGloballyIdentifiables? GenericGloballyIdentifiablesFromString(string text) - { - if (_genericGloballyIdentifiablesFromString.TryGetValue(text, out GenericGloballyIdentifiables value)) - { - return value; - } - else - { - return null; - } - } - - private static readonly Dictionary AasIdentifiablesToString = ( - new Dictionary() - { - { Aas.AasIdentifiables.AssetAdministrationShell, "AssetAdministrationShell" }, - { Aas.AasIdentifiables.ConceptDescription, "ConceptDescription" }, - { Aas.AasIdentifiables.Identifiable, "Identifiable" }, - { Aas.AasIdentifiables.Submodel, "Submodel" } - }); - - /// - /// Retrieve the string representation of . - /// - /// - /// If is not a valid literal, return null. - /// - public static string? ToString(Aas.AasIdentifiables? that) - { - if (!that.HasValue) - { - return null; - } - else - { - if (AasIdentifiablesToString.TryGetValue(that.Value, out string? value)) - { - return value; - } - else - { - return null; - } - } - } - - [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _aasIdentifiablesFromString = ( - new Dictionary() - { - { "AssetAdministrationShell", Aas.AasIdentifiables.AssetAdministrationShell }, - { "ConceptDescription", Aas.AasIdentifiables.ConceptDescription }, - { "Identifiable", Aas.AasIdentifiables.Identifiable }, - { "Submodel", Aas.AasIdentifiables.Submodel } - }); - - /// - /// Parse the string representation of . - /// - /// - /// If is not a valid string representation - /// of a literal of , - /// return null. - /// - public static Aas.AasIdentifiables? AasIdentifiablesFromString(string text) - { - if (_aasIdentifiablesFromString.TryGetValue(text, out AasIdentifiables value)) - { - return value; - } - else - { - return null; - } - } - private static readonly Dictionary AasSubmodelElementsToString = ( new Dictionary() { @@ -704,26 +284,11 @@ public static class Stringification } } - private static readonly Dictionary AasReferableNonIdentifiablesToString = ( - new Dictionary() - { - { Aas.AasReferableNonIdentifiables.AnnotatedRelationshipElement, "AnnotatedRelationshipElement" }, - { Aas.AasReferableNonIdentifiables.BasicEventElement, "BasicEventElement" }, - { Aas.AasReferableNonIdentifiables.Blob, "Blob" }, - { Aas.AasReferableNonIdentifiables.Capability, "Capability" }, - { Aas.AasReferableNonIdentifiables.DataElement, "DataElement" }, - { Aas.AasReferableNonIdentifiables.Entity, "Entity" }, - { Aas.AasReferableNonIdentifiables.EventElement, "EventElement" }, - { Aas.AasReferableNonIdentifiables.File, "File" }, - { Aas.AasReferableNonIdentifiables.MultiLanguageProperty, "MultiLanguageProperty" }, - { Aas.AasReferableNonIdentifiables.Operation, "Operation" }, - { Aas.AasReferableNonIdentifiables.Property, "Property" }, - { Aas.AasReferableNonIdentifiables.Range, "Range" }, - { Aas.AasReferableNonIdentifiables.ReferenceElement, "ReferenceElement" }, - { Aas.AasReferableNonIdentifiables.RelationshipElement, "RelationshipElement" }, - { Aas.AasReferableNonIdentifiables.SubmodelElement, "SubmodelElement" }, - { Aas.AasReferableNonIdentifiables.SubmodelElementCollection, "SubmodelElementCollection" }, - { Aas.AasReferableNonIdentifiables.SubmodelElementList, "SubmodelElementList" } + private static readonly Dictionary EntityTypeToString = ( + new Dictionary() + { + { Aas.EntityType.CoManagedEntity, "CoManagedEntity" }, + { Aas.EntityType.SelfManagedEntity, "SelfManagedEntity" } }); /// @@ -732,7 +297,7 @@ public static class Stringification /// /// If is not a valid literal, return null. /// - public static string? ToString(Aas.AasReferableNonIdentifiables? that) + public static string? ToString(Aas.EntityType? that) { if (!that.HasValue) { @@ -740,7 +305,7 @@ public static class Stringification } else { - if (AasReferableNonIdentifiablesToString.TryGetValue(that.Value, out string? value)) + if (EntityTypeToString.TryGetValue(that.Value, out string? value)) { return value; } @@ -752,39 +317,24 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _aasReferableNonIdentifiablesFromString = ( - new Dictionary() - { - { "AnnotatedRelationshipElement", Aas.AasReferableNonIdentifiables.AnnotatedRelationshipElement }, - { "BasicEventElement", Aas.AasReferableNonIdentifiables.BasicEventElement }, - { "Blob", Aas.AasReferableNonIdentifiables.Blob }, - { "Capability", Aas.AasReferableNonIdentifiables.Capability }, - { "DataElement", Aas.AasReferableNonIdentifiables.DataElement }, - { "Entity", Aas.AasReferableNonIdentifiables.Entity }, - { "EventElement", Aas.AasReferableNonIdentifiables.EventElement }, - { "File", Aas.AasReferableNonIdentifiables.File }, - { "MultiLanguageProperty", Aas.AasReferableNonIdentifiables.MultiLanguageProperty }, - { "Operation", Aas.AasReferableNonIdentifiables.Operation }, - { "Property", Aas.AasReferableNonIdentifiables.Property }, - { "Range", Aas.AasReferableNonIdentifiables.Range }, - { "ReferenceElement", Aas.AasReferableNonIdentifiables.ReferenceElement }, - { "RelationshipElement", Aas.AasReferableNonIdentifiables.RelationshipElement }, - { "SubmodelElement", Aas.AasReferableNonIdentifiables.SubmodelElement }, - { "SubmodelElementCollection", Aas.AasReferableNonIdentifiables.SubmodelElementCollection }, - { "SubmodelElementList", Aas.AasReferableNonIdentifiables.SubmodelElementList } + private static readonly Dictionary _entityTypeFromString = ( + new Dictionary() + { + { "CoManagedEntity", Aas.EntityType.CoManagedEntity }, + { "SelfManagedEntity", Aas.EntityType.SelfManagedEntity } }); /// - /// Parse the string representation of . + /// Parse the string representation of . /// /// /// If is not a valid string representation - /// of a literal of , + /// of a literal of , /// return null. /// - public static Aas.AasReferableNonIdentifiables? AasReferableNonIdentifiablesFromString(string text) + public static Aas.EntityType? EntityTypeFromString(string text) { - if (_aasReferableNonIdentifiablesFromString.TryGetValue(text, out AasReferableNonIdentifiables value)) + if (_entityTypeFromString.TryGetValue(text, out EntityType value)) { return value; } @@ -794,31 +344,11 @@ public static class Stringification } } - private static readonly Dictionary AasReferablesToString = ( - new Dictionary() - { - { Aas.AasReferables.Referable, "Referable" }, - { Aas.AasReferables.AssetAdministrationShell, "AssetAdministrationShell" }, - { Aas.AasReferables.ConceptDescription, "ConceptDescription" }, - { Aas.AasReferables.Identifiable, "Identifiable" }, - { Aas.AasReferables.Submodel, "Submodel" }, - { Aas.AasReferables.AnnotatedRelationshipElement, "AnnotatedRelationshipElement" }, - { Aas.AasReferables.BasicEventElement, "BasicEventElement" }, - { Aas.AasReferables.Blob, "Blob" }, - { Aas.AasReferables.Capability, "Capability" }, - { Aas.AasReferables.DataElement, "DataElement" }, - { Aas.AasReferables.Entity, "Entity" }, - { Aas.AasReferables.EventElement, "EventElement" }, - { Aas.AasReferables.File, "File" }, - { Aas.AasReferables.MultiLanguageProperty, "MultiLanguageProperty" }, - { Aas.AasReferables.Operation, "Operation" }, - { Aas.AasReferables.Property, "Property" }, - { Aas.AasReferables.Range, "Range" }, - { Aas.AasReferables.ReferenceElement, "ReferenceElement" }, - { Aas.AasReferables.RelationshipElement, "RelationshipElement" }, - { Aas.AasReferables.SubmodelElement, "SubmodelElement" }, - { Aas.AasReferables.SubmodelElementCollection, "SubmodelElementCollection" }, - { Aas.AasReferables.SubmodelElementList, "SubmodelElementList" } + private static readonly Dictionary DirectionToString = ( + new Dictionary() + { + { Aas.Direction.Input, "input" }, + { Aas.Direction.Output, "output" } }); /// @@ -827,7 +357,7 @@ public static class Stringification /// /// If is not a valid literal, return null. /// - public static string? ToString(Aas.AasReferables? that) + public static string? ToString(Aas.Direction? that) { if (!that.HasValue) { @@ -835,7 +365,7 @@ public static class Stringification } else { - if (AasReferablesToString.TryGetValue(that.Value, out string? value)) + if (DirectionToString.TryGetValue(that.Value, out string? value)) { return value; } @@ -847,44 +377,24 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _aasReferablesFromString = ( - new Dictionary() - { - { "Referable", Aas.AasReferables.Referable }, - { "AssetAdministrationShell", Aas.AasReferables.AssetAdministrationShell }, - { "ConceptDescription", Aas.AasReferables.ConceptDescription }, - { "Identifiable", Aas.AasReferables.Identifiable }, - { "Submodel", Aas.AasReferables.Submodel }, - { "AnnotatedRelationshipElement", Aas.AasReferables.AnnotatedRelationshipElement }, - { "BasicEventElement", Aas.AasReferables.BasicEventElement }, - { "Blob", Aas.AasReferables.Blob }, - { "Capability", Aas.AasReferables.Capability }, - { "DataElement", Aas.AasReferables.DataElement }, - { "Entity", Aas.AasReferables.Entity }, - { "EventElement", Aas.AasReferables.EventElement }, - { "File", Aas.AasReferables.File }, - { "MultiLanguageProperty", Aas.AasReferables.MultiLanguageProperty }, - { "Operation", Aas.AasReferables.Operation }, - { "Property", Aas.AasReferables.Property }, - { "Range", Aas.AasReferables.Range }, - { "ReferenceElement", Aas.AasReferables.ReferenceElement }, - { "RelationshipElement", Aas.AasReferables.RelationshipElement }, - { "SubmodelElement", Aas.AasReferables.SubmodelElement }, - { "SubmodelElementCollection", Aas.AasReferables.SubmodelElementCollection }, - { "SubmodelElementList", Aas.AasReferables.SubmodelElementList } + private static readonly Dictionary _directionFromString = ( + new Dictionary() + { + { "input", Aas.Direction.Input }, + { "output", Aas.Direction.Output } }); /// - /// Parse the string representation of . + /// Parse the string representation of . /// /// /// If is not a valid string representation - /// of a literal of , + /// of a literal of , /// return null. /// - public static Aas.AasReferables? AasReferablesFromString(string text) + public static Aas.Direction? DirectionFromString(string text) { - if (_aasReferablesFromString.TryGetValue(text, out AasReferables value)) + if (_directionFromString.TryGetValue(text, out Direction value)) { return value; } @@ -894,14 +404,11 @@ public static class Stringification } } - private static readonly Dictionary GloballyIdentifiablesToString = ( - new Dictionary() - { - { Aas.GloballyIdentifiables.GlobalReference, "GlobalReference" }, - { Aas.GloballyIdentifiables.AssetAdministrationShell, "AssetAdministrationShell" }, - { Aas.GloballyIdentifiables.ConceptDescription, "ConceptDescription" }, - { Aas.GloballyIdentifiables.Identifiable, "Identifiable" }, - { Aas.GloballyIdentifiables.Submodel, "Submodel" } + private static readonly Dictionary StateOfEventToString = ( + new Dictionary() + { + { Aas.StateOfEvent.On, "on" }, + { Aas.StateOfEvent.Off, "off" } }); /// @@ -910,7 +417,7 @@ public static class Stringification /// /// If is not a valid literal, return null. /// - public static string? ToString(Aas.GloballyIdentifiables? that) + public static string? ToString(Aas.StateOfEvent? that) { if (!that.HasValue) { @@ -918,7 +425,7 @@ public static class Stringification } else { - if (GloballyIdentifiablesToString.TryGetValue(that.Value, out string? value)) + if (StateOfEventToString.TryGetValue(that.Value, out string? value)) { return value; } @@ -930,27 +437,24 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _globallyIdentifiablesFromString = ( - new Dictionary() - { - { "GlobalReference", Aas.GloballyIdentifiables.GlobalReference }, - { "AssetAdministrationShell", Aas.GloballyIdentifiables.AssetAdministrationShell }, - { "ConceptDescription", Aas.GloballyIdentifiables.ConceptDescription }, - { "Identifiable", Aas.GloballyIdentifiables.Identifiable }, - { "Submodel", Aas.GloballyIdentifiables.Submodel } + private static readonly Dictionary _stateOfEventFromString = ( + new Dictionary() + { + { "on", Aas.StateOfEvent.On }, + { "off", Aas.StateOfEvent.Off } }); /// - /// Parse the string representation of . + /// Parse the string representation of . /// /// /// If is not a valid string representation - /// of a literal of , + /// of a literal of , /// return null. /// - public static Aas.GloballyIdentifiables? GloballyIdentifiablesFromString(string text) + public static Aas.StateOfEvent? StateOfEventFromString(string text) { - if (_globallyIdentifiablesFromString.TryGetValue(text, out GloballyIdentifiables value)) + if (_stateOfEventFromString.TryGetValue(text, out StateOfEvent value)) { return value; } @@ -960,30 +464,11 @@ public static class Stringification } } - private static readonly Dictionary FragmentKeysToString = ( - new Dictionary() - { - { Aas.FragmentKeys.FragmentReference, "FragmentReference" }, - { Aas.FragmentKeys.AnnotatedRelationshipElement, "AnnotatedRelationshipElement" }, - { Aas.FragmentKeys.AssetAdministrationShell, "AssetAdministrationShell" }, - { Aas.FragmentKeys.BasicEventElement, "BasicEventElement" }, - { Aas.FragmentKeys.Blob, "Blob" }, - { Aas.FragmentKeys.Capability, "Capability" }, - { Aas.FragmentKeys.ConceptDescription, "ConceptDescription" }, - { Aas.FragmentKeys.DataElement, "DataElement" }, - { Aas.FragmentKeys.Entity, "Entity" }, - { Aas.FragmentKeys.EventElement, "EventElement" }, - { Aas.FragmentKeys.File, "File" }, - { Aas.FragmentKeys.MultiLanguageProperty, "MultiLanguageProperty" }, - { Aas.FragmentKeys.Operation, "Operation" }, - { Aas.FragmentKeys.Property, "Property" }, - { Aas.FragmentKeys.Range, "Range" }, - { Aas.FragmentKeys.ReferenceElement, "ReferenceElement" }, - { Aas.FragmentKeys.RelationshipElement, "RelationshipElement" }, - { Aas.FragmentKeys.Submodel, "Submodel" }, - { Aas.FragmentKeys.SubmodelElement, "SubmodelElement" }, - { Aas.FragmentKeys.SubmodelElementList, "SubmodelElementList" }, - { Aas.FragmentKeys.SubmodelElementCollection, "SubmodelElementCollection" } + private static readonly Dictionary ReferenceTypesToString = ( + new Dictionary() + { + { Aas.ReferenceTypes.GlobalReference, "GlobalReference" }, + { Aas.ReferenceTypes.ModelReference, "ModelReference" } }); /// @@ -992,7 +477,7 @@ public static class Stringification /// /// If is not a valid literal, return null. /// - public static string? ToString(Aas.FragmentKeys? that) + public static string? ToString(Aas.ReferenceTypes? that) { if (!that.HasValue) { @@ -1000,7 +485,7 @@ public static class Stringification } else { - if (FragmentKeysToString.TryGetValue(that.Value, out string? value)) + if (ReferenceTypesToString.TryGetValue(that.Value, out string? value)) { return value; } @@ -1012,43 +497,24 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _fragmentKeysFromString = ( - new Dictionary() - { - { "FragmentReference", Aas.FragmentKeys.FragmentReference }, - { "AnnotatedRelationshipElement", Aas.FragmentKeys.AnnotatedRelationshipElement }, - { "AssetAdministrationShell", Aas.FragmentKeys.AssetAdministrationShell }, - { "BasicEventElement", Aas.FragmentKeys.BasicEventElement }, - { "Blob", Aas.FragmentKeys.Blob }, - { "Capability", Aas.FragmentKeys.Capability }, - { "ConceptDescription", Aas.FragmentKeys.ConceptDescription }, - { "DataElement", Aas.FragmentKeys.DataElement }, - { "Entity", Aas.FragmentKeys.Entity }, - { "EventElement", Aas.FragmentKeys.EventElement }, - { "File", Aas.FragmentKeys.File }, - { "MultiLanguageProperty", Aas.FragmentKeys.MultiLanguageProperty }, - { "Operation", Aas.FragmentKeys.Operation }, - { "Property", Aas.FragmentKeys.Property }, - { "Range", Aas.FragmentKeys.Range }, - { "ReferenceElement", Aas.FragmentKeys.ReferenceElement }, - { "RelationshipElement", Aas.FragmentKeys.RelationshipElement }, - { "Submodel", Aas.FragmentKeys.Submodel }, - { "SubmodelElement", Aas.FragmentKeys.SubmodelElement }, - { "SubmodelElementList", Aas.FragmentKeys.SubmodelElementList }, - { "SubmodelElementCollection", Aas.FragmentKeys.SubmodelElementCollection } + private static readonly Dictionary _referenceTypesFromString = ( + new Dictionary() + { + { "GlobalReference", Aas.ReferenceTypes.GlobalReference }, + { "ModelReference", Aas.ReferenceTypes.ModelReference } }); /// - /// Parse the string representation of . + /// Parse the string representation of . /// /// /// If is not a valid string representation - /// of a literal of , + /// of a literal of , /// return null. /// - public static Aas.FragmentKeys? FragmentKeysFromString(string text) + public static Aas.ReferenceTypes? ReferenceTypesFromString(string text) { - if (_fragmentKeysFromString.TryGetValue(text, out FragmentKeys value)) + if (_referenceTypesFromString.TryGetValue(text, out ReferenceTypes value)) { return value; } @@ -1078,8 +544,8 @@ public static class Stringification { Aas.KeyTypes.Operation, "Operation" }, { Aas.KeyTypes.Property, "Property" }, { Aas.KeyTypes.Range, "Range" }, - { Aas.KeyTypes.Referable, "Referable" }, { Aas.KeyTypes.ReferenceElement, "ReferenceElement" }, + { Aas.KeyTypes.Referable, "Referable" }, { Aas.KeyTypes.RelationshipElement, "RelationshipElement" }, { Aas.KeyTypes.Submodel, "Submodel" }, { Aas.KeyTypes.SubmodelElement, "SubmodelElement" }, @@ -1133,8 +599,8 @@ public static class Stringification { "Operation", Aas.KeyTypes.Operation }, { "Property", Aas.KeyTypes.Property }, { "Range", Aas.KeyTypes.Range }, - { "Referable", Aas.KeyTypes.Referable }, { "ReferenceElement", Aas.KeyTypes.ReferenceElement }, + { "Referable", Aas.KeyTypes.Referable }, { "RelationshipElement", Aas.KeyTypes.RelationshipElement }, { "Submodel", Aas.KeyTypes.Submodel }, { "SubmodelElement", Aas.KeyTypes.SubmodelElement }, @@ -1190,7 +656,7 @@ public static class Stringification { Aas.DataTypeDefXsd.Int, "xs:int" }, { Aas.DataTypeDefXsd.Short, "xs:short" }, { Aas.DataTypeDefXsd.Byte, "xs:byte" }, - { Aas.DataTypeDefXsd.NonNegativeInteger, "xs:NonNegativeInteger" }, + { Aas.DataTypeDefXsd.NonNegativeInteger, "xs:nonNegativeInteger" }, { Aas.DataTypeDefXsd.PositiveInteger, "xs:positiveInteger" }, { Aas.DataTypeDefXsd.UnsignedLong, "xs:unsignedLong" }, { Aas.DataTypeDefXsd.UnsignedInt, "xs:unsignedInt" }, @@ -1254,7 +720,7 @@ public static class Stringification { "xs:int", Aas.DataTypeDefXsd.Int }, { "xs:short", Aas.DataTypeDefXsd.Short }, { "xs:byte", Aas.DataTypeDefXsd.Byte }, - { "xs:NonNegativeInteger", Aas.DataTypeDefXsd.NonNegativeInteger }, + { "xs:nonNegativeInteger", Aas.DataTypeDefXsd.NonNegativeInteger }, { "xs:positiveInteger", Aas.DataTypeDefXsd.PositiveInteger }, { "xs:unsignedLong", Aas.DataTypeDefXsd.UnsignedLong }, { "xs:unsignedInt", Aas.DataTypeDefXsd.UnsignedInt }, @@ -1284,10 +750,28 @@ public static class Stringification } } - private static readonly Dictionary DataTypeDefRdfToString = ( - new Dictionary() + private static readonly Dictionary DataTypeIec61360ToString = ( + new Dictionary() { - { Aas.DataTypeDefRdf.LangString, "rdf:langString" } + { Aas.DataTypeIec61360.Date, "DATE" }, + { Aas.DataTypeIec61360.String, "STRING" }, + { Aas.DataTypeIec61360.StringTranslatable, "STRING_TRANSLATABLE" }, + { Aas.DataTypeIec61360.IntegerMeasure, "INTEGER_MEASURE" }, + { Aas.DataTypeIec61360.IntegerCount, "INTEGER_COUNT" }, + { Aas.DataTypeIec61360.IntegerCurrency, "INTEGER_CURRENCY" }, + { Aas.DataTypeIec61360.RealMeasure, "REAL_MEASURE" }, + { Aas.DataTypeIec61360.RealCount, "REAL_COUNT" }, + { Aas.DataTypeIec61360.RealCurrency, "REAL_CURRENCY" }, + { Aas.DataTypeIec61360.Boolean, "BOOLEAN" }, + { Aas.DataTypeIec61360.Iri, "IRI" }, + { Aas.DataTypeIec61360.Irdi, "IRDI" }, + { Aas.DataTypeIec61360.Rational, "RATIONAL" }, + { Aas.DataTypeIec61360.RationalMeasure, "RATIONAL_MEASURE" }, + { Aas.DataTypeIec61360.Time, "TIME" }, + { Aas.DataTypeIec61360.Timestamp, "TIMESTAMP" }, + { Aas.DataTypeIec61360.File, "FILE" }, + { Aas.DataTypeIec61360.Html, "HTML" }, + { Aas.DataTypeIec61360.Blob, "BLOB" } }); /// @@ -1296,7 +780,7 @@ public static class Stringification /// /// If is not a valid literal, return null. /// - public static string? ToString(Aas.DataTypeDefRdf? that) + public static string? ToString(Aas.DataTypeIec61360? that) { if (!that.HasValue) { @@ -1304,7 +788,7 @@ public static class Stringification } else { - if (DataTypeDefRdfToString.TryGetValue(that.Value, out string? value)) + if (DataTypeIec61360ToString.TryGetValue(that.Value, out string? value)) { return value; } @@ -1316,23 +800,41 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _dataTypeDefRdfFromString = ( - new Dictionary() - { - { "rdf:langString", Aas.DataTypeDefRdf.LangString } - }); - - /// - /// Parse the string representation of . + 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 . /// /// /// If is not a valid string representation - /// of a literal of , + /// of a literal of , /// return null. /// - public static Aas.DataTypeDefRdf? DataTypeDefRdfFromString(string text) + public static Aas.DataTypeIec61360? DataTypeIec61360FromString(string text) { - if (_dataTypeDefRdfFromString.TryGetValue(text, out DataTypeDefRdf value)) + if (_dataTypeIec61360FromString.TryGetValue(text, out DataTypeIec61360 value)) { return value; } @@ -1342,43 +844,13 @@ public static class Stringification } } - private static readonly Dictionary DataTypeDefToString = ( - new Dictionary() - { - { Aas.DataTypeDef.AnyUri, "xs:anyURI" }, - { Aas.DataTypeDef.Base64Binary, "xs:base64Binary" }, - { Aas.DataTypeDef.Boolean, "xs:boolean" }, - { Aas.DataTypeDef.Date, "xs:date" }, - { Aas.DataTypeDef.DateTime, "xs:dateTime" }, - { Aas.DataTypeDef.DateTimeStamp, "xs:dateTimeStamp" }, - { Aas.DataTypeDef.Decimal, "xs:decimal" }, - { Aas.DataTypeDef.Double, "xs:double" }, - { Aas.DataTypeDef.Duration, "xs:duration" }, - { Aas.DataTypeDef.Float, "xs:float" }, - { Aas.DataTypeDef.GDay, "xs:gDay" }, - { Aas.DataTypeDef.GMonth, "xs:gMonth" }, - { Aas.DataTypeDef.GMonthDay, "xs:gMonthDay" }, - { Aas.DataTypeDef.GYear, "xs:gYear" }, - { Aas.DataTypeDef.GYearMonth, "xs:gYearMonth" }, - { Aas.DataTypeDef.HexBinary, "xs:hexBinary" }, - { Aas.DataTypeDef.String, "xs:string" }, - { Aas.DataTypeDef.Time, "xs:time" }, - { Aas.DataTypeDef.DayTimeDuration, "xs:dayTimeDuration" }, - { Aas.DataTypeDef.YearMonthDuration, "xs:yearMonthDuration" }, - { Aas.DataTypeDef.Integer, "xs:integer" }, - { Aas.DataTypeDef.Long, "xs:long" }, - { Aas.DataTypeDef.Int, "xs:int" }, - { Aas.DataTypeDef.Short, "xs:short" }, - { Aas.DataTypeDef.Byte, "xs:byte" }, - { Aas.DataTypeDef.NonNegativeInteger, "xs:NonNegativeInteger" }, - { Aas.DataTypeDef.PositiveInteger, "xs:positiveInteger" }, - { Aas.DataTypeDef.UnsignedLong, "xs:unsignedLong" }, - { Aas.DataTypeDef.UnsignedInt, "xs:unsignedInt" }, - { Aas.DataTypeDef.UnsignedShort, "xs:unsignedShort" }, - { Aas.DataTypeDef.UnsignedByte, "xs:unsignedByte" }, - { Aas.DataTypeDef.NonPositiveInteger, "xs:nonPositiveInteger" }, - { Aas.DataTypeDef.NegativeInteger, "xs:negativeInteger" }, - { Aas.DataTypeDef.LangString, "rdf:langString" } + private static readonly Dictionary LevelTypeToString = ( + new Dictionary() + { + { Aas.LevelType.Min, "Min" }, + { Aas.LevelType.Max, "Max" }, + { Aas.LevelType.Nom, "Nom" }, + { Aas.LevelType.Typ, "Typ" } }); /// @@ -1387,7 +859,7 @@ public static class Stringification /// /// If is not a valid literal, return null. /// - public static string? ToString(Aas.DataTypeDef? that) + public static string? ToString(Aas.LevelType? that) { if (!that.HasValue) { @@ -1395,7 +867,7 @@ public static class Stringification } else { - if (DataTypeDefToString.TryGetValue(that.Value, out string? value)) + if (LevelTypeToString.TryGetValue(that.Value, out string? value)) { return value; } @@ -1407,56 +879,26 @@ public static class Stringification } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - private static readonly Dictionary _dataTypeDefFromString = ( - new Dictionary() - { - { "xs:anyURI", Aas.DataTypeDef.AnyUri }, - { "xs:base64Binary", Aas.DataTypeDef.Base64Binary }, - { "xs:boolean", Aas.DataTypeDef.Boolean }, - { "xs:date", Aas.DataTypeDef.Date }, - { "xs:dateTime", Aas.DataTypeDef.DateTime }, - { "xs:dateTimeStamp", Aas.DataTypeDef.DateTimeStamp }, - { "xs:decimal", Aas.DataTypeDef.Decimal }, - { "xs:double", Aas.DataTypeDef.Double }, - { "xs:duration", Aas.DataTypeDef.Duration }, - { "xs:float", Aas.DataTypeDef.Float }, - { "xs:gDay", Aas.DataTypeDef.GDay }, - { "xs:gMonth", Aas.DataTypeDef.GMonth }, - { "xs:gMonthDay", Aas.DataTypeDef.GMonthDay }, - { "xs:gYear", Aas.DataTypeDef.GYear }, - { "xs:gYearMonth", Aas.DataTypeDef.GYearMonth }, - { "xs:hexBinary", Aas.DataTypeDef.HexBinary }, - { "xs:string", Aas.DataTypeDef.String }, - { "xs:time", Aas.DataTypeDef.Time }, - { "xs:dayTimeDuration", Aas.DataTypeDef.DayTimeDuration }, - { "xs:yearMonthDuration", Aas.DataTypeDef.YearMonthDuration }, - { "xs:integer", Aas.DataTypeDef.Integer }, - { "xs:long", Aas.DataTypeDef.Long }, - { "xs:int", Aas.DataTypeDef.Int }, - { "xs:short", Aas.DataTypeDef.Short }, - { "xs:byte", Aas.DataTypeDef.Byte }, - { "xs:NonNegativeInteger", Aas.DataTypeDef.NonNegativeInteger }, - { "xs:positiveInteger", Aas.DataTypeDef.PositiveInteger }, - { "xs:unsignedLong", Aas.DataTypeDef.UnsignedLong }, - { "xs:unsignedInt", Aas.DataTypeDef.UnsignedInt }, - { "xs:unsignedShort", Aas.DataTypeDef.UnsignedShort }, - { "xs:unsignedByte", Aas.DataTypeDef.UnsignedByte }, - { "xs:nonPositiveInteger", Aas.DataTypeDef.NonPositiveInteger }, - { "xs:negativeInteger", Aas.DataTypeDef.NegativeInteger }, - { "rdf:langString", Aas.DataTypeDef.LangString } + private static readonly Dictionary _levelTypeFromString = ( + new Dictionary() + { + { "Min", Aas.LevelType.Min }, + { "Max", Aas.LevelType.Max }, + { "Nom", Aas.LevelType.Nom }, + { "Typ", Aas.LevelType.Typ } }); /// - /// Parse the string representation of . + /// Parse the string representation of . /// /// /// If is not a valid string representation - /// of a literal of , + /// of a literal of , /// return null. /// - public static Aas.DataTypeDef? DataTypeDefFromString(string text) + public static Aas.LevelType? LevelTypeFromString(string text) { - if (_dataTypeDefFromString.TryGetValue(text, out DataTypeDef value)) + if (_levelTypeFromString.TryGetValue(text, out LevelType value)) { return value; } diff --git a/src/AasxServer.DomainModelV3_0_RC02/types.cs b/src/AasxServer.DomainModelV3_0_RC02/types.cs index 4226bb39c..cf13214c0 100644 --- a/src/AasxServer.DomainModelV3_0_RC02/types.cs +++ b/src/AasxServer.DomainModelV3_0_RC02/types.cs @@ -1,14 +1,17 @@ +/* /* * This code has been automatically generated by aas-core-codegen. * Do NOT edit or append. */ +using Aas = AasCore.Aas3_0_RC02; // renamed using EnumMemberAttribute = System.Runtime.Serialization.EnumMemberAttribute; + using System.Collections.Generic; // can't alias -using Aas = AasCore.Aas3_0_RC02; -using System; using Newtonsoft.Json; +using AdminShellNS.DiaryData; +using System; namespace AasCore.Aas3_0_RC02 { @@ -63,13 +66,15 @@ public T Transform( /// definitions. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-118: /// If there are ID defined /// then there shall be also a main semantic ID . - ///
  • + /// ///
///
public interface IHasSemantics : IClass @@ -120,12 +125,14 @@ public class Extension : IHasSemantics /// Name of the extension. ///
/// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-077: /// The name of an extension within needs to be unique. - ///
  • + /// ///
///
public string Name { get; set; } @@ -311,7 +318,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 @@ -343,38 +350,53 @@ public interface IReferable : IHasExtensions /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -400,6 +422,7 @@ public interface IReferable : IHasExtensions public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + #endregion } @@ -442,13 +465,17 @@ public enum ModelingKind /// Concrete, clearly identifiable component of a certain template. /// /// - /// It becomes an individual entity of a template, for example a + /// + /// It becomes an individual entity of a template, for example a /// device model, by defining specific property values. - /// - /// In an object oriented view, an instance denotes an object of a + /// + /// + /// In an object oriented view, an instance denotes an object of a /// template (class). - /// - /// [SOURCE: IEC 62890:2016, 3.1.16 65/617/CDV] modified + /// + /// + /// [SOURCE: IEC 62890:2016, 3.1.16 65/617/CDV] modified + /// /// [EnumMember(Value = "Instance")] Instance @@ -485,12 +512,9 @@ public interface IHasKind : IClass public interface IHasDataSpecification : IClass { /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } } /// @@ -498,25 +522,24 @@ public interface IHasDataSpecification : IClass /// information. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-005: /// If is not specified then also shall be /// unspecified. This means, a revision requires a version. If there is no version /// there is no revision neither. Revision is optional. - ///
  • + /// ///
///
public class AdministrativeInformation : IHasDataSpecification { /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Version of the element. @@ -529,12 +552,12 @@ public class AdministrativeInformation : IHasDataSpecification public string? Revision { get; set; } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -543,9 +566,9 @@ public IEnumerable OverDataSpecificationsOrEmpty() /// public IEnumerable DescendOnce() { - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -557,9 +580,9 @@ public IEnumerable DescendOnce() /// public IEnumerable Descend() { - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -613,11 +636,11 @@ public T Transform( } public AdministrativeInformation( - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, string? version = null, string? revision = null) { - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; Version = version; Revision = revision; } @@ -628,15 +651,17 @@ public AdministrativeInformation( /// qualifiers. ///
/// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-119: /// If any value of is /// equal to and the qualified element - /// inherits from then the qualified element shell be of + /// inherits from then the qualified element shall be of /// kind Template ( = ). - ///
  • + /// ///
///
public interface IQualifiable : IClass @@ -645,13 +670,15 @@ public interface IQualifiable : IClass /// Additional qualification of a qualifiable element. ///
/// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } @@ -695,20 +722,22 @@ public enum QualifierKind /// of the element. ///
/// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-006: /// If both the and the of /// a are present then the needs /// to be identical to the value of the referenced coded value /// in . - ///
  • - ///
  • + ///
  • + ///
  • /// Constraint AASd-020: /// The value of shall be consistent to the data type as /// defined in . - ///
  • + /// ///
///
public class Qualifier : IHasSemantics @@ -950,38 +979,53 @@ public class AssetAdministrationShell : /// Display name. Can be provided in several languages. ///
/// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -1010,12 +1054,9 @@ public class AssetAdministrationShell : public string Id { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// The reference to the AAS the AAS was derived from. @@ -1031,11 +1072,15 @@ public class AssetAdministrationShell : /// References to submodels of the AAS. /// /// + /// /// A submodel is a description of an aspect of the asset the AAS is representing. - /// + /// + /// /// The asset of an AAS is typically described by one or more submodels. - /// + /// + /// /// Temporarily no submodel might be assigned to the AAS. + /// /// public List? Submodels { get; set; } @@ -1046,8 +1091,15 @@ public class AssetAdministrationShell : 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 /// @@ -1060,12 +1112,30 @@ public IEnumerable OverExtensionsOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverDisplayNameOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() + { + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -1093,12 +1163,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (Administration != null) @@ -1106,9 +1182,9 @@ public IEnumerable DescendOnce() yield return Administration; } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -1151,23 +1227,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -1182,9 +1264,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -1270,22 +1352,17 @@ public T Transform( return transformer.Transform(this, context); } - //TODO:jtikekar refactor, added to support XML serilization at AdminShellPackageEnv line 805 - public AssetAdministrationShell() - { - - } public AssetAdministrationShell( string id, AssetInformation assetInformation, List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, AdministrativeInformation? administration = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, Reference? derivedFrom = null, List? submodels = null) { @@ -1297,7 +1374,7 @@ public AssetAdministrationShell( Checksum = checksum; Id = id; Administration = administration; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; DerivedFrom = derivedFrom; AssetInformation = assetInformation; Submodels = submodels; @@ -1309,21 +1386,25 @@ public AssetAdministrationShell( /// represented by an AAS is defined. /// /// + /// /// The asset may either represent an asset type or an asset instance. - /// + /// + /// /// The asset has a globally unique identifier plus – if needed – additional domain /// specific (proprietary) identifiers. However, to support the corner case of very - /// first phase of lifecycle where a stabilised/constant global asset identifier does + /// first phase of lifecycle where a stabilised/constant_set global asset identifier does /// not already exist, the corresponding attribute is optional. - /// + /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-116: /// globalAssetId (case-insensitive) is a reserved key. If used as value for /// then shall be /// identical to . - ///
  • + /// ///
///
public class AssetInformation : IClass @@ -1338,12 +1419,15 @@ public class AssetInformation : IClass /// Global identifier of the asset the AAS is representing. ///
/// + /// /// This attribute is required as soon as the AAS is exchanged via partners in the life /// cycle of the asset. In a first phase of the life cycle the asset might not yet have /// a global ID but already an internal identifier. The internal identifier would be /// modelled via . - /// + /// + /// /// This is a global reference. + /// /// public Reference? GlobalAssetId { get; set; } @@ -1599,13 +1683,17 @@ public enum AssetKind /// concrete, clearly identifiable component of a certain type ///
/// + /// /// It becomes an individual entity of a type, for example a device, by defining /// specific property values. - /// + /// + /// /// In an object oriented view, an instance denotes an object of a class /// (of a type). - /// + /// + /// /// [SOURCE: IEC 62890:2016, 3.1.16] 65/617/CDV + /// /// [EnumMember(Value = "Instance")] Instance @@ -1832,38 +1920,53 @@ public class Submodel : /// Display name. Can be provided in several languages. ///
/// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -1921,24 +2024,23 @@ public class Submodel : /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// A submodel consists of zero or more submodel elements. @@ -1952,8 +2054,12 @@ public class Submodel : public DateTime TimeStampCreate { get; set; } [JsonIgnore] public DateTime TimeStamp { get; set; } + [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -1965,6 +2071,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -1984,12 +2108,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -2026,12 +2150,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (Administration != null) @@ -2060,9 +2190,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -2098,23 +2228,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -2168,9 +2304,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -2242,15 +2378,15 @@ public Submodel( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, AdministrativeInformation? administration = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, List? submodelElements = null) { Extensions = extensions; @@ -2265,7 +2401,7 @@ public Submodel( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; SubmodelElements = submodelElements; } } @@ -2345,38 +2481,53 @@ public class RelationshipElement : IRelationshipElement /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -2420,24 +2571,23 @@ public class RelationshipElement : IRelationshipElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Reference to the first element in the relationship taking the role of the subject. @@ -2456,8 +2606,12 @@ public class RelationshipElement : IRelationshipElement public DateTime TimeStampCreate { get; set; } [JsonIgnore] public DateTime TimeStamp { get; set; } + [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -2469,6 +2623,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -2488,12 +2660,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -2521,12 +2693,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -2550,9 +2728,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -2584,23 +2762,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -2643,9 +2827,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -2720,14 +2904,14 @@ public RelationshipElement( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null) + List? embeddedDataSpecifications = null) { Extensions = extensions; IdShort = idShort; @@ -2739,43 +2923,103 @@ public RelationshipElement( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; First = first; Second = second; } } + /// + /// Enumeration of all possible elements of a . + /// + public enum AasSubmodelElements + { + [EnumMember(Value = "AnnotatedRelationshipElement")] + AnnotatedRelationshipElement, + + [EnumMember(Value = "BasicEventElement")] + BasicEventElement, + + [EnumMember(Value = "Blob")] + Blob, + + [EnumMember(Value = "Capability")] + Capability, + + [EnumMember(Value = "DataElement")] + DataElement, + + [EnumMember(Value = "Entity")] + Entity, + + [EnumMember(Value = "EventElement")] + EventElement, + + [EnumMember(Value = "File")] + File, + + [EnumMember(Value = "MultiLanguageProperty")] + MultiLanguageProperty, + + [EnumMember(Value = "Operation")] + Operation, + + [EnumMember(Value = "Property")] + Property, + + [EnumMember(Value = "Range")] + Range, + + [EnumMember(Value = "ReferenceElement")] + ReferenceElement, + + [EnumMember(Value = "RelationshipElement")] + RelationshipElement, + + [EnumMember(Value = "SubmodelElement")] + SubmodelElement, + + [EnumMember(Value = "SubmodelElementList")] + SubmodelElementList, + + [EnumMember(Value = "SubmodelElementCollection")] + SubmodelElementCollection + } + /// /// A submodel element list is an ordered list of submodel elements. /// /// + /// /// The numbering starts with zero (0). - /// + /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-107: /// If a first level child element in a has - /// a it + /// a it /// shall be identical to . - ///
  • - ///
  • + ///
  • + ///
  • /// Constraint AASd-114: /// If two first level child elements in a have - /// a then they shall be identical. - ///
  • - ///
  • + /// a then they shall be identical. + ///
  • + ///
  • /// Constraint AASd-115: /// If a first level child element in a does not - /// specify a then the value is assumed to be + /// specify a then the value is assumed to be /// identical to . - ///
  • - ///
  • + ///
  • + ///
  • /// Constraint AASd-108: /// All first level child elements in a shall have /// the same submodel element type as specified in . - ///
  • - ///
  • + ///
  • + ///
  • /// Constraint AASd-109: /// If is equal to /// or @@ -2783,7 +3027,7 @@ public RelationshipElement( /// shall be set and all first /// level child elements in the shall have /// the value type as specified in . - ///
  • + /// ///
///
public class SubmodelElementList : ISubmodelElement @@ -2823,38 +3067,53 @@ public class SubmodelElementList : ISubmodelElement /// Display name. Can be provided in several languages. ///
/// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -2898,24 +3157,23 @@ public class SubmodelElementList : ISubmodelElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Defines whether order in list is relevant. If = False @@ -2951,6 +3209,7 @@ public class SubmodelElementList : ISubmodelElement /// The value type of the submodel element contained in the list. /// public DataTypeDefXsd? ValueTypeListElement { get; set; } + #region Parent and Timestamp [JsonIgnore] public IClass Parent { get; set; } @@ -2958,8 +3217,12 @@ public class SubmodelElementList : ISubmodelElement public DateTime TimeStampCreate { get; set; } [JsonIgnore] public DateTime TimeStamp { get; set; } + [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -2971,6 +3234,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -2990,12 +3271,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -3041,12 +3322,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -3070,9 +3357,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -3113,23 +3400,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -3172,9 +3465,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -3257,14 +3550,14 @@ public SubmodelElementList( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, bool? orderRelevant = null, List? value = null, Reference? semanticIdListElement = null, @@ -3280,7 +3573,7 @@ public SubmodelElementList( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; TypeValueListElement = typeValueListElement; OrderRelevant = orderRelevant; Value = value; @@ -3330,38 +3623,53 @@ public class SubmodelElementCollection : ISubmodelElement /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -3405,24 +3713,23 @@ public class SubmodelElementCollection : ISubmodelElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Submodel element contained in the collection. @@ -3438,6 +3745,9 @@ public class SubmodelElementCollection : ISubmodelElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -3449,6 +3759,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -3468,12 +3796,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -3510,12 +3838,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -3539,9 +3873,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -3577,23 +3911,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; - } - } + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } + } + } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -3636,9 +3976,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -3709,14 +4049,14 @@ public SubmodelElementCollection( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, List? value = null) { Extensions = extensions; @@ -3729,7 +4069,7 @@ public SubmodelElementCollection( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; Value = value; } } @@ -3739,53 +4079,45 @@ public SubmodelElementCollection( /// other submodel elements. /// /// + /// /// A data element is a submodel element that has a value. The type of value differs /// for different subtypes of data elements. - /// + /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • + /// /// Constraint AASd-090: - /// For data elements (inherited by ) shall be - /// one of the following values: CONSTANT, PARAMETER or VARIABLE. - /// + /// For data elements shall be one of the following + /// values: CONSTANT, PARAMETER or VARIABLE. + /// + /// /// Default: VARIABLE - ///
  • + /// + /// ///
///
public interface IDataElement : ISubmodelElement { public string CategoryOrDefault(); - /// - /// Iterate over Extensions, if set, and otherwise return an empty enumerable. - /// - public IEnumerable OverExtensionsOrEmpty(); - /// - /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. - /// - public IEnumerable OverSupplementalSemanticIdsOrEmpty(); - /// - /// Iterate over Qualifiers, if set, and otherwise return an empty enumerable. - /// - public IEnumerable OverQualifiersOrEmpty(); - /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. - /// - public IEnumerable OverDataSpecificationsOrEmpty(); } /// /// A property is a data element that has a single value. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-007: /// If both, the and the are /// present then the value of needs to be identical to /// the value of the referenced coded value in . - ///
  • + /// ///
///
public class Property : IDataElement @@ -3825,38 +4157,53 @@ public class Property : IDataElement /// Display name. Can be provided in several languages. ///
/// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -3900,24 +4247,23 @@ public class Property : IDataElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Data type of the value @@ -3946,6 +4292,9 @@ public class Property : IDataElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -3957,6 +4306,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -3976,12 +4343,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -3994,7 +4361,7 @@ public ModelingKind KindOrDefault() } /// - /// Return the or the default value + /// Return the or the default value /// if it has not been set. /// public string CategoryOrDefault() @@ -4002,7 +4369,7 @@ public string CategoryOrDefault() string result = Category ?? "VARIABLE"; #if DEBUG - if (!Verification.DataElementCategoryIsValid( + if (!Constants.ValidCategoriesForDataElement.Contains( result)) { throw new System.InvalidOperationException( @@ -4030,12 +4397,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -4059,9 +4432,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -4094,23 +4467,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -4153,9 +4532,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -4224,14 +4603,14 @@ public Property( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, string? value = null, Reference? valueId = null) { @@ -4245,7 +4624,7 @@ public Property( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; ValueType = valueType; Value = value; ValueId = valueId; @@ -4256,14 +4635,16 @@ public Property( /// A property is a data element that has a multi-language value. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-012: /// If both the and the are present then for each /// string in a specific language the meaning must be the same as specified in /// . - ///
  • + /// ///
///
public class MultiLanguageProperty : IDataElement @@ -4303,38 +4684,53 @@ public class MultiLanguageProperty : IDataElement /// Display name. Can be provided in several languages. ///
/// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -4378,29 +4774,28 @@ public class MultiLanguageProperty : IDataElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// The value of the property instance. /// - public LangStringSet? Value { get; set; } + public List? Value { get; set; } /// /// Reference to the global unique ID of a coded value. @@ -4409,6 +4804,7 @@ public class MultiLanguageProperty : IDataElement /// It is recommended to use a global reference. /// public Reference? ValueId { get; set; } + #region Parent and Timestamp [JsonIgnore] public IClass Parent { get; set; } @@ -4418,6 +4814,8 @@ public class MultiLanguageProperty : IDataElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -4429,6 +4827,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -4448,12 +4864,21 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Value, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverValueOrEmpty() + { + return Value + ?? System.Linq.Enumerable.Empty(); } /// @@ -4466,7 +4891,7 @@ public ModelingKind KindOrDefault() } /// - /// Return the or the default value + /// Return the or the default value /// if it has not been set. /// public string CategoryOrDefault() @@ -4474,7 +4899,7 @@ public string CategoryOrDefault() string result = Category ?? "VARIABLE"; #if DEBUG - if (!Verification.DataElementCategoryIsValid( + if (!Constants.ValidCategoriesForDataElement.Contains( result)) { throw new System.InvalidOperationException( @@ -4502,12 +4927,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -4531,9 +4962,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -4541,7 +4972,10 @@ public IEnumerable DescendOnce() if (Value != null) { - yield return Value; + foreach (var anItem in Value) + { + yield return anItem; + } } if (ValueId != null) @@ -4571,23 +5005,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -4630,9 +5070,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -4646,12 +5086,15 @@ public IEnumerable Descend() if (Value != null) { - yield return Value; - - // Recurse - foreach (var anItem in Value.Descend()) + foreach (var anItem in Value) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -4711,15 +5154,15 @@ public MultiLanguageProperty( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, - LangStringSet? value = null, + List? embeddedDataSpecifications = null, + List? value = null, Reference? valueId = null) { Extensions = extensions; @@ -4732,7 +5175,7 @@ public MultiLanguageProperty( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; Value = value; ValueId = valueId; } @@ -4778,38 +5221,53 @@ public class Range : IDataElement /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -4853,24 +5311,23 @@ public class Range : IDataElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Data type of the min und max @@ -4889,9 +5346,10 @@ public class Range : IDataElement /// The maximum value of the range. /// /// - /// If the max value is missing, then the value is assumed to be positive infinite. + /// If the max value is missing, then the value is assumed to be positive infinite. /// public string? Max { get; set; } + #region Parent and Timestamp [JsonIgnore] public IClass Parent { get; set; } @@ -4901,6 +5359,9 @@ public class Range : IDataElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -4912,6 +5373,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -4931,12 +5410,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -4949,7 +5428,7 @@ public ModelingKind KindOrDefault() } /// - /// Return the or the default value + /// Return the or the default value /// if it has not been set. /// public string CategoryOrDefault() @@ -4957,7 +5436,7 @@ public string CategoryOrDefault() string result = Category ?? "VARIABLE"; #if DEBUG - if (!Verification.DataElementCategoryIsValid( + if (!Constants.ValidCategoriesForDataElement.Contains( result)) { throw new System.InvalidOperationException( @@ -4985,12 +5464,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -5014,9 +5499,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -5044,23 +5529,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -5103,9 +5594,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -5163,14 +5654,14 @@ public Range( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, string? min = null, string? max = null) { @@ -5184,7 +5675,7 @@ public Range( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; ValueType = valueType; Min = min; Max = max; @@ -5233,38 +5724,53 @@ public class ReferenceElement : IDataElement /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -5308,24 +5814,23 @@ public class ReferenceElement : IDataElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Global reference to an external object or entity or a logical reference to @@ -5334,7 +5839,7 @@ public class ReferenceElement : IDataElement /// public Reference? Value { get; set; } - #region Parent and timestamp + #region Parent and Timestamp [JsonIgnore] public IClass Parent { get; set; } [JsonIgnore] @@ -5343,6 +5848,9 @@ public class ReferenceElement : IDataElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -5354,6 +5862,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -5373,12 +5899,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -5391,7 +5917,7 @@ public ModelingKind KindOrDefault() } /// - /// Return the or the default value + /// Return the or the default value /// if it has not been set. /// public string CategoryOrDefault() @@ -5399,7 +5925,7 @@ public string CategoryOrDefault() string result = Category ?? "VARIABLE"; #if DEBUG - if (!Verification.DataElementCategoryIsValid( + if (!Constants.ValidCategoriesForDataElement.Contains( result)) { throw new System.InvalidOperationException( @@ -5427,12 +5953,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -5456,9 +5988,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -5491,23 +6023,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -5550,9 +6088,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -5620,14 +6158,14 @@ public ReferenceElement( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, Reference? value = null) { Extensions = extensions; @@ -5640,7 +6178,7 @@ public ReferenceElement( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; Value = value; } } @@ -5686,38 +6224,53 @@ public class Blob : IDataElement /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -5761,24 +6314,23 @@ public class Blob : IDataElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// The value of the instance of a blob data element. @@ -5793,12 +6345,16 @@ public class Blob : IDataElement /// Content type of the content of the . /// /// + /// /// The content type (MIME type) states which file extensions the file can have. - /// + /// + /// /// Valid values are content types like e.g. application/json, application/xls, /// image/jpg. - /// + /// + /// /// The allowed values are defined as in RFC2046. + /// /// public string ContentType { get; set; } @@ -5811,6 +6367,9 @@ public class Blob : IDataElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -5822,6 +6381,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -5841,12 +6418,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -5859,7 +6436,7 @@ public ModelingKind KindOrDefault() } /// - /// Return the or the default value + /// Return the or the default value /// if it has not been set. /// public string CategoryOrDefault() @@ -5867,7 +6444,7 @@ public string CategoryOrDefault() string result = Category ?? "VARIABLE"; #if DEBUG - if (!Verification.DataElementCategoryIsValid( + if (!Constants.ValidCategoriesForDataElement.Contains( result)) { throw new System.InvalidOperationException( @@ -5895,12 +6472,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -5924,9 +6507,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -5954,23 +6537,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -6013,9 +6602,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -6073,14 +6662,14 @@ public Blob( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, byte[]? value = null) { Extensions = extensions; @@ -6093,7 +6682,7 @@ public Blob( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; ContentType = contentType; Value = value; } @@ -6142,38 +6731,53 @@ public class File : IDataElement /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -6217,24 +6821,23 @@ public class File : IDataElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Path and name of the referenced file (with file extension). @@ -6261,6 +6864,9 @@ public class File : IDataElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -6273,32 +6879,50 @@ public IEnumerable OverExtensionsOrEmpty() } /// - /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverSupplementalSemanticIdsOrEmpty() + public IEnumerable OverDisplayNameOrEmpty() { - return SupplementalSemanticIds - ?? System.Linq.Enumerable.Empty(); + return DisplayName + ?? System.Linq.Enumerable.Empty(); } /// - /// Iterate over Qualifiers, if set, and otherwise return an empty enumerable. + /// Iterate over Description, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverQualifiersOrEmpty() + public IEnumerable OverDescriptionOrEmpty() { - return Qualifiers - ?? System.Linq.Enumerable.Empty(); + return Description + ?? System.Linq.Enumerable.Empty(); } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverSupplementalSemanticIdsOrEmpty() { - return DataSpecifications + return SupplementalSemanticIds ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over Qualifiers, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverQualifiersOrEmpty() + { + return Qualifiers + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() + { + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); + } + /// /// Return the or the default value /// if it has not been set. @@ -6309,7 +6933,7 @@ public ModelingKind KindOrDefault() } /// - /// Return the or the default value + /// Return the or the default value /// if it has not been set. /// public string CategoryOrDefault() @@ -6317,7 +6941,7 @@ public string CategoryOrDefault() string result = Category ?? "VARIABLE"; #if DEBUG - if (!Verification.DataElementCategoryIsValid( + if (!Constants.ValidCategoriesForDataElement.Contains( result)) { throw new System.InvalidOperationException( @@ -6345,12 +6969,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -6374,9 +7004,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -6404,23 +7034,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -6463,9 +7099,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -6523,14 +7159,14 @@ public File( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, string? value = null) { Extensions = extensions; @@ -6543,7 +7179,7 @@ public File( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; ContentType = contentType; Value = value; } @@ -6590,38 +7226,53 @@ public class AnnotatedRelationshipElement : IRelationshipElement /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -6665,24 +7316,23 @@ public class AnnotatedRelationshipElement : IRelationshipElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Reference to the first element in the relationship taking the role of the subject. @@ -6709,6 +7359,9 @@ public class AnnotatedRelationshipElement : IRelationshipElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -6720,6 +7373,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -6739,12 +7410,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -6781,12 +7452,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -6810,9 +7487,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -6852,23 +7529,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -6911,9 +7594,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -7002,14 +7685,14 @@ public AnnotatedRelationshipElement( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, List? annotations = null) { Extensions = extensions; @@ -7022,7 +7705,7 @@ public AnnotatedRelationshipElement( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; First = first; Second = second; Annotations = annotations; @@ -7057,14 +7740,16 @@ public enum EntityType /// An entity is a submodel element that is used to model entities. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-014: /// Either the attribute or /// of an must be set if is set to /// . They are not existing otherwise. - ///
  • + /// ///
///
public class Entity : ISubmodelElement @@ -7104,38 +7789,53 @@ public class Entity : ISubmodelElement /// Display name. Can be provided in several languages. ///
/// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -7179,24 +7879,23 @@ public class Entity : ISubmodelElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Describes statements applicable to the entity by a set of submodel elements, @@ -7232,6 +7931,9 @@ public class Entity : ISubmodelElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -7243,6 +7945,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -7262,12 +7982,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -7304,12 +8024,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -7333,9 +8059,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -7381,23 +8107,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -7440,9 +8172,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -7536,14 +8268,14 @@ public Entity( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, List? statements = null, Reference? globalAssetId = null, SpecificAssetId? specificAssetId = null) @@ -7558,7 +8290,7 @@ public Entity( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; Statements = statements; EntityType = entityType; GlobalAssetId = globalAssetId; @@ -7574,13 +8306,13 @@ public enum Direction /// /// Input direction. /// - [EnumMember(Value = "INPUT")] + [EnumMember(Value = "input")] Input, /// /// Output direction /// - [EnumMember(Value = "OUTPUT")] + [EnumMember(Value = "output")] Output } @@ -7592,13 +8324,13 @@ public enum StateOfEvent /// /// Event is on /// - [EnumMember(Value = "ON")] + [EnumMember(Value = "on")] On, /// /// Event is off. /// - [EnumMember(Value = "OFF")] + [EnumMember(Value = "off")] Off } @@ -7854,38 +8586,53 @@ public class BasicEventElement : IEventElement /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -7929,24 +8676,23 @@ public class BasicEventElement : IEventElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Reference to the , which defines the scope of the event. @@ -8005,10 +8751,13 @@ public class BasicEventElement : IEventElement /// the respective Referable can handle input events. /// /// + /// /// For output events, specifies the maximum frequency of outputting this event to /// an outer infrastructure. - /// + /// + /// /// Might be not specified, that is, there is no minimum interval. + /// /// public string? MinInterval { get; set; } @@ -8016,11 +8765,14 @@ public class BasicEventElement : IEventElement /// For input direction: not applicable. ///
/// + /// /// For output direction: maximum interval in time, the respective Referable shall send /// an update of the status of the event, even if no other trigger condition for /// the event was not met. - /// + /// + /// /// Might be not specified, that is, there is no maximum interval + /// /// public string? MaxInterval { get; set; } @@ -8033,6 +8785,9 @@ public class BasicEventElement : IEventElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -8044,6 +8799,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -8063,12 +8836,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -8096,12 +8869,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -8125,9 +8904,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -8162,23 +8941,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -8221,9 +9006,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -8302,14 +9087,14 @@ public BasicEventElement( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, string? messageTopic = null, Reference? messageBroker = null, string? lastUpdate = null, @@ -8326,7 +9111,7 @@ public BasicEventElement( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; Observed = observed; Direction = direction; State = state; @@ -8378,38 +9163,53 @@ public class Operation : ISubmodelElement /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -8453,24 +9253,23 @@ public class Operation : ISubmodelElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Input parameter of the operation. @@ -8496,6 +9295,9 @@ public class Operation : ISubmodelElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -8507,6 +9309,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -8526,12 +9346,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -8586,12 +9406,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -8615,9 +9441,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -8669,23 +9495,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -8728,9 +9560,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -8829,14 +9661,14 @@ public Operation( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, List? inputVariables = null, List? outputVariables = null, List? inoutputVariables = null) @@ -8851,7 +9683,7 @@ public Operation( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; InputVariables = inputVariables; OutputVariables = outputVariables; InoutputVariables = inoutputVariables; @@ -8983,38 +9815,53 @@ public class Capability : ISubmodelElement /// Display name. Can be provided in several languages. /// /// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -9058,24 +9905,23 @@ public class Capability : ISubmodelElement /// Additional qualification of a qualifiable element. /// /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-021: /// Every qualifiable can only have one qualifier with the same /// . - ///
  • + /// ///
///
public List? Qualifiers { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } #region Parent and Timestamp [JsonIgnore] @@ -9086,6 +9932,9 @@ public class Capability : ISubmodelElement public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -9097,6 +9946,24 @@ public IEnumerable OverExtensionsOrEmpty() ?? System.Linq.Enumerable.Empty(); } + /// + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDisplayNameOrEmpty() + { + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + /// /// Iterate over SupplementalSemanticIds, if set, and otherwise return an empty enumerable. /// @@ -9116,12 +9983,12 @@ public IEnumerable OverQualifiersOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -9149,12 +10016,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (SemanticId != null) @@ -9178,9 +10051,9 @@ public IEnumerable DescendOnce() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -9208,23 +10081,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } if (Description != null) { - yield return Description; - - // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -9267,9 +10146,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -9326,14 +10205,14 @@ public Capability( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, ModelingKind? kind = null, Reference? semanticId = null, List? supplementalSemanticIds = null, List? qualifiers = null, - List? dataSpecifications = null) + List? embeddedDataSpecifications = null) { Extensions = extensions; IdShort = idShort; @@ -9345,7 +10224,7 @@ public Capability( SemanticId = semanticId; SupplementalSemanticIds = supplementalSemanticIds; Qualifiers = qualifiers; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; } } @@ -9354,20 +10233,69 @@ public Capability( /// is defined by a concept description. /// /// + /// /// The description of the concept should follow a standardized schema (realized as /// data specification template). - /// + /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • + /// /// Constraint AASd-051: /// A shall have one of the following categories /// VALUE, PROPERTY, REFERENCE, DOCUMENT, CAPABILITY, /// RELATIONSHIP, COLLECTION, FUNCTION, EVENT, ENTITY, /// APPLICATION_CLASS, QUALIFIER, VIEW. - /// + /// + /// /// Default: PROPERTY. - ///
  • + /// + /// + ///
  • + /// Constraint AASc-004: + /// For a with PROPERTY or + /// VALUE using data specification IEC61360, + /// the is mandatory and shall be + /// one of: DATE, STRING, STRING_TRANSLATABLE, INTEGER_MEASURE, + /// INTEGER_COUNT, INTEGER_CURRENCY, REAL_MEASURE, REAL_COUNT, + /// REAL_CURRENCY, BOOLEAN, RATIONAL, RATIONAL_MEASURE, + /// TIME, TIMESTAMP. + ///
  • + ///
  • + /// Constraint AASc-005: + /// For a with REFERENCE + /// using data specification IEC61360, + /// the is mandatory and shall be + /// one of: STRING, IRI, IRDI. + ///
  • + ///
  • + /// Constraint AASc-006: + /// For a with DOCUMENT + /// using data specification IEC61360, + /// the is mandatory and shall be + /// defined. + ///
  • + ///
  • + /// Constraint AASc-007: + /// For a with QUALIFIER_TYPE + /// using data specification IEC61360, + /// the is mandatory and shall be + ///
  • + ///
  • + /// Constraint AASc-008: + /// For all 's with a category except + /// VALUE using data specification IEC61360, + /// is mandatory and shall be + /// defined at least in English. + ///
  • + ///
  • + /// Constraint AASc-003: + /// For a with VALUE + /// using data specification IEC61360, + /// the shall be set. + ///
  • ///
///
public class ConceptDescription : @@ -9409,38 +10337,53 @@ public class ConceptDescription : /// Display name. Can be provided in several languages. ///
/// + /// /// If no display name is defined in the language requested by the application, /// then the display name is selected in the following order if available: - /// + /// ///
    - ///
  • the preferred name in the requested language of the concept description defining - /// the semantics of the element
  • - ///
  • If there is a default language list defined in the application, - /// then the corresponding preferred name in the language is chosen - /// according to this order.
  • - ///
  • the English preferred name of the concept description defining - /// the semantics of the element
  • - ///
  • the short name of the concept description
  • - ///
  • the of the element
  • + ///
  • + /// the preferred name in the requested language of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// If there is a default language list defined in the application, + /// then the corresponding preferred name in the language is chosen + /// according to this order. + ///
  • + ///
  • + /// the English preferred name of the concept description defining + /// the semantics of the element + ///
  • + ///
  • + /// the short name of the concept description + ///
  • + ///
  • + /// the of the element + ///
  • ///
///
- public LangStringSet? DisplayName { get; set; } + public List? DisplayName { get; set; } /// /// Description or comments on the element. /// /// + /// /// The description can be provided in several languages. - /// + /// + /// /// If no description is defined, then the definition of the concept /// description that defines the semantics of the element is used. - /// + /// + /// /// Additional information can be provided, e.g., if the element is /// qualified and which qualifier types can be expected in which /// context or which additional data specification templates are /// provided. + /// /// - public LangStringSet? Description { get; set; } + public List? Description { get; set; } /// /// Checksum to be used to determine if an Referable (including its @@ -9469,21 +10412,21 @@ public class ConceptDescription : public string Id { get; set; } /// - /// Global reference to the data specification template used by the element. + /// Embedded data specification. /// - /// - /// This is a global reference. - /// - public List? DataSpecifications { get; set; } + public List? EmbeddedDataSpecifications { get; set; } /// /// Reference to an external definition the concept is compatible to or was derived /// from. /// /// + /// /// It is recommended to use a global reference. - /// + /// + /// /// Compare to is-case-of relationship in ISO 13584-32 & IEC EN 61360" + /// /// public List? IsCaseOf { get; set; } @@ -9496,6 +10439,9 @@ public class ConceptDescription : public DateTime TimeStamp { get; set; } [JsonIgnore] public DateTime TimeStampTree { get; set; } + + public DiaryDataDef DiaryData { get; set; } + #endregion /// @@ -9508,12 +10454,30 @@ public IEnumerable OverExtensionsOrEmpty() } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over DisplayName, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverDisplayNameOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return DisplayName + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over Description, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverDescriptionOrEmpty() + { + return Description + ?? System.Linq.Enumerable.Empty(); + } + + /// + /// Iterate over EmbeddedDataSpecifications, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverEmbeddedDataSpecificationsOrEmpty() + { + return EmbeddedDataSpecifications + ?? System.Linq.Enumerable.Empty(); } /// @@ -9534,7 +10498,7 @@ public string CategoryOrDefault() string result = Category ?? "PROPERTY"; #if DEBUG - if (!Verification.ConceptDescriptionCategoryIsValid( + if (!Constants.ValidCategoriesForConceptDescription.Contains( result)) { throw new System.InvalidOperationException( @@ -9562,12 +10526,18 @@ public IEnumerable DescendOnce() if (DisplayName != null) { - yield return DisplayName; + foreach (var anItem in DisplayName) + { + yield return anItem; + } } if (Description != null) { - yield return Description; + foreach (var anItem in Description) + { + yield return anItem; + } } if (Administration != null) @@ -9575,9 +10545,9 @@ public IEnumerable DescendOnce() yield return Administration; } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; } @@ -9613,23 +10583,29 @@ public IEnumerable Descend() if (DisplayName != null) { - yield return DisplayName; - - // Recurse - foreach (var anItem in DisplayName.Descend()) + foreach (var anItem in DisplayName) { yield return anItem; - } - } - if (Description != null) - { - yield return Description; + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } + } + } - // Recurse - foreach (var anItem in Description.Descend()) + if (Description != null) + { + foreach (var anItem in Description) { yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } } } @@ -9644,9 +10620,9 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (EmbeddedDataSpecifications != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in EmbeddedDataSpecifications) { yield return anItem; @@ -9718,22 +10694,22 @@ public ConceptDescription( List? extensions = null, string? category = null, string? idShort = null, - LangStringSet? displayName = null, - LangStringSet? description = null, + List? displayName = null, + List? description = null, string? checksum = null, AdministrativeInformation? administration = null, - List? dataSpecifications = null, + List? embeddedDataSpecifications = null, List? isCaseOf = null) { Extensions = extensions; IdShort = idShort; DisplayName = displayName; - Category = category; + Category = category; Description = description; Checksum = checksum; Id = id; Administration = administration; - DataSpecifications = dataSpecifications; + EmbeddedDataSpecifications = embeddedDataSpecifications; IsCaseOf = isCaseOf; } } @@ -9761,82 +10737,93 @@ public enum ReferenceTypes /// entity. /// /// + /// /// A reference is an ordered list of keys. - /// + /// + /// /// A model reference is an ordered list of keys, each key referencing an element. The /// complete list of keys may for example be concatenated to a path that then gives /// unique access to an element. - /// + /// + /// /// A global reference is a reference to an external entity. - /// + /// + /// /// Constraints: + /// ///
    - ///
  • + ///
  • /// Constraint AASd-121: /// For 's the of the first key of - /// shall be one of . - ///
  • - ///
  • + /// shall be one of . + ///
  • + ///
  • /// Constraint AASd-122: /// For global references, i.e. 's with /// = , the type /// of the first key of shall be one of - /// . - ///
  • - ///
  • + /// . + ///
  • + ///
  • /// Constraint AASd-123: /// For model references, i.e. 's with /// = , the type /// of the first key of shall be one of - /// . - ///
  • - ///
  • + /// . + ///
  • + ///
  • /// Constraint AASd-124: /// For global references, i.e. 's with /// = , the last /// key of shall be either one of - /// or one of - /// . - ///
  • - ///
  • + /// or one of + /// . + ///
  • + ///
  • + /// /// Constraint AASd-125: /// For model references, i.e. 's with /// = , with more /// than one key in the type of the keys following the first - /// key of shall be one of . - /// + /// key of shall be one of . + /// + /// /// Constraint AASd-125 ensures that the shortest path is used. - ///
  • - ///
  • + /// + ///
  • + ///
  • /// Constraint AASd-126: /// For model references, i.e. 's with /// = , with more /// than one key in the type of the last key in the - /// reference key chain may be one of or no key - /// at all shall have a value out of . - ///
  • - ///
  • + /// reference key chain may be one of or no key + /// at all shall have a value out of . + ///
  • + ///
  • + /// /// Constraint AASd-127: /// For model references, i.e. 's with /// = , with more /// than one key in a key with /// shall be preceded by a key with /// or . All other - /// AAS fragments, i.e. type values out of , do not - /// support fragments. - /// + /// AAS fragments, i.e. type values out of , + /// do not support fragments. + /// + /// /// Which kind of fragments are supported depends on the content type and the - /// specification of allowed fragment identifiers for the corrsponding resource + /// specification of allowed fragment identifiers for the corresponding resource /// being referenced via the reference. - ///
  • - ///
  • + /// + ///
  • + ///
  • /// Constraint AASd-128: /// For model references, i.e. 's with /// = , the /// of a preceded by a with /// = is an integer /// number denoting the position in the array of the submodel element list. - ///
  • + /// ///
///
public class Reference : IClass @@ -9854,9 +10841,12 @@ public class Reference : IClass /// ( = ). ///
/// + /// /// For global references there typically is no semantic ID. - /// + /// + /// /// It is recommended to use a global reference. + /// /// public Reference? ReferredSemanticId { get; set; } @@ -9970,12 +10960,15 @@ public class Key : IClass /// Denotes which kind of entity is referenced. ///
/// + /// /// In case = the key represents /// a bookmark or a similar local identifier within its parent element as specified /// by the key that precedes this key. - /// + /// + /// /// In all other cases the key references a model element of the same or of another AAS. /// The name of the model element is explicitly listed. + /// /// public KeyTypes Type { get; set; } @@ -10053,34 +11046,35 @@ public Key( } /// - /// Enumeration of all identifiable elements within an asset administration shell. + /// Enumeration of different key value types within a key. /// - public enum GenericFragmentKeys + public enum KeyTypes { /// - /// Bookmark or a similar local identifier of a subordinate part of a primary resource + /// Bookmark or a similar local identifier of a subordinate part of + /// a primary resource /// [EnumMember(Value = "FragmentReference")] - FragmentReference - } + FragmentReference, - /// - /// Enumeration of different key value types within a key. - /// - public enum GenericGloballyIdentifiables - { [EnumMember(Value = "GlobalReference")] - GlobalReference - } + GlobalReference, + + [EnumMember(Value = "AnnotatedRelationshipElement")] + AnnotatedRelationshipElement, - /// - /// Enumeration of different key value types within a key. - /// - public enum AasIdentifiables - { [EnumMember(Value = "AssetAdministrationShell")] AssetAdministrationShell, + [EnumMember(Value = "BasicEventElement")] + BasicEventElement, + + [EnumMember(Value = "Blob")] + Blob, + + [EnumMember(Value = "Capability")] + Capability, + [EnumMember(Value = "ConceptDescription")] ConceptDescription, @@ -10094,33 +11088,12 @@ public enum AasIdentifiables [EnumMember(Value = "Identifiable")] Identifiable, - [EnumMember(Value = "Submodel")] - Submodel - } - - /// - /// Enumeration of all referable elements within an asset administration shell. - /// - public enum AasSubmodelElements - { - [EnumMember(Value = "AnnotatedRelationshipElement")] - AnnotatedRelationshipElement, - - [EnumMember(Value = "BasicEventElement")] - BasicEventElement, - - [EnumMember(Value = "Blob")] - Blob, - - [EnumMember(Value = "Capability")] - Capability, - /// - /// Data Element. + /// Data element. /// /// - /// Data Element is abstract, i.e. if a key uses - /// the reference may be a , a etc. + /// Data Element is abstract, i.e. if a key uses + /// the reference may be a Property, a File etc. /// [EnumMember(Value = "DataElement")] DataElement, @@ -10129,7 +11102,7 @@ public enum AasSubmodelElements Entity, /// - /// Event element + /// Event. /// /// /// is abstract. @@ -10164,19 +11137,24 @@ public enum AasSubmodelElements [EnumMember(Value = "ReferenceElement")] ReferenceElement, + [EnumMember(Value = "Referable")] + Referable, + /// /// Relationship /// [EnumMember(Value = "RelationshipElement")] RelationshipElement, + [EnumMember(Value = "Submodel")] + Submodel, + /// /// Submodel Element /// /// - /// Submodel Element is abstract, i.e. if a key uses - /// the reference may be a , - /// a , an etc. + /// Submodel Element is abstract, i.e. if a key uses + /// the reference may be a , an etc. /// [EnumMember(Value = "SubmodelElement")] SubmodelElement, @@ -10195,739 +11173,256 @@ public enum AasSubmodelElements } /// - /// Enumeration of different fragment key value types within a key. + /// Enumeration listing all xsd anySimpleTypes /// - public enum AasReferableNonIdentifiables + public enum DataTypeDefXsd { - [EnumMember(Value = "AnnotatedRelationshipElement")] - AnnotatedRelationshipElement, + [EnumMember(Value = "xs:anyURI")] + AnyUri, - [EnumMember(Value = "BasicEventElement")] - BasicEventElement, + [EnumMember(Value = "xs:base64Binary")] + Base64Binary, - [EnumMember(Value = "Blob")] - Blob, + [EnumMember(Value = "xs:boolean")] + Boolean, - [EnumMember(Value = "Capability")] - Capability, + [EnumMember(Value = "xs:date")] + Date, - /// - /// Data Element. - /// - /// - /// Data Element is abstract, i.e. if a key uses - /// the reference may be a , a etc. - /// - [EnumMember(Value = "DataElement")] - DataElement, + [EnumMember(Value = "xs:dateTime")] + DateTime, - [EnumMember(Value = "Entity")] - Entity, + [EnumMember(Value = "xs:dateTimeStamp")] + DateTimeStamp, - /// - /// Event element - /// - /// - /// is abstract. - /// - [EnumMember(Value = "EventElement")] - EventElement, + [EnumMember(Value = "xs:decimal")] + Decimal, - [EnumMember(Value = "File")] - File, + [EnumMember(Value = "xs:double")] + Double, - /// - /// Property with a value that can be provided in multiple languages - /// - [EnumMember(Value = "MultiLanguageProperty")] - MultiLanguageProperty, + [EnumMember(Value = "xs:duration")] + Duration, - [EnumMember(Value = "Operation")] - Operation, + [EnumMember(Value = "xs:float")] + Float, - [EnumMember(Value = "Property")] - Property, + [EnumMember(Value = "xs:gDay")] + GDay, - /// - /// Range with min and max - /// - [EnumMember(Value = "Range")] - Range, + [EnumMember(Value = "xs:gMonth")] + GMonth, - /// - /// Reference - /// - [EnumMember(Value = "ReferenceElement")] - ReferenceElement, + [EnumMember(Value = "xs:gMonthDay")] + GMonthDay, - /// - /// Relationship - /// - [EnumMember(Value = "RelationshipElement")] - RelationshipElement, + [EnumMember(Value = "xs:gYear")] + GYear, - /// - /// Submodel Element - /// - /// - /// Submodel Element is abstract, i.e. if a key uses - /// the reference may be a , - /// a , an etc. - /// - [EnumMember(Value = "SubmodelElement")] - SubmodelElement, + [EnumMember(Value = "xs:gYearMonth")] + GYearMonth, - /// - /// Struct of Submodel Elements - /// - [EnumMember(Value = "SubmodelElementCollection")] - SubmodelElementCollection, + [EnumMember(Value = "xs:hexBinary")] + HexBinary, - /// - /// List of Submodel Elements - /// - [EnumMember(Value = "SubmodelElementList")] - SubmodelElementList - } + [EnumMember(Value = "xs:string")] + String, - /// - /// Enumeration of referables. - /// - public enum AasReferables - { - /// - /// Referable - /// - /// - /// Referable is abstract, i.e. if a key uses “Referable” the reference - /// may be an Asset Administration Shell, a Property etc - /// - [EnumMember(Value = "Referable")] - Referable, + [EnumMember(Value = "xs:time")] + Time, - [EnumMember(Value = "AssetAdministrationShell")] - AssetAdministrationShell, + [EnumMember(Value = "xs:dayTimeDuration")] + DayTimeDuration, - [EnumMember(Value = "ConceptDescription")] - ConceptDescription, + [EnumMember(Value = "xs:yearMonthDuration")] + YearMonthDuration, - /// - /// Identifiable. - /// - /// - /// 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 = "xs:integer")] + Integer, - [EnumMember(Value = "Submodel")] - Submodel, + [EnumMember(Value = "xs:long")] + Long, - [EnumMember(Value = "AnnotatedRelationshipElement")] - AnnotatedRelationshipElement, + [EnumMember(Value = "xs:int")] + Int, - [EnumMember(Value = "BasicEventElement")] - BasicEventElement, + [EnumMember(Value = "xs:short")] + Short, - [EnumMember(Value = "Blob")] - Blob, + [EnumMember(Value = "xs:byte")] + Byte, - [EnumMember(Value = "Capability")] - Capability, + [EnumMember(Value = "xs:nonNegativeInteger")] + NonNegativeInteger, - /// - /// Data Element. - /// - /// - /// Data Element is abstract, i.e. if a key uses - /// the reference may be a , a etc. - /// - [EnumMember(Value = "DataElement")] - DataElement, + [EnumMember(Value = "xs:positiveInteger")] + PositiveInteger, - [EnumMember(Value = "Entity")] - Entity, + [EnumMember(Value = "xs:unsignedLong")] + UnsignedLong, - /// - /// Event element - /// - /// - /// is abstract. - /// - [EnumMember(Value = "EventElement")] - EventElement, + [EnumMember(Value = "xs:unsignedInt")] + UnsignedInt, - [EnumMember(Value = "File")] - File, + [EnumMember(Value = "xs:unsignedShort")] + UnsignedShort, - /// - /// Property with a value that can be provided in multiple languages - /// - [EnumMember(Value = "MultiLanguageProperty")] - MultiLanguageProperty, - - [EnumMember(Value = "Operation")] - Operation, - - [EnumMember(Value = "Property")] - Property, - - /// - /// Range with min and max - /// - [EnumMember(Value = "Range")] - Range, - - /// - /// Reference - /// - [EnumMember(Value = "ReferenceElement")] - ReferenceElement, - - /// - /// Relationship - /// - [EnumMember(Value = "RelationshipElement")] - RelationshipElement, - - /// - /// Submodel Element - /// - /// - /// Submodel Element is abstract, i.e. if a key uses - /// the reference may be a , - /// a , an etc. - /// - [EnumMember(Value = "SubmodelElement")] - SubmodelElement, - - /// - /// Struct of Submodel Elements - /// - [EnumMember(Value = "SubmodelElementCollection")] - SubmodelElementCollection, - - /// - /// List of Submodel Elements - /// - [EnumMember(Value = "SubmodelElementList")] - SubmodelElementList - } - - /// - /// Enumeration of all referable elements within an asset administration shell - /// - public enum GloballyIdentifiables - { - [EnumMember(Value = "GlobalReference")] - GlobalReference, - - [EnumMember(Value = "AssetAdministrationShell")] - AssetAdministrationShell, - - [EnumMember(Value = "ConceptDescription")] - ConceptDescription, + [EnumMember(Value = "xs:unsignedByte")] + UnsignedByte, - /// - /// Identifiable. - /// - /// - /// 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 = "xs:nonPositiveInteger")] + NonPositiveInteger, - [EnumMember(Value = "Submodel")] - Submodel + [EnumMember(Value = "xs:negativeInteger")] + NegativeInteger } /// - /// Enumeration of different key value types within a key. + /// Strings with language tags /// - public enum FragmentKeys + public class LangString : IClass { /// - /// Bookmark or a similar local identifier of a subordinate part of - /// a primary resource - /// - [EnumMember(Value = "FragmentReference")] - FragmentReference, - - [EnumMember(Value = "AnnotatedRelationshipElement")] - AnnotatedRelationshipElement, - - [EnumMember(Value = "AssetAdministrationShell")] - AssetAdministrationShell, - - [EnumMember(Value = "BasicEventElement")] - BasicEventElement, - - [EnumMember(Value = "Blob")] - Blob, - - [EnumMember(Value = "Capability")] - Capability, - - [EnumMember(Value = "ConceptDescription")] - ConceptDescription, - - /// - /// Data element. + /// Language tag conforming to BCP 47 /// - /// - /// 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 = "Entity")] - Entity, + public string Language { get; set; } /// - /// Event. + /// Text in the /// - /// - /// is abstract. - /// - [EnumMember(Value = "EventElement")] - EventElement, - - [EnumMember(Value = "File")] - File, + public string Text { get; set; } /// - /// Property with a value that can be provided in multiple languages + /// Iterate over all the class instances referenced from this instance + /// without further recursion. /// - [EnumMember(Value = "MultiLanguageProperty")] - MultiLanguageProperty, - - [EnumMember(Value = "Operation")] - Operation, - - [EnumMember(Value = "Property")] - Property, + public IEnumerable DescendOnce() + { + // No descendable properties + yield break; + } /// - /// Range with min and max + /// Iterate recursively over all the class instances referenced from this instance. /// - [EnumMember(Value = "Range")] - Range, + public IEnumerable Descend() + { + // No descendable properties + yield break; + } /// - /// Reference + /// Accept the to visit this instance + /// for double dispatch. /// - [EnumMember(Value = "ReferenceElement")] - ReferenceElement, + public void Accept(Visitation.IVisitor visitor) + { + visitor.Visit(this); + } /// - /// Relationship + /// Accept the visitor to visit this instance for double dispatch + /// with the . /// - [EnumMember(Value = "RelationshipElement")] - RelationshipElement, - - [EnumMember(Value = "Submodel")] - Submodel, + public void Accept( + Visitation.IVisitorWithContext visitor, + TContext context) + { + visitor.Visit(this, context); + } /// - /// Submodel Element + /// Accept the to transform this instance + /// for double dispatch. /// - /// - /// Submodel Element is abstract, i.e. if a key uses - /// the reference may be a , an etc. - /// - [EnumMember(Value = "SubmodelElement")] - SubmodelElement, + public T Transform(Visitation.ITransformer transformer) + { + return transformer.Transform(this); + } /// - /// List of Submodel Elements + /// Accept the to visit this instance + /// for double dispatch with the . /// - [EnumMember(Value = "SubmodelElementList")] - SubmodelElementList, + public T Transform( + Visitation.ITransformerWithContext transformer, + TContext context) + { + return transformer.Transform(this, context); + } - /// - /// Struct of Submodel Elements - /// - [EnumMember(Value = "SubmodelElementCollection")] - SubmodelElementCollection + public LangString( + string language, + string text) + { + Language = language; + Text = text; + } } /// - /// Enumeration of different key value types within a key. + /// Container for the sets of different identifiables. /// - public enum KeyTypes + /// + /// w.r.t. file exchange: There is exactly one environment independent on how many + /// 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 class Environment : IClass, IDiaryData { /// - /// Bookmark or a similar local identifier of a subordinate part of - /// a primary resource + /// Asset administration shell /// - [EnumMember(Value = "FragmentReference")] - FragmentReference, - - [EnumMember(Value = "GlobalReference")] - GlobalReference, - - [EnumMember(Value = "AnnotatedRelationshipElement")] - AnnotatedRelationshipElement, + public List? AssetAdministrationShells { get; set; } - [EnumMember(Value = "AssetAdministrationShell")] - AssetAdministrationShell, + /// + /// Submodel + /// + public List? Submodels { get; set; } - [EnumMember(Value = "BasicEventElement")] - BasicEventElement, + /// + /// Concept description + /// + public List? ConceptDescriptions { get; set; } - [EnumMember(Value = "Blob")] - Blob, + #region Parent and Timestamp + [JsonIgnore] + public IClass Parent { get; set; } + [JsonIgnore] + public DateTime TimeStampCreate { get; set; } + [JsonIgnore] + public DateTime TimeStamp { get; set; } - [EnumMember(Value = "Capability")] - Capability, + public DiaryDataDef DiaryData { get; set; } - [EnumMember(Value = "ConceptDescription")] - ConceptDescription, + #endregion /// - /// Identifiable. + /// Iterate over AssetAdministrationShells, if set, and otherwise return an empty enumerable. /// - /// - /// 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, - - /// - /// Data element. - /// - /// - /// 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 = "Entity")] - Entity, - - /// - /// Event. - /// - /// - /// is abstract. - /// - [EnumMember(Value = "EventElement")] - EventElement, - - [EnumMember(Value = "File")] - File, - - /// - /// Property with a value that can be provided in multiple languages - /// - [EnumMember(Value = "MultiLanguageProperty")] - MultiLanguageProperty, - - [EnumMember(Value = "Operation")] - Operation, - - [EnumMember(Value = "Property")] - Property, - - /// - /// Range with min and max - /// - [EnumMember(Value = "Range")] - Range, - - [EnumMember(Value = "Referable")] - Referable, - - /// - /// Reference - /// - [EnumMember(Value = "ReferenceElement")] - ReferenceElement, - - /// - /// Relationship - /// - [EnumMember(Value = "RelationshipElement")] - RelationshipElement, - - [EnumMember(Value = "Submodel")] - Submodel, - - /// - /// Submodel Element - /// - /// - /// Submodel Element is abstract, i.e. if a key uses - /// the reference may be a , an etc. - /// - [EnumMember(Value = "SubmodelElement")] - SubmodelElement, - - /// - /// List of Submodel Elements - /// - [EnumMember(Value = "SubmodelElementList")] - SubmodelElementList, - - /// - /// Struct of Submodel Elements - /// - [EnumMember(Value = "SubmodelElementCollection")] - SubmodelElementCollection - } - - /// - /// Enumeration listing all xsd anySimpleTypes - /// - public enum DataTypeDefXsd - { - [EnumMember(Value = "xs:anyURI")] - AnyUri, - - [EnumMember(Value = "xs:base64Binary")] - Base64Binary, - - [EnumMember(Value = "xs:boolean")] - Boolean, - - [EnumMember(Value = "xs:date")] - Date, - - [EnumMember(Value = "xs:dateTime")] - DateTime, - - [EnumMember(Value = "xs:dateTimeStamp")] - DateTimeStamp, - - [EnumMember(Value = "xs:decimal")] - Decimal, - - [EnumMember(Value = "xs:double")] - Double, - - [EnumMember(Value = "xs:duration")] - Duration, - - [EnumMember(Value = "xs:float")] - Float, - - [EnumMember(Value = "xs:gDay")] - GDay, - - [EnumMember(Value = "xs:gMonth")] - GMonth, - - [EnumMember(Value = "xs:gMonthDay")] - GMonthDay, - - [EnumMember(Value = "xs:gYear")] - GYear, - - [EnumMember(Value = "xs:gYearMonth")] - GYearMonth, - - [EnumMember(Value = "xs:hexBinary")] - HexBinary, - - [EnumMember(Value = "xs:string")] - String, - - [EnumMember(Value = "xs:time")] - Time, - - [EnumMember(Value = "xs:dayTimeDuration")] - DayTimeDuration, - - [EnumMember(Value = "xs:yearMonthDuration")] - YearMonthDuration, - - [EnumMember(Value = "xs:integer")] - Integer, - - [EnumMember(Value = "xs:long")] - Long, - - [EnumMember(Value = "xs:int")] - Int, - - [EnumMember(Value = "xs:short")] - Short, - - [EnumMember(Value = "xs:byte")] - Byte, - - [EnumMember(Value = "xs:NonNegativeInteger")] - NonNegativeInteger, - - [EnumMember(Value = "xs:positiveInteger")] - PositiveInteger, - - [EnumMember(Value = "xs:unsignedLong")] - UnsignedLong, - - [EnumMember(Value = "xs:unsignedInt")] - UnsignedInt, - - [EnumMember(Value = "xs:unsignedShort")] - UnsignedShort, - - [EnumMember(Value = "xs:unsignedByte")] - UnsignedByte, - - [EnumMember(Value = "xs:nonPositiveInteger")] - NonPositiveInteger, - - [EnumMember(Value = "xs:negativeInteger")] - NegativeInteger - } - - /// - /// Enumeration listing all RDF types - /// - public enum DataTypeDefRdf - { - /// - /// String with a language tag - /// - /// - /// RDF requires IETF BCP 47 language tags, i.e. simple two-letter language tags - /// for Locales like “de” conformant to ISO 639-1 are allowed as well as language - /// tags plus extension like “de-DE” for country code, dialect etc. like in “en-US” - /// or “en-GB” for English (United Kingdom) and English (United States). - /// IETF language tags are referencing ISO 639, ISO 3166 and ISO 15924. - /// - [EnumMember(Value = "rdf:langString")] - LangString - } - - /// - /// string with values of enumerations , - /// - /// - public enum DataTypeDef - { - [EnumMember(Value = "xs:anyURI")] - AnyUri, - - [EnumMember(Value = "xs:base64Binary")] - Base64Binary, - - [EnumMember(Value = "xs:boolean")] - Boolean, - - [EnumMember(Value = "xs:date")] - Date, - - [EnumMember(Value = "xs:dateTime")] - DateTime, - - [EnumMember(Value = "xs:dateTimeStamp")] - DateTimeStamp, - - [EnumMember(Value = "xs:decimal")] - Decimal, - - [EnumMember(Value = "xs:double")] - Double, - - [EnumMember(Value = "xs:duration")] - Duration, - - [EnumMember(Value = "xs:float")] - Float, - - [EnumMember(Value = "xs:gDay")] - GDay, - - [EnumMember(Value = "xs:gMonth")] - GMonth, - - [EnumMember(Value = "xs:gMonthDay")] - GMonthDay, - - [EnumMember(Value = "xs:gYear")] - GYear, - - [EnumMember(Value = "xs:gYearMonth")] - GYearMonth, - - [EnumMember(Value = "xs:hexBinary")] - HexBinary, - - [EnumMember(Value = "xs:string")] - String, - - [EnumMember(Value = "xs:time")] - Time, - - [EnumMember(Value = "xs:dayTimeDuration")] - DayTimeDuration, - - [EnumMember(Value = "xs:yearMonthDuration")] - YearMonthDuration, - - [EnumMember(Value = "xs:integer")] - Integer, - - [EnumMember(Value = "xs:long")] - Long, - - [EnumMember(Value = "xs:int")] - Int, - - [EnumMember(Value = "xs:short")] - Short, - - [EnumMember(Value = "xs:byte")] - Byte, - - [EnumMember(Value = "xs:NonNegativeInteger")] - NonNegativeInteger, - - [EnumMember(Value = "xs:positiveInteger")] - PositiveInteger, - - [EnumMember(Value = "xs:unsignedLong")] - UnsignedLong, - - [EnumMember(Value = "xs:unsignedInt")] - UnsignedInt, - - [EnumMember(Value = "xs:unsignedShort")] - UnsignedShort, - - [EnumMember(Value = "xs:unsignedByte")] - UnsignedByte, - - [EnumMember(Value = "xs:nonPositiveInteger")] - NonPositiveInteger, - - [EnumMember(Value = "xs:negativeInteger")] - NegativeInteger, - - [EnumMember(Value = "rdf:langString")] - LangString - } + public IEnumerable OverAssetAdministrationShellsOrEmpty() + { + return AssetAdministrationShells + ?? System.Linq.Enumerable.Empty(); + } - /// - /// Strings with language tags - /// - public class LangString : IClass - { /// - /// Language tag conforming to BCP 47 + /// Iterate over Submodels, if set, and otherwise return an empty enumerable. /// - public string Language { get; set; } + public IEnumerable OverSubmodelsOrEmpty() + { + return Submodels + ?? System.Linq.Enumerable.Empty(); + } /// - /// Text in the + /// Iterate over ConceptDescriptions, if set, and otherwise return an empty enumerable. /// - public string Text { get; set; } + public IEnumerable OverConceptDescriptionsOrEmpty() + { + return ConceptDescriptions + ?? System.Linq.Enumerable.Empty(); + } /// /// Iterate over all the class instances referenced from this instance @@ -10935,8 +11430,29 @@ public class LangString : IClass /// public IEnumerable DescendOnce() { - // No descendable properties - yield break; + if (AssetAdministrationShells != null) + { + foreach (var anItem in AssetAdministrationShells) + { + yield return anItem; + } + } + + if (Submodels != null) + { + foreach (var anItem in Submodels) + { + yield return anItem; + } + } + + if (ConceptDescriptions != null) + { + foreach (var anItem in ConceptDescriptions) + { + yield return anItem; + } + } } /// @@ -10944,8 +11460,47 @@ public IEnumerable DescendOnce() /// public IEnumerable Descend() { - // No descendable properties - yield break; + if (AssetAdministrationShells != null) + { + foreach (var anItem in AssetAdministrationShells) + { + yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } + } + } + + if (Submodels != null) + { + foreach (var anItem in Submodels) + { + yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } + } + } + + if (ConceptDescriptions != null) + { + foreach (var anItem in ConceptDescriptions) + { + yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } + } + } } /// @@ -10988,31 +11543,41 @@ public T Transform( return transformer.Transform(this, context); } - public LangString( - string language, - string text) + public Environment( + List? assetAdministrationShells = null, + List? submodels = null, + List? conceptDescriptions = null) { - Language = language; - Text = text; + AssetAdministrationShells = assetAdministrationShells; + Submodels = submodels; + ConceptDescriptions = conceptDescriptions; } } /// - /// Array of elements of type langString + /// Data specification content is part of a data specification template and defines + /// which additional attributes shall be added to the element instance that references + /// the data specification template and meta information about the template itself. + /// + public interface IDataSpecificationContent : IClass + { + // Intentionally empty. + } + + /// + /// Embed the content of a data specification. /// - /// - /// langString is a RDF data type. - /// - /// A langString is a string value tagged with a language code. - /// It depends on the serialization rules for a technology how - /// this is realized. - /// - public class LangStringSet : IClass + public class EmbeddedDataSpecification : IClass { /// - /// Strings in different languages + /// Reference to the data specification /// - public List LangStrings { get; set; } + public Reference DataSpecification { get; set; } + + /// + /// Actual content of the data specification + /// + public IDataSpecificationContent DataSpecificationContent { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -11020,10 +11585,9 @@ public class LangStringSet : IClass /// public IEnumerable DescendOnce() { - foreach (var anItem in LangStrings) - { - yield return anItem; - } + yield return DataSpecification; + + yield return DataSpecificationContent; } /// @@ -11031,15 +11595,20 @@ public IEnumerable DescendOnce() /// public IEnumerable Descend() { - foreach (var anItem in LangStrings) + yield return DataSpecification; + + // Recurse + foreach (var anItem in DataSpecification.Descend()) { yield return anItem; + } - // Recurse - foreach (var anotherItem in anItem.Descend()) - { - yield return anotherItem; - } + yield return DataSpecificationContent; + + // Recurse + foreach (var anItem in DataSpecificationContent.Descend()) + { + yield return anItem; } } @@ -11083,27 +11652,230 @@ public T Transform( return transformer.Transform(this, context); } - public LangStringSet(List langStrings) + public EmbeddedDataSpecification( + Reference dataSpecification, + IDataSpecificationContent dataSpecificationContent) { - LangStrings = langStrings; + DataSpecification = dataSpecification; + DataSpecificationContent = dataSpecificationContent; } } + public enum DataTypeIec61360 + { + /// + /// values containing a calendar date, conformant to ISO 8601:2004 Format yyyy-mm-dd + /// Example from IEC 61360-1:2017: "1999-05-31" is the [DATE] representation of: + /// "31 May 1999". + /// + [EnumMember(Value = "DATE")] + Date, + + /// + /// values consisting of sequence of characters but cannot be translated into other + /// languages + /// + [EnumMember(Value = "STRING")] + String, + + /// + /// values containing string but shall be represented as different string in different + /// languages + /// + [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")] + IntegerMeasure, + + /// + /// values containing values of type INTEGER but are no currencies or measures + /// + [EnumMember(Value = "INTEGER_COUNT")] + IntegerCount, + + /// + /// values containing values of type INTEGER that are currencies + /// + [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, + + /// + /// 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, + + /// + /// values containing values of type REAL that are currencies + /// + [EnumMember(Value = "REAL_CURRENCY")] + RealCurrency, + + /// + /// values representing truth of logic or Boolean algebra (TRUE, FALSE) + /// + [EnumMember(Value = "BOOLEAN")] + Boolean, + + /// + /// values containing values of type STRING conformant to Rfc 3987 + /// + /// + /// 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, + + /// + /// values conforming to ISO/IEC 11179 series global identifier sequences + /// + /// + /// + /// IRDI can be used instead of the more specific data types ICID or ISO29002_IRDI. + /// + /// + /// ICID values are value conformant to an IRDI, where the delimiter between RAI and ID + /// is “#” while the delimiter between DI and VI is confined to “##” + /// + /// + /// ISO29002_IRDI values are values containing a global identifier that identifies an + /// administrated item in a registry. The structure of this identifier complies with + /// identifier syntax defined in ISO/TS 29002-5. The identifier shall fulfil the + /// requirements specified in ISO/TS 29002-5 for an "international registration data + /// identifier" (IRDI). + /// + /// + [EnumMember(Value = "IRDI")] + Irdi, + + /// + /// values containing values of type 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")] + RationalMeasure, + + /// + /// values containing a time, conformant to ISO 8601:2004 but restricted to what is + /// allowed in the corresponding type in xml. + /// + /// + /// + /// Format hh:mm (ECLASS) + /// + /// + /// Example from IEC 61360-1:2017: "13:20:00-05:00" is the [TIME] representation of: + /// 1.20 p.m. for Eastern Standard Time, which is 5 hours behind Coordinated + /// Universal Time (UTC). + /// + /// + [EnumMember(Value = "TIME")] + Time, + + /// + /// values containing a time, conformant to ISO 8601:2004 but restricted to what is + /// allowed in the corresponding type in xml. + /// + /// + /// Format yyyy-mm-dd hh:mm (ECLASS) + /// + [EnumMember(Value = "TIMESTAMP")] + Timestamp, + + /// + /// values containing an address to a file. The values are of type URI and can represent + /// an absolute or relative path. + /// + /// + /// IEC61360 does not support the file type. + /// + [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, + + /// + /// values containing the content of a file. Values may be binaries. + /// + /// + /// + /// HTML conformant to HTML5 is a special blob. + /// + /// + /// In IEC61360 binary is for a sequence of bits, each bit being represented by “0” and + /// “1” only. A binary is a blob but a blob may also contain other source code. + /// + /// + [EnumMember(Value = "BLOB")] + Blob + } + + public enum LevelType + { + [EnumMember(Value = "Min")] + Min, + + [EnumMember(Value = "Max")] + Max, + + [EnumMember(Value = "Nom")] + Nom, + + [EnumMember(Value = "Typ")] + Typ + } + /// - /// Data specification content is part of a data specification template and defines - /// which additional attributes shall be added to the element instance that references - /// the data specification template and meta information about the template itself. + /// A value reference pair within a value list. Each value has a global unique id + /// defining its semantic. /// - public class DataSpecificationContent : IClass + public class ValueReferencePair : IClass { + /// + /// The value of the referenced concept definition of the value in valueId. + /// + public string Value { get; set; } + + /// + /// Global unique id of the value. + /// + /// + /// It is recommended to use a global reference. + /// + public Reference ValueId { get; set; } + /// /// Iterate over all the class instances referenced from this instance /// without further recursion. /// public IEnumerable DescendOnce() { - // No descendable properties - yield break; + yield return ValueId; } /// @@ -11111,8 +11883,13 @@ public IEnumerable DescendOnce() /// public IEnumerable Descend() { - // No descendable properties - yield break; + yield return ValueId; + + // Recurse + foreach (var anItem in ValueId.Descend()) + { + yield return anItem; + } } /// @@ -11154,37 +11931,25 @@ public T Transform( { return transformer.Transform(this, context); } + + public ValueReferencePair( + string value, + Reference valueId) + { + Value = value; + ValueId = valueId; + } } /// - /// Data Specification Template - /// - public class DataSpecification : IClass - { - /// - /// The globally unique identification of the element. - /// - public string Id { get; set; } - - /// - /// The content of the template without meta data - /// - public DataSpecificationContent DataSpecificationContent { get; set; } - - /// - /// Administrative information of an identifiable element. - /// - /// - /// Some of the administrative information like the version number might need to - /// be part of the identification. - /// - public AdministrativeInformation? Administration { get; set; } - + /// A set of value reference pairs. + /// + public class ValueList : IClass + { /// - /// Description how and in which context the data specification template is applicable. - /// The description can be provided in several languages. + /// A pair of a value together with its global unique id. /// - public LangStringSet? Description { get; set; } + public List ValueReferencePairs { get; set; } /// /// Iterate over all the class instances referenced from this instance @@ -11192,16 +11957,9 @@ public class DataSpecification : IClass /// public IEnumerable DescendOnce() { - yield return DataSpecificationContent; - - if (Administration != null) - { - yield return Administration; - } - - if (Description != null) + foreach (var anItem in ValueReferencePairs) { - yield return Description; + yield return anItem; } } @@ -11210,33 +11968,14 @@ public IEnumerable DescendOnce() /// public IEnumerable Descend() { - yield return DataSpecificationContent; - - // Recurse - foreach (var anItem in DataSpecificationContent.Descend()) + foreach (var anItem in ValueReferencePairs) { yield return anItem; - } - - if (Administration != null) - { - yield return Administration; - - // Recurse - foreach (var anItem in Administration.Descend()) - { - yield return anItem; - } - } - - if (Description != null) - { - yield return Description; // Recurse - foreach (var anItem in Description.Descend()) + foreach (var anotherItem in anItem.Descend()) { - yield return anItem; + yield return anotherItem; } } } @@ -11281,83 +12020,157 @@ public T Transform( return transformer.Transform(this, context); } - public DataSpecification( - string id, - DataSpecificationContent dataSpecificationContent, - AdministrativeInformation? administration, - LangStringSet? description) + public ValueList(List valueReferencePairs) { - Id = id; - DataSpecificationContent = dataSpecificationContent; - Administration = administration; - Description = description; + ValueReferencePairs = valueReferencePairs; } } /// - /// Container for the sets of different identifiables. + /// Content of data specification template for concept descriptions for properties, + /// values and value lists conformant to IEC 61360. /// /// - /// w.r.t. file exchange: There is exactly one environment independent on how many - /// 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. + /// + /// IEC61360 requires also a globally unique identifier for a concept + /// description. This ID is not part of the data specification template. + /// Instead the as inherited via + /// is used. Same holds for administrative + /// information like the version and revision. + /// + /// + /// and are very + /// similar. However, in this case the decision was to add + /// explicitly to the data specification. Same holds for + /// and + /// . Same holds for + /// and . + /// + /// + /// Constraints: + /// + ///
    + ///
  • + /// Constraint AASc-010: + /// If is not empty then shall be empty + /// and vice versa. + ///
  • + ///
  • + /// Constraint AASc-009: + /// If one of: + /// , + /// , + /// , + /// , + /// , then or + /// shall be defined. + ///
  • + ///
///
- public class Environment : IClass + public class DataSpecificationIec61360 : IDataSpecificationContent { /// - /// Asset administration shell + /// Preferred name /// - public List? AssetAdministrationShells { get; set; } + /// + /// + /// Constraints: + /// + ///
    + ///
  • + /// Constraint AASc-002: + /// shall be provided at least in English. + ///
  • + ///
+ ///
+ public List PreferredName { get; set; } /// - /// Submodel + /// Short name /// - public List? Submodels { get; set; } + public List? ShortName { get; set; } /// - /// Concept description + /// Unit /// - public List? ConceptDescriptions { get; set; } + public string? Unit { get; set; } /// - /// Data specification + /// Unique unit id /// - public List? DataSpecifications { get; set; } + /// + /// + /// and need to be consistent if both attributes + /// are set + /// + /// + /// It is recommended to use a global reference. + /// + /// + /// Although the is a global reference there might exist a + /// + /// with data specification with + /// the same ID. + /// + /// + public Reference? UnitId { get; set; } /// - /// Iterate over AssetAdministrationShells, if set, and otherwise return an empty enumerable. + /// Source of definition /// - public IEnumerable OverAssetAdministrationShellsOrEmpty() - { - return AssetAdministrationShells - ?? System.Linq.Enumerable.Empty(); - } + public string? SourceOfDefinition { get; set; } /// - /// Iterate over Submodels, if set, and otherwise return an empty enumerable. + /// Symbol /// - public IEnumerable OverSubmodelsOrEmpty() - { - return Submodels - ?? System.Linq.Enumerable.Empty(); - } + public string? Symbol { get; set; } /// - /// Iterate over ConceptDescriptions, if set, and otherwise return an empty enumerable. + /// Data Type /// - public IEnumerable OverConceptDescriptionsOrEmpty() + public DataTypeIec61360? DataType { get; set; } + + /// + /// Definition in different languages + /// + public List? Definition { get; set; } + + /// + /// Value Format + /// + public string? ValueFormat { get; set; } + + /// + /// List of allowed values + /// + public ValueList? ValueList { get; set; } + + /// + /// Value + /// + public string? Value { get; set; } + + /// + /// Set of levels. + /// + public LevelType? LevelType { get; set; } + + /// + /// Iterate over ShortName, if set, and otherwise return an empty enumerable. + /// + public IEnumerable OverShortNameOrEmpty() { - return ConceptDescriptions - ?? System.Linq.Enumerable.Empty(); + return ShortName + ?? System.Linq.Enumerable.Empty(); } /// - /// Iterate over DataSpecifications, if set, and otherwise return an empty enumerable. + /// Iterate over Definition, if set, and otherwise return an empty enumerable. /// - public IEnumerable OverDataSpecificationsOrEmpty() + public IEnumerable OverDefinitionOrEmpty() { - return DataSpecifications - ?? System.Linq.Enumerable.Empty(); + return Definition + ?? System.Linq.Enumerable.Empty(); } /// @@ -11366,37 +12179,36 @@ public IEnumerable OverDataSpecificationsOrEmpty() /// public IEnumerable DescendOnce() { - if (AssetAdministrationShells != null) + foreach (var anItem in PreferredName) { - foreach (var anItem in AssetAdministrationShells) - { - yield return anItem; - } + yield return anItem; } - if (Submodels != null) + if (ShortName != null) { - foreach (var anItem in Submodels) + foreach (var anItem in ShortName) { yield return anItem; } } - if (ConceptDescriptions != null) + if (UnitId != null) { - foreach (var anItem in ConceptDescriptions) - { - yield return anItem; - } + yield return UnitId; } - if (DataSpecifications != null) + if (Definition != null) { - foreach (var anItem in DataSpecifications) + foreach (var anItem in Definition) { yield return anItem; } } + + if (ValueList != null) + { + yield return ValueList; + } } /// @@ -11404,9 +12216,20 @@ public IEnumerable DescendOnce() /// public IEnumerable Descend() { - if (AssetAdministrationShells != null) + foreach (var anItem in PreferredName) { - foreach (var anItem in AssetAdministrationShells) + yield return anItem; + + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } + } + + if (ShortName != null) + { + foreach (var anItem in ShortName) { yield return anItem; @@ -11418,23 +12241,20 @@ public IEnumerable Descend() } } - if (Submodels != null) + if (UnitId != null) { - foreach (var anItem in Submodels) + yield return UnitId; + + // Recurse + foreach (var anItem in UnitId.Descend()) { yield return anItem; - - // Recurse - foreach (var anotherItem in anItem.Descend()) - { - yield return anotherItem; - } } } - if (ConceptDescriptions != null) + if (Definition != null) { - foreach (var anItem in ConceptDescriptions) + foreach (var anItem in Definition) { yield return anItem; @@ -11446,17 +12266,14 @@ public IEnumerable Descend() } } - if (DataSpecifications != null) + if (ValueList != null) { - foreach (var anItem in DataSpecifications) + yield return ValueList; + + // Recurse + foreach (var anItem in ValueList.Descend()) { yield return anItem; - - // Recurse - foreach (var anotherItem in anItem.Descend()) - { - yield return anotherItem; - } } } } @@ -11501,20 +12318,199 @@ public T Transform( return transformer.Transform(this, context); } - public Environment() + public DataSpecificationIec61360( + List preferredName, + List? shortName = null, + string? unit = null, + Reference? unitId = null, + string? sourceOfDefinition = null, + string? symbol = null, + DataTypeIec61360? dataType = null, + List? definition = null, + string? valueFormat = null, + ValueList? valueList = null, + string? value = null, + LevelType? levelType = null) + { + PreferredName = preferredName; + ShortName = shortName; + Unit = unit; + UnitId = unitId; + SourceOfDefinition = sourceOfDefinition; + Symbol = symbol; + DataType = dataType; + Definition = definition; + ValueFormat = valueFormat; + ValueList = valueList; + Value = value; + LevelType = levelType; + } + } + + public class DataSpecificationPhysicalUnit : IDataSpecificationContent + { + /// + /// Name of the physical unit + /// + public string UnitName { get; set; } + + /// + /// Symbol for the physical unit + /// + public string UnitSymbol { get; set; } + + /// + /// Definition in different languages + /// + public List Definition { get; set; } + + /// + /// Notation of SI physical unit + /// + public string? SiNotation { get; set; } + + /// + /// Name of SI physical unit + /// + public string? SiName { get; set; } + + /// + /// Notation of physical unit conformant to DIN + /// + public string? DinNotation { get; set; } + + /// + /// Name of physical unit conformant to ECE + /// + public string? EceName { get; set; } + + /// + /// Code of physical unit conformant to ECE + /// + public string? EceCode { get; set; } + + /// + /// Name of NIST physical unit + /// + public string? NistName { get; set; } + + /// + /// Source of definition + /// + public string? SourceOfDefinition { get; set; } + + /// + /// Conversion factor + /// + public string? ConversionFactor { get; set; } + + /// + /// Registration authority ID + /// + public string? RegistrationAuthorityId { get; set; } + + /// + /// Supplier + /// + public string? Supplier { get; set; } + + /// + /// Iterate over all the class instances referenced from this instance + /// without further recursion. + /// + public IEnumerable DescendOnce() + { + foreach (var anItem in Definition) + { + yield return anItem; + } + } + + /// + /// Iterate recursively over all the class instances referenced from this instance. + /// + public IEnumerable Descend() { + foreach (var anItem in Definition) + { + yield return anItem; + // Recurse + foreach (var anotherItem in anItem.Descend()) + { + yield return anotherItem; + } + } } - public Environment( - List? assetAdministrationShells = null, - List? submodels = null, - List? conceptDescriptions = null, - List? dataSpecifications = null) + + /// + /// Accept the to visit this instance + /// for double dispatch. + /// + public void Accept(Visitation.IVisitor visitor) { - AssetAdministrationShells = assetAdministrationShells; - Submodels = submodels; - ConceptDescriptions = conceptDescriptions; - DataSpecifications = dataSpecifications; + visitor.Visit(this); + } + + /// + /// Accept the visitor to visit this instance for double dispatch + /// with the . + /// + public void Accept( + Visitation.IVisitorWithContext visitor, + TContext context) + { + visitor.Visit(this, context); + } + + /// + /// Accept the to transform this instance + /// for double dispatch. + /// + public T Transform(Visitation.ITransformer transformer) + { + return transformer.Transform(this); + } + + /// + /// Accept the to visit this instance + /// for double dispatch with the . + /// + public T Transform( + Visitation.ITransformerWithContext transformer, + TContext context) + { + return transformer.Transform(this, context); + } + + public DataSpecificationPhysicalUnit( + string unitName, + string unitSymbol, + List definition, + string? siNotation = null, + string? siName = null, + string? dinNotation = null, + string? eceName = null, + string? eceCode = null, + string? nistName = null, + string? sourceOfDefinition = null, + string? conversionFactor = null, + string? registrationAuthorityId = null, + string? supplier = null) + { + UnitName = unitName; + UnitSymbol = unitSymbol; + Definition = definition; + SiNotation = siNotation; + SiName = siName; + DinNotation = dinNotation; + EceName = eceName; + EceCode = eceCode; + NistName = nistName; + SourceOfDefinition = sourceOfDefinition; + ConversionFactor = conversionFactor; + RegistrationAuthorityId = registrationAuthorityId; + Supplier = supplier; } } diff --git a/src/AasxServer.DomainModelV3_0_RC02/verification.cs b/src/AasxServer.DomainModelV3_0_RC02/verification.cs index c8dfcae04..9921205e6 100644 --- a/src/AasxServer.DomainModelV3_0_RC02/verification.cs +++ b/src/AasxServer.DomainModelV3_0_RC02/verification.cs @@ -3,13 +3,13 @@ * Do NOT edit or append. */ +using Aas = AasCore.Aas3_0_RC02; // renamed using CodeAnalysis = System.Diagnostics.CodeAnalysis; using Regex = System.Text.RegularExpressions.Regex; + using System.Collections.Generic; // can't alias using System.Linq; // can't alias -using Aas = AasCore.Aas3_0_RC02; - namespace AasCore.Aas3_0_RC02 { /// @@ -77,11 +77,14 @@ private static Regex _constructMatchesXsDateTimeStampUtc() /// Check that conforms to the pattern of an xs:dateTimeStamp. /// /// + /// /// The time zone must be fixed to UTC. We verify only that the text matches /// a pre-defined pattern. We do not verify that the day of month is /// correct nor do we check for leap seconds. - /// + /// + /// /// See: https://www.w3.org/TR/xmlschema11-2/#dateTimeStamp + /// /// /// /// Text to be checked @@ -94,56 +97,165 @@ public static bool MatchesXsDateTimeStampUtc(string text) return RegexMatchesXsDateTimeStampUtc.IsMatch(text); } - private static readonly string[] XsDateFormats = { - "yyyy-MM-dd" - }; + private static readonly Regex RegexDatePrefix = ( + new Regex("^(-?[0-9]+)-([0-9]{2})-([0-9]{2})")); /// - /// Clip the to the date part. + /// Check whether the given year is a leap year. /// - /// - /// We ignore the negative sign prefix and clip years to 4 digits. - /// This is necessary as can not handle - /// dates B.C. and the expects - /// exactly four digits. - /// - /// We strip the negative sign and assume astronomical years. - /// See: https://en.wikipedia.org/wiki/Leap_year#Algorithm - /// - /// Furthermore, we always assume that has been - /// already validated with the corresponding regular expression. - /// Hence we can use this function to validate the date-times as the time - /// segment and offsets are correctly matched by the regular expression, - /// while day/month combinations need to be validated by - /// . - /// - private static string ClipToDate(string value) + /// Year 1 BCE is a leap year. + /// to be checked + /// True if is a leap year + public static bool IsLeapYear(System.Numerics.BigInteger year) + { + // NOTE (mristin, 2022-11-02): + // We consider the years B.C. to be one-off. + // See the note at: https://www.w3.org/TR/xmlschema-2/#dateTime: + // "'-0001' is the lexical representation of the year 1 Before Common Era + // (1 BCE, sometimes written "1 BC")." + // + // Hence, -1 year in XML is 1 BCE, which is 0 year in astronomical years. + if (year < 0) + { + year = -year - 1; + } + + // See: See: https://en.wikipedia.org/wiki/Leap_year#Algorithm + if (year % 4 > 0) + { + return false; + } + + if (year % 100 > 0) + { + return true; + } + + if (year % 400 > 0) + { + return false; + } + + return true; + } + + /// + /// Check that the value starts with a valid date. + /// + /// + /// an xs:date, an xs:dateTime, + /// or an xs:dateTimeStamp + /// + /// true if the value starts with a valid date + /// + private static bool IsPrefixedWithValidDate(string value) { - int start = 0; - if (value[0] == '-') + // NOTE (mristin, 2022-11-02): + // We can not use System.DateTime.ParseExact since it does not handle the zero and + // BCE years correctly. Therefore, we have to roll out our own date validator. + var match = RegexDatePrefix.Match(value); + if (!match.Success) + { + return false; + } + + bool ok = System.Numerics.BigInteger.TryParse( + match.Groups[1].Value, + out System.Numerics.BigInteger year); + if (!ok) + { + throw new System.InvalidOperationException( + $"Expected to parse the year from {match.Groups[1].Value}, " + + "but the parsing failed"); + } + + ok = System.SByte.TryParse(match.Groups[2].Value, out sbyte month); + if (!ok) + { + throw new System.InvalidOperationException( + $"Expected to parse the month from {match.Groups[2].Value}, " + + "but the parsing failed"); + } + + ok = System.SByte.TryParse(match.Groups[3].Value, out sbyte day); + if (!ok) + { + throw new System.InvalidOperationException( + $"Expected to parse the day from {match.Groups[3].Value}, " + + "but the parsing failed"); + } + + // Year zero does not exist, see: https://www.w3.org/TR/xmlschema-2/#dateTime + if (year == 0) + { + return false; + } + + if (day <= 0 || day > 31) + { + return false; + } + + if (month <= 0 || month >= 13) + { + return false; + } + + sbyte maxDaysInMonth; + switch (month) { - start++; + case 1: + maxDaysInMonth = 31; + break; + case 2: + maxDaysInMonth = (IsLeapYear(year)) ? (sbyte)29 : (sbyte)28; + break; + case 3: + maxDaysInMonth = 31; + break; + case 4: + maxDaysInMonth = 30; + break; + case 5: + maxDaysInMonth = 31; + break; + case 6: + maxDaysInMonth = 30; + break; + case 7: + maxDaysInMonth = 31; + break; + case 8: + maxDaysInMonth = 31; + break; + case 9: + maxDaysInMonth = 30; + break; + case 10: + maxDaysInMonth = 31; + break; + case 11: + maxDaysInMonth = 30; + break; + case 12: + maxDaysInMonth = 31; + break; + default: + throw new System.InvalidOperationException($"Unexpected month: {month}"); } - int yearEnd = start; - for (; value[yearEnd] != '-'; yearEnd++) + if (day > maxDaysInMonth) { - // Intentionally empty. + return false; } - return (yearEnd == 4 && value.Length == 10) - ? value - : value.Substring(yearEnd - 4, 10); + return true; } /// /// Check that is a xs:dateTimeStamp with /// the time zone set to UTC. /// - /// - /// The is assumed to be already checked with - /// . - /// public static bool IsXsDateTimeStampUtc( string value ) @@ -153,20 +265,7 @@ string value return false; } - try - { - // ReSharper disable once ReturnValueOfPureMethodIsNotUsed - System.DateTime.ParseExact( - ClipToDate(value), - XsDateFormats, - System.Globalization.CultureInfo.InvariantCulture, - System.Globalization.DateTimeStyles.None); - return true; - } - catch (System.FormatException) - { - return false; - } + return IsPrefixedWithValidDate(value); } [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] @@ -630,7 +729,7 @@ public static bool MatchesXsDecimal(string text) [CodeAnalysis.SuppressMessage("ReSharper", "StringLiteralTypo")] private static Regex _constructMatchesXsDouble() { - var doubleRep = "(\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([Ee](\\+|-)?[0-9]+)?|(\\+|-)?INF|NaN"; + var doubleRep = "((\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([Ee](\\+|-)?[0-9]+)?|-?INF|NaN)"; var pattern = $"^{doubleRep}$"; return new Regex(pattern); @@ -690,7 +789,7 @@ public static bool MatchesXsDuration(string text) [CodeAnalysis.SuppressMessage("ReSharper", "StringLiteralTypo")] private static Regex _constructMatchesXsFloat() { - var floatRep = "(\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([Ee](\\+|-)?[0-9]+)?|(\\+|-)?INF|NaN"; + var floatRep = "((\\+|-)?([0-9]+(\\.[0-9]*)?|\\.[0-9]+)([Ee](\\+|-)?[0-9]+)?|-?INF|NaN)"; var pattern = $"^{floatRep}$"; return new Regex(pattern); @@ -1434,20 +1533,7 @@ Aas.DataTypeDefXsd valueType return false; } - try - { - // ReSharper disable once ReturnValueOfPureMethodIsNotUsed - System.DateTime.ParseExact( - ClipToDate(value), - XsDateFormats, - System.Globalization.CultureInfo.InvariantCulture, - System.Globalization.DateTimeStyles.None); - return true; - } - catch (System.FormatException) - { - return false; - } + return IsPrefixedWithValidDate(value); } case Aas.DataTypeDefXsd.DateTime: { @@ -1459,21 +1545,7 @@ Aas.DataTypeDefXsd valueType // The time part and the time zone part will be checked by // MatchesXsDateTime. We need to check that the date part is // correct in sense of the day/month combination. - - try - { - // ReSharper disable once ReturnValueOfPureMethodIsNotUsed - System.DateTime.ParseExact( - ClipToDate(value), - XsDateFormats, - System.Globalization.CultureInfo.InvariantCulture, - System.Globalization.DateTimeStyles.None); - return true; - } - catch (System.FormatException) - { - return false; - } + return IsPrefixedWithValidDate(value); } case Aas.DataTypeDefXsd.DateTimeStamp: { @@ -1485,21 +1557,7 @@ Aas.DataTypeDefXsd valueType // The time part and the time zone part will be checked by // MatchesXsDateTimeStamp. We need to check that the date part is // correct in sense of the day/month combination. - - try - { - // ReSharper disable once ReturnValueOfPureMethodIsNotUsed - System.DateTime.ParseExact( - ClipToDate(value), - XsDateFormats, - System.Globalization.CultureInfo.InvariantCulture, - System.Globalization.DateTimeStyles.None); - return true; - } - catch (System.FormatException) - { - return false; - } + return IsPrefixedWithValidDate(value); } case Aas.DataTypeDefXsd.Decimal: { @@ -1963,21 +2021,29 @@ public static bool MatchesGlobalAssetIdLiterally(string text) } /// - /// Check that the target of the model matches - /// the . + /// Check that the target of the model reference matches the . /// public static bool IsModelReferenceTo( - Aas.Reference reference, - Aas.KeyTypes expectedType + Reference reference, + KeyTypes expectedType ) { - if (reference.Keys.Count == 0) - { - return false; - } + return reference.Type == ReferenceTypes.ModelReference + && reference.Keys.Count != 0 + && reference.Keys[^1].Type == expectedType; + } // public static bool IsModelReferenceTo - return reference.Keys[^1].Type == expectedType; - } + /// + /// Check that the target of the reference matches a . + /// + public static bool IsModelReferenceToReferable( + Reference reference + ) + { + return reference.Type == ReferenceTypes.ModelReference + && reference.Keys.Count != 0 + && Aas.Constants.AasReferables.Contains(reference.Keys[^1].Type); + } // public static bool IsModelReferenceToReferable /// /// Check that all are unique among @@ -2066,10 +2132,10 @@ public static bool SubmodelElementsHaveIdenticalSemanticIds( public static bool SubmodelElementIsOfType( Aas.ISubmodelElement element, - Aas.AasSubmodelElements elementType + Aas.AasSubmodelElements expectedType ) { - switch (elementType) + switch (expectedType) { case Aas.AasSubmodelElements.AnnotatedRelationshipElement: return element is Aas.AnnotatedRelationshipElement; @@ -2126,7 +2192,7 @@ Aas.AasSubmodelElements elementType default: throw new System.ArgumentException( - $"elementType is not a valid AasSubmodelElements: {elementType}" + $"expectedType is not a valid AasSubmodelElements: {expectedType}" ); } } @@ -2168,81 +2234,242 @@ public static bool PropertiesOrRangesHaveValueType( return true; } - private static readonly HashSet ConceptDescriptionCategories = new HashSet + /// + /// Check that the two references, and + /// , are equal by comparing + /// their by + /// 's. + /// + public static bool ReferenceKeyValuesEqual( + Aas.Reference that, + Aas.Reference other + ) + { + if (that.Keys.Count != other.Keys.Count) + { + return false; + } + + for (int i = 0; i < that.Keys.Count; i++) + { + if (that.Keys[i].Value != other.Keys[i].Value) + { + return false; + } + } + + return true; + } + + /// + /// Check that the is defined + /// appropriately for all data specifications whose content is given as IEC 61360. + /// + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static bool DataSpecificationIec61360sForPropertyOrValueHaveAppropriateDataType( + IEnumerable embeddedDataSpecifications + ) { - "APPLICATION_CLASS", - "CAPABILITY", - "COLLECTION", - "DOCUMENT", - "ENTITY", - "EVENT", - "FUNCTION", - "PROPERTY", - "VALUE", - "RANGE", - "QUALIFIER_TYPE", - "REFERENCE", - "RELATIONSHIP" - }; + foreach (var embeddedDataSpecification in embeddedDataSpecifications) + { + var iec61360 = ( + embeddedDataSpecification.DataSpecificationContent + as DataSpecificationIec61360 + ); + if (iec61360 != null) + { + if ( + iec61360.DataType == null + || !Constants.DataTypeIec61360ForPropertyOrValue.Contains( + iec61360.DataType) + ) + { + return false; + } + } + } + + return true; + } /// - /// Check that is a valid - /// category of the concept description. + /// Check that the is defined + /// appropriately for all data specifications whose content is given as IEC 61360. /// - public static bool ConceptDescriptionCategoryIsValid( - string category + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static bool DataSpecificationIec61360sForReferenceHaveAppropriateDataType( + IEnumerable embeddedDataSpecifications ) { - return ConceptDescriptionCategories.Contains( - category); + foreach (var embeddedDataSpecification in embeddedDataSpecifications) + { + var iec61360 = ( + embeddedDataSpecification.DataSpecificationContent + as DataSpecificationIec61360 + ); + if (iec61360 != null) + { + if ( + iec61360.DataType == null + || !Constants.DataTypeIec61360ForReference.Contains( + iec61360.DataType) + ) + { + return false; + } + } + } + + return true; } - private static readonly HashSet DataElementCategories = new HashSet + /// + /// Check that the is defined + /// appropriately for all data specifications whose content is given as IEC 61360. + /// + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static bool DataSpecificationIec61360sForDocumentHaveAppropriateDataType( + IEnumerable embeddedDataSpecifications + ) { - "CONSTANT", - "PARAMETER", - "VARIABLE" - }; + foreach (var embeddedDataSpecification in embeddedDataSpecifications) + { + var iec61360 = ( + embeddedDataSpecification.DataSpecificationContent + as DataSpecificationIec61360 + ); + if (iec61360 != null) + { + if ( + iec61360.DataType == null + || !Constants.DataTypeIec61360ForDocument.Contains( + iec61360.DataType) + ) + { + return false; + } + } + } + + return true; + } /// - /// Check that is a valid - /// category of a data element. + /// Check that the is defined + /// for all data specifications whose content is given as IEC 61360. /// - public static bool DataElementCategoryIsValid( - string category + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static bool DataSpecificationIec61360sHaveDataType( + IEnumerable embeddedDataSpecifications ) { - return DataElementCategories.Contains( - category); + foreach (var embeddedDataSpecification in embeddedDataSpecifications) + { + var iec61360 = ( + embeddedDataSpecification.DataSpecificationContent + as DataSpecificationIec61360 + ); + if (iec61360 != null) + { + if (iec61360.DataType == null) + { + return false; + } + } + } + + return true; } /// - /// Check that the two references, and - /// , are equal by comparing - /// their by - /// 's. + /// Check that the is defined + /// for all data specifications whose content is given as IEC 61360. /// - public static bool ReferenceKeyValuesEqual( - Aas.Reference that, - Aas.Reference other + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static bool DataSpecificationIec61360sHaveValue( + IEnumerable embeddedDataSpecifications ) { - if (that.Keys.Count != other.Keys.Count) + foreach (var embeddedDataSpecification in embeddedDataSpecifications) { - return false; + var iec61360 = ( + embeddedDataSpecification.DataSpecificationContent + as DataSpecificationIec61360 + ); + if (iec61360 != null) + { + if (iec61360.Value == null) + { + return false; + } + } } - for (int i = 0; i < that.Keys.Count; i++) + return true; + } + + /// + /// Check that the is defined + /// for all data specifications whose content is given as IEC 61360 at least in English. + /// + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static bool DataSpecificationIec61360sHaveDefinitionAtLeastInEnglish( + IEnumerable embeddedDataSpecifications + ) + { + foreach (var embeddedDataSpecification in embeddedDataSpecifications) { - if (that.Keys[i].Value != other.Keys[i].Value) + var iec61360 = ( + embeddedDataSpecification.DataSpecificationContent + as DataSpecificationIec61360 + ); + if (iec61360 != null) { - return false; + if (iec61360.Definition == null) + { + return false; + } + + var noDefinitionInEnglish = true; + foreach (var langString in iec61360.Definition) + { + if (IsBcp47ForEnglish(langString.Language)) + { + noDefinitionInEnglish = false; + break; + } + } + + if (noDefinitionInEnglish) + { + return false; + } } } return true; } + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + [CodeAnalysis.SuppressMessageAttribute("ReSharper", "IdentifierTypo")] + [CodeAnalysis.SuppressMessage("ReSharper", "StringLiteralTypo")] + private static Regex _constructIsBcp47ForEnglish() + { + var pattern = "^(en|EN)(-.*)?$"; + + return new Regex(pattern); + } + + private static readonly Regex RegexIsBcp47ForEnglish = _constructIsBcp47ForEnglish(); + + /// + /// Check that the corresponds to a BCP47 code for english. + /// + public static bool IsBcp47ForEnglish(string text) + { + return RegexIsBcp47ForEnglish.IsMatch(text); + } + /// /// Hash allowed enum values for efficient validation of enums. /// @@ -2270,6 +2497,28 @@ internal static class EnumValueSet (int)Aas.AssetKind.Instance }; + internal static readonly HashSet ForAasSubmodelElements = new HashSet + { + + (int)Aas.AasSubmodelElements.AnnotatedRelationshipElement, + (int)Aas.AasSubmodelElements.BasicEventElement, + (int)Aas.AasSubmodelElements.Blob, + (int)Aas.AasSubmodelElements.Capability, + (int)Aas.AasSubmodelElements.DataElement, + (int)Aas.AasSubmodelElements.Entity, + (int)Aas.AasSubmodelElements.EventElement, + (int)Aas.AasSubmodelElements.File, + (int)Aas.AasSubmodelElements.MultiLanguageProperty, + (int)Aas.AasSubmodelElements.Operation, + (int)Aas.AasSubmodelElements.Property, + (int)Aas.AasSubmodelElements.Range, + (int)Aas.AasSubmodelElements.ReferenceElement, + (int)Aas.AasSubmodelElements.RelationshipElement, + (int)Aas.AasSubmodelElements.SubmodelElement, + (int)Aas.AasSubmodelElements.SubmodelElementList, + (int)Aas.AasSubmodelElements.SubmodelElementCollection + }; + internal static readonly HashSet ForEntityType = new HashSet { @@ -2298,135 +2547,7 @@ internal static class EnumValueSet (int)Aas.ReferenceTypes.ModelReference }; - internal static readonly HashSet ForGenericFragmentKeys = new HashSet - { - - (int)Aas.GenericFragmentKeys.FragmentReference - }; - - internal static readonly HashSet ForGenericGloballyIdentifiables = new HashSet - { - - (int)Aas.GenericGloballyIdentifiables.GlobalReference - }; - - internal static readonly HashSet ForAasIdentifiables = new HashSet - { - - (int)Aas.AasIdentifiables.AssetAdministrationShell, - (int)Aas.AasIdentifiables.ConceptDescription, - (int)Aas.AasIdentifiables.Identifiable, - (int)Aas.AasIdentifiables.Submodel - }; - - internal static readonly HashSet ForAasSubmodelElements = new HashSet - { - - (int)Aas.AasSubmodelElements.AnnotatedRelationshipElement, - (int)Aas.AasSubmodelElements.BasicEventElement, - (int)Aas.AasSubmodelElements.Blob, - (int)Aas.AasSubmodelElements.Capability, - (int)Aas.AasSubmodelElements.DataElement, - (int)Aas.AasSubmodelElements.Entity, - (int)Aas.AasSubmodelElements.EventElement, - (int)Aas.AasSubmodelElements.File, - (int)Aas.AasSubmodelElements.MultiLanguageProperty, - (int)Aas.AasSubmodelElements.Operation, - (int)Aas.AasSubmodelElements.Property, - (int)Aas.AasSubmodelElements.Range, - (int)Aas.AasSubmodelElements.ReferenceElement, - (int)Aas.AasSubmodelElements.RelationshipElement, - (int)Aas.AasSubmodelElements.SubmodelElement, - (int)Aas.AasSubmodelElements.SubmodelElementList, - (int)Aas.AasSubmodelElements.SubmodelElementCollection - }; - - internal static readonly HashSet ForAasReferableNonIdentifiables = new HashSet - { - - (int)Aas.AasReferableNonIdentifiables.AnnotatedRelationshipElement, - (int)Aas.AasReferableNonIdentifiables.BasicEventElement, - (int)Aas.AasReferableNonIdentifiables.Blob, - (int)Aas.AasReferableNonIdentifiables.Capability, - (int)Aas.AasReferableNonIdentifiables.DataElement, - (int)Aas.AasReferableNonIdentifiables.Entity, - (int)Aas.AasReferableNonIdentifiables.EventElement, - (int)Aas.AasReferableNonIdentifiables.File, - (int)Aas.AasReferableNonIdentifiables.MultiLanguageProperty, - (int)Aas.AasReferableNonIdentifiables.Operation, - (int)Aas.AasReferableNonIdentifiables.Property, - (int)Aas.AasReferableNonIdentifiables.Range, - (int)Aas.AasReferableNonIdentifiables.ReferenceElement, - (int)Aas.AasReferableNonIdentifiables.RelationshipElement, - (int)Aas.AasReferableNonIdentifiables.SubmodelElement, - (int)Aas.AasReferableNonIdentifiables.SubmodelElementCollection, - (int)Aas.AasReferableNonIdentifiables.SubmodelElementList - }; - - internal static readonly HashSet ForAasReferables = new HashSet - { - - (int)Aas.AasReferables.Referable, - (int)Aas.AasReferables.AssetAdministrationShell, - (int)Aas.AasReferables.ConceptDescription, - (int)Aas.AasReferables.Identifiable, - (int)Aas.AasReferables.Submodel, - (int)Aas.AasReferables.AnnotatedRelationshipElement, - (int)Aas.AasReferables.BasicEventElement, - (int)Aas.AasReferables.Blob, - (int)Aas.AasReferables.Capability, - (int)Aas.AasReferables.DataElement, - (int)Aas.AasReferables.Entity, - (int)Aas.AasReferables.EventElement, - (int)Aas.AasReferables.File, - (int)Aas.AasReferables.MultiLanguageProperty, - (int)Aas.AasReferables.Operation, - (int)Aas.AasReferables.Property, - (int)Aas.AasReferables.Range, - (int)Aas.AasReferables.ReferenceElement, - (int)Aas.AasReferables.RelationshipElement, - (int)Aas.AasReferables.SubmodelElement, - (int)Aas.AasReferables.SubmodelElementCollection, - (int)Aas.AasReferables.SubmodelElementList - }; - - internal static readonly HashSet ForGloballyIdentifiables = new HashSet - { - - (int)Aas.GloballyIdentifiables.GlobalReference, - (int)Aas.GloballyIdentifiables.AssetAdministrationShell, - (int)Aas.GloballyIdentifiables.ConceptDescription, - (int)Aas.GloballyIdentifiables.Identifiable, - (int)Aas.GloballyIdentifiables.Submodel - }; - - internal static readonly HashSet ForFragmentKeys = new HashSet - { - - (int)Aas.FragmentKeys.FragmentReference, - (int)Aas.FragmentKeys.AnnotatedRelationshipElement, - (int)Aas.FragmentKeys.AssetAdministrationShell, - (int)Aas.FragmentKeys.BasicEventElement, - (int)Aas.FragmentKeys.Blob, - (int)Aas.FragmentKeys.Capability, - (int)Aas.FragmentKeys.ConceptDescription, - (int)Aas.FragmentKeys.DataElement, - (int)Aas.FragmentKeys.Entity, - (int)Aas.FragmentKeys.EventElement, - (int)Aas.FragmentKeys.File, - (int)Aas.FragmentKeys.MultiLanguageProperty, - (int)Aas.FragmentKeys.Operation, - (int)Aas.FragmentKeys.Property, - (int)Aas.FragmentKeys.Range, - (int)Aas.FragmentKeys.ReferenceElement, - (int)Aas.FragmentKeys.RelationshipElement, - (int)Aas.FragmentKeys.Submodel, - (int)Aas.FragmentKeys.SubmodelElement, - (int)Aas.FragmentKeys.SubmodelElementList, - (int)Aas.FragmentKeys.SubmodelElementCollection - }; - - internal static readonly HashSet ForKeyTypes = new HashSet + internal static readonly HashSet ForKeyTypes = new HashSet { (int)Aas.KeyTypes.FragmentReference, @@ -2446,8 +2567,8 @@ internal static class EnumValueSet (int)Aas.KeyTypes.Operation, (int)Aas.KeyTypes.Property, (int)Aas.KeyTypes.Range, - (int)Aas.KeyTypes.Referable, (int)Aas.KeyTypes.ReferenceElement, + (int)Aas.KeyTypes.Referable, (int)Aas.KeyTypes.RelationshipElement, (int)Aas.KeyTypes.Submodel, (int)Aas.KeyTypes.SubmodelElement, @@ -2493,49 +2614,37 @@ internal static class EnumValueSet (int)Aas.DataTypeDefXsd.NegativeInteger }; - internal static readonly HashSet ForDataTypeDefRdf = new HashSet + internal static readonly HashSet ForDataTypeIec61360 = new HashSet { - (int)Aas.DataTypeDefRdf.LangString + (int)Aas.DataTypeIec61360.Date, + (int)Aas.DataTypeIec61360.String, + (int)Aas.DataTypeIec61360.StringTranslatable, + (int)Aas.DataTypeIec61360.IntegerMeasure, + (int)Aas.DataTypeIec61360.IntegerCount, + (int)Aas.DataTypeIec61360.IntegerCurrency, + (int)Aas.DataTypeIec61360.RealMeasure, + (int)Aas.DataTypeIec61360.RealCount, + (int)Aas.DataTypeIec61360.RealCurrency, + (int)Aas.DataTypeIec61360.Boolean, + (int)Aas.DataTypeIec61360.Iri, + (int)Aas.DataTypeIec61360.Irdi, + (int)Aas.DataTypeIec61360.Rational, + (int)Aas.DataTypeIec61360.RationalMeasure, + (int)Aas.DataTypeIec61360.Time, + (int)Aas.DataTypeIec61360.Timestamp, + (int)Aas.DataTypeIec61360.File, + (int)Aas.DataTypeIec61360.Html, + (int)Aas.DataTypeIec61360.Blob }; - internal static readonly HashSet ForDataTypeDef = new HashSet + internal static readonly HashSet ForLevelType = new HashSet { - (int)Aas.DataTypeDef.AnyUri, - (int)Aas.DataTypeDef.Base64Binary, - (int)Aas.DataTypeDef.Boolean, - (int)Aas.DataTypeDef.Date, - (int)Aas.DataTypeDef.DateTime, - (int)Aas.DataTypeDef.DateTimeStamp, - (int)Aas.DataTypeDef.Decimal, - (int)Aas.DataTypeDef.Double, - (int)Aas.DataTypeDef.Duration, - (int)Aas.DataTypeDef.Float, - (int)Aas.DataTypeDef.GDay, - (int)Aas.DataTypeDef.GMonth, - (int)Aas.DataTypeDef.GMonthDay, - (int)Aas.DataTypeDef.GYear, - (int)Aas.DataTypeDef.GYearMonth, - (int)Aas.DataTypeDef.HexBinary, - (int)Aas.DataTypeDef.String, - (int)Aas.DataTypeDef.Time, - (int)Aas.DataTypeDef.DayTimeDuration, - (int)Aas.DataTypeDef.YearMonthDuration, - (int)Aas.DataTypeDef.Integer, - (int)Aas.DataTypeDef.Long, - (int)Aas.DataTypeDef.Int, - (int)Aas.DataTypeDef.Short, - (int)Aas.DataTypeDef.Byte, - (int)Aas.DataTypeDef.NonNegativeInteger, - (int)Aas.DataTypeDef.PositiveInteger, - (int)Aas.DataTypeDef.UnsignedLong, - (int)Aas.DataTypeDef.UnsignedInt, - (int)Aas.DataTypeDef.UnsignedShort, - (int)Aas.DataTypeDef.UnsignedByte, - (int)Aas.DataTypeDef.NonPositiveInteger, - (int)Aas.DataTypeDef.NegativeInteger, - (int)Aas.DataTypeDef.LangString + (int)Aas.LevelType.Min, + (int)Aas.LevelType.Max, + (int)Aas.LevelType.Nom, + (int)Aas.LevelType.Typ }; } // internal static class EnumValueSet @@ -2550,6 +2659,16 @@ private class Transformer public override IEnumerable Transform( Aas.Extension that) { + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); + } + if (!( !(that.SupplementalSemanticIds != null) || (that.SemanticId != null))) @@ -2557,9 +2676,7 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); } if (!( @@ -2568,8 +2685,7 @@ private class Transformer { yield return new Reporting.Error( "Invariant violated:\n" + - "!(that.Value != null)\n" + - "|| Verification.ValueConsistentWithXsdType(that.Value, that.ValueTypeOrDefault())"); + "The value must match the value type."); } if (that.SemanticId != null) @@ -2651,6 +2767,16 @@ private class Transformer public override IEnumerable Transform( Aas.AdministrativeInformation that) { + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); + } + if (!( !(that.Revision != null) || (that.Version != null))) @@ -2660,27 +2786,25 @@ private class Transformer "Constraint AASd-005: If version is not specified then also " + "revision shall be unspecified. This means, a revision " + "requires a version. If there is no version there is no " + - "revision either. Revision is optional.\n" + - "!(that.Revision != null)\n" + - "|| (that.Version != null)"); + "revision either. Revision is optional."); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -2711,6 +2835,16 @@ private class Transformer public override IEnumerable Transform( Aas.Qualifier that) { + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); + } + if (!( !(that.SupplementalSemanticIds != null) || (that.SemanticId != null))) @@ -2718,9 +2852,7 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); } if (!( @@ -2730,9 +2862,7 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-020: The value shall be consistent to " + - "the data type as defined in value type.\n" + - "!(that.Value != null)\n" + - "|| Verification.ValueConsistentWithXsdType(that.Value, that.ValueType)"); + "the data type as defined in value type."); } if (that.SemanticId != null) @@ -2822,6 +2952,15 @@ private class Transformer public override IEnumerable Transform( Aas.AssetAdministrationShell that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -2829,9 +2968,63 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); + } + + if (!( + !(that.Submodels != null) + || (that.Submodels.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Submodels must be either not set or have at least one item"); } if (!( @@ -2842,10 +3035,8 @@ private class Transformer { yield return new Reporting.Error( "Invariant violated:\n" + - "!(that.DerivedFrom != null)\n" + - "|| Verification.IsModelReferenceTo(\n" + - " that.DerivedFrom,\n" + - " KeyTypes.AssetAdministrationShell)"); + "Derived-from must be a model reference to an asset " + + "administration shell."); } if (!( @@ -2857,11 +3048,7 @@ private class Transformer { yield return new Reporting.Error( "Invariant violated:\n" + - "!(that.Submodels != null)\n" + - "|| (\n" + - " that.Submodels.All(\n" + - " reference => Verification.IsModelReferenceTo(reference, KeyTypes.Submodel))\n" + - ")"); + "All submodels must be model references to a submodel."); } if (that.Extensions != null) @@ -2907,23 +3094,39 @@ private class Transformer if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -2957,22 +3160,22 @@ private class Transformer yield return error; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -3019,6 +3222,16 @@ private class Transformer public override IEnumerable Transform( Aas.AssetInformation that) { + if (!( + !(that.SpecificAssetIds != null) + || (that.SpecificAssetIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Specific asset IDs must be either not set or have at least " + + "one item"); + } + foreach (var error in Verification.VerifyAssetKind(that.AssetKind)) { error.PrependSegment( @@ -3097,6 +3310,16 @@ private class Transformer public override IEnumerable Transform( Aas.SpecificAssetId that) { + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); + } + if (!( !(that.SupplementalSemanticIds != null) || (that.SemanticId != null))) @@ -3104,9 +3327,7 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); } if (that.SemanticId != null) @@ -3168,6 +3389,15 @@ private class Transformer public override IEnumerable Transform( Aas.Submodel that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -3175,9 +3405,54 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -3187,9 +3462,16 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -3199,9 +3481,27 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); + } + + if (!( + !(that.SubmodelElements != null) + || (that.SubmodelElements.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Submodel elements must be either not set or have at least " + + "one item"); } if (!( @@ -3213,12 +3513,7 @@ private class Transformer { yield return new Reporting.Error( "Invariant violated:\n" + - "ID-shorts need to be defined for all the submodel elements.\n" + - "!(that.SubmodelElements != null)\n" + - "|| (\n" + - " that.SubmodelElements.All(\n" + - " element => element.IdShort != null)\n" + - ")"); + "ID-shorts need to be defined for all the submodel elements."); } if (!( @@ -3228,9 +3523,7 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-120: ID-short of non-identifiable " + - "referables shall be unique in its namespace.\n" + - "!(that.SubmodelElements != null)\n" + - "|| Verification.IdShortsAreUnique(that.SubmodelElements)"); + "referables shall be unique in its namespace."); } if (!( @@ -3248,15 +3541,7 @@ private class Transformer "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); } if (that.Extensions != null) @@ -3302,23 +3587,39 @@ private class Transformer if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -3415,22 +3716,22 @@ private class Transformer } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -3458,6 +3759,15 @@ private class Transformer public override IEnumerable Transform( Aas.RelationshipElement that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -3465,64 +3775,116 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); } if (!( - !(that.SupplementalSemanticIds != null) - || (that.SemanticId != null))) + !(that.Description != null) + || (that.Description.Count >= 1))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "Description must be either not set or have at least one item"); } if (!( - !(that.Qualifiers != null) - || Verification.QualifierTypesAreUnique(that.Qualifiers))) + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "Description specifies no duplicate languages"); } if (!( - !(that.Qualifiers != null) - || ( - !( - that.Qualifiers.Any( - qualifier => qualifier.Kind == QualifierKind.TemplateQualifier) - ) - || (that.KindOrDefault() == ModelingKind.Template) - ))) + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-119: If any qualifier kind value of " + - "a qualifiable qualifier is equal to template qualifier and " + - "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "Display name must be either not set or have at least one " + + "item"); } - if (that.Extensions != null) + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) { - int indexExtensions = 0; + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SemanticId != null))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); + } + + if (!( + !(that.Qualifiers != null) + || Verification.QualifierTypesAreUnique(that.Qualifiers))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); + } + + if (!( + !(that.Qualifiers != null) + || ( + !( + that.Qualifiers.Any( + qualifier => qualifier.Kind == QualifierKind.TemplateQualifier) + ) + || (that.KindOrDefault() == ModelingKind.Template) + ))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-119: If any qualifier kind value of " + + "a qualifiable qualifier is equal to template qualifier and " + + "the qualified element has kind then the qualified element " + + "shall be of kind template."); + } + + if (that.Extensions != null) + { + int indexExtensions = 0; foreach (var item in that.Extensions) { foreach (var error in Verification.Verify(item)) @@ -3563,23 +3925,39 @@ private class Transformer if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -3657,22 +4035,22 @@ private class Transformer } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -3697,6 +4075,15 @@ private class Transformer public override IEnumerable Transform( Aas.SubmodelElementList that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -3704,9 +4091,54 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -3716,9 +4148,16 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -3728,9 +4167,17 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -3748,15 +4195,16 @@ private class Transformer "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); + } + + if (!( + !(that.Value != null) + || (that.Value.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Value must be either not set or have at least one item"); } if (!( @@ -3774,16 +4222,7 @@ private class Transformer "Invariant violated:\n" + "Constraint AASd-107: If a first level child element has " + "a semantic ID it shall be identical to semantic ID list " + - "element.\n" + - "!(\n" + - " (that.Value != null)\n" + - " && (that.SemanticIdListElement != null)\n" + - ")\n" + - "|| (\n" + - " that.Value.All(\n" + - " child => !(child.SemanticId != null)\n" + - " || Verification.ReferenceKeyValuesEqual(child.SemanticId, that.SemanticIdListElement))\n" + - ")"); + "element."); } if (!( @@ -3793,9 +4232,7 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-114: If two first level child elements have " + - "a semantic ID then they shall be identical.\n" + - "!(that.Value != null)\n" + - "|| Verification.SubmodelElementsHaveIdenticalSemanticIds(that.Value)"); + "a semantic ID then they shall be identical."); } if (!( @@ -3809,12 +4246,7 @@ private class Transformer "Invariant violated:\n" + "Constraint AASd-108: All first level child elements shall " + "have the same submodel element type as specified in type " + - "value list element.\n" + - "!(that.Value != null)\n" + - "|| (\n" + - " that.Value.All(\n" + - " element => Verification.SubmodelElementIsOfType(element, that.TypeValueListElement))\n" + - ")"); + "value list element."); } if (!( @@ -3835,18 +4267,7 @@ private class Transformer "Constraint AASd-109: If type value list element is equal to " + "Property or Range value type list element shall be set and " + "all first level child elements shall have the value type as " + - "specified in value type list element.\n" + - "!(\n" + - " (that.Value != null)\n" + - " && (\n" + - " that.TypeValueListElement == AasSubmodelElements.Property\n" + - " || that.TypeValueListElement == AasSubmodelElements.Range\n" + - " )\n" + - ")\n" + - "|| (\n" + - " (that.ValueTypeListElement != null)\n" + - " && Verification.PropertiesOrRangesHaveValueType(that.Value, that.ValueTypeListElement)\n" + - ")"); + "specified in value type list element."); } if (!( @@ -3859,12 +4280,7 @@ private class Transformer yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-120: ID-shorts of submodel elements within " + - "a SubmodelElementList shall not be specified.\n" + - "!(that.Value != null)\n" + - "|| (\n" + - " that.Value.All(\n" + - " element => element.IdShort == null)\n" + - ")"); + "a SubmodelElementList shall not be specified."); } if (that.Extensions != null) @@ -3910,23 +4326,39 @@ private class Transformer if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -4004,22 +4436,22 @@ private class Transformer } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -4082,6 +4514,15 @@ var error in Verification.VerifyAasSubmodelElements( public override IEnumerable Transform( Aas.SubmodelElementCollection that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -4089,9 +4530,54 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -4101,9 +4587,16 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -4113,9 +4606,17 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -4133,15 +4634,16 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); + } + + if (!( + !(that.Value != null) + || (that.Value.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Value must be either not set or have at least one item"); } if (!( @@ -4153,12 +4655,7 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "ID-shorts need to be defined for all the elements.\n" + - "!(that.Value != null)\n" + - "|| (\n" + - " that.Value.All(\n" + - " element => element.IdShort != null)\n" + - ")"); + "ID-shorts need to be defined for all the elements."); } if (!( @@ -4167,8 +4664,7 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "!(that.Value != null)\n" + - "|| Verification.IdShortsAreUnique(that.Value)"); + "ID-shorts of the value must be unique."); } if (that.Extensions != null) @@ -4214,23 +4710,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -4308,22 +4820,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -4353,42 +4865,111 @@ var error in Verification.VerifyAasSubmodelElements( { if (!( !(that.Extensions != null) - || Verification.ExtensionNamesAreUnique(that.Extensions))) + || (that.Extensions.Count >= 1))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Extensions must be either not set or have at least one item"); } if (!( - !(that.SupplementalSemanticIds != null) - || (that.SemanticId != null))) + !(that.Extensions != null) + || Verification.ExtensionNamesAreUnique(that.Extensions))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."); } if (!( - !(that.Qualifiers != null) - || Verification.QualifierTypesAreUnique(that.Qualifiers))) + !(that.Description != null) + || (that.Description.Count >= 1))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "Description must be either not set or have at least one item"); } if (!( - !(that.Qualifiers != null) + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SemanticId != null))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); + } + + if (!( + !(that.Qualifiers != null) + || Verification.QualifierTypesAreUnique(that.Qualifiers))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); + } + + if (!( + !(that.Qualifiers != null) || ( !( that.Qualifiers.Any( @@ -4402,27 +4983,17 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); } if (!( !(that.Category != null) - || Verification.DataElementCategoryIsValid(that.Category))) + || Aas.Constants.ValidCategoriesForDataElement.Contains(that.Category))) { yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-090: For data elements category shall be " + - "one of the following values: CONSTANT, PARAMETER or VARIABLE\n" + - "!(that.Category != null)\n" + - "|| Verification.DataElementCategoryIsValid(that.Category)"); + "one of the following values: CONSTANT, PARAMETER or VARIABLE"); } if (!( @@ -4431,8 +5002,7 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "!(that.Value != null)\n" + - "|| Verification.ValueConsistentWithXsdType(that.Value, that.ValueType)"); + "Value must be consistent with the value type."); } if (that.Extensions != null) @@ -4478,23 +5048,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -4572,22 +5158,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -4626,6 +5212,15 @@ var error in Verification.VerifyAasSubmodelElements( public override IEnumerable Transform( Aas.MultiLanguageProperty that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -4633,9 +5228,54 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -4645,9 +5285,16 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -4657,9 +5304,17 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -4677,27 +5332,35 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); } if (!( !(that.Category != null) - || Verification.DataElementCategoryIsValid(that.Category))) + || Aas.Constants.ValidCategoriesForDataElement.Contains(that.Category))) { yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-090: For data elements category shall be " + - "one of the following values: CONSTANT, PARAMETER or VARIABLE\n" + - "!(that.Category != null)\n" + - "|| Verification.DataElementCategoryIsValid(that.Category)"); + "one of the following values: CONSTANT, PARAMETER or VARIABLE"); + } + + if (!( + !(that.Value != null) + || Verification.LangStringsHaveUniqueLanguages(that.Value))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Value specifies no duplicate languages"); + } + + if (!( + !(that.Value != null) + || (that.Value.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Value must be either not set or have at least one item"); } if (that.Extensions != null) @@ -4743,23 +5406,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -4837,33 +5516,41 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } if (that.Value != null) { - foreach (var error in Verification.Verify(that.Value)) + int indexValue = 0; + foreach (var item in that.Value) { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexValue)); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + yield return error; + } + indexValue++; } } @@ -4883,6 +5570,15 @@ var error in Verification.VerifyAasSubmodelElements( public override IEnumerable Transform( Aas.Range that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -4890,9 +5586,54 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -4902,9 +5643,16 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -4914,9 +5662,17 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -4934,27 +5690,17 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); } if (!( !(that.Category != null) - || Verification.DataElementCategoryIsValid(that.Category))) + || Aas.Constants.ValidCategoriesForDataElement.Contains(that.Category))) { yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-090: For data elements category shall be " + - "one of the following values: CONSTANT, PARAMETER or VARIABLE\n" + - "!(that.Category != null)\n" + - "|| Verification.DataElementCategoryIsValid(that.Category)"); + "one of the following values: CONSTANT, PARAMETER or VARIABLE"); } if (!( @@ -4963,8 +5709,7 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "!(that.Max != null)\n" + - "|| Verification.ValueConsistentWithXsdType(that.Max, that.ValueType)"); + "Max must be consistent with the value type."); } if (!( @@ -4973,8 +5718,7 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "!(that.Min != null)\n" + - "|| Verification.ValueConsistentWithXsdType(that.Min, that.ValueType)"); + "Min must be consistent with the value type."); } if (that.Extensions != null) @@ -5020,29 +5764,45 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; - } - } - - if (that.Checksum != null) - { - foreach (var error in Verification.VerifyNonEmptyString(that.Checksum)) + int indexDescription = 0; + foreach (var item in that.Description) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; + } + } + + if (that.Checksum != null) + { + foreach (var error in Verification.VerifyNonEmptyString(that.Checksum)) { error.PrependSegment( new Reporting.NameSegment( @@ -5114,22 +5874,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -5168,6 +5928,15 @@ var error in Verification.VerifyAasSubmodelElements( public override IEnumerable Transform( Aas.ReferenceElement that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -5175,9 +5944,54 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -5187,9 +6001,16 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -5199,9 +6020,17 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -5219,27 +6048,17 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); } if (!( !(that.Category != null) - || Verification.DataElementCategoryIsValid(that.Category))) + || Aas.Constants.ValidCategoriesForDataElement.Contains(that.Category))) { yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-090: For data elements category shall be " + - "one of the following values: CONSTANT, PARAMETER or VARIABLE\n" + - "!(that.Category != null)\n" + - "|| Verification.DataElementCategoryIsValid(that.Category)"); + "one of the following values: CONSTANT, PARAMETER or VARIABLE"); } if (that.Extensions != null) @@ -5285,23 +6104,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -5379,22 +6214,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -5414,6 +6249,15 @@ var error in Verification.VerifyAasSubmodelElements( public override IEnumerable Transform( Aas.Blob that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -5421,9 +6265,54 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -5433,9 +6322,16 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -5445,9 +6341,17 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -5465,27 +6369,17 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); } if (!( !(that.Category != null) - || Verification.DataElementCategoryIsValid(that.Category))) + || Aas.Constants.ValidCategoriesForDataElement.Contains(that.Category))) { yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-090: For data elements category shall be " + - "one of the following values: CONSTANT, PARAMETER or VARIABLE\n" + - "!(that.Category != null)\n" + - "|| Verification.DataElementCategoryIsValid(that.Category)"); + "one of the following values: CONSTANT, PARAMETER or VARIABLE"); } if (that.Extensions != null) @@ -5531,23 +6425,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -5625,22 +6535,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -5668,6 +6578,15 @@ var error in Verification.VerifyAasSubmodelElements( public override IEnumerable Transform( Aas.File that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -5675,9 +6594,54 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -5687,9 +6651,16 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -5699,9 +6670,17 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -5719,27 +6698,17 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); } if (!( !(that.Category != null) - || Verification.DataElementCategoryIsValid(that.Category))) + || Aas.Constants.ValidCategoriesForDataElement.Contains(that.Category))) { yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-090: For data elements category shall be " + - "one of the following values: CONSTANT, PARAMETER or VARIABLE\n" + - "!(that.Category != null)\n" + - "|| Verification.DataElementCategoryIsValid(that.Category)"); + "one of the following values: CONSTANT, PARAMETER or VARIABLE"); } if (that.Extensions != null) @@ -5785,23 +6754,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -5879,22 +6864,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -5924,64 +6909,134 @@ var error in Verification.VerifyAasSubmodelElements( { if (!( !(that.Extensions != null) - || Verification.ExtensionNamesAreUnique(that.Extensions))) + || (that.Extensions.Count >= 1))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Extensions must be either not set or have at least one item"); } if (!( - !(that.SupplementalSemanticIds != null) - || (that.SemanticId != null))) + !(that.Extensions != null) + || Verification.ExtensionNamesAreUnique(that.Extensions))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."); } if (!( - !(that.Qualifiers != null) - || Verification.QualifierTypesAreUnique(that.Qualifiers))) + !(that.Description != null) + || (that.Description.Count >= 1))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "Description must be either not set or have at least one item"); } if (!( - !(that.Qualifiers != null) - || ( - !( - that.Qualifiers.Any( - qualifier => qualifier.Kind == QualifierKind.TemplateQualifier) - ) - || (that.KindOrDefault() == ModelingKind.Template) - ))) + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-119: If any qualifier kind value of " + - "a qualifiable qualifier is equal to template qualifier and " + - "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SemanticId != null))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); + } + + if (!( + !(that.Qualifiers != null) + || Verification.QualifierTypesAreUnique(that.Qualifiers))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-021: Every qualifiable can only have one " + + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); + } + + if (!( + !(that.Qualifiers != null) + || ( + !( + that.Qualifiers.Any( + qualifier => qualifier.Kind == QualifierKind.TemplateQualifier) + ) + || (that.KindOrDefault() == ModelingKind.Template) + ))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-119: If any qualifier kind value of " + + "a qualifiable qualifier is equal to template qualifier and " + + "the qualified element has kind then the qualified element " + + "shall be of kind template."); + } + + if (!( + !(that.Annotations != null) + || (that.Annotations.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Annotations must be either not set or have at least one item"); } if (that.Extensions != null) @@ -6027,23 +7082,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -6121,22 +7192,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -6180,6 +7251,15 @@ var error in Verification.VerifyAasSubmodelElements( public override IEnumerable Transform( Aas.Entity that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -6187,9 +7267,54 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -6199,9 +7324,16 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -6211,9 +7343,17 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -6231,15 +7371,16 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); + } + + if (!( + !(that.Statements != null) + || (that.Statements.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Statements must be either not set or have at least one item"); } if (!( @@ -6265,24 +7406,7 @@ var error in Verification.VerifyAasSubmodelElements( "Invariant violated:\n" + "Constraint AASd-014: Either the attribute global asset ID " + "or specific asset ID must be set if entity type is set to " + - "'SelfManagedEntity'. They are not existing otherwise.\n" + - "(\n" + - " that.EntityType == EntityType.SelfManagedEntity\n" + - " && (\n" + - " (\n" + - " (that.GlobalAssetId != null)\n" + - " && (that.SpecificAssetId == null)\n" + - " )\n" + - " || (\n" + - " (that.GlobalAssetId == null)\n" + - " && (that.SpecificAssetId != null)\n" + - " )\n" + - " )\n" + - ")\n" + - "|| (\n" + - " (that.GlobalAssetId == null)\n" + - " && (that.SpecificAssetId == null)\n" + - ")"); + "'SelfManagedEntity'. They are not existing otherwise."); } if (that.Extensions != null) @@ -6328,23 +7452,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -6422,22 +7562,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -6496,19 +7636,20 @@ var error in Verification.VerifyAasSubmodelElements( Aas.EventPayload that) { if (!( - Verification.IsModelReferenceTo(that.Source, KeyTypes.Referable))) + Verification.IsModelReferenceToReferable(that.Source))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Verification.IsModelReferenceTo(that.Source, KeyTypes.Referable)"); + "Source must be a model reference to a referable."); } if (!( - Verification.IsModelReferenceTo(that.ObservableReference, KeyTypes.Referable))) + Verification.IsModelReferenceToReferable(that.ObservableReference))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Verification.IsModelReferenceTo(that.ObservableReference, KeyTypes.Referable)"); + "Observable reference must be a model reference to " + + "a referable."); } foreach (var error in Verification.Verify(that.Source)) @@ -6595,6 +7736,15 @@ var error in Verification.VerifyAasSubmodelElements( public override IEnumerable Transform( Aas.BasicEventElement that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -6602,9 +7752,54 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -6614,9 +7809,16 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -6626,9 +7828,17 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -6646,15 +7856,7 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); } if (!( @@ -6663,27 +7865,24 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "Max. interval is not applicable for input direction\n" + - "!(that.Direction == Direction.Input)\n" + - "|| (that.MaxInterval == null)"); + "Max. interval is not applicable for input direction"); } if (!( - Verification.IsModelReferenceTo(that.Observed, KeyTypes.Referable))) + Verification.IsModelReferenceToReferable(that.Observed))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Verification.IsModelReferenceTo(that.Observed, KeyTypes.Referable)"); + "Observed must be a model reference to a referable."); } if (!( !(that.MessageBroker != null) - || Verification.IsModelReferenceTo(that.MessageBroker, KeyTypes.Referable))) + || Verification.IsModelReferenceToReferable(that.MessageBroker))) { yield return new Reporting.Error( "Invariant violated:\n" + - "!(that.MessageBroker != null)\n" + - "|| Verification.IsModelReferenceTo(that.MessageBroker, KeyTypes.Referable)"); + "Message broker must be a model reference to a referable."); } if (that.Extensions != null) @@ -6729,23 +7928,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -6823,22 +8038,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -6928,38 +8143,107 @@ var error in Verification.VerifyAasSubmodelElements( { if (!( !(that.Extensions != null) - || Verification.ExtensionNamesAreUnique(that.Extensions))) + || (that.Extensions.Count >= 1))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Extensions must be either not set or have at least one item"); } if (!( - !(that.SupplementalSemanticIds != null) - || (that.SemanticId != null))) + !(that.Extensions != null) + || Verification.ExtensionNamesAreUnique(that.Extensions))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "Constraint AASd-077: The name of an extension within " + + "Has-Extensions needs to be unique."); } if (!( - !(that.Qualifiers != null) + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SemanticId != null))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-118: If there are supplemental semantic IDs " + + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); + } + + if (!( + !(that.Qualifiers != null) || Verification.QualifierTypesAreUnique(that.Qualifiers))) { yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -6977,15 +8261,37 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); + } + + if (!( + !(that.InputVariables != null) + || (that.InputVariables.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Input variables must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.OutputVariables != null) + || (that.OutputVariables.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Output variables must be either not set or have at least " + + "one item"); + } + + if (!( + !(that.InoutputVariables != null) + || (that.InoutputVariables.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Inoutput variables must be either not set or have at least " + + "one item"); } if (that.Extensions != null) @@ -7031,23 +8337,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -7125,22 +8447,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -7219,6 +8541,15 @@ var error in Verification.VerifyAasSubmodelElements( public override IEnumerable Transform( Aas.Capability that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -7226,9 +8557,54 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); + } + + if (!( + !(that.Description != null) + || (that.Description.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description must be either not set or have at least one item"); + } + + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); + } + + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); + } + + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); + } + + if (!( + !(that.SupplementalSemanticIds != null) + || (that.SupplementalSemanticIds.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Supplemental semantic IDs must be either not set or have at " + + "least one item"); } if (!( @@ -7238,9 +8614,16 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-118: If there are supplemental semantic IDs " + - "defined then there shall be also a main semantic ID.\n" + - "!(that.SupplementalSemanticIds != null)\n" + - "|| (that.SemanticId != null)"); + "defined then there shall be also a main semantic ID."); + } + + if (!( + !(that.Qualifiers != null) + || (that.Qualifiers.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Qualifiers must be either not set or have at least one item"); } if (!( @@ -7250,9 +8633,17 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-021: Every qualifiable can only have one " + - "qualifier with the same type.\n" + - "!(that.Qualifiers != null)\n" + - "|| Verification.QualifierTypesAreUnique(that.Qualifiers)"); + "qualifier with the same type."); + } + + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } if (!( @@ -7270,15 +8661,7 @@ var error in Verification.VerifyAasSubmodelElements( "Constraint AASd-119: If any qualifier kind value of " + "a qualifiable qualifier is equal to template qualifier and " + "the qualified element has kind then the qualified element " + - "shall be of kind template.\n" + - "!(that.Qualifiers != null)\n" + - "|| (\n" + - " !(\n" + - " that.Qualifiers.Any(\n" + - " qualifier => qualifier.Kind == QualifierKind.TemplateQualifier)\n" + - " )\n" + - " || (that.KindOrDefault() == ModelingKind.Template)\n" + - ")"); + "shall be of kind template."); } if (that.Extensions != null) @@ -7324,23 +8707,39 @@ var error in Verification.VerifyAasSubmodelElements( if (that.DisplayName != null) { - foreach (var error in Verification.Verify(that.DisplayName)) + int indexDisplayName = 0; + foreach (var item in that.DisplayName) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; } } if (that.Description != null) { - foreach (var error in Verification.Verify(that.Description)) + int indexDescription = 0; + foreach (var item in that.Description) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; } } @@ -7418,22 +8817,22 @@ var error in Verification.VerifyAasSubmodelElements( } } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } } @@ -7442,6 +8841,15 @@ var error in Verification.VerifyAasSubmodelElements( public override IEnumerable Transform( Aas.ConceptDescription that) { + if (!( + !(that.Extensions != null) + || (that.Extensions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Extensions must be either not set or have at least one item"); + } + if (!( !(that.Extensions != null) || Verification.ExtensionNamesAreUnique(that.Extensions))) @@ -7449,102 +8857,271 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-077: The name of an extension within " + - "Has-Extensions needs to be unique.\n" + - "!(that.Extensions != null)\n" + - "|| Verification.ExtensionNamesAreUnique(that.Extensions)"); + "Has-Extensions needs to be unique."); } if (!( - !(that.Category != null) - || Verification.ConceptDescriptionCategoryIsValid(that.Category))) + !(that.Description != null) + || (that.Description.Count >= 1))) { yield return new Reporting.Error( "Invariant violated:\n" + - "Constraint AASd-051: A concept description shall have one " + - "of the following categories: 'VALUE', 'PROPERTY', " + - "'REFERENCE', 'DOCUMENT', 'CAPABILITY',; 'RELATIONSHIP', " + - "'COLLECTION', 'FUNCTION', 'EVENT', 'ENTITY', " + - "'APPLICATION_CLASS', 'QUALIFIER', 'VIEW'.\n" + - "!(that.Category != null)\n" + - "|| Verification.ConceptDescriptionCategoryIsValid(that.Category)"); + "Description must be either not set or have at least one item"); } - if (that.Extensions != null) + if (!( + !(that.Description != null) + || Verification.LangStringsHaveUniqueLanguages(that.Description))) { - int indexExtensions = 0; - foreach (var item in that.Extensions) - { - foreach (var error in Verification.Verify(item)) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexExtensions)); - error.PrependSegment( - new Reporting.NameSegment( - "extensions")); - yield return error; - } - indexExtensions++; - } + yield return new Reporting.Error( + "Invariant violated:\n" + + "Description specifies no duplicate languages"); } - if (that.Category != null) + if (!( + !(that.DisplayName != null) + || (that.DisplayName.Count >= 1))) { - foreach (var error in Verification.VerifyNonEmptyString(that.Category)) - { - error.PrependSegment( - new Reporting.NameSegment( - "category")); - yield return error; - } + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name must be either not set or have at least one " + + "item"); } - if (that.IdShort != null) + if (!( + !(that.DisplayName != null) + || Verification.LangStringsHaveUniqueLanguages(that.DisplayName))) { - foreach (var error in Verification.VerifyIdShort(that.IdShort)) - { - error.PrependSegment( - new Reporting.NameSegment( - "idShort")); - yield return error; - } + yield return new Reporting.Error( + "Invariant violated:\n" + + "Display name specifies no duplicate languages"); } - if (that.DisplayName != null) + if (!( + !(that.EmbeddedDataSpecifications != null) + || (that.EmbeddedDataSpecifications.Count >= 1))) { - foreach (var error in Verification.Verify(that.DisplayName)) - { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - yield return error; - } + yield return new Reporting.Error( + "Invariant violated:\n" + + "Embedded data specifications must be either not set or have " + + "at least one item"); } - if (that.Description != null) + if (!( + !(that.IsCaseOf != null) + || (that.IsCaseOf.Count >= 1))) { - foreach (var error in Verification.Verify(that.Description)) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - yield return error; - } + yield return new Reporting.Error( + "Invariant violated:\n" + + "Is-case-of must be either not set or have at least one item"); } - if (that.Checksum != null) + if (!( + !(that.Category != null) + || Aas.Constants.ValidCategoriesForConceptDescription.Contains(that.Category))) { - foreach (var error in Verification.VerifyNonEmptyString(that.Checksum)) - { - error.PrependSegment( - new Reporting.NameSegment( - "checksum")); - yield return error; - } + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-051: A concept description shall have one " + + "of the following categories: 'VALUE', 'PROPERTY', " + + "'REFERENCE', 'DOCUMENT', 'CAPABILITY',; 'RELATIONSHIP', " + + "'COLLECTION', 'FUNCTION', 'EVENT', 'ENTITY', " + + "'APPLICATION_CLASS', 'QUALIFIER', 'VIEW'."); } - if (that.Administration != null) - { + if (!( + !( + (that.Category != null) + && that.Category != "VALUE" + && (that.EmbeddedDataSpecifications != null) + ) + || Verification.DataSpecificationIec61360sHaveDefinitionAtLeastInEnglish(that.EmbeddedDataSpecifications))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-003: For all concept descriptions with " + + "a category except VALUE using data specification IEC 61360, " + + "the definition of the data specification is mandatory and " + + "shall be defined at least in English."); + } + + if (!( + !( + (that.Category != null) + && that.Category == "VALUE" + && (that.EmbeddedDataSpecifications != null) + ) + || Verification.DataSpecificationIec61360sHaveValue(that.EmbeddedDataSpecifications))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-008: For a concept description with " + + "category VALUE using data specification IEC 61360, " + + "the value of the data specification shall be set."); + } + + if (!( + !( + (that.Category != null) + && that.Category == "QUALIFIER_TYPE" + && (that.EmbeddedDataSpecifications != null) + ) + || Verification.DataSpecificationIec61360sHaveDataType(that.EmbeddedDataSpecifications))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-007: For a concept description with " + + "category QUALIFIER_TYPE using data specification IEC 61360, " + + "the data type of the data specification is mandatory and " + + "shall be defined."); + } + + if (!( + !( + (that.Category != null) + && that.Category == "DOCUMENT" + && (that.EmbeddedDataSpecifications != null) + ) + || Verification.DataSpecificationIec61360sForDocumentHaveAppropriateDataType(that.EmbeddedDataSpecifications))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-006: For a concept description with " + + "category DOCUMENT using data specification IEC 61360, " + + "the data type of the data specification is mandatory and " + + "shall be one of: FILE, BLOB, HTML."); + } + + if (!( + !( + (that.Category != null) + && that.Category == "REFERENCE" + && (that.EmbeddedDataSpecifications != null) + ) + || Verification.DataSpecificationIec61360sForReferenceHaveAppropriateDataType(that.EmbeddedDataSpecifications))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-005: For a concept description with " + + "category REFERENCE using data specification IEC 61360, " + + "the data type of the data specification is mandatory and " + + "shall be one of: STRING, IRI, IRDI."); + } + + if (!( + !( + (that.Category != null) + && ( + that.Category == "PROPERTY" + || that.Category == "VALUE" + ) + && (that.EmbeddedDataSpecifications != null) + ) + || Verification.DataSpecificationIec61360sForPropertyOrValueHaveAppropriateDataType(that.EmbeddedDataSpecifications))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-004: For a concept description with " + + "category PROPERTY or VALUE using data specification IEC " + + "61360, the data type of the data specification is mandatory " + + "and shall be one of: DATE, STRING, STRING_TRANSLATABLE, " + + "INTEGER_MEASURE, INTEGER_COUNT, INTEGER_CURRENCY, " + + "REAL_MEASURE, REAL_COUNT, REAL_CURRENCY, BOOLEAN, RATIONAL, " + + "RATIONAL_MEASURE, TIME, TIMESTAMP."); + } + + if (that.Extensions != null) + { + int indexExtensions = 0; + foreach (var item in that.Extensions) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); + yield return error; + } + indexExtensions++; + } + } + + if (that.Category != null) + { + foreach (var error in Verification.VerifyNonEmptyString(that.Category)) + { + error.PrependSegment( + new Reporting.NameSegment( + "category")); + yield return error; + } + } + + if (that.IdShort != null) + { + foreach (var error in Verification.VerifyIdShort(that.IdShort)) + { + error.PrependSegment( + new Reporting.NameSegment( + "idShort")); + yield return error; + } + } + + if (that.DisplayName != null) + { + int indexDisplayName = 0; + foreach (var item in that.DisplayName) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + yield return error; + } + indexDisplayName++; + } + } + + if (that.Description != null) + { + int indexDescription = 0; + foreach (var item in that.Description) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + yield return error; + } + indexDescription++; + } + } + + if (that.Checksum != null) + { + foreach (var error in Verification.VerifyNonEmptyString(that.Checksum)) + { + error.PrependSegment( + new Reporting.NameSegment( + "checksum")); + yield return error; + } + } + + if (that.Administration != null) + { foreach (var error in Verification.Verify(that.Administration)) { error.PrependSegment( @@ -7562,22 +9139,22 @@ var error in Verification.VerifyAasSubmodelElements( yield return error; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + int indexEmbeddedDataSpecifications = 0; + foreach (var item in that.EmbeddedDataSpecifications) { foreach (var error in Verification.Verify(item)) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); yield return error; } - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; } } @@ -7609,7 +9186,142 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "that.Keys.Count >= 1"); + "Keys must contain at least one item."); + } + + if (!( + !(that.Keys.Count >= 1) + || Aas.Constants.GloballyIdentifiables.Contains(that.Keys[0].Type))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-121: For References the type of the first " + + "key shall be one of Globally identifiables."); + } + + if (!( + !( + that.Type == ReferenceTypes.GlobalReference + && that.Keys.Count >= 1 + ) + || Aas.Constants.GenericGloballyIdentifiables.Contains(that.Keys[0].Type))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-122: For global references the type of " + + "the first key shall be one of Generic globally " + + "identifiables."); + } + + if (!( + !( + that.Type == ReferenceTypes.ModelReference + && that.Keys.Count >= 1 + ) + || Aas.Constants.AasIdentifiables.Contains(that.Keys[0].Type))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-123: For model references the type of " + + "the first key shall be one of AAS identifiables"); + } + + if (!( + !( + that.Type == ReferenceTypes.GlobalReference + && that.Keys.Count >= 1 + ) + || ( + Aas.Constants.GenericGloballyIdentifiables.Contains(that.Keys[^1].Type) + || Aas.Constants.GenericFragmentKeys.Contains(that.Keys[^1].Type) + ))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-124: For global references the last key " + + "shall be either one of Generic globally identifiables or " + + "one of Generic fragment keys."); + } + + if (!( + !( + that.Type == ReferenceTypes.ModelReference + && that.Keys.Count > 1 + ) + || ( + Enumerable.Range( + 1, + that.Keys.Count - 1 + ).All( + i => Aas.Constants.FragmentKeys.Contains(that.Keys[i].Type)) + ))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-125: For model references with more than " + + "one key, the type of the keys following the first key shall " + + "be one of Fragment keys."); + } + + if (!( + !( + that.Type == ReferenceTypes.ModelReference + && that.Keys.Count > 1 + ) + || ( + Enumerable.Range( + 0, + that.Keys.Count - 1 + ).All( + i => !Aas.Constants.GenericFragmentKeys.Contains(that.Keys[i].Type)) + ))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-126: For model references with more than " + + "one key, the type of the last key in the reference key " + + "chain may be one of Generic fragment keys or no key at all " + + "shall have a value out of Generic fragment keys."); + } + + if (!( + !( + that.Type == ReferenceTypes.ModelReference + && that.Keys.Count > 1 + && that.Keys[^1].Type == KeyTypes.FragmentReference + ) + || ( + that.Keys[^2].Type == KeyTypes.File + || that.Keys[^2].Type == KeyTypes.Blob + ))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-127: For model references with more than " + + "one key, a key with type Fragment reference shall be " + + "preceded by a key with type File or Blob."); + } + + if (!( + !( + that.Type == ReferenceTypes.ModelReference + && that.Keys.Count > 2 + ) + || ( + Enumerable.Range( + 0, + that.Keys.Count - 1 + ).All( + i => !(that.Keys[i].Type == KeyTypes.SubmodelElementList) + || Verification.MatchesXsPositiveInteger(that.Keys[i + 1].Value)) + ))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASd-128: For model references, the value of " + + "a key preceded by a key with type Submodel element list is " + + "an integer number denoting the position in the array of " + + "the submodel element list."); } foreach (var error in Verification.VerifyReferenceTypes(that.Type)) @@ -7631,221 +9343,622 @@ var error in Verification.VerifyAasSubmodelElements( } } - int indexKeys = 0; - foreach (var item in that.Keys) + int indexKeys = 0; + foreach (var item in that.Keys) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexKeys)); + error.PrependSegment( + new Reporting.NameSegment( + "keys")); + yield return error; + } + indexKeys++; + } + } + + [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] + public override IEnumerable Transform( + Aas.Key that) + { + foreach (var error in Verification.VerifyKeyTypes(that.Type)) + { + error.PrependSegment( + new Reporting.NameSegment( + "type")); + yield return error; + } + + foreach (var error in Verification.VerifyNonEmptyString(that.Value)) + { + error.PrependSegment( + new Reporting.NameSegment( + "value")); + yield return error; + } + } + + [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] + public override IEnumerable Transform( + Aas.LangString that) + { + foreach (var error in Verification.VerifyBcp47LanguageTag(that.Language)) + { + error.PrependSegment( + new Reporting.NameSegment( + "language")); + yield return error; + } + } + + [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] + public override IEnumerable Transform( + Aas.Environment that) + { + if (!( + !(that.ConceptDescriptions != null) + || (that.ConceptDescriptions.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Concept descriptions must be either not set or have at " + + "least one item"); + } + + if (!( + !(that.Submodels != null) + || (that.Submodels.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Submodels must be either not set or have at least one item"); + } + + if (!( + !(that.AssetAdministrationShells != null) + || (that.AssetAdministrationShells.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Asset administration shells must be either not set or have " + + "at least one item"); + } + + if (that.AssetAdministrationShells != null) + { + int indexAssetAdministrationShells = 0; + foreach (var item in that.AssetAdministrationShells) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexAssetAdministrationShells)); + error.PrependSegment( + new Reporting.NameSegment( + "assetAdministrationShells")); + yield return error; + } + indexAssetAdministrationShells++; + } + } + + if (that.Submodels != null) + { + int indexSubmodels = 0; + foreach (var item in that.Submodels) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSubmodels)); + error.PrependSegment( + new Reporting.NameSegment( + "submodels")); + yield return error; + } + indexSubmodels++; + } + } + + if (that.ConceptDescriptions != null) + { + int indexConceptDescriptions = 0; + foreach (var item in that.ConceptDescriptions) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexConceptDescriptions)); + error.PrependSegment( + new Reporting.NameSegment( + "conceptDescriptions")); + yield return error; + } + indexConceptDescriptions++; + } + } + } + + [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] + public override IEnumerable Transform( + Aas.EmbeddedDataSpecification that) + { + foreach (var error in Verification.Verify(that.DataSpecification)) + { + error.PrependSegment( + new Reporting.NameSegment( + "dataSpecification")); + yield return error; + } + + foreach (var error in Verification.Verify(that.DataSpecificationContent)) + { + error.PrependSegment( + new Reporting.NameSegment( + "dataSpecificationContent")); + yield return error; + } + } + + [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] + public override IEnumerable Transform( + Aas.ValueReferencePair that) + { + foreach (var error in Verification.Verify(that.ValueId)) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueId")); + yield return error; + } + } + + [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] + public override IEnumerable Transform( + Aas.ValueList that) + { + if (!(that.ValueReferencePairs.Count >= 1)) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Value reference pair types must contain at least one item."); + } + + int indexValueReferencePairs = 0; + foreach (var item in that.ValueReferencePairs) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexValueReferencePairs)); + error.PrependSegment( + new Reporting.NameSegment( + "valueReferencePairs")); + yield return error; + } + indexValueReferencePairs++; + } + } + + [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] + public override IEnumerable Transform( + Aas.DataSpecificationIec61360 that) + { + if (!( + ( + (that.Value != null) + && (that.ValueList == null) + ) + || ( + (that.Value == null) + && (that.ValueList != null) + && that.ValueList.ValueReferencePairs.Count >= 1 + ))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-010: If value is not empty then value list " + + "shall be empty and vice versa."); + } + + if (!( + !( + (that.DataType == null) + && Aas.Constants.Iec61360DataTypesWithUnit.Contains(that.DataType) + ) + || ( + (that.Unit != null) + || (that.UnitId != null) + ))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-009: If data type is a an integer, real or " + + "rational with a measure or currency, unit or unit ID shall " + + "be defined."); + } + + if (!( + !(that.Definition != null) + || (that.Definition.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Definition must be either not set or have at least one item"); + } + + if (!( + !(that.Definition != null) + || Verification.LangStringsHaveUniqueLanguages(that.Definition))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Definition specifies no duplicate languages"); + } + + if (!( + !(that.ShortName != null) + || (that.ShortName.Count >= 1))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Short name must be either not set or have at least one item"); + } + + if (!( + !(that.ShortName != null) + || Verification.LangStringsHaveUniqueLanguages(that.ShortName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Short name specifies no duplicate languages"); + } + + if (!(that.PreferredName.Count >= 1)) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Preferred name must have at least one item"); + } + + if (!( + Verification.LangStringsHaveUniqueLanguages(that.PreferredName))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Preferred name specifies no duplicate languages"); + } + + if (!( + that.PreferredName.Any( + langString => Verification.IsBcp47ForEnglish(langString.Language)))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Constraint AASc-002: preferred name shall be provided at " + + "least in English."); + } + + int indexPreferredName = 0; + foreach (var item in that.PreferredName) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexPreferredName)); + error.PrependSegment( + new Reporting.NameSegment( + "preferredName")); + yield return error; + } + indexPreferredName++; + } + + if (that.ShortName != null) + { + int indexShortName = 0; + foreach (var item in that.ShortName) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexShortName)); + error.PrependSegment( + new Reporting.NameSegment( + "shortName")); + yield return error; + } + indexShortName++; + } + } + + if (that.Unit != null) + { + foreach (var error in Verification.VerifyNonEmptyString(that.Unit)) + { + error.PrependSegment( + new Reporting.NameSegment( + "unit")); + yield return error; + } + } + + if (that.UnitId != null) + { + foreach (var error in Verification.Verify(that.UnitId)) + { + error.PrependSegment( + new Reporting.NameSegment( + "unitId")); + yield return error; + } + } + + if (that.SourceOfDefinition != null) + { + foreach ( + var error in Verification.VerifyNonEmptyString( + that.SourceOfDefinition)) + { + error.PrependSegment( + new Reporting.NameSegment( + "sourceOfDefinition")); + yield return error; + } + } + + if (that.Symbol != null) + { + foreach (var error in Verification.VerifyNonEmptyString(that.Symbol)) + { + error.PrependSegment( + new Reporting.NameSegment( + "symbol")); + yield return error; + } + } + + if (that.DataType != null) + { + // We need to help the static analyzer with a null coalescing. + Aas.DataTypeIec61360 value = that.DataType + ?? throw new System.InvalidOperationException(); + foreach (var error in Verification.VerifyDataTypeIec61360(value)) + { + error.PrependSegment( + new Reporting.NameSegment( + "dataType")); + yield return error; + } + } + + if (that.Definition != null) + { + int indexDefinition = 0; + foreach (var item in that.Definition) + { + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDefinition)); + error.PrependSegment( + new Reporting.NameSegment( + "definition")); + yield return error; + } + indexDefinition++; + } + } + + if (that.ValueFormat != null) + { + foreach (var error in Verification.VerifyNonEmptyString(that.ValueFormat)) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueFormat")); + yield return error; + } + } + + if (that.ValueList != null) + { + foreach (var error in Verification.Verify(that.ValueList)) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueList")); + yield return error; + } + } + + if (that.LevelType != null) { - foreach (var error in Verification.Verify(item)) + // We need to help the static analyzer with a null coalescing. + Aas.LevelType value = that.LevelType + ?? throw new System.InvalidOperationException(); + foreach (var error in Verification.VerifyLevelType(value)) { - error.PrependSegment( - new Reporting.IndexSegment( - indexKeys)); error.PrependSegment( new Reporting.NameSegment( - "keys")); + "levelType")); yield return error; } - indexKeys++; } } [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] public override IEnumerable Transform( - Aas.Key that) + Aas.DataSpecificationPhysicalUnit that) { - foreach (var error in Verification.VerifyKeyTypes(that.Type)) + if (!(that.Definition.Count >= 1)) { - error.PrependSegment( - new Reporting.NameSegment( - "type")); - yield return error; + yield return new Reporting.Error( + "Invariant violated:\n" + + "Definition must have at least one item"); } - foreach (var error in Verification.VerifyNonEmptyString(that.Value)) + if (!( + Verification.LangStringsHaveUniqueLanguages(that.Definition))) + { + yield return new Reporting.Error( + "Invariant violated:\n" + + "Definition specifies no duplicate languages"); + } + + foreach (var error in Verification.VerifyNonEmptyString(that.UnitName)) { error.PrependSegment( new Reporting.NameSegment( - "value")); + "unitName")); yield return error; } - } - [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] - public override IEnumerable Transform( - Aas.LangString that) - { - foreach (var error in Verification.VerifyBcp47LanguageTag(that.Language)) + foreach (var error in Verification.VerifyNonEmptyString(that.UnitSymbol)) { error.PrependSegment( new Reporting.NameSegment( - "language")); + "unitSymbol")); yield return error; } - } - [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] - public override IEnumerable Transform( - Aas.LangStringSet that) - { - if (!(that.LangStrings.Count >= 1)) + int indexDefinition = 0; + foreach (var item in that.Definition) { - yield return new Reporting.Error( - "Invariant violated:\n" + - "that.LangStrings.Count >= 1"); + foreach (var error in Verification.Verify(item)) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDefinition)); + error.PrependSegment( + new Reporting.NameSegment( + "definition")); + yield return error; + } + indexDefinition++; } - if (!( - Verification.LangStringsHaveUniqueLanguages(that.LangStrings))) + if (that.SiNotation != null) { - yield return new Reporting.Error( - "Invariant violated:\n" + - "Verification.LangStringsHaveUniqueLanguages(that.LangStrings)"); + foreach (var error in Verification.VerifyNonEmptyString(that.SiNotation)) + { + error.PrependSegment( + new Reporting.NameSegment( + "siNotation")); + yield return error; + } } - int indexLangStrings = 0; - foreach (var item in that.LangStrings) + if (that.SiName != null) { - foreach (var error in Verification.Verify(item)) + foreach (var error in Verification.VerifyNonEmptyString(that.SiName)) { - error.PrependSegment( - new Reporting.IndexSegment( - indexLangStrings)); error.PrependSegment( new Reporting.NameSegment( - "langStrings")); + "siName")); yield return error; } - indexLangStrings++; } - } - - [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] - public override IEnumerable Transform( - Aas.DataSpecificationContent that) - { - // No verification has been defined for DataSpecificationContent. - yield break; - } - [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] - public override IEnumerable Transform( - Aas.DataSpecification that) - { - foreach (var error in Verification.VerifyIdentifier(that.Id)) + if (that.DinNotation != null) { - error.PrependSegment( - new Reporting.NameSegment( - "id")); - yield return error; + foreach (var error in Verification.VerifyNonEmptyString(that.DinNotation)) + { + error.PrependSegment( + new Reporting.NameSegment( + "dinNotation")); + yield return error; + } } - foreach (var error in Verification.Verify(that.DataSpecificationContent)) + if (that.EceName != null) { - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecificationContent")); - yield return error; + foreach (var error in Verification.VerifyNonEmptyString(that.EceName)) + { + error.PrependSegment( + new Reporting.NameSegment( + "eceName")); + yield return error; + } } - if (that.Administration != null) + if (that.EceCode != null) { - foreach (var error in Verification.Verify(that.Administration)) + foreach (var error in Verification.VerifyNonEmptyString(that.EceCode)) { error.PrependSegment( new Reporting.NameSegment( - "administration")); + "eceCode")); yield return error; } } - if (that.Description != null) + if (that.NistName != null) { - foreach (var error in Verification.Verify(that.Description)) + foreach (var error in Verification.VerifyNonEmptyString(that.NistName)) { error.PrependSegment( new Reporting.NameSegment( - "description")); + "nistName")); yield return error; } } - } - [CodeAnalysis.SuppressMessage("ReSharper", "NegativeEqualityExpression")] - public override IEnumerable Transform( - Aas.Environment that) - { - if (that.AssetAdministrationShells != null) + if (that.SourceOfDefinition != null) { - int indexAssetAdministrationShells = 0; - foreach (var item in that.AssetAdministrationShells) + foreach ( + var error in Verification.VerifyNonEmptyString( + that.SourceOfDefinition)) { - foreach (var error in Verification.Verify(item)) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexAssetAdministrationShells)); - error.PrependSegment( - new Reporting.NameSegment( - "assetAdministrationShells")); - yield return error; - } - indexAssetAdministrationShells++; + error.PrependSegment( + new Reporting.NameSegment( + "sourceOfDefinition")); + yield return error; } } - if (that.Submodels != null) + if (that.ConversionFactor != null) { - int indexSubmodels = 0; - foreach (var item in that.Submodels) + foreach (var error in Verification.VerifyNonEmptyString(that.ConversionFactor)) { - foreach (var error in Verification.Verify(item)) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSubmodels)); - error.PrependSegment( - new Reporting.NameSegment( - "submodels")); - yield return error; - } - indexSubmodels++; + error.PrependSegment( + new Reporting.NameSegment( + "conversionFactor")); + yield return error; } } - if (that.ConceptDescriptions != null) + if (that.RegistrationAuthorityId != null) { - int indexConceptDescriptions = 0; - foreach (var item in that.ConceptDescriptions) + foreach ( + var error in Verification.VerifyNonEmptyString( + that.RegistrationAuthorityId)) { - foreach (var error in Verification.Verify(item)) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexConceptDescriptions)); - error.PrependSegment( - new Reporting.NameSegment( - "conceptDescriptions")); - yield return error; - } - indexConceptDescriptions++; + error.PrependSegment( + new Reporting.NameSegment( + "registrationAuthorityId")); + yield return error; } } - if (that.DataSpecifications != null) + if (that.Supplier != null) { - int indexDataSpecifications = 0; - foreach (var item in that.DataSpecifications) + foreach (var error in Verification.VerifyNonEmptyString(that.Supplier)) { - foreach (var error in Verification.Verify(item)) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - yield return error; - } - indexDataSpecifications++; + error.PrependSegment( + new Reporting.NameSegment( + "supplier")); + yield return error; } } } @@ -7875,7 +9988,8 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "that.Length >= 1"); + "Constraint AASd-100: An attribute with data type ``string`` " + + "is not allowed to be empty."); } } @@ -7889,14 +10003,16 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "Verification.MatchesXsDateTimeStampUtc(that)"); + "The value must match the pattern of xs:dateTimeStamp with " + + "the time zone fixed to UTC."); } if (!Verification.IsXsDateTimeStampUtc(that)) { yield return new Reporting.Error( "Invariant violated:\n" + - "Verification.IsXsDateTimeStampUtc(that)"); + "The value must represent a valid xs:dateTimeStamp with " + + "the time zone fixed to UTC."); } } @@ -7920,7 +10036,8 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "that.Length >= 1"); + "Constraint AASd-100: An attribute with data type ``string`` " + + "is not allowed to be empty."); } } @@ -7934,7 +10051,8 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "Verification.MatchesBcp47(that)"); + "The value must represent a value language tag conformant to " + + "BCP 47."); } } @@ -7948,14 +10066,16 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "that.Length >= 1"); + "Constraint AASd-100: An attribute with data type ``string`` " + + "is not allowed to be empty."); } if (!Verification.MatchesMimeType(that)) { yield return new Reporting.Error( "Invariant violated:\n" + - "Verification.MatchesMimeType(that)"); + "The value must represent a valid content MIME type " + + "according to RFC 2046."); } } @@ -7969,14 +10089,16 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "that.Length >= 1"); + "Constraint AASd-100: An attribute with data type ``string`` " + + "is not allowed to be empty."); } if (!Verification.MatchesRfc8089Path(that)) { yield return new Reporting.Error( "Invariant violated:\n" + - "Verification.MatchesRfc8089Path(that)"); + "The value must represent a valid file URI scheme according " + + "to RFC 8089."); } } @@ -7990,7 +10112,8 @@ var error in Verification.VerifyAasSubmodelElements( { yield return new Reporting.Error( "Invariant violated:\n" + - "that.Length >= 1"); + "Constraint AASd-100: An attribute with data type ``string`` " + + "is not allowed to be empty."); } } @@ -8015,8 +10138,7 @@ var error in Verification.VerifyAasSubmodelElements( yield return new Reporting.Error( "Invariant violated:\n" + "Constraint AASd-027: ID-short shall have a maximum length " + - "of 128 characters.\n" + - "that.Length <= 128"); + "of 128 characters."); } if (!Verification.MatchesIdShort(that)) @@ -8025,8 +10147,7 @@ var error in Verification.VerifyAasSubmodelElements( "Invariant violated:\n" + "ID-short of Referables shall only feature letters, digits, " + "underscore (``_``); starting mandatory with a letter. " + - "*I.e.* ``[a-zA-Z][a-zA-Z0-9_]+``.\n" + - "Verification.MatchesIdShort(that)"); + "*I.e.* ``[a-zA-Z][a-zA-Z0-9_]+``."); } } @@ -8072,6 +10193,20 @@ var error in Verification.VerifyAasSubmodelElements( } } + /// + /// Verify that is a valid enumeration value. + /// + public static IEnumerable VerifyAasSubmodelElements( + Aas.AasSubmodelElements that) + { + if (!EnumValueSet.ForAasSubmodelElements.Contains( + (int)that)) + { + yield return new Reporting.Error( + $"Invalid AasSubmodelElements: {that}"); + } + } + /// /// Verify that is a valid enumeration value. /// @@ -8128,118 +10263,6 @@ var error in Verification.VerifyAasSubmodelElements( } } - /// - /// Verify that is a valid enumeration value. - /// - public static IEnumerable VerifyGenericFragmentKeys( - Aas.GenericFragmentKeys that) - { - if (!EnumValueSet.ForGenericFragmentKeys.Contains( - (int)that)) - { - yield return new Reporting.Error( - $"Invalid GenericFragmentKeys: {that}"); - } - } - - /// - /// Verify that is a valid enumeration value. - /// - public static IEnumerable VerifyGenericGloballyIdentifiables( - Aas.GenericGloballyIdentifiables that) - { - if (!EnumValueSet.ForGenericGloballyIdentifiables.Contains( - (int)that)) - { - yield return new Reporting.Error( - $"Invalid GenericGloballyIdentifiables: {that}"); - } - } - - /// - /// Verify that is a valid enumeration value. - /// - public static IEnumerable VerifyAasIdentifiables( - Aas.AasIdentifiables that) - { - if (!EnumValueSet.ForAasIdentifiables.Contains( - (int)that)) - { - yield return new Reporting.Error( - $"Invalid AasIdentifiables: {that}"); - } - } - - /// - /// Verify that is a valid enumeration value. - /// - public static IEnumerable VerifyAasSubmodelElements( - Aas.AasSubmodelElements that) - { - if (!EnumValueSet.ForAasSubmodelElements.Contains( - (int)that)) - { - yield return new Reporting.Error( - $"Invalid AasSubmodelElements: {that}"); - } - } - - /// - /// Verify that is a valid enumeration value. - /// - public static IEnumerable VerifyAasReferableNonIdentifiables( - Aas.AasReferableNonIdentifiables that) - { - if (!EnumValueSet.ForAasReferableNonIdentifiables.Contains( - (int)that)) - { - yield return new Reporting.Error( - $"Invalid AasReferableNonIdentifiables: {that}"); - } - } - - /// - /// Verify that is a valid enumeration value. - /// - public static IEnumerable VerifyAasReferables( - Aas.AasReferables that) - { - if (!EnumValueSet.ForAasReferables.Contains( - (int)that)) - { - yield return new Reporting.Error( - $"Invalid AasReferables: {that}"); - } - } - - /// - /// Verify that is a valid enumeration value. - /// - public static IEnumerable VerifyGloballyIdentifiables( - Aas.GloballyIdentifiables that) - { - if (!EnumValueSet.ForGloballyIdentifiables.Contains( - (int)that)) - { - yield return new Reporting.Error( - $"Invalid GloballyIdentifiables: {that}"); - } - } - - /// - /// Verify that is a valid enumeration value. - /// - public static IEnumerable VerifyFragmentKeys( - Aas.FragmentKeys that) - { - if (!EnumValueSet.ForFragmentKeys.Contains( - (int)that)) - { - yield return new Reporting.Error( - $"Invalid FragmentKeys: {that}"); - } - } - /// /// Verify that is a valid enumeration value. /// @@ -8271,28 +10294,28 @@ var error in Verification.VerifyAasSubmodelElements( /// /// Verify that is a valid enumeration value. /// - public static IEnumerable VerifyDataTypeDefRdf( - Aas.DataTypeDefRdf that) + public static IEnumerable VerifyDataTypeIec61360( + Aas.DataTypeIec61360 that) { - if (!EnumValueSet.ForDataTypeDefRdf.Contains( + if (!EnumValueSet.ForDataTypeIec61360.Contains( (int)that)) { yield return new Reporting.Error( - $"Invalid DataTypeDefRdf: {that}"); + $"Invalid DataTypeIec61360: {that}"); } } /// /// Verify that is a valid enumeration value. /// - public static IEnumerable VerifyDataTypeDef( - Aas.DataTypeDef that) + public static IEnumerable VerifyLevelType( + Aas.LevelType that) { - if (!EnumValueSet.ForDataTypeDef.Contains( + if (!EnumValueSet.ForLevelType.Contains( (int)that)) { yield return new Reporting.Error( - $"Invalid DataTypeDef: {that}"); + $"Invalid LevelType: {that}"); } } } // public static class Verification diff --git a/src/AasxServer.DomainModelV3_0_RC02/visitation.cs b/src/AasxServer.DomainModelV3_0_RC02/visitation.cs index 2da7cd330..b6c170d45 100644 --- a/src/AasxServer.DomainModelV3_0_RC02/visitation.cs +++ b/src/AasxServer.DomainModelV3_0_RC02/visitation.cs @@ -41,10 +41,12 @@ public interface IVisitor public void Visit(Reference that); public void Visit(Key that); public void Visit(LangString that); - public void Visit(LangStringSet that); - public void Visit(DataSpecificationContent that); - public void Visit(DataSpecification that); public void Visit(Environment that); + public void Visit(EmbeddedDataSpecification that); + public void Visit(ValueReferencePair that); + public void Visit(ValueList that); + public void Visit(DataSpecificationIec61360 that); + public void Visit(DataSpecificationPhysicalUnit that); } // public interface IVisitor /// @@ -314,7 +316,7 @@ public virtual void Visit(LangString that) } } - public virtual void Visit(LangStringSet that) + public virtual void Visit(Environment that) { // Just descend through, do nothing with that foreach (var something in that.DescendOnce()) @@ -323,7 +325,7 @@ public virtual void Visit(LangStringSet that) } } - public virtual void Visit(DataSpecificationContent that) + public virtual void Visit(EmbeddedDataSpecification that) { // Just descend through, do nothing with that foreach (var something in that.DescendOnce()) @@ -332,7 +334,7 @@ public virtual void Visit(DataSpecificationContent that) } } - public virtual void Visit(DataSpecification that) + public virtual void Visit(ValueReferencePair that) { // Just descend through, do nothing with that foreach (var something in that.DescendOnce()) @@ -341,7 +343,25 @@ public virtual void Visit(DataSpecification that) } } - public virtual void Visit(Environment that) + public virtual void Visit(ValueList that) + { + // Just descend through, do nothing with that + foreach (var something in that.DescendOnce()) + { + Visit(something); + } + } + + public virtual void Visit(DataSpecificationIec61360 that) + { + // Just descend through, do nothing with that + foreach (var something in that.DescendOnce()) + { + Visit(something); + } + } + + public virtual void Visit(DataSpecificationPhysicalUnit that) { // Just descend through, do nothing with that foreach (var something in that.DescendOnce()) @@ -388,10 +408,12 @@ public virtual void Visit(IClass that) public abstract void Visit(Reference that); public abstract void Visit(Key that); public abstract void Visit(LangString that); - public abstract void Visit(LangStringSet that); - public abstract void Visit(DataSpecificationContent that); - public abstract void Visit(DataSpecification that); public abstract void Visit(Environment that); + public abstract void Visit(EmbeddedDataSpecification that); + public abstract void Visit(ValueReferencePair that); + public abstract void Visit(ValueList that); + public abstract void Visit(DataSpecificationIec61360 that); + public abstract void Visit(DataSpecificationPhysicalUnit that); } // public abstract class AbstractVisitor /// @@ -429,10 +451,12 @@ public interface IVisitorWithContext public void Visit(Reference that, TContext context); public void Visit(Key that, TContext context); public void Visit(LangString that, TContext context); - public void Visit(LangStringSet that, TContext context); - public void Visit(DataSpecificationContent that, TContext context); - public void Visit(DataSpecification that, TContext context); public void Visit(Environment that, TContext context); + public void Visit(EmbeddedDataSpecification that, TContext context); + public void Visit(ValueReferencePair that, TContext context); + public void Visit(ValueList that, TContext context); + public void Visit(DataSpecificationIec61360 that, TContext context); + public void Visit(DataSpecificationPhysicalUnit that, TContext context); } // public interface IVisitorWithContext /// @@ -475,10 +499,12 @@ public void Visit(IClass that, TContext context) public abstract void Visit(Reference that, TContext context); public abstract void Visit(Key that, TContext context); public abstract void Visit(LangString that, TContext context); - public abstract void Visit(LangStringSet that, TContext context); - public abstract void Visit(DataSpecificationContent that, TContext context); - public abstract void Visit(DataSpecification that, TContext context); public abstract void Visit(Environment that, TContext context); + public abstract void Visit(EmbeddedDataSpecification that, TContext context); + public abstract void Visit(ValueReferencePair that, TContext context); + public abstract void Visit(ValueList that, TContext context); + public abstract void Visit(DataSpecificationIec61360 that, TContext context); + public abstract void Visit(DataSpecificationPhysicalUnit that, TContext context); } // public abstract class AbstractVisitorWithContext /// @@ -517,10 +543,12 @@ public interface ITransformer public T Transform(Reference that); public T Transform(Key that); public T Transform(LangString that); - public T Transform(LangStringSet that); - public T Transform(DataSpecificationContent that); - public T Transform(DataSpecification that); public T Transform(Environment that); + public T Transform(EmbeddedDataSpecification that); + public T Transform(ValueReferencePair that); + public T Transform(ValueList that); + public T Transform(DataSpecificationIec61360 that); + public T Transform(DataSpecificationPhysicalUnit that); } // public interface ITransformer /// @@ -591,13 +619,17 @@ public T Transform(IClass that) public abstract T Transform(LangString that); - public abstract T Transform(LangStringSet that); + public abstract T Transform(Environment that); - public abstract T Transform(DataSpecificationContent that); + public abstract T Transform(EmbeddedDataSpecification that); - public abstract T Transform(DataSpecification that); + public abstract T Transform(ValueReferencePair that); - public abstract T Transform(Environment that); + public abstract T Transform(ValueList that); + + public abstract T Transform(DataSpecificationIec61360 that); + + public abstract T Transform(DataSpecificationPhysicalUnit that); } // public abstract class AbstractTransformer /// @@ -637,10 +669,12 @@ public interface ITransformerWithContext public T Transform(Reference that, TContext context); public T Transform(Key that, TContext context); public T Transform(LangString that, TContext context); - public T Transform(LangStringSet that, TContext context); - public T Transform(DataSpecificationContent that, TContext context); - public T Transform(DataSpecification that, TContext context); public T Transform(Environment that, TContext context); + public T Transform(EmbeddedDataSpecification that, TContext context); + public T Transform(ValueReferencePair that, TContext context); + public T Transform(ValueList that, TContext context); + public T Transform(DataSpecificationIec61360 that, TContext context); + public T Transform(DataSpecificationPhysicalUnit that, TContext context); } // public interface ITransformerWithContext /// @@ -713,13 +747,17 @@ public T Transform(IClass that, TContext context) public abstract T Transform(LangString that, TContext context); - public abstract T Transform(LangStringSet that, TContext context); + public abstract T Transform(Environment that, TContext context); + + public abstract T Transform(EmbeddedDataSpecification that, TContext context); - public abstract T Transform(DataSpecificationContent that, TContext context); + public abstract T Transform(ValueReferencePair that, TContext context); - public abstract T Transform(DataSpecification that, TContext context); + public abstract T Transform(ValueList that, TContext context); - public abstract T Transform(Environment that, TContext context); + public abstract T Transform(DataSpecificationIec61360 that, TContext context); + + public abstract T Transform(DataSpecificationPhysicalUnit that, TContext context); } // public abstract class AbstractTransformerWithContext } // public static class Visitation } // namespace AasCore.Aas3_0_RC02 diff --git a/src/AasxServer.DomainModelV3_0_RC02/xmlization.cs b/src/AasxServer.DomainModelV3_0_RC02/xmlization.cs index 116163764..44fc2a75a 100644 --- a/src/AasxServer.DomainModelV3_0_RC02/xmlization.cs +++ b/src/AasxServer.DomainModelV3_0_RC02/xmlization.cs @@ -3,11 +3,11 @@ * Do NOT edit or append. */ +using Aas = AasCore.Aas3_0_RC02; // renamed using CodeAnalysis = System.Diagnostics.CodeAnalysis; using Xml = System.Xml; -using System.Collections.Generic; // can't alias -using Aas = AasCore.Aas3_0_RC02; +using System.Collections.Generic; // can't alias namespace AasCore.Aas3_0_RC02 { @@ -16,6 +16,11 @@ namespace AasCore.Aas3_0_RC02 /// public static class Xmlization { + /// The XML namespace of the meta-model + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static readonly string NS = ( + "https://admin-shell.io/aas/3/0"); + /// /// Implement the deserialization of meta-model classes from XML. /// @@ -69,14 +74,8 @@ private static byte[] ReadWholeContentAsBase64( /// /// Check the namespace and extract the element's name. /// - /// - /// If the namespace has been specified, the prefix is automatically - /// taken care of by , and we return the local - /// name stripped of the prefix. Otherwise, we return the element's name as-is. - /// private static string TryElementName( Xml.XmlReader reader, - string? ns, out Reporting.Error? error ) { @@ -91,21 +90,15 @@ out Reporting.Error? error } error = null; - if (ns == null) - { - return reader.Name; - } - else + if (reader.NamespaceURI != NS) { - if (ns != reader.NamespaceURI) - { - error = new Reporting.Error( - $"Expected an element within a namespace {ns}, " + - $"but got: {reader.NamespaceURI}"); - return ""; - } - return reader.LocalName; + error = new Reporting.Error( + $"Expected an element within a namespace {NS}, " + + $"but got: {reader.NamespaceURI}"); + return ""; } + + return reader.LocalName; } /// @@ -114,7 +107,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.IHasSemantics? IHasSemanticsFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -138,7 +130,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -148,58 +140,58 @@ out Reporting.Error? error { case "relationshipElement": return RelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "annotatedRelationshipElement": return AnnotatedRelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "basicEventElement": return BasicEventElementFromElement( - reader, ns, out error); + reader, out error); case "blob": return BlobFromElement( - reader, ns, out error); + reader, out error); case "capability": return CapabilityFromElement( - reader, ns, out error); + reader, out error); case "entity": return EntityFromElement( - reader, ns, out error); + reader, out error); case "extension": return ExtensionFromElement( - reader, ns, out error); + reader, out error); case "file": return FileFromElement( - reader, ns, out error); + reader, out error); case "multiLanguageProperty": return MultiLanguagePropertyFromElement( - reader, ns, out error); + reader, out error); case "operation": return OperationFromElement( - reader, ns, out error); + reader, out error); case "property": return PropertyFromElement( - reader, ns, out error); + reader, out error); case "qualifier": return QualifierFromElement( - reader, ns, out error); + reader, out error); case "range": return RangeFromElement( - reader, ns, out error); + reader, out error); case "referenceElement": return ReferenceElementFromElement( - reader, ns, out error); + reader, out error); case "specificAssetId": return SpecificAssetIdFromElement( - reader, ns, out error); + reader, out error); case "submodel": return SubmodelFromElement( - reader, ns, out error); + reader, out error); case "submodelElementCollection": return SubmodelElementCollectionFromElement( - reader, ns, out error); + reader, out error); case "submodelElementList": return SubmodelElementListFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -218,7 +210,6 @@ out Reporting.Error? error internal static Aas.Extension? ExtensionFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -244,7 +235,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -260,7 +251,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -283,13 +274,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -442,7 +436,7 @@ out Reporting.Error? error case "refersTo": { theRefersTo = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -486,7 +480,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -537,7 +531,6 @@ out Reporting.Error? error /// internal static Aas.Extension? ExtensionFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -562,7 +555,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -583,7 +576,7 @@ out Reporting.Error? error Aas.Extension? result = ( ExtensionFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -611,7 +604,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -638,7 +631,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.IHasExtensions? IHasExtensionsFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -662,7 +654,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -672,55 +664,55 @@ out Reporting.Error? error { case "relationshipElement": return RelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "annotatedRelationshipElement": return AnnotatedRelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "assetAdministrationShell": return AssetAdministrationShellFromElement( - reader, ns, out error); + reader, out error); case "basicEventElement": return BasicEventElementFromElement( - reader, ns, out error); + reader, out error); case "blob": return BlobFromElement( - reader, ns, out error); + reader, out error); case "capability": return CapabilityFromElement( - reader, ns, out error); + reader, out error); case "conceptDescription": return ConceptDescriptionFromElement( - reader, ns, out error); + reader, out error); case "entity": return EntityFromElement( - reader, ns, out error); + reader, out error); case "file": return FileFromElement( - reader, ns, out error); + reader, out error); case "multiLanguageProperty": return MultiLanguagePropertyFromElement( - reader, ns, out error); + reader, out error); case "operation": return OperationFromElement( - reader, ns, out error); + reader, out error); case "property": return PropertyFromElement( - reader, ns, out error); + reader, out error); case "range": return RangeFromElement( - reader, ns, out error); + reader, out error); case "referenceElement": return ReferenceElementFromElement( - reader, ns, out error); + reader, out error); case "submodel": return SubmodelFromElement( - reader, ns, out error); + reader, out error); case "submodelElementCollection": return SubmodelElementCollectionFromElement( - reader, ns, out error); + reader, out error); case "submodelElementList": return SubmodelElementListFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -734,7 +726,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.IReferable? IReferableFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -758,7 +749,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -768,55 +759,55 @@ out Reporting.Error? error { case "relationshipElement": return RelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "annotatedRelationshipElement": return AnnotatedRelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "assetAdministrationShell": return AssetAdministrationShellFromElement( - reader, ns, out error); + reader, out error); case "basicEventElement": return BasicEventElementFromElement( - reader, ns, out error); + reader, out error); case "blob": return BlobFromElement( - reader, ns, out error); + reader, out error); case "capability": return CapabilityFromElement( - reader, ns, out error); + reader, out error); case "conceptDescription": return ConceptDescriptionFromElement( - reader, ns, out error); + reader, out error); case "entity": return EntityFromElement( - reader, ns, out error); + reader, out error); case "file": return FileFromElement( - reader, ns, out error); + reader, out error); case "multiLanguageProperty": return MultiLanguagePropertyFromElement( - reader, ns, out error); + reader, out error); case "operation": return OperationFromElement( - reader, ns, out error); + reader, out error); case "property": return PropertyFromElement( - reader, ns, out error); + reader, out error); case "range": return RangeFromElement( - reader, ns, out error); + reader, out error); case "referenceElement": return ReferenceElementFromElement( - reader, ns, out error); + reader, out error); case "submodel": return SubmodelFromElement( - reader, ns, out error); + reader, out error); case "submodelElementCollection": return SubmodelElementCollectionFromElement( - reader, ns, out error); + reader, out error); case "submodelElementList": return SubmodelElementListFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -830,7 +821,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.IIdentifiable? IIdentifiableFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -854,7 +844,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -864,13 +854,13 @@ out Reporting.Error? error { case "assetAdministrationShell": return AssetAdministrationShellFromElement( - reader, ns, out error); + reader, out error); case "conceptDescription": return ConceptDescriptionFromElement( - reader, ns, out error); + reader, out error); case "submodel": return SubmodelFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -884,7 +874,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.IHasKind? IHasKindFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -908,7 +897,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -918,49 +907,49 @@ out Reporting.Error? error { case "relationshipElement": return RelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "annotatedRelationshipElement": return AnnotatedRelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "basicEventElement": return BasicEventElementFromElement( - reader, ns, out error); + reader, out error); case "blob": return BlobFromElement( - reader, ns, out error); + reader, out error); case "capability": return CapabilityFromElement( - reader, ns, out error); + reader, out error); case "entity": return EntityFromElement( - reader, ns, out error); + reader, out error); case "file": return FileFromElement( - reader, ns, out error); + reader, out error); case "multiLanguageProperty": return MultiLanguagePropertyFromElement( - reader, ns, out error); + reader, out error); case "operation": return OperationFromElement( - reader, ns, out error); + reader, out error); case "property": return PropertyFromElement( - reader, ns, out error); + reader, out error); case "range": return RangeFromElement( - reader, ns, out error); + reader, out error); case "referenceElement": return ReferenceElementFromElement( - reader, ns, out error); + reader, out error); case "submodel": return SubmodelFromElement( - reader, ns, out error); + reader, out error); case "submodelElementCollection": return SubmodelElementCollectionFromElement( - reader, ns, out error); + reader, out error); case "submodelElementList": return SubmodelElementListFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -974,7 +963,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.IHasDataSpecification? IHasDataSpecificationFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -998,7 +986,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -1008,58 +996,58 @@ out Reporting.Error? error { case "administrativeInformation": return AdministrativeInformationFromElement( - reader, ns, out error); + reader, out error); case "relationshipElement": return RelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "annotatedRelationshipElement": return AnnotatedRelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "assetAdministrationShell": return AssetAdministrationShellFromElement( - reader, ns, out error); + reader, out error); case "basicEventElement": return BasicEventElementFromElement( - reader, ns, out error); + reader, out error); case "blob": return BlobFromElement( - reader, ns, out error); + reader, out error); case "capability": return CapabilityFromElement( - reader, ns, out error); + reader, out error); case "conceptDescription": return ConceptDescriptionFromElement( - reader, ns, out error); + reader, out error); case "entity": return EntityFromElement( - reader, ns, out error); + reader, out error); case "file": return FileFromElement( - reader, ns, out error); + reader, out error); case "multiLanguageProperty": return MultiLanguagePropertyFromElement( - reader, ns, out error); + reader, out error); case "operation": return OperationFromElement( - reader, ns, out error); + reader, out error); case "property": return PropertyFromElement( - reader, ns, out error); + reader, out error); case "range": return RangeFromElement( - reader, ns, out error); + reader, out error); case "referenceElement": return ReferenceElementFromElement( - reader, ns, out error); + reader, out error); case "submodel": return SubmodelFromElement( - reader, ns, out error); + reader, out error); case "submodelElementCollection": return SubmodelElementCollectionFromElement( - reader, ns, out error); + reader, out error); case "submodelElementList": return SubmodelElementListFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -1078,12 +1066,11 @@ out Reporting.Error? error internal static Aas.AdministrativeInformation? AdministrativeInformationFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; string? theVersion = null; string? theRevision = null; @@ -1101,7 +1088,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -1114,34 +1101,37 @@ out Reporting.Error? error switch (elementName) { - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -1260,7 +1250,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -1288,7 +1278,7 @@ out Reporting.Error? error } return new Aas.AdministrativeInformation( - theDataSpecifications, + theEmbeddedDataSpecifications, theVersion, theRevision); } // internal static Aas.AdministrativeInformation? AdministrativeInformationFromSequence @@ -1298,7 +1288,6 @@ out Reporting.Error? error /// internal static Aas.AdministrativeInformation? AdministrativeInformationFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -1323,7 +1312,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -1344,7 +1333,7 @@ out Reporting.Error? error Aas.AdministrativeInformation? result = ( AdministrativeInformationFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -1372,7 +1361,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -1399,7 +1388,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.IQualifiable? IQualifiableFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -1423,7 +1411,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -1433,49 +1421,49 @@ out Reporting.Error? error { case "relationshipElement": return RelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "annotatedRelationshipElement": return AnnotatedRelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "basicEventElement": return BasicEventElementFromElement( - reader, ns, out error); + reader, out error); case "blob": return BlobFromElement( - reader, ns, out error); + reader, out error); case "capability": return CapabilityFromElement( - reader, ns, out error); + reader, out error); case "entity": return EntityFromElement( - reader, ns, out error); + reader, out error); case "file": return FileFromElement( - reader, ns, out error); + reader, out error); case "multiLanguageProperty": return MultiLanguagePropertyFromElement( - reader, ns, out error); + reader, out error); case "operation": return OperationFromElement( - reader, ns, out error); + reader, out error); case "property": return PropertyFromElement( - reader, ns, out error); + reader, out error); case "range": return RangeFromElement( - reader, ns, out error); + reader, out error); case "referenceElement": return ReferenceElementFromElement( - reader, ns, out error); + reader, out error); case "submodel": return SubmodelFromElement( - reader, ns, out error); + reader, out error); case "submodelElementCollection": return SubmodelElementCollectionFromElement( - reader, ns, out error); + reader, out error); case "submodelElementList": return SubmodelElementListFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -1494,7 +1482,6 @@ out Reporting.Error? error internal static Aas.Qualifier? QualifierFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -1521,7 +1508,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -1537,7 +1524,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -1560,13 +1547,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -1774,7 +1764,7 @@ out Reporting.Error? error case "valueId": { theValueId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -1818,7 +1808,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -1880,7 +1870,6 @@ out Reporting.Error? error /// internal static Aas.Qualifier? QualifierFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -1905,7 +1894,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -1926,7 +1915,7 @@ out Reporting.Error? error Aas.Qualifier? result = ( QualifierFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -1954,7 +1943,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -1986,7 +1975,6 @@ out Reporting.Error? error internal static Aas.AssetAdministrationShell? AssetAdministrationShellFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -1994,12 +1982,12 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; AdministrativeInformation? theAdministration = null; string? theId = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; Reference? theDerivedFrom = null; AssetInformation? theAssetInformation = null; List? theSubmodels = null; @@ -2018,7 +2006,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -2043,13 +2031,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -2146,29 +2137,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -2215,7 +2250,7 @@ out Reporting.Error? error case "administration": { theAdministration = AdministrativeInformationFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -2266,34 +2301,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -2302,7 +2340,7 @@ out Reporting.Error? error case "derivedFrom": { theDerivedFrom = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -2316,7 +2354,7 @@ out Reporting.Error? error case "assetInformation": { theAssetInformation = AssetInformationFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -2339,13 +2377,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSubmodels)); + error.PrependSegment( + new Reporting.NameSegment( + "submodels")); return null; } @@ -2393,7 +2434,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -2450,7 +2491,7 @@ out Reporting.Error? error theDescription, theChecksum, theAdministration, - theDataSpecifications, + theEmbeddedDataSpecifications, theDerivedFrom, theSubmodels); } // internal static Aas.AssetAdministrationShell? AssetAdministrationShellFromSequence @@ -2460,7 +2501,6 @@ out Reporting.Error? error /// internal static Aas.AssetAdministrationShell? AssetAdministrationShellFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -2485,7 +2525,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -2506,7 +2546,7 @@ out Reporting.Error? error Aas.AssetAdministrationShell? result = ( AssetAdministrationShellFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -2534,7 +2574,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -2566,7 +2606,6 @@ out Reporting.Error? error internal static Aas.AssetInformation? AssetInformationFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -2590,7 +2629,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -2661,7 +2700,7 @@ out Reporting.Error? error case "globalAssetId": { theGlobalAssetId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -2684,13 +2723,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { SpecificAssetId? item = SpecificAssetIdFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSpecificAssetIds)); + error.PrependSegment( + new Reporting.NameSegment( + "specificAssetIds")); return null; } @@ -2708,7 +2750,7 @@ out Reporting.Error? error case "defaultThumbnail": { theDefaultThumbnail = ResourceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -2752,7 +2794,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -2801,7 +2843,6 @@ out Reporting.Error? error /// internal static Aas.AssetInformation? AssetInformationFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -2826,7 +2867,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -2847,7 +2888,7 @@ out Reporting.Error? error Aas.AssetInformation? result = ( AssetInformationFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -2875,7 +2916,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -2907,7 +2948,6 @@ out Reporting.Error? error internal static Aas.Resource? ResourceFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -2929,7 +2969,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -3055,7 +3095,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -3102,7 +3142,6 @@ out Reporting.Error? error /// internal static Aas.Resource? ResourceFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -3127,7 +3166,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -3148,7 +3187,7 @@ out Reporting.Error? error Aas.Resource? result = ( ResourceFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -3176,7 +3215,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -3208,7 +3247,6 @@ out Reporting.Error? error internal static Aas.SpecificAssetId? SpecificAssetIdFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -3233,7 +3271,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -3249,7 +3287,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -3272,13 +3310,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -3376,7 +3417,7 @@ out Reporting.Error? error case "externalSubjectId": { theExternalSubjectId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -3420,7 +3461,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -3490,7 +3531,6 @@ out Reporting.Error? error /// internal static Aas.SpecificAssetId? SpecificAssetIdFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -3515,7 +3555,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -3536,7 +3576,7 @@ out Reporting.Error? error Aas.SpecificAssetId? result = ( SpecificAssetIdFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -3564,7 +3604,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -3596,7 +3636,6 @@ out Reporting.Error? error internal static Aas.Submodel? SubmodelFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -3604,8 +3643,8 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; AdministrativeInformation? theAdministration = null; string? theId = null; @@ -3613,7 +3652,7 @@ out Reporting.Error? error Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; List? theSubmodelElements = null; if (!isEmptySequence) @@ -3630,7 +3669,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -3655,13 +3694,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -3758,29 +3800,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -3827,7 +3913,7 @@ out Reporting.Error? error case "administration": { theAdministration = AdministrativeInformationFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -3936,7 +4022,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -3959,13 +4045,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -3992,13 +4081,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -4013,34 +4105,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -4058,13 +4153,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { ISubmodelElement? item = ISubmodelElementFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSubmodelElements)); + error.PrependSegment( + new Reporting.NameSegment( + "submodelElements")); return null; } @@ -4112,7 +4210,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -4162,7 +4260,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theSubmodelElements); } // internal static Aas.Submodel? SubmodelFromSequence @@ -4171,7 +4269,6 @@ out Reporting.Error? error /// internal static Aas.Submodel? SubmodelFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -4196,7 +4293,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -4217,7 +4314,7 @@ out Reporting.Error? error Aas.Submodel? result = ( SubmodelFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -4245,7 +4342,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -4272,7 +4369,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.ISubmodelElement? ISubmodelElementFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -4296,7 +4392,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -4306,46 +4402,46 @@ out Reporting.Error? error { case "relationshipElement": return RelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "annotatedRelationshipElement": return AnnotatedRelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "basicEventElement": return BasicEventElementFromElement( - reader, ns, out error); + reader, out error); case "blob": return BlobFromElement( - reader, ns, out error); + reader, out error); case "capability": return CapabilityFromElement( - reader, ns, out error); + reader, out error); case "entity": return EntityFromElement( - reader, ns, out error); + reader, out error); case "file": return FileFromElement( - reader, ns, out error); + reader, out error); case "multiLanguageProperty": return MultiLanguagePropertyFromElement( - reader, ns, out error); + reader, out error); case "operation": return OperationFromElement( - reader, ns, out error); + reader, out error); case "property": return PropertyFromElement( - reader, ns, out error); + reader, out error); case "range": return RangeFromElement( - reader, ns, out error); + reader, out error); case "referenceElement": return ReferenceElementFromElement( - reader, ns, out error); + reader, out error); case "submodelElementCollection": return SubmodelElementCollectionFromElement( - reader, ns, out error); + reader, out error); case "submodelElementList": return SubmodelElementListFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -4364,7 +4460,6 @@ out Reporting.Error? error internal static Aas.RelationshipElement? RelationshipElementFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -4372,14 +4467,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; Reference? theFirst = null; Reference? theSecond = null; @@ -4397,7 +4492,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -4422,13 +4517,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -4525,29 +4623,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -4649,7 +4791,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -4672,13 +4814,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -4705,13 +4850,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -4726,34 +4874,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -4762,7 +4913,7 @@ out Reporting.Error? error case "first": { theFirst = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -4776,7 +4927,7 @@ out Reporting.Error? error case "second": { theSecond = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -4820,7 +4971,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -4880,7 +5031,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications); + theEmbeddedDataSpecifications); } // internal static Aas.RelationshipElement? RelationshipElementFromSequence /// @@ -4889,7 +5040,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.IRelationshipElement? IRelationshipElementFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -4913,7 +5063,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -4923,10 +5073,10 @@ out Reporting.Error? error { case "annotatedRelationshipElement": return AnnotatedRelationshipElementFromElement( - reader, ns, out error); + reader, out error); case "relationshipElement": return RelationshipElementFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -4939,7 +5089,6 @@ out Reporting.Error? error /// internal static Aas.RelationshipElement? RelationshipElementFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -4964,7 +5113,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -4985,7 +5134,7 @@ out Reporting.Error? error Aas.RelationshipElement? result = ( RelationshipElementFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -5013,7 +5162,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -5045,7 +5194,6 @@ out Reporting.Error? error internal static Aas.SubmodelElementList? SubmodelElementListFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -5053,14 +5201,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; bool? theOrderRelevant = null; List? theValue = null; Reference? theSemanticIdListElement = null; @@ -5081,7 +5229,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -5106,13 +5254,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -5209,44 +5360,88 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - break; - } - case "checksum": - { - if (isEmptyProperty) - { - theChecksum = ""; - } - else + if (!isEmptyProperty) { - if (reader.EOF) + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) { - error = new Reporting.Error( - "Expected an XML content representing " + + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + case "checksum": + { + if (isEmptyProperty) + { + theChecksum = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + "the property Checksum of an instance of class SubmodelElementList, " + "but reached the end-of-file"); return null; @@ -5333,7 +5528,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -5356,13 +5551,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -5389,13 +5587,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -5410,34 +5611,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -5502,13 +5706,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { ISubmodelElement? item = ISubmodelElementFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexValue)); + error.PrependSegment( + new Reporting.NameSegment( + "value")); return null; } @@ -5526,7 +5733,7 @@ out Reporting.Error? error case "semanticIdListElement": { theSemanticIdListElement = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -5680,7 +5887,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -5729,7 +5936,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theOrderRelevant, theValue, theSemanticIdListElement, @@ -5741,7 +5948,6 @@ out Reporting.Error? error ///
internal static Aas.SubmodelElementList? SubmodelElementListFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -5766,7 +5972,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -5787,7 +5993,7 @@ out Reporting.Error? error Aas.SubmodelElementList? result = ( SubmodelElementListFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -5815,7 +6021,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -5847,7 +6053,6 @@ out Reporting.Error? error internal static Aas.SubmodelElementCollection? SubmodelElementCollectionFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -5855,14 +6060,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; List? theValue = null; if (!isEmptySequence) @@ -5879,7 +6084,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -5904,13 +6109,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -6007,29 +6215,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -6131,7 +6383,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -6154,13 +6406,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -6187,13 +6442,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -6208,34 +6466,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -6253,13 +6514,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { ISubmodelElement? item = ISubmodelElementFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexValue)); + error.PrependSegment( + new Reporting.NameSegment( + "value")); return null; } @@ -6307,7 +6571,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -6345,7 +6609,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theValue); } // internal static Aas.SubmodelElementCollection? SubmodelElementCollectionFromSequence @@ -6354,7 +6618,6 @@ out Reporting.Error? error ///
internal static Aas.SubmodelElementCollection? SubmodelElementCollectionFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -6379,7 +6642,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -6400,7 +6663,7 @@ out Reporting.Error? error Aas.SubmodelElementCollection? result = ( SubmodelElementCollectionFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -6428,7 +6691,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -6455,7 +6718,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.IDataElement? IDataElementFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -6479,7 +6741,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -6489,22 +6751,22 @@ out Reporting.Error? error { case "blob": return BlobFromElement( - reader, ns, out error); + reader, out error); case "file": return FileFromElement( - reader, ns, out error); + reader, out error); case "multiLanguageProperty": return MultiLanguagePropertyFromElement( - reader, ns, out error); + reader, out error); case "property": return PropertyFromElement( - reader, ns, out error); + reader, out error); case "range": return RangeFromElement( - reader, ns, out error); + reader, out error); case "referenceElement": return ReferenceElementFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -6523,7 +6785,6 @@ out Reporting.Error? error internal static Aas.Property? PropertyFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -6531,14 +6792,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; DataTypeDefXsd? theValueType = null; string? theValue = null; Reference? theValueId = null; @@ -6557,7 +6818,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -6582,13 +6843,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -6685,29 +6949,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -6809,7 +7117,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -6832,13 +7140,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -6865,13 +7176,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -6886,34 +7200,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -7017,7 +7334,7 @@ out Reporting.Error? error case "valueId": { theValueId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -7061,7 +7378,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -7110,7 +7427,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theValue, theValueId); } // internal static Aas.Property? PropertyFromSequence @@ -7120,7 +7437,6 @@ out Reporting.Error? error ///
internal static Aas.Property? PropertyFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -7145,7 +7461,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -7166,7 +7482,7 @@ out Reporting.Error? error Aas.Property? result = ( PropertyFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -7194,7 +7510,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -7226,7 +7542,6 @@ out Reporting.Error? error internal static Aas.MultiLanguageProperty? MultiLanguagePropertyFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -7234,15 +7549,15 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; - LangStringSet? theValue = null; + List? theEmbeddedDataSpecifications = null; + List? theValue = null; Reference? theValueId = null; if (!isEmptySequence) @@ -7259,7 +7574,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -7284,13 +7599,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -7387,29 +7705,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -7511,7 +7873,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -7534,13 +7896,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -7567,13 +7932,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -7588,34 +7956,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -7623,38 +7994,60 @@ out Reporting.Error? error } case "value": { - theValue = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theValue = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "value")); - return null; - } - break; - } - case "valueId": - { - theValueId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + SkipNoneWhitespaceAndComments(reader); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "valueId")); - return null; - } - break; - } - default: - error = new Reporting.Error( - "We expected properties of the class MultiLanguageProperty, " + - "but got an unexpected element " + - $"with the name {elementName}"); - return null; + int indexValue = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexValue)); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + + theValue.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexValue++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + case "valueId": + { + theValueId = ReferenceFromSequence( + reader, isEmptyProperty, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueId")); + return null; + } + break; + } + default: + error = new Reporting.Error( + "We expected properties of the class MultiLanguageProperty, " + + "but got an unexpected element " + + $"with the name {elementName}"); + return null; } SkipNoneWhitespaceAndComments(reader); @@ -7682,7 +8075,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -7720,7 +8113,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theValue, theValueId); } // internal static Aas.MultiLanguageProperty? MultiLanguagePropertyFromSequence @@ -7730,7 +8123,6 @@ out Reporting.Error? error ///
internal static Aas.MultiLanguageProperty? MultiLanguagePropertyFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -7755,7 +8147,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -7776,7 +8168,7 @@ out Reporting.Error? error Aas.MultiLanguageProperty? result = ( MultiLanguagePropertyFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -7804,7 +8196,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -7836,7 +8228,6 @@ out Reporting.Error? error internal static Aas.Range? RangeFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -7844,14 +8235,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; DataTypeDefXsd? theValueType = null; string? theMin = null; string? theMax = null; @@ -7870,7 +8261,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -7895,13 +8286,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -7998,29 +8392,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -8122,7 +8560,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -8145,13 +8583,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -8178,13 +8619,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -8199,34 +8643,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -8400,7 +8847,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -8449,7 +8896,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theMin, theMax); } // internal static Aas.Range? RangeFromSequence @@ -8459,7 +8906,6 @@ out Reporting.Error? error ///
internal static Aas.Range? RangeFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -8484,7 +8930,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -8505,7 +8951,7 @@ out Reporting.Error? error Aas.Range? result = ( RangeFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -8533,7 +8979,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -8565,7 +9011,6 @@ out Reporting.Error? error internal static Aas.ReferenceElement? ReferenceElementFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -8573,14 +9018,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; Reference? theValue = null; if (!isEmptySequence) @@ -8597,7 +9042,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -8622,13 +9067,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -8725,29 +9173,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -8849,7 +9341,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -8872,13 +9364,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -8905,13 +9400,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -8926,34 +9424,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -8962,7 +9463,7 @@ out Reporting.Error? error case "value": { theValue = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -9006,7 +9507,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -9044,7 +9545,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theValue); } // internal static Aas.ReferenceElement? ReferenceElementFromSequence @@ -9053,7 +9554,6 @@ out Reporting.Error? error ///
internal static Aas.ReferenceElement? ReferenceElementFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -9078,7 +9578,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -9099,7 +9599,7 @@ out Reporting.Error? error Aas.ReferenceElement? result = ( ReferenceElementFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -9127,7 +9627,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -9159,7 +9659,6 @@ out Reporting.Error? error internal static Aas.Blob? BlobFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -9167,14 +9666,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; byte[]? theValue = null; string? theContentType = null; @@ -9192,7 +9691,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -9217,13 +9716,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -9320,29 +9822,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -9444,7 +9990,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -9467,13 +10013,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -9500,13 +10049,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -9521,34 +10073,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -9675,7 +10230,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -9724,7 +10279,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theValue); } // internal static Aas.Blob? BlobFromSequence @@ -9733,7 +10288,6 @@ out Reporting.Error? error ///
internal static Aas.Blob? BlobFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -9758,7 +10312,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -9779,7 +10333,7 @@ out Reporting.Error? error Aas.Blob? result = ( BlobFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -9807,7 +10361,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -9839,7 +10393,6 @@ out Reporting.Error? error internal static Aas.File? FileFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -9847,14 +10400,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; string? theValue = null; string? theContentType = null; @@ -9872,7 +10425,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -9897,13 +10450,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -10000,38 +10556,82 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; - } - break; - } - case "description": - { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + SkipNoneWhitespaceAndComments(reader); - if (error != null) - { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; - } - break; - } - case "checksum": - { - if (isEmptyProperty) - { - theChecksum = ""; - } + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + case "description": + { + theDescription = new List(); + + if (!isEmptyProperty) + { + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + case "checksum": + { + if (isEmptyProperty) + { + theChecksum = ""; + } else { if (reader.EOF) @@ -10124,7 +10724,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -10147,13 +10747,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -10180,13 +10783,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -10201,34 +10807,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -10347,7 +10956,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -10396,7 +11005,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theValue); } // internal static Aas.File? FileFromSequence @@ -10405,7 +11014,6 @@ out Reporting.Error? error ///
internal static Aas.File? FileFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -10430,7 +11038,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -10451,7 +11059,7 @@ out Reporting.Error? error Aas.File? result = ( FileFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -10479,7 +11087,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -10511,7 +11119,6 @@ out Reporting.Error? error internal static Aas.AnnotatedRelationshipElement? AnnotatedRelationshipElementFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -10519,14 +11126,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; Reference? theFirst = null; Reference? theSecond = null; List? theAnnotations = null; @@ -10545,7 +11152,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -10570,13 +11177,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -10673,29 +11283,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -10797,7 +11451,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -10820,13 +11474,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -10853,13 +11510,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -10874,34 +11534,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -10910,7 +11573,7 @@ out Reporting.Error? error case "first": { theFirst = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -10924,7 +11587,7 @@ out Reporting.Error? error case "second": { theSecond = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -10947,13 +11610,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { IDataElement? item = IDataElementFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexAnnotations)); + error.PrependSegment( + new Reporting.NameSegment( + "annotations")); return null; } @@ -11001,7 +11667,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -11061,7 +11727,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theAnnotations); } // internal static Aas.AnnotatedRelationshipElement? AnnotatedRelationshipElementFromSequence @@ -11070,7 +11736,6 @@ out Reporting.Error? error ///
internal static Aas.AnnotatedRelationshipElement? AnnotatedRelationshipElementFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -11095,7 +11760,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -11116,7 +11781,7 @@ out Reporting.Error? error Aas.AnnotatedRelationshipElement? result = ( AnnotatedRelationshipElementFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -11144,7 +11809,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -11176,7 +11841,6 @@ out Reporting.Error? error internal static Aas.Entity? EntityFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -11184,14 +11848,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; List? theStatements = null; EntityType? theEntityType = null; Reference? theGlobalAssetId = null; @@ -11211,7 +11875,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -11236,13 +11900,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -11339,29 +12006,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -11463,7 +12174,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -11486,13 +12197,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -11519,13 +12233,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -11540,34 +12257,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -11585,13 +12305,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { ISubmodelElement? item = ISubmodelElementFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexStatements)); + error.PrependSegment( + new Reporting.NameSegment( + "statements")); return null; } @@ -11664,7 +12387,7 @@ out Reporting.Error? error case "globalAssetId": { theGlobalAssetId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -11678,7 +12401,7 @@ out Reporting.Error? error case "specificAssetId": { theSpecificAssetId = SpecificAssetIdFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -11722,7 +12445,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -11771,7 +12494,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theStatements, theGlobalAssetId, theSpecificAssetId); @@ -11782,7 +12505,6 @@ out Reporting.Error? error ///
internal static Aas.Entity? EntityFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -11807,7 +12529,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -11828,7 +12550,7 @@ out Reporting.Error? error Aas.Entity? result = ( EntityFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -11856,7 +12578,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -11888,7 +12610,6 @@ out Reporting.Error? error internal static Aas.EventPayload? EventPayloadFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -11916,7 +12637,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -11932,7 +12653,7 @@ out Reporting.Error? error case "source": { theSource = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -11946,7 +12667,7 @@ out Reporting.Error? error case "sourceSemanticId": { theSourceSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -11960,7 +12681,7 @@ out Reporting.Error? error case "observableReference": { theObservableReference = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -11974,7 +12695,7 @@ out Reporting.Error? error case "observableSemanticId": { theObservableSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -12028,7 +12749,7 @@ out Reporting.Error? error case "subjectId": { theSubjectId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -12152,7 +12873,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -12225,7 +12946,6 @@ out Reporting.Error? error ///
internal static Aas.EventPayload? EventPayloadFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -12250,7 +12970,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -12271,7 +12991,7 @@ out Reporting.Error? error Aas.EventPayload? result = ( EventPayloadFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -12299,7 +13019,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -12326,7 +13046,6 @@ out Reporting.Error? error [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] internal static Aas.IEventElement? IEventElementFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -12350,7 +13069,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -12360,7 +13079,7 @@ out Reporting.Error? error { case "basicEventElement": return BasicEventElementFromElement( - reader, ns, out error); + reader, out error); default: error = new Reporting.Error( $"Unexpected element with the name {elementName}"); @@ -12379,7 +13098,6 @@ out Reporting.Error? error internal static Aas.BasicEventElement? BasicEventElementFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -12387,14 +13105,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; Reference? theObserved = null; Direction? theDirection = null; StateOfEvent? theState = null; @@ -12418,7 +13136,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -12443,13 +13161,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -12546,29 +13267,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -12670,7 +13435,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -12693,13 +13458,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -12726,13 +13494,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -12747,34 +13518,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -12783,7 +13557,7 @@ out Reporting.Error? error case "observed": { theObserved = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -12947,7 +13721,7 @@ out Reporting.Error? error case "messageBroker": { theMessageBroker = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -13111,7 +13885,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -13182,7 +13956,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theMessageTopic, theMessageBroker, theLastUpdate, @@ -13195,7 +13969,6 @@ out Reporting.Error? error ///
internal static Aas.BasicEventElement? BasicEventElementFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -13220,7 +13993,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -13241,7 +14014,7 @@ out Reporting.Error? error Aas.BasicEventElement? result = ( BasicEventElementFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -13269,7 +14042,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -13301,7 +14074,6 @@ out Reporting.Error? error internal static Aas.Operation? OperationFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -13309,14 +14081,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; List? theInputVariables = null; List? theOutputVariables = null; List? theInoutputVariables = null; @@ -13335,7 +14107,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -13360,13 +14132,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -13463,29 +14238,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -13587,7 +14406,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -13610,13 +14429,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -13643,13 +14465,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -13664,34 +14489,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -13709,13 +14537,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { OperationVariable? item = OperationVariableFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexInputVariables)); + error.PrependSegment( + new Reporting.NameSegment( + "inputVariables")); return null; } @@ -13742,13 +14573,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { OperationVariable? item = OperationVariableFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexOutputVariables)); + error.PrependSegment( + new Reporting.NameSegment( + "outputVariables")); return null; } @@ -13775,13 +14609,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { OperationVariable? item = OperationVariableFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexInoutputVariables)); + error.PrependSegment( + new Reporting.NameSegment( + "inoutputVariables")); return null; } @@ -13829,7 +14666,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -13867,7 +14704,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theInputVariables, theOutputVariables, theInoutputVariables); @@ -13878,7 +14715,6 @@ out Reporting.Error? error ///
internal static Aas.Operation? OperationFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -13903,7 +14739,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -13924,7 +14760,7 @@ out Reporting.Error? error Aas.Operation? result = ( OperationFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -13952,7 +14788,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -13984,7 +14820,6 @@ out Reporting.Error? error internal static Aas.OperationVariable? OperationVariableFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -14005,7 +14840,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -14029,6 +14864,10 @@ out Reporting.Error? error return null; } + // We need to skip the whitespace here in order to be able to look ahead + // the discriminator element shortly. + SkipNoneWhitespaceAndComments(reader); + if (reader.EOF) { error = new Reporting.Error( @@ -14038,11 +14877,28 @@ out Reporting.Error? error return null; } + // Try to look ahead the discriminator name; + // we need this name only for the error reporting below. + // ISubmodelElementFromElement will perform more sophisticated + // checks. + string? discriminatorElementName = null; + if (reader.NodeType == Xml.XmlNodeType.Element) + { + discriminatorElementName = reader.LocalName; + } + theValue = ISubmodelElementFromElement( - reader, ns, out error); + reader, out error); if (error != null) { + if (discriminatorElementName != null) + { + error.PrependSegment( + new Reporting.NameSegment( + discriminatorElementName)); + } + error.PrependSegment( new Reporting.NameSegment( "value")); @@ -14083,7 +14939,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -14129,7 +14985,6 @@ out Reporting.Error? error ///
internal static Aas.OperationVariable? OperationVariableFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -14154,7 +15009,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -14175,7 +15030,7 @@ out Reporting.Error? error Aas.OperationVariable? result = ( OperationVariableFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -14203,7 +15058,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -14235,7 +15090,6 @@ out Reporting.Error? error internal static Aas.Capability? CapabilityFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -14243,14 +15097,14 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; ModelingKind? theKind = null; Reference? theSemanticId = null; List? theSupplementalSemanticIds = null; List? theQualifiers = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; if (!isEmptySequence) { @@ -14266,7 +15120,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -14291,13 +15145,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -14394,29 +15251,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -14518,7 +15419,7 @@ out Reporting.Error? error case "semanticId": { theSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -14541,13 +15442,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexSupplementalSemanticIds)); + error.PrependSegment( + new Reporting.NameSegment( + "supplementalSemanticIds")); return null; } @@ -14574,13 +15478,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Qualifier? item = QualifierFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexQualifiers)); + error.PrependSegment( + new Reporting.NameSegment( + "qualifiers")); return null; } @@ -14595,34 +15502,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -14661,7 +15571,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -14699,7 +15609,7 @@ out Reporting.Error? error theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications); + theEmbeddedDataSpecifications); } // internal static Aas.Capability? CapabilityFromSequence /// @@ -14707,7 +15617,6 @@ out Reporting.Error? error /// internal static Aas.Capability? CapabilityFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -14732,7 +15641,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -14753,7 +15662,7 @@ out Reporting.Error? error Aas.Capability? result = ( CapabilityFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -14781,7 +15690,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -14813,7 +15722,6 @@ out Reporting.Error? error internal static Aas.ConceptDescription? ConceptDescriptionFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -14821,12 +15729,12 @@ out Reporting.Error? error List? theExtensions = null; string? theCategory = null; string? theIdShort = null; - LangStringSet? theDisplayName = null; - LangStringSet? theDescription = null; + List? theDisplayName = null; + List? theDescription = null; string? theChecksum = null; AdministrativeInformation? theAdministration = null; string? theId = null; - List? theDataSpecifications = null; + List? theEmbeddedDataSpecifications = null; List? theIsCaseOf = null; if (!isEmptySequence) @@ -14843,7 +15751,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -14868,13 +15776,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Extension? item = ExtensionFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexExtensions)); + error.PrependSegment( + new Reporting.NameSegment( + "extensions")); return null; } @@ -14971,29 +15882,73 @@ out Reporting.Error? error } case "displayName": { - theDisplayName = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDisplayName = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "displayName")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDisplayName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + + theDisplayName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDisplayName++; + SkipNoneWhitespaceAndComments(reader); + } } break; } case "description": { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + theDescription = new List(); - if (error != null) + if (!isEmptyProperty) { - error.PrependSegment( - new Reporting.NameSegment( - "description")); - return null; + SkipNoneWhitespaceAndComments(reader); + + int indexDescription = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + + theDescription.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDescription++; + SkipNoneWhitespaceAndComments(reader); + } } break; } @@ -15040,7 +15995,7 @@ out Reporting.Error? error case "administration": { theAdministration = AdministrativeInformationFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -15091,34 +16046,37 @@ out Reporting.Error? error } break; } - case "dataSpecifications": + case "embeddedDataSpecifications": { - theDataSpecifications = new List(); + theEmbeddedDataSpecifications = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexDataSpecifications = 0; + int indexEmbeddedDataSpecifications = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - Reference? item = ReferenceFromElement( - reader, ns, out error); + EmbeddedDataSpecification? item = EmbeddedDataSpecificationFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexDataSpecifications)); + indexEmbeddedDataSpecifications)); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); return null; } - theDataSpecifications.Add( + theEmbeddedDataSpecifications.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexDataSpecifications++; + indexEmbeddedDataSpecifications++; SkipNoneWhitespaceAndComments(reader); } } @@ -15136,13 +16094,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Reference? item = ReferenceFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexIsCaseOf)); + error.PrependSegment( + new Reporting.NameSegment( + "isCaseOf")); return null; } @@ -15190,7 +16151,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -15236,7 +16197,7 @@ out Reporting.Error? error theDescription, theChecksum, theAdministration, - theDataSpecifications, + theEmbeddedDataSpecifications, theIsCaseOf); } // internal static Aas.ConceptDescription? ConceptDescriptionFromSequence @@ -15245,7 +16206,6 @@ out Reporting.Error? error ///
internal static Aas.ConceptDescription? ConceptDescriptionFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -15270,7 +16230,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -15291,7 +16251,7 @@ out Reporting.Error? error Aas.ConceptDescription? result = ( ConceptDescriptionFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -15319,7 +16279,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -15351,7 +16311,6 @@ out Reporting.Error? error internal static Aas.Reference? ReferenceFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -15374,7 +16333,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -15445,7 +16404,7 @@ out Reporting.Error? error case "referredSemanticId": { theReferredSemanticId = ReferenceFromSequence( - reader, isEmptyProperty, ns, out error); + reader, isEmptyProperty, out error); if (error != null) { @@ -15468,13 +16427,16 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { Key? item = KeyFromElement( - reader, ns, out error); + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( indexKeys)); + error.PrependSegment( + new Reporting.NameSegment( + "keys")); return null; } @@ -15522,7 +16484,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -15580,7 +16542,6 @@ out Reporting.Error? error ///
internal static Aas.Reference? ReferenceFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -15605,7 +16566,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -15626,7 +16587,7 @@ out Reporting.Error? error Aas.Reference? result = ( ReferenceFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -15654,7 +16615,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -15686,7 +16647,6 @@ out Reporting.Error? error internal static Aas.Key? KeyFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -15708,7 +16668,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -15849,7 +16809,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -15906,7 +16866,6 @@ out Reporting.Error? error ///
internal static Aas.Key? KeyFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -15931,7 +16890,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -15952,7 +16911,7 @@ out Reporting.Error? error Aas.Key? result = ( KeyFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -15980,7 +16939,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -16012,7 +16971,6 @@ out Reporting.Error? error internal static Aas.LangString? LangStringFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; @@ -16034,7 +16992,7 @@ out Reporting.Error? error while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -16160,7 +17118,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -16217,7 +17175,6 @@ out Reporting.Error? error ///
internal static Aas.LangString? LangStringFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -16242,7 +17199,7 @@ out Reporting.Error? error } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -16263,7 +17220,7 @@ out Reporting.Error? error Aas.LangString? result = ( LangStringFromSequence( - reader, isEmptyElement, ns, out error)); + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -16291,7 +17248,7 @@ out Reporting.Error? error } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -16313,22 +17270,23 @@ out Reporting.Error? error } // internal static Aas.LangString? LangStringFromElement /// - /// Deserialize an instance of class LangStringSet from a sequence of XML elements. + /// Deserialize an instance of class Environment from a sequence of XML elements. /// /// /// If is set, we should try to deserialize /// the instance from an empty sequence. That is, the parent element /// was a self-closing element. /// - internal static Aas.LangStringSet? LangStringSetFromSequence( + internal static Aas.Environment? EnvironmentFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; - List? theLangStrings = null; + List? theAssetAdministrationShells = null; + List? theSubmodels = null; + List? theConceptDescriptions = null; if (!isEmptySequence) { @@ -16337,14 +17295,14 @@ out Reporting.Error? error { error = new Reporting.Error( "Expected an XML element representing " + - "a property of an instance of class LangStringSet, " + + "a property of an instance of class Environment, " + "but reached the end-of-file"); return null; } while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -16357,82 +17315,157 @@ out Reporting.Error? error switch (elementName) { - case "langStrings": + case "assetAdministrationShells": { - theLangStrings = new List(); + theAssetAdministrationShells = new List(); if (!isEmptyProperty) { SkipNoneWhitespaceAndComments(reader); - int indexLangStrings = 0; + int indexAssetAdministrationShells = 0; while (reader.NodeType == Xml.XmlNodeType.Element) { - LangString? item = LangStringFromElement( - reader, ns, out error); + AssetAdministrationShell? item = AssetAdministrationShellFromElement( + reader, out error); if (error != null) { error.PrependSegment( new Reporting.IndexSegment( - indexLangStrings)); + indexAssetAdministrationShells)); + error.PrependSegment( + new Reporting.NameSegment( + "assetAdministrationShells")); return null; } - theLangStrings.Add( + theAssetAdministrationShells.Add( item ?? throw new System.InvalidOperationException( "Unexpected item null when error null")); - indexLangStrings++; + indexAssetAdministrationShells++; SkipNoneWhitespaceAndComments(reader); } } break; } - default: - error = new Reporting.Error( - "We expected properties of the class LangStringSet, " + - "but got an unexpected element " + - $"with the name {elementName}"); - return null; - } + case "submodels": + { + theSubmodels = new List(); - SkipNoneWhitespaceAndComments(reader); + if (!isEmptyProperty) + { + SkipNoneWhitespaceAndComments(reader); - if (!isEmptyProperty) - { - // Read the end element + int indexSubmodels = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + Submodel? item = SubmodelFromElement( + reader, out error); - if (reader.EOF) - { - error = new Reporting.Error( - "Expected an XML end element to conclude a property of class LangStringSet " + - $"with the element name {elementName}, " + - "but got the end-of-file."); - return null; - } - if (reader.NodeType != Xml.XmlNodeType.EndElement) - { - error = new Reporting.Error( - "Expected an XML end element to conclude a property of class LangStringSet " + - $"with the element name {elementName}, " + - $"but got the node of type {reader.NodeType} " + - $"with the value {reader.Value}"); - return null; - } + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexSubmodels)); + error.PrependSegment( + new Reporting.NameSegment( + "submodels")); + return null; + } - string endElementName = TryElementName( - reader, ns, out error); - if (error != null) - { - return null; - } + theSubmodels.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexSubmodels++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + case "conceptDescriptions": + { + theConceptDescriptions = new List(); + + if (!isEmptyProperty) + { + SkipNoneWhitespaceAndComments(reader); + + int indexConceptDescriptions = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + ConceptDescription? item = ConceptDescriptionFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexConceptDescriptions)); + error.PrependSegment( + new Reporting.NameSegment( + "conceptDescriptions")); + return null; + } + + theConceptDescriptions.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexConceptDescriptions++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + default: + error = new Reporting.Error( + "We expected properties of the class Environment, " + + "but got an unexpected element " + + $"with the name {elementName}"); + return null; + } + + SkipNoneWhitespaceAndComments(reader); + + if (!isEmptyProperty) + { + // Read the end element + + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class Environment " + + $"with the element name {elementName}, " + + "but got the end-of-file."); + return null; + } + if (reader.NodeType != Xml.XmlNodeType.EndElement) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class Environment " + + $"with the element name {elementName}, " + + $"but got the node of type {reader.NodeType} " + + $"with the value {reader.Value}"); + return null; + } + + string endElementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } if (endElementName != elementName) { error = new Reporting.Error( - "Expected an XML end element to conclude a property of class LangStringSet " + + "Expected an XML end element to conclude a property of class Environment " + $"with the element name {elementName}, " + $"but got the end element with the name {reader.Name}"); return null; @@ -16450,26 +17483,17 @@ out Reporting.Error? error } } - if (theLangStrings == null) - { - error = new Reporting.Error( - "The required property LangStrings has not been given " + - "in the XML representation of an instance of class LangStringSet"); - return null; - } - - return new Aas.LangStringSet( - theLangStrings - ?? throw new System.InvalidOperationException( - "Unexpected null, had to be handled before")); - } // internal static Aas.LangStringSet? LangStringSetFromSequence + return new Aas.Environment( + theAssetAdministrationShells, + theSubmodels, + theConceptDescriptions); + } // internal static Aas.Environment? EnvironmentFromSequence /// - /// Deserialize an instance of class LangStringSet from an XML element. + /// Deserialize an instance of class Environment from an XML element. /// - internal static Aas.LangStringSet? LangStringSetFromElement( + internal static Aas.Environment? EnvironmentFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -16479,7 +17503,7 @@ out Reporting.Error? error if (reader.EOF) { error = new Reporting.Error( - "Expected an XML element representing an instance of class LangStringSet, " + + "Expected an XML element representing an instance of class Environment, " + "but reached the end-of-file"); return null; } @@ -16487,24 +17511,24 @@ out Reporting.Error? error if (reader.NodeType != Xml.XmlNodeType.Element) { error = new Reporting.Error( - "Expected an XML element representing an instance of class LangStringSet, " + + "Expected an XML element representing an instance of class Environment, " + $"but got a node of type {reader.NodeType} " + $"with value {reader.Value}"); return null; } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; } - if (elementName != "langStringSet") + if (elementName != "environment") { error = new Reporting.Error( - "Expected an element representing an instance of class LangStringSet " + - $"with element name langStringSet, but got: {elementName}"); + "Expected an element representing an instance of class Environment " + + $"with element name environment, but got: {elementName}"); return null; } @@ -16513,9 +17537,9 @@ out Reporting.Error? error // Skip the element node and go to the content reader.Read(); - Aas.LangStringSet? result = ( - LangStringSetFromSequence( - reader, isEmptyElement, ns, out error)); + Aas.Environment? result = ( + EnvironmentFromSequence( + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -16528,7 +17552,7 @@ out Reporting.Error? error if (reader.EOF) { error = new Reporting.Error( - "Expected an XML end element concluding an instance of class LangStringSet, " + + "Expected an XML end element concluding an instance of class Environment, " + "but reached the end-of-file"); return null; } @@ -16536,14 +17560,14 @@ out Reporting.Error? error if (reader.NodeType != Xml.XmlNodeType.EndElement) { error = new Reporting.Error( - "Expected an XML end element concluding an instance of class LangStringSet, " + + "Expected an XML end element concluding an instance of class Environment, " + $"but got a node of type {reader.NodeType} " + $"with value {reader.Value}"); return null; } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -16562,32 +17586,14 @@ out Reporting.Error? error } return result; - } // internal static Aas.LangStringSet? LangStringSetFromElement - - /// - /// Deserialize an instance of class DataSpecificationContent from a sequence of XML elements. - /// - /// - /// If is set, we should try to deserialize - /// the instance from an empty sequence. That is, the parent element - /// was a self-closing element. - /// - internal static Aas.DataSpecificationContent DataSpecificationContentFromSequence( - Xml.XmlReader reader, - bool isEmptySequence, - string? ns, - out Reporting.Error? error) - { - error = null; - return new Aas.DataSpecificationContent(); - } // internal static Aas.DataSpecificationContent? DataSpecificationContentFromSequence + } // internal static Aas.Environment? EnvironmentFromElement /// - /// Deserialize an instance of class DataSpecificationContent from an XML element. + /// Deserialize an instance of IDataSpecificationContent from an XML element. /// - internal static Aas.DataSpecificationContent? DataSpecificationContentFromElement( + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + internal static Aas.IDataSpecificationContent? IDataSpecificationContentFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -16597,111 +17603,58 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.EOF) { error = new Reporting.Error( - "Expected an XML element representing an instance of class DataSpecificationContent, " + - "but reached the end-of-file"); + "Expected an XML element, but reached end-of-file"); return null; } if (reader.NodeType != Xml.XmlNodeType.Element) { error = new Reporting.Error( - "Expected an XML element representing an instance of class DataSpecificationContent, " + + "Expected an XML element, " + $"but got a node of type {reader.NodeType} " + $"with value {reader.Value}"); return null; } string elementName = TryElementName( - reader, ns, out error); - if (error != null) - { - return null; - } - - if (elementName != "dataSpecificationContent") - { - error = new Reporting.Error( - "Expected an element representing an instance of class DataSpecificationContent " + - $"with element name dataSpecificationContent, but got: {elementName}"); - return null; - } - - bool isEmptyElement = reader.IsEmptyElement; - - // Skip the element node and go to the content - reader.Read(); - - Aas.DataSpecificationContent result = ( - DataSpecificationContentFromSequence( - reader, isEmptyElement, ns, out error)); + reader, out error); if (error != null) { return null; } - SkipNoneWhitespaceAndComments(reader); - - if (!isEmptyElement) + switch (elementName) { - if (reader.EOF) - { - error = new Reporting.Error( - "Expected an XML end element concluding an instance of class DataSpecificationContent, " + - "but reached the end-of-file"); - return null; - } - - if (reader.NodeType != Xml.XmlNodeType.EndElement) - { - error = new Reporting.Error( - "Expected an XML end element concluding an instance of class DataSpecificationContent, " + - $"but got a node of type {reader.NodeType} " + - $"with value {reader.Value}"); - return null; - } - - string endElementName = TryElementName( - reader, ns, out error); - if (error != null) - { - return null; - } - - if (endElementName != elementName) - { + case "dataSpecificationIec61360": + return DataSpecificationIec61360FromElement( + reader, out error); + case "dataSpecificationPhysicalUnit": + return DataSpecificationPhysicalUnitFromElement( + reader, out error); + default: error = new Reporting.Error( - $"Expected an XML end element with an name {elementName}, " + - $"but got: {endElementName}"); + $"Unexpected element with the name {elementName}"); return null; - } - - // Skip the end element - reader.Read(); } - - return result; - } // internal static Aas.DataSpecificationContent? DataSpecificationContentFromElement + } // internal static Aas.IDataSpecificationContent? IDataSpecificationContentFromElement /// - /// Deserialize an instance of class DataSpecification from a sequence of XML elements. + /// Deserialize an instance of class EmbeddedDataSpecification from a sequence of XML elements. /// /// /// If is set, we should try to deserialize /// the instance from an empty sequence. That is, the parent element /// was a self-closing element. /// - internal static Aas.DataSpecification? DataSpecificationFromSequence( + internal static Aas.EmbeddedDataSpecification? EmbeddedDataSpecificationFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; - string? theId = null; - DataSpecificationContent? theDataSpecificationContent = null; - AdministrativeInformation? theAdministration = null; - LangStringSet? theDescription = null; + Reference? theDataSpecification = null; + IDataSpecificationContent? theDataSpecificationContent = null; if (!isEmptySequence) { @@ -16710,14 +17663,14 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc { error = new Reporting.Error( "Expected an XML element representing " + - "a property of an instance of class DataSpecification, " + + "a property of an instance of class EmbeddedDataSpecification, " + "but reached the end-of-file"); return null; } while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -16730,91 +17683,76 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc switch (elementName) { - case "id": - { - if (isEmptyProperty) - { - theId = ""; - } - else - { - if (reader.EOF) - { - error = new Reporting.Error( - "Expected an XML content representing " + - "the property Id of an instance of class DataSpecification, " + - "but reached the end-of-file"); - return null; - } - - try - { - theId = reader.ReadContentAsString(); - } - catch (System.Exception exception) - { - if (exception is System.FormatException - || exception is System.Xml.XmlException) - { - error = new Reporting.Error( - "The property Id of an instance of class DataSpecification " + - $"could not be de-serialized: {exception.Message}"); - error.PrependSegment( - new Reporting.NameSegment( - "id")); - return null; - } - - throw; - } - } - break; - } - case "dataSpecificationContent": + case "dataSpecification": { - theDataSpecificationContent = DataSpecificationContentFromSequence( - reader, isEmptyProperty, ns, out error); + theDataSpecification = ReferenceFromSequence( + reader, isEmptyProperty, out error); if (error != null) { error.PrependSegment( new Reporting.NameSegment( - "dataSpecificationContent")); + "dataSpecification")); return null; } break; } - case "administration": + case "dataSpecificationContent": { - theAdministration = AdministrativeInformationFromSequence( - reader, isEmptyProperty, ns, out error); + if (isEmptyProperty) + { + error = new Reporting.Error( + $"Expected an XML element within the element {elementName} representing " + + "the property DataSpecificationContent of an instance of class EmbeddedDataSpecification, " + + "but encountered a self-closing element {elementName}"); + return null; + } - if (error != null) + // We need to skip the whitespace here in order to be able to look ahead + // the discriminator element shortly. + SkipNoneWhitespaceAndComments(reader); + + if (reader.EOF) { - error.PrependSegment( - new Reporting.NameSegment( - "administration")); + error = new Reporting.Error( + $"Expected an XML element within the element {elementName} representing " + + "the property DataSpecificationContent of an instance of class EmbeddedDataSpecification, " + + "but reached the end-of-file"); return null; } - break; - } - case "description": - { - theDescription = LangStringSetFromSequence( - reader, isEmptyProperty, ns, out error); + + // Try to look ahead the discriminator name; + // we need this name only for the error reporting below. + // IDataSpecificationContentFromElement will perform more sophisticated + // checks. + string? discriminatorElementName = null; + if (reader.NodeType == Xml.XmlNodeType.Element) + { + discriminatorElementName = reader.LocalName; + } + + theDataSpecificationContent = IDataSpecificationContentFromElement( + reader, out error); if (error != null) { + if (discriminatorElementName != null) + { + error.PrependSegment( + new Reporting.NameSegment( + discriminatorElementName)); + } + error.PrependSegment( new Reporting.NameSegment( - "description")); + "dataSpecificationContent")); return null; } break; } default: error = new Reporting.Error( - "We expected properties of the class DataSpecification, " + + "We expected properties of the class EmbeddedDataSpecification, " + "but got an unexpected element " + $"with the name {elementName}"); return null; @@ -16829,7 +17767,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.EOF) { error = new Reporting.Error( - "Expected an XML end element to conclude a property of class DataSpecification " + + "Expected an XML end element to conclude a property of class EmbeddedDataSpecification " + $"with the element name {elementName}, " + "but got the end-of-file."); return null; @@ -16837,7 +17775,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.NodeType != Xml.XmlNodeType.EndElement) { error = new Reporting.Error( - "Expected an XML end element to conclude a property of class DataSpecification " + + "Expected an XML end element to conclude a property of class EmbeddedDataSpecification " + $"with the element name {elementName}, " + $"but got the node of type {reader.NodeType} " + $"with the value {reader.Value}"); @@ -16845,7 +17783,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -16854,7 +17792,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (endElementName != elementName) { error = new Reporting.Error( - "Expected an XML end element to conclude a property of class DataSpecification " + + "Expected an XML end element to conclude a property of class EmbeddedDataSpecification " + $"with the element name {elementName}, " + $"but got the end element with the name {reader.Name}"); return null; @@ -16872,11 +17810,11 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc } } - if (theId == null) + if (theDataSpecification == null) { error = new Reporting.Error( - "The required property Id has not been given " + - "in the XML representation of an instance of class DataSpecification"); + "The required property DataSpecification has not been given " + + "in the XML representation of an instance of class EmbeddedDataSpecification"); return null; } @@ -16884,27 +17822,24 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc { error = new Reporting.Error( "The required property DataSpecificationContent has not been given " + - "in the XML representation of an instance of class DataSpecification"); + "in the XML representation of an instance of class EmbeddedDataSpecification"); return null; } - return new Aas.DataSpecification( - theId + 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"), - theAdministration, - theDescription); - } // internal static Aas.DataSpecification? DataSpecificationFromSequence + "Unexpected null, had to be handled before")); + } // internal static Aas.EmbeddedDataSpecification? EmbeddedDataSpecificationFromSequence /// - /// Deserialize an instance of class DataSpecification from an XML element. + /// Deserialize an instance of class EmbeddedDataSpecification from an XML element. /// - internal static Aas.DataSpecification? DataSpecificationFromElement( + internal static Aas.EmbeddedDataSpecification? EmbeddedDataSpecificationFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -16914,7 +17849,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.EOF) { error = new Reporting.Error( - "Expected an XML element representing an instance of class DataSpecification, " + + "Expected an XML element representing an instance of class EmbeddedDataSpecification, " + "but reached the end-of-file"); return null; } @@ -16922,24 +17857,24 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.NodeType != Xml.XmlNodeType.Element) { error = new Reporting.Error( - "Expected an XML element representing an instance of class DataSpecification, " + + "Expected an XML element representing an instance of class EmbeddedDataSpecification, " + $"but got a node of type {reader.NodeType} " + $"with value {reader.Value}"); return null; } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; } - if (elementName != "dataSpecification") + if (elementName != "embeddedDataSpecification") { error = new Reporting.Error( - "Expected an element representing an instance of class DataSpecification " + - $"with element name dataSpecification, but got: {elementName}"); + "Expected an element representing an instance of class EmbeddedDataSpecification " + + $"with element name embeddedDataSpecification, but got: {elementName}"); return null; } @@ -16948,9 +17883,9 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc // Skip the element node and go to the content reader.Read(); - Aas.DataSpecification? result = ( - DataSpecificationFromSequence( - reader, isEmptyElement, ns, out error)); + Aas.EmbeddedDataSpecification? result = ( + EmbeddedDataSpecificationFromSequence( + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -16963,7 +17898,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.EOF) { error = new Reporting.Error( - "Expected an XML end element concluding an instance of class DataSpecification, " + + "Expected an XML end element concluding an instance of class EmbeddedDataSpecification, " + "but reached the end-of-file"); return null; } @@ -16971,14 +17906,14 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.NodeType != Xml.XmlNodeType.EndElement) { error = new Reporting.Error( - "Expected an XML end element concluding an instance of class DataSpecification, " + + "Expected an XML end element concluding an instance of class EmbeddedDataSpecification, " + $"but got a node of type {reader.NodeType} " + $"with value {reader.Value}"); return null; } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -16997,28 +17932,25 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc } return result; - } // internal static Aas.DataSpecification? DataSpecificationFromElement + } // internal static Aas.EmbeddedDataSpecification? EmbeddedDataSpecificationFromElement /// - /// Deserialize an instance of class Environment from a sequence of XML elements. + /// Deserialize an instance of class ValueReferencePair from a sequence of XML elements. /// /// /// If is set, we should try to deserialize /// the instance from an empty sequence. That is, the parent element /// was a self-closing element. /// - internal static Aas.Environment? EnvironmentFromSequence( + internal static Aas.ValueReferencePair? ValueReferencePairFromSequence( Xml.XmlReader reader, bool isEmptySequence, - string? ns, out Reporting.Error? error) { error = null; - List? theAssetAdministrationShells = null; - List? theSubmodels = null; - List? theConceptDescriptions = null; - List? theDataSpecifications = null; + string? theValue = null; + Reference? theValueId = null; if (!isEmptySequence) { @@ -17027,14 +17959,14 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc { error = new Reporting.Error( "Expected an XML element representing " + - "a property of an instance of class Environment, " + + "a property of an instance of class ValueReferencePair, " + "but reached the end-of-file"); return null; } while (reader.NodeType == Xml.XmlNodeType.Element) { string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -17047,141 +17979,63 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc switch (elementName) { - case "assetAdministrationShells": + case "value": { - theAssetAdministrationShells = new List(); - - if (!isEmptyProperty) + if (isEmptyProperty) { - SkipNoneWhitespaceAndComments(reader); - - int indexAssetAdministrationShells = 0; - while (reader.NodeType == Xml.XmlNodeType.Element) - { - AssetAdministrationShell? item = AssetAdministrationShellFromElement( - reader, ns, out error); - - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexAssetAdministrationShells)); - return null; - } - - theAssetAdministrationShells.Add( - item - ?? throw new System.InvalidOperationException( - "Unexpected item null when error null")); - - indexAssetAdministrationShells++; - SkipNoneWhitespaceAndComments(reader); - } + theValue = ""; } - break; - } - case "submodels": - { - theSubmodels = new List(); - - if (!isEmptyProperty) + else { - SkipNoneWhitespaceAndComments(reader); - - int indexSubmodels = 0; - while (reader.NodeType == Xml.XmlNodeType.Element) + if (reader.EOF) { - Submodel? item = SubmodelFromElement( - reader, ns, out error); - - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexSubmodels)); - return null; - } - - theSubmodels.Add( - item - ?? throw new System.InvalidOperationException( - "Unexpected item null when error null")); - - indexSubmodels++; - SkipNoneWhitespaceAndComments(reader); + error = new Reporting.Error( + "Expected an XML content representing " + + "the property Value of an instance of class ValueReferencePair, " + + "but reached the end-of-file"); + return null; } - } - break; - } - case "conceptDescriptions": - { - theConceptDescriptions = new List(); - - if (!isEmptyProperty) - { - SkipNoneWhitespaceAndComments(reader); - int indexConceptDescriptions = 0; - while (reader.NodeType == Xml.XmlNodeType.Element) + try { - ConceptDescription? item = ConceptDescriptionFromElement( - reader, ns, out error); - - if (error != null) + theValue = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) { + error = new Reporting.Error( + "The property Value of an instance of class ValueReferencePair " + + $"could not be de-serialized: {exception.Message}"); error.PrependSegment( - new Reporting.IndexSegment( - indexConceptDescriptions)); + new Reporting.NameSegment( + "value")); return null; } - theConceptDescriptions.Add( - item - ?? throw new System.InvalidOperationException( - "Unexpected item null when error null")); - - indexConceptDescriptions++; - SkipNoneWhitespaceAndComments(reader); + throw; } } break; } - case "dataSpecifications": + case "valueId": { - theDataSpecifications = new List(); + theValueId = ReferenceFromSequence( + reader, isEmptyProperty, out error); - if (!isEmptyProperty) + if (error != null) { - SkipNoneWhitespaceAndComments(reader); - - int indexDataSpecifications = 0; - while (reader.NodeType == Xml.XmlNodeType.Element) - { - DataSpecification? item = DataSpecificationFromElement( - reader, ns, out error); - - if (error != null) - { - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - return null; - } - - theDataSpecifications.Add( - item - ?? throw new System.InvalidOperationException( - "Unexpected item null when error null")); - - indexDataSpecifications++; - SkipNoneWhitespaceAndComments(reader); - } + error.PrependSegment( + new Reporting.NameSegment( + "valueId")); + return null; } break; } default: error = new Reporting.Error( - "We expected properties of the class Environment, " + + "We expected properties of the class ValueReferencePair, " + "but got an unexpected element " + $"with the name {elementName}"); return null; @@ -17196,7 +18050,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.EOF) { error = new Reporting.Error( - "Expected an XML end element to conclude a property of class Environment " + + "Expected an XML end element to conclude a property of class ValueReferencePair " + $"with the element name {elementName}, " + "but got the end-of-file."); return null; @@ -17204,7 +18058,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.NodeType != Xml.XmlNodeType.EndElement) { error = new Reporting.Error( - "Expected an XML end element to conclude a property of class Environment " + + "Expected an XML end element to conclude a property of class ValueReferencePair " + $"with the element name {elementName}, " + $"but got the node of type {reader.NodeType} " + $"with the value {reader.Value}"); @@ -17212,7 +18066,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -17221,7 +18075,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (endElementName != elementName) { error = new Reporting.Error( - "Expected an XML end element to conclude a property of class Environment " + + "Expected an XML end element to conclude a property of class ValueReferencePair " + $"with the element name {elementName}, " + $"but got the end element with the name {reader.Name}"); return null; @@ -17239,19 +18093,36 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc } } - return new Aas.Environment( - theAssetAdministrationShells, - theSubmodels, - theConceptDescriptions, - theDataSpecifications); - } // internal static Aas.Environment? EnvironmentFromSequence + if (theValue == null) + { + error = new Reporting.Error( + "The required property Value has not been given " + + "in the XML representation of an instance of class ValueReferencePair"); + return null; + } + + if (theValueId == null) + { + error = new Reporting.Error( + "The required property ValueId has not been given " + + "in the XML representation of an instance of class ValueReferencePair"); + return null; + } + + return new Aas.ValueReferencePair( + theValue + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theValueId + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before")); + } // internal static Aas.ValueReferencePair? ValueReferencePairFromSequence /// - /// Deserialize an instance of class Environment from an XML element. + /// Deserialize an instance of class ValueReferencePair from an XML element. /// - internal static Aas.Environment? EnvironmentFromElement( + internal static Aas.ValueReferencePair? ValueReferencePairFromElement( Xml.XmlReader reader, - string? ns, out Reporting.Error? error) { error = null; @@ -17261,7 +18132,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.EOF) { error = new Reporting.Error( - "Expected an XML element representing an instance of class Environment, " + + "Expected an XML element representing an instance of class ValueReferencePair, " + "but reached the end-of-file"); return null; } @@ -17269,24 +18140,24 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.NodeType != Xml.XmlNodeType.Element) { error = new Reporting.Error( - "Expected an XML element representing an instance of class Environment, " + + "Expected an XML element representing an instance of class ValueReferencePair, " + $"but got a node of type {reader.NodeType} " + $"with value {reader.Value}"); return null; } string elementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; } - if (elementName != "environment") + if (elementName != "valueReferencePair") { error = new Reporting.Error( - "Expected an element representing an instance of class Environment " + - $"with element name environment, but got: {elementName}"); + "Expected an element representing an instance of class ValueReferencePair " + + $"with element name valueReferencePair, but got: {elementName}"); return null; } @@ -17295,9 +18166,9 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc // Skip the element node and go to the content reader.Read(); - Aas.Environment? result = ( - EnvironmentFromSequence( - reader, isEmptyElement, ns, out error)); + Aas.ValueReferencePair? result = ( + ValueReferencePairFromSequence( + reader, isEmptyElement, out error)); if (error != null) { return null; @@ -17310,7 +18181,7 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.EOF) { error = new Reporting.Error( - "Expected an XML end element concluding an instance of class Environment, " + + "Expected an XML end element concluding an instance of class ValueReferencePair, " + "but reached the end-of-file"); return null; } @@ -17318,14 +18189,14 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc if (reader.NodeType != Xml.XmlNodeType.EndElement) { error = new Reporting.Error( - "Expected an XML end element concluding an instance of class Environment, " + + "Expected an XML end element concluding an instance of class ValueReferencePair, " + $"but got a node of type {reader.NodeType} " + $"with value {reader.Value}"); return null; } string endElementName = TryElementName( - reader, ns, out error); + reader, out error); if (error != null) { return null; @@ -17344,102 +18215,1805 @@ internal static Aas.DataSpecificationContent DataSpecificationContentFromSequenc } return result; - } // internal static Aas.Environment? EnvironmentFromElement - } // internal static class DeserializeImplementation - - /// - /// Represent a critical error during the deserialization. - /// - public class Exception : System.Exception - { - public readonly string Path; - public readonly string Cause; - public Exception(string path, string cause) - : base($"{cause} at: {path}") - { - Path = path; - Cause = cause; - } - } + } // internal static Aas.ValueReferencePair? ValueReferencePairFromElement - /// - /// Deserialize instances of meta-model classes from XML. - /// - /// - /// Here is an example how to parse an instance of class IHasSemantics: - /// - /// var reader = new System.Xml.XmlReader(/* some arguments */); - /// Aas.IHasSemantics anInstance = Deserialize.IHasSemanticsFrom( - /// reader); - /// - /// - /// - /// - /// If the elements live in a namespace, you have to supply it. For example: - /// - /// var reader = new System.Xml.XmlReader(/* some arguments */); - /// Aas.IHasSemantics anInstance = Deserialize.IHasSemanticsFrom( - /// reader, - /// "http://www.example.com/5/12"); - /// - /// - public static class Deserialize - { /// - /// Deserialize an instance of IHasSemantics from . + /// Deserialize an instance of class ValueList from a sequence of XML elements. /// - /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// - /// - /// Thrown when the element is not a valid XML - /// representation of IHasSemantics. - /// - [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] - public static Aas.IHasSemantics IHasSemanticsFrom( + /// + /// If is set, we should try to deserialize + /// the instance from an empty sequence. That is, the parent element + /// was a self-closing element. + /// + internal static Aas.ValueList? ValueListFromSequence( Xml.XmlReader reader, - string? ns = null) + bool isEmptySequence, + out Reporting.Error? error) { - Aas.IHasSemantics? result = ( - DeserializeImplementation.IHasSemanticsFromElement( - reader, - ns, - out Reporting.Error? error)); - if (error != null) - { - throw new Xmlization.Exception( - Reporting.GenerateRelativeXPath(error.PathSegments), - error.Cause); - } - return result - ?? throw new System.InvalidOperationException( - "Unexpected output null when error is null"); - } + error = null; - /// - /// Deserialize an instance of Extension from . - /// - /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// - /// - /// Thrown when the element is not a valid XML - /// representation of Extension. - /// - public static Aas.Extension ExtensionFrom( - Xml.XmlReader reader, - string? ns = null) - { - Aas.Extension? result = ( - DeserializeImplementation.ExtensionFromElement( - reader, - ns, - out Reporting.Error? error)); - if (error != null) + List? theValueReferencePairs = null; + + if (!isEmptySequence) + { + SkipNoneWhitespaceAndComments(reader); + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class ValueList, " + + "but reached the end-of-file"); + return null; + } + while (reader.NodeType == Xml.XmlNodeType.Element) + { + string elementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + bool isEmptyProperty = reader.IsEmptyElement; + + // Skip the expected element + reader.Read(); + + switch (elementName) + { + case "valueReferencePairs": + { + theValueReferencePairs = new List(); + + if (!isEmptyProperty) + { + SkipNoneWhitespaceAndComments(reader); + + int indexValueReferencePairs = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + ValueReferencePair? item = ValueReferencePairFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexValueReferencePairs)); + error.PrependSegment( + new Reporting.NameSegment( + "valueReferencePairs")); + return null; + } + + theValueReferencePairs.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexValueReferencePairs++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + default: + error = new Reporting.Error( + "We expected properties of the class ValueList, " + + "but got an unexpected element " + + $"with the name {elementName}"); + return null; + } + + SkipNoneWhitespaceAndComments(reader); + + if (!isEmptyProperty) + { + // Read the end element + + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class ValueList " + + $"with the element name {elementName}, " + + "but got the end-of-file."); + return null; + } + if (reader.NodeType != Xml.XmlNodeType.EndElement) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class ValueList " + + $"with the element name {elementName}, " + + $"but got the node of type {reader.NodeType} " + + $"with the value {reader.Value}"); + return null; + } + + string endElementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + if (endElementName != elementName) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class ValueList " + + $"with the element name {elementName}, " + + $"but got the end element with the name {reader.Name}"); + return null; + } + // Skip the expected end element + reader.Read(); + + SkipNoneWhitespaceAndComments(reader); + } + + if (reader.EOF) + { + break; + } + } + } + + if (theValueReferencePairs == null) + { + error = new Reporting.Error( + "The required property ValueReferencePairs has not been given " + + "in the XML representation of an instance of class ValueList"); + return null; + } + + return new Aas.ValueList( + theValueReferencePairs + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before")); + } // internal static Aas.ValueList? ValueListFromSequence + + /// + /// Deserialize an instance of class ValueList from an XML element. + /// + internal static Aas.ValueList? ValueListFromElement( + Xml.XmlReader reader, + out Reporting.Error? error) + { + error = null; + + SkipNoneWhitespaceAndComments(reader); + + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML element representing an instance of class ValueList, " + + "but reached the end-of-file"); + return null; + } + + if (reader.NodeType != Xml.XmlNodeType.Element) + { + error = new Reporting.Error( + "Expected an XML element representing an instance of class ValueList, " + + $"but got a node of type {reader.NodeType} " + + $"with value {reader.Value}"); + return null; + } + + string elementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + if (elementName != "valueList") + { + error = new Reporting.Error( + "Expected an element representing an instance of class ValueList " + + $"with element name valueList, but got: {elementName}"); + return null; + } + + bool isEmptyElement = reader.IsEmptyElement; + + // Skip the element node and go to the content + reader.Read(); + + Aas.ValueList? result = ( + ValueListFromSequence( + reader, isEmptyElement, out error)); + if (error != null) + { + return null; + } + + SkipNoneWhitespaceAndComments(reader); + + if (!isEmptyElement) + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML end element concluding an instance of class ValueList, " + + "but reached the end-of-file"); + return null; + } + + if (reader.NodeType != Xml.XmlNodeType.EndElement) + { + error = new Reporting.Error( + "Expected an XML end element concluding an instance of class ValueList, " + + $"but got a node of type {reader.NodeType} " + + $"with value {reader.Value}"); + return null; + } + + string endElementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + if (endElementName != elementName) + { + error = new Reporting.Error( + $"Expected an XML end element with an name {elementName}, " + + $"but got: {endElementName}"); + return null; + } + + // Skip the end element + reader.Read(); + } + + return result; + } // internal static Aas.ValueList? ValueListFromElement + + /// + /// Deserialize an instance of class DataSpecificationIec61360 from a sequence of XML elements. + /// + /// + /// If is set, we should try to deserialize + /// the instance from an empty sequence. That is, the parent element + /// was a self-closing element. + /// + internal static Aas.DataSpecificationIec61360? DataSpecificationIec61360FromSequence( + Xml.XmlReader reader, + bool isEmptySequence, + out Reporting.Error? error) + { + error = null; + + List? thePreferredName = null; + List? theShortName = null; + string? theUnit = null; + Reference? theUnitId = null; + string? theSourceOfDefinition = null; + string? theSymbol = null; + DataTypeIec61360? theDataType = null; + List? theDefinition = null; + string? theValueFormat = null; + ValueList? theValueList = null; + string? theValue = null; + LevelType? theLevelType = null; + + if (!isEmptySequence) + { + SkipNoneWhitespaceAndComments(reader); + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return null; + } + while (reader.NodeType == Xml.XmlNodeType.Element) + { + string elementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + bool isEmptyProperty = reader.IsEmptyElement; + + // Skip the expected element + reader.Read(); + + switch (elementName) + { + case "preferredName": + { + thePreferredName = new List(); + + if (!isEmptyProperty) + { + SkipNoneWhitespaceAndComments(reader); + + int indexPreferredName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexPreferredName)); + error.PrependSegment( + new Reporting.NameSegment( + "preferredName")); + return null; + } + + thePreferredName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexPreferredName++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + case "shortName": + { + theShortName = new List(); + + if (!isEmptyProperty) + { + SkipNoneWhitespaceAndComments(reader); + + int indexShortName = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexShortName)); + error.PrependSegment( + new Reporting.NameSegment( + "shortName")); + return null; + } + + theShortName.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexShortName++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + case "unit": + { + if (isEmptyProperty) + { + theUnit = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property Unit of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return null; + } + + try + { + theUnit = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property Unit of an instance of class DataSpecificationIec61360 " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "unit")); + return null; + } + + throw; + } + } + break; + } + case "unitId": + { + theUnitId = ReferenceFromSequence( + reader, isEmptyProperty, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "unitId")); + return null; + } + break; + } + case "sourceOfDefinition": + { + if (isEmptyProperty) + { + theSourceOfDefinition = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property SourceOfDefinition of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return null; + } + + try + { + theSourceOfDefinition = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property SourceOfDefinition of an instance of class DataSpecificationIec61360 " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "sourceOfDefinition")); + return null; + } + + throw; + } + } + break; + } + case "symbol": + { + if (isEmptyProperty) + { + theSymbol = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property Symbol of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return null; + } + + try + { + theSymbol = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property Symbol of an instance of class DataSpecificationIec61360 " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "symbol")); + return null; + } + + throw; + } + } + break; + } + case "dataType": + { + if (isEmptyProperty) + { + error = new Reporting.Error( + "The property DataType of an instance of class DataSpecificationIec61360 " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.PrependSegment( + new Reporting.NameSegment( + "dataType")); + return null; + } + + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property DataType of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return null; + } + + string textDataType; + try + { + textDataType = reader.ReadContentAsString(); + } + catch (System.FormatException exception) + { + error = new Reporting.Error( + "The property DataType of an instance of class DataSpecificationIec61360 " + + $"could not be de-serialized as a string: {exception}"); + error.PrependSegment( + new Reporting.NameSegment( + "dataType")); + return null; + } + + theDataType = Stringification.DataTypeIec61360FromString( + textDataType); + + if (theDataType == null) + { + error = new Reporting.Error( + "The property DataType of an instance of class DataSpecificationIec61360 " + + "could not be de-serialized from an unexpected enumeration literal: " + + textDataType); + error.PrependSegment( + new Reporting.NameSegment( + "dataType")); + return null; + } + break; + } + case "definition": + { + theDefinition = new List(); + + if (!isEmptyProperty) + { + SkipNoneWhitespaceAndComments(reader); + + int indexDefinition = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDefinition)); + error.PrependSegment( + new Reporting.NameSegment( + "definition")); + return null; + } + + theDefinition.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDefinition++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + case "valueFormat": + { + if (isEmptyProperty) + { + theValueFormat = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property ValueFormat of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return null; + } + + try + { + theValueFormat = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property ValueFormat of an instance of class DataSpecificationIec61360 " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "valueFormat")); + return null; + } + + throw; + } + } + break; + } + case "valueList": + { + theValueList = ValueListFromSequence( + reader, isEmptyProperty, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.NameSegment( + "valueList")); + return null; + } + break; + } + case "value": + { + if (isEmptyProperty) + { + theValue = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property Value of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return null; + } + + try + { + theValue = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property Value of an instance of class DataSpecificationIec61360 " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "value")); + return null; + } + + throw; + } + } + break; + } + case "levelType": + { + if (isEmptyProperty) + { + error = new Reporting.Error( + "The property LevelType of an instance of class DataSpecificationIec61360 " + + "can not be de-serialized from a self-closing element " + + "since it needs content"); + error.PrependSegment( + new Reporting.NameSegment( + "levelType")); + return null; + } + + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property LevelType of an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return null; + } + + string textLevelType; + try + { + textLevelType = reader.ReadContentAsString(); + } + catch (System.FormatException exception) + { + error = new Reporting.Error( + "The property LevelType of an instance of class DataSpecificationIec61360 " + + $"could not be de-serialized as a string: {exception}"); + error.PrependSegment( + new Reporting.NameSegment( + "levelType")); + return null; + } + + theLevelType = Stringification.LevelTypeFromString( + textLevelType); + + if (theLevelType == null) + { + error = new Reporting.Error( + "The property LevelType of an instance of class DataSpecificationIec61360 " + + "could not be de-serialized from an unexpected enumeration literal: " + + textLevelType); + error.PrependSegment( + new Reporting.NameSegment( + "levelType")); + return null; + } + break; + } + default: + error = new Reporting.Error( + "We expected properties of the class DataSpecificationIec61360, " + + "but got an unexpected element " + + $"with the name {elementName}"); + return null; + } + + SkipNoneWhitespaceAndComments(reader); + + if (!isEmptyProperty) + { + // Read the end element + + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class DataSpecificationIec61360 " + + $"with the element name {elementName}, " + + "but got the end-of-file."); + return null; + } + if (reader.NodeType != Xml.XmlNodeType.EndElement) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class DataSpecificationIec61360 " + + $"with the element name {elementName}, " + + $"but got the node of type {reader.NodeType} " + + $"with the value {reader.Value}"); + return null; + } + + string endElementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + if (endElementName != elementName) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class DataSpecificationIec61360 " + + $"with the element name {elementName}, " + + $"but got the end element with the name {reader.Name}"); + return null; + } + // Skip the expected end element + reader.Read(); + + SkipNoneWhitespaceAndComments(reader); + } + + if (reader.EOF) + { + break; + } + } + } + + if (thePreferredName == null) + { + error = new Reporting.Error( + "The required property PreferredName has not been given " + + "in the XML representation of an instance of class DataSpecificationIec61360"); + return null; + } + + return new Aas.DataSpecificationIec61360( + thePreferredName + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theShortName, + theUnit, + theUnitId, + theSourceOfDefinition, + theSymbol, + theDataType, + theDefinition, + theValueFormat, + theValueList, + theValue, + theLevelType); + } // internal static Aas.DataSpecificationIec61360? DataSpecificationIec61360FromSequence + + /// + /// Deserialize an instance of class DataSpecificationIec61360 from an XML element. + /// + internal static Aas.DataSpecificationIec61360? DataSpecificationIec61360FromElement( + Xml.XmlReader reader, + out Reporting.Error? error) + { + error = null; + + SkipNoneWhitespaceAndComments(reader); + + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML element representing an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return null; + } + + if (reader.NodeType != Xml.XmlNodeType.Element) + { + error = new Reporting.Error( + "Expected an XML element representing an instance of class DataSpecificationIec61360, " + + $"but got a node of type {reader.NodeType} " + + $"with value {reader.Value}"); + return null; + } + + string elementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + if (elementName != "dataSpecificationIec61360") + { + error = new Reporting.Error( + "Expected an element representing an instance of class DataSpecificationIec61360 " + + $"with element name dataSpecificationIec61360, but got: {elementName}"); + return null; + } + + bool isEmptyElement = reader.IsEmptyElement; + + // Skip the element node and go to the content + reader.Read(); + + Aas.DataSpecificationIec61360? result = ( + DataSpecificationIec61360FromSequence( + reader, isEmptyElement, out error)); + if (error != null) + { + return null; + } + + SkipNoneWhitespaceAndComments(reader); + + if (!isEmptyElement) + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML end element concluding an instance of class DataSpecificationIec61360, " + + "but reached the end-of-file"); + return null; + } + + if (reader.NodeType != Xml.XmlNodeType.EndElement) + { + error = new Reporting.Error( + "Expected an XML end element concluding an instance of class DataSpecificationIec61360, " + + $"but got a node of type {reader.NodeType} " + + $"with value {reader.Value}"); + return null; + } + + string endElementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + if (endElementName != elementName) + { + error = new Reporting.Error( + $"Expected an XML end element with an name {elementName}, " + + $"but got: {endElementName}"); + return null; + } + + // Skip the end element + reader.Read(); + } + + return result; + } // internal static Aas.DataSpecificationIec61360? DataSpecificationIec61360FromElement + + /// + /// Deserialize an instance of class DataSpecificationPhysicalUnit from a sequence of XML elements. + /// + /// + /// If is set, we should try to deserialize + /// the instance from an empty sequence. That is, the parent element + /// was a self-closing element. + /// + internal static Aas.DataSpecificationPhysicalUnit? DataSpecificationPhysicalUnitFromSequence( + Xml.XmlReader reader, + bool isEmptySequence, + out Reporting.Error? error) + { + error = null; + + string? theUnitName = null; + string? theUnitSymbol = null; + List? theDefinition = null; + string? theSiNotation = null; + string? theSiName = null; + string? theDinNotation = null; + string? theEceName = null; + string? theEceCode = null; + string? theNistName = null; + string? theSourceOfDefinition = null; + string? theConversionFactor = null; + string? theRegistrationAuthorityId = null; + string? theSupplier = null; + + if (!isEmptySequence) + { + SkipNoneWhitespaceAndComments(reader); + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML element representing " + + "a property of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + while (reader.NodeType == Xml.XmlNodeType.Element) + { + string elementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + bool isEmptyProperty = reader.IsEmptyElement; + + // Skip the expected element + reader.Read(); + + switch (elementName) + { + case "unitName": + { + if (isEmptyProperty) + { + theUnitName = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property UnitName of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theUnitName = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property UnitName of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "unitName")); + return null; + } + + throw; + } + } + break; + } + case "unitSymbol": + { + if (isEmptyProperty) + { + theUnitSymbol = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property UnitSymbol of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theUnitSymbol = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property UnitSymbol of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "unitSymbol")); + return null; + } + + throw; + } + } + break; + } + case "definition": + { + theDefinition = new List(); + + if (!isEmptyProperty) + { + SkipNoneWhitespaceAndComments(reader); + + int indexDefinition = 0; + while (reader.NodeType == Xml.XmlNodeType.Element) + { + LangString? item = LangStringFromElement( + reader, out error); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDefinition)); + error.PrependSegment( + new Reporting.NameSegment( + "definition")); + return null; + } + + theDefinition.Add( + item + ?? throw new System.InvalidOperationException( + "Unexpected item null when error null")); + + indexDefinition++; + SkipNoneWhitespaceAndComments(reader); + } + } + break; + } + case "siNotation": + { + if (isEmptyProperty) + { + theSiNotation = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property SiNotation of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theSiNotation = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property SiNotation of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "siNotation")); + return null; + } + + throw; + } + } + break; + } + case "siName": + { + if (isEmptyProperty) + { + theSiName = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property SiName of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theSiName = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property SiName of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "siName")); + return null; + } + + throw; + } + } + break; + } + case "dinNotation": + { + if (isEmptyProperty) + { + theDinNotation = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property DinNotation of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theDinNotation = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property DinNotation of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "dinNotation")); + return null; + } + + throw; + } + } + break; + } + case "eceName": + { + if (isEmptyProperty) + { + theEceName = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property EceName of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theEceName = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property EceName of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "eceName")); + return null; + } + + throw; + } + } + break; + } + case "eceCode": + { + if (isEmptyProperty) + { + theEceCode = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property EceCode of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theEceCode = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property EceCode of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "eceCode")); + return null; + } + + throw; + } + } + break; + } + case "nistName": + { + if (isEmptyProperty) + { + theNistName = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property NistName of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theNistName = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property NistName of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "nistName")); + return null; + } + + throw; + } + } + break; + } + case "sourceOfDefinition": + { + if (isEmptyProperty) + { + theSourceOfDefinition = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property SourceOfDefinition of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theSourceOfDefinition = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property SourceOfDefinition of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "sourceOfDefinition")); + return null; + } + + throw; + } + } + break; + } + case "conversionFactor": + { + if (isEmptyProperty) + { + theConversionFactor = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property ConversionFactor of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theConversionFactor = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property ConversionFactor of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "conversionFactor")); + return null; + } + + throw; + } + } + break; + } + case "registrationAuthorityId": + { + if (isEmptyProperty) + { + theRegistrationAuthorityId = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property RegistrationAuthorityId of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theRegistrationAuthorityId = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property RegistrationAuthorityId of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "registrationAuthorityId")); + return null; + } + + throw; + } + } + break; + } + case "supplier": + { + if (isEmptyProperty) + { + theSupplier = ""; + } + else + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML content representing " + + "the property Supplier of an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + try + { + theSupplier = reader.ReadContentAsString(); + } + catch (System.Exception exception) + { + if (exception is System.FormatException + || exception is System.Xml.XmlException) + { + error = new Reporting.Error( + "The property Supplier of an instance of class DataSpecificationPhysicalUnit " + + $"could not be de-serialized: {exception.Message}"); + error.PrependSegment( + new Reporting.NameSegment( + "supplier")); + return null; + } + + throw; + } + } + break; + } + default: + error = new Reporting.Error( + "We expected properties of the class DataSpecificationPhysicalUnit, " + + "but got an unexpected element " + + $"with the name {elementName}"); + return null; + } + + SkipNoneWhitespaceAndComments(reader); + + if (!isEmptyProperty) + { + // Read the end element + + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class DataSpecificationPhysicalUnit " + + $"with the element name {elementName}, " + + "but got the end-of-file."); + return null; + } + if (reader.NodeType != Xml.XmlNodeType.EndElement) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class DataSpecificationPhysicalUnit " + + $"with the element name {elementName}, " + + $"but got the node of type {reader.NodeType} " + + $"with the value {reader.Value}"); + return null; + } + + string endElementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + if (endElementName != elementName) + { + error = new Reporting.Error( + "Expected an XML end element to conclude a property of class DataSpecificationPhysicalUnit " + + $"with the element name {elementName}, " + + $"but got the end element with the name {reader.Name}"); + return null; + } + // Skip the expected end element + reader.Read(); + + SkipNoneWhitespaceAndComments(reader); + } + + if (reader.EOF) + { + break; + } + } + } + + if (theUnitName == null) + { + error = new Reporting.Error( + "The required property UnitName has not been given " + + "in the XML representation of an instance of class DataSpecificationPhysicalUnit"); + return null; + } + + if (theUnitSymbol == null) + { + error = new Reporting.Error( + "The required property UnitSymbol has not been given " + + "in the XML representation of an instance of class DataSpecificationPhysicalUnit"); + return null; + } + + if (theDefinition == null) + { + error = new Reporting.Error( + "The required property Definition has not been given " + + "in the XML representation of an instance of class DataSpecificationPhysicalUnit"); + return null; + } + + return new Aas.DataSpecificationPhysicalUnit( + theUnitName + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theUnitSymbol + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theDefinition + ?? throw new System.InvalidOperationException( + "Unexpected null, had to be handled before"), + theSiNotation, + theSiName, + theDinNotation, + theEceName, + theEceCode, + theNistName, + theSourceOfDefinition, + theConversionFactor, + theRegistrationAuthorityId, + theSupplier); + } // internal static Aas.DataSpecificationPhysicalUnit? DataSpecificationPhysicalUnitFromSequence + + /// + /// Deserialize an instance of class DataSpecificationPhysicalUnit from an XML element. + /// + internal static Aas.DataSpecificationPhysicalUnit? DataSpecificationPhysicalUnitFromElement( + Xml.XmlReader reader, + out Reporting.Error? error) + { + error = null; + + SkipNoneWhitespaceAndComments(reader); + + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML element representing an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + if (reader.NodeType != Xml.XmlNodeType.Element) + { + error = new Reporting.Error( + "Expected an XML element representing an instance of class DataSpecificationPhysicalUnit, " + + $"but got a node of type {reader.NodeType} " + + $"with value {reader.Value}"); + return null; + } + + string elementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + if (elementName != "dataSpecificationPhysicalUnit") + { + error = new Reporting.Error( + "Expected an element representing an instance of class DataSpecificationPhysicalUnit " + + $"with element name dataSpecificationPhysicalUnit, but got: {elementName}"); + return null; + } + + bool isEmptyElement = reader.IsEmptyElement; + + // Skip the element node and go to the content + reader.Read(); + + Aas.DataSpecificationPhysicalUnit? result = ( + DataSpecificationPhysicalUnitFromSequence( + reader, isEmptyElement, out error)); + if (error != null) + { + return null; + } + + SkipNoneWhitespaceAndComments(reader); + + if (!isEmptyElement) + { + if (reader.EOF) + { + error = new Reporting.Error( + "Expected an XML end element concluding an instance of class DataSpecificationPhysicalUnit, " + + "but reached the end-of-file"); + return null; + } + + if (reader.NodeType != Xml.XmlNodeType.EndElement) + { + error = new Reporting.Error( + "Expected an XML end element concluding an instance of class DataSpecificationPhysicalUnit, " + + $"but got a node of type {reader.NodeType} " + + $"with value {reader.Value}"); + return null; + } + + string endElementName = TryElementName( + reader, out error); + if (error != null) + { + return null; + } + + if (endElementName != elementName) + { + error = new Reporting.Error( + $"Expected an XML end element with an name {elementName}, " + + $"but got: {endElementName}"); + return null; + } + + // Skip the end element + reader.Read(); + } + + return result; + } // internal static Aas.DataSpecificationPhysicalUnit? DataSpecificationPhysicalUnitFromElement + } // internal static class DeserializeImplementation + + /// + /// Represent a critical error during the deserialization. + /// + public class Exception : System.Exception + { + public readonly string Path; + public readonly string Cause; + public Exception(string path, string cause) + : base($"{cause} at: {path}") + { + Path = path; + Cause = cause; + } + } + + /// + /// Deserialize instances of meta-model classes from XML. + /// + /// + /// Here is an example how to parse an instance of class IHasSemantics: + /// + /// var reader = new System.Xml.XmlReader(/* some arguments */); + /// Aas.IHasSemantics anInstance = Deserialize.IHasSemanticsFrom( + /// reader); + /// + /// + /// + /// + /// If the elements live in a namespace, you have to supply it. For example: + /// + /// var reader = new System.Xml.XmlReader(/* some arguments */); + /// Aas.IHasSemantics anInstance = Deserialize.IHasSemanticsFrom( + /// reader, + /// "http://www.example.com/5/12"); + /// + /// + public static class Deserialize + { + /// + /// Deserialize an instance of IHasSemantics from . + /// + /// Initialized XML reader with cursor set to the element + /// + /// Thrown when the element is not a valid XML + /// representation of IHasSemantics. + /// + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static Aas.IHasSemantics IHasSemanticsFrom( + Xml.XmlReader reader) + { + Aas.IHasSemantics? result = ( + DeserializeImplementation.IHasSemanticsFromElement( + reader, + out Reporting.Error? error)); + if (error != null) + { + throw new Xmlization.Exception( + Reporting.GenerateRelativeXPath(error.PathSegments), + error.Cause); + } + return result + ?? throw new System.InvalidOperationException( + "Unexpected output null when error is null"); + } + + /// + /// Deserialize an instance of Extension from . + /// + /// Initialized XML reader with cursor set to the element + /// + /// Thrown when the element is not a valid XML + /// representation of Extension. + /// + public static Aas.Extension ExtensionFrom( + Xml.XmlReader reader) + { + Aas.Extension? result = ( + DeserializeImplementation.ExtensionFromElement( + reader, + out Reporting.Error? error)); + if (error != null) { throw new Xmlization.Exception( Reporting.GenerateRelativeXPath(error.PathSegments), @@ -17454,23 +20028,17 @@ public static Aas.Extension ExtensionFrom( /// Deserialize an instance of IHasExtensions from . ///
/// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of IHasExtensions. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] public static Aas.IHasExtensions IHasExtensionsFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.IHasExtensions? result = ( DeserializeImplementation.IHasExtensionsFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17487,23 +20055,17 @@ public static Aas.IHasExtensions IHasExtensionsFrom( /// Deserialize an instance of IReferable from . ///
/// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of IReferable. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] public static Aas.IReferable IReferableFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.IReferable? result = ( DeserializeImplementation.IReferableFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17520,23 +20082,17 @@ public static Aas.IReferable IReferableFrom( /// Deserialize an instance of IIdentifiable from . ///
/// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of IIdentifiable. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] public static Aas.IIdentifiable IIdentifiableFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.IIdentifiable? result = ( DeserializeImplementation.IIdentifiableFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17553,23 +20109,17 @@ public static Aas.IIdentifiable IIdentifiableFrom( /// Deserialize an instance of IHasKind from . ///
/// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of IHasKind. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] public static Aas.IHasKind IHasKindFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.IHasKind? result = ( DeserializeImplementation.IHasKindFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17586,23 +20136,17 @@ public static Aas.IHasKind IHasKindFrom( /// Deserialize an instance of IHasDataSpecification from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of IHasDataSpecification. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] public static Aas.IHasDataSpecification IHasDataSpecificationFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.IHasDataSpecification? result = ( DeserializeImplementation.IHasDataSpecificationFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17619,22 +20163,16 @@ public static Aas.IHasDataSpecification IHasDataSpecificationFrom( /// Deserialize an instance of AdministrativeInformation from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of AdministrativeInformation. /// public static Aas.AdministrativeInformation AdministrativeInformationFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.AdministrativeInformation? result = ( DeserializeImplementation.AdministrativeInformationFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17651,23 +20189,17 @@ public static Aas.AdministrativeInformation AdministrativeInformationFrom( /// Deserialize an instance of IQualifiable from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of IQualifiable. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] public static Aas.IQualifiable IQualifiableFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.IQualifiable? result = ( DeserializeImplementation.IQualifiableFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17684,22 +20216,16 @@ public static Aas.IQualifiable IQualifiableFrom( /// Deserialize an instance of Qualifier from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Qualifier. /// public static Aas.Qualifier QualifierFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Qualifier? result = ( DeserializeImplementation.QualifierFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17716,22 +20242,16 @@ public static Aas.Qualifier QualifierFrom( /// Deserialize an instance of AssetAdministrationShell from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of AssetAdministrationShell. /// public static Aas.AssetAdministrationShell AssetAdministrationShellFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.AssetAdministrationShell? result = ( DeserializeImplementation.AssetAdministrationShellFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17748,22 +20268,16 @@ public static Aas.AssetAdministrationShell AssetAdministrationShellFrom( /// Deserialize an instance of AssetInformation from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of AssetInformation. /// public static Aas.AssetInformation AssetInformationFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.AssetInformation? result = ( DeserializeImplementation.AssetInformationFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17780,22 +20294,16 @@ public static Aas.AssetInformation AssetInformationFrom( /// Deserialize an instance of Resource from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Resource. /// public static Aas.Resource ResourceFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Resource? result = ( DeserializeImplementation.ResourceFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17812,22 +20320,16 @@ public static Aas.Resource ResourceFrom( /// Deserialize an instance of SpecificAssetId from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of SpecificAssetId. /// public static Aas.SpecificAssetId SpecificAssetIdFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.SpecificAssetId? result = ( DeserializeImplementation.SpecificAssetIdFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17844,22 +20346,16 @@ public static Aas.SpecificAssetId SpecificAssetIdFrom( /// Deserialize an instance of Submodel from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Submodel. /// public static Aas.Submodel SubmodelFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Submodel? result = ( DeserializeImplementation.SubmodelFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17876,23 +20372,17 @@ public static Aas.Submodel SubmodelFrom( /// Deserialize an instance of ISubmodelElement from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of ISubmodelElement. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] public static Aas.ISubmodelElement ISubmodelElementFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.ISubmodelElement? result = ( DeserializeImplementation.ISubmodelElementFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17909,23 +20399,17 @@ public static Aas.ISubmodelElement ISubmodelElementFrom( /// Deserialize an instance of IRelationshipElement from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of IRelationshipElement. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] public static Aas.IRelationshipElement IRelationshipElementFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.IRelationshipElement? result = ( DeserializeImplementation.IRelationshipElementFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17942,22 +20426,16 @@ public static Aas.IRelationshipElement IRelationshipElementFrom( /// Deserialize an instance of RelationshipElement from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of RelationshipElement. /// public static Aas.RelationshipElement RelationshipElementFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.RelationshipElement? result = ( DeserializeImplementation.RelationshipElementFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -17974,22 +20452,16 @@ public static Aas.RelationshipElement RelationshipElementFrom( /// Deserialize an instance of SubmodelElementList from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of SubmodelElementList. /// public static Aas.SubmodelElementList SubmodelElementListFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.SubmodelElementList? result = ( DeserializeImplementation.SubmodelElementListFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18006,22 +20478,16 @@ public static Aas.SubmodelElementList SubmodelElementListFrom( /// Deserialize an instance of SubmodelElementCollection from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of SubmodelElementCollection. /// public static Aas.SubmodelElementCollection SubmodelElementCollectionFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.SubmodelElementCollection? result = ( DeserializeImplementation.SubmodelElementCollectionFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18038,23 +20504,17 @@ public static Aas.SubmodelElementCollection SubmodelElementCollectionFrom( /// Deserialize an instance of IDataElement from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of IDataElement. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] public static Aas.IDataElement IDataElementFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.IDataElement? result = ( DeserializeImplementation.IDataElementFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18071,22 +20531,16 @@ public static Aas.IDataElement IDataElementFrom( /// Deserialize an instance of Property from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Property. /// public static Aas.Property PropertyFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Property? result = ( DeserializeImplementation.PropertyFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18103,22 +20557,16 @@ public static Aas.Property PropertyFrom( /// Deserialize an instance of MultiLanguageProperty from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of MultiLanguageProperty. /// public static Aas.MultiLanguageProperty MultiLanguagePropertyFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.MultiLanguageProperty? result = ( DeserializeImplementation.MultiLanguagePropertyFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18135,22 +20583,16 @@ public static Aas.MultiLanguageProperty MultiLanguagePropertyFrom( /// Deserialize an instance of Range from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Range. /// public static Aas.Range RangeFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Range? result = ( DeserializeImplementation.RangeFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18167,22 +20609,16 @@ public static Aas.Range RangeFrom( /// Deserialize an instance of ReferenceElement from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of ReferenceElement. /// public static Aas.ReferenceElement ReferenceElementFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.ReferenceElement? result = ( DeserializeImplementation.ReferenceElementFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18199,22 +20635,16 @@ public static Aas.ReferenceElement ReferenceElementFrom( /// Deserialize an instance of Blob from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Blob. /// public static Aas.Blob BlobFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Blob? result = ( DeserializeImplementation.BlobFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18231,22 +20661,16 @@ public static Aas.Blob BlobFrom( /// Deserialize an instance of File from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of File. /// public static Aas.File FileFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.File? result = ( DeserializeImplementation.FileFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18263,22 +20687,16 @@ public static Aas.File FileFrom( /// Deserialize an instance of AnnotatedRelationshipElement from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of AnnotatedRelationshipElement. /// public static Aas.AnnotatedRelationshipElement AnnotatedRelationshipElementFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.AnnotatedRelationshipElement? result = ( DeserializeImplementation.AnnotatedRelationshipElementFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18295,22 +20713,16 @@ public static Aas.AnnotatedRelationshipElement AnnotatedRelationshipElementFrom( /// Deserialize an instance of Entity from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Entity. /// public static Aas.Entity EntityFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Entity? result = ( DeserializeImplementation.EntityFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18327,22 +20739,16 @@ public static Aas.Entity EntityFrom( /// Deserialize an instance of EventPayload from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of EventPayload. /// public static Aas.EventPayload EventPayloadFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.EventPayload? result = ( DeserializeImplementation.EventPayloadFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18359,23 +20765,17 @@ public static Aas.EventPayload EventPayloadFrom( /// Deserialize an instance of IEventElement from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of IEventElement. /// [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] public static Aas.IEventElement IEventElementFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.IEventElement? result = ( DeserializeImplementation.IEventElementFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18392,22 +20792,16 @@ public static Aas.IEventElement IEventElementFrom( /// Deserialize an instance of BasicEventElement from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of BasicEventElement. /// public static Aas.BasicEventElement BasicEventElementFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.BasicEventElement? result = ( DeserializeImplementation.BasicEventElementFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18424,22 +20818,16 @@ public static Aas.BasicEventElement BasicEventElementFrom( /// Deserialize an instance of Operation from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Operation. /// public static Aas.Operation OperationFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Operation? result = ( DeserializeImplementation.OperationFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18456,22 +20844,16 @@ public static Aas.Operation OperationFrom( /// Deserialize an instance of OperationVariable from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of OperationVariable. /// public static Aas.OperationVariable OperationVariableFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.OperationVariable? result = ( DeserializeImplementation.OperationVariableFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18488,22 +20870,16 @@ public static Aas.OperationVariable OperationVariableFrom( /// Deserialize an instance of Capability from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Capability. /// public static Aas.Capability CapabilityFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Capability? result = ( DeserializeImplementation.CapabilityFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18520,22 +20896,16 @@ public static Aas.Capability CapabilityFrom( /// Deserialize an instance of ConceptDescription from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of ConceptDescription. /// public static Aas.ConceptDescription ConceptDescriptionFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.ConceptDescription? result = ( DeserializeImplementation.ConceptDescriptionFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18552,22 +20922,16 @@ public static Aas.ConceptDescription ConceptDescriptionFrom( /// Deserialize an instance of Reference from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Reference. /// public static Aas.Reference ReferenceFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Reference? result = ( DeserializeImplementation.ReferenceFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18584,22 +20948,16 @@ public static Aas.Reference ReferenceFrom( /// Deserialize an instance of Key from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of Key. /// public static Aas.Key KeyFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.Key? result = ( DeserializeImplementation.KeyFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18616,22 +20974,16 @@ public static Aas.Key KeyFrom( /// Deserialize an instance of LangString from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML /// representation of LangString. /// public static Aas.LangString LangStringFrom( - Xml.XmlReader reader, - string? ns = null) + Xml.XmlReader reader) { Aas.LangString? result = ( DeserializeImplementation.LangStringFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18645,25 +20997,98 @@ public static Aas.LangString LangStringFrom( } /// - /// Deserialize an instance of LangStringSet from . + /// Deserialize an instance of Environment from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML - /// representation of LangStringSet. + /// representation of Environment. /// - public static Aas.LangStringSet LangStringSetFrom( - Xml.XmlReader reader, - string? ns = null) + public static Aas.Environment EnvironmentFrom( + Xml.XmlReader reader) + { + Aas.Environment? result = ( + DeserializeImplementation.EnvironmentFromElement( + reader, + out Reporting.Error? error)); + if (error != null) + { + throw new Xmlization.Exception( + Reporting.GenerateRelativeXPath(error.PathSegments), + error.Cause); + } + return result + ?? throw new System.InvalidOperationException( + "Unexpected output null when error is null"); + } + + /// + /// Deserialize an instance of IDataSpecificationContent from . + /// + /// Initialized XML reader with cursor set to the element + /// + /// Thrown when the element is not a valid XML + /// representation of IDataSpecificationContent. + /// + [CodeAnalysis.SuppressMessage("ReSharper", "InconsistentNaming")] + public static Aas.IDataSpecificationContent IDataSpecificationContentFrom( + Xml.XmlReader reader) + { + Aas.IDataSpecificationContent? result = ( + DeserializeImplementation.IDataSpecificationContentFromElement( + reader, + out Reporting.Error? error)); + if (error != null) + { + throw new Xmlization.Exception( + Reporting.GenerateRelativeXPath(error.PathSegments), + error.Cause); + } + return result + ?? throw new System.InvalidOperationException( + "Unexpected output null when error is null"); + } + + /// + /// Deserialize an instance of EmbeddedDataSpecification from . + /// + /// Initialized XML reader with cursor set to the element + /// + /// Thrown when the element is not a valid XML + /// representation of EmbeddedDataSpecification. + /// + public static Aas.EmbeddedDataSpecification EmbeddedDataSpecificationFrom( + Xml.XmlReader reader) + { + Aas.EmbeddedDataSpecification? result = ( + DeserializeImplementation.EmbeddedDataSpecificationFromElement( + reader, + out Reporting.Error? error)); + if (error != null) + { + throw new Xmlization.Exception( + Reporting.GenerateRelativeXPath(error.PathSegments), + error.Cause); + } + return result + ?? throw new System.InvalidOperationException( + "Unexpected output null when error is null"); + } + + /// + /// Deserialize an instance of ValueReferencePair from . + /// + /// Initialized XML reader with cursor set to the element + /// + /// Thrown when the element is not a valid XML + /// representation of ValueReferencePair. + /// + public static Aas.ValueReferencePair ValueReferencePairFrom( + Xml.XmlReader reader) { - Aas.LangStringSet? result = ( - DeserializeImplementation.LangStringSetFromElement( + Aas.ValueReferencePair? result = ( + DeserializeImplementation.ValueReferencePairFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18677,25 +21102,19 @@ public static Aas.LangStringSet LangStringSetFrom( } /// - /// Deserialize an instance of DataSpecificationContent from . + /// Deserialize an instance of ValueList from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML - /// representation of DataSpecificationContent. + /// representation of ValueList. /// - public static Aas.DataSpecificationContent DataSpecificationContentFrom( - Xml.XmlReader reader, - string? ns = null) + public static Aas.ValueList ValueListFrom( + Xml.XmlReader reader) { - Aas.DataSpecificationContent? result = ( - DeserializeImplementation.DataSpecificationContentFromElement( + Aas.ValueList? result = ( + DeserializeImplementation.ValueListFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18709,25 +21128,19 @@ public static Aas.DataSpecificationContent DataSpecificationContentFrom( } /// - /// Deserialize an instance of DataSpecification from . + /// Deserialize an instance of DataSpecificationIec61360 from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML - /// representation of DataSpecification. + /// representation of DataSpecificationIec61360. /// - public static Aas.DataSpecification DataSpecificationFrom( - Xml.XmlReader reader, - string? ns = null) + public static Aas.DataSpecificationIec61360 DataSpecificationIec61360From( + Xml.XmlReader reader) { - Aas.DataSpecification? result = ( - DeserializeImplementation.DataSpecificationFromElement( + Aas.DataSpecificationIec61360? result = ( + DeserializeImplementation.DataSpecificationIec61360FromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18741,25 +21154,19 @@ public static Aas.DataSpecification DataSpecificationFrom( } /// - /// Deserialize an instance of Environment from . + /// Deserialize an instance of DataSpecificationPhysicalUnit from . /// /// Initialized XML reader with cursor set to the element - /// - /// The expected namespace that the XML elements live in. - /// If not specified, assume the element names as-are instead of the local names. - /// /// /// Thrown when the element is not a valid XML - /// representation of Environment. + /// representation of DataSpecificationPhysicalUnit. /// - public static Aas.Environment EnvironmentFrom( - Xml.XmlReader reader, - string? ns = null) + public static Aas.DataSpecificationPhysicalUnit DataSpecificationPhysicalUnitFrom( + Xml.XmlReader reader) { - Aas.Environment? result = ( - DeserializeImplementation.EnvironmentFromElement( + Aas.DataSpecificationPhysicalUnit? result = ( + DeserializeImplementation.DataSpecificationPhysicalUnitFromElement( reader, - ns, out Reporting.Error? error)); if (error != null) { @@ -18777,16 +21184,173 @@ public static Aas.Environment EnvironmentFrom( /// Serialize recursively the instances as XML elements. /// internal class VisitorWithWriter - : Visitation.AbstractVisitorWithContext + : Visitation.AbstractVisitorWithContext { private void ExtensionToSequence( Extension that, - WrappedXmlWriter writer) + Xml.XmlWriter writer) + { + if (that.SemanticId != null) + { + writer.WriteStartElement( + "semanticId", + NS); + + this.ReferenceToSequence( + that.SemanticId, + writer); + + writer.WriteEndElement(); + } + + if (that.SupplementalSemanticIds != null) + { + writer.WriteStartElement( + "supplementalSemanticIds", + NS); + + foreach (var item in that.SupplementalSemanticIds) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + } + + writer.WriteStartElement( + "name", + NS); + + writer.WriteValue( + that.Name); + + writer.WriteEndElement(); + + if (that.ValueType != null) + { + writer.WriteStartElement( + "valueType", + NS); + + string? textValueType = Stringification.ToString( + that.ValueType); + writer.WriteValue( + textValueType + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration DataTypeDefXsd: " + + that.ValueType.ToString())); + + writer.WriteEndElement(); + } + + if (that.Value != null) + { + writer.WriteStartElement( + "value", + NS); + + writer.WriteValue( + that.Value); + + writer.WriteEndElement(); + } + + if (that.RefersTo != null) + { + writer.WriteStartElement( + "refersTo", + NS); + + this.ReferenceToSequence( + that.RefersTo, + writer); + + writer.WriteEndElement(); + } + } // private void ExtensionToSequence + + public override void Visit( + Aas.Extension that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "extension", + NS); + this.ExtensionToSequence( + that, + writer); + writer.WriteEndElement(); + } + + private void AdministrativeInformationToSequence( + AdministrativeInformation that, + Xml.XmlWriter writer) + { + if (that.EmbeddedDataSpecifications != null) + { + writer.WriteStartElement( + "embeddedDataSpecifications", + NS); + + foreach (var item in that.EmbeddedDataSpecifications) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + } + + if (that.Version != null) + { + writer.WriteStartElement( + "version", + NS); + + writer.WriteValue( + that.Version); + + writer.WriteEndElement(); + } + + if (that.Revision != null) + { + writer.WriteStartElement( + "revision", + NS); + + writer.WriteValue( + that.Revision); + + writer.WriteEndElement(); + } + } // private void AdministrativeInformationToSequence + + public override void Visit( + Aas.AdministrativeInformation that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "administrativeInformation", + NS); + this.AdministrativeInformationToSequence( + that, + writer); + writer.WriteEndElement(); + } + + private void QualifierToSequence( + Qualifier that, + Xml.XmlWriter writer) { if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -18795,12 +21359,152 @@ private void ExtensionToSequence( writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null) + if (that.SupplementalSemanticIds != null) + { + writer.WriteStartElement( + "supplementalSemanticIds", + NS); + + foreach (var item in that.SupplementalSemanticIds) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + } + + if (that.Kind != null) + { + writer.WriteStartElement( + "kind", + NS); + + string? textKind = Stringification.ToString( + that.Kind); + writer.WriteValue( + textKind + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration QualifierKind: " + + that.Kind.ToString())); + + writer.WriteEndElement(); + } + + writer.WriteStartElement( + "type", + NS); + + writer.WriteValue( + that.Type); + + writer.WriteEndElement(); + + writer.WriteStartElement( + "valueType", + NS); + + string? textValueType = Stringification.ToString( + that.ValueType); + writer.WriteValue( + textValueType + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration DataTypeDefXsd: " + + that.ValueType.ToString())); + + writer.WriteEndElement(); + + if (that.Value != null) + { + writer.WriteStartElement( + "value", + NS); + + writer.WriteValue( + that.Value); + + writer.WriteEndElement(); + } + + if (that.ValueId != null) + { + writer.WriteStartElement( + "valueId", + NS); + + this.ReferenceToSequence( + that.ValueId, + writer); + + writer.WriteEndElement(); + } + } // private void QualifierToSequence + + public override void Visit( + Aas.Qualifier that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "qualifier", + NS); + this.QualifierToSequence( + that, + writer); + writer.WriteEndElement(); + } + + private void AssetAdministrationShellToSequence( + AssetAdministrationShell that, + Xml.XmlWriter writer) + { + if (that.Extensions != null) + { + writer.WriteStartElement( + "extensions", + NS); + + foreach (var item in that.Extensions) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + } + + if (that.Category != null) + { + writer.WriteStartElement( + "category", + NS); + + writer.WriteValue( + that.Category); + + writer.WriteEndElement(); + } + + if (that.IdShort != null) + { + writer.WriteStartElement( + "idShort", + NS); + + writer.WriteValue( + that.IdShort); + + writer.WriteEndElement(); + } + + if (that.DisplayName != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "displayName", + NS); - foreach (var item in that.SupplementalSemanticIds) + foreach (var item in that.DisplayName) { this.Visit( item, @@ -18810,76 +21514,63 @@ private void ExtensionToSequence( writer.WriteEndElement(); } - writer.WriteStartElement( - "name"); - - writer.WriteValue( - that.Name); - - writer.WriteEndElement(); - - if (that.ValueType != null) + if (that.Description != null) { writer.WriteStartElement( - "valueType"); + "description", + NS); - string? textValueType = Stringification.ToString( - that.ValueType); - writer.WriteValue( - textValueType - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration DataTypeDefXsd: " + - that.ValueType.ToString())); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } - if (that.Value != null) + if (that.Checksum != null) { writer.WriteStartElement( - "value"); + "checksum", + NS); writer.WriteValue( - that.Value); + that.Checksum); writer.WriteEndElement(); } - if (that.RefersTo != null) + if (that.Administration != null) { writer.WriteStartElement( - "refersTo"); + "administration", + NS); - this.ReferenceToSequence( - that.RefersTo, + this.AdministrativeInformationToSequence( + that.Administration, writer); writer.WriteEndElement(); } - } // private void ExtensionToSequence - public override void Visit( - Aas.Extension that, - WrappedXmlWriter writer) - { writer.WriteStartElement( - "extension"); - this.ExtensionToSequence( - that, - writer); + "id", + NS); + + writer.WriteValue( + that.Id); + writer.WriteEndElement(); - } - private void AdministrativeInformationToSequence( - AdministrativeInformation that, - WrappedXmlWriter writer) - { - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -18889,63 +21580,97 @@ private void AdministrativeInformationToSequence( writer.WriteEndElement(); } - if (that.Version != null) + if (that.DerivedFrom != null) { writer.WriteStartElement( - "version"); + "derivedFrom", + NS); - writer.WriteValue( - that.Version); + this.ReferenceToSequence( + that.DerivedFrom, + writer); writer.WriteEndElement(); } - if (that.Revision != null) + writer.WriteStartElement( + "assetInformation", + NS); + + this.AssetInformationToSequence( + that.AssetInformation, + writer); + + writer.WriteEndElement(); + + if (that.Submodels != null) { writer.WriteStartElement( - "revision"); + "submodels", + NS); - writer.WriteValue( - that.Revision); + foreach (var item in that.Submodels) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } - } // private void AdministrativeInformationToSequence + } // private void AssetAdministrationShellToSequence public override void Visit( - Aas.AdministrativeInformation that, - WrappedXmlWriter writer) + Aas.AssetAdministrationShell that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "administrativeInformation"); - this.AdministrativeInformationToSequence( + "assetAdministrationShell", + NS); + this.AssetAdministrationShellToSequence( that, writer); writer.WriteEndElement(); } - private void QualifierToSequence( - Qualifier that, - WrappedXmlWriter writer) + private void AssetInformationToSequence( + AssetInformation that, + Xml.XmlWriter writer) { - if (that.SemanticId != null) + writer.WriteStartElement( + "assetKind", + NS); + + string? textAssetKind = Stringification.ToString( + that.AssetKind); + writer.WriteValue( + textAssetKind + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration AssetKind: " + + that.AssetKind.ToString())); + + writer.WriteEndElement(); + + if (that.GlobalAssetId != null) { writer.WriteStartElement( - "semanticId"); + "globalAssetId", + NS); this.ReferenceToSequence( - that.SemanticId, + that.GlobalAssetId, writer); writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null) + if (that.SpecificAssetIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "specificAssetIds", + NS); - foreach (var item in that.SupplementalSemanticIds) + foreach (var item in that.SpecificAssetIds) { this.Visit( item, @@ -18955,87 +21680,156 @@ private void QualifierToSequence( writer.WriteEndElement(); } - if (that.Kind != null) + if (that.DefaultThumbnail != null) { writer.WriteStartElement( - "kind"); + "defaultThumbnail", + NS); - string? textKind = Stringification.ToString( - that.Kind); - writer.WriteValue( - textKind - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration QualifierKind: " + - that.Kind.ToString())); + this.ResourceToSequence( + that.DefaultThumbnail, + writer); writer.WriteEndElement(); } + } // private void AssetInformationToSequence + public override void Visit( + Aas.AssetInformation that, + Xml.XmlWriter writer) + { writer.WriteStartElement( - "type"); - - writer.WriteValue( - that.Type); - + "assetInformation", + NS); + this.AssetInformationToSequence( + that, + writer); writer.WriteEndElement(); + } + private void ResourceToSequence( + Resource that, + Xml.XmlWriter writer) + { writer.WriteStartElement( - "valueType"); + "path", + NS); - string? textValueType = Stringification.ToString( - that.ValueType); writer.WriteValue( - textValueType - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration DataTypeDefXsd: " + - that.ValueType.ToString())); + that.Path); writer.WriteEndElement(); - if (that.Value != null) + if (that.ContentType != null) { writer.WriteStartElement( - "value"); + "contentType", + NS); writer.WriteValue( - that.Value); + that.ContentType); writer.WriteEndElement(); } + } // private void ResourceToSequence - if (that.ValueId != null) + public override void Visit( + Aas.Resource that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "resource", + NS); + this.ResourceToSequence( + that, + writer); + writer.WriteEndElement(); + } + + private void SpecificAssetIdToSequence( + SpecificAssetId that, + Xml.XmlWriter writer) + { + if (that.SemanticId != null) { writer.WriteStartElement( - "valueId"); + "semanticId", + NS); this.ReferenceToSequence( - that.ValueId, + that.SemanticId, writer); writer.WriteEndElement(); } - } // private void QualifierToSequence + + if (that.SupplementalSemanticIds != null) + { + writer.WriteStartElement( + "supplementalSemanticIds", + NS); + + foreach (var item in that.SupplementalSemanticIds) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + } + + writer.WriteStartElement( + "name", + NS); + + writer.WriteValue( + that.Name); + + writer.WriteEndElement(); + + writer.WriteStartElement( + "value", + NS); + + writer.WriteValue( + that.Value); + + writer.WriteEndElement(); + + writer.WriteStartElement( + "externalSubjectId", + NS); + + this.ReferenceToSequence( + that.ExternalSubjectId, + writer); + + writer.WriteEndElement(); + } // private void SpecificAssetIdToSequence public override void Visit( - Aas.Qualifier that, - WrappedXmlWriter writer) + Aas.SpecificAssetId that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "qualifier"); - this.QualifierToSequence( + "specificAssetId", + NS); + this.SpecificAssetIdToSequence( that, writer); writer.WriteEndElement(); } - private void AssetAdministrationShellToSequence( - AssetAdministrationShell that, - WrappedXmlWriter writer) + private void SubmodelToSequence( + Submodel that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -19050,7 +21844,8 @@ private void AssetAdministrationShellToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -19061,7 +21856,8 @@ private void AssetAdministrationShellToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -19072,11 +21868,15 @@ private void AssetAdministrationShellToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -19084,11 +21884,15 @@ private void AssetAdministrationShellToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -19096,7 +21900,8 @@ private void AssetAdministrationShellToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -19107,7 +21912,8 @@ private void AssetAdministrationShellToSequence( if (that.Administration != null) { writer.WriteStartElement( - "administration"); + "administration", + NS); this.AdministrativeInformationToSequence( that.Administration, @@ -19117,19 +21923,67 @@ private void AssetAdministrationShellToSequence( } writer.WriteStartElement( - "id"); + "id", + NS); writer.WriteValue( that.Id); - writer.WriteEndElement(); + writer.WriteEndElement(); + + if (that.Kind != null) + { + writer.WriteStartElement( + "kind", + NS); + + string? textKind = Stringification.ToString( + that.Kind); + writer.WriteValue( + textKind + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration ModelingKind: " + + that.Kind.ToString())); + + writer.WriteEndElement(); + } + + if (that.SemanticId != null) + { + writer.WriteStartElement( + "semanticId", + NS); + + this.ReferenceToSequence( + that.SemanticId, + writer); + + writer.WriteEndElement(); + } + + if (that.SupplementalSemanticIds != null) + { + writer.WriteStartElement( + "supplementalSemanticIds", + NS); + + foreach (var item in that.SupplementalSemanticIds) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + } - if (that.DataSpecifications != null) + if (that.Qualifiers != null) { writer.WriteStartElement( - "dataSpecifications"); + "qualifiers", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.Qualifiers) { this.Visit( item, @@ -19139,33 +21993,29 @@ private void AssetAdministrationShellToSequence( writer.WriteEndElement(); } - if (that.DerivedFrom != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "derivedFrom"); + "embeddedDataSpecifications", + NS); - this.ReferenceToSequence( - that.DerivedFrom, - writer); + foreach (var item in that.EmbeddedDataSpecifications) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } - writer.WriteStartElement( - "assetInformation"); - - this.AssetInformationToSequence( - that.AssetInformation, - writer); - - writer.WriteEndElement(); - - if (that.Submodels != null) + if (that.SubmodelElements != null) { writer.WriteStartElement( - "submodels"); + "submodelElements", + NS); - foreach (var item in that.Submodels) + foreach (var item in that.SubmodelElements) { this.Visit( item, @@ -19174,55 +22024,72 @@ private void AssetAdministrationShellToSequence( writer.WriteEndElement(); } - } // private void AssetAdministrationShellToSequence + } // private void SubmodelToSequence public override void Visit( - Aas.AssetAdministrationShell that, - WrappedXmlWriter writer) + Aas.Submodel that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "assetAdministrationShell"); - this.AssetAdministrationShellToSequence( + "submodel", + NS); + this.SubmodelToSequence( that, writer); writer.WriteEndElement(); } - private void AssetInformationToSequence( - AssetInformation that, - WrappedXmlWriter writer) + private void RelationshipElementToSequence( + RelationshipElement that, + Xml.XmlWriter writer) { - writer.WriteStartElement( - "assetKind"); + if (that.Extensions != null) + { + writer.WriteStartElement( + "extensions", + NS); - string? textAssetKind = Stringification.ToString( - that.AssetKind); - writer.WriteValue( - textAssetKind - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration AssetKind: " + - that.AssetKind.ToString())); + foreach (var item in that.Extensions) + { + this.Visit( + item, + writer); + } - writer.WriteEndElement(); + writer.WriteEndElement(); + } - if (that.GlobalAssetId != null) + if (that.Category != null) { writer.WriteStartElement( - "globalAssetId"); + "category", + NS); - this.ReferenceToSequence( - that.GlobalAssetId, - writer); + writer.WriteValue( + that.Category); writer.WriteEndElement(); } - if (that.SpecificAssetIds != null) + if (that.IdShort != null) { writer.WriteStartElement( - "specificAssetIds"); + "idShort", + NS); - foreach (var item in that.SpecificAssetIds) + writer.WriteValue( + that.IdShort); + + writer.WriteEndElement(); + } + + if (that.DisplayName != null) + { + writer.WriteStartElement( + "displayName", + NS); + + foreach (var item in that.DisplayName) { this.Visit( item, @@ -19232,75 +22099,56 @@ private void AssetInformationToSequence( writer.WriteEndElement(); } - if (that.DefaultThumbnail != null) + if (that.Description != null) { writer.WriteStartElement( - "defaultThumbnail"); + "description", + NS); - this.ResourceToSequence( - that.DefaultThumbnail, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } - } // private void AssetInformationToSequence - - public override void Visit( - Aas.AssetInformation that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "assetInformation"); - this.AssetInformationToSequence( - that, - writer); - writer.WriteEndElement(); - } - private void ResourceToSequence( - Resource that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "path"); + if (that.Checksum != null) + { + writer.WriteStartElement( + "checksum", + NS); - writer.WriteValue( - that.Path); + writer.WriteValue( + that.Checksum); - writer.WriteEndElement(); + writer.WriteEndElement(); + } - if (that.ContentType != null) + if (that.Kind != null) { writer.WriteStartElement( - "contentType"); + "kind", + NS); + string? textKind = Stringification.ToString( + that.Kind); writer.WriteValue( - that.ContentType); + textKind + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration ModelingKind: " + + that.Kind.ToString())); writer.WriteEndElement(); } - } // private void ResourceToSequence - - public override void Visit( - Aas.Resource that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "resource"); - this.ResourceToSequence( - that, - writer); - writer.WriteEndElement(); - } - private void SpecificAssetIdToSequence( - SpecificAssetId that, - WrappedXmlWriter writer) - { if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -19312,7 +22160,8 @@ private void SpecificAssetIdToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -19324,52 +22173,81 @@ private void SpecificAssetIdToSequence( writer.WriteEndElement(); } - writer.WriteStartElement( - "name"); + if (that.Qualifiers != null) + { + writer.WriteStartElement( + "qualifiers", + NS); - writer.WriteValue( - that.Name); + foreach (var item in that.Qualifiers) + { + this.Visit( + item, + writer); + } - writer.WriteEndElement(); + writer.WriteEndElement(); + } + + if (that.EmbeddedDataSpecifications != null) + { + writer.WriteStartElement( + "embeddedDataSpecifications", + NS); + + foreach (var item in that.EmbeddedDataSpecifications) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + } writer.WriteStartElement( - "value"); + "first", + NS); - writer.WriteValue( - that.Value); + this.ReferenceToSequence( + that.First, + writer); writer.WriteEndElement(); writer.WriteStartElement( - "externalSubjectId"); + "second", + NS); this.ReferenceToSequence( - that.ExternalSubjectId, + that.Second, writer); writer.WriteEndElement(); - } // private void SpecificAssetIdToSequence + } // private void RelationshipElementToSequence public override void Visit( - Aas.SpecificAssetId that, - WrappedXmlWriter writer) + Aas.RelationshipElement that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "specificAssetId"); - this.SpecificAssetIdToSequence( + "relationshipElement", + NS); + this.RelationshipElementToSequence( that, writer); writer.WriteEndElement(); } - private void SubmodelToSequence( - Submodel that, - WrappedXmlWriter writer) + private void SubmodelElementListToSequence( + SubmodelElementList that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -19384,7 +22262,8 @@ private void SubmodelToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -19395,7 +22274,8 @@ private void SubmodelToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -19406,11 +22286,15 @@ private void SubmodelToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -19418,11 +22302,15 @@ private void SubmodelToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -19430,7 +22318,8 @@ private void SubmodelToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -19438,30 +22327,11 @@ private void SubmodelToSequence( writer.WriteEndElement(); } - if (that.Administration != null) - { - writer.WriteStartElement( - "administration"); - - this.AdministrativeInformationToSequence( - that.Administration, - writer); - - writer.WriteEndElement(); - } - - writer.WriteStartElement( - "id"); - - writer.WriteValue( - that.Id); - - writer.WriteEndElement(); - if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -19477,7 +22347,8 @@ private void SubmodelToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -19489,7 +22360,8 @@ private void SubmodelToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -19504,7 +22376,8 @@ private void SubmodelToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -19516,57 +22389,117 @@ private void SubmodelToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) + { + writer.WriteStartElement( + "embeddedDataSpecifications", + NS); + + foreach (var item in that.EmbeddedDataSpecifications) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + } + + if (that.OrderRelevant.HasValue) + { + writer.WriteStartElement( + "orderRelevant", + NS); + + writer.WriteValue( + that.OrderRelevant.Value); + + writer.WriteEndElement(); + } + + if (that.Value != null) { writer.WriteStartElement( - "dataSpecifications"); + "value", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.Value) { this.Visit( item, writer); } - writer.WriteEndElement(); - } + writer.WriteEndElement(); + } + + if (that.SemanticIdListElement != null) + { + writer.WriteStartElement( + "semanticIdListElement", + NS); + + this.ReferenceToSequence( + that.SemanticIdListElement, + writer); + + writer.WriteEndElement(); + } + + writer.WriteStartElement( + "typeValueListElement", + NS); + + string? textTypeValueListElement = Stringification.ToString( + that.TypeValueListElement); + writer.WriteValue( + textTypeValueListElement + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration AasSubmodelElements: " + + that.TypeValueListElement.ToString())); + + writer.WriteEndElement(); - if (that.SubmodelElements != null) + if (that.ValueTypeListElement != null) { writer.WriteStartElement( - "submodelElements"); + "valueTypeListElement", + NS); - foreach (var item in that.SubmodelElements) - { - this.Visit( - item, - writer); - } + string? textValueTypeListElement = Stringification.ToString( + that.ValueTypeListElement); + writer.WriteValue( + textValueTypeListElement + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration DataTypeDefXsd: " + + that.ValueTypeListElement.ToString())); writer.WriteEndElement(); } - } // private void SubmodelToSequence + } // private void SubmodelElementListToSequence public override void Visit( - Aas.Submodel that, - WrappedXmlWriter writer) + Aas.SubmodelElementList that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "submodel"); - this.SubmodelToSequence( + "submodelElementList", + NS); + this.SubmodelElementListToSequence( that, writer); writer.WriteEndElement(); } - private void RelationshipElementToSequence( - RelationshipElement that, - WrappedXmlWriter writer) + private void SubmodelElementCollectionToSequence( + SubmodelElementCollection that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -19581,7 +22514,8 @@ private void RelationshipElementToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -19592,7 +22526,8 @@ private void RelationshipElementToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -19603,11 +22538,15 @@ private void RelationshipElementToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -19615,11 +22554,15 @@ private void RelationshipElementToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -19627,7 +22570,8 @@ private void RelationshipElementToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -19638,7 +22582,8 @@ private void RelationshipElementToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -19654,7 +22599,8 @@ private void RelationshipElementToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -19666,7 +22612,8 @@ private void RelationshipElementToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -19681,7 +22628,8 @@ private void RelationshipElementToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -19693,12 +22641,13 @@ private void RelationshipElementToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -19708,45 +22657,45 @@ private void RelationshipElementToSequence( writer.WriteEndElement(); } - writer.WriteStartElement( - "first"); - - this.ReferenceToSequence( - that.First, - writer); - - writer.WriteEndElement(); - - writer.WriteStartElement( - "second"); + if (that.Value != null) + { + writer.WriteStartElement( + "value", + NS); - this.ReferenceToSequence( - that.Second, - writer); + foreach (var item in that.Value) + { + this.Visit( + item, + writer); + } - writer.WriteEndElement(); - } // private void RelationshipElementToSequence + writer.WriteEndElement(); + } + } // private void SubmodelElementCollectionToSequence public override void Visit( - Aas.RelationshipElement that, - WrappedXmlWriter writer) + Aas.SubmodelElementCollection that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "relationshipElement"); - this.RelationshipElementToSequence( + "submodelElementCollection", + NS); + this.SubmodelElementCollectionToSequence( that, writer); writer.WriteEndElement(); } - private void SubmodelElementListToSequence( - SubmodelElementList that, - WrappedXmlWriter writer) + private void PropertyToSequence( + Property that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -19761,7 +22710,8 @@ private void SubmodelElementListToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -19772,7 +22722,8 @@ private void SubmodelElementListToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -19783,11 +22734,15 @@ private void SubmodelElementListToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -19795,11 +22750,15 @@ private void SubmodelElementListToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -19807,7 +22766,8 @@ private void SubmodelElementListToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -19818,7 +22778,8 @@ private void SubmodelElementListToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -19834,7 +22795,8 @@ private void SubmodelElementListToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -19846,7 +22808,8 @@ private void SubmodelElementListToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -19861,7 +22824,8 @@ private void SubmodelElementListToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -19873,12 +22837,13 @@ private void SubmodelElementListToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -19888,94 +22853,68 @@ private void SubmodelElementListToSequence( writer.WriteEndElement(); } - if (that.OrderRelevant.HasValue) - { - writer.WriteStartElement( - "orderRelevant"); + writer.WriteStartElement( + "valueType", + NS); - writer.WriteValue( - that.OrderRelevant.Value); + string? textValueType = Stringification.ToString( + that.ValueType); + writer.WriteValue( + textValueType + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration DataTypeDefXsd: " + + that.ValueType.ToString())); - writer.WriteEndElement(); - } + writer.WriteEndElement(); if (that.Value != null) { writer.WriteStartElement( - "value"); + "value", + NS); - foreach (var item in that.Value) - { - this.Visit( - item, - writer); - } + writer.WriteValue( + that.Value); writer.WriteEndElement(); } - if (that.SemanticIdListElement != null) + if (that.ValueId != null) { writer.WriteStartElement( - "semanticIdListElement"); + "valueId", + NS); this.ReferenceToSequence( - that.SemanticIdListElement, + that.ValueId, writer); writer.WriteEndElement(); } - - writer.WriteStartElement( - "typeValueListElement"); - - string? textTypeValueListElement = Stringification.ToString( - that.TypeValueListElement); - writer.WriteValue( - textTypeValueListElement - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration AasSubmodelElements: " + - that.TypeValueListElement.ToString())); - - writer.WriteEndElement(); - - if (that.ValueTypeListElement != null) - { - writer.WriteStartElement( - "valueTypeListElement"); - - string? textValueTypeListElement = Stringification.ToString( - that.ValueTypeListElement); - writer.WriteValue( - textValueTypeListElement - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration DataTypeDefXsd: " + - that.ValueTypeListElement.ToString())); - - writer.WriteEndElement(); - } - } // private void SubmodelElementListToSequence + } // private void PropertyToSequence public override void Visit( - Aas.SubmodelElementList that, - WrappedXmlWriter writer) + Aas.Property that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "submodelElementList"); - this.SubmodelElementListToSequence( + "property", + NS); + this.PropertyToSequence( that, writer); writer.WriteEndElement(); } - private void SubmodelElementCollectionToSequence( - SubmodelElementCollection that, - WrappedXmlWriter writer) + private void MultiLanguagePropertyToSequence( + MultiLanguageProperty that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -19990,7 +22929,8 @@ private void SubmodelElementCollectionToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -20001,7 +22941,8 @@ private void SubmodelElementCollectionToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -20012,11 +22953,15 @@ private void SubmodelElementCollectionToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20024,11 +22969,15 @@ private void SubmodelElementCollectionToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20036,7 +22985,8 @@ private void SubmodelElementCollectionToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -20047,7 +22997,8 @@ private void SubmodelElementCollectionToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -20063,7 +23014,8 @@ private void SubmodelElementCollectionToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -20075,7 +23027,8 @@ private void SubmodelElementCollectionToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -20090,7 +23043,8 @@ private void SubmodelElementCollectionToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -20102,12 +23056,13 @@ private void SubmodelElementCollectionToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -20120,7 +23075,8 @@ private void SubmodelElementCollectionToSequence( if (that.Value != null) { writer.WriteStartElement( - "value"); + "value", + NS); foreach (var item in that.Value) { @@ -20131,28 +23087,43 @@ private void SubmodelElementCollectionToSequence( writer.WriteEndElement(); } - } // private void SubmodelElementCollectionToSequence + + if (that.ValueId != null) + { + writer.WriteStartElement( + "valueId", + NS); + + this.ReferenceToSequence( + that.ValueId, + writer); + + writer.WriteEndElement(); + } + } // private void MultiLanguagePropertyToSequence public override void Visit( - Aas.SubmodelElementCollection that, - WrappedXmlWriter writer) + Aas.MultiLanguageProperty that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "submodelElementCollection"); - this.SubmodelElementCollectionToSequence( + "multiLanguageProperty", + NS); + this.MultiLanguagePropertyToSequence( that, writer); writer.WriteEndElement(); } - private void PropertyToSequence( - Property that, - WrappedXmlWriter writer) + private void RangeToSequence( + Range that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -20167,7 +23138,8 @@ private void PropertyToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -20178,7 +23150,8 @@ private void PropertyToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -20189,11 +23162,15 @@ private void PropertyToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20201,11 +23178,15 @@ private void PropertyToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20213,7 +23194,8 @@ private void PropertyToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -20224,7 +23206,8 @@ private void PropertyToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -20240,7 +23223,8 @@ private void PropertyToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -20252,7 +23236,8 @@ private void PropertyToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -20267,7 +23252,8 @@ private void PropertyToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -20279,12 +23265,13 @@ private void PropertyToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -20295,7 +23282,8 @@ private void PropertyToSequence( } writer.WriteStartElement( - "valueType"); + "valueType", + NS); string? textValueType = Stringification.ToString( that.ValueType); @@ -20307,50 +23295,53 @@ private void PropertyToSequence( writer.WriteEndElement(); - if (that.Value != null) + if (that.Min != null) { writer.WriteStartElement( - "value"); + "min", + NS); writer.WriteValue( - that.Value); + that.Min); writer.WriteEndElement(); } - if (that.ValueId != null) + if (that.Max != null) { writer.WriteStartElement( - "valueId"); + "max", + NS); - this.ReferenceToSequence( - that.ValueId, - writer); + writer.WriteValue( + that.Max); writer.WriteEndElement(); } - } // private void PropertyToSequence + } // private void RangeToSequence public override void Visit( - Aas.Property that, - WrappedXmlWriter writer) + Aas.Range that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "property"); - this.PropertyToSequence( + "range", + NS); + this.RangeToSequence( that, writer); writer.WriteEndElement(); } - private void MultiLanguagePropertyToSequence( - MultiLanguageProperty that, - WrappedXmlWriter writer) + private void ReferenceElementToSequence( + ReferenceElement that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -20365,7 +23356,8 @@ private void MultiLanguagePropertyToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -20376,7 +23368,8 @@ private void MultiLanguagePropertyToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -20387,11 +23380,15 @@ private void MultiLanguagePropertyToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20399,11 +23396,15 @@ private void MultiLanguagePropertyToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20411,7 +23412,8 @@ private void MultiLanguagePropertyToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -20422,7 +23424,8 @@ private void MultiLanguagePropertyToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -20438,7 +23441,8 @@ private void MultiLanguagePropertyToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -20450,7 +23454,8 @@ private void MultiLanguagePropertyToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -20465,7 +23470,8 @@ private void MultiLanguagePropertyToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -20477,12 +23483,13 @@ private void MultiLanguagePropertyToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -20495,48 +23502,39 @@ private void MultiLanguagePropertyToSequence( if (that.Value != null) { writer.WriteStartElement( - "value"); - - this.LangStringSetToSequence( - that.Value, - writer); - - writer.WriteEndElement(); - } - - if (that.ValueId != null) - { - writer.WriteStartElement( - "valueId"); + "value", + NS); this.ReferenceToSequence( - that.ValueId, + that.Value, writer); writer.WriteEndElement(); } - } // private void MultiLanguagePropertyToSequence + } // private void ReferenceElementToSequence public override void Visit( - Aas.MultiLanguageProperty that, - WrappedXmlWriter writer) + Aas.ReferenceElement that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "multiLanguageProperty"); - this.MultiLanguagePropertyToSequence( + "referenceElement", + NS); + this.ReferenceElementToSequence( that, writer); writer.WriteEndElement(); } - private void RangeToSequence( - Range that, - WrappedXmlWriter writer) + private void BlobToSequence( + Blob that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -20551,7 +23549,8 @@ private void RangeToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -20562,7 +23561,8 @@ private void RangeToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -20573,11 +23573,15 @@ private void RangeToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20585,11 +23589,15 @@ private void RangeToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20597,7 +23605,8 @@ private void RangeToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -20608,7 +23617,8 @@ private void RangeToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -20624,7 +23634,8 @@ private void RangeToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -20636,7 +23647,8 @@ private void RangeToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -20651,7 +23663,8 @@ private void RangeToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -20663,12 +23676,13 @@ private void RangeToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -20678,62 +23692,52 @@ private void RangeToSequence( writer.WriteEndElement(); } - writer.WriteStartElement( - "valueType"); - - string? textValueType = Stringification.ToString( - that.ValueType); - writer.WriteValue( - textValueType - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration DataTypeDefXsd: " + - that.ValueType.ToString())); - - writer.WriteEndElement(); - - if (that.Min != null) + if (that.Value != null) { writer.WriteStartElement( - "min"); + "value", + NS); - writer.WriteValue( - that.Min); + writer.WriteBase64( + that.Value, + 0, + that.Value.Length); writer.WriteEndElement(); } - if (that.Max != null) - { - writer.WriteStartElement( - "max"); + writer.WriteStartElement( + "contentType", + NS); - writer.WriteValue( - that.Max); + writer.WriteValue( + that.ContentType); - writer.WriteEndElement(); - } - } // private void RangeToSequence + writer.WriteEndElement(); + } // private void BlobToSequence public override void Visit( - Aas.Range that, - WrappedXmlWriter writer) + Aas.Blob that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "range"); - this.RangeToSequence( + "blob", + NS); + this.BlobToSequence( that, writer); writer.WriteEndElement(); } - private void ReferenceElementToSequence( - ReferenceElement that, - WrappedXmlWriter writer) + private void FileToSequence( + File that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -20748,7 +23752,8 @@ private void ReferenceElementToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -20759,7 +23764,8 @@ private void ReferenceElementToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -20770,11 +23776,15 @@ private void ReferenceElementToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20782,11 +23792,15 @@ private void ReferenceElementToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20794,7 +23808,8 @@ private void ReferenceElementToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -20805,7 +23820,8 @@ private void ReferenceElementToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -20821,7 +23837,8 @@ private void ReferenceElementToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -20833,7 +23850,8 @@ private void ReferenceElementToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -20848,7 +23866,8 @@ private void ReferenceElementToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -20860,12 +23879,13 @@ private void ReferenceElementToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -20878,36 +23898,47 @@ private void ReferenceElementToSequence( if (that.Value != null) { writer.WriteStartElement( - "value"); + "value", + NS); - this.ReferenceToSequence( - that.Value, - writer); + writer.WriteValue( + that.Value); writer.WriteEndElement(); } - } // private void ReferenceElementToSequence + + writer.WriteStartElement( + "contentType", + NS); + + writer.WriteValue( + that.ContentType); + + writer.WriteEndElement(); + } // private void FileToSequence public override void Visit( - Aas.ReferenceElement that, - WrappedXmlWriter writer) + Aas.File that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "referenceElement"); - this.ReferenceElementToSequence( + "file", + NS); + this.FileToSequence( that, writer); writer.WriteEndElement(); } - private void BlobToSequence( - Blob that, - WrappedXmlWriter writer) + private void AnnotatedRelationshipElementToSequence( + AnnotatedRelationshipElement that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -20922,7 +23953,8 @@ private void BlobToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -20933,7 +23965,8 @@ private void BlobToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -20944,11 +23977,15 @@ private void BlobToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20956,11 +23993,15 @@ private void BlobToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -20968,7 +24009,8 @@ private void BlobToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -20979,7 +24021,8 @@ private void BlobToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -20995,7 +24038,8 @@ private void BlobToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -21007,7 +24051,8 @@ private void BlobToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -21022,7 +24067,8 @@ private void BlobToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -21034,12 +24080,13 @@ private void BlobToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -21049,46 +24096,65 @@ private void BlobToSequence( writer.WriteEndElement(); } - if (that.Value != null) - { - writer.WriteStartElement( - "value"); + writer.WriteStartElement( + "first", + NS); - writer.WriteBase64( - that.Value); + this.ReferenceToSequence( + that.First, + writer); - writer.WriteEndElement(); - } + writer.WriteEndElement(); writer.WriteStartElement( - "contentType"); + "second", + NS); - writer.WriteValue( - that.ContentType); + this.ReferenceToSequence( + that.Second, + writer); writer.WriteEndElement(); - } // private void BlobToSequence + + if (that.Annotations != null) + { + writer.WriteStartElement( + "annotations", + NS); + + foreach (var item in that.Annotations) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + } + } // private void AnnotatedRelationshipElementToSequence public override void Visit( - Aas.Blob that, - WrappedXmlWriter writer) + Aas.AnnotatedRelationshipElement that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "blob"); - this.BlobToSequence( + "annotatedRelationshipElement", + NS); + this.AnnotatedRelationshipElementToSequence( that, writer); writer.WriteEndElement(); } - private void FileToSequence( - File that, - WrappedXmlWriter writer) + private void EntityToSequence( + Entity that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -21103,7 +24169,8 @@ private void FileToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -21114,7 +24181,8 @@ private void FileToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -21125,11 +24193,15 @@ private void FileToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -21137,11 +24209,15 @@ private void FileToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -21149,7 +24225,8 @@ private void FileToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -21160,7 +24237,8 @@ private void FileToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -21176,7 +24254,8 @@ private void FileToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -21188,7 +24267,8 @@ private void FileToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -21203,7 +24283,8 @@ private void FileToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -21215,12 +24296,29 @@ private void FileToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) + { + writer.WriteStartElement( + "embeddedDataSpecifications", + NS); + + foreach (var item in that.EmbeddedDataSpecifications) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + } + + if (that.Statements != null) { writer.WriteStartElement( - "dataSpecifications"); + "statements", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.Statements) { this.Visit( item, @@ -21230,46 +24328,179 @@ private void FileToSequence( writer.WriteEndElement(); } - if (that.Value != null) + writer.WriteStartElement( + "entityType", + NS); + + string? textEntityType = Stringification.ToString( + that.EntityType); + writer.WriteValue( + textEntityType + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration EntityType: " + + that.EntityType.ToString())); + + writer.WriteEndElement(); + + if (that.GlobalAssetId != null) + { + writer.WriteStartElement( + "globalAssetId", + NS); + + this.ReferenceToSequence( + that.GlobalAssetId, + writer); + + writer.WriteEndElement(); + } + + if (that.SpecificAssetId != null) + { + writer.WriteStartElement( + "specificAssetId", + NS); + + this.SpecificAssetIdToSequence( + that.SpecificAssetId, + writer); + + writer.WriteEndElement(); + } + } // private void EntityToSequence + + public override void Visit( + Aas.Entity that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "entity", + NS); + this.EntityToSequence( + that, + writer); + writer.WriteEndElement(); + } + + private void EventPayloadToSequence( + EventPayload that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "source", + NS); + + this.ReferenceToSequence( + that.Source, + writer); + + writer.WriteEndElement(); + + if (that.SourceSemanticId != null) + { + writer.WriteStartElement( + "sourceSemanticId", + NS); + + this.ReferenceToSequence( + that.SourceSemanticId, + writer); + + writer.WriteEndElement(); + } + + writer.WriteStartElement( + "observableReference", + NS); + + this.ReferenceToSequence( + that.ObservableReference, + writer); + + writer.WriteEndElement(); + + if (that.ObservableSemanticId != null) + { + writer.WriteStartElement( + "observableSemanticId", + NS); + + this.ReferenceToSequence( + that.ObservableSemanticId, + writer); + + writer.WriteEndElement(); + } + + if (that.Topic != null) + { + writer.WriteStartElement( + "topic", + NS); + + writer.WriteValue( + that.Topic); + + writer.WriteEndElement(); + } + + if (that.SubjectId != null) { writer.WriteStartElement( - "value"); + "subjectId", + NS); - writer.WriteValue( - that.Value); + this.ReferenceToSequence( + that.SubjectId, + writer); writer.WriteEndElement(); } writer.WriteStartElement( - "contentType"); + "timeStamp", + NS); writer.WriteValue( - that.ContentType); + that.TimeStamp); writer.WriteEndElement(); - } // private void FileToSequence + + if (that.Payload != null) + { + writer.WriteStartElement( + "payload", + NS); + + writer.WriteValue( + that.Payload); + + writer.WriteEndElement(); + } + } // private void EventPayloadToSequence public override void Visit( - Aas.File that, - WrappedXmlWriter writer) + Aas.EventPayload that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "file"); - this.FileToSequence( + "eventPayload", + NS); + this.EventPayloadToSequence( that, writer); writer.WriteEndElement(); } - private void AnnotatedRelationshipElementToSequence( - AnnotatedRelationshipElement that, - WrappedXmlWriter writer) + private void BasicEventElementToSequence( + BasicEventElement that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -21284,7 +24515,8 @@ private void AnnotatedRelationshipElementToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -21295,7 +24527,8 @@ private void AnnotatedRelationshipElementToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -21306,11 +24539,15 @@ private void AnnotatedRelationshipElementToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -21318,11 +24555,15 @@ private void AnnotatedRelationshipElementToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -21330,7 +24571,8 @@ private void AnnotatedRelationshipElementToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -21341,7 +24583,8 @@ private void AnnotatedRelationshipElementToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -21357,7 +24600,8 @@ private void AnnotatedRelationshipElementToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -21369,7 +24613,8 @@ private void AnnotatedRelationshipElementToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -21384,7 +24629,8 @@ private void AnnotatedRelationshipElementToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -21396,12 +24642,13 @@ private void AnnotatedRelationshipElementToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -21412,59 +24659,127 @@ private void AnnotatedRelationshipElementToSequence( } writer.WriteStartElement( - "first"); + "observed", + NS); this.ReferenceToSequence( - that.First, + that.Observed, writer); writer.WriteEndElement(); writer.WriteStartElement( - "second"); + "direction", + NS); - this.ReferenceToSequence( - that.Second, - writer); + string? textDirection = Stringification.ToString( + that.Direction); + writer.WriteValue( + textDirection + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration Direction: " + + that.Direction.ToString())); writer.WriteEndElement(); - if (that.Annotations != null) + writer.WriteStartElement( + "state", + NS); + + string? textState = Stringification.ToString( + that.State); + writer.WriteValue( + textState + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration StateOfEvent: " + + that.State.ToString())); + + writer.WriteEndElement(); + + if (that.MessageTopic != null) { writer.WriteStartElement( - "annotations"); + "messageTopic", + NS); - foreach (var item in that.Annotations) - { - this.Visit( - item, - writer); - } + writer.WriteValue( + that.MessageTopic); writer.WriteEndElement(); } - } // private void AnnotatedRelationshipElementToSequence + + if (that.MessageBroker != null) + { + writer.WriteStartElement( + "messageBroker", + NS); + + this.ReferenceToSequence( + that.MessageBroker, + writer); + + writer.WriteEndElement(); + } + + if (that.LastUpdate != null) + { + writer.WriteStartElement( + "lastUpdate", + NS); + + writer.WriteValue( + that.LastUpdate); + + writer.WriteEndElement(); + } + + if (that.MinInterval != null) + { + writer.WriteStartElement( + "minInterval", + NS); + + writer.WriteValue( + that.MinInterval); + + writer.WriteEndElement(); + } + + if (that.MaxInterval != null) + { + writer.WriteStartElement( + "maxInterval", + NS); + + writer.WriteValue( + that.MaxInterval); + + writer.WriteEndElement(); + } + } // private void BasicEventElementToSequence public override void Visit( - Aas.AnnotatedRelationshipElement that, - WrappedXmlWriter writer) + Aas.BasicEventElement that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "annotatedRelationshipElement"); - this.AnnotatedRelationshipElementToSequence( + "basicEventElement", + NS); + this.BasicEventElementToSequence( that, writer); writer.WriteEndElement(); } - private void EntityToSequence( - Entity that, - WrappedXmlWriter writer) + private void OperationToSequence( + Operation that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -21479,7 +24794,8 @@ private void EntityToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -21490,7 +24806,8 @@ private void EntityToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -21501,11 +24818,15 @@ private void EntityToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -21513,11 +24834,15 @@ private void EntityToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -21525,7 +24850,8 @@ private void EntityToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -21536,7 +24862,8 @@ private void EntityToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -21552,7 +24879,8 @@ private void EntityToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -21564,7 +24892,8 @@ private void EntityToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -21579,7 +24908,8 @@ private void EntityToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -21591,12 +24921,13 @@ private void EntityToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -21606,12 +24937,13 @@ private void EntityToSequence( writer.WriteEndElement(); } - if (that.Statements != null) + if (that.InputVariables != null) { writer.WriteStartElement( - "statements"); + "inputVariables", + NS); - foreach (var item in that.Statements) + foreach (var item in that.InputVariables) { this.Visit( item, @@ -21621,165 +24953,89 @@ private void EntityToSequence( writer.WriteEndElement(); } - writer.WriteStartElement( - "entityType"); - - string? textEntityType = Stringification.ToString( - that.EntityType); - writer.WriteValue( - textEntityType - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration EntityType: " + - that.EntityType.ToString())); - - writer.WriteEndElement(); - - if (that.GlobalAssetId != null) + if (that.OutputVariables != null) { writer.WriteStartElement( - "globalAssetId"); + "outputVariables", + NS); - this.ReferenceToSequence( - that.GlobalAssetId, - writer); + foreach (var item in that.OutputVariables) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } - if (that.SpecificAssetId != null) + if (that.InoutputVariables != null) { writer.WriteStartElement( - "specificAssetId"); + "inoutputVariables", + NS); - this.SpecificAssetIdToSequence( - that.SpecificAssetId, - writer); + foreach (var item in that.InoutputVariables) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } - } // private void EntityToSequence + } // private void OperationToSequence public override void Visit( - Aas.Entity that, - WrappedXmlWriter writer) + Aas.Operation that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "entity"); - this.EntityToSequence( + "operation", + NS); + this.OperationToSequence( that, writer); writer.WriteEndElement(); } - private void EventPayloadToSequence( - EventPayload that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "source"); - - this.ReferenceToSequence( - that.Source, - writer); - - writer.WriteEndElement(); - - if (that.SourceSemanticId != null) - { - writer.WriteStartElement( - "sourceSemanticId"); - - this.ReferenceToSequence( - that.SourceSemanticId, - writer); - - writer.WriteEndElement(); - } - - writer.WriteStartElement( - "observableReference"); - - this.ReferenceToSequence( - that.ObservableReference, - writer); - - writer.WriteEndElement(); - - if (that.ObservableSemanticId != null) - { - writer.WriteStartElement( - "observableSemanticId"); - - this.ReferenceToSequence( - that.ObservableSemanticId, - writer); - - writer.WriteEndElement(); - } - - if (that.Topic != null) - { - writer.WriteStartElement( - "topic"); - - writer.WriteValue( - that.Topic); - - writer.WriteEndElement(); - } - - if (that.SubjectId != null) - { - writer.WriteStartElement( - "subjectId"); - - this.ReferenceToSequence( - that.SubjectId, - writer); - - writer.WriteEndElement(); - } - - writer.WriteStartElement( - "timeStamp"); - - writer.WriteValue( - that.TimeStamp); - - writer.WriteEndElement(); - - if (that.Payload != null) - { - writer.WriteStartElement( - "payload"); + private void OperationVariableToSequence( + OperationVariable that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "value", + NS); - writer.WriteValue( - that.Payload); + this.Visit( + that.Value, + writer); - writer.WriteEndElement(); - } - } // private void EventPayloadToSequence + writer.WriteEndElement(); + } // private void OperationVariableToSequence public override void Visit( - Aas.EventPayload that, - WrappedXmlWriter writer) + Aas.OperationVariable that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "eventPayload"); - this.EventPayloadToSequence( + "operationVariable", + NS); + this.OperationVariableToSequence( that, writer); writer.WriteEndElement(); } - private void BasicEventElementToSequence( - BasicEventElement that, - WrappedXmlWriter writer) + private void CapabilityToSequence( + Capability that, + Xml.XmlWriter writer) { if (that.Extensions != null) { writer.WriteStartElement( - "extensions"); + "extensions", + NS); foreach (var item in that.Extensions) { @@ -21794,7 +25050,8 @@ private void BasicEventElementToSequence( if (that.Category != null) { writer.WriteStartElement( - "category"); + "category", + NS); writer.WriteValue( that.Category); @@ -21805,7 +25062,8 @@ private void BasicEventElementToSequence( if (that.IdShort != null) { writer.WriteStartElement( - "idShort"); + "idShort", + NS); writer.WriteValue( that.IdShort); @@ -21816,11 +25074,15 @@ private void BasicEventElementToSequence( if (that.DisplayName != null) { writer.WriteStartElement( - "displayName"); + "displayName", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -21828,11 +25090,15 @@ private void BasicEventElementToSequence( if (that.Description != null) { writer.WriteStartElement( - "description"); + "description", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.Description) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } @@ -21840,7 +25106,8 @@ private void BasicEventElementToSequence( if (that.Checksum != null) { writer.WriteStartElement( - "checksum"); + "checksum", + NS); writer.WriteValue( that.Checksum); @@ -21851,7 +25118,8 @@ private void BasicEventElementToSequence( if (that.Kind != null) { writer.WriteStartElement( - "kind"); + "kind", + NS); string? textKind = Stringification.ToString( that.Kind); @@ -21867,7 +25135,8 @@ private void BasicEventElementToSequence( if (that.SemanticId != null) { writer.WriteStartElement( - "semanticId"); + "semanticId", + NS); this.ReferenceToSequence( that.SemanticId, @@ -21879,7 +25148,8 @@ private void BasicEventElementToSequence( if (that.SupplementalSemanticIds != null) { writer.WriteStartElement( - "supplementalSemanticIds"); + "supplementalSemanticIds", + NS); foreach (var item in that.SupplementalSemanticIds) { @@ -21894,7 +25164,8 @@ private void BasicEventElementToSequence( if (that.Qualifiers != null) { writer.WriteStartElement( - "qualifiers"); + "qualifiers", + NS); foreach (var item in that.Qualifiers) { @@ -21906,12 +25177,13 @@ private void BasicEventElementToSequence( writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "dataSpecifications"); + "embeddedDataSpecifications", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.EmbeddedDataSpecifications) { this.Visit( item, @@ -21920,121 +25192,88 @@ private void BasicEventElementToSequence( writer.WriteEndElement(); } + } // private void CapabilityToSequence + public override void Visit( + Aas.Capability that, + Xml.XmlWriter writer) + { writer.WriteStartElement( - "observed"); - - this.ReferenceToSequence( - that.Observed, + "capability", + NS); + this.CapabilityToSequence( + that, writer); - - writer.WriteEndElement(); - - writer.WriteStartElement( - "direction"); - - string? textDirection = Stringification.ToString( - that.Direction); - writer.WriteValue( - textDirection - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration Direction: " + - that.Direction.ToString())); - - writer.WriteEndElement(); - - writer.WriteStartElement( - "state"); - - string? textState = Stringification.ToString( - that.State); - writer.WriteValue( - textState - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration StateOfEvent: " + - that.State.ToString())); - writer.WriteEndElement(); + } - if (that.MessageTopic != null) - { - writer.WriteStartElement( - "messageTopic"); - - writer.WriteValue( - that.MessageTopic); - - writer.WriteEndElement(); - } - - if (that.MessageBroker != null) + private void ConceptDescriptionToSequence( + ConceptDescription that, + Xml.XmlWriter writer) + { + if (that.Extensions != null) { writer.WriteStartElement( - "messageBroker"); + "extensions", + NS); - this.ReferenceToSequence( - that.MessageBroker, - writer); + foreach (var item in that.Extensions) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } - if (that.LastUpdate != null) + if (that.Category != null) { writer.WriteStartElement( - "lastUpdate"); + "category", + NS); writer.WriteValue( - that.LastUpdate); + that.Category); writer.WriteEndElement(); } - if (that.MinInterval != null) + if (that.IdShort != null) { writer.WriteStartElement( - "minInterval"); + "idShort", + NS); writer.WriteValue( - that.MinInterval); + that.IdShort); writer.WriteEndElement(); } - if (that.MaxInterval != null) + if (that.DisplayName != null) { writer.WriteStartElement( - "maxInterval"); + "displayName", + NS); - writer.WriteValue( - that.MaxInterval); + foreach (var item in that.DisplayName) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } - } // private void BasicEventElementToSequence - - public override void Visit( - Aas.BasicEventElement that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "basicEventElement"); - this.BasicEventElementToSequence( - that, - writer); - writer.WriteEndElement(); - } - private void OperationToSequence( - Operation that, - WrappedXmlWriter writer) - { - if (that.Extensions != null) + if (that.Description != null) { writer.WriteStartElement( - "extensions"); + "description", + NS); - foreach (var item in that.Extensions) + foreach (var item in that.Description) { this.Visit( item, @@ -22044,142 +25283,232 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.Category != null) + if (that.Checksum != null) { writer.WriteStartElement( - "category"); + "checksum", + NS); writer.WriteValue( - that.Category); + that.Checksum); writer.WriteEndElement(); } - if (that.IdShort != null) + if (that.Administration != null) { writer.WriteStartElement( - "idShort"); + "administration", + NS); - writer.WriteValue( - that.IdShort); + this.AdministrativeInformationToSequence( + that.Administration, + writer); writer.WriteEndElement(); } - if (that.DisplayName != null) - { - writer.WriteStartElement( - "displayName"); + writer.WriteStartElement( + "id", + NS); - this.LangStringSetToSequence( - that.DisplayName, - writer); + writer.WriteValue( + that.Id); - writer.WriteEndElement(); - } + writer.WriteEndElement(); - if (that.Description != null) + if (that.EmbeddedDataSpecifications != null) { writer.WriteStartElement( - "description"); + "embeddedDataSpecifications", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + foreach (var item in that.EmbeddedDataSpecifications) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } - if (that.Checksum != null) + if (that.IsCaseOf != null) { writer.WriteStartElement( - "checksum"); + "isCaseOf", + NS); - writer.WriteValue( - that.Checksum); + foreach (var item in that.IsCaseOf) + { + this.Visit( + item, + writer); + } writer.WriteEndElement(); } + } // private void ConceptDescriptionToSequence - if (that.Kind != null) - { - writer.WriteStartElement( - "kind"); + public override void Visit( + Aas.ConceptDescription that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "conceptDescription", + NS); + this.ConceptDescriptionToSequence( + that, + writer); + writer.WriteEndElement(); + } - string? textKind = Stringification.ToString( - that.Kind); - writer.WriteValue( - textKind - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration ModelingKind: " + - that.Kind.ToString())); + private void ReferenceToSequence( + Reference that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "type", + NS); - writer.WriteEndElement(); - } + string? textType = Stringification.ToString( + that.Type); + writer.WriteValue( + textType + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration ReferenceTypes: " + + that.Type.ToString())); - if (that.SemanticId != null) + writer.WriteEndElement(); + + if (that.ReferredSemanticId != null) { writer.WriteStartElement( - "semanticId"); + "referredSemanticId", + NS); this.ReferenceToSequence( - that.SemanticId, + that.ReferredSemanticId, writer); writer.WriteEndElement(); } - if (that.SupplementalSemanticIds != null) + writer.WriteStartElement( + "keys", + NS); + + foreach (var item in that.Keys) { - writer.WriteStartElement( - "supplementalSemanticIds"); + this.Visit( + item, + writer); + } - foreach (var item in that.SupplementalSemanticIds) - { - this.Visit( - item, - writer); - } + writer.WriteEndElement(); + } // private void ReferenceToSequence + + public override void Visit( + Aas.Reference that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "reference", + NS); + this.ReferenceToSequence( + that, + writer); + writer.WriteEndElement(); + } + + private void KeyToSequence( + Key that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "type", + NS); + + string? textType = Stringification.ToString( + that.Type); + writer.WriteValue( + textType + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration KeyTypes: " + + that.Type.ToString())); + + writer.WriteEndElement(); + + writer.WriteStartElement( + "value", + NS); + + writer.WriteValue( + that.Value); + + writer.WriteEndElement(); + } // private void KeyToSequence + + public override void Visit( + Aas.Key that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "key", + NS); + this.KeyToSequence( + that, + writer); + writer.WriteEndElement(); + } - writer.WriteEndElement(); - } + private void LangStringToSequence( + LangString that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "language", + NS); - if (that.Qualifiers != null) - { - writer.WriteStartElement( - "qualifiers"); + writer.WriteValue( + that.Language); - foreach (var item in that.Qualifiers) - { - this.Visit( - item, - writer); - } + writer.WriteEndElement(); - writer.WriteEndElement(); - } + writer.WriteStartElement( + "text", + NS); - if (that.DataSpecifications != null) - { - writer.WriteStartElement( - "dataSpecifications"); + writer.WriteValue( + that.Text); - foreach (var item in that.DataSpecifications) - { - this.Visit( - item, - writer); - } + writer.WriteEndElement(); + } // private void LangStringToSequence - writer.WriteEndElement(); - } + public override void Visit( + Aas.LangString that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "langString", + NS); + this.LangStringToSequence( + that, + writer); + writer.WriteEndElement(); + } - if (that.InputVariables != null) + private void EnvironmentToSequence( + Environment that, + Xml.XmlWriter writer) + { + if (that.AssetAdministrationShells != null) { writer.WriteStartElement( - "inputVariables"); + "assetAdministrationShells", + NS); - foreach (var item in that.InputVariables) + foreach (var item in that.AssetAdministrationShells) { this.Visit( item, @@ -22189,12 +25518,13 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.OutputVariables != null) + if (that.Submodels != null) { writer.WriteStartElement( - "outputVariables"); + "submodels", + NS); - foreach (var item in that.OutputVariables) + foreach (var item in that.Submodels) { this.Visit( item, @@ -22204,12 +25534,13 @@ private void OperationToSequence( writer.WriteEndElement(); } - if (that.InoutputVariables != null) + if (that.ConceptDescriptions != null) { writer.WriteStartElement( - "inoutputVariables"); + "conceptDescriptions", + NS); - foreach (var item in that.InoutputVariables) + foreach (var item in that.ConceptDescriptions) { this.Visit( item, @@ -22218,218 +25549,151 @@ private void OperationToSequence( writer.WriteEndElement(); } - } // private void OperationToSequence + } // private void EnvironmentToSequence public override void Visit( - Aas.Operation that, - WrappedXmlWriter writer) + Aas.Environment that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "operation"); - this.OperationToSequence( + "environment", + NS); + this.EnvironmentToSequence( that, writer); writer.WriteEndElement(); } - private void OperationVariableToSequence( - OperationVariable that, - WrappedXmlWriter writer) + private void EmbeddedDataSpecificationToSequence( + EmbeddedDataSpecification that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "value"); + "dataSpecification", + NS); + + this.ReferenceToSequence( + that.DataSpecification, + writer); + + writer.WriteEndElement(); + + writer.WriteStartElement( + "dataSpecificationContent", + NS); this.Visit( - that.Value, + that.DataSpecificationContent, writer); writer.WriteEndElement(); - } // private void OperationVariableToSequence + } // private void EmbeddedDataSpecificationToSequence public override void Visit( - Aas.OperationVariable that, - WrappedXmlWriter writer) + Aas.EmbeddedDataSpecification that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "operationVariable"); - this.OperationVariableToSequence( + "embeddedDataSpecification", + NS); + this.EmbeddedDataSpecificationToSequence( that, writer); writer.WriteEndElement(); } - private void CapabilityToSequence( - Capability that, - WrappedXmlWriter writer) + private void ValueReferencePairToSequence( + ValueReferencePair that, + Xml.XmlWriter writer) { - if (that.Extensions != null) - { - writer.WriteStartElement( - "extensions"); - - foreach (var item in that.Extensions) - { - this.Visit( - item, - writer); - } - - writer.WriteEndElement(); - } - - if (that.Category != null) - { - writer.WriteStartElement( - "category"); - - writer.WriteValue( - that.Category); - - writer.WriteEndElement(); - } - - if (that.IdShort != null) - { - writer.WriteStartElement( - "idShort"); - - writer.WriteValue( - that.IdShort); - - writer.WriteEndElement(); - } - - if (that.DisplayName != null) - { - writer.WriteStartElement( - "displayName"); - - this.LangStringSetToSequence( - that.DisplayName, - writer); - - writer.WriteEndElement(); - } - - if (that.Description != null) - { - writer.WriteStartElement( - "description"); - - this.LangStringSetToSequence( - that.Description, - writer); + writer.WriteStartElement( + "value", + NS); - writer.WriteEndElement(); - } + writer.WriteValue( + that.Value); - if (that.Checksum != null) - { - writer.WriteStartElement( - "checksum"); + writer.WriteEndElement(); - writer.WriteValue( - that.Checksum); + writer.WriteStartElement( + "valueId", + NS); - writer.WriteEndElement(); - } + this.ReferenceToSequence( + that.ValueId, + writer); - if (that.Kind != null) - { - writer.WriteStartElement( - "kind"); + writer.WriteEndElement(); + } // private void ValueReferencePairToSequence - string? textKind = Stringification.ToString( - that.Kind); - writer.WriteValue( - textKind - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration ModelingKind: " + - that.Kind.ToString())); + public override void Visit( + Aas.ValueReferencePair that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "valueReferencePair", + NS); + this.ValueReferencePairToSequence( + that, + writer); + writer.WriteEndElement(); + } - writer.WriteEndElement(); - } + private void ValueListToSequence( + ValueList that, + Xml.XmlWriter writer) + { + writer.WriteStartElement( + "valueReferencePairs", + NS); - if (that.SemanticId != null) + foreach (var item in that.ValueReferencePairs) { - writer.WriteStartElement( - "semanticId"); - - this.ReferenceToSequence( - that.SemanticId, + this.Visit( + item, writer); - - writer.WriteEndElement(); - } - - if (that.SupplementalSemanticIds != null) - { - writer.WriteStartElement( - "supplementalSemanticIds"); - - foreach (var item in that.SupplementalSemanticIds) - { - this.Visit( - item, - writer); - } - - writer.WriteEndElement(); - } - - if (that.Qualifiers != null) - { - writer.WriteStartElement( - "qualifiers"); - - foreach (var item in that.Qualifiers) - { - this.Visit( - item, - writer); - } - - writer.WriteEndElement(); } - if (that.DataSpecifications != null) - { - writer.WriteStartElement( - "dataSpecifications"); - - foreach (var item in that.DataSpecifications) - { - this.Visit( - item, - writer); - } - - writer.WriteEndElement(); - } - } // private void CapabilityToSequence + writer.WriteEndElement(); + } // private void ValueListToSequence public override void Visit( - Aas.Capability that, - WrappedXmlWriter writer) + Aas.ValueList that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "capability"); - this.CapabilityToSequence( + "valueList", + NS); + this.ValueListToSequence( that, writer); writer.WriteEndElement(); } - private void ConceptDescriptionToSequence( - ConceptDescription that, - WrappedXmlWriter writer) + private void DataSpecificationIec61360ToSequence( + DataSpecificationIec61360 that, + Xml.XmlWriter writer) { - if (that.Extensions != null) + writer.WriteStartElement( + "preferredName", + NS); + + foreach (var item in that.PreferredName) + { + this.Visit( + item, + writer); + } + + writer.WriteEndElement(); + + if (that.ShortName != null) { writer.WriteStartElement( - "extensions"); + "shortName", + NS); - foreach (var item in that.Extensions) + foreach (var item in that.ShortName) { this.Visit( item, @@ -22439,89 +25703,79 @@ private void ConceptDescriptionToSequence( writer.WriteEndElement(); } - if (that.Category != null) - { - writer.WriteStartElement( - "category"); - - writer.WriteValue( - that.Category); - - writer.WriteEndElement(); - } - - if (that.IdShort != null) + if (that.Unit != null) { writer.WriteStartElement( - "idShort"); + "unit", + NS); writer.WriteValue( - that.IdShort); + that.Unit); writer.WriteEndElement(); } - if (that.DisplayName != null) + if (that.UnitId != null) { writer.WriteStartElement( - "displayName"); + "unitId", + NS); - this.LangStringSetToSequence( - that.DisplayName, + this.ReferenceToSequence( + that.UnitId, writer); writer.WriteEndElement(); } - if (that.Description != null) + if (that.SourceOfDefinition != null) { writer.WriteStartElement( - "description"); + "sourceOfDefinition", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + writer.WriteValue( + that.SourceOfDefinition); writer.WriteEndElement(); } - if (that.Checksum != null) + if (that.Symbol != null) { writer.WriteStartElement( - "checksum"); + "symbol", + NS); writer.WriteValue( - that.Checksum); + that.Symbol); writer.WriteEndElement(); } - if (that.Administration != null) + if (that.DataType != null) { writer.WriteStartElement( - "administration"); + "dataType", + NS); - this.AdministrativeInformationToSequence( - that.Administration, - writer); + string? textDataType = Stringification.ToString( + that.DataType); + writer.WriteValue( + textDataType + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration DataTypeIec61360: " + + that.DataType.ToString())); writer.WriteEndElement(); } - writer.WriteStartElement( - "id"); - - writer.WriteValue( - that.Id); - - writer.WriteEndElement(); - - if (that.DataSpecifications != null) + if (that.Definition != null) { writer.WriteStartElement( - "dataSpecifications"); + "definition", + NS); - foreach (var item in that.DataSpecifications) + foreach (var item in that.Definition) { this.Visit( item, @@ -22531,167 +25785,101 @@ private void ConceptDescriptionToSequence( writer.WriteEndElement(); } - if (that.IsCaseOf != null) + if (that.ValueFormat != null) { writer.WriteStartElement( - "isCaseOf"); + "valueFormat", + NS); - foreach (var item in that.IsCaseOf) - { - this.Visit( - item, - writer); - } + writer.WriteValue( + that.ValueFormat); writer.WriteEndElement(); } - } // private void ConceptDescriptionToSequence - - public override void Visit( - Aas.ConceptDescription that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "conceptDescription"); - this.ConceptDescriptionToSequence( - that, - writer); - writer.WriteEndElement(); - } - - private void ReferenceToSequence( - Reference that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "type"); - - string? textType = Stringification.ToString( - that.Type); - writer.WriteValue( - textType - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration ReferenceTypes: " + - that.Type.ToString())); - - writer.WriteEndElement(); - if (that.ReferredSemanticId != null) + if (that.ValueList != null) { writer.WriteStartElement( - "referredSemanticId"); + "valueList", + NS); - this.ReferenceToSequence( - that.ReferredSemanticId, + this.ValueListToSequence( + that.ValueList, writer); writer.WriteEndElement(); } - writer.WriteStartElement( - "keys"); - - foreach (var item in that.Keys) + if (that.Value != null) { - this.Visit( - item, - writer); - } - - writer.WriteEndElement(); - } // private void ReferenceToSequence - - public override void Visit( - Aas.Reference that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "reference"); - this.ReferenceToSequence( - that, - writer); - writer.WriteEndElement(); - } - - private void KeyToSequence( - Key that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "type"); + writer.WriteStartElement( + "value", + NS); - string? textType = Stringification.ToString( - that.Type); - writer.WriteValue( - textType - ?? throw new System.ArgumentException( - "Invalid literal for the enumeration KeyTypes: " + - that.Type.ToString())); + writer.WriteValue( + that.Value); - writer.WriteEndElement(); + writer.WriteEndElement(); + } - writer.WriteStartElement( - "value"); + if (that.LevelType != null) + { + writer.WriteStartElement( + "levelType", + NS); - writer.WriteValue( - that.Value); + string? textLevelType = Stringification.ToString( + that.LevelType); + writer.WriteValue( + textLevelType + ?? throw new System.ArgumentException( + "Invalid literal for the enumeration LevelType: " + + that.LevelType.ToString())); - writer.WriteEndElement(); - } // private void KeyToSequence + writer.WriteEndElement(); + } + } // private void DataSpecificationIec61360ToSequence public override void Visit( - Aas.Key that, - WrappedXmlWriter writer) + Aas.DataSpecificationIec61360 that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "key"); - this.KeyToSequence( + "dataSpecificationIec61360", + NS); + this.DataSpecificationIec61360ToSequence( that, writer); writer.WriteEndElement(); } - private void LangStringToSequence( - LangString that, - WrappedXmlWriter writer) + private void DataSpecificationPhysicalUnitToSequence( + DataSpecificationPhysicalUnit that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "language"); + "unitName", + NS); writer.WriteValue( - that.Language); + that.UnitName); writer.WriteEndElement(); writer.WriteStartElement( - "text"); + "unitSymbol", + NS); writer.WriteValue( - that.Text); + that.UnitSymbol); writer.WriteEndElement(); - } // private void LangStringToSequence - - public override void Visit( - Aas.LangString that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "langString"); - this.LangStringToSequence( - that, - writer); - writer.WriteEndElement(); - } - private void LangStringSetToSequence( - LangStringSet that, - WrappedXmlWriter writer) - { writer.WriteStartElement( - "langStrings"); + "definition", + NS); - foreach (var item in that.LangStrings) + foreach (var item in that.Definition) { this.Visit( item, @@ -22699,235 +25887,142 @@ private void LangStringSetToSequence( } writer.WriteEndElement(); - } // private void LangStringSetToSequence - public override void Visit( - Aas.LangStringSet that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "langStringSet"); - this.LangStringSetToSequence( - that, - writer); - writer.WriteEndElement(); - } + if (that.SiNotation != null) + { + writer.WriteStartElement( + "siNotation", + NS); - [CodeAnalysis.SuppressMessage("ReSharper", "UnusedParameter.Local")] - private void DataSpecificationContentToSequence( - DataSpecificationContent that, - WrappedXmlWriter writer) - { - // Intentionally empty. - } // private void DataSpecificationContentToSequence + writer.WriteValue( + that.SiNotation); - public override void Visit( - Aas.DataSpecificationContent that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "dataSpecificationContent"); - this.DataSpecificationContentToSequence( - that, - writer); - writer.WriteEndElement(); - } + writer.WriteEndElement(); + } - private void DataSpecificationToSequence( - DataSpecification that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "id"); + if (that.SiName != null) + { + writer.WriteStartElement( + "siName", + NS); - writer.WriteValue( - that.Id); + writer.WriteValue( + that.SiName); - writer.WriteEndElement(); + writer.WriteEndElement(); + } - writer.WriteStartElement( - "dataSpecificationContent"); + if (that.DinNotation != null) + { + writer.WriteStartElement( + "dinNotation", + NS); - this.DataSpecificationContentToSequence( - that.DataSpecificationContent, - writer); + writer.WriteValue( + that.DinNotation); - writer.WriteEndElement(); + writer.WriteEndElement(); + } - if (that.Administration != null) + if (that.EceName != null) { writer.WriteStartElement( - "administration"); + "eceName", + NS); - this.AdministrativeInformationToSequence( - that.Administration, - writer); + writer.WriteValue( + that.EceName); writer.WriteEndElement(); } - if (that.Description != null) + if (that.EceCode != null) { writer.WriteStartElement( - "description"); + "eceCode", + NS); - this.LangStringSetToSequence( - that.Description, - writer); + writer.WriteValue( + that.EceCode); writer.WriteEndElement(); } - } // private void DataSpecificationToSequence - public override void Visit( - Aas.DataSpecification that, - WrappedXmlWriter writer) - { - writer.WriteStartElement( - "dataSpecification"); - this.DataSpecificationToSequence( - that, - writer); - writer.WriteEndElement(); - } + if (that.NistName != null) + { + writer.WriteStartElement( + "nistName", + NS); - private void EnvironmentToSequence( - Environment that, - WrappedXmlWriter writer) - { - if (that.AssetAdministrationShells != null) + writer.WriteValue( + that.NistName); + + writer.WriteEndElement(); + } + + if (that.SourceOfDefinition != null) { writer.WriteStartElement( - "assetAdministrationShells"); + "sourceOfDefinition", + NS); - foreach (var item in that.AssetAdministrationShells) - { - this.Visit( - item, - writer); - } + writer.WriteValue( + that.SourceOfDefinition); writer.WriteEndElement(); } - if (that.Submodels != null) + if (that.ConversionFactor != null) { writer.WriteStartElement( - "submodels"); + "conversionFactor", + NS); - foreach (var item in that.Submodels) - { - this.Visit( - item, - writer); - } + writer.WriteValue( + that.ConversionFactor); writer.WriteEndElement(); } - if (that.ConceptDescriptions != null) + if (that.RegistrationAuthorityId != null) { writer.WriteStartElement( - "conceptDescriptions"); + "registrationAuthorityId", + NS); - foreach (var item in that.ConceptDescriptions) - { - this.Visit( - item, - writer); - } + writer.WriteValue( + that.RegistrationAuthorityId); writer.WriteEndElement(); } - if (that.DataSpecifications != null) + if (that.Supplier != null) { writer.WriteStartElement( - "dataSpecifications"); + "supplier", + NS); - foreach (var item in that.DataSpecifications) - { - this.Visit( - item, - writer); - } + writer.WriteValue( + that.Supplier); writer.WriteEndElement(); } - } // private void EnvironmentToSequence + } // private void DataSpecificationPhysicalUnitToSequence public override void Visit( - Aas.Environment that, - WrappedXmlWriter writer) + Aas.DataSpecificationPhysicalUnit that, + Xml.XmlWriter writer) { writer.WriteStartElement( - "environment"); - this.EnvironmentToSequence( + "dataSpecificationPhysicalUnit", + NS); + this.DataSpecificationPhysicalUnitToSequence( that, writer); writer.WriteEndElement(); } } // internal class VisitorWithWriter - /// - /// Wrap the writer so that we can omit the namespace and the prefix. - /// - internal class WrappedXmlWriter - { - private readonly Xml.XmlWriter _writer; - private readonly string? _prefix; - private readonly string? _ns; - - internal WrappedXmlWriter( - Xml.XmlWriter writer, - string? prefix, - string? ns) - { - _writer = writer; - _prefix = prefix; - _ns = ns; - } - - internal void WriteStartElement(string localName) - { - _writer.WriteStartElement( - _prefix, localName, _ns); - } - - internal void WriteEndElement() - { - _writer.WriteEndElement(); - } - - internal virtual void WriteValue(bool value) - { - _writer.WriteValue(value); - } - - internal virtual void WriteValue(long value) - { - _writer.WriteValue(value); - } - - internal virtual void WriteValue(double value) - { - _writer.WriteValue(value); - } - - internal virtual void WriteValue(string? value) - { - _writer.WriteValue(value); - } - - internal virtual void WriteBase64(byte[] buffer) - { - _writer.WriteBase64( - buffer, - 0, - buffer.Length); - } - } // WrappedXmlWriter - /// /// Serialize instances of meta-model classes to XML. /// @@ -22942,21 +26037,6 @@ internal virtual void WriteBase64(byte[] buffer) /// anInstance, /// writer); /// - /// - /// - /// - /// You can also set the namespace and the prefix: - /// - /// var anInstance = new Aas.IHasSemantics( - /// /* ... some constructor arguments ... */ - /// ); - /// var writer = new System.Xml.XmlWriter( /* some arguments */ ); - /// Serialize.To( - /// anInstance, - /// writer, - /// "somePrefix", - /// "https://some-namespace.com"); - /// /// public static class Serialize { @@ -22969,15 +26049,10 @@ public static class Serialize /// public static void To( Aas.IClass that, - Xml.XmlWriter writer, - string? prefix = null, - string? ns = null) + Xml.XmlWriter writer) { - var wrappedWriter = new WrappedXmlWriter( - writer, prefix, ns); - Serialize._visitorWithWriter.Visit( - that, wrappedWriter); + that, writer); } } // public static class Serialize } // public static class Xmlization diff --git a/src/AasxServer.sln b/src/AasxServer.sln index 91230349c..a5231bdf7 100644 --- a/src/AasxServer.sln +++ b/src/AasxServer.sln @@ -3,8 +3,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.2.32616.157 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxServerCore", "AasxServerCore\AasxServerCore.csproj", "{7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxServerStandardBib", "AasxServerStandardBib\AasxServerStandardBib.csproj", "{6D8FAFA1-0BA5-4E52-87D2-E4E37FC6D95F}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B8C116C4-932B-4071-9DCC-D4F64E3C4E6F}" @@ -13,8 +11,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution README.md = README.md EndProjectSection EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxServerBlazor", "AasxServerBlazor\AasxServerBlazor.csproj", "{53165247-64F7-4151-A1DA-347780E0A538}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasCore.Aas3_0_RC02", "AasxServer.DomainModelV3_0_RC02\AasCore.Aas3_0_RC02.csproj", "{2423FA18-149F-4079-B898-10A08AE724E1}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IO.Swagger.V1RC03", "IO.Swagger.V1RC03\IO.Swagger.V1RC03.csproj", "{7407634A-FF58-45DA-B815-85B1D76A508A}" @@ -25,6 +21,12 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "es6numberserializer", "es6n EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IO.Swagger.Registry", "IO.Swagger.Registry.Lib\IO.Swagger.Registry.csproj", "{142D8180-5B73-42EF-BD57-B2ECDB11FF52}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxCsharpLibrary", "AasxCsharpLibrary\AasxCsharpLibrary.csproj", "{41638E72-A699-4474-9B1F-ACBEC8CA5FED}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AasxServerBlazor", "AasxServerBlazor\AasxServerBlazor.csproj", "{158BF4D6-90FE-404F-AC7C-718A7D74007B}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IO.Swagger.Lib.V3", "IO.Swagger.Lib.V3\IO.Swagger.Lib.V3.csproj", "{1C237091-3C10-4D14-956B-35740AC03BA6}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -38,24 +40,6 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Debug|x64.ActiveCfg = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Debug|x64.Build.0 = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Debug|x86.ActiveCfg = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Debug|x86.Build.0 = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.DebugSlow|Any CPU.ActiveCfg = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.DebugSlow|Any CPU.Build.0 = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.DebugSlow|x64.ActiveCfg = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.DebugSlow|x64.Build.0 = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.DebugSlow|x86.ActiveCfg = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.DebugSlow|x86.Build.0 = Debug|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Release|Any CPU.Build.0 = Release|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Release|x64.ActiveCfg = Release|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Release|x64.Build.0 = Release|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Release|x86.ActiveCfg = Release|Any CPU - {7C0704A8-85C7-4FC9-B12D-C7B9E63EF7B6}.Release|x86.Build.0 = Release|Any CPU {6D8FAFA1-0BA5-4E52-87D2-E4E37FC6D95F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {6D8FAFA1-0BA5-4E52-87D2-E4E37FC6D95F}.Debug|Any CPU.Build.0 = Debug|Any CPU {6D8FAFA1-0BA5-4E52-87D2-E4E37FC6D95F}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -74,24 +58,6 @@ Global {6D8FAFA1-0BA5-4E52-87D2-E4E37FC6D95F}.Release|x64.Build.0 = Release|Any CPU {6D8FAFA1-0BA5-4E52-87D2-E4E37FC6D95F}.Release|x86.ActiveCfg = Release|Any CPU {6D8FAFA1-0BA5-4E52-87D2-E4E37FC6D95F}.Release|x86.Build.0 = Release|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Debug|Any CPU.Build.0 = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Debug|x64.ActiveCfg = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Debug|x64.Build.0 = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Debug|x86.ActiveCfg = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Debug|x86.Build.0 = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.DebugSlow|Any CPU.ActiveCfg = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.DebugSlow|Any CPU.Build.0 = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.DebugSlow|x64.ActiveCfg = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.DebugSlow|x64.Build.0 = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.DebugSlow|x86.ActiveCfg = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.DebugSlow|x86.Build.0 = Debug|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Release|Any CPU.ActiveCfg = Release|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Release|Any CPU.Build.0 = Release|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Release|x64.ActiveCfg = Release|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Release|x64.Build.0 = Release|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Release|x86.ActiveCfg = Release|Any CPU - {53165247-64F7-4151-A1DA-347780E0A538}.Release|x86.Build.0 = Release|Any CPU {2423FA18-149F-4079-B898-10A08AE724E1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {2423FA18-149F-4079-B898-10A08AE724E1}.Debug|Any CPU.Build.0 = Debug|Any CPU {2423FA18-149F-4079-B898-10A08AE724E1}.Debug|x64.ActiveCfg = Debug|Any CPU @@ -182,6 +148,60 @@ Global {142D8180-5B73-42EF-BD57-B2ECDB11FF52}.Release|x64.Build.0 = Release|Any CPU {142D8180-5B73-42EF-BD57-B2ECDB11FF52}.Release|x86.ActiveCfg = Release|Any CPU {142D8180-5B73-42EF-BD57-B2ECDB11FF52}.Release|x86.Build.0 = Release|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Debug|Any CPU.Build.0 = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Debug|x64.ActiveCfg = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Debug|x64.Build.0 = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Debug|x86.ActiveCfg = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Debug|x86.Build.0 = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.DebugSlow|Any CPU.ActiveCfg = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.DebugSlow|Any CPU.Build.0 = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.DebugSlow|x64.ActiveCfg = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.DebugSlow|x64.Build.0 = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.DebugSlow|x86.ActiveCfg = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.DebugSlow|x86.Build.0 = Debug|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Release|Any CPU.ActiveCfg = Release|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Release|Any CPU.Build.0 = Release|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Release|x64.ActiveCfg = Release|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Release|x64.Build.0 = Release|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Release|x86.ActiveCfg = Release|Any CPU + {41638E72-A699-4474-9B1F-ACBEC8CA5FED}.Release|x86.Build.0 = Release|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Debug|x64.ActiveCfg = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Debug|x64.Build.0 = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Debug|x86.ActiveCfg = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Debug|x86.Build.0 = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.DebugSlow|Any CPU.ActiveCfg = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.DebugSlow|Any CPU.Build.0 = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.DebugSlow|x64.ActiveCfg = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.DebugSlow|x64.Build.0 = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.DebugSlow|x86.ActiveCfg = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.DebugSlow|x86.Build.0 = Debug|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Release|Any CPU.Build.0 = Release|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Release|x64.ActiveCfg = Release|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Release|x64.Build.0 = Release|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Release|x86.ActiveCfg = Release|Any CPU + {158BF4D6-90FE-404F-AC7C-718A7D74007B}.Release|x86.Build.0 = Release|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Debug|x64.ActiveCfg = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Debug|x64.Build.0 = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Debug|x86.ActiveCfg = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Debug|x86.Build.0 = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.DebugSlow|Any CPU.ActiveCfg = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.DebugSlow|Any CPU.Build.0 = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.DebugSlow|x64.ActiveCfg = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.DebugSlow|x64.Build.0 = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.DebugSlow|x86.ActiveCfg = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.DebugSlow|x86.Build.0 = Debug|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Release|Any CPU.Build.0 = Release|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Release|x64.ActiveCfg = Release|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Release|x64.Build.0 = Release|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Release|x86.ActiveCfg = Release|Any CPU + {1C237091-3C10-4D14-956B-35740AC03BA6}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/AasxServerBlazor/AasxServerBlazor.csproj b/src/AasxServerBlazor/AasxServerBlazor.csproj index 5ddccec4a..857117687 100644 --- a/src/AasxServerBlazor/AasxServerBlazor.csproj +++ b/src/AasxServerBlazor/AasxServerBlazor.csproj @@ -22,7 +22,7 @@ - + diff --git a/src/AasxServerBlazor/Data/AASService.cs b/src/AasxServerBlazor/Data/AASService.cs index 2c8f4318c..2d0866b98 100644 --- a/src/AasxServerBlazor/Data/AASService.cs +++ b/src/AasxServerBlazor/Data/AASService.cs @@ -1,14 +1,11 @@ -using System; +using AasCore.Aas3_0_RC02; +using AasxServer; +using System; using System.Collections.Generic; using System.IO; using System.Linq; -using System.Threading.Tasks; -using AasCore.Aas3_0_RC02; -using AasxRestServerLibrary; -using AasxServer; -using AdminShellNS; -using Extenstions; using static AasxServerBlazor.Pages.TreePage; +using Extensions; namespace AasxServerBlazor.Data { @@ -89,66 +86,69 @@ public void buildTree() root.envIndex = i; if (Program.env[i] != null) { - root.Text = Program.env[i].AasEnv.AssetAdministrationShells[0].IdShort; - root.Tag = Program.env[i].AasEnv.AssetAdministrationShells[0]; - if (Program.envSymbols[i] != "L") + if (Program.env[i].AasEnv.AssetAdministrationShells != null && Program.env[i].AasEnv.AssetAdministrationShells.Count > 0) { - List childs = new List(); - var env = AasxServer.Program.env[i]; - var aas = env.AasEnv.AssetAdministrationShells[0]; - if (env != null && aas.Submodels != null && aas.Submodels.Count > 0) - foreach (var smr in aas.Submodels) - { - var sm = env.AasEnv.FindSubmodel(smr); - if (sm != null && sm.IdShort != null) + root.Text = Program.env[i].AasEnv.AssetAdministrationShells[0].IdShort; + root.Tag = Program.env[i].AasEnv.AssetAdministrationShells[0]; + if (Program.envSymbols[i] != "L") + { + List childs = new List(); + var env = AasxServer.Program.env[i]; + var aas = env.AasEnv.AssetAdministrationShells[0]; + if (env != null && aas.Submodels != null && aas.Submodels.Count > 0) + foreach (var smr in aas.Submodels) { - var smItem = new Item(); - smItem.envIndex = i; - smItem.Text = sm.IdShort; - smItem.Tag = sm; - childs.Add(smItem); - List smChilds = new List(); - if (sm.SubmodelElements != null) - foreach (var sme in sm.SubmodelElements) - { - var smeItem = new Item(); - smeItem.envIndex = i; - smeItem.Text = sme.IdShort; - smeItem.Tag = sme; - smChilds.Add(smeItem); - if (sme is SubmodelElementCollection) - { - var smec = sme as SubmodelElementCollection; - createSMECItems(smeItem, smec, i); - } - if (sme is Operation) - { - var o = sme as Operation; - createOperationItems(smeItem, o, i); - } - if (sme is Entity) - { - var e = sme as Entity; - createEntityItems(smeItem, e, i); - } - if (sme is AnnotatedRelationshipElement annotatedRelationshipElement) - { - CreateAnnotedRelationshipElementItems(smeItem, annotatedRelationshipElement, i); - } - if (sme is SubmodelElementList smeList) + var sm = env.AasEnv.FindSubmodel(smr); + if (sm != null && sm.IdShort != null) + { + var smItem = new Item(); + smItem.envIndex = i; + smItem.Text = sm.IdShort; + smItem.Tag = sm; + childs.Add(smItem); + List smChilds = new List(); + if (sm.SubmodelElements != null) + foreach (var sme in sm.SubmodelElements) { - CreateSMEListItems(smeItem, smeList, i); + var smeItem = new Item(); + smeItem.envIndex = i; + smeItem.Text = sme.IdShort; + smeItem.Tag = sme; + smChilds.Add(smeItem); + if (sme is SubmodelElementCollection) + { + var smec = sme as SubmodelElementCollection; + createSMECItems(smeItem, smec, i); + } + if (sme is Operation) + { + var o = sme as Operation; + createOperationItems(smeItem, o, i); + } + if (sme is Entity) + { + var e = sme as Entity; + createEntityItems(smeItem, e, i); + } + if (sme is AnnotatedRelationshipElement annotatedRelationshipElement) + { + CreateAnnotedRelationshipElementItems(smeItem, annotatedRelationshipElement, i); + } + if (sme is SubmodelElementList smeList) + { + CreateSMEListItems(smeItem, smeList, i); + } } - } - smItem.Childs = smChilds; - foreach (var c in smChilds) - c.parent = smItem; + smItem.Childs = smChilds; + foreach (var c in smChilds) + c.parent = smItem; + } } - } - root.Childs = childs; - foreach (var c in childs) - c.parent = root; - items.Add(root); + root.Childs = childs; + foreach (var c in childs) + c.parent = root; + items.Add(root); + } } } if (Program.envSymbols[i] == "L") diff --git a/src/AasxServerBlazor/Pages/Pcf2.razor b/src/AasxServerBlazor/Pages/Pcf2.razor index dad695804..20ff3ded6 100644 --- a/src/AasxServerBlazor/Pages/Pcf2.razor +++ b/src/AasxServerBlazor/Pages/Pcf2.razor @@ -5,7 +5,7 @@ @inject AASService SubmodelService @inject CredentialService cs @using AasxServer; -@using Extenstions; +@using Extensions; @using Microsoft.IdentityModel.Tokens; @using System.Drawing; @using System.Globalization; diff --git a/src/AasxServerBlazor/Pages/TreePage.razor b/src/AasxServerBlazor/Pages/TreePage.razor index 170c54b0c..2ddd39c1f 100644 --- a/src/AasxServerBlazor/Pages/TreePage.razor +++ b/src/AasxServerBlazor/Pages/TreePage.razor @@ -2,7 +2,7 @@ @inject AASService SubmodelService @inject NavigationManager NavigationManager @using AasCore.Aas3_0_RC02 -@using Extenstions +@using Extensions @using Microsoft.IdentityModel.Tokens; @using System @using System.Net; @@ -1590,11 +1590,11 @@ if (ls != null) { ret = " = "; - for (int i = 0; i < ls.LangStrings.Count; i++) + for (int i = 0; i < ls.Count; i++) { - ret += ls.LangStrings[i].Language + " "; + ret += ls[i].Language + " "; if (i == 0) - ret += ls.LangStrings[i].Text + " "; + ret += ls[i].Text + " "; } } if (mlp.Qualifiers != null && mlp.Qualifiers.Count > 0) @@ -2284,9 +2284,9 @@ { var mlp = o as MultiLanguageProperty; var ls = mlp.Value; - for (int i = 0; i < ls.LangStrings.Count; i++) + for (int i = 0; i < ls.Count; i++) { - ret += ls.LangStrings[i].Language + " "; + ret += ls[i].Language + " "; } switch (line) { @@ -2308,12 +2308,12 @@ case 3: case 4: ret = ""; - if (ls.LangStrings.Count > line - 1) + if (ls.Count > line - 1) { if (col == 0) - ret = ls.LangStrings[line - 1].Language; + ret = ls[line - 1].Language; if (col == 1) - ret = ls.LangStrings[line - 1].Text + ""; + ret = ls[line - 1].Text + ""; } break; case 5: diff --git a/src/AasxServerBlazor/Program.cs b/src/AasxServerBlazor/Program.cs index 54be5cbb6..1ce5c2e0c 100644 --- a/src/AasxServerBlazor/Program.cs +++ b/src/AasxServerBlazor/Program.cs @@ -37,6 +37,7 @@ public static IHostBuilder CreateHostBuilder(string[] args) => .ConfigureWebHostDefaults(webBuilder => { webBuilder + //.UseStartup() .UseStartup() .UseUrls("http://*:5000") /* diff --git a/src/AasxServerBlazor/Properties/launchSettings.json b/src/AasxServerBlazor/Properties/launchSettings.json index 22ca38275..942aefb3a 100644 --- a/src/AasxServerBlazor/Properties/launchSettings.json +++ b/src/AasxServerBlazor/Properties/launchSettings.json @@ -10,7 +10,7 @@ }, "AasxServerBlazor": { "commandName": "Project", - "commandLineArgs": "--data-path \"C:\\Development\\PCF\" --edit --external-blazor http://localhost:5001", + "commandLineArgs": "--no-security --data-path \"C:\\Development\\AASX\" --edit --external-blazor http://localhost:5001", "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development", diff --git a/src/AasxServerBlazor/Startup.cs b/src/AasxServerBlazor/Startup.cs index e5646b29c..d589940f9 100644 --- a/src/AasxServerBlazor/Startup.cs +++ b/src/AasxServerBlazor/Startup.cs @@ -1,22 +1,18 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Threading.Tasks; -using AasxServerBlazor.Data; -using IO.Swagger.V1RC03; -using IO.Swagger.V1RC03.APIModels.ValueOnly; -using IO.Swagger.V1RC03.Controllers; -using IO.Swagger.V1RC03.Filters; -using IO.Swagger.V1RC03.Logging; -using IO.Swagger.V1RC03.Middleware; -using IO.Swagger.V1RC03.Services; +using AasxServerBlazor.Data; +using AasxServerStandardBib.Extensions; +using AasxServerStandardBib.Interfaces; +using AasxServerStandardBib.Logging; +using AasxServerStandardBib.Services; +using IO.Swagger.Controllers; +using IO.Swagger.Filters; +using IO.Swagger.Lib.V3.Formatters; +using IO.Swagger.Lib.V3.Interfaces; +using IO.Swagger.Lib.V3.Middleware; +using IO.Swagger.Lib.V3.Services; //using IO.Swagger.Controllers; //using IO.Swagger.Filters; //using IO.Swagger.Services; -using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; -using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Http.Connections; using Microsoft.Extensions.Configuration; @@ -26,10 +22,13 @@ using Microsoft.OpenApi.Models; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Serialization; -using static Org.BouncyCastle.Math.EC.ECCurve; +using System; +using System.Collections.Generic; +using System.IO; namespace AasxServerBlazor { + //TODO:jtikekar change to startup instead of startupV3 public class Startup { private const string _corsPolicyName = "AllowAll"; @@ -61,7 +60,7 @@ public void ConfigureServices(IServiceCollection services) builder => { builder - .AllowAnyOrigin() + .AllowAnyOrigin() // Pass "Allowed Hosts" from appsettings.json .AllowAnyMethod() .AllowAnyHeader(); }); @@ -72,15 +71,27 @@ public void ConfigureServices(IServiceCollection services) services.AddControllers(); + services.AddLazyResolution(); + services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>)); - services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); - services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + //TODO:jtikekar uncomment + //services.AddTransient(); + //services.AddTransient(); + + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); + //services.AddTransient(); // Add framework services. services @@ -92,8 +103,11 @@ public void ConfigureServices(IServiceCollection services) { options.InputFormatters.RemoveType(); options.OutputFormatters.RemoveType(); - options.InputFormatters.Add(new AasCoreInputFormatter()); - options.OutputFormatters.Add(new AasCoreOutputFormatter()); + options.InputFormatters.Add(new AasRequestFormatter()); + options.OutputFormatters.Add(new AasResponseFormatter()); + //TODO:jtikekar uncomment + //options.InputFormatters.Add(new AasCoreInputFormatter()); + //options.OutputFormatters.Add(new AasCoreOutputFormatter()); }) .AddNewtonsoftJson(opts => { @@ -127,7 +141,8 @@ public void ConfigureServices(IServiceCollection services) TermsOfService = new Uri("https://github.com/admin-shell-io/aas-specs") }); - c.SchemaFilter(); + //TODO:jtikekar uncomment + //c.SchemaFilter(); //c.AddSecurityDefinition("basic", new OpenApiSecurityScheme //{ @@ -156,7 +171,8 @@ public void ConfigureServices(IServiceCollection services) c.EnableAnnotations(); c.CustomSchemaIds(type => type.FullName); - string swaggerCommentedAssembly = typeof(AssetAdministrationShellEnvironmentAPIController).Assembly.GetName().Name; + //string swaggerCommentedAssembly = typeof(AssetAdministrationShellEnvironmentAPIController).Assembly.GetName().Name; + string swaggerCommentedAssembly = typeof(AssetAdministrationShellRepositoryAPIApiController).Assembly.GetName().Name; c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{swaggerCommentedAssembly}.xml"); // Include DataAnnotation attributes on Controller Action parameters as Swagger validation rules (e.g required, pattern, ..) diff --git a/src/AasxServerBlazor/appsettings.json b/src/AasxServerBlazor/appsettings.json index 6de83bdd9..7ccdd2b84 100644 --- a/src/AasxServerBlazor/appsettings.json +++ b/src/AasxServerBlazor/appsettings.json @@ -8,10 +8,21 @@ }, "Logging": { "LogLevel": { - "Default": "Warning", + "Default": "Information", "Microsoft.*": "Warning" + }, + "Console": { + "LogLevel": { + "Default": "Debug", + "Microsoft.*": "Warning" + }, + "FormatterName": "simple", + "FormatterOptions": { + "SingleLine": true, + "TimestampFormat": "yyyy-MM-dd HH:mm:ss " + } } }, - "AllowedHosts": "*", - "SyntaxHighlight": false + "AllowedHosts": "*",//comma string + "SyntaxHighlight": true } diff --git a/src/AasxServerStandardBib/AasEntityBuilder.cs b/src/AasxServerStandardBib/AasEntityBuilder.cs index cb6a57c2d..43d64e0d6 100644 --- a/src/AasxServerStandardBib/AasEntityBuilder.cs +++ b/src/AasxServerStandardBib/AasEntityBuilder.cs @@ -7,15 +7,11 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt). This source code may use other Open Source software components (see LICENSE.txt). */ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using AasCore.Aas3_0_RC02; using AdminShellNS; -using Extenstions; using Opc.Ua; +using System.Collections.Generic; +using Extensions; namespace AasOpcUaServer { diff --git a/src/AasxServerStandardBib/AasEventMsgEnvelope.cs b/src/AasxServerStandardBib/AasEventMsgEnvelope.cs index 5ebfbb660..dbfba4261 100644 --- a/src/AasxServerStandardBib/AasEventMsgEnvelope.cs +++ b/src/AasxServerStandardBib/AasEventMsgEnvelope.cs @@ -10,17 +10,13 @@ This source code may use other Open Source software components (see LICENSE.txt) // to be disabled for AASX Server // #define UseMarkup -using System; -using System.Collections.Generic; -using System.Globalization; -using System.Linq; -using System.Text; -using System.Threading.Tasks; using AasCore.Aas3_0_RC02; using AasxIntegrationBase; -using AdminShellNS; -using Extenstions; using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Globalization; +using Extensions; namespace AdminShellEvents { diff --git a/src/AasxServerStandardBib/AasUaEntities.cs b/src/AasxServerStandardBib/AasUaEntities.cs index b9171c5b1..941f2a6e9 100644 --- a/src/AasxServerStandardBib/AasUaEntities.cs +++ b/src/AasxServerStandardBib/AasUaEntities.cs @@ -7,17 +7,13 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt). This source code may use other Open Source software components (see LICENSE.txt). */ +using AasCore.Aas3_0_RC02; +using Extensions; +using Opc.Ua; using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using AasCore.Aas3_0_RC02; -using AdminShellNS; -using Extenstions; -using Opc.Ua; // TODO (MIHO, 2020-08-29): The UA mapping needs to be overworked in order to comply the joint aligment with I4AAS // TODO (MIHO, 2020-08-29): The UA mapping needs to be checked for the "new" HasDataSpecification strcuture of V2.0.1 @@ -719,10 +715,10 @@ public NodeState CreateAddInstanceObject(NodeState parent, this.entityBuilder.AasTypes.Administration.CreateAddElements( o, CreateMode.Instance, aas.Administration); // HasDataSpecification - if (aas.DataSpecifications != null && aas.DataSpecifications != null) - foreach (var ds in aas.DataSpecifications) + if (aas.EmbeddedDataSpecifications != null && aas.EmbeddedDataSpecifications != null) + foreach (var ds in aas.EmbeddedDataSpecifications) this.entityBuilder.AasTypes.Reference.CreateAddElements( - o, CreateMode.Instance, ds, "DataSpecification"); + o, CreateMode.Instance, ds.DataSpecification, "DataSpecification"); // own attributes this.entityBuilder.AasTypes.Reference.CreateAddElements( o, CreateMode.Instance, aas.DerivedFrom, "DerivedFrom"); @@ -843,10 +839,10 @@ public NodeState CreateAddElements(NodeState parent, CreateMode mode, Submodel s this.entityBuilder.AasTypes.ModelingKind.CreateAddElements( o, CreateMode.Instance, (ModelingKind)sm.Kind); // HasDataSpecification - if (sm.DataSpecifications != null && sm.DataSpecifications != null) - foreach (var ds in sm.DataSpecifications) + if (sm.EmbeddedDataSpecifications != null && sm.EmbeddedDataSpecifications != null) + foreach (var ds in sm.EmbeddedDataSpecifications) this.entityBuilder.AasTypes.Reference.CreateAddElements( - o, CreateMode.Instance, ds, "DataSpecification"); + o, CreateMode.Instance, ds.DataSpecification, "DataSpecification"); // Qualifiable if (sm.Qualifiers != null) foreach (var q in sm.Qualifiers) @@ -932,10 +928,10 @@ public NodeState PopulateInstanceObject(NodeState o, ISubmodelElement sme) this.entityBuilder.AasTypes.ModelingKind.CreateAddElements( o, CreateMode.Instance, (ModelingKind)sme.Kind); // HasDataSpecification - if (sme.DataSpecifications != null && sme.DataSpecifications != null) - foreach (var ds in sme.DataSpecifications) + if (sme.EmbeddedDataSpecifications != null && sme.EmbeddedDataSpecifications != null) + foreach (var ds in sme.EmbeddedDataSpecifications) this.entityBuilder.AasTypes.Reference.CreateAddElements( - o, CreateMode.Instance, ds, "DataSpecification"); + o, CreateMode.Instance, ds.DataSpecification, "DataSpecification"); // Qualifiable if (sme.Qualifiers != null) foreach (var q in sme.Qualifiers) diff --git a/src/AasxServerStandardBib/AasUaUtils.cs b/src/AasxServerStandardBib/AasUaUtils.cs index acd30329d..901969d20 100644 --- a/src/AasxServerStandardBib/AasUaUtils.cs +++ b/src/AasxServerStandardBib/AasUaUtils.cs @@ -57,23 +57,23 @@ public static List ToOpcUaReferenceList(Reference refid) return res; } - public static LocalizedText[] GetUaLocalizedTexts(LangStringSet ls) + public static LocalizedText[] GetUaLocalizedTexts(List ls) { - if (ls == null || ls.LangStrings.Count < 1) + if (ls == null || ls.Count < 1) return new LocalizedText[] { new LocalizedText("", "") }; - var res = new LocalizedText[ls.LangStrings.Count]; - for (int i = 0; i < ls.LangStrings.Count; i++) - res[i] = new LocalizedText(ls.LangStrings[i].Language, ls.LangStrings[i].Text); + var res = new LocalizedText[ls.Count]; + for (int i = 0; i < ls.Count; i++) + res[i] = new LocalizedText(ls[i].Language, ls[i].Text); return res; } - public static LocalizedText GetBestUaDescriptionFromAasDescription(LangStringSet desc) + public static LocalizedText GetBestUaDescriptionFromAasDescription(List desc) { var res = new LocalizedText("", ""); - if (desc != null && desc.LangStrings != null) + if (desc != null && desc != null) { var found = false; - foreach (var ls in desc.LangStrings) + foreach (var ls in desc) if (!found || ls.Language.Trim().ToLower().StartsWith("en")) { found = true; diff --git a/src/AasxServerStandardBib/AasxCompatibilityModels/V20/AdminShellValidateV20.cs b/src/AasxServerStandardBib/AasxCompatibilityModels/V20/AdminShellValidateV20.cs deleted file mode 100644 index fad75ca2f..000000000 --- a/src/AasxServerStandardBib/AasxCompatibilityModels/V20/AdminShellValidateV20.cs +++ /dev/null @@ -1,318 +0,0 @@ -/* -Copyright (c) 2018-2021 Festo AG & Co. KG -Author: Michael Hoffmeister - -This source code is licensed under the Apache License 2.0 (see LICENSE.txt). - -This source code may use other Open Source software components (see LICENSE.txt). -*/ - -using System; -using System.Collections.Generic; -using System.ComponentModel.Design; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Xml; -using System.Xml.Schema; -using JetBrains.Annotations; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Schema; - -// ReSharper disable All .. as this is legacy code! - -#if !DoNotUseAasxCompatibilityModels - -namespace AasxCompatibilityModels -{ - public class XmlValidatorV20 - { - private System.Xml.Schema.XmlSchemaSet xmlSchemaSet; - - internal XmlValidatorV20(XmlSchemaSet xmlSchemaSet) - { - this.xmlSchemaSet = xmlSchemaSet; - } - - /// - /// validates the given XML content and stores the results in the . - /// - /// Validation records - /// Content to be validated - public void Validate(AasValidationRecordListV20 recs, Stream xmlContent) - { - if (recs == null) - throw new ArgumentException($"Unexpected null {nameof(recs)}"); - - if (xmlContent == null) - throw new ArgumentException($"Unexpected null {nameof(xmlContent)}"); - - // load/ validate on same records - var settings = new System.Xml.XmlReaderSettings(); - settings.ValidationType = System.Xml.ValidationType.Schema; - settings.Schemas = xmlSchemaSet; - - settings.ValidationEventHandler += - (object sender, System.Xml.Schema.ValidationEventArgs e) => - { - recs.Add( - new AasValidationRecordV20( - AasValidationSeverityV20.Serialization, null, - $"XML: {e?.Exception?.LineNumber}, {e?.Exception?.LinePosition}: {e?.Message}")); - }; - - // use the xml stream - using (var reader = System.Xml.XmlReader.Create(xmlContent, settings)) - { - while (reader.Read()) - { - // Invoke callbacks - }; - } - } - } - - public enum AasValidationSeverityV20 - { - Hint, Warning, SpecViolation, SchemaViolation, Serialization - } - - [UsedImplicitlyAttribute] // for eventual use - public enum AasValidationActionV20 - { - No, ToBeDeleted - } - - public class AasValidationRecordV20 - { - public AasValidationSeverityV20 Severity = AasValidationSeverityV20.Hint; - public AdminShellV20.Referable Source = null; - public string Message = ""; - - public Action Fix = null; - - public AasValidationRecordV20(AasValidationSeverityV20 Severity, AdminShellV20.Referable Source, - string Message, Action Fix = null) - { - this.Severity = Severity; - this.Source = Source; - this.Message = Message; - this.Fix = Fix; - } - - public override string ToString() - { - return $"[{Severity.ToString()}] in {"" + Source?.ToString()}: {"" + Message}"; - } - - public string DisplaySeverity { get { return "" + Severity.ToString(); } } - public string DisplaySource - { - get - { - return "" + ((Source != null) ? Source.ToString() : "(whole content)"); - } - } - public string DisplayMessage { get { return "" + Message?.ToString(); } } - } - - public class AasValidationRecordListV20 : List - { - } - - public static class AasSchemaValidationV20 - { - public enum SerializationFormat { XML, JSON } - - public static string[] GetSchemaResources(SerializationFormat fmt) - { - if (fmt == SerializationFormat.XML) - { - return new[] - { - "AdminShellNS.Resources.schemaV201.AAS.xsd", - "AdminShellNS.Resources.schemaV201.AAS_ABAC.xsd", - "AdminShellNS.Resources.schemaV201.IEC61360.xsd" - }; - } - if (fmt == SerializationFormat.JSON) - { - return new[] - { - "AdminShellNS.Resources.schemaV201.aas.json" - }; - } - return null; - } - - /// - /// produces a validator which validates XML AASX files. - /// - /// initialized validator - public static XmlValidatorV20 NewXmlValidator() - { - // Load the schema files - var files = GetSchemaResources(SerializationFormat.XML); - if (files == null) - throw new InvalidOperationException("No XML schema files could be found in the resources."); - - var xmlSchemaSet = new System.Xml.Schema.XmlSchemaSet(); - xmlSchemaSet.XmlResolver = new System.Xml.XmlUrlResolver(); - - try - { - Assembly myAssembly = Assembly.GetExecutingAssembly(); - foreach (var schemaFn in files) - { - using (Stream schemaStream = myAssembly.GetManifestResourceStream(schemaFn)) - { - using (XmlReader schemaReader = XmlReader.Create(schemaStream)) - { - xmlSchemaSet.Add(null, schemaReader); - } - } - } - } - catch (Exception ex) - { - throw new FileNotFoundException( - $"Error accessing embedded resource schema files: {ex.Message}"); - } - - var newRecs = new AasValidationRecordListV20(); - - // set up messages - xmlSchemaSet.ValidationEventHandler += (object sender, System.Xml.Schema.ValidationEventArgs e) => - { - newRecs.Add( - new AasValidationRecordV20( - AasValidationSeverityV20.Serialization, null, - $"{e?.Exception?.LineNumber}, {e?.Exception?.LinePosition}: {e?.Message}")); - }; - - // compile - try - { - xmlSchemaSet.Compile(); - } - catch (Exception ex) - { - throw new InvalidOperationException( - $"Error compiling schema files: {ex.Message}"); - } - - if (newRecs.Count > 0) - { - var parts = new List { $"Failed to compile the schema files:" }; - parts.AddRange(newRecs.Select((r) => r.Message)); - throw new InvalidOperationException(string.Join(Environment.NewLine, parts)); - } - - return new XmlValidatorV20(xmlSchemaSet); - } - - public static void ValidateXML(AasValidationRecordListV20 recs, Stream xmlContent) - { - var validator = NewXmlValidator(); - validator.Validate(recs, xmlContent); - } - - public static int ValidateJSONAlternative(AasValidationRecordListV20 recs, Stream jsonContent) - { - // see: https://github.com/RicoSuter/NJsonSchema/wiki/JsonSchemaValidator - var newRecs = new AasValidationRecordListV20(); - - // access - if (recs == null || jsonContent == null) - return -1; - - // Load the schema files - // right now: exactly ONE schema file - var files = GetSchemaResources(SerializationFormat.JSON); - if (files == null || files.Length != 1) - return -1; - - NJsonSchema.JsonSchema schema = null; - - try - { - Assembly myAssembly = Assembly.GetExecutingAssembly(); - foreach (var schemaFn in files) - { - using (Stream schemaStream = myAssembly.GetManifestResourceStream(schemaFn)) - { - using (var streamReader = new StreamReader(schemaStream)) - { - var allTxt = streamReader.ReadToEnd(); - schema = NJsonSchema.JsonSchema.FromJsonAsync(allTxt).GetAwaiter().GetResult(); - break; - } - } - } - } - catch (Exception ex) - { - throw new FileNotFoundException("ValidateJSON: Error loading schema: " + - ex.Message); - } - - if (schema == null) - { - throw new FileNotFoundException("ValidateJSON: Schema not found properly."); - } - - // create validator - var validator = new NJsonSchema.Validation.JsonSchemaValidator(); - - // load the JSON content - string jsonTxt = null; - try - { - using (var streamReader = new StreamReader(jsonContent)) - { - jsonTxt = streamReader.ReadToEnd(); - } - } - catch (Exception ex) - { - throw new InvalidOperationException("ValidateJSON: Error loading JSON content: " + - ex.Message); - } - - if (jsonTxt == null || jsonTxt == "") - throw new InvalidOperationException("ValidateJSON: Error loading JSON content gave null."); - - // validate - ICollection errors; - try - { - errors = validator.Validate(jsonTxt, schema); - } - catch (Exception ex) - { - throw new InvalidOperationException("ValidateJSON: Error when validating: " + - ex.Message); - } - - // re-format messages - if (errors != null) - foreach (var ve in errors) - { - var msg = ("" + ve.ToString()); - msg = Regex.Replace(msg, @"\s+", " "); - newRecs.Add(new AasValidationRecordV20(AasValidationSeverityV20.Serialization, null, - $"JSON: {ve.LineNumber,5},{ve.LinePosition:3}: {msg}")); - } - - // result - recs.AddRange(newRecs); - return newRecs.Count; - } - } -} - -#endif \ No newline at end of file diff --git a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell.cs b/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell.cs deleted file mode 100644 index d2b95b9ba..000000000 --- a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell.cs +++ /dev/null @@ -1,2064 +0,0 @@ -/* -Copyright (c) 2018-2021 Festo AG & Co. KG -Author: Michael Hoffmeister - -This source code is licensed under the Apache License 2.0 (see LICENSE.txt). - -This source code may use other Open Source software components (see LICENSE.txt). -*/ - -using AdminShellNS; -using Newtonsoft.Json; -using System; -using System.Collections; -using System.Collections.Generic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using System.Xml.Serialization; - -//namespace AdminShellNS -namespace AdminShell_V30 -{ - /// - /// This empty class derives always from the current version of the Administration Shell class hierarchy. - /// - public class AdminShell : AdminShellV30 { } - - #region AdminShell_V3_0 - - public partial class AdminShellV30 - { - // - // Version - // - - /// - /// Major version of the meta-model - /// - [XmlIgnore] - [JsonIgnore] - public static string MetaModelVersionCoarse = "AAS3.0"; - - /// - /// Minor version (extension) of the meta-model. - /// Should be added to MetaModelVersionCoarse - /// - [XmlIgnore] - [JsonIgnore] - public static string MetaModelVersionFine = "RC02"; - - // - // Interfaces - // - - /// - /// Extends understanding of Referable to further elements, which can be related to - /// - public interface IAasElement - { - AasElementSelfDescription GetSelfDescription(); - string GetElementName(); - } - - /// - /// This class allows to describe further data (in derived classes) when enumerating Children. - /// - public class EnumerationPlacmentBase - { - } - - /// - /// This interfaces designates enitities, whích can enumerate their children. - /// An optional placement can be provided (in/ out/ inout, index, ..) - /// - public interface IEnumerateChildren - { - IEnumerable EnumerateChildren(); - EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child); - object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null); - } - - public interface IValidateEntity - { - void Validate(AasValidationRecordList results); - } - - /// - /// Marks an object, preferaby a payload item, which might be featured by the diary collection - /// - public interface IAasDiaryEntry - { - } - - /// - /// Marks every entity which features DiaryData, for derivation of AAS event flow - /// - public interface IDiaryData - { - DiaryDataDef DiaryData { get; } - } - - - public interface IRecurseOnReferables - { - void RecurseOnReferables( - object state, Func lambda, - bool includeThis = false); - } - - /// - /// Use by FindAllReference to provide a enumeration of referenced with location - /// info, where they are contained - /// - public class LocatedReference - { - public Identifiable Identifiable; - - // ReSharper disable once MemberHidesStaticFromOuterClass - public ModelReference Reference; - - public LocatedReference() { } - public LocatedReference(Identifiable identifiable, ModelReference reference) - { - Identifiable = identifiable; - Reference = reference; - } - } - - public interface IFindAllReferences - { - IEnumerable FindAllReferences(); - } - - public interface IGetSemanticId - { - SemanticId GetSemanticId(); - } - - /// - /// This interface marks an entity, which can provide a ModelReference of itself. - /// Typically, these are Referables or Identifiables. - /// - public interface IGetModelReference - { - ModelReference GetModelReference(bool includeParents = true); - } - - /// - /// This interface marks an entity, which can provide a GlobaleReference of itself. - /// These entities are much more rare. - /// - public interface IGetGlobalReference - { - GlobalReference GetGlobalReference(); - } - - public interface IGetQualifiers - { - QualifierCollection GetQualifiers(); - } - - public interface IManageSubmodelElements - { - void Add(SubmodelElement sme); - void Insert(int index, SubmodelElement sme); - void Remove(SubmodelElement sme); - } - - // - // Attributes - // - - /// - /// This attribute indicates, that it should e.g. serialized in JSON. - /// - [System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = true)] - public class CountForHash : System.Attribute - { - } - - /// - /// This attribute indicates, that evaluation shall not count following field or not dive into references. - /// - [System.AttributeUsage(System.AttributeTargets.Field, AllowMultiple = true)] - public class SkipForHash : System.Attribute - { - } - - /// - /// 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; - } - } - - /// - /// 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 - { - } - - /// - /// 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 - { - } - - /// - /// This attribute indicates, that the field / property is searchable - /// - [System.AttributeUsage(System.AttributeTargets.Field | System.AttributeTargets.Property, AllowMultiple = true)] - public class TextSearchable : System.Attribute - { - } - - // - // Serialization helpers - // - - public class JsonModelTypeWrapper - { - public string name = ""; - - public JsonModelTypeWrapper(string name = "") { this.name = name; } - } - - // - // Administration - // - - public class Administration - { - - // members - - [MetaModelName("Administration.version")] - [TextSearchable] - [CountForHash] - public string version = ""; - - [MetaModelName("Administration.revision")] - [TextSearchable] - [CountForHash] - public string revision = ""; - - // constructors - - public Administration() { } - - public Administration(Administration src) - { - this.version = src.version; - this.revision = src.revision; - } - -#if !DoNotUseAasxCompatibilityModels - public Administration(AasxCompatibilityModels.AdminShellV10.Administration src) - { - this.version = src.version; - this.revision = src.revision; - } - - public Administration(AasxCompatibilityModels.AdminShellV20.Administration src) - { - this.version = src.version; - this.revision = src.revision; - } -#endif - - public Administration(string version, string revision) - { - this.version = version; - this.revision = revision; - } - - public override string ToString() - { - return $"R={this.version}, V={this.revision}"; - } - } - - // - // Self description (not in the meta model!) - // - - public class AasElementSelfDescription - { - public string ElementName = ""; - public string ElementAbbreviation = ""; - public SubmodelElementWrapper.AdequateElementEnum ElementEnum = - SubmodelElementWrapper.AdequateElementEnum.Unknown; - - public AasElementSelfDescription() { } - - public AasElementSelfDescription( - string ElementName, string ElementAbbreviation, - SubmodelElementWrapper.AdequateElementEnum elementEnum - = SubmodelElementWrapper.AdequateElementEnum.Unknown) - { - this.ElementName = ElementName; - this.ElementAbbreviation = ElementAbbreviation; - this.ElementEnum = elementEnum; - } - } - - // - // Data Specification - // - - // Note: In versions prior to V2.0.1, the SDK has "HasDataSpecification" containing only a Reference. - // Iv 2.0.1, theoretically each entity with HasDataSpecification could also conatin a - // EmbeddedDataSpecification. - - [XmlType(TypeName = "hasDataSpecification")] - public class HasDataSpecification : List - { - public HasDataSpecification() { } - - public HasDataSpecification(HasDataSpecification src) - { - foreach (var r in src) - this.Add(new EmbeddedDataSpecification(r)); - } - - public HasDataSpecification(IEnumerable src) - { - foreach (var r in src) - this.Add(new EmbeddedDataSpecification(r)); - } - -#if !DoNotUseAasxCompatibilityModels - public HasDataSpecification(AasxCompatibilityModels.AdminShellV10.HasDataSpecification src) - { - foreach (var r in src.reference) - this.Add(new EmbeddedDataSpecification(r)); - } - - public HasDataSpecification(AasxCompatibilityModels.AdminShellV20.HasDataSpecification src) - { - foreach (var r in src) - this.Add(new EmbeddedDataSpecification(r)); - } - - // make some explicit and easy to use getter, setters - - [XmlIgnore] - [JsonIgnore] - public EmbeddedDataSpecification IEC61360 - { - get - { - foreach (var eds in this) - if (eds?.dataSpecificationContent?.dataSpecificationIEC61360 != null - || eds?.dataSpecification?.Matches( - DataSpecificationIEC61360.GetIdentifier(), Key.MatchMode.Identification) == true) - return eds; - return null; - } - set - { - // search existing first? - var eds = this.IEC61360; - if (eds != null) - { - // replace this - /* TODO (MIHO, 2020-08-30): this does not prevent the corner case, that we could have - * multiple dataSpecificationIEC61360 in this list, which would be an error */ - this.Remove(eds); - this.Add(value); - return; - } - - // no? .. add! - this.Add(value); - } - } - - [XmlIgnore] - [JsonIgnore] - public DataSpecificationIEC61360 IEC61360Content - { - get - { - return this.IEC61360?.dataSpecificationContent?.dataSpecificationIEC61360; - } - set - { - // search existing first? - var eds = this.IEC61360; - if (eds != null) - { - // replace this - eds.dataSpecificationContent.dataSpecificationIEC61360 = value; - return; - } - // no? .. add! - var edsnew = new EmbeddedDataSpecification(); - edsnew.dataSpecificationContent.dataSpecificationIEC61360 = value; - this.Add(edsnew); - } - } - - } -#endif - - // - // Lang Str - // - - [XmlType(TypeName = "langString", Namespace = "http://www.admin-shell.io/3/0")] - public class LangStr - { - // constants - public static string LANG_DEFAULT = "en"; - - // members - - [MetaModelName("LangStr.lang")] - [TextSearchable] - [XmlAttribute(Namespace = "http://www.admin-shell.io/3/0")] - [JsonProperty(PropertyName = "language")] - [CountForHash] - public string lang = ""; - - [MetaModelName("LangStr.str")] - [TextSearchable] - [XmlText] - [JsonProperty(PropertyName = "text")] - [CountForHash] - public string str = ""; - - // constructors - - public LangStr() { } - - public LangStr(LangStr src) - { - this.lang = src.lang; - this.str = src.str; - } - -#if !DoNotUseAasxCompatibilityModels - public LangStr(AasxCompatibilityModels.AdminShellV10.LangStr src) - { - this.lang = src.lang; - this.str = src.str; - } - - public LangStr(AasxCompatibilityModels.AdminShellV20.LangStr src) - { - this.lang = src.lang; - this.str = src.str; - } -#endif - - public LangStr(string lang, string str) - { - this.lang = lang; - this.str = str; - } - - public static ListOfLangStr CreateManyFromStringArray(string[] s) - { - var r = new ListOfLangStr(); - var i = 0; - while ((i + 1) < s.Length) - { - r.Add(new LangStr(s[i], s[i + 1])); - i += 2; - } - return r; - } - - public override string ToString() - { - return $"{str}@{lang}"; - } - } - - public class ListOfLangStr : List - { - public ListOfLangStr() { } - - public ListOfLangStr(LangStr ls) - { - if (ls != null) - this.Add(ls); - } - - public ListOfLangStr(ListOfLangStr src) - { - if (src != null) - foreach (var ls in src) - this.Add(ls); - } - - public string this[string lang] - { - get - { - return GetDefaultStr(lang); - } - set - { - foreach (var ls in this) - if (ls.lang.Trim().ToLower() == lang?.Trim().ToLower()) - { - ls.str = value; - return; - } - this.Add(new LangStr(lang, value)); - } - } - - public string GetDefaultStr(string defaultLang = null) - { - // start - if (defaultLang == null) - defaultLang = LangStr.LANG_DEFAULT; - defaultLang = defaultLang.Trim().ToLower(); - string res = null; - - // search - foreach (var ls in this) - if (ls.lang.Trim().ToLower() == defaultLang) - res = ls.str; - if (res == null && this.Count > 0) - res = this[0].str; - - // found? - return res; - } - - public bool AllLangSameString() - { - if (this.Count < 2) - return true; - - for (int i = 1; i < this.Count; i++) - if (this[0]?.str != null && this[0]?.str?.Trim() != this[i]?.str?.Trim()) - return false; - - return true; - } - - public override string ToString() - { - return string.Join(", ", this.Select((ls) => ls.ToString())); - } - - public static ListOfLangStr Parse(string cell) - { - // access - if (cell == null) - return null; - - // iterative approach - var res = new ListOfLangStr(); - while (true) - { - // trivial case and finite end - if (!cell.Contains("@")) - { - if (cell.Trim() != "") - res.Add(new LangStr(LangStr.LANG_DEFAULT, cell)); - break; - } - - // OK, pick the next couple - var m = Regex.Match(cell, @"(.*?)@(\w+)", RegexOptions.Singleline); - if (!m.Success) - { - // take emergency exit? - res.Add(new LangStr("??", cell)); - break; - } - - // use the match and shorten cell .. - res.Add(new LangStr(m.Groups[2].ToString(), m.Groups[1].ToString().Trim())); - cell = cell.Substring(m.Index + m.Length); - } - - return res; - } - } - - // - // DisplayName - // - - public class DisplayName - { - - // members - - [XmlElement(ElementName = "langString")] - public ListOfLangStr langString = new ListOfLangStr(); - - // constructors - - public DisplayName() { } - - public DisplayName(Description src) - { - if (src != null && src.langString != null) - foreach (var ls in src.langString) - langString.Add(new LangStr(ls)); - } - - public DisplayName(LangStringSet src) - { - if (src != null && src.langString != null) - foreach (var ls in src.langString) - langString.Add(new LangStr(ls)); - } - -#if !DoNotUseAasxCompatibilityModels - // new in V3.0 -#endif - - // further - [XmlIgnore] - [JsonIgnore] - public bool IsValid { get { return langString != null && langString.Count >= 1; } } - - // single string representation - public string GetDefaultStr(string defaultLang = null) - { - return this.langString?.GetDefaultStr(defaultLang); - } - - } - - // - // Description - // - - public class Description - { - - // members - - [XmlElement(ElementName = "langString")] - public ListOfLangStr langString = new ListOfLangStr(); - - // constructors - - public Description() { } - - public Description(Description src) - { - if (src != null && src.langString != null) - foreach (var ls in src.langString) - langString.Add(new LangStr(ls)); - } - - public Description(LangStringSet src) - { - if (src != null && src.langString != null) - foreach (var ls in src.langString) - langString.Add(new LangStr(ls)); - } - -#if !DoNotUseAasxCompatibilityModels - public Description(AasxCompatibilityModels.AdminShellV10.Description src) - { - if (src != null) - foreach (var ls in src.langString) - langString.Add(new LangStr(ls)); - } - - public Description(AasxCompatibilityModels.AdminShellV20.Description src) - { - if (src != null && src.langString != null) - foreach (var ls in src.langString) - langString.Add(new LangStr(ls)); - } -#endif - - // further - [XmlIgnore] - [JsonIgnore] - public bool IsValid { get { return langString != null && langString.Count >= 1; } } - - // single string representation - public string GetDefaultStr(string defaultLang = null) - { - return this.langString?.GetDefaultStr(defaultLang); - } - - } - - // - // Kinds - // - - public class AssetKind - { - // constants - public static string Type = "Type"; - public static string Instance = "Instance"; - - [MetaModelName("AssetKind.kind")] - [TextSearchable] - [XmlText] - [CountForHash] - public string kind = "Instance"; - - // getters / setters - - [XmlIgnore] - [JsonIgnore] - public bool IsInstance { get { return kind == null || kind.Trim().ToLower() == "instance"; } } - - [XmlIgnore] - [JsonIgnore] - public bool IsType { get { return kind != null && kind.Trim().ToLower() == "type"; } } - - // constructors / creators - - public AssetKind() { } - - public AssetKind(AssetKind src) - { - kind = src.kind; - } - -#if !DoNotUseAasxCompatibilityModels - public AssetKind(AasxCompatibilityModels.AdminShellV10.Kind src) - { - kind = src.kind; - } - - public AssetKind(AasxCompatibilityModels.AdminShellV20.AssetKind src) - { - kind = src.kind; - } -#endif - - public AssetKind(string kind) - { - this.kind = kind; - } - - public static AssetKind CreateAsType() - { - var res = new AssetKind() { kind = AssetKind.Type }; - return res; - } - - public static AssetKind CreateAsInstance() - { - var res = new AssetKind() { kind = AssetKind.Instance }; - return res; - } - } - - public class ModelingKind - { - // constants - public static string Template = "Template"; - public static string Instance = "Instance"; - - [MetaModelName("ModelingKind.kind")] - [TextSearchable] - [XmlText] - [CountForHash] - public string kind = Instance; - - // getters / setters - - [XmlIgnore] - [JsonIgnore] - public bool IsInstance { get { return kind == null || kind.Trim().ToLower() == Instance.ToLower(); } } - - [XmlIgnore] - [JsonIgnore] - public bool IsTemplate { get { return kind != null && kind.Trim().ToLower() == Template.ToLower(); } } - - // constructors / creators - - public ModelingKind() { } - - public ModelingKind(ModelingKind src) - { - kind = src.kind; - } - -#if !DoNotUseAasxCompatibilityModels - public ModelingKind(AasxCompatibilityModels.AdminShellV10.Kind src) - { - kind = src.kind; - } - - public ModelingKind(AasxCompatibilityModels.AdminShellV20.ModelingKind src) - { - kind = src.kind; - } -#endif - - public ModelingKind(string kind) - { - this.kind = kind; - } - - public static ModelingKind CreateAsTemplate() - { - var res = new ModelingKind() { kind = Template }; - return res; - } - - public static ModelingKind CreateAsInstance() - { - var res = new ModelingKind() { kind = Instance }; - return res; - } - - // validation - - public static void Validate(AasValidationRecordList results, ModelingKind mk, Referable container) - { - // access - if (results == null || container == null) - return; - - // check - if (mk == null || mk.kind == null) - { - // warning - results.Add(new AasValidationRecord( - AasValidationSeverity.Warning, container, - "ModelingKind: is null", - () => - { - })); - } - else - { - var k = mk.kind.Trim(); - var kl = k.ToLower(); - if (kl != Template.ToLower() && kl != Instance.ToLower()) - { - // violation case - results.Add(new AasValidationRecord( - AasValidationSeverity.SchemaViolation, container, - $"ModelingKind: enumeration value neither {Template} nor {Instance}", - () => - { - mk.kind = Instance; - })); - } - else if (k != Template && k != Instance) - { - // warning - results.Add(new AasValidationRecord( - AasValidationSeverity.Warning, container, - "ModelingKind: enumeration value in wrong casing", - () => - { - if (kl == Template.ToLower()) - mk.kind = Template; - else - mk.kind = Instance; - })); - } - } - } - } - - // - // Extensions attached to each Referable - // - - /// - /// Single extension of an element. - /// - public class Extension : IGetSemanticId - { - // members - - // from hasSemantics: - [XmlElement(ElementName = "semanticId")] - public SemanticId semanticId = null; - public SemanticId GetSemanticId() => semanticId; - - // this class - - /// - /// Name of the extension. The name of an extension within ListOfExtension - /// needs to be unique. - /// - public string name = ""; - - /// - /// Type of the value of the extension. - /// - public string valueType = "xsd:string"; - - /// - /// Value of the extension. In meta model this is ValueDataType, but in this SDK - /// its just a plain string. Appropriate serialization needs to happen. - /// Note: this string can VERY HUGE, i.e. an XML document on its own. - /// - public string value = ""; - - /// - /// Reference to (multiple) elements the extension refers to. - /// - public List refersTo = null; - } - - /// - /// Allows each Referable to hold multiple Extensions. - /// - public class ListOfExtension : List - { - } - - // - // hierarchical organized time stamping and transaction approach, coined "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(Referable 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 Referable)?.parent as IDiaryData; - } - } - } - - public class ListOfReferable : List - { - // conversion to other list - - public KeyList ToKeyList() - { - var res = new KeyList(); - foreach (var rf in this) - res.Add(rf.ToKey()); - return res; - } - - public ModelReference GetReference() - { - return ModelReference.CreateNew(ToKeyList()); - } - } - - public class Referable : IValidateEntity, IAasElement, IDiaryData, IGetModelReference, IRecurseOnReferables - { - // diary - - [XmlIgnore] - [JsonIgnore] - [SkipForHash] - [SkipForReflection] - private DiaryDataDef _diaryData = new DiaryDataDef(); - - [XmlIgnore] - [JsonIgnore] - [SkipForReflection] - public DiaryDataDef DiaryData { get { return _diaryData; } } - - // from HasExtension - public ListOfExtension extension = null; - - #region Timestamp - - [XmlIgnore] - [JsonIgnore] - [SkipForHash] // important to skip, as recursion elsewise will go in cycles! - [SkipForReflection] // important to skip, as recursion elsewise will go in cycles! - public DateTime TimeStampCreate; - - [XmlIgnore] - [JsonIgnore] - [SkipForHash] // important to skip, as recursion elsewise will go in cycles! - [SkipForReflection] // important to skip, as recursion elsewise will go in cycles! - public DateTime TimeStamp; - - public void setTimeStamp(DateTime timeStamp) - { - Referable r = this; - - do - { - r.TimeStamp = timeStamp; - if (r != r.parent) - { - r = (Referable)r.parent; - } - else - r = null; - } - while (r != null); - } - - public void SetAllTimeStamps(DateTime timeStamp, DateTime timeStampCreate) - { - TimeStamp = timeStamp; - TimeStampCreate = timeStampCreate; - - // via interface enumaration - if (this is IEnumerateChildren) - { - var childs = (this as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - c.submodelElement.SetAllTimeStamps(timeStamp, timeStampCreate); - } - } - - public void SetAllTimeStamps(DateTime timeStamp) - { - TimeStamp = timeStamp; - TimeStampCreate = timeStamp; - - // via interface enumaration - if (this is IEnumerateChildren) - { - var childs = (this as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - c.submodelElement.SetAllTimeStamps(timeStamp); - } - } - - public void SetAllParents(Referable parent, DateTime timeStamp) - { - if (parent == null) - return; - - this.parent = parent; - this.TimeStamp = timeStamp; - this.TimeStampCreate = timeStamp; - - // via interface enumaration - if (this is IEnumerateChildren) - { - var childs = (this as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - c.submodelElement.SetAllParents(this, timeStamp); - } - } - - public void SetAllParentsAndTimestamps(Referable parent, DateTime timeStamp, DateTime timeStampCreate) - { - if (parent == null) - return; - - this.parent = parent; - this.TimeStamp = timeStamp; - this.TimeStampCreate = timeStampCreate; - - // via interface enumaration - if (this is IEnumerateChildren) - { - var childs = (this as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - c.submodelElement.SetAllParentsAndTimestamps(this, timeStamp, timeStampCreate); - } - } - - public Submodel getParentSubmodel() - { - Referable parent = this; - while (!(parent is Submodel) && parent != null) - parent = (Referable)parent.parent; - return parent as Submodel; - } - - #endregion Timestamp - - // members - - [MetaModelName("Referable.idShort")] - [TextSearchable] - [CountForHash] - public string idShort = ""; - - [XmlElement(ElementName = "displayName")] - [JsonIgnore] - [CountForHash] - public DisplayName displayName = null; - - [XmlIgnore] - [JsonProperty(PropertyName = "displayNames")] - public ListOfLangStr JsonDisplayName - { - get - { - return displayName?.langString; - } - set - { - if (value == null) - { - displayName = null; - return; - } - - if (displayName == null) - displayName = new DisplayName(); - displayName.langString = value; - } - } - - [MetaModelName("Referable.category")] - [TextSearchable] - [CountForHash] - public string category = null; - - [XmlElement(ElementName = "description")] - [JsonIgnore] - [CountForHash] - public Description description = null; - - [XmlIgnore] - [JsonProperty(PropertyName = "descriptions")] - public ListOfLangStr JsonDescription - { - get - { - return description?.langString; - } - set - { - if (value == null) - { - description = null; - return; - } - - if (description == null) - description = new Description(); - description.langString = value; - } - } - - [MetaModelName("Referable.checksum")] - public string checksum = ""; - - [XmlIgnore] - [JsonIgnore] - [SkipForHash] // important to skip, as recursion elsewise will go in cycles! - [SkipForReflection] // important to skip, as recursion elsewise will go in cycles! - public IAasElement parent = null; - - public static string CONSTANT = "CONSTANT"; - public static string Category_PARAMETER = "PARAMETER"; - public static string VARIABLE = "VARIABLE"; - - public static string[] ReferableCategoryNames = new string[] { CONSTANT, Category_PARAMETER, VARIABLE }; - - // constructors - - public Referable() { } - - public Referable(string idShort) - { - this.idShort = idShort; - } - - public Referable(Referable src) - { - if (src == null) - return; - this.idShort = src.idShort; - this.category = src.category; - if (src.description != null) - this.description = new Description(src.description); - } - -#if !DoNotUseAasxCompatibilityModels - public Referable(AasxCompatibilityModels.AdminShellV10.Referable src) - { - if (src == null) - return; - this.idShort = src.idShort; - if (this.idShort == null) - // change in V2.0 -> mandatory - this.idShort = ""; - this.category = src.category; - if (src.description != null) - this.description = new Description(src.description); - } - - public Referable(AasxCompatibilityModels.AdminShellV20.Referable src) - { - if (src == null) - return; - this.idShort = src.idShort; - this.category = src.category; - if (src.description != null) - this.description = new Description(src.description); - } -#endif - - /// - /// Introduced for JSON serialization, can create Referables based on a string name - /// - /// string name (standard PascalCased) - public static Referable CreateAdequateType(string elementName) - { - if (elementName == Key.AAS) - return new AdministrationShell(); - if (elementName == Key.ConceptDescription) - return new ConceptDescription(); - if (elementName == Key.Submodel) - return new Submodel(); - return SubmodelElementWrapper.CreateAdequateType(elementName); - } - - public void AddDescription(string lang, string str) - { - if (description == null) - description = new Description(); - description.langString.Add(new LangStr(lang, str)); - } - - public void AddExtension(Extension ext) - { - if (ext == null) - return; - if (extension == null) - extension = new ListOfExtension(); - extension.Add(ext); - } - - public virtual AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Referable", "Ref"); - } - - public virtual string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - - public string GetFriendlyName() - { - return AdminShellUtil.FilterFriendlyName(this.idShort); - } - - public virtual ModelReference GetModelReference(bool includeParents = true) - { - var r = new ModelReference(new AdminShell.Key( - this.GetElementName(), "" + this.idShort)); - - if (this is IGetSemanticId igs) - r.referredSemanticId = igs.GetSemanticId(); - - return r; - } - - public void CollectReferencesByParent(List refs) - { - // access - if (refs == null) - return; - - // check, if this is identifiable - if (this is Identifiable) - { - var idf = this as Identifiable; - if (idf != null) - { - var k = Key.CreateNew(idf.GetElementName(), idf.id?.value); - refs.Insert(0, k); - } - } - else - { - var k = Key.CreateNew(this.GetElementName(), this.idShort); - refs.Insert(0, k); - // recurse upwards! - if (this.parent is Referable prf) - prf.CollectReferencesByParent(refs); - } - } - - public string CollectIdShortByParent() - { - // recurse first - var head = ""; - if (!(this is Identifiable) && this.parent is Referable prf) - // can go up - head = prf.CollectIdShortByParent() + "/"; - // add own - var myid = ""; - if (this.idShort != null && this.idShort.Trim() != "") - myid = this.idShort.Trim(); - // together - return head + myid; - } - - // string functions - - public string ToIdShortString() - { - if (this.idShort == null || this.idShort.Trim().Length < 1) - return (""); - return this.idShort.Trim(); - } - - public override string ToString() - { - return "" + this.idShort; - } - - public virtual Key ToKey() - { - return new Key(GetElementName(), idShort); - } - - // hash functionality - - public class ObjectFieldInfo - { - public object o; - public FieldInfo fi; - public ObjectFieldInfo() { } - public ObjectFieldInfo(object o, FieldInfo fi) - { - this.o = o; - this.fi = fi; - } - } - - public List RecursivelyFindFields(object o, Type countAttribute, Type skipAttribute) - { - // access - var res = new List(); - if (o == null || countAttribute == null) - return res; - - // find fields for this object - var t = o.GetType(); - var l = t.GetFields(BindingFlags.Instance | BindingFlags.Public); - foreach (var f in l) - { - // Skip this field?? - if (skipAttribute != null && f.GetCustomAttribute(skipAttribute) != null) - continue; - - // add directly? - if (f.GetCustomAttribute(countAttribute) != null) - res.Add(new ObjectFieldInfo(o, f)); - - // object - if (f.FieldType.IsClass) - { - var oo = f.GetValue(o); - var r = RecursivelyFindFields(oo, countAttribute, skipAttribute); - res.AddRange(r); - } - - // try cast in IList to check further - var elems = f.GetValue(o) as IList; - if (elems != null) - foreach (var e in elems) - { - var r = RecursivelyFindFields(e, countAttribute, skipAttribute); - res.AddRange(r); - } - - } - // OK - return res; - } - - public byte[] ComputeByteArray() - { - // use memory stream for effcient behaviour - var mems = new MemoryStream(); - - // TEST - var xxx = RecursivelyFindFields(this, typeof(CountForHash), typeof(SkipForHash)); - - foreach (var ofi in xxx) - { - var a = ofi.fi.GetCustomAttribute(); - if (a != null) - { - // found an accountable field, get bytes - var o = ofi.fi.GetValue(ofi.o); - byte[] bs = null; - - // optimize for probabilities - - if (o is string) - bs = System.Text.Encoding.UTF8.GetBytes((string)o); - else if (o is char[]) - bs = System.Text.Encoding.UTF8.GetBytes((char[])o); - else if (o is double) - bs = BitConverter.GetBytes((double)o); - else if (o is float) - bs = BitConverter.GetBytes((float)o); - else if (o is char) - bs = BitConverter.GetBytes((char)o); - else if (o is byte) - bs = BitConverter.GetBytes((byte)o); - else if (o is int) - bs = BitConverter.GetBytes((int)o); - else if (o is long) - bs = BitConverter.GetBytes((long)o); - else if (o is short) - bs = BitConverter.GetBytes((short)o); - else if (o is uint) - bs = BitConverter.GetBytes((uint)o); - else if (o is ulong) - bs = BitConverter.GetBytes((ulong)o); - else if (o is ushort) - bs = BitConverter.GetBytes((ushort)o); - - if (bs != null) - mems.Write(bs, 0, bs.Length); - } - } - - return mems.ToArray(); - } - - private static System.Security.Cryptography.SHA256 HashProvider = - System.Security.Cryptography.SHA256.Create(); - - public string ComputeHashcode() - { - var dataBytes = this.ComputeByteArray(); - var hashBytes = Referable.HashProvider.ComputeHash(dataBytes); - - StringBuilder sb = new StringBuilder(); - foreach (var hb in hashBytes) - sb.Append(hb.ToString("X2")); - return sb.ToString(); - } - - // sorting - - public class ComparerIdShort : IComparer - { - public int Compare(Referable a, Referable b) - { - return String.Compare(a?.idShort, b?.idShort, - CultureInfo.InvariantCulture, CompareOptions.IgnoreCase); - } - } - - public class ComparerIndexed : IComparer - { - public int NullIndex = int.MaxValue; - public Dictionary Index = new Dictionary(); - - public int Compare(Referable a, Referable b) - { - var ca = Index.ContainsKey(a); - var cb = Index.ContainsKey(b); - - if (!ca && !cb) - return 0; - // make CDs without usage to appear at end of list - if (!ca) - return +1; - if (!cb) - return -1; - - var ia = Index[a]; - var ib = Index[b]; - - if (ia == ib) - return 0; - if (ia < ib) - return -1; - return +1; - } - } - - // validation - - public virtual void Validate(AasValidationRecordList results) - { - // access - if (results == null) - return; - - // check - if (this.idShort == null || this.idShort.Trim() == "") - results.Add(new AasValidationRecord( - AasValidationSeverity.SpecViolation, this, - "Referable: missing idShort", - () => - { - this.idShort = "TO_FIX"; - })); - - if (this.description != null && (this.description.langString == null - || this.description.langString.Count < 1)) - results.Add(new AasValidationRecord( - AasValidationSeverity.SchemaViolation, this, - "Referable: existing description with missing langString", - () => - { - this.description = null; - })); - } - - // hierarchy & recursion (by derived elements) - - public virtual void RecurseOnReferables( - object state, Func lambda, - bool includeThis = false) - { - if (includeThis) - lambda(state, null, this); - } - - public Identifiable FindParentFirstIdentifiable() - { - Referable curr = this; - while (curr != null) - { - if (curr is Identifiable curri) - return curri; - curr = curr.parent as Referable; - } - return null; - } - } - - public class Identifiable : Referable, IGetModelReference - { - - // members - - // this is complex, because V3.0 made id a simple string - // and this should be translated to the outside. - // TODO (MIHO, 2021-12-30): consider a converter for this - // https://stackoverflow.com/questions/24472404/json-net-how-to-serialize-object-as-value - - [JsonIgnore] - public Identifier id = new Identifier(); - [XmlIgnore] - [JsonProperty(PropertyName = "id")] - public string JsonId - { - get { return id?.value; } - set - { - if (id == null) - id = new Identifier(value); - else - id.value = value; - } - } - - // rest of members - - public Administration administration = null; - - // constructors - - public Identifiable() : base() { } - - public Identifiable(string idShort) : base(idShort) { } - - public Identifiable(Identifiable src) - : base(src) - { - if (src == null) - return; - if (src.id != null) - this.id = new Identifier(src.id); - if (src.administration != null) - this.administration = new Administration(src.administration); - } - -#if !DoNotUseAasxCompatibilityModels - public Identifiable(AasxCompatibilityModels.AdminShellV10.Identifiable src) - : base(src) - { - if (src.identification != null) - this.id = new Identifier(src.identification); - if (src.administration != null) - this.administration = new Administration(src.administration); - } - - public Identifiable(AasxCompatibilityModels.AdminShellV20.Identifiable src) - : base(src) - { - if (src.identification != null) - this.id = new Identifier(src.identification); - if (src.administration != null) - this.administration = new Administration(src.administration); - } -#endif - - public void SetIdentification(string id, string idShort = null) - { - this.id.value = id; - if (idShort != null) - this.idShort = idShort; - } - - public void SetAdminstration(string version, string revision) - { - if (administration == null) - administration = new Administration(); - administration.version = version; - administration.revision = revision; - } - - public new string GetFriendlyName() - { - if (id != null && id.value != "") - return AdminShellUtil.FilterFriendlyName(this.id.value); - return AdminShellUtil.FilterFriendlyName(this.idShort); - } - - public override string ToString() - { - return ("" + id?.ToString() + " " + administration?.ToString()).Trim(); - } - - public override Key ToKey() - { - return new Key(GetElementName(), "" + id?.value); - } - - // self description - - public override ModelReference GetModelReference(bool includeParents = true) - { - var r = new ModelReference(); - - if (this is IGetSemanticId igs) - r.referredSemanticId = igs.GetSemanticId(); - - r.Keys.Add( - Key.CreateNew(this.GetElementName(), this.id.value)); - return r; - } - - // sorting - - public class ComparerIdentification : IComparer - { - public int Compare(Identifiable a, Identifiable b) - { - if (a?.id == null && b?.id == null) - return 0; - if (a?.id == null) - return +1; - if (b?.id == null) - return -1; - - return String.Compare(a.id.value, b.id.value, - CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace); - } - } - - } - - /// - /// Multiple lang string for the AAS namespace - /// - public class LangStringSet - { - - // members - - [XmlElement(ElementName = "langString", Namespace = "http://www.admin-shell.io/aas/3/0")] - public ListOfLangStr langString = new ListOfLangStr(); - - // getters / setters - - [XmlIgnore] - [JsonIgnore] - public bool IsEmpty { get { return langString == null || langString.Count < 1; } } - [XmlIgnore] - [JsonIgnore] - public int Count { get { if (langString == null) return 0; return langString.Count; } } - [XmlIgnore] - [JsonIgnore] - public LangStr this[int index] { get { return langString[index]; } } - - // constructors - - public LangStringSet() { } - - public LangStringSet(LangStringSet src) - { - if (src.langString != null) - foreach (var ls in src.langString) - this.langString.Add(new LangStr(ls)); - } - - public LangStringSet(ListOfLangStr src) - { - if (src != null) - foreach (var ls in src) - this.langString.Add(new LangStr(ls)); - } - -#if !DoNotUseAasxCompatibilityModels - public LangStringSet(AasxCompatibilityModels.AdminShellV20.LangStringSet src) - { - if (src.langString != null) - foreach (var ls in src.langString) - this.langString.Add(new LangStr(ls)); - } -#endif - public LangStringSet(string lang, string str) - { - if (str == null || str.Trim() == "") - return; - this.langString.Add(new LangStr(lang, str)); - } - - // converter - - public static LangStringSet CreateFrom(List src) - { - var res = new LangStringSet(); - if (src != null) - foreach (var ls in src) - res.langString.Add(new LangStr(ls)); - return res; - } - - // add - - public LangStr Add(LangStr ls) - { - this.langString.Add(ls); - return ls; - } - - public LangStr Add(string lang, string str) - { - var ls = new LangStr(lang, str); - this.langString.Add(ls); - return ls; - } - - // single string representation - public string GetDefaultStr(string defaultLang = null) - { - return this.langString?.GetDefaultStr(defaultLang); - } - } - - // - // Qualifier - // - - public class Qualifier : IAasElement, IGetSemanticId - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } - - // member - // from hasSemantics: - [XmlElement(ElementName = "semanticId")] - public SemanticId semanticId = null; - public SemanticId GetSemanticId() { return semanticId; } - - // this class - // TODO (Michael Hoffmeister, 2020-08-01): check, if Json has Qualifiers or not - - [MetaModelName("Qualifier.type")] - [TextSearchable] - [CountForHash] - public string type = ""; - - [MetaModelName("Qualifier.valueType")] - [TextSearchable] - [CountForHash] - public string valueType = ""; - - [CountForHash] - public GlobalReference valueId = null; - - [MetaModelName("Qualifier.value")] - [TextSearchable] - [CountForHash] - public string value = null; - - // dead-csharp off - // Remark: due to publication of v2.0.1, the order of elements has changed!!! - // from hasSemantics: - // [XmlElement(ElementName = "semanticId")] - // [JsonIgnore] - // public SemanticId semanticId = null; - // dead-csharp on - - // constructors - - public Qualifier() { } - - public Qualifier(Qualifier src) - { - if (src.semanticId != null) - this.semanticId = new SemanticId(src.semanticId); - this.type = src.type; - this.value = src.value; - if (src.valueId != null) - this.valueId = new GlobalReference(src.valueId); - } - -#if !DoNotUseAasxCompatibilityModels - public Qualifier(AasxCompatibilityModels.AdminShellV10.Qualifier src) - { - if (src.semanticId != null) - this.semanticId = new SemanticId(src.semanticId); - this.type = src.qualifierType; - this.value = src.qualifierValue; - if (src.qualifierValueId != null) - this.valueId = new GlobalReference(src.qualifierValueId); - } - - public Qualifier(AasxCompatibilityModels.AdminShellV20.Qualifier src) - { - if (src.semanticId != null) - this.semanticId = new SemanticId(src.semanticId); - this.type = src.type; - this.value = src.value; - if (src.valueId != null) - this.valueId = new GlobalReference(src.valueId); - } -#endif - - public AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Qualifier", "Qfr"); - } - - public string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - - // ReSharper disable MethodOverloadWithOptionalParameter .. this seems to work, anyhow - // ReSharper disable RedundantArgumentDefaultValue - public string ToString(int format = 0, string delimiter = ",") - { - var res = "" + type; - if (res == "") - res += "" + semanticId?.ToString(format, delimiter); - - if (value != null) - res += " = " + value; - else if (valueId != null) - res += " = " + valueId?.ToString(format, delimiter); - - return res; - } - - public override string ToString() - { - return this.ToString(0); - } - // ReSharper enable MethodOverloadWithOptionalParameter - // ReSharper enable RedundantArgumentDefaultValue - - public static Qualifier Parse(string input) - { - var m = Regex.Match(input, @"\s*([^,]*)(,[^=]+){0,1}\s*=\s*([^,]*)(,.+){0,1}\s*"); - if (!m.Success) - return null; - - return new Qualifier() - { - type = m.Groups[1].ToString().Trim(), - semanticId = SemanticId.Parse(m.Groups[1].ToString().Trim()), - value = m.Groups[3].ToString().Trim(), - valueId = GlobalReference.Parse(m.Groups[1].ToString().Trim()) - }; - } - } - - /// - /// This class holds some convenience functions for Qualifiers - /// - public class QualifierCollection : List - { - public QualifierCollection() - { - - } - -#if !DoNotUseAasxCompatibilityModels - public QualifierCollection( - List src, bool shallowCopy = false) - - { - if (src != null && src.Count != 0) - { - foreach (var q in src) - { - this.Add(new Qualifier(q)); - } - } - } -#endif - - /// - /// Add qualifier. If null, do nothing - /// - public new void Add(Qualifier q) - { - if (q == null) - return; - base.Add(q); - } - - public Qualifier FindType(string type) - { - if (type == null) - return null; - foreach (var q in this) - if (q != null && q.type != null && q.type.Trim() == type.Trim()) - return q; - return null; - } - - public Qualifier FindSemanticId(SemanticId semId) - { - if (semId == null) - return null; - foreach (var q in this) - if (q != null && q.semanticId != null && q.semanticId.Matches(semId)) - return q; - return null; - } - - // ReSharper disable MethodOverloadWithOptionalParameter .. this seems to work, anyhow - // ReSharper disable RedundantArgumentDefaultValue - public string ToString(int format = 0, string delimiter = ";", string referencesDelimiter = ",") - { - var res = ""; - foreach (var q in this) - { - if (res != "") - res += delimiter; - res += q.ToString(format, referencesDelimiter); - } - return res; - } - - public override string ToString() - { - return this.ToString(0); - } - // ReSharper enable MethodOverloadWithOptionalParameter - // ReSharper enable RedundantArgumentDefaultValue - - // for convenience methods of Submodel, SubmodelElement - - public static void AddQualifier( - ref QualifierCollection qualifiers, - string qualifierType = null, string qualifierValue = null, KeyList semanticKeys = null, - GlobalReference qualifierValueId = null) - { - if (qualifiers == null) - qualifiers = new QualifierCollection(); - var q = new Qualifier() - { - type = qualifierType, - value = qualifierValue, - valueId = qualifierValueId, - }; - if (semanticKeys != null) - q.semanticId = SemanticId.CreateFromKeys(semanticKeys); - qualifiers.Add(q); - } - - public static Qualifier HasQualifierOfType( - QualifierCollection qualifiers, - string qualifierType) - { - if (qualifiers == null || qualifierType == null) - return null; - foreach (var q in qualifiers) - if (q.type.Trim().ToLower() == qualifierType.Trim().ToLower()) - return q; - return null; - } - - public IEnumerable FindAllQualifierType(string qualifierType) - { - if (qualifierType == null) - yield break; - foreach (var q in this) - if (q.type.Trim().ToLower() == qualifierType.Trim().ToLower()) - yield return q; - } - } - - } - - #endregion -} - diff --git a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_Ids_Keys_Refs.cs b/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_Ids_Keys_Refs.cs deleted file mode 100644 index cf3c1a6af..000000000 --- a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_Ids_Keys_Refs.cs +++ /dev/null @@ -1,1799 +0,0 @@ -/* -Copyright (c) 2018-2021 Festo AG & Co. KG -Author: Michael Hoffmeister - -This source code is licensed under the Apache License 2.0 (see LICENSE.txt). - -This source code may use other Open Source software components (see LICENSE.txt). -*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Globalization; -using System.IO; -using System.IO.Packaging; -using System.Linq; -using System.Reflection; -using System.Runtime; -using System.Text; -using System.Text.RegularExpressions; -using System.Xml; -using System.Xml.Serialization; -using AdminShellNS; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -//namespace AdminShellNS -namespace AdminShell_V30 -{ - /// - /// Version of Details of Administration Shell Part 1 V3.0 RC 02 published Apre 2022 - /// - public partial class AdminShellV30 - { - // - // Identifier - // - - /// - /// V30 - /// Thic class is the "old" Identification class of meta-model V2.0 - /// It did contain two attributes "idType" and "id" - /// As string is sealed, this class cannot derive dirctly from string, - /// so an implicit conversion is tested - /// - public class Identifier - { - - // members - - [XmlText] - [CountForHash] - public string value = ""; - - // implicit operators - - public static implicit operator string(Identifier d) - { - return d.value; - } - - public static implicit operator Identifier(string d) - { - return new Identifier(d); - } - - // some constants - - public static string IRDI = "IRDI"; - public static string IRI = "IRI"; - public static string IdShort = "IdShort"; - - // constructors - - public Identifier() { } - - public Identifier(Identifier src) - { - this.value = src.value; - } - -#if !DoNotUseAasxCompatibilityModels - public Identifier(AasxCompatibilityModels.AdminShellV10.Identification src) - { - this.value = src.id; - } - - public Identifier(AasxCompatibilityModels.AdminShellV20.Identification src) - { - this.value = src.id; - } -#endif - - public Identifier(string id) - { - this.value = id; - } - - public Identifier(Key key) - { - this.value = key.value; - } - - // Creator with validation - - public static Identifier CreateNew(string id) - { - return new Identifier(id); - } - - // further - - public bool IsEqual(Identifier other) - { - return this.value.Trim().ToLower() == other.value.Trim().ToLower(); - } - - public static bool IsIRI(string value) - { - if (value == null) - return false; - var m = Regex.Match(value, @"\s*(\w+)://"); - return m.Success; - } - - public bool IsIRI() - { - return IsIRI(value); - } - - public static bool IsIRDI(string value) - { - if (value == null) - return false; - var m = Regex.Match(value, @"\s*(\d{3,4})(:|-|/)"); - return m.Success; - } - - public bool IsIRDI() - { - return IsIRDI(value); - } - - // Matching - - public bool Matches(string id, Key.MatchMode matchMode = Key.MatchMode.Identification) - { - if (id == null || value == null) - return false; - return value.Trim() == id.Trim(); - } - - public bool Matches(Identifier id, Key.MatchMode matchMode = Key.MatchMode.Identification) - { - if (id == null || value == null) - return false; - return value.Trim() == id.value.Trim(); - } - - public bool Matches(Key key, Key.MatchMode matchMode = Key.MatchMode.Identification) - { - if (key == null) - return false; - return this.Matches(key.value, matchMode); - } - - // validation - - public static AasValidationAction Validate( - AasValidationRecordList results, Identifier id, Referable container) - { - // access - if (results == null || container == null) - return AasValidationAction.No; - - var res = AasValidationAction.No; - - // check - if (id?.value == null) - { - // violation case - results.Add(new AasValidationRecord( - AasValidationSeverity.SpecViolation, container, - "Value: is null", - () => - { - res = AasValidationAction.ToBeDeleted; - })); - } - - // may give result "to be deleted" - return res; - } - - // Other - - public override string ToString() - { - return value; - } - } - - public class ListOfIdentifier : List - { - // constructors / creators - - public ListOfIdentifier() : base() { } - public ListOfIdentifier(Identifier id) : base() { if (id != null) Add(id); } - public ListOfIdentifier(ListOfIdentifier loi) : base() { if (loi != null) AddRange(loi); } - - public static ListOfIdentifier CreateNew(KeyList kl) - { - if (kl == null) - return null; - var res = new ListOfIdentifier(); - foreach (var k in kl) - if (k?.value != null) - res.Add(new Identifier(k?.value)); - return res; - } - - // Member operation - - public void AddRange(List kl) - { - if (kl == null) - return; - foreach (var k in kl) - Add(k?.value); - } - - public string ToString(string delimiter = ",") - { - return string.Join(delimiter, this.Select((x) => x.ToString())); - } - - public static ListOfIdentifier Parse(string input) - { - // access - if (input == null) - return null; - - // split - var parts = input.Split(',', ';'); - var loi = new ListOfIdentifier(); - - foreach (var p in parts) - loi.Add(p); - - return loi; - } - - // validation - - public static void Validate(AasValidationRecordList results, ListOfIdentifier kl, - Referable container) - { - // access - if (results == null || kl == null || container == null) - return; - - // iterate thru - var idx = 0; - while (idx < kl.Count) - { - var act = Identifier.Validate(results, kl[idx], container); - if (act == AasValidationAction.ToBeDeleted) - { - kl.RemoveAt(idx); - continue; - } - idx++; - } - } - - } - - // - // IdentifierKeyValuePair(s) - // - - public class IdentifierKeyValuePair : IAasElement - { - // member - // from hasSemantics: - [XmlElement(ElementName = "semanticId")] - public SemanticId semanticId = null; - - [MetaModelName("IdentifierKeyValuePair.key")] - [TextSearchable] - [CountForHash] - public string key = ""; - - [MetaModelName("IdentifierKeyValuePair.value")] - [TextSearchable] - [CountForHash] - public string value = null; - - [CountForHash] - public GlobalReference externalSubjectId = null; - - // constructors - - public IdentifierKeyValuePair() { } - - public IdentifierKeyValuePair(IdentifierKeyValuePair src) - { - if (src.semanticId != null) - this.semanticId = new SemanticId(src.semanticId); - this.key = src.key; - this.value = src.value; - if (src.externalSubjectId != null) - this.externalSubjectId = new GlobalReference(src.externalSubjectId); - } - -#if !DoNotUseAasxCompatibilityModels - // not existing in V2.0 -#endif - - // further - - public string ToString(int format = 0) - { - if (format == 1) - { - return String.Format( - "({0}){1}", this.key, this.value); - } - if (format == 2) - { - return String.Format("{0}", this.value); - } - - // (old) default - return $"[{this.key}, {this.value}]"; - } - - // self description - - public AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("IdentifierKeyValuePair", "IKV"); - } - - public string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - - } - - public class ListOfIdentifierKeyValuePair : List - { - - // constructors - public ListOfIdentifierKeyValuePair() : base() { } - public ListOfIdentifierKeyValuePair(ListOfIdentifierKeyValuePair src) : base() - { - if (src != null) - foreach (var kvp in src) - Add(new IdentifierKeyValuePair(kvp)); - } - - // further - - public string ToString(int format = 0, string delimiter = ",") - { - return string.Join(delimiter, this.Select((x) => x.ToString(format))); - } - } - - // - // Keys - // - - public class Key - { - // Constants - - public enum MatchMode { Relaxed, Identification }; // in V3.0RC02: Strict not anymore - - // Members - - [MetaModelName("Key.type")] - [TextSearchable] - [XmlAttribute] - [CountForHash] - public string type = ""; - - [MetaModelName("Key.value")] - [TextSearchable] - [XmlText] - [CountForHash] - public string value = ""; - - [XmlIgnore] - [JsonProperty(PropertyName = "index")] - [CountForHash] - public int index = 0; - - public Key() - { - } - - public Key(Key src) - { - this.type = src.type; - this.value = src.value; - } - -#if !DoNotUseAasxCompatibilityModels - public Key(AasxCompatibilityModels.AdminShellV10.Key src) - { - this.type = src.type; - this.value = src.value; - } - - public Key(AasxCompatibilityModels.AdminShellV20.Key src) - { - if (src == null) - return; - var stll = src.type?.Trim().ToLower(); - if (stll == AasxCompatibilityModels.AdminShellV20.Key.GlobalReference.ToLower()) - this.type = Key.GlobalReference; - else - this.type = src.type; - this.value = src.value; - } -#endif - - public Key(string type, string value) - { - this.type = type; - this.value = value; - } - - public static Key CreateNew(string type, string value) - { - var k = new Key() - { - type = type, - value = value - }; - return (k); - } - - public static Key GetFromRef(ModelReference r) - { - if (r == null || r.Count != 1) - return null; - return r[0]; - } - - public Identifier ToId() - { - return new Identifier(this); - } - - public string ToString(int format = 0) - { - if (format == 1) - { - return String.Format( - "({0}){1}", this.type, this.value); - } - if (format == 2) - { - return String.Format("{0}", this.value); - } - - // (old) default - return $"[{this.type}, {this.value}]"; - } - - public static Key Parse(string cell, string typeIfNotSet = null, - bool allowFmtAll = false, bool allowFmt0 = false, - bool allowFmt1 = false, bool allowFmt2 = false) - { - // access and defaults? - if (cell == null || cell.Trim().Length < 1) - return null; - if (typeIfNotSet == null) - typeIfNotSet = Key.GlobalReference; - - // TODO (MIHO, 2022-01-07): REWORK OLD & NEW FORMATS!! - - // OLD format == 1 - if (allowFmtAll || allowFmt1) - { - var m = Regex.Match(cell, @"\((\w+)\)\((\S+)\)\[(\w+)\]( ?)(.*)$"); - if (m.Success) - { - return new AdminShell.Key( - m.Groups[1].ToString(), m.Groups[5].ToString()); - } - } - - // OLD format == 2 - if (allowFmtAll || allowFmt2) - { - var m = Regex.Match(cell, @"\[(\w+)\]( ?)(.*)$"); - if (m.Success) - { - return new AdminShell.Key(typeIfNotSet, m.Groups[3].ToString()); - } - } - - // OLD format == 0 - if (allowFmtAll || allowFmt0) - { - var m = Regex.Match(cell, @"\[(\w+),( ?)([^,]+),( ?)\[(\w+)\],( ?)(.*)\]"); - if (m.Success) - { - return new AdminShell.Key(m.Groups[1].ToString(), m.Groups[7].ToString()); - } - } - - // no - return null; - } - - public static string KeyListToString(List keys) - { - if (keys == null || keys.Count < 1) - return ""; - // normally, exactly one key - if (keys.Count == 1) - return keys[0].ToString(); - // multiple! - var s = "[ "; - foreach (var k in keys) - { - if (s.Length > 0) - s += ", "; - s += k.ToString(); - } - return s + " ]"; - } - - public static string[] KeyElements = new string[] { - "AnnotatedRelationshipElement", - "AssetAdministrationShell", - "BasicEvent", - "Blob", - "Capability", - "ConceptDescription", - "DataElement", - "Entity", - "Event", - "File", - "FragmentReference", - "GlobalElementReference", - "ModelElementReference", - "MultiLanguageProperty", - "Operation", - "OperationVariable", // not specified, but used by AASX Package Explorer - "Property", - "Range", - "ReferenceElement", - "RelationshipElement", - "Submodel", - "SubmodelElement", - "SubmodelElementCollection", // not specified, but used by AASX Package Explorer - "SubmodelElementList", - "SubmodelElementStruct", - "SubmodelRef" // not specified, but used by AASX Package Explorer - }; - - public static string[] ReferableElements = new string[] { - "AnnotatedRelationshipElement", - "AssetAdministrationShell", - "BasicEvent", - "Blob", - "Capability", - "ConceptDescription", - "DataElement", - "Entity", - "Event", - "File", - "FragmentReference", - "GlobalElementReference", - "ModelElementReference", - "MultiLanguageProperty", - "Operation", - "OperationVariable", // not specified, but used by AASX Package Explorer - "Property", - "Range", - "ReferenceElement", - "RelationshipElement", - "Submodel", - "SubmodelElement", - "SubmodelElementCollection", // not specified, but used by AASX Package Explorer - "SubmodelElementList", - "SubmodelElementStruct" - }; - - public static string[] SubmodelElementElements = new string[] { - "AnnotatedRelationshipElement", - "BasicEvent", - "Blob", - "Capability", - "DataElement", - "Entity", - "Event", - "File", - "GlobalReferenceElement", - "ModelReferenceElement", - "MultiLanguageProperty", - "Operation", - "Property", - "Range", - "ReferenceElement", // typo in spec?, but used by AASX Package Explorer - "RelationshipElement", - "Submodel", // not specified, but used by AASX Package Explorer - "SubmodelElement", - "SubmodelElementCollection", // not specified, but used by AASX Package Explorer - "SubmodelElementList", - "SubmodelElementStruct" - }; - - // use this in list to designate all of the above elements - public static string AllElements = "All"; - - // use this in list to designate the GlobalReference - // Resharper disable MemberHidesStaticFromOuterClass - public static string GlobalReference = "GlobalElementReference"; - public static string ModelReference = "ModelElementReference"; - public static string FragmentReference = "FragmentReference"; - public static string ConceptDescription = "ConceptDescription"; - public static string SubmodelRef = "SubmodelRef"; - public static string Submodel = "Submodel"; - public static string SubmodelElement = "SubmodelElement"; - public static string AssetInformation = "AssetInformation"; - public static string AAS = "AssetAdministrationShell"; - public static string Entity = "Entity"; - // Resharper enable MemberHidesStaticFromOuterClass - - // some helpers - - public static bool IsInNamedElementsList(string[] elementsList, string ke) - { - if (elementsList == null || ke == null) - return false; - - foreach (var s in elementsList) - if (s.Trim().ToLower() == ke.Trim().ToLower()) - return true; - - return false; - } - - public bool IsInKeyElements() - { - return IsInNamedElementsList(KeyElements, this.type); - } - - public bool IsInReferableElements() - { - return IsInNamedElementsList(ReferableElements, this.type); - } - - public bool IsInSubmodelElements() - { - return IsInNamedElementsList(SubmodelElementElements, this.type); - } - - public bool IsIRI() - { - return Identifier.IsIRI(value); - } - - public bool IsIRDI() - { - return Identifier.IsIRDI(value); - } - - public bool IsType(string value) - { - if (value == null || type == null || type.Trim() == "") - return false; - return value.Trim().ToLower().Equals(type.Trim().ToLower()); - } - - public bool IsAbsolute() - { - return IsType(Key.GlobalReference) - || IsType(Key.AAS) - || IsType(Key.Submodel); - } - - public bool Matches( - string type, string id, MatchMode matchMode = MatchMode.Relaxed) - { - if (matchMode == MatchMode.Relaxed) - return this.type == type && this.value == id; - - if (matchMode == MatchMode.Identification) - return this.value == id; - - return false; - } - - public bool Matches(Identifier id) - { - if (id == null) - return false; - return this.Matches(Key.GlobalReference, id.value, MatchMode.Identification); - } - - public bool Matches(Key key, MatchMode matchMode = MatchMode.Relaxed) - { - if (key == null) - return false; - return this.Matches(key.type, key.value, matchMode); - } - - // validation - - public static AasValidationAction Validate(AasValidationRecordList results, Key k, Referable container) - { - // access - if (results == null || container == null) - return AasValidationAction.No; - - var res = AasValidationAction.No; - - // check - if (k == null) - { - // violation case - results.Add(new AasValidationRecord( - AasValidationSeverity.SpecViolation, container, - "Key: is null", - () => - { - res = AasValidationAction.ToBeDeleted; - })); - } - else - { - // check type - var tf = AdminShellUtil.CheckIfInConstantStringArray(KeyElements, k.type); - if (tf == AdminShellUtil.ConstantFoundEnum.No) - // violation case - results.Add(new AasValidationRecord( - AasValidationSeverity.SchemaViolation, container, - "Key: type is not in allowed enumeration values", - () => - { - k.type = GlobalReference; - })); - if (tf == AdminShellUtil.ConstantFoundEnum.AnyCase) - // violation case - results.Add(new AasValidationRecord( - AasValidationSeverity.SchemaViolation, container, - "Key: type in wrong casing", - () => - { - k.type = AdminShellUtil.CorrectCasingForConstantStringArray( - KeyElements, k.type); - })); - } - - // may give result "to be deleted" - return res; - } - } - - public class KeyList : List - { - // getters / setters - - [XmlIgnore] - public bool IsEmpty { get { return this.Count < 1; } } - - // constructors / creators - - public KeyList() { } - - public KeyList(KeyList src) - { - if (src != null) - foreach (var k in src) - this.Add(new Key(k)); - } - - public static KeyList CreateNew(Key k) - { - var kl = new KeyList { k }; - return kl; - } - - public static KeyList CreateNew(string type, string value) - { - var kl = new KeyList() { - Key.CreateNew(type, value) - }; - return kl; - } - - public static KeyList CreateNew(string type, string[] valueItems) - { - // access - if (valueItems == null) - return null; - - // prepare - var kl = new AdminShell.KeyList(); - foreach (var x in valueItems) - kl.Add(new AdminShell.Key(type, "" + x)); - return kl; - } - - // matches - - public bool Matches(KeyList other, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (other == null || other.Count != this.Count) - return false; - - var same = true; - for (int i = 0; i < this.Count; i++) - same = same && this[i].Matches(other[i], matchMode); - - return same; - } - - // other - - public void NumberIndices() - { - for (int i = 0; i < this.Count; i++) - this[i].index = i; - } - - public string ToString(int format = 0, string delimiter = ",") - { - return string.Join(delimiter, this.Select((x) => x.ToString(format))); - } - - public static KeyList Parse(string input) - { - // access - if (input == null) - return null; - - // split - var parts = input.Split(',', ';'); - var kl = new KeyList(); - - foreach (var p in parts) - { - var k = Key.Parse(p); - if (k != null) - kl.Add(k); - } - - return kl; - } - - public string MostSignificantInfo() - { - if (this.Count < 1) - return "-"; - var i = this.Count - 1; - var res = this[i].value; - if (this[i].IsType(Key.FragmentReference) && i > 0) - res += this[i - 1].value; - return res; - } - - // validation - - public static void Validate(AasValidationRecordList results, KeyList kl, - Referable container) - { - // access - if (results == null || kl == null || container == null) - return; - - // iterate thru - var idx = 0; - while (idx < kl.Count) - { - var act = Key.Validate(results, kl[idx], container); - if (act == AasValidationAction.ToBeDeleted) - { - kl.RemoveAt(idx); - continue; - } - idx++; - } - } - - public bool StartsWith(KeyList head, bool emptyIsTrue = false, - Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - // access - if (head == null) - return false; - if (head.Count == 0) - return emptyIsTrue; - - // simply test element-wise - for (int i = 0; i < head.Count; i++) - { - // does head have more elements than this list? - if (i >= this.Count) - return false; - - if (!head[i].Matches(this[i], matchMode)) - return false; - } - - // ok! - return true; - } - - // arithmetics - - public static KeyList operator +(KeyList a, Key b) - { - var res = new KeyList(a); - if (b != null) - res.Add(b); - return res; - } - - public static KeyList operator +(KeyList a, KeyList b) - { - var res = new KeyList(a); - if (b != null) - res.AddRange(b); - return res; - } - - public KeyList SubList(int startPos, int count = int.MaxValue) - { - var res = new KeyList(); - if (startPos >= this.Count) - return res; - int nr = 0; - for (int i = startPos; i < this.Count && nr < count; i++) - { - nr++; - res.Add(this[i]); - } - return res; - } - - public KeyList ReplaceLastKey(KeyList newKeys) - { - var res = new KeyList(this); - if (res.Count < 1 || newKeys == null || newKeys.Count < 1) - return res; - - res.Remove(res.Last()); - res = res + newKeys; - - return res; - } - - // other - - /// - /// Take only idShort, ignore all other key-types and create a '/'-separated list - /// - /// Empty string or list of idShorts - public string BuildIdShortPath(int startPos = 0, int count = int.MaxValue) - { - if (startPos >= this.Count) - return ""; - int nr = 0; - var res = ""; - for (int i = startPos; i < this.Count && nr < count; i++) - { - nr++; - // V3RC02: quite expensive check: if SME -> then treat as idShort - if (this[i].IsInSubmodelElements()) - { - if (res != "") - res += "/"; - res += this[i].value; - } - } - return res; - } - } - - // - // <> Reference - // - - [XmlType(TypeName = "reference")] - public class Reference : IAasElement - { - // self description - - public virtual AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Reference", "Rfc"); - } - - public virtual string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - } - - /// - /// This reference is used to point OUTSIDE the model, to definitions and knowledge - /// existing in the outside world. - /// - public class GlobalReference : Reference - { - // members - - [XmlIgnore] // anyway, as it is private/ protected - [JsonIgnore] - protected ListOfIdentifier value = new ListOfIdentifier(); - - // Keys getters / setters - - [XmlArray("values")] - [XmlArrayItem("value")] - [JsonIgnore] - public ListOfIdentifier Value { get { return value; } } - [XmlIgnore] - [JsonProperty(PropertyName = "values")] - public ListOfIdentifier JsonKeys => value; - - // other members - - [XmlIgnore] - [JsonIgnore] - public bool IsEmpty { get { return value == null || value.Count < 1; } } - [XmlIgnore] - [JsonIgnore] - public bool IsValid { get { return value != null && value.Count >= 1; } } - [XmlIgnore] - [JsonIgnore] - public int Count { get { if (value == null) return 0; return value.Count; } } - [XmlIgnore] - [JsonIgnore] - public Identifier this[int index] { get { return value[index]; } } - - [XmlIgnore] - [JsonIgnore] - public Identifier First { get { return this.Count < 1 ? null : this.value[0]; } } - - [XmlIgnore] - [JsonIgnore] - public Identifier Last { get { return this.Count < 1 ? null : this.value[this.value.Count - 1]; } } - - // constructors / creators - - public GlobalReference() : base() { } - public GlobalReference(GlobalReference src) : base() - { - if (src == null) - return; - - foreach (var id in src.Value) - value.Add(new Identifier(id)); - } - - public GlobalReference(Reference r) : base() { } - - public GlobalReference(Identifier id) : base() - { - value.Add(id); - } - -#if !DoNotUseAasxCompatibilityModels - public GlobalReference(List src) - { - if (src == null) - return; - - foreach (var k in src) - value.Add("" + k?.value); - } - - public GlobalReference(List src) - { - if (src == null) - return; - - foreach (var k in src) - value.Add("" + k?.value); - } - - public GlobalReference(AasxCompatibilityModels.AdminShellV10.Reference src) - { - if (src == null) - return; - - foreach (var k in src.Keys) - value.Add("" + k?.value); - } - - public GlobalReference(AasxCompatibilityModels.AdminShellV20.Reference src) - { - if (src == null) - return; - - foreach (var k in src.Keys) - value.Add("" + k?.value); - } -#endif - - public static GlobalReference CreateNew(Identifier id) - { - if (id == null) - return null; - var r = new GlobalReference(); - r.value.Add(id); - return r; - } - - public static GlobalReference CreateNew(ListOfIdentifier loi) - { - if (loi == null) - return null; - var r = new GlobalReference(); - r.value.AddRange(loi); - return r; - } - - public static GlobalReference CreateNew(List loi) - { - if (loi == null) - return null; - var r = new GlobalReference(); - foreach (var id in loi) - r.value.Add(id); - return r; - } - - public static GlobalReference CreateNew(ModelReference mref) - { - if (mref?.Keys == null) - return null; - var r = new GlobalReference(); - foreach (var key in mref.Keys) - r.value.Add(key?.value); - return r; - } - - public static GlobalReference CreateIrdiReference(string irdi) - { - return new GlobalReference("" + irdi); - } - - // Matching - - public bool MatchesExactlyOneId(Identifier id, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (value == null || value.Count != 1) - return false; - return value[0].Matches(id, matchMode); - } - - public bool Matches(Identifier id, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (this.Count == 1) - return this[0].Matches(id, matchMode); - return false; - } - - public bool Matches(GlobalReference other, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (this.value == null || other == null || other.Value == null || other.Count != this.Count) - return false; - - var same = true; - for (int i = 0; i < this.Count; i++) - same = same && this.Value[i].Matches(other[i], matchMode); - - return same; - } - - public bool Matches(ModelReference other, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (this.value == null || other == null || other.Keys == null || other.Count != this.Count) - return false; - - var same = true; - for (int i = 0; i < this.Count; i++) - same = same && this.Value[i].Matches(other[i], matchMode); - - return same; - } - - public bool Matches(SemanticId other, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - return Matches(new GlobalReference(other), matchMode); - } - - public bool Matches(ConceptDescription cd, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - return Matches(cd?.GetSemanticId(), matchMode); - } - - // other - - public string ToString(int format = 0, string delimiter = ",") - { - return string.Join(delimiter, value); - } - - public static GlobalReference Parse(string input) - { - return CreateNew(ListOfIdentifier.Parse(input)); - } - - /// - /// Converts the GlobalReference to a simple Identifier - /// - /// Check, if exact number of information is available - /// Identifier - public Identifier GetAsIdentifier(bool strict = false) - { - if (value == null || value.Count < 1) - return null; - if (strict && value.Count != 1) - return null; - return value.First().value; - } - - public Key GetAsExactlyOneKey(string type = null) - { - if (value == null || value.Count != 1) - return null; - if (type == null) - type = Key.GlobalReference; - var k = value[0]; - return new Key(type, k.value); - } - - // self description - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("GlobalReference", "GRf"); - } - - public override string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - } - - - /// - /// These references are menat to point inside an model described by the meta model of the AAS - /// - public class ModelReference : Reference - { - // members - - public GlobalReference referredSemanticId = null; - - [XmlIgnore] // anyway, as it is private/ protected - [JsonIgnore] - protected KeyList keys = new KeyList(); - - // Keys getters / setters - - [XmlArray("keys")] - [XmlArrayItem("key")] - [JsonIgnore] - public KeyList Keys { get { return keys; } } - [XmlIgnore] - [JsonProperty(PropertyName = "keys")] - public KeyList JsonKeys - { - get - { - keys?.NumberIndices(); - return keys; - } - } - - // other members - - [XmlIgnore] - [JsonIgnore] - public bool IsEmpty { get { return keys == null || keys.Count < 1; } } - [XmlIgnore] - [JsonIgnore] - public bool IsValid { get { return keys != null && keys.Count >= 1; } } - [XmlIgnore] - [JsonIgnore] - public int Count { get { if (keys == null) return 0; return keys.Count; } } - [XmlIgnore] - [JsonIgnore] - public Key this[int index] { get { return keys[index]; } } - - [XmlIgnore] - [JsonIgnore] - public Key First { get { return this.Count < 1 ? null : this.keys[0]; } } - - [XmlIgnore] - [JsonIgnore] - public Key Last { get { return this.Count < 1 ? null : this.keys[this.keys.Count - 1]; } } - - // constructors / creators - - public ModelReference() - { - } - - public ModelReference(Key k) - { - if (k != null) - keys.Add(k); - } - - public ModelReference(ModelReference src) - { - if (src == null) - return; - - if (src.referredSemanticId != null) - referredSemanticId = new GlobalReference(src.referredSemanticId); - - foreach (var k in src.Keys) - keys.Add(new Key(k)); - } - - public ModelReference(GlobalReference src) - { - if (src == null) - return; - - foreach (var id in src.Value) - keys.Add(new Key("", id)); - } - - public ModelReference(SemanticId src, string type = null) - { - if (type == null) - type = Key.GlobalReference; - if (src != null) - foreach (var id in src.Value) - keys.Add(new Key(type, id)); - } - -#if !DoNotUseAasxCompatibilityModels - public ModelReference(AasxCompatibilityModels.AdminShellV10.Reference src) - { - if (src != null) - foreach (var k in src.Keys) - keys.Add(new Key(k)); - } - - public ModelReference(AasxCompatibilityModels.AdminShellV10.SemanticId src) - { - if (src != null) - foreach (var k in src.Keys) - keys.Add(new Key(k)); - } - - public ModelReference(AasxCompatibilityModels.AdminShellV20.Reference src) - { - if (src != null) - foreach (var k in src.Keys) - keys.Add(new Key(k)); - } -#endif - - public static ModelReference CreateNew(Key k) - { - if (k == null) - return null; - var r = new ModelReference(); - r.keys.Add(k); - return r; - } - - public static ModelReference CreateNew(List k) - { - if (k == null) - return null; - var r = new ModelReference(); - r.keys.AddRange(k); - return r; - } - - public static ModelReference CreateNew(string keyType, Identifier id) - { - if (id == null) - return null; - var r = new ModelReference(); - r.keys.Add(new Key(keyType, id)); - return r; - } - - public static ModelReference CreateNew(string keyType, ListOfIdentifier loi) - { - if (loi == null) - return null; - var r = new ModelReference(); - foreach (var id in loi) - r.keys.Add(new Key(keyType, id)); - return r; - } - - public static ModelReference CreateNew(string type, string value) - { - if (type == null || value == null) - return null; - var r = new ModelReference(); - r.keys.Add(Key.CreateNew(type, value)); - return r; - } - - public static ModelReference Parse(string input) - { - return CreateNew(KeyList.Parse(input)); - } - - public static ModelReference CreateIrdiReference(string irdi) - { - if (irdi == null) - return null; - var r = new ModelReference(); - r.keys.Add(new Key(Key.GlobalReference, irdi)); - return r; - } - - // additions - - public static ModelReference operator +(ModelReference a, Key b) - { - var res = new ModelReference(a); - res.Keys?.Add(b); - return res; - } - - public static ModelReference operator +(ModelReference a, ModelReference b) - { - var res = new ModelReference(a); - res.Keys?.AddRange(b?.Keys); - return res; - } - - // Matching - - public bool MatchesExactlyOneKey( - string type, string id, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (keys == null || keys.Count != 1) - return false; - var k = keys[0]; - return k.Matches(type, id, matchMode); - } - - public bool MatchesExactlyOneKey(Key key, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (key == null) - return false; - return this.MatchesExactlyOneKey(key.type, key.value, matchMode); - } - - public bool Matches( - string type, string id, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (this.Count == 1) - { - var k = keys[0]; - return k.Matches(type, id, matchMode); - } - return false; - } - - public bool Matches(Key key, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (this.Count == 1) - { - var k = keys[0]; - return k.Matches(key, matchMode); - } - return false; - } - - public bool Matches(Identifier other) - { - if (other == null) - return false; - if (this.Count == 1) - { - var k = keys[0]; - return k.Matches(Key.GlobalReference, other.value, Key.MatchMode.Identification); - } - return false; - } - - public bool Matches(ModelReference other, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (this.keys == null || other == null || other.keys == null || other.Count != this.Count) - return false; - - var same = true; - for (int i = 0; i < this.Count; i++) - same = same && this.keys[i].Matches(other.keys[i], matchMode); - - return same; - } - - public bool Matches(SemanticId other, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - return Matches(new ModelReference(other), matchMode); - } - - public bool Matches(ConceptDescription cd, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - return Matches(cd?.GetModelReference(), matchMode); - } - - public string ToString(int format = 0, string delimiter = ",") - { - return keys?.ToString(format, delimiter); - } - - // further - - public Key GetAsExactlyOneKey() - { - if (keys == null || keys.Count != 1) - return null; - var k = keys[0]; - return new Key(k.type, k.value); - } - - public string ListOfValues(string delim) - { - string res = ""; - if (this.Keys != null) - foreach (var x in this.Keys) - { - if (x == null) - continue; - if (res != "") res += delim; - res += x.value; - } - return res; - } - - // self description - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("ModelReference", "MRf"); - } - - public override string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - } - - // - // derived References - // - - [XmlType(TypeName = "assetRef")] - public class AssetRef : GlobalReference - { - // constructors - - public AssetRef() : base() { } - public AssetRef(AssetRef src) : base(src) { } - public AssetRef(GlobalReference r) : base(r) { } - public AssetRef(Identifier id) : base(id) { } - -#if !DoNotUseAasxCompatibilityModels - public AssetRef(AasxCompatibilityModels.AdminShellV10.AssetRef src) : base(src) { } - public AssetRef(AasxCompatibilityModels.AdminShellV20.AssetRef src) : base(src) { } -#endif - - - // further methods - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("AssetRef", "AssetRef"); - } - } - - [XmlType(TypeName = "derivedFrom")] - public class AssetAdministrationShellRef : ModelReference - { - // constructors - - public AssetAdministrationShellRef() : base() { } - - public AssetAdministrationShellRef(Key k) : base(k) { } - - public AssetAdministrationShellRef(ModelReference src) : base(src) { } - -#if !DoNotUseAasxCompatibilityModels - public AssetAdministrationShellRef(AasxCompatibilityModels.AdminShellV10.Reference src) : base(src) { } - - public AssetAdministrationShellRef(AasxCompatibilityModels.AdminShellV20.Reference src) : base(src) { } -#endif - - // further methods - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("AssetAdministrationShellRef", "AasRef"); - } - } - - [XmlType(TypeName = "submodelRef")] - public class SubmodelRef : ModelReference - { - // constructors - - public SubmodelRef() : base() { } - - public SubmodelRef(SubmodelRef src) : base(src) { } - - public SubmodelRef(ModelReference src) : base(src) { } - -#if !DoNotUseAasxCompatibilityModels - public SubmodelRef(AasxCompatibilityModels.AdminShellV10.SubmodelRef src) : base(src) { } - - public SubmodelRef(AasxCompatibilityModels.AdminShellV20.SubmodelRef src) : base(src) { } -#endif - - public new static SubmodelRef CreateNew(string type, string value) - { - var r = new SubmodelRef(); - r.Keys.Add(Key.CreateNew(type, value)); - return r; - } - - public static SubmodelRef CreateNew(ModelReference src) - { - if (src == null || src.Keys == null) - return null; - var r = new SubmodelRef(); - r.Keys.AddRange(src.Keys); - return r; - } - - // further methods - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("SubmodelRef", "SMRef"); - } - } - - [XmlType(TypeName = "conceptDescriptionRef")] - public class ConceptDescriptionRef : ModelReference - { - // constructors - - public ConceptDescriptionRef() : base() { } - - public ConceptDescriptionRef(ConceptDescriptionRef src) : base(src) { } - -#if !DoNotUseAasxCompatibilityModels - public ConceptDescriptionRef( - AasxCompatibilityModels.AdminShellV10.ConceptDescriptionRef src) : base(src) { } - - public ConceptDescriptionRef( - AasxCompatibilityModels.AdminShellV20.ConceptDescriptionRef src) : base(src) { } -#endif - - // further methods - - public new static ConceptDescriptionRef CreateNew(string type, string value) - { - var r = new ConceptDescriptionRef(); - r.Keys.Add(Key.CreateNew(type, value)); - return r; - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("ConceptDescriptionRef", "CDRef"); - } - - } - - [XmlType(TypeName = "dataSpecificationRef")] - public class DataSpecificationRef : GlobalReference - { - // constructors - - public DataSpecificationRef() : base() { } - - public DataSpecificationRef(DataSpecificationRef src) : base(src) { } - public DataSpecificationRef(GlobalReference src) : base(src) { } - public DataSpecificationRef(Identifier src) : base(src) { } - -#if !DoNotUseAasxCompatibilityModels - public DataSpecificationRef(AasxCompatibilityModels.AdminShellV10.DataSpecificationRef src) : base(src) { } - - public DataSpecificationRef(AasxCompatibilityModels.AdminShellV10.Reference src) : base(src) { } - - public DataSpecificationRef(AasxCompatibilityModels.AdminShellV20.DataSpecificationRef src) : base(src) { } -#endif - - // further methods - - public static DataSpecificationRef CreateNew(GlobalReference src) - { - return new DataSpecificationRef(src); - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("DataSpecificationRef", "DSRef"); - } - - } - - [XmlType(TypeName = "conceptDescriptions")] - public class ConceptDescriptionRefs - { - [XmlElement(ElementName = "conceptDescriptionRef")] - public List conceptDescriptions = new List(); - - // constructors - - public ConceptDescriptionRefs() { } - - public ConceptDescriptionRefs(ConceptDescriptionRefs src) - { - if (src.conceptDescriptions != null) - foreach (var cdr in src.conceptDescriptions) - this.conceptDescriptions.Add(new ConceptDescriptionRef(cdr)); - } - -#if !DoNotUseAasxCompatibilityModels - public ConceptDescriptionRefs(AasxCompatibilityModels.AdminShellV10.ConceptDescriptionRefs src) - { - if (src.conceptDescriptions != null) - foreach (var cdr in src.conceptDescriptions) - this.conceptDescriptions.Add(new ConceptDescriptionRef(cdr)); - } - - public ConceptDescriptionRefs(AasxCompatibilityModels.AdminShellV20.ConceptDescriptionRefs src) - { - if (src.conceptDescriptions != null) - foreach (var cdr in src.conceptDescriptions) - this.conceptDescriptions.Add(new ConceptDescriptionRef(cdr)); - } -#endif - } - - public class SemanticId : GlobalReference - { - // constructors / creators - - public SemanticId() : base() { } - public SemanticId(Identifier id) : base(id) { } - public SemanticId(SemanticId src) : base(src) { } - public SemanticId(Reference src) : base(src) { } - -#if !DoNotUseAasxCompatibilityModels - public SemanticId(AasxCompatibilityModels.AdminShellV10.SemanticId src) : base(src?.Keys) { } - public SemanticId(AasxCompatibilityModels.AdminShellV20.SemanticId src) : base(src) { } -#endif - - public static SemanticId CreateFromKey(Key key) - { - if (key == null) - return null; - var res = new SemanticId(); - res.Value.Add(key?.value); - return res; - } - - public static SemanticId CreateFromKeys(List keys) - { - if (keys == null) - return null; - var res = new SemanticId(); - foreach (var k in keys) - res.Value.Add(k?.value); - return res; - } - - public new static SemanticId Parse(string input) - { - return (SemanticId)CreateNew(ListOfIdentifier.Parse(input)); - } - } - - } -} diff --git a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_LargeEntities.cs b/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_LargeEntities.cs deleted file mode 100644 index 19c6893bd..000000000 --- a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_LargeEntities.cs +++ /dev/null @@ -1,1753 +0,0 @@ -/* -Copyright (c) 2018-2021 Festo AG & Co. KG -Author: Michael Hoffmeister - -This source code is licensed under the Apache License 2.0 (see LICENSE.txt). - -This source code may use other Open Source software components (see LICENSE.txt). -*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Globalization; -using System.IO; -using System.IO.Packaging; -using System.Linq; -using System.Reflection; -using System.Runtime; -using System.Text; -using System.Text.RegularExpressions; -using System.Xml; -using System.Xml.Serialization; -using AdminShellNS; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -//namespace AdminShellNS -namespace AdminShell_V30 -{ - /// - /// Partial main class of AdminShell: SubmodelElements - /// - public partial class AdminShellV30 - { - // - // AAS - // - - public class AdministrationShell : Identifiable, IFindAllReferences - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } - - // from hasDataSpecification: - [XmlElement(ElementName = "hasDataSpecification")] - public HasDataSpecification hasDataSpecification = null; - - // from this very class - public AssetAdministrationShellRef derivedFrom = null; - - public AssetInformation assetInformation = null; - - [JsonProperty(PropertyName = "submodels")] - [SkipForSearch] - public List submodelRefs = new List(); - - // constructors - - public AdministrationShell() { } - - public AdministrationShell(string idShort) : base(idShort) { } - - public AdministrationShell(AdministrationShell src) - : base(src) - { - if (src != null) - { - if (src.hasDataSpecification != null) - this.hasDataSpecification = new HasDataSpecification(src.hasDataSpecification); - - if (src.derivedFrom != null) - this.derivedFrom = new AssetAdministrationShellRef(src.derivedFrom); - - if (src.submodelRefs != null) - foreach (var smr in src.submodelRefs) - this.submodelRefs.Add(new SubmodelRef(smr)); - } - } - -#if !DoNotUseAasxCompatibilityModels - public AdministrationShell( - AasxCompatibilityModels.AdminShellV10.AdministrationShell src, - AasxCompatibilityModels.AdminShellV10.AdministrationShellEnv srcenv) - : base(src) - { - if (src.hasDataSpecification != null) - this.hasDataSpecification = new HasDataSpecification(src.hasDataSpecification); - - if (src.derivedFrom != null) - this.derivedFrom = new AssetAdministrationShellRef(src.derivedFrom); - - if (src.submodelRefs != null) - foreach (var smr in src.submodelRefs) - this.submodelRefs.Add(new SubmodelRef(smr)); - - // now locate the Asset in the old environment and set - var srcasset = srcenv?.FindAsset(src.assetRef); - if (srcasset != null) - assetInformation = new AssetInformation(srcasset); - } - - public AdministrationShell(AasxCompatibilityModels.AdminShellV20.AdministrationShell src, - AasxCompatibilityModels.AdminShellV20.AdministrationShellEnv srcenv) - : base(src) - { - if (src != null) - { - if (src.hasDataSpecification != null) - this.hasDataSpecification = new HasDataSpecification(src.hasDataSpecification); - - if (src.derivedFrom != null) - this.derivedFrom = new AssetAdministrationShellRef(src.derivedFrom); - - if (src.submodelRefs != null) - foreach (var smr in src.submodelRefs) - this.submodelRefs.Add(new SubmodelRef(smr)); - - // now locate the Asset in the old environment and set - var srcasset = srcenv?.FindAsset(src.assetRef); - if (srcasset != null) - { - assetInformation = new AssetInformation(srcasset); - - this.AddExtension(new Extension() - { - name = "AAS2.0/MIGRATION", - valueType = "application/json", - value = JsonConvert.SerializeObject(srcasset, Newtonsoft.Json.Formatting.Indented) - }); - } - } - } -#endif - - public static AdministrationShell CreateNew( - string idShort, string idType, string id, string version = null, string revision = null) - { - var s = new AdministrationShell(); - s.idShort = idShort; - if (version != null) - s.SetAdminstration(version, revision); - s.id.value = id; - return (s); - } - - // add - - public void AddDataSpecification(Identifier id) - { - if (hasDataSpecification == null) - hasDataSpecification = new HasDataSpecification(); - hasDataSpecification.Add(new EmbeddedDataSpecification(new GlobalReference(id))); - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("AssetAdministrationShell", "AAS"); - } - - public Tuple ToCaptionInfo() - { - var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, "\"AAS\""); - if (administration != null) - caption += "V" + administration.version + "." + administration.revision; - - var info = ""; - if (id != null) - info = $"[{id.value}]"; - return Tuple.Create(caption, info); - } - - public override string ToString() - { - var ci = ToCaptionInfo(); - return string.Format("{0}{1}", ci.Item1, (ci.Item2 != "") ? " / " + ci.Item2 : ""); - } - - public SubmodelRef FindSubmodelRef(Identifier refid) - { - if (this.submodelRefs == null) - return null; - foreach (var r in this.submodelRefs) - if (r.Matches(refid)) - return r; - return null; - } - - public bool HasSubmodelRef(SubmodelRef newref) - { - // check, if existing - if (this.submodelRefs == null) - return false; - var found = false; - foreach (var r in this.submodelRefs) - if (r.Matches(newref)) - found = true; - - return found; - } - - public void AddSubmodelRef(SubmodelRef newref) - { - if (this.submodelRefs == null) - this.submodelRefs = new List(); - this.submodelRefs.Add(newref); - } - - public IEnumerable FindAllReferences() - { - // Submodel references - if (this.submodelRefs != null) - foreach (var r in this.submodelRefs) - yield return new LocatedReference(this, r); - } - - public ModelReference GetReference() - { - return ModelReference.CreateNew(new Key(GetElementName(), "" + id?.value)); - } - } - - public class ListOfAdministrationShells : List, IAasElement - { - // self decscription - - public AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("AssetAdministrationShells", "AASs"); - } - - public string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - } - - // - // Asset - // - - public class AssetInformation : IAasElement - { - // as for V3RC02, Asset in no Referable anymore - [XmlIgnore] - [JsonIgnore] - [SkipForHash] // important to skip, as recursion elsewise will go in cycles! - [SkipForReflection] // important to skip, as recursion elsewise will go in cycles! - public IAasElement parent = null; - - // V3RC02: instead of Identification - public GlobalReference globalAssetId; - - // new in V3RC02 - public ListOfIdentifierKeyValuePair specificAssetId = null; - - // new in V3RC02 - public Resource defaultThumbnail = null; - - // some fake information - [XmlIgnore] - [JsonIgnore] - public string fakeIdShort => Key.AssetInformation; - - [XmlIgnore] - [JsonIgnore] - public Description fakeDescription => null; - - // from HasKind - [XmlElement(ElementName = "assetKind")] - [JsonIgnore] - public AssetKind assetKind = new AssetKind(); - [XmlIgnore] - [JsonProperty(PropertyName = "assetKind")] - public string JsonKind - { - get - { - if (assetKind == null) - return null; - return assetKind.kind; - } - set - { - if (assetKind == null) - assetKind = new AssetKind(); - assetKind.kind = value; - } - } - - // constructors - - public AssetInformation() { } - - public AssetInformation(string fakeIdShort) - { - // empty, because V3RC02 does not foresee storage anymore - } - - public AssetInformation(AssetInformation src) - { - if (src == null) - return; - - if (src.assetKind != null) - assetKind = new AssetKind(src.assetKind); - - if (src.globalAssetId != null) - globalAssetId = new GlobalReference(); - - if (src.specificAssetId != null) - specificAssetId = new ListOfIdentifierKeyValuePair(src.specificAssetId); - - if (src.defaultThumbnail != null) - defaultThumbnail = new Resource(src.defaultThumbnail); - } - -#if !DoNotUseAasxCompatibilityModels - public AssetInformation(AasxCompatibilityModels.AdminShellV10.Asset src) - { - if (src == null) - return; - - if (src.kind != null) - this.assetKind = new AssetKind(src.kind); - - if (src.identification != null) - SetIdentification(src.identification.id); - } - - public AssetInformation(AasxCompatibilityModels.AdminShellV20.Asset src) - { - if (src == null) - return; - - if (src.kind != null) - this.assetKind = new AssetKind(src.kind); - - if (src.identification != null) - SetIdentification(src.identification.id); - } -#endif - - // Getter & setters - - public AssetRef GetAssetReference() => new AssetRef(globalAssetId); - - public string GetElementName() => Key.AssetInformation; - - public AasElementSelfDescription GetSelfDescription() - => new AasElementSelfDescription(Key.AssetInformation, "Asset"); - - public Tuple ToCaptionInfo() - { - var caption = Key.AssetInformation; - var info = "" + globalAssetId.ToString(1); - return Tuple.Create(caption, info); - } - - public override string ToString() - { - var ci = ToCaptionInfo(); - return string.Format("{0}{1}", ci.Item1, (ci.Item2 != "") ? " / " + ci.Item2 : ""); - } - - public IEnumerable FindAllReferences() - { - yield break; - } - - public void AddDescription(string lang, string str) - { - // empty, because V3RC02 does not foresee storage anymore - } - - public void SetIdentification(Identifier id) - { - if (id == null) - return; - globalAssetId = new GlobalReference(new Identifier(id)); - } - } - - // - // ConceptDescriptions - // - - /// - /// Multiple lang string for the IEC61360 namespace - /// - public class LangStringSetIEC61360 : ListOfLangStr - { - - // getters / setters - - [XmlIgnore] - [JsonIgnore] - public bool IsEmpty { get { return this.Count < 1; } } - - // constructors - - public LangStringSetIEC61360() { } - - public LangStringSetIEC61360(ListOfLangStr lol) : base(lol) { } - - public LangStringSetIEC61360(LangStringSetIEC61360 src) - { - if (src == null) - return; - foreach (var ls in src) - this.Add(new LangStr(ls)); - } - -#if !DoNotUseAasxCompatibilityModels - public LangStringSetIEC61360(AasxCompatibilityModels.AdminShellV10.LangStringIEC61360 src) - { - if (src.langString != null) - foreach (var ls in src.langString) - this.Add(new LangStr(ls)); - } - - public LangStringSetIEC61360(AasxCompatibilityModels.AdminShellV20.LangStringSetIEC61360 src) - { - if (src == null) - return; - foreach (var ls in src) - this.Add(new LangStr(ls)); - } -#endif - public LangStringSetIEC61360(string lang, string str) - { - if (str == null || str.Trim() == "") - return; - this.Add(new LangStr(lang, str)); - } - - // converter - - public static LangStringSetIEC61360 CreateFrom(List src) - { - var res = new LangStringSetIEC61360(); - if (src != null) - foreach (var ls in src) - res.Add(new LangStr(ls)); - return res; - } - - } - - public class UnitId : GlobalReference - { - // constructors / creators - - public UnitId() : base() { } - public UnitId(Identifier id) : base(id) { } - public UnitId(UnitId src) : base(src) { } - - public UnitId(GlobalReference src) : base(src) { } - public UnitId(Reference src) : base(src) { } - -#if !DoNotUseAasxCompatibilityModels - public UnitId(AasxCompatibilityModels.AdminShellV10.UnitId src) : base(src?.Keys) { } - public UnitId(AasxCompatibilityModels.AdminShellV20.UnitId src) : base(src?.Keys) { } -#endif - } - - [XmlRoot(Namespace = "http://www.admin-shell.io/IEC61360/3/0")] - public class DataSpecificationIEC61360 - { - // static member - [XmlIgnore] - [JsonIgnore] - public static string[] DataTypeNames = { - "STRING", - "STRING_TRANSLATABLE", - "REAL_MEASURE", - "REAL_COUNT", - "REAL_CURRENCY", - "INTEGER_MEASURE", - "INTEGER_COUNT", - "INTEGER_CURRENCY", - "BOOLEAN", - "URL", - "RATIONAL", - "RATIONAL_MEASURE", - "TIME", - "TIMESTAMP", - "DATE" }; - - // members - // TODO (MIHO, 2020-08-27): According to spec, cardinality is [1..1][1..n] - // these cardinalities are NOT MAINTAINED in ANY WAY by the system - public LangStringSetIEC61360 preferredName = new LangStringSetIEC61360(); - - // TODO (MIHO, 2020-08-27): According to spec, cardinality is [0..1][1..n] - // these cardinalities are NOT MAINTAINED in ANY WAY by the system - public LangStringSetIEC61360 shortName = null; - - [MetaModelName("DataSpecificationIEC61360.unit")] - [TextSearchable] - [CountForHash] - public string unit = ""; - - public UnitId unitId = null; - - [MetaModelName("DataSpecificationIEC61360.valueFormat")] - [TextSearchable] - [CountForHash] - public string valueFormat = null; - - [MetaModelName("DataSpecificationIEC61360.sourceOfDefinition")] - [TextSearchable] - [CountForHash] - public string sourceOfDefinition = null; - - [MetaModelName("DataSpecificationIEC61360.symbol")] - [TextSearchable] - [CountForHash] - public string symbol = null; - - [MetaModelName("DataSpecificationIEC61360.dataType")] - [TextSearchable] - [CountForHash] - public string dataType = ""; - - // TODO (MIHO, 2020-08-27): According to spec, cardinality is [0..1][1..n] - // these cardinalities are NOT MAINTAINED in ANY WAY by the system - public LangStringSetIEC61360 definition = null; - - // getter / setters - - // constructors - - public DataSpecificationIEC61360() { } - - public DataSpecificationIEC61360(DataSpecificationIEC61360 src) - { - if (src.preferredName != null) - this.preferredName = new LangStringSetIEC61360(src.preferredName); - this.shortName = src.shortName; - this.unit = src.unit; - if (src.unitId != null) - this.unitId = new UnitId(src.unitId); - this.valueFormat = src.valueFormat; - this.sourceOfDefinition = src.sourceOfDefinition; - this.symbol = src.symbol; - this.dataType = src.dataType; - if (src.definition != null) - this.definition = new LangStringSetIEC61360(src.definition); - } - -#if !DoNotUseAasxCompatibilityModels - public DataSpecificationIEC61360(AasxCompatibilityModels.AdminShellV10.DataSpecificationIEC61360 src) - { - if (src.preferredName != null) - this.preferredName = new LangStringSetIEC61360(src.preferredName); - this.shortName = new LangStringSetIEC61360("EN?", src.shortName); - this.unit = src.unit; - if (src.unitId != null) - this.unitId = new UnitId(src.unitId); - this.valueFormat = src.valueFormat; - if (src.sourceOfDefinition != null && src.sourceOfDefinition.Count > 0) - this.sourceOfDefinition = src.sourceOfDefinition[0].str; - this.symbol = src.symbol; - this.dataType = src.dataType; - if (src.definition != null) - this.definition = new LangStringSetIEC61360(src.definition); - } - - public DataSpecificationIEC61360(AasxCompatibilityModels.AdminShellV20.DataSpecificationIEC61360 src) - { - if (src.preferredName != null) - this.preferredName = new LangStringSetIEC61360(src.preferredName); - this.shortName = new LangStringSetIEC61360(src.shortName); - this.unit = src.unit; - if (src.unitId != null) - this.unitId = new UnitId(src.unitId); - this.valueFormat = src.valueFormat; - this.sourceOfDefinition = src.sourceOfDefinition; - this.symbol = src.symbol; - this.dataType = src.dataType; - if (src.definition != null) - this.definition = new LangStringSetIEC61360(src.definition); - } -#endif - - public static DataSpecificationIEC61360 CreateNew( - string[] preferredName = null, - string shortName = "", - string unit = "", - UnitId unitId = null, - string valueFormat = null, - string sourceOfDefinition = null, - string symbol = null, - string dataType = "", - string[] definition = null - ) - { - var d = new DataSpecificationIEC61360(); - if (preferredName != null) - { - d.preferredName = new LangStringSetIEC61360(LangStr.CreateManyFromStringArray(preferredName)); - } - d.shortName = new LangStringSetIEC61360("EN?", shortName); - d.unit = unit; - d.unitId = unitId; - d.valueFormat = valueFormat; - d.sourceOfDefinition = sourceOfDefinition; - d.symbol = symbol; - d.dataType = dataType; - if (definition != null) - { - if (d.definition == null) - d.definition = new LangStringSetIEC61360(); - d.definition = new LangStringSetIEC61360(LangStr.CreateManyFromStringArray(definition)); - } - return (d); - } - - // "constants" - - public static Key GetKey() - { - return Key.CreateNew( - "GlobalReference", - "http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0"); - } - - public static Identifier GetIdentifier() - { - return new Identifier( - "http://admin-shell.io/DataSpecificationTemplates/DataSpecificationIEC61360/3/0"); - } - - // validation - - public void Validate(AasValidationRecordList results, ConceptDescription cd) - { - // access - if (results == null || cd == null) - return; - - // check IEC61360 spec - if (this.preferredName == null || this.preferredName.Count < 1) - results.Add(new AasValidationRecord( - AasValidationSeverity.SchemaViolation, cd, - "ConceptDescription: missing preferredName", - () => - { - this.preferredName = new AdminShell.LangStringSetIEC61360("EN?", - AdminShellUtil.EvalToNonEmptyString("{0}", cd.idShort, "UNKNOWN")); - })); - - if (this.shortName != null && this.shortName.Count < 1) - results.Add(new AasValidationRecord( - AasValidationSeverity.SchemaViolation, cd, - "ConceptDescription: existing shortName with missing langString", - () => - { - this.shortName = null; - })); - - if (this.definition != null && this.definition.Count < 1) - results.Add(new AasValidationRecord( - AasValidationSeverity.SchemaViolation, cd, - "ConceptDescription: existing definition with missing langString", - () => - { - this.definition = null; - })); - - // check data type - string foundDataType = null; - if (this.dataType != null) - foreach (var dtn in DataTypeNames) - if (this.dataType.Trim() == dtn.Trim()) - foundDataType = this.dataType; - if (foundDataType == null) - results.Add(new AasValidationRecord( - AasValidationSeverity.SchemaViolation, cd, - "ConceptDescription: dataType does not match allowed enumeration values", - () => - { - this.dataType = "STRING"; - })); - } - } - - // ReSharper disable ClassNeverInstantiated.Global .. class is important to show potential for ISO! - - public class DataSpecificationISO99999 - { - } - - // ReSharper enable ClassNeverInstantiated.Global - - public class DataSpecificationContent - { - - // members - - public DataSpecificationIEC61360 dataSpecificationIEC61360 = null; - public DataSpecificationISO99999 dataSpecificationISO99999 = null; - - // constructors - - public DataSpecificationContent() { } - - public DataSpecificationContent(DataSpecificationContent src) - { - if (src.dataSpecificationIEC61360 != null) - this.dataSpecificationIEC61360 = new DataSpecificationIEC61360(src.dataSpecificationIEC61360); - } - -#if !DoNotUseAasxCompatibilityModels - public DataSpecificationContent(AasxCompatibilityModels.AdminShellV10.DataSpecificationContent src) - { - if (src.dataSpecificationIEC61360 != null) - this.dataSpecificationIEC61360 = new DataSpecificationIEC61360(src.dataSpecificationIEC61360); - } - - public DataSpecificationContent(AasxCompatibilityModels.AdminShellV20.DataSpecificationContent src) - { - if (src.dataSpecificationIEC61360 != null) - this.dataSpecificationIEC61360 = new DataSpecificationIEC61360(src.dataSpecificationIEC61360); - } -#endif - } - - public class EmbeddedDataSpecification - { - // members - - [JsonIgnore] - public DataSpecificationContent dataSpecificationContent = null; - - [XmlIgnore] - [JsonProperty("dataSpecificationContent")] - public DataSpecificationIEC61360 JsonWrongDataSpec61360 - { - get { return dataSpecificationContent?.dataSpecificationIEC61360; } - set - { - if (dataSpecificationContent == null) - dataSpecificationContent = new DataSpecificationContent(); - dataSpecificationContent.dataSpecificationIEC61360 = value; - } - } - - public DataSpecificationRef dataSpecification = null; - - // constructors - - public EmbeddedDataSpecification() { } - - public EmbeddedDataSpecification( - DataSpecificationRef dataSpecification, - DataSpecificationContent dataSpecificationContent) - { - this.dataSpecification = dataSpecification; - this.dataSpecificationContent = dataSpecificationContent; - } - - public EmbeddedDataSpecification(EmbeddedDataSpecification src) - { - if (src.dataSpecification != null) - this.dataSpecification = new DataSpecificationRef(src.dataSpecification); - if (src.dataSpecificationContent != null) - this.dataSpecificationContent = new DataSpecificationContent(src.dataSpecificationContent); - } - - public EmbeddedDataSpecification(GlobalReference src) - { - if (src != null) - this.dataSpecification = new DataSpecificationRef(src); - } - -#if !DoNotUseAasxCompatibilityModels - public EmbeddedDataSpecification(AasxCompatibilityModels.AdminShellV10.EmbeddedDataSpecification src) - { - if (src.hasDataSpecification != null) - this.dataSpecification = new DataSpecificationRef(src.hasDataSpecification); - if (src.dataSpecificationContent != null) - this.dataSpecificationContent = new DataSpecificationContent(src.dataSpecificationContent); - } - - public EmbeddedDataSpecification(AasxCompatibilityModels.AdminShellV10.Reference src) - { - if (src != null) - this.dataSpecification = new DataSpecificationRef(src); - } - - public EmbeddedDataSpecification(AasxCompatibilityModels.AdminShellV20.EmbeddedDataSpecification src) - { - if (src.dataSpecification != null) - this.dataSpecification = new DataSpecificationRef(src.dataSpecification); - if (src.dataSpecificationContent != null) - this.dataSpecificationContent = new DataSpecificationContent(src.dataSpecificationContent); - } -#endif - - public static EmbeddedDataSpecification CreateIEC61360WithContent() - { - var eds = new EmbeddedDataSpecification(new DataSpecificationRef(), new DataSpecificationContent()); - - eds.dataSpecification.Value.Add(DataSpecificationIEC61360.GetIdentifier()); - - eds.dataSpecificationContent.dataSpecificationIEC61360 = - AdminShell.DataSpecificationIEC61360.CreateNew(); - - return eds; - } - - public DataSpecificationIEC61360 GetIEC61360() - { - return this.dataSpecificationContent?.dataSpecificationIEC61360; - } - } - - public class ConceptDescription : Identifiable, System.IDisposable - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } - - // members - - // do this in order to be IDisposable, that is: suitable for (using) - void System.IDisposable.Dispose() { } - public void GetData() { } - // from HasDataSpecification - -#if __not_anymore - - [XmlElement(ElementName = "embeddedDataSpecification")] - [JsonIgnore] - public EmbeddedDataSpecification embeddedDataSpecification = new EmbeddedDataSpecification(); -#else - // According to Spec V2.0.1, a ConceptDescription might feature alos multiple data specifications - /* TODO (MIHO, 2020-08-30): align wording of the member ("embeddedDataSpecification") with the - * wording of the other entities ("hasDataSpecification") */ - [XmlElement(ElementName = "embeddedDataSpecification")] - [JsonIgnore] - public HasDataSpecification embeddedDataSpecification = null; -#endif - - [XmlIgnore] - [JsonProperty(PropertyName = "embeddedDataSpecifications")] - public EmbeddedDataSpecification[] JsonEmbeddedDataSpecifications - { - get - { - return this.embeddedDataSpecification?.ToArray(); - } - set - { - embeddedDataSpecification = new HasDataSpecification(value); - } - } - - // old - - // this class - [XmlIgnore] - private List isCaseOf = null; - - // getter / setter - - [XmlElement(ElementName = "isCaseOf")] - [JsonProperty(PropertyName = "isCaseOf")] - public List IsCaseOf - { - get { return isCaseOf; } - set { isCaseOf = value; } - } - - // constructors / creators - - public ConceptDescription() : base() { } - - public ConceptDescription(ConceptDescription src) - : base(src) - { - if (src.embeddedDataSpecification != null) - this.embeddedDataSpecification = new HasDataSpecification(src.embeddedDataSpecification); - if (src.isCaseOf != null) - foreach (var ico in src.isCaseOf) - { - if (this.isCaseOf == null) - this.isCaseOf = new List(); - this.isCaseOf.Add(new ModelReference(ico)); - } - } - -#if !DoNotUseAasxCompatibilityModels - public ConceptDescription(AasxCompatibilityModels.AdminShellV10.ConceptDescription src) - : base(src) - { - if (src.embeddedDataSpecification != null) - { - this.embeddedDataSpecification = new HasDataSpecification(); - this.embeddedDataSpecification.Add(new EmbeddedDataSpecification(src.embeddedDataSpecification)); - } - if (src.IsCaseOf != null) - foreach (var ico in src.IsCaseOf) - { - if (this.isCaseOf == null) - this.isCaseOf = new List(); - this.isCaseOf.Add(new ModelReference(ico)); - } - } - - public ConceptDescription(AasxCompatibilityModels.AdminShellV20.ConceptDescription src) - : base(src) - { - if (src.embeddedDataSpecification != null) - this.embeddedDataSpecification = new HasDataSpecification(src.embeddedDataSpecification); - if (src.IsCaseOf != null) - foreach (var ico in src.IsCaseOf) - { - if (this.isCaseOf == null) - this.isCaseOf = new List(); - this.isCaseOf.Add(new ModelReference(ico)); - } - } -#endif - - public static ConceptDescription CreateNew( - string idShort, string idType, string id, string version = null, string revision = null) - { - var cd = new ConceptDescription(); - cd.idShort = idShort; - cd.id.value = id; - if (version != null) - { - if (cd.administration == null) - cd.administration = new Administration(); - cd.administration.version = version; - cd.administration.revision = revision; - } - return (cd); - } - - public Key GetSingleKey() - { - return Key.CreateNew(this.GetElementName(), this.id.value); - } - - public Identifier GetSingleId() - { - return new Identifier(this.id.value); - } - - /// - /// In order to be semantically precise, use this id to figure out - /// the single id zo be put in a semantic id. - /// - public Identifier GetSemanticId() - { - return new Identifier(this.id.value); - } - - public ConceptDescriptionRef GetCdReference() - { - var r = new ConceptDescriptionRef(); - r.Keys.Add( - Key.CreateNew(this.GetElementName(), this.id.value)); - return r; - } - - public void SetIEC61360Spec( - string[] preferredNames = null, - string shortName = "", - string unit = "", - UnitId unitId = null, - string valueFormat = null, - string sourceOfDefinition = null, - string symbol = null, - string dataType = "", - string[] definition = null - ) - { - var eds = new EmbeddedDataSpecification(new DataSpecificationRef(), new DataSpecificationContent()); - eds.dataSpecification.Value.Add( - DataSpecificationIEC61360.GetIdentifier()); - eds.dataSpecificationContent.dataSpecificationIEC61360 = - AdminShell.DataSpecificationIEC61360.CreateNew( - preferredNames, shortName, unit, unitId, valueFormat, sourceOfDefinition, symbol, - dataType, definition); - - this.embeddedDataSpecification = new HasDataSpecification(); - this.embeddedDataSpecification.Add(eds); - - this.AddIsCaseOf( - ModelReference.CreateNew(new Key("ConceptDescription", this.id.value))); - } - - public DataSpecificationIEC61360 GetIEC61360() - { - return this.embeddedDataSpecification?.IEC61360Content; - } - - // as experimental approach, forward the IEC getter/sett of hasDataSpec directly - - [XmlIgnore] - [JsonIgnore] - public EmbeddedDataSpecification IEC61360DataSpec - { - get - { - return this.embeddedDataSpecification?.IEC61360; - } - set - { - // add embeddedDataSpecification first? - if (this.embeddedDataSpecification == null) - this.embeddedDataSpecification = new HasDataSpecification(); - this.embeddedDataSpecification.IEC61360 = value; - } - } - - [XmlIgnore] - [JsonIgnore] - public DataSpecificationIEC61360 IEC61360Content - { - get - { - return this.embeddedDataSpecification?.IEC61360Content; - } - set - { - // add embeddedDataSpecification first? - if (this.embeddedDataSpecification == null) - this.embeddedDataSpecification = new HasDataSpecification(); - - // check, if e IEC61360 can be found - var eds = this.embeddedDataSpecification.IEC61360; - - // if already there, update - if (eds != null) - { - eds.dataSpecificationContent = new DataSpecificationContent(); - eds.dataSpecificationContent.dataSpecificationIEC61360 = value; - return; - } - - // no: add a full record - eds = EmbeddedDataSpecification.CreateIEC61360WithContent(); - eds.dataSpecificationContent.dataSpecificationIEC61360 = value; - this.embeddedDataSpecification.Add(eds); - } - } - - public DataSpecificationIEC61360 CreateDataSpecWithContentIec61360() - { - var eds = AdminShell.EmbeddedDataSpecification.CreateIEC61360WithContent(); - if (this.embeddedDataSpecification == null) - this.embeddedDataSpecification = new HasDataSpecification(); - this.embeddedDataSpecification.Add(eds); - return eds.dataSpecificationContent?.dataSpecificationIEC61360; - } - - public string GetDefaultPreferredName(string defaultLang = null) - { - return "" + - GetIEC61360()? - .preferredName?.GetDefaultStr(defaultLang); - } - - public string GetDefaultShortName(string defaultLang = null) - { - return "" + - GetIEC61360()? - .shortName?.GetDefaultStr(defaultLang); - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("ConceptDescription", "CD"); - } - - public Tuple ToCaptionInfo() - { - var caption = ""; - if (this.idShort != null && this.idShort.Trim() != "") - caption = $"\"{this.idShort.Trim()}\""; - if (this.id != null) - caption = (caption + " " + this.id).Trim(); - - var info = "" + GetDefaultShortName(); - - return Tuple.Create(caption, info); - } - - public override string ToString() - { - var ci = ToCaptionInfo(); - return string.Format("{0}{1}", ci.Item1, (ci.Item2 != "") ? " / " + ci.Item2 : ""); - } - - public void AddIsCaseOf(ModelReference ico) - { - if (isCaseOf == null) - isCaseOf = new List(); - isCaseOf.Add(ico); - } - - public static IDisposable CreateNew() - { - throw new NotImplementedException(); - } - - // validation - - public override void Validate(AasValidationRecordList results) - { - // access - if (results == null) - return; - - // check CD itself - base.Validate(results); - - // check IEC61360 spec - var eds61360 = this.IEC61360DataSpec; - if (eds61360 != null) - { - // check data spec - if (eds61360.dataSpecification == null || - !(eds61360.dataSpecification.MatchesExactlyOneId(DataSpecificationIEC61360.GetIdentifier()))) - results.Add(new AasValidationRecord( - AasValidationSeverity.SpecViolation, this, - "HasDataSpecification: data specification content set to IEC61360, but no " + - "data specification reference set!", - () => - { - eds61360.dataSpecification = new DataSpecificationRef( - new GlobalReference( - DataSpecificationIEC61360.GetIdentifier())); - })); - - // validate content - if (eds61360.dataSpecificationContent?.dataSpecificationIEC61360 == null) - { - results.Add(new AasValidationRecord( - AasValidationSeverity.SpecViolation, this, - "HasDataSpecification: data specification reference set to IEC61360, but no " + - "data specification content set!", - () => - { - eds61360.dataSpecificationContent = new DataSpecificationContent(); - eds61360.dataSpecificationContent.dataSpecificationIEC61360 = - new DataSpecificationIEC61360(); - })); - } - else - { - // validate - eds61360.dataSpecificationContent.dataSpecificationIEC61360.Validate(results, this); - } - } - } - - // more find - - public IEnumerable FindAllReferences() - { - yield break; - } - } - - public class ListOfConceptDescriptions : List, IAasElement - { - // finding - - public ConceptDescription Find(ConceptDescriptionRef cdr) - { - if (cdr == null) - return null; - return Find(cdr.Keys); - } - - public ConceptDescription Find(Identifier id) - { - var cdr = ConceptDescriptionRef.CreateNew("Conceptdescription", id.value); - return Find(cdr); - } - - public ConceptDescription Find(List keys) - { - // trivial - if (keys == null) - return null; - // can only refs with 1 key - if (keys.Count != 1) - return null; - // and we're picky - var key = keys[0]; - if (key.type.ToLower().Trim() != "conceptdescription") - return null; - // brute force - foreach (var cd in this) - if (cd.id.value.ToLower().Trim() == key.value.ToLower().Trim()) - return cd; - // uups - return null; - } - - // item management - - public ConceptDescription AddIfNew(ConceptDescription cd) - { - if (cd == null) - return null; - - var exist = this.Find(cd.id); - if (exist != null) - return exist; - - this.Add(cd); - return cd; - } - - // self decscription - - public AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("ConceptDescriptions", "CDS"); - } - - public string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - - // sorting - - - } - - // - // Submodel - // - - public class Submodel : Identifiable, IManageSubmodelElements, - System.IDisposable, IEnumerateChildren, IFindAllReferences, - IGetSemanticId, IGetQualifiers - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } - - // members - - // do this in order to be IDisposable, that is: suitable for (using) - void System.IDisposable.Dispose() { } - public void GetData() { } - - // from HasKind - [XmlElement(ElementName = "kind")] - [JsonIgnore] - public ModelingKind kind = new ModelingKind(); - [XmlIgnore] - [JsonProperty(PropertyName = "kind")] - public string JsonKind - { - get - { - if (kind == null) - return null; - return kind.kind; - } - set - { - if (kind == null) - kind = new ModelingKind(); - kind.kind = value; - } - } - - // from hasSemanticId: - [XmlElement(ElementName = "semanticId")] - public SemanticId semanticId = new SemanticId(); - public SemanticId GetSemanticId() { return semanticId; } - - // from Qualifiable: - [XmlArray("qualifier")] - [XmlArrayItem("qualifier")] - public QualifierCollection qualifiers = null; - public QualifierCollection GetQualifiers() => qualifiers; - - // from hasDataSpecification: - [XmlElement(ElementName = "embeddedDataSpecification")] - public HasDataSpecification hasDataSpecification = null; - - // from this very class - [XmlIgnore] - [JsonIgnore] - private SubmodelElementWrapperCollection _submodelElements = null; - - [JsonIgnore] - public SubmodelElementWrapperCollection submodelElements - { - get { return _submodelElements; } - set { _submodelElements = value; _submodelElements.Parent = this; } - } - - [XmlIgnore] - [JsonProperty(PropertyName = "submodelElements")] - public SubmodelElement[] JsonSubmodelElements - { - get - { - var res = new ListOfSubmodelElement(); - if (submodelElements != null) - foreach (var smew in submodelElements) - res.Add(smew.submodelElement); - return res.ToArray(); - } - set - { - if (value != null) - { - this.submodelElements = new SubmodelElementWrapperCollection(); - foreach (var x in value) - { - var smew = new SubmodelElementWrapper() { submodelElement = x }; - this.submodelElements.Add(smew); - } - } - } - } - - // getter / setter - - // constructors / creators - - public Submodel() : base() { } - - public Submodel(Submodel src, bool shallowCopy = false) - : base(src) - { - if (src == null) - return; - if (src.hasDataSpecification != null) - this.hasDataSpecification = new HasDataSpecification(src.hasDataSpecification); - if (src.semanticId != null) - this.semanticId = new SemanticId(src.semanticId); - if (src.kind != null) - this.kind = new ModelingKind(src.kind); - if (!shallowCopy && src.submodelElements != null) - { - if (this.submodelElements == null) - this.submodelElements = new SubmodelElementWrapperCollection(); - foreach (var smw in src.submodelElements) - this.submodelElements.Add(new SubmodelElementWrapper(smw.submodelElement, shallowCopy: false)); - } - } - -#if !DoNotUseAasxCompatibilityModels - public Submodel(AasxCompatibilityModels.AdminShellV10.Submodel src, bool shallowCopy = false) - : base(src) - { - if (src.hasDataSpecification != null) - this.hasDataSpecification = new HasDataSpecification(src.hasDataSpecification); - if (src.semanticId != null) - this.semanticId = new SemanticId(src.semanticId); - if (src.kind != null) - this.kind = new ModelingKind(src.kind); - if (src.qualifiers != null) - this.qualifiers = new QualifierCollection(src.qualifiers); - if (!shallowCopy && src.submodelElements != null) - { - if (this.submodelElements == null) - this.submodelElements = new SubmodelElementWrapperCollection(); - foreach (var smw in src.submodelElements) - this.submodelElements.Add(new SubmodelElementWrapper(smw.submodelElement, shallowCopy: false)); - } - } - - public Submodel(AasxCompatibilityModels.AdminShellV20.Submodel src, bool shallowCopy = false) - : base(src) - { - if (src == null) - return; - if (src.hasDataSpecification != null) - this.hasDataSpecification = new HasDataSpecification(src.hasDataSpecification); - if (src.semanticId != null) - this.semanticId = new SemanticId(src.semanticId); - if (src.kind != null) - this.kind = new ModelingKind(src.kind); - if (!shallowCopy && src.submodelElements != null) - { - if (this.submodelElements == null) - this.submodelElements = new SubmodelElementWrapperCollection(); - foreach (var smw in src.submodelElements) - this.submodelElements.Add(new SubmodelElementWrapper(smw.submodelElement, shallowCopy: false)); - } - } -#endif - - public static Submodel CreateNew(string idType, string id, string version = null, string revision = null) - { - var s = new Submodel() { id = new Identifier(id) }; - if (version != null) - { - if (s.administration == null) - s.administration = new Administration(); - s.administration.version = version; - s.administration.revision = revision; - } - return (s); - } - - [JsonIgnore] - [XmlIgnore] - public SubmodelElementWrapperCollection SmeForWrite - { - get - { - if (this.submodelElements == null) - this.submodelElements = new SubmodelElementWrapperCollection(); - return this.submodelElements; - } - } - - // from IEnumarateChildren - public IEnumerable EnumerateChildren() - { - if (this.submodelElements != null) - foreach (var smw in this.submodelElements) - yield return smw; - } - - public EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child) - { - return null; - } - - public object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null) - { - if (smw == null) - return null; - if (this.submodelElements == null) - this.submodelElements = new SubmodelElementWrapperCollection(); - if (smw.submodelElement != null) - smw.submodelElement.parent = this; - this.submodelElements.Add(smw); - return smw; - } - - // from IManageSubmodelElements - public void Add(SubmodelElement sme) - { - if (submodelElements == null) - submodelElements = new SubmodelElementWrapperCollection(); - var sew = new SubmodelElementWrapper(); - sme.parent = this; // track parent here! - sew.submodelElement = sme; - submodelElements.Add(sew); - } - - public void Insert(int index, SubmodelElement sme) - { - if (submodelElements == null) - submodelElements = new SubmodelElementWrapperCollection(); - var sew = new SubmodelElementWrapper(); - sme.parent = this; // track parent here! - sew.submodelElement = sme; - if (index < 0 || index > submodelElements.Count) - return; - submodelElements.Insert(index, sew); - } - - public void Remove(SubmodelElement sme) - { - if (submodelElements != null) - submodelElements.Remove(sme); - } - - // further - - public void AddQualifier( - string qualifierType = null, string qualifierValue = null, KeyList semanticKeys = null, - GlobalReference qualifierValueId = null) - { - QualifierCollection.AddQualifier( - ref this.qualifiers, qualifierType, qualifierValue, semanticKeys, qualifierValueId); - } - - public Qualifier HasQualifierOfType(string qualifierType) - { - return QualifierCollection.HasQualifierOfType(this.qualifiers, qualifierType); - } - - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Submodel", "SM"); - } - - public SubmodelRef GetSubmodelRef() - => new SubmodelRef(GetModelReference()); - - /// - /// If instance, return semanticId as one key. - /// If template, return identification as key. - /// - public Key GetAutoSingleKey() - { - if (true == this.kind?.IsTemplate) - return new Key(this.GetElementName(), this.id?.value); - else - return this.semanticId?.GetAsExactlyOneKey(); - } - - /// - /// If instance, return semanticId as one key. - /// If template, return identification as key. - /// - public Identifier GetAutoSingleId() - { - if (true == this.kind?.IsTemplate) - return new Identifier(this.id); - else - return this.semanticId?.GetAsIdentifier(strict: true); - } - - public void AddDataSpecification(Identifier id) - { - if (hasDataSpecification == null) - hasDataSpecification = new HasDataSpecification(); - hasDataSpecification.Add(new EmbeddedDataSpecification(new GlobalReference(id))); - } - - public SubmodelElementWrapper FindSubmodelElementWrapper(string idShort) - { - if (this.submodelElements == null) - return null; - foreach (var smw in this.submodelElements) - if (smw.submodelElement != null) - if (smw.submodelElement.idShort.Trim().ToLower() == idShort.Trim().ToLower()) - return smw; - return null; - } - - public IEnumerable FindDeep(Predicate match = null) where T : SubmodelElement - { - if (this.submodelElements == null) - yield break; - foreach (var x in this.submodelElements.FindDeep(match)) - yield return x; - } - - public Tuple ToCaptionInfo() - { - var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, ""); - if (administration != null) - caption += "V" + administration.version + "." + administration.revision; - var info = ""; - if (id != null) - info = $"[{id.value}]"; - return Tuple.Create(caption, info); - } - - public override string ToString() - { - var ci = ToCaptionInfo(); - return string.Format("{0}{1}", ci.Item1, (ci.Item2 != "") ? " / " + ci.Item2 : ""); - } - - // Recursing - - /// - /// Recurses on all Submodel elements of a Submodel or SME, which allows children. - /// The state object will be passed to the lambda function in order to provide - /// stateful approaches. - /// - /// State object to be provided to lambda. Could be null. - /// The lambda function as (state, parents, SME) - /// The lambda shall return TRUE in order to deep into recursion. - /// - public void RecurseOnSubmodelElements( - object state, Func lambda) - { - this.submodelElements?.RecurseOnReferables(state, null, (o, par, rf) => - { - if (rf is SubmodelElement sme) - return lambda(o, par, sme); - else - return true; - }); - } - - /// - /// Recurses on all Submodel elements of a Submodel or SME, which allows children. - /// The state object will be passed to the lambda function in order to provide - /// stateful approaches. Include this element, as well. - /// - /// State object to be provided to lambda. Could be null. - /// The lambda function as (state, parents, SME) - /// The lambda shall return TRUE in order to deep into recursion. - /// Include this element as well. parents will then - /// include this element as well! - public override void RecurseOnReferables( - object state, Func lambda, - bool includeThis = false) - { - var parents = new ListOfReferable(); - if (includeThis) - { - lambda(state, null, this); - parents.Add(this); - } - this.submodelElements?.RecurseOnReferables(state, parents, lambda); - } - - // Parents stuff - - public static void SetParentsForSME(Referable parent, SubmodelElement se) - { - if (se == null) - return; - - se.parent = parent; - - // via interface enumaration - if (se is IEnumerateChildren) - { - var childs = (se as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - SetParentsForSME(se, c.submodelElement); - } - } - - public void SetAllParents() - { - if (this.submodelElements != null) - foreach (var sme in this.submodelElements) - SetParentsForSME(this, sme.submodelElement); - } - - public T CreateSMEForCD(ConceptDescription cd, string category = null, string idShort = null, - string idxTemplate = null, int maxNum = 999, bool addSme = false) where T : SubmodelElement, new() - { - if (this.submodelElements == null) - this.submodelElements = new SubmodelElementWrapperCollection(); - return this.submodelElements.CreateSMEForCD(cd, category, idShort, idxTemplate, maxNum, addSme); - } - - public T CreateSMEForIdShort(string idShort, string category = null, - string idxTemplate = null, int maxNum = 999, bool addSme = false) where T : SubmodelElement, new() - { - if (this.submodelElements == null) - this.submodelElements = new SubmodelElementWrapperCollection(); - return this.submodelElements.CreateSMEForIdShort(idShort, category, idxTemplate, maxNum, addSme); - } - - // validation - - public override void Validate(AasValidationRecordList results) - { - // access - if (results == null) - return; - - // check - base.Validate(results); - ModelingKind.Validate(results, kind, this); - ListOfIdentifier.Validate(results, semanticId?.Value, this); - } - - // find - - public IEnumerable FindAllReferences() - { - // not nice: use temp list - var temp = new List(); - - // recurse - this.RecurseOnSubmodelElements(null, (state, parents, sme) => - { - if (sme is ModelReferenceElement mre) - if (mre.value != null) - temp.Add(mre.value); - if (sme is RelationshipElement rl) - { - if (rl.first != null) - temp.Add(rl.first); - if (rl.second != null) - temp.Add(rl.second); - } - // recurse - return true; - }); - - // now, give back - foreach (var r in temp) - yield return new LocatedReference(this, r); - } - - #region Timestamp - public void SetAllParents(DateTime timeStamp) - { - if (this.submodelElements != null) - foreach (var sme in this.submodelElements) - SetParentsForSME(this, sme.submodelElement, timeStamp); - } - - private static void SetParentsForSME(Referable parent, SubmodelElement se, DateTime timeStamp) - { - if (se == null) - return; - - se.parent = parent; - se.TimeStamp = timeStamp; - se.TimeStampCreate = timeStamp; - - // via interface enumaration - if (se is IEnumerateChildren) - { - var childs = (se as IEnumerateChildren).EnumerateChildren(); - if (childs != null) - foreach (var c in childs) - SetParentsForSME(se, c.submodelElement, timeStamp); - } - } - - #endregion - } - - public class ListOfSubmodels : List, IAasElement - { - // self decscription - - public AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Submodels", "SMS"); - } - - public string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - } - - } -} diff --git a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_Root_AasEnv.cs b/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_Root_AasEnv.cs deleted file mode 100644 index d8f679139..000000000 --- a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_Root_AasEnv.cs +++ /dev/null @@ -1,1075 +0,0 @@ -/* -Copyright (c) 2018-2021 Festo AG & Co. KG -Author: Michael Hoffmeister - -This source code is licensed under the Apache License 2.0 (see LICENSE.txt). - -This source code may use other Open Source software components (see LICENSE.txt). -*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Globalization; -using System.IO; -using System.IO.Packaging; -using System.Linq; -using System.Reflection; -using System.Runtime; -using System.Text; -using System.Text.RegularExpressions; -using System.Xml; -using System.Xml.Serialization; -using AdminShellNS; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - -//namespace AdminShellNS -namespace AdminShell_V30 -{ - /// - /// Partial main class of AdminShell: SubmodelElements - /// - public partial class AdminShellV30 - { - - // - // AAS ENV - // - - /// - /// Result of FindReferable in Environment - /// - public class ReferableRootInfo - { - public AdministrationShell AAS = null; - public AssetInformation Asset = null; - public Submodel Submodel = null; - - public int NrOfRootKeys = 0; - - public bool IsValid - { - get - { - return NrOfRootKeys > 0 && (AAS != null || Submodel != null || Asset != null); - } - } - } - - [XmlRoot(ElementName = "aasenv", Namespace = "http://www.admin-shell.io/aas/3/0")] - public class AdministrationShellEnv : IFindAllReferences, IAasElement, IDiaryData, IRecurseOnReferables - { - // diary (as e.g. deleted AASes need to be listed somewhere) - - [XmlIgnore] - [JsonIgnore] - [SkipForHash] - [SkipForReflection] - private DiaryDataDef _diaryData = new DiaryDataDef(); - - [XmlIgnore] - [JsonIgnore] - [SkipForReflection] - public DiaryDataDef DiaryData { get { return _diaryData; } } - - // members - - [XmlAttribute(Namespace = System.Xml.Schema.XmlSchema.InstanceNamespace)] - [JsonIgnore] - public string schemaLocation = - "http://www.admin-shell.io/aas/3/0 AAS.xsd http://www.admin-shell.io/IEC61360/3/0 IEC61360.xsd"; - - [XmlIgnore] // will be ignored, anyway - private ListOfAdministrationShells administrationShells = new ListOfAdministrationShells(); - [XmlIgnore] // will be ignored, anyway - private List assets = new List(); - [XmlIgnore] // will be ignored, anyway - private ListOfSubmodels submodels = new ListOfSubmodels(); - [XmlIgnore] // will be ignored, anyway - private ListOfConceptDescriptions conceptDescriptions = new ListOfConceptDescriptions(); - - // getter / setters - - [XmlArray("assetAdministrationShells")] - [XmlArrayItem("assetAdministrationShell")] - [JsonProperty(PropertyName = "assetAdministrationShells")] - public ListOfAdministrationShells AdministrationShells - { - get { return administrationShells; } - set { administrationShells = value; } - } - - [XmlArray("assets")] - [XmlArrayItem("asset")] - [JsonProperty(PropertyName = "assets")] - public List Assets - { - get { return assets; } - set { assets = value; } - } - - [XmlArray("submodels")] - [XmlArrayItem("submodel")] - [JsonProperty(PropertyName = "submodels")] - public ListOfSubmodels Submodels - { - get { return submodels; } - set { submodels = value; } - } - - [XmlArray("conceptDescriptions")] - [XmlArrayItem("conceptDescription")] - [JsonProperty(PropertyName = "conceptDescriptions")] - public ListOfConceptDescriptions ConceptDescriptions - { - get { return conceptDescriptions; } - set { conceptDescriptions = value; } - } - - // constructors - - public AdministrationShellEnv() { } - -#if !DoNotUseAasxCompatibilityModels - public AdministrationShellEnv(AasxCompatibilityModels.AdminShellV10.AdministrationShellEnv src) - { - if (src.AdministrationShells != null) - foreach (var aas in src.AdministrationShells) - this.administrationShells.Add(new AdministrationShell(aas, src)); - - // AssetInformation is aleady migrated in the constrcutor above - - if (src.Submodels != null) - foreach (var sm in src.Submodels) - this.submodels.Add(new Submodel(sm)); - - if (src.ConceptDescriptions != null) - foreach (var cd in src.ConceptDescriptions) - this.conceptDescriptions.Add(new ConceptDescription(cd)); - } - - public AdministrationShellEnv(AasxCompatibilityModels.AdminShellV20.AdministrationShellEnv src) - { - if (src.AdministrationShells != null) - foreach (var aas in src.AdministrationShells) - this.administrationShells.Add(new AdministrationShell(aas, src)); - - // AssetInformation is aleady migrated in the constrcutor above - - if (src.Submodels != null) - foreach (var sm in src.Submodels) - this.submodels.Add(new Submodel(sm)); - - if (src.ConceptDescriptions != null) - foreach (var cd in src.ConceptDescriptions) - this.conceptDescriptions.Add(new ConceptDescription(cd)); - } -#endif - - // to String - - public override string ToString() - { - var res = "AAS-ENV"; - if (AdministrationShells != null) - res += $" {AdministrationShells.Count} AAS"; - if (Submodels != null) - res += $" {Submodels.Count} Submodels"; - if (ConceptDescriptions != null) - res += $" {ConceptDescriptions.Count} CDs"; - return res; - } - - // self decscription - - public AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("AdministrationShellEnv", "Env"); - } - - public string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - - // finders - - public AdministrationShell FindAAS(Identifier id) - { - if (id == null) - return null; - foreach (var aas in this.AdministrationShells) - if (aas.id != null && aas.id.IsEqual(id)) - return aas; - return null; - } - - public AdministrationShell FindAAS(string idShort) - { - if (idShort == null) - return null; - foreach (var aas in this.AdministrationShells) - if (aas.idShort != null && aas.idShort.Trim().ToLower() == idShort.Trim().ToLower()) - return aas; - return null; - } - - public AdministrationShell FindAASwithSubmodel(Identifier smid) - { - if (smid == null) - return null; - foreach (var aas in this.AdministrationShells) - if (aas.submodelRefs != null) - foreach (var smref in aas.submodelRefs) - if (smref.Matches(smid)) - return aas; - return null; - } - - public IEnumerable FindAllAAS( - Predicate p = null) - { - if (this.administrationShells == null) - yield break; - foreach (var x in this.administrationShells) - if (p == null || p(x)) - yield return x; - } - - public IEnumerable FindAllSubmodelGroupedByAAS( - Func p = null) - { - if (this.administrationShells == null || this.submodels == null) - yield break; - foreach (var aas in this.administrationShells) - { - if (aas?.submodelRefs == null) - continue; - foreach (var smref in aas.submodelRefs) - { - var sm = this.FindSubmodel(smref); - if (sm != null && (p == null || p(aas, sm))) - yield return sm; - } - } - } - - public AdministrationShell FindAasWithAssetInfo(Identifier id) - { - if (id == null) - return null; - foreach (var aas in this.AdministrationShells) - if (aas?.assetInformation?.globalAssetId?.Matches(id) == true) - return aas; - return null; - } - - public AdministrationShell FindAasWithAsset(AssetRef aref) - { - // trivial - if (aref == null) - return null; - // can only refs with 1 key - if (aref.Count != 1) - return null; - // brute force - foreach (var aas in this.AdministrationShells) - if (aas?.assetInformation?.globalAssetId?.Matches(aref) == true) - return aas; - // uups - return null; - } - - public Submodel FindSubmodel(Identifier id) - { - if (id == null) - return null; - foreach (var sm in this.Submodels) - if (sm.id != null && sm.id.IsEqual(id)) - return sm; - return null; - } - - public Submodel FindSubmodel(SubmodelRef smref) - { - // trivial - if (smref == null) - return null; - // can only refs with 1 key - if (smref.Count != 1) - return null; - // and we're picky - var key = smref.Keys[0]; - if (key.type.ToLower().Trim() != "submodel") - return null; - // brute force - foreach (var sm in this.Submodels) - if (sm.id.value.ToLower().Trim() == key.value.ToLower().Trim()) - return sm; - // uups - return null; - } - - public Submodel FindFirstSubmodelBySemanticId(Identifier semId) - { - // access - if (semId == null) - return null; - - // brute force - foreach (var sm in this.Submodels) - if (true == sm.semanticId?.MatchesExactlyOneId(semId)) - return sm; - - return null; - } - - public IEnumerable FindAllSubmodelBySemanticId( - Identifier semId, Key.MatchMode matchMode = Key.MatchMode.Identification) - { - // access - if (semId == null) - yield break; - - // brute force - foreach (var sm in this.Submodels) - if (true == sm.semanticId?.MatchesExactlyOneId(semId, matchMode)) - yield return sm; - } - - public IEnumerable FindAllReferable(Predicate p) - { - if (p == null) - yield break; - - foreach (var r in this.FindAllReferable()) - if (r != null && p(r)) - yield return r; - } - - public IEnumerable FindAllReferable(bool onlyIdentifiables = false) - { - if (this.AdministrationShells != null) - foreach (var aas in this.AdministrationShells) - if (aas != null) - { - // AAS itself - yield return aas; - } - - if (this.Submodels != null) - foreach (var sm in this.Submodels) - if (sm != null) - { - yield return sm; - - if (!onlyIdentifiables) - { - // TODO (MIHO, 2020-08-26): not very elegant, yet. Avoid temporary collection - var allsme = new ListOfSubmodelElement(); - sm.RecurseOnSubmodelElements(null, (state, parents, sme) => - { - allsme.Add(sme); return true; - }); - foreach (var sme in allsme) - yield return sme; - } - } - - if (this.ConceptDescriptions != null) - foreach (var cd in this.ConceptDescriptions) - if (cd != null) - yield return cd; - } - - // - // Reference handling - // - - public Referable FindReferableByReference(ModelReference rf, int keyIndex = 0, bool exactMatch = false) - { - return FindReferableByReference(rf?.Keys); - } - - public Referable FindReferableByReference(KeyList kl, int keyIndex = 0, bool exactMatch = false, - ReferableRootInfo rootInfo = null) - { - // first index needs to exist .. - if (kl == null || keyIndex >= kl.Count) - return null; - - // which type? - var firstType = kl[keyIndex].type.Trim().ToLower(); - var firstIdentification = new Identifier(kl[keyIndex].value); - AdministrationShell aasToFollow = null; - - if (firstType == Key.AAS.Trim().ToLower()) - { - // search aas - var aas = this.FindAAS(firstIdentification); - - // not found or already at end with our search? - if (aas == null || keyIndex >= kl.Count - 1) - return aas; - - // side info? - if (rootInfo != null) - { - rootInfo.AAS = aas; - rootInfo.NrOfRootKeys = 1 + keyIndex; - } - - // follow up - aasToFollow = aas; - } - - if (firstType == Key.AssetInformation.Trim().ToLower()) - { - // search asset - var aas4asset = this.FindAasWithAssetInfo(firstIdentification); - - // not found or already at end with our search? - if (aas4asset == null || keyIndex >= kl.Count - 1) - return exactMatch ? null : aas4asset; - - // side info? - if (rootInfo != null) - { - rootInfo.Asset = aas4asset?.assetInformation; - rootInfo.NrOfRootKeys = 1 + keyIndex; - } - - // follow up - aasToFollow = aas4asset; - } - - // try - if (aasToFollow != null) - { - // search different entities - if (kl[keyIndex + 1].type.Trim().ToLower() == Key.Submodel.ToLower() - || kl[keyIndex + 1].type.Trim().ToLower() == Key.SubmodelRef.ToLower()) - { - // ok, search SubmodelRef - var smref = aasToFollow.FindSubmodelRef(kl[keyIndex + 1].ToId()); - if (smref == null) - return exactMatch ? null : aasToFollow; - - // validate matching submodel - var sm = this.FindSubmodel(smref); - if (sm == null) - return exactMatch ? null : aasToFollow; - - // side info - // side info? - if (rootInfo != null) - { - rootInfo.Submodel = sm; - rootInfo.NrOfRootKeys = 2 + keyIndex; - } - - // at our end? - if (keyIndex >= kl.Count - 2) - return sm; - - // go inside - return SubmodelElementWrapper.FindReferableByReference(sm.submodelElements, kl, keyIndex + 2); - } - } - - if (firstType == Key.ConceptDescription.Trim().ToLower()) - return this.FindConceptDescription(firstIdentification); - - if (firstType == Key.Submodel.Trim().ToLower()) - { - // ok, search Submodel - var sm = this.FindSubmodel(new Identifier(kl[keyIndex].value)); - if (sm == null) - return null; - - // notice in side info - if (rootInfo != null) - { - rootInfo.Submodel = sm; - rootInfo.NrOfRootKeys = 1 + keyIndex; - - // add even more info - if (rootInfo.AAS == null) - { - foreach (var aas2 in this.AdministrationShells) - { - var smref2 = aas2.FindSubmodelRef(sm.id); - if (smref2 != null) - { - rootInfo.AAS = aas2; - break; - } - } - } - } - - // at our end? - if (keyIndex >= kl.Count - 1) - return sm; - - // go inside - return SubmodelElementWrapper.FindReferableByReference(sm.submodelElements, kl, keyIndex + 1); - } - - // nothing in this Environment - return null; - } - - // - // Handling of CDs - // - - public ConceptDescription FindConceptDescription(ConceptDescriptionRef cdr) - { - if (cdr == null) - return null; - return FindConceptDescription(cdr.Keys); - } - - public ConceptDescription FindConceptDescription(SemanticId semId) - { - if (semId == null) - return null; - return FindConceptDescription(semId.Value); - } - - public ConceptDescription FindConceptDescription(ModelReference rf) - { - if (rf == null) - return null; - return FindConceptDescription(rf.Keys); - } - - public ConceptDescription FindConceptDescription(Identifier id) - { - var cdr = ConceptDescriptionRef.CreateNew(Key.ConceptDescription, id.value); - return FindConceptDescription(cdr); - } - - public ConceptDescription FindConceptDescription(List keys) - { - // trivial - if (keys == null) - return null; - // can only refs with 1 key - if (keys.Count != 1) - return null; - // and we're picky - var key = keys[0]; - if (key.type.ToLower().Trim() != "conceptdescription") - return null; - // brute force - foreach (var cd in conceptDescriptions) - if (cd.id.value.ToLower().Trim() == key.value.ToLower().Trim()) - return cd; - // uups - return null; - } - - public ConceptDescription FindConceptDescription(ListOfIdentifier loi) - { - // trivial - if (loi == null) - return null; - // can only refs with 1 key - if (loi.Count != 1) - return null; - // and we're picky - var id = loi[0]; - // brute force - foreach (var cd in conceptDescriptions) - if (cd.id.value.ToLower().Trim() == id.value.ToLower().Trim()) - return cd; - // uups - return null; - } - - public IEnumerable FindAllSubmodelElements( - Predicate match = null, AdministrationShell onlyForAAS = null) where T : SubmodelElement - { - // more or less two different schemes - if (onlyForAAS != null) - { - if (onlyForAAS.submodelRefs == null) - yield break; - foreach (var smr in onlyForAAS.submodelRefs) - { - var sm = this.FindSubmodel(smr); - if (sm?.submodelElements != null) - foreach (var x in sm.submodelElements.FindDeep(match)) - yield return x; - } - } - else - { - if (this.Submodels != null) - foreach (var sm in this.Submodels) - if (sm?.submodelElements != null) - foreach (var x in sm.submodelElements.FindDeep(match)) - yield return x; - } - } - - public ConceptDescription FindConceptDescription(Key key) - { - if (key == null) - return null; - var l = new List { key }; - return (FindConceptDescription(l)); - } - - public IEnumerable FindAllReferences() - { - if (this.AdministrationShells != null) - foreach (var aas in this.AdministrationShells) - if (aas != null) - foreach (var r in aas.FindAllReferences()) - yield return r; - - if (this.Submodels != null) - foreach (var sm in this.Submodels) - if (sm != null) - foreach (var r in sm.FindAllReferences()) - yield return r; - - if (this.ConceptDescriptions != null) - foreach (var cd in this.ConceptDescriptions) - if (cd != null) - foreach (var r in cd.FindAllReferences()) - yield return new LocatedReference(cd, r); - } - - // creators - - private void CopyConceptDescriptionsFrom( - AdministrationShellEnv srcEnv, SubmodelElement src, bool shallowCopy = false) - { - // access - if (srcEnv == null || src == null || src.semanticId == null) - return; - // check for this SubmodelElement in Source - var cdSrc = srcEnv.FindConceptDescription(src.semanticId); - if (cdSrc == null) - return; - // check for this SubmodelElement in Destnation (this!) - var cdDest = this.FindConceptDescription(src.semanticId); - if (cdDest != null) - return; - // copy new - this.ConceptDescriptions.Add(new ConceptDescription(cdSrc)); - // recurse? - if (!shallowCopy && src is SubmodelElementCollection) - foreach (var m in (src as SubmodelElementCollection).value) - CopyConceptDescriptionsFrom(srcEnv, m.submodelElement, shallowCopy: false); - - } - - public SubmodelElementWrapper CopySubmodelElementAndCD( - AdministrationShellEnv srcEnv, SubmodelElement srcElem, bool copyCD = false, bool shallowCopy = false) - { - // access - if (srcEnv == null || srcElem == null) - return null; - - // 1st result pretty easy (calling function will add this to the appropriate Submodel) - var res = new SubmodelElementWrapper(srcElem); - - // copy the CDs.. - if (copyCD) - CopyConceptDescriptionsFrom(srcEnv, srcElem, shallowCopy); - - // give back - return res; - } - - public SubmodelRef CopySubmodelRefAndCD( - AdministrationShellEnv srcEnv, SubmodelRef srcSubRef, bool copySubmodel = false, bool copyCD = false, - bool shallowCopy = false) - { - // access - if (srcEnv == null || srcSubRef == null) - return null; - - // need to have the source Submodel - var srcSub = srcEnv.FindSubmodel(srcSubRef); - if (srcSub == null) - return null; - - // 1st result pretty easy (calling function will add this to the appropriate AAS) - var dstSubRef = new SubmodelRef(srcSubRef); - - // get the destination and shall src != dst - var dstSub = this.FindSubmodel(dstSubRef); - if (srcSub == dstSub) - return null; - - // maybe we need the Submodel in our environment, as well - if (dstSub == null && copySubmodel) - { - dstSub = new Submodel(srcSub, shallowCopy); - this.Submodels.Add(dstSub); - } - else - if (dstSub != null) - { - // there is already an submodel, just add members - if (!shallowCopy && srcSub.submodelElements != null) - { - if (dstSub.submodelElements == null) - dstSub.submodelElements = new SubmodelElementWrapperCollection(); - foreach (var smw in srcSub.submodelElements) - dstSub.submodelElements.Add( - new SubmodelElementWrapper( - smw.submodelElement, shallowCopy: false)); - } - } - - // copy the CDs.. - if (copyCD && srcSub.submodelElements != null) - foreach (var smw in srcSub.submodelElements) - CopyConceptDescriptionsFrom(srcEnv, smw.submodelElement, shallowCopy); - - // give back - return dstSubRef; - } - - /// - /// Tries renaming an Identifiable, specifically: the identification of an Identifiable and - /// all references to it. - /// Currently supported: ConceptDescriptions - /// Returns a list of Referables, which were changed or null in case of error - /// - public List RenameIdentifiable(Identifier oldId, Identifier newId) - where T : IAasElement - { - // access - if (oldId == null || newId == null || oldId.IsEqual(newId)) - return null; - - var res = new List(); - - if (typeof(T) == typeof(ConceptDescription)) - { - // check, if exist or not exist - var cdOld = FindConceptDescription(oldId); - if (cdOld == null || FindConceptDescription(newId) != null) - return null; - - // rename old cd - cdOld.id = newId; - res.Add(cdOld); - - // search all SMEs referring to this CD - foreach (var sme in this.FindAllSubmodelElements(match: (s) => - { - return (s != null && s.semanticId != null && s.semanticId.Matches(oldId)); - })) - { - sme.semanticId[0].value = newId.value; - res.Add(sme); - } - - // seems fine - return res; - } - - if (typeof(T) == typeof(Submodel)) - { - // check, if exist or not exist - var smOld = FindSubmodel(oldId); - if (smOld == null || FindSubmodel(newId) != null) - return null; - - // recurse all possible Referenes in the aas env - foreach (var lr in this.FindAllReferences()) - { - var r = lr?.Reference; - if (r != null) - for (int i = 0; i < r.Count; i++) - if (r[i].Matches(Key.Submodel, oldId.value, Key.MatchMode.Relaxed)) - { - // directly replace - r[i].value = newId.value; - if (res.Contains(lr.Identifiable)) - res.Add(lr.Identifiable); - } - } - - // rename old Submodel - smOld.id = newId; - - // seems fine - return res; - } - - if (typeof(T) == typeof(AssetInformation)) - { - // check, if exist or not exist - var assetOld = FindAasWithAssetInfo(oldId); - if (assetOld == null || FindAasWithAssetInfo(newId) != null) - return null; - - // recurse all possible Referenes in the aas env - foreach (var lr in this.FindAllReferences()) - { - var r = lr?.Reference; - if (r != null) - for (int i = 0; i < r.Count; i++) - if (r[i].Matches(Key.AssetInformation, oldId.value)) - { - // directly replace - r[i].value = newId.value; - if (res.Contains(lr.Identifiable)) - res.Add(lr.Identifiable); - } - } - - // rename old Asset - assetOld.assetInformation.SetIdentification(newId); - - // seems fine - return res; - } - - // no result is false, as well - return null; - } - - // serializations - - public void SerializeXmlToStream(StreamWriter s) - { - var serializer = new XmlSerializer(typeof(AdminShell.AdministrationShellEnv)); - var nss = new XmlSerializerNamespaces(); - nss.Add("xsi", System.Xml.Schema.XmlSchema.InstanceNamespace); - nss.Add("aas", "http://www.admin-shell.io/aas/3/0"); - nss.Add("IEC61360", "http://www.admin-shell.io/IEC61360/3/0"); - serializer.Serialize(s, this, nss); - } - - public JsonWriter SerialiazeJsonToStream(StreamWriter sw, bool leaveJsonWriterOpen = false) - { - sw.AutoFlush = true; - - JsonSerializer serializer = new JsonSerializer() - { - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Serialize, - Formatting = Newtonsoft.Json.Formatting.Indented - }; - - JsonWriter writer = new JsonTextWriter(sw); - serializer.Serialize(writer, this); - if (leaveJsonWriterOpen) - return writer; - writer.Close(); - return null; - } - - public AdministrationShellEnv DeserializeFromXmlStream(TextReader reader) - { - XmlSerializer serializer = new XmlSerializer( - typeof(AdminShell.AdministrationShellEnv), "http://www.admin-shell.io/aas/3/0"); - var res = serializer.Deserialize(reader) as AdminShell.AdministrationShellEnv; - return res; - } - - public AdministrationShellEnv DeserializeFromJsonStream(TextReader reader) - { - JsonSerializer serializer = new JsonSerializer(); - serializer.Converters.Add(new AdminShellConverters.JsonAasxConverter("modelType", "name")); - var res = (AdministrationShellEnv)serializer.Deserialize(reader, typeof(AdministrationShellEnv)); - return res; - } - - // special functions - - private static void CreateFromExistingEnvRecurseForCDs( - AdministrationShellEnv src, List wrappers, - ref List filterForCD) - { - if (wrappers == null || filterForCD == null) - return; - - foreach (var w in wrappers) - { - // access - if (w == null) - continue; - - // include in filter .. - if (w.submodelElement.semanticId != null) - { - var cd = src.FindConceptDescription(w.submodelElement.semanticId); - if (cd != null) - filterForCD.Add(cd); - } - - // recurse? - if (w.submodelElement is SubmodelElementCollection smec) - CreateFromExistingEnvRecurseForCDs(src, smec.value, ref filterForCD); - - if (w.submodelElement is Operation op) - for (int i = 0; i < 2; i++) - { - var w2s = Operation.GetWrappers(op[i]); - CreateFromExistingEnvRecurseForCDs(src, w2s, ref filterForCD); - } - - if (w.submodelElement is Entity smee) - CreateFromExistingEnvRecurseForCDs(src, smee.statements, ref filterForCD); - - if (w.submodelElement is AnnotatedRelationshipElement smea) - CreateFromExistingEnvRecurseForCDs(src, smea.annotations, ref filterForCD); - } - } - - public static AdministrationShellEnv CreateFromExistingEnv(AdministrationShellEnv src, - List filterForAas = null, - List filterForAsset = null, - ListOfSubmodels filterForSubmodel = null, - List filterForCD = null) - { - // prepare defaults - if (filterForAas == null) - filterForAas = new List(); - if (filterForSubmodel == null) - filterForSubmodel = new ListOfSubmodels(); - if (filterForCD == null) - filterForCD = new List(); - - // make new - var res = new AdministrationShellEnv(); - - // take over AAS - foreach (var aas in src.administrationShells) - if (filterForAas.Contains(aas)) - { - // take over - res.administrationShells.Add(new AdministrationShell(aas)); - - if (aas.submodelRefs != null) - foreach (var smr in aas.submodelRefs) - { - var sm = src.FindSubmodel(smr); - if (sm != null) - filterForSubmodel.Add(sm); - } - } - - // take over Submodels - foreach (var sm in src.Submodels) - if (filterForSubmodel.Contains(sm)) - { - // take over - res.submodels.Add(new Submodel(sm)); - - // recursion in order to find used CDs - CreateFromExistingEnvRecurseForCDs(src, sm.submodelElements, ref filterForCD); - } - - // ConceptDescriptions - foreach (var cd in src.ConceptDescriptions) - if (filterForCD.Contains(cd)) - { - // take over - res.conceptDescriptions.Add(new ConceptDescription(cd)); - } - - // ok - return res; - } - - // Sorting - - public Referable.ComparerIndexed CreateIndexedComparerCdsForSmUsage() - { - var cmp = new Referable.ComparerIndexed(); - int nr = 0; - foreach (var sm in FindAllSubmodelGroupedByAAS()) - foreach (var sme in sm.FindDeep()) - { - if (sme.semanticId == null) - continue; - var cd = this.FindConceptDescription(sme.semanticId); - if (cd == null) - continue; - if (cmp.Index.ContainsKey(cd)) - continue; - cmp.Index[cd] = nr++; - } - return cmp; - } - - // Validation - - public AasValidationRecordList ValidateAll() - { - // collect results - var results = new AasValidationRecordList(); - - // all entities - foreach (var rf in this.FindAllReferable()) - rf.Validate(results); - - // give back - return results; - } - - public int AutoFix(IEnumerable records) - { - // access - if (records == null) - return -1; - - // collect Referables (expensive safety measure) - var allowedReferables = this.FindAllReferable().ToList(); - - // go thru records - int res = 0; - foreach (var rec in records) - { - // access - if (rec == null || rec.Fix == null || rec.Source == null) - continue; - - // minimal safety measure - if (!allowedReferables.Contains(rec.Source)) - continue; - - // apply fix - res++; - try - { - rec.Fix.Invoke(); - } - catch - { - res--; - } - } - - // return number of applied fixes - return res; - } - - public void RecurseOnReferables( - object state, Func lambda, bool includeThis = false) - { - // includeThis does not make sense, as no Referable - // just use the others - foreach (var idf in this.FindAllReferable(onlyIdentifiables: true)) - idf?.RecurseOnReferables(state, lambda, includeThis); - } - - } - - } -} diff --git a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_SMEs.cs b/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_SMEs.cs deleted file mode 100644 index 99533644a..000000000 --- a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/AdminShell_SMEs.cs +++ /dev/null @@ -1,3773 +0,0 @@ -/* -Copyright (c) 2018-2021 Festo AG & Co. KG -Author: Michael Hoffmeister - -This source code is licensed under the Apache License 2.0 (see LICENSE.txt). - -This source code may use other Open Source software components (see LICENSE.txt). -*/ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.ComponentModel; -using System.Dynamic; -using System.Globalization; -using System.IO; -using System.IO.Packaging; -using System.Linq; -using System.Reflection; -using System.Runtime; -using System.Text; -using System.Text.RegularExpressions; -using System.Xml; -using System.Xml.Serialization; -using AdminShellNS; -using Microsoft.IdentityModel.Tokens; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; - - -//namespace AdminShellNS -namespace AdminShell_V30 -{ - /// - /// Partial main class of AdminShell: SubmodelElements - /// - public partial class AdminShellV30 - { - public class ListOfSubmodelElement : List - { - // conversion to other list - - public KeyList ToKeyList() - { - var res = new KeyList(); - foreach (var sme in this) - res.Add(sme.ToKey()); - return res; - } - - public ModelReference GetReference() - { - return ModelReference.CreateNew(ToKeyList()); - } - } - - [JsonConverter(typeof(AdminShellConverters.JsonAasxConverter))] - public class SubmodelElement : Referable, System.IDisposable, IGetModelReference, IGetSemanticId, IGetQualifiers - { - // constants - public static Type[] PROP_MLP = new Type[] { - typeof(AdminShell.MultiLanguageProperty), typeof(AdminShell.Property) }; - - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } - - // members - - // do this in order to be IDisposable, that is: suitable for (using) - void System.IDisposable.Dispose() { } - public void GetData() { } - - // from HasKind - [XmlElement(ElementName = "kind")] - [JsonIgnore] - public ModelingKind kind = new ModelingKind(); - [XmlIgnore] - [JsonProperty(PropertyName = "kind")] - public string JsonKind - { - get - { - if (kind == null) - return null; - return kind.kind; - } - set - { - if (kind == null) - kind = new ModelingKind(); - kind.kind = value; - } - } - - // from hasSemanticId: - [XmlElement(ElementName = "semanticId")] - public SemanticId semanticId = new SemanticId(); - public SemanticId GetSemanticId() { return semanticId; } - - // from Qualifiable: - [XmlArray("qualifier")] - [XmlArrayItem("qualifier")] - [JsonProperty(PropertyName = "constraints")] - public QualifierCollection qualifiers = null; - public QualifierCollection GetQualifiers() => qualifiers; - - // from hasDataSpecification: - [XmlElement(ElementName = "embeddedDataSpecification")] - public HasDataSpecification hasDataSpecification = null; - - // getter / setter - - // constructors / creators - - public SubmodelElement() - : base() { } - - public SubmodelElement(SubmodelElement src) - : base(src) - { - if (src == null) - return; - if (src.hasDataSpecification != null) - hasDataSpecification = new HasDataSpecification(src.hasDataSpecification); - if (src.semanticId != null) - semanticId = new SemanticId(src.semanticId); - if (src.kind != null) - kind = new ModelingKind(src.kind); - if (src.qualifiers != null) - { - if (qualifiers == null) - qualifiers = new QualifierCollection(); - foreach (var q in src.qualifiers) - qualifiers.Add(new Qualifier(q)); - } - } - -#if !DoNotUseAasxCompatibilityModels - public SubmodelElement(AasxCompatibilityModels.AdminShellV10.SubmodelElement src) - : base(src) - { - if (src.hasDataSpecification != null) - hasDataSpecification = new HasDataSpecification(src.hasDataSpecification); - if (src.semanticId != null) - semanticId = new SemanticId(src.semanticId); - if (src.kind != null) - kind = new ModelingKind(src.kind); - if (src.qualifiers != null) - { - if (qualifiers == null) - qualifiers = new QualifierCollection(src.qualifiers); - foreach (var q in src.qualifiers) - qualifiers.Add(new Qualifier(q)); - } - } - - public SubmodelElement(AasxCompatibilityModels.AdminShellV20.SubmodelElement src) - : base(src) - { - if (src == null) - return; - if (src.hasDataSpecification != null) - hasDataSpecification = new HasDataSpecification(src.hasDataSpecification); - if (src.semanticId != null) - semanticId = new SemanticId(src.semanticId); - if (src.kind != null) - kind = new ModelingKind(src.kind); - if (src.qualifiers != null) - { - if (qualifiers == null) - qualifiers = new QualifierCollection(); - foreach (var q in src.qualifiers) - qualifiers.Add(new Qualifier(q)); - } - } -#endif - - public static T CreateNew(string idShort = null, string category = null, Reference semanticId = null) - where T : SubmodelElement, new() - { - var res = new T(); - if (idShort != null) - res.idShort = idShort; - if (category != null) - res.category = category; - if (semanticId != null) - res.semanticId = new SemanticId(semanticId); - return res; - } - - public void CreateNewLogic(string idShort = null, string category = null, Identifier semanticIdKey = null) - { - if (idShort != null) - this.idShort = idShort; - if (category != null) - this.category = category; - if (semanticIdKey != null) - { - if (this.semanticId == null) - this.semanticId = new SemanticId(); - this.semanticId.Value.Add(semanticIdKey); - } - } - - public void AddQualifier( - string qualifierType = null, string qualifierValue = null, KeyList semanticKeys = null, - GlobalReference qualifierValueId = null) - { - QualifierCollection.AddQualifier( - ref this.qualifiers, qualifierType, qualifierValue, semanticKeys, qualifierValueId); - } - - public Qualifier HasQualifierOfType(string qualifierType) - { - return QualifierCollection.HasQualifierOfType(this.qualifiers, qualifierType); - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("SubmodelElement", "SME"); - } - - public override ModelReference GetModelReference(bool includeParents = true) - { - var r = new ModelReference(); - // semantic id - r.referredSemanticId = new GlobalReference(semanticId); - // this is the tail of our referencing chain .. - r.Keys.Add(Key.CreateNew(GetElementName(), this.idShort)); - // try to climb up .. - var current = this.parent; - while (includeParents && current != null) - { - if (current is Identifiable cid) - { - // add big information set - r.Keys.Insert(0, Key.CreateNew( - current.GetElementName(), - cid.id.value)); - } - else - if (current is Referable crf) - { - // reference via idShort - r.Keys.Insert(0, Key.CreateNew( - current.GetElementName(), - crf.idShort)); - } - - if (current is Referable crf2) - current = crf2.parent; - else - current = null; - } - return r; - } - - public IEnumerable FindAllParents( - Predicate p, - bool includeThis = false, bool includeSubmodel = false, - bool passOverMiss = false) - { - // call for this? - if (includeThis) - { - if (p == null || p.Invoke(this)) - yield return this; - else - if (!passOverMiss) - yield break; - } - - // daisy chain all parents .. - if (this.parent != null) - { - if (this.parent is SubmodelElement psme) - { - foreach (var q in psme.FindAllParents(p, includeThis: true, - passOverMiss: passOverMiss)) - yield return q; - } - else if (includeSubmodel && this.parent is Submodel psm) - { - if (p == null || p.Invoke(psm)) - yield return this; - } - } - } - - public IEnumerable FindAllParentsWithSemanticId( - SemanticId semId, - bool includeThis = false, bool includeSubmodel = false, bool passOverMiss = false) - { - return (FindAllParents( - (rf) => true == (rf as IGetSemanticId)?.GetSemanticId()?.Matches(semId), - includeThis: includeThis, includeSubmodel: includeSubmodel, passOverMiss: passOverMiss)); - } - - public Tuple ToCaptionInfo() - { - var caption = AdminShellUtil.EvalToNonNullString("\"{0}\" ", idShort, ""); - var info = ""; - // TODO (MIHO, 2021-07-08): obvious error .. info should receive semanticId .. but would change - // display presentation .. therefore to be checked again - if (semanticId != null) - AdminShellUtil.EvalToNonEmptyString("\u21e8 {0}", semanticId.ToString(), ""); - return Tuple.Create(caption, info); - } - - public override string ToString() - { - var ci = ToCaptionInfo(); - return string.Format("{0}{1}", ci.Item1, (ci.Item2 != "") ? " / " + ci.Item2 : ""); - } - - public virtual string ValueAsText(string defaultLang = null) - { - return ""; - } - - public virtual double? ValueAsDouble() - { - return null; - } - - public virtual void ValueFromText(string text, string defaultLang = null) - { - } - - // validation - - public override void Validate(AasValidationRecordList results) - { - // access - if (results == null) - return; - - // check - base.Validate(results); - ModelingKind.Validate(results, kind, this); - ListOfIdentifier.Validate(results, semanticId?.Value, this); - } - - public virtual object ToValueOnlySerialization() - { - throw new NotImplementedException(); - } - - } - - [XmlType(TypeName = "submodelElement")] - public class SubmodelElementWrapper - { - - // members - - [XmlElement(ElementName = "property", Type = typeof(Property))] - [XmlElement(ElementName = "multiLanguageProperty", Type = typeof(MultiLanguageProperty))] - [XmlElement(ElementName = "range", Type = typeof(Range))] - [XmlElement(ElementName = "file", Type = typeof(File))] - [XmlElement(ElementName = "blob", Type = typeof(Blob))] - [XmlElement(ElementName = "referenceElement", Type = typeof(ReferenceElement))] - [XmlElement(ElementName = "relationshipElement", Type = typeof(RelationshipElement))] - [XmlElement(ElementName = "annotatedRelationshipElement", Type = typeof(AnnotatedRelationshipElement))] - [XmlElement(ElementName = "capability", Type = typeof(Capability))] - [XmlElement(ElementName = "submodelElementCollection", Type = typeof(SubmodelElementCollection))] - [XmlElement(ElementName = "operation", Type = typeof(Operation))] - [XmlElement(ElementName = "basicEvent", Type = typeof(BasicEvent))] - [XmlElement(ElementName = "entity", Type = typeof(Entity))] - [XmlElement(ElementName = "submodelElementList", Type = typeof(SubmodelElementList))] - [XmlElement(ElementName = "submodelElementStruct", Type = typeof(SubmodelElementStruct))] - [XmlElement(ElementName = "globalReferenceElement", Type = typeof(GlobalReferenceElement))] - [XmlElement(ElementName = "modelReferenceElement", Type = typeof(ModelReferenceElement))] - public SubmodelElement submodelElement; - - // element names - public enum AdequateElementEnum - { - Unknown = 0, SubmodelElementCollection, Property, MultiLanguageProperty, Range, File, Blob, - ReferenceElement, RelationshipElement, AnnotatedRelationshipElement, Capability, Operation, - BasicEvent, Entity, SubmodelElementList, SubmodelElementStruct, - ModelReferenceElement, GlobalReferenceElement - } - - public static AdequateElementEnum[] AdequateElementsDataElement = - { - AdequateElementEnum.SubmodelElementCollection, AdequateElementEnum.RelationshipElement, - AdequateElementEnum.AnnotatedRelationshipElement, AdequateElementEnum.Capability, - AdequateElementEnum.Operation, AdequateElementEnum.BasicEvent, AdequateElementEnum.Entity - }; - - // shall be consistent to (int) AdequateElementEnum ! - public static string[] AdequateElementNames = { - "Unknown", "SubmodelElementCollection", "Property", - "MultiLanguageProperty", "Range", "File", "Blob", "ReferenceElement", "RelationshipElement", - "AnnotatedRelationshipElement", "Capability", "Operation", "BasicEvent", "Entity", - "SubmodelElementList", "SubmodelElementStruct", - "ModelReferenceElement", "GlobalReferenceElement" - }; - - // shall be consistent to (int) AdequateElementEnum ! - public static string[] AdequateElementShortName = { - null, "SMC", null, - "MLP", null, null, null, "Ref", "Rel", - "ARel", null, null, "Event", "Entity", "SML", "SMS", - "RefM", "RefG" - }; - - // shall be consistent to (int) AdequateElementEnum ! - public static bool[] AdequateElementDeprecated = { - false, true, false, - false, false, false, false, true, false, - false, false, false, false, false, false, false, - false, false - }; - - // constructors - - public SubmodelElementWrapper() { } - - // cloning - - public SubmodelElementWrapper(SubmodelElement src, bool shallowCopy = false) - { - /* TODO (MIHO, 2021-08-12): consider using: - Activator.CreateInstance(pl.GetType(), new object[] { pl }) */ - - if (src is Property) - this.submodelElement = new Property(src as Property); - if (src is MultiLanguageProperty) - this.submodelElement = new MultiLanguageProperty(src as MultiLanguageProperty); - if (src is Range) - this.submodelElement = new Range(src as Range); - if (src is File) - this.submodelElement = new File(src as File); - if (src is Blob) - this.submodelElement = new Blob(src as Blob); - - if (src is Capability) - this.submodelElement = new Capability(src as Capability); - if (src is Operation) - this.submodelElement = new Operation(src as Operation); - if (src is BasicEvent) - this.submodelElement = new BasicEvent(src as BasicEvent); - if (src is Entity) - this.submodelElement = new Entity(src as Entity); - - // care abuot elements, which could be derived from (not so) abstract base types - if (src is SubmodelElementList) - this.submodelElement = new SubmodelElementList(src as SubmodelElementList); - else - if (src is SubmodelElementStruct) - this.submodelElement = new SubmodelElementStruct(src as SubmodelElementStruct); - else - if (src is SubmodelElementCollection) - this.submodelElement = new SubmodelElementCollection( - src as SubmodelElementCollection, shallowCopy: shallowCopy); - - // again - if (src is AnnotatedRelationshipElement) - this.submodelElement = new AnnotatedRelationshipElement(src as AnnotatedRelationshipElement); - else - if (src is RelationshipElement) - this.submodelElement = new RelationshipElement(src as RelationshipElement); - - // again - if (src is ModelReferenceElement) - this.submodelElement = new ModelReferenceElement(src as ModelReferenceElement); - else - if (src is GlobalReferenceElement) - this.submodelElement = new GlobalReferenceElement(src as GlobalReferenceElement); - else - if (src is ReferenceElement) - this.submodelElement = new ReferenceElement(src as ReferenceElement); - - } - -#if !DoNotUseAasxCompatibilityModels - public SubmodelElementWrapper( - AasxCompatibilityModels.AdminShellV10.SubmodelElement src, bool shallowCopy = false) - { - if (src is AasxCompatibilityModels.AdminShellV10.SubmodelElementCollection) - this.submodelElement = new SubmodelElementCollection( - src as AasxCompatibilityModels.AdminShellV10.SubmodelElementCollection, - shallowCopy: shallowCopy); - if (src is AasxCompatibilityModels.AdminShellV10.Property) - this.submodelElement = new Property(src as AasxCompatibilityModels.AdminShellV10.Property); - if (src is AasxCompatibilityModels.AdminShellV10.File) - this.submodelElement = new File(src as AasxCompatibilityModels.AdminShellV10.File); - if (src is AasxCompatibilityModels.AdminShellV10.Blob) - this.submodelElement = new Blob(src as AasxCompatibilityModels.AdminShellV10.Blob); - if (src is AasxCompatibilityModels.AdminShellV10.ReferenceElement) - this.submodelElement = new ReferenceElement( - src as AasxCompatibilityModels.AdminShellV10.ReferenceElement); - if (src is AasxCompatibilityModels.AdminShellV10.RelationshipElement) - this.submodelElement = new RelationshipElement( - src as AasxCompatibilityModels.AdminShellV10.RelationshipElement); - if (src is AasxCompatibilityModels.AdminShellV10.Operation) - this.submodelElement = new Operation(src as AasxCompatibilityModels.AdminShellV10.Operation); - } - - public SubmodelElementWrapper( - AasxCompatibilityModels.AdminShellV20.SubmodelElement src, bool shallowCopy = false) - { - /* TODO (MIHO, 2021-08-12): consider using: - Activator.CreateInstance(pl.GetType(), new object[] { pl }) */ - - if (src is AasxCompatibilityModels.AdminShellV20.SubmodelElementCollection) - this.submodelElement = new SubmodelElementCollection( - src as AasxCompatibilityModels.AdminShellV20.SubmodelElementCollection, - shallowCopy: shallowCopy); - if (src is AasxCompatibilityModels.AdminShellV20.Property) - this.submodelElement = new Property(src as AasxCompatibilityModels.AdminShellV20.Property); - if (src is AasxCompatibilityModels.AdminShellV20.MultiLanguageProperty) - this.submodelElement = new MultiLanguageProperty( - src as AasxCompatibilityModels.AdminShellV20.MultiLanguageProperty); - if (src is AasxCompatibilityModels.AdminShellV20.Range) - this.submodelElement = new Range(src as AasxCompatibilityModels.AdminShellV20.Range); - if (src is AasxCompatibilityModels.AdminShellV20.File) - this.submodelElement = new File(src as AasxCompatibilityModels.AdminShellV20.File); - if (src is AasxCompatibilityModels.AdminShellV20.Blob) - this.submodelElement = new Blob(src as AasxCompatibilityModels.AdminShellV20.Blob); - if (src is AasxCompatibilityModels.AdminShellV20.RelationshipElement) - this.submodelElement = new RelationshipElement( - src as AasxCompatibilityModels.AdminShellV20.RelationshipElement); - if (src is AasxCompatibilityModels.AdminShellV20.AnnotatedRelationshipElement) - this.submodelElement = new AnnotatedRelationshipElement( - src as AasxCompatibilityModels.AdminShellV20.AnnotatedRelationshipElement); - if (src is AasxCompatibilityModels.AdminShellV20.Capability) - this.submodelElement = new Capability(src as AasxCompatibilityModels.AdminShellV20.Capability); - if (src is AasxCompatibilityModels.AdminShellV20.Operation) - this.submodelElement = new Operation(src as AasxCompatibilityModels.AdminShellV20.Operation); - if (src is AasxCompatibilityModels.AdminShellV20.BasicEvent) - this.submodelElement = new BasicEvent(src as AasxCompatibilityModels.AdminShellV20.BasicEvent); - if (src is AasxCompatibilityModels.AdminShellV20.Entity) - this.submodelElement = new Entity(src as AasxCompatibilityModels.AdminShellV20.Entity); - - // a little more special - if (src is AasxCompatibilityModels.AdminShellV20.ReferenceElement) - this.submodelElement = new ModelReferenceElement( - src as AasxCompatibilityModels.AdminShellV20.ReferenceElement); - } -#endif - - public static string GetAdequateName(AdequateElementEnum ae) - { - return AdequateElementNames[(int)ae]; - } - - /// - /// Deprecated. See below. - /// - public static AdequateElementEnum GetAdequateEnum(string adequateName) - { - if (adequateName == null) - return AdequateElementEnum.Unknown; - - foreach (var en in (AdequateElementEnum[])Enum.GetValues(typeof(AdequateElementEnum))) - if (Enum.GetName(typeof(AdequateElementEnum), en)?.Trim().ToLower() == - adequateName.Trim().ToLower()) - return en; - - return AdequateElementEnum.Unknown; - } - - /// - /// This version uses the element name array and allows using ShortName - /// - public static AdequateElementEnum GetAdequateEnum2(string adequateName, bool useShortName = false) - { - if (adequateName == null) - return AdequateElementEnum.Unknown; - - foreach (var en in (AdequateElementEnum[])Enum.GetValues(typeof(AdequateElementEnum))) - if (((int)en < AdequateElementNames.Length - && AdequateElementNames[(int)en].Trim().ToLower() == adequateName.Trim().ToLower()) - || (useShortName - && (int)en < AdequateElementShortName.Length - && AdequateElementShortName[(int)en] != null - && AdequateElementShortName[(int)en].Trim().ToLower() == adequateName.Trim().ToLower())) - return en; - - return AdequateElementEnum.Unknown; - } - - /// - /// Returns, if the element is deprecated in the most current version of the meta model. - /// - public static bool GetElementIsDeprecated(AdequateElementEnum ae) - { - return AdequateElementDeprecated[(int)ae]; - } - - /// - /// Returns, if the element is deprecated in the most current version of the meta model. - /// - public static bool GetElementIsDeprecated(SubmodelElement sme) - { - if (sme == null) - return false; - var sd = sme.GetSelfDescription(); - if (sd == null) - return false; - return AdequateElementDeprecated[(int)sd.ElementEnum]; - } - - /// - /// Returns a rather general statement, if the SME is deprecated. - /// - /// - public static string EvalDeprecationMessage(SubmodelElement sme) - { - string res = null; - if (AdminShell.SubmodelElementWrapper.GetElementIsDeprecated(sme)) - { - res = "This SubmodelElement is considered deprecated by the AdminShell meta model " - + AdminShell.MetaModelVersionCoarse + AdminShell.MetaModelVersionFine + ". " - + "Please refactor to another adequate SubmodelElement. "; - - if (sme is SubmodelElementCollection) - res += "Please consider to used SubmodelElementList or SubmodelElemenStructure. "; - if (sme is ReferenceElement) - res += "For references to elements of an AAS, either local or external, consider " + - "ModelReferenceElement. For references to external information or services, " + - "consider GlobalReferenceElement. "; - } - return res; - } - - public static IEnumerable GetAdequateEnums( - AdequateElementEnum[] excludeValues = null, AdequateElementEnum[] includeValues = null) - { - if (includeValues != null) - { - foreach (var en in includeValues) - yield return en; - } - else - { - foreach (var en in (AdequateElementEnum[])Enum.GetValues(typeof(AdequateElementEnum))) - { - if (en == AdequateElementEnum.Unknown) - continue; - if (excludeValues != null && excludeValues.Contains(en)) - continue; - yield return en; - } - } - } - - /// - /// Introduced for JSON serialization, can create SubModelElements based on a string name - /// - public static SubmodelElement CreateAdequateType(AdequateElementEnum ae, SubmodelElement src = null) - { - if (ae == AdequateElementEnum.Property) - return new Property(src); - if (ae == AdequateElementEnum.MultiLanguageProperty) - return new MultiLanguageProperty(src); - if (ae == AdequateElementEnum.Range) - return new Range(src); - if (ae == AdequateElementEnum.File) - return new File(src); - if (ae == AdequateElementEnum.Blob) - return new Blob(src); - if (ae == AdequateElementEnum.ReferenceElement) - return new ReferenceElement(src); - if (ae == AdequateElementEnum.RelationshipElement) - return new RelationshipElement(src); - if (ae == AdequateElementEnum.AnnotatedRelationshipElement) - return new AnnotatedRelationshipElement(src); - if (ae == AdequateElementEnum.Capability) - return new Capability(src); - if (ae == AdequateElementEnum.SubmodelElementCollection) - return new SubmodelElementCollection(src); - if (ae == AdequateElementEnum.Operation) - return new Operation(src); - if (ae == AdequateElementEnum.BasicEvent) - return new BasicEvent(src); - if (ae == AdequateElementEnum.Entity) - return new Entity(src); - if (ae == AdequateElementEnum.SubmodelElementList) - return new SubmodelElementList(src); - if (ae == AdequateElementEnum.SubmodelElementStruct) - return new SubmodelElementStruct(src); - if (ae == AdequateElementEnum.ModelReferenceElement) - return new ModelReferenceElement(src); - if (ae == AdequateElementEnum.GlobalReferenceElement) - return new GlobalReferenceElement(src); - return null; - } - - /// - /// Introduced for JSON serialization, can create SubModelElements based on a string name - /// - /// string name (standard PascalCased) - public static SubmodelElement CreateAdequateType(string elementName) - { - return CreateAdequateType(GetAdequateEnum(elementName)); - } - - /// - /// Can create SubmodelElements based on a given type information - /// - /// Type of the SME to be created - /// SubmodelElement or null - public static SubmodelElement CreateAdequateType(Type t) - { - if (t == null || !t.IsSubclassOf(typeof(AdminShell.SubmodelElement))) - return null; - var sme = Activator.CreateInstance(t) as SubmodelElement; - return sme; - } - - public string GetElementAbbreviation() - { - if (submodelElement == null) - return ("Null"); - var dsc = submodelElement.GetSelfDescription(); - if (dsc?.ElementAbbreviation == null) - return ("Null"); - return dsc.ElementAbbreviation; - } - - public static string GetElementNameByAdequateType(SubmodelElement sme) - { - // access - var sd = sme.GetSelfDescription(); - if (sd == null || sd.ElementEnum == AdequateElementEnum.Unknown) - return null; - var en = sd.ElementEnum; - - // get the names - string res = null; - if ((int)en < AdequateElementNames.Length) - res = AdequateElementNames[(int)en].Trim(); - if ((int)en < AdequateElementShortName.Length && AdequateElementShortName[(int)en] != null) - res = AdequateElementShortName[(int)en].Trim(); - return res; - } - - public static ListOfSubmodelElement ListOfWrappersToListOfElems(List wrappers) - { - var res = new ListOfSubmodelElement(); - if (wrappers == null) - return res; - foreach (var w in wrappers) - if (w.submodelElement != null) - res.Add(w.submodelElement); - return res; - } - - public static SubmodelElementWrapper CreateFor(SubmodelElement sme) - { - var res = new SubmodelElementWrapper() { submodelElement = sme }; - return res; - } - - public static Referable FindReferableByReference( - List wrappers, ModelReference rf, int keyIndex) - { - return FindReferableByReference(wrappers, rf?.Keys, keyIndex); - } - - public static Referable FindReferableByReference( - List wrappers, KeyList rf, int keyIndex) - { - // first index needs to exist .. - if (wrappers == null || rf == null || keyIndex >= rf.Count) - return null; - - // as SubmodelElements are not Identifiables, the actual key shall be IdShort - if (!rf[keyIndex].IsInSubmodelElements()) - return null; - - // over all wrappers - foreach (var smw in wrappers) - if (smw.submodelElement != null && - smw.submodelElement.idShort.Trim().ToLower() == rf[keyIndex].value.Trim().ToLower()) - { - // match on this level. Did we find a leaf element? - if ((keyIndex + 1) >= rf.Count) - return smw.submodelElement; - - // dive into SMC? - if (smw.submodelElement is SubmodelElementCollection smc) - { - var found = FindReferableByReference(smc.value, rf, keyIndex + 1); - if (found != null) - return found; - } - - // dive into Entity statements? - if (smw.submodelElement is Entity ent) - { - var found = FindReferableByReference(ent.statements, rf, keyIndex + 1); - if (found != null) - return found; - } - - // else: - return null; - } - - // no? - return null; - } - - // typecasting wrapper into specific type - public T GetAs() where T : SubmodelElement - { - var x = (this.submodelElement) as T; - return x; - } - - } - - public class SubmodelElementWrapperCollection : BaseSubmodelElementWrapperCollection - { - public SubmodelElementWrapperCollection() : base() { } - - public SubmodelElementWrapperCollection(SubmodelElementWrapper smw) : base(smw) { } - - public SubmodelElementWrapperCollection(SubmodelElement sme) : base(sme) { } - - public SubmodelElementWrapperCollection(SubmodelElementWrapperCollection other) : base(other) { } - - } - - public class DataElementWrapperCollection : BaseSubmodelElementWrapperCollection - { - public DataElementWrapperCollection() : base() { } - - public DataElementWrapperCollection(SubmodelElementWrapperCollection other) - : base(other) - { - } - - public DataElementWrapperCollection(DataElementWrapperCollection other) - : base() - { - foreach (var wo in other) - this.Add(wo); - } - -#if !DoNotUseAasxCompatibilityModels - public DataElementWrapperCollection(AasxCompatibilityModels.AdminShellV20.DataElementWrapperCollection src) - : base() - { - foreach (var wo in src) - this.Add(new SubmodelElementWrapper(wo?.submodelElement)); - } -#endif - - } - - /// - /// Provides some more functionalities for searching specific elements, e.g. in a SMEC - /// - // OZ - // Resharper disable UnusedTypeParameter - public class BaseSubmodelElementWrapperCollection : List - where ELEMT : SubmodelElement - { - // Resharper enable UnusedTypeParameter - - // member: Parent - // will be held correctly by the containing class - public Referable Parent = null; - - // constructors - - public BaseSubmodelElementWrapperCollection() : base() { } - - public BaseSubmodelElementWrapperCollection(SubmodelElementWrapperCollection other) - : base() - { - if (other == null) - return; - - foreach (var smw in other) - this.Add(new SubmodelElementWrapper(smw.submodelElement)); - } - - public BaseSubmodelElementWrapperCollection(SubmodelElementWrapper smw) - : base() - { - if (smw != null) - this.Add(smw); - } - - public BaseSubmodelElementWrapperCollection(SubmodelElement sme) - : base() - { - if (sme != null) - this.Add(new SubmodelElementWrapper(sme)); - } - - // better find functions - - public IEnumerable FindDeep(Predicate match = null) where T : SubmodelElement - { - foreach (var smw in this) - { - var current = smw.submodelElement; - if (current == null) - continue; - - // call lambda for this element - if (current is T) - if (match == null || match.Invoke(current as T)) - yield return current as T; - - // dive into? - // TODO (MIHO, 2020-07-31): would be nice to use IEnumerateChildren for this .. - if (current is SubmodelElementCollection smc && smc.value != null) - foreach (var x in smc.value.FindDeep(match)) - yield return x; - - if (current is AnnotatedRelationshipElement are && are.annotations != null) - foreach (var x in are.annotations.FindDeep(match)) - yield return x; - - if (current is Entity ent && ent.statements != null) - foreach (var x in ent.statements.FindDeep(match)) - yield return x; - - if (current is Operation op) - for (int i = 0; i < 2; i++) - if (Operation.GetWrappers(op[i]) != null) - foreach (var x in Operation.GetWrappers(op[i]).FindDeep(match)) - yield return x; - } - } - - public IEnumerable FindAllIdShort(string idShort) - { - foreach (var smw in this) - if (smw.submodelElement != null) - if (smw.submodelElement.idShort.Trim().ToLower() == idShort.Trim().ToLower()) - yield return smw; - } - - public IEnumerable FindAllIdShortAs(string idShort) where T : SubmodelElement - { - foreach (var smw in this) - if (smw.submodelElement != null && smw.submodelElement is T) - if (smw.submodelElement.idShort.Trim().ToLower() == idShort.Trim().ToLower()) - yield return smw.submodelElement as T; - - yield return null; - } - - public SubmodelElementWrapper FindFirstIdShort(string idShort) - { - return FindAllIdShort(idShort)?.FirstOrDefault(); - } - - public T FindFirstIdShortAs(string idShort) where T : SubmodelElement - { - return FindAllIdShortAs(idShort)?.FirstOrDefault(); - } - - public IEnumerable FindAllSemanticId( - Identifier semId, Type[] allowedTypes = null, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - foreach (var smw in this) - if (smw.submodelElement != null && smw.submodelElement.semanticId != null) - { - if (smw.submodelElement == null) - continue; - - if (allowedTypes != null) - { - var smwt = smw.submodelElement.GetType(); - if (!allowedTypes.Contains(smwt)) - continue; - } - - if (smw.submodelElement.semanticId.MatchesExactlyOneId(semId, matchMode)) - yield return smw; - } - } - - public IEnumerable FindAllSemanticIdAs( - Identifier semId, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - where T : SubmodelElement - { - foreach (var smw in this) - if (smw.submodelElement != null && smw.submodelElement is T - && smw.submodelElement.semanticId != null) - if (smw.submodelElement.semanticId.MatchesExactlyOneId(semId, matchMode)) - yield return smw.submodelElement as T; - } - - public IEnumerable FindAllSemanticIdAs(GlobalReference semId, - Key.MatchMode matchMode = Key.MatchMode.Relaxed) - where T : SubmodelElement - { - foreach (var smw in this) - if (smw.submodelElement != null && smw.submodelElement is T - && smw.submodelElement.semanticId != null) - if (smw.submodelElement.semanticId.Matches(semId, matchMode)) - yield return smw.submodelElement as T; - } - - public SubmodelElementWrapper FindFirstSemanticId( - Identifier semId, Type[] allowedTypes = null, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - return FindAllSemanticId(semId, allowedTypes, matchMode)?.FirstOrDefault(); - } - - public SubmodelElementWrapper FindFirstAnySemanticId( - Identifier[] semId, Type[] allowedTypes = null, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - { - if (semId == null) - return null; - foreach (var si in semId) - { - var found = FindAllSemanticId(si, allowedTypes, matchMode)? - .FirstOrDefault(); - if (found != null) - return found; - } - return null; - } - - public T FindFirstSemanticIdAs(Identifier semId, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - where T : SubmodelElement - { - return FindAllSemanticIdAs(semId, matchMode)?.FirstOrDefault(); - } - - public T FindFirstAnySemanticIdAs(Identifier[] semId, Key.MatchMode matchMode = Key.MatchMode.Relaxed) - where T : SubmodelElement - { - if (semId == null) - return null; - foreach (var si in semId) - { - var found = FindAllSemanticIdAs(si, matchMode)?.FirstOrDefault(); - if (found != null) - return found; - } - return null; - } - - /* TODO (MIHO, 2021-10-18): there are overlaps of this new function with - * this old function: FindFirstAnySemanticId(Key[] semId .. - * clarify/ refactor */ - public IEnumerable FindAllSemanticId( - Identifier[] allowedSemId, Key.MatchMode matchMode = Key.MatchMode.Relaxed, - bool invertAllowed = false) - where T : SubmodelElement - { - if (allowedSemId == null || allowedSemId.Length < 1) - yield break; - - foreach (var smw in this) - { - if (smw.submodelElement == null || !(smw.submodelElement is T)) - continue; - - if (smw.submodelElement.semanticId == null || smw.submodelElement.semanticId.Count < 1) - { - if (invertAllowed) - yield return smw.submodelElement as T; - continue; - } - - var found = false; - foreach (var semId in allowedSemId) - if (smw.submodelElement.semanticId.MatchesExactlyOneId(semId, matchMode)) - { - found = true; - break; - } - - if (invertAllowed) - found = !found; - - if (found) - yield return smw.submodelElement as T; - } - } - - public T FindFirstAnySemanticId( - Identifier[] allowedSemId, Key.MatchMode matchMode = Key.MatchMode.Relaxed, - bool invertAllowed = false) - where T : SubmodelElement - { - return FindAllSemanticId(allowedSemId, matchMode, invertAllowed)?.FirstOrDefault(); - } - - // recursion - - /// - /// Recurses on all Submodel elements of a Submodel or SME, which allows children. - /// The state object will be passed to the lambda function in order to provide - /// stateful approaches. Also a list of parents will be provided to - /// the lambda. This list of parents can be initialized or simply set to null - /// in order to be created automatically. - /// - /// State object to be provided to lambda. Could be null. - /// List of already existing parents to be provided to lambda. - /// Could be null. - /// The lambda function as (state, parents, SME) - /// The lambda shall return TRUE in order to deep into recursion. - /// - public void RecurseOnReferables( - object state, ListOfReferable parents, - Func lambda) - { - // trivial - if (lambda == null) - return; - if (parents == null) - parents = new ListOfReferable(); - - // over all elements - foreach (var smw in this) - { - var current = smw.submodelElement; - if (current == null) - continue; - - // call lambda for this element - // AND decide, if to recurse! - var goDeeper = lambda(state, parents, current); - - if (goDeeper) - { - // add to parents - parents.Add(current); - - // dive into? - if (current is SubmodelElementCollection smc) - smc.value?.RecurseOnReferables(state, parents, lambda); - - if (current is Entity ent) - ent.statements?.RecurseOnReferables(state, parents, lambda); - - if (current is Operation op) - for (int i = 0; i < 2; i++) - Operation.GetWrappers(op[i])?.RecurseOnReferables(state, parents, lambda); - - if (current is AnnotatedRelationshipElement arel) - arel.annotations?.RecurseOnReferables(state, parents, lambda); - - // remove from parents - parents.RemoveAt(parents.Count - 1); - } - } - } - - // idShort management - - /// - /// Checks, if given idShort is already existing in the collection of SubmodelElements. - /// Trims the string, but does not ignore upper/ lowercase. An empty idShort returns false. - /// - public bool CheckIdShortIsUnique(string idShort) - { - idShort = idShort?.Trim(); - if (idShort == null || idShort.Length < 1) - return false; - - var res = true; - foreach (var smw in this) - if (smw.submodelElement != null && smw.submodelElement.idShort != null && - smw.submodelElement.idShort == idShort) - { - res = false; - break; - } - - return res; - } - - /// - /// The string idShortTemplate shall contain Format.String partt such as {0}. - /// A int-Parameter is as long incremented, until the resulting idShort proves - /// to be unique in the collection of SubmodelElements or maxNum is reached. - /// Returns null in case of any error. - /// - public string IterateIdShortTemplateToBeUnique(string idShortTemplate, int maxNum) - { - if (idShortTemplate == null || maxNum < 1 || !idShortTemplate.Contains("{0")) - return null; - - int i = 1; - while (i < maxNum) - { - var ids = String.Format(idShortTemplate, i); - if (this.CheckIdShortIsUnique(ids)) - return ids; - i++; - } - - return null; - } - - // give more direct access to SMEs - - /// - /// Add sme by creating a SubmodelElementWrapper for it and adding to this collection. - /// - public void Add(SubmodelElement sme) - { - if (sme == null) - return; - sme.parent = this.Parent; - this.Add(SubmodelElementWrapper.CreateFor(sme)); - } - - /// - /// Add sme by creating a SubmodelElementWrapper for it and adding to this collection. - /// - public void Insert(int index, SubmodelElement sme) - { - if (sme == null || index < 0 || index >= this.Count) - return; - sme.parent = this.Parent; - this.Insert(index, SubmodelElementWrapper.CreateFor(sme)); - } - - /// - /// Finds the first (shall be only 1!) SubmodelElementWrapper with SubmodelElement sme. - /// - public SubmodelElementWrapper FindSubModelElement(SubmodelElement sme) - { - if (sme != null) - foreach (var smw in this) - if (smw?.submodelElement == sme) - return smw; - return null; - } - - /// - /// Removes the first (shall be only 1!) SubmodelElementWrapper with SubmodelElement sme. - /// - public void Remove(SubmodelElement sme) - { - if (sme == null) - return; - var found = FindSubModelElement(sme); - if (found != null) - this.Remove(found); - } - - // a little more business logic - - public T CreateSMEForCD(ConceptDescription cd, string category = null, string idShort = null, - string idxTemplate = null, int maxNum = 999, bool addSme = false) where T : SubmodelElement, new() - { - // access - if (cd == null) - return null; - - // try to potentially figure out idShort - var ids = cd.idShort; - if ((ids == null || ids.Trim() == "") && cd.GetIEC61360() != null) - ids = cd.GetIEC61360().shortName? - .GetDefaultStr(); - if (idShort != null) - ids = idShort; - if (ids == null) - return null; - - // unique? - if (idxTemplate != null) - ids = this.IterateIdShortTemplateToBeUnique(idxTemplate, maxNum); - - // make a new instance - var sme = new T() - { - idShort = ids, - semanticId = new SemanticId(cd.GetCdReference()) - }; - if (category != null) - sme.category = category; - - // if its a SMC, make sure its accessible - if (sme is SubmodelElementCollection smc) - smc.value = new SubmodelElementWrapperCollection(); - - // instantanously add it? - if (addSme) - this.Add(sme); - - // give back - return sme; - } - - public T CreateSMEForIdShort(string idShort, string category = null, - string idxTemplate = null, int maxNum = 999, bool addSme = false) where T : SubmodelElement, new() - { - // access - if (idShort == null) - return null; - - // try to potentially figure out idShort - var ids = idShort; - - // unique? - if (idxTemplate != null) - ids = this.IterateIdShortTemplateToBeUnique(idxTemplate, maxNum); - - // make a new instance - var sme = new T() { idShort = ids }; - if (category != null) - sme.category = category; - - // instantanously add it? - if (addSme) - this.Add(sme); - - // give back - return sme; - } - - // for conversion - - public T AdaptiveConvertTo( - SubmodelElement anySrc, - ConceptDescription createDefault = null, - string idShort = null, bool addSme = false) where T : SubmodelElement, new() - { - if (typeof(T) == typeof(MultiLanguageProperty) - && anySrc is Property srcProp) - { - var res = this.CreateSMEForCD(createDefault, idShort: idShort, addSme: addSme); - if (res is MultiLanguageProperty mlp) - { - mlp.value = new LangStringSet("EN?", srcProp.value); - mlp.valueId = srcProp.valueId; - return res; - } - } - - if (typeof(T) == typeof(Property) - && anySrc is MultiLanguageProperty srcMlp) - { - var res = this.CreateSMEForCD(createDefault, idShort: idShort, addSme: addSme); - if (res is Property prp) - { - prp.value = "" + srcMlp.value?.GetDefaultStr(); - prp.valueId = srcMlp.valueId; - return res; - } - } - - return null; - } - - public T CopyOneSMEbyCopy(Identifier destSemanticId, - SubmodelElementWrapperCollection sourceSmc, Identifier[] sourceSemanticId, - ConceptDescription createDefault = null, Action setDefault = null, - Key.MatchMode matchMode = Key.MatchMode.Relaxed, - string idShort = null, bool addSme = false) where T : SubmodelElement, new() - { - // get source - var src = sourceSmc?.FindFirstAnySemanticIdAs(sourceSemanticId, matchMode); - - // may be make an adaptive conversion - if (src == null) - { - var anySrc = sourceSmc?.FindFirstAnySemanticId(sourceSemanticId, matchMode: matchMode); - src = AdaptiveConvertTo(anySrc?.submodelElement, createDefault, - idShort: idShort, addSme: false); - } - - // proceed - var aeSrc = SubmodelElementWrapper.GetAdequateEnum(src?.GetElementName()); - if (src == null || aeSrc == SubmodelElementWrapper.AdequateElementEnum.Unknown) - { - // create a default? - if (createDefault == null) - return null; - - // ok, default - var dflt = this.CreateSMEForCD(createDefault, idShort: idShort, addSme: addSme); - - // set default? - setDefault?.Invoke(dflt); - - // return - return dflt; - } - - // ok, create new one - var dst = SubmodelElementWrapper.CreateAdequateType(aeSrc, src) as T; - if (dst == null) - return null; - - // make same things sure - dst.idShort = src.idShort; - dst.category = src.category; - dst.semanticId = new SemanticId(destSemanticId); - - // instantanously add it? - if (addSme) - this.Add(dst); - - // give back - return dst; - } - - public T CopyOneSMEbyCopy(ConceptDescription destCD, - SubmodelElementWrapperCollection sourceSmc, ConceptDescription sourceCD, - bool createDefault = false, Action setDefault = null, - Key.MatchMode matchMode = Key.MatchMode.Relaxed, - string idShort = null, bool addSme = false) where T : SubmodelElement, new() - { - return this.CopyOneSMEbyCopy(destCD?.GetSingleId(), sourceSmc, new[] { sourceCD?.GetSingleId() }, - createDefault ? destCD : null, setDefault, matchMode, idShort, addSme); - } - - public T CopyOneSMEbyCopy(ConceptDescription destCD, - SubmodelElementWrapperCollection sourceSmc, Identifier[] sourceIds, - bool createDefault = false, Action setDefault = null, - Key.MatchMode matchMode = Key.MatchMode.Relaxed, - string idShort = null, bool addSme = false) where T : SubmodelElement, new() - { - return this.CopyOneSMEbyCopy(destCD?.GetSingleId(), sourceSmc, sourceIds, - createDefault ? destCD : null, setDefault, matchMode, idShort, addSme); - } - - public void CopyManySMEbyCopy(Identifier destSemanticId, - SubmodelElementWrapperCollection sourceSmc, Identifier sourceSemanticId, - ConceptDescription createDefault = null, Action setDefault = null, - Key.MatchMode matchMode = Key.MatchMode.Relaxed) where T : SubmodelElement, new() - { - // bool find possible sources - bool foundSrc = false; - if (sourceSmc == null) - return; - foreach (var src in sourceSmc.FindAllSemanticIdAs(sourceSemanticId, matchMode)) - { - // type of found src? - var aeSrc = SubmodelElementWrapper.GetAdequateEnum(src?.GetElementName()); - - // ok? - if (src == null || aeSrc == SubmodelElementWrapper.AdequateElementEnum.Unknown) - continue; - foundSrc = true; - - // ok, create new one - var dst = SubmodelElementWrapper.CreateAdequateType(aeSrc, src) as T; - if (dst != null) - { - // make same things sure - dst.idShort = src.idShort; - dst.category = src.category; - dst.semanticId = new SemanticId(destSemanticId); - - // instantanously add it? - this.Add(dst); - } - } - - // default? - if (createDefault != null && !foundSrc) - { - // ok, default - var dflt = this.CreateSMEForCD(createDefault, addSme: true); - - // set default? - setDefault?.Invoke(dflt); - } - } - - public void CopyManySMEbyCopy(ConceptDescription destCD, - SubmodelElementWrapperCollection sourceSmc, ConceptDescription sourceCD, - bool createDefault = false, Action setDefault = null, - Key.MatchMode matchMode = Key.MatchMode.Relaxed) where T : SubmodelElement, new() - { - CopyManySMEbyCopy(destCD.GetSingleId(), sourceSmc, sourceCD.GetSingleId(), - createDefault ? destCD : null, setDefault, matchMode); - } - } - - // - // Derived from SubmodelElements - // - - public class DataElement : SubmodelElement - { - public static string ValueType_STRING = "string"; - public static string ValueType_DATE = "date"; - public static string ValueType_BOOLEAN = "boolean"; - - public static string[] ValueTypeItems = new string[] { - "anyURI", "base64Binary", - "boolean", "date", "dateTime", - "dateTimeStamp", "decimal", "integer", "long", "int", "short", "byte", "nonNegativeInteger", - "positiveInteger", - "unsignedLong", "unsignedInt", "unsignedShort", "unsignedByte", - "nonPositiveInteger", "negativeInteger", - "double", "duration", - "dayTimeDuration", "yearMonthDuration", "float", "hexBinary", "string", "langString", "time" }; - - public static string[] ValueTypes_Number = new[] { - "decimal", "integer", "long", "int", "short", "byte", "nonNegativeInteger", - "positiveInteger", - "unsignedLong", "unsignedShort", "unsignedByte", "nonPositiveInteger", "negativeInteger", - "double", "float" }; - - public DataElement() { } - - public DataElement(SubmodelElement src) : base(src) { } - - public DataElement(DataElement src) : base(src) { } - -#if !DoNotUseAasxCompatibilityModels - public DataElement(AasxCompatibilityModels.AdminShellV10.DataElement src) - : base(src) - { } - - public DataElement(AasxCompatibilityModels.AdminShellV20.DataElement src) : base(src) { } -#endif - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("DataElement", "DE"); - } - } - - public class JsonValueTypeCast - { - - public class JsonDataObjectType - { - [JsonProperty(PropertyName = "name")] - public string name = ""; - } - - [JsonProperty(PropertyName = "dataObjectType")] - public JsonDataObjectType dataObjectType = new JsonDataObjectType(); - - public JsonValueTypeCast(string name) - { - this.dataObjectType.name = name; - } - } - - public class Property : DataElement - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - - [MetaModelName("Property.valueType")] - [TextSearchable] - [JsonIgnore] - public string valueType = ""; - [XmlIgnore] - [JsonProperty(PropertyName = "valueType")] - public JsonValueTypeCast JsonValueType - { - get { return new JsonValueTypeCast(this.valueType); } - set { this.valueType = value?.dataObjectType?.name; } - } - - - [MetaModelName("Property.value")] - [TextSearchable] - public string value = ""; - public GlobalReference valueId = null; - - // constructors - - public Property() { } - - public Property(SubmodelElement src) - : base(src) - { - if (!(src is Property p)) - return; - this.valueType = p.valueType; - this.value = p.value; - if (p.valueId != null) - valueId = new GlobalReference(p.valueId); - } - -#if !DoNotUseAasxCompatibilityModels - public Property(AasxCompatibilityModels.AdminShellV10.Property src) - : base(src) - { - if (src == null) - return; - - this.valueType = src.valueType; - this.value = src.value; - if (src.valueId != null) - this.valueId = new GlobalReference(src.valueId); - } - - public Property(AasxCompatibilityModels.AdminShellV20.Property src) - : base(src) - { - if (src == null) - return; - - this.valueType = src.valueType; - this.value = src.value; - if (src.valueId != null) - this.valueId = new GlobalReference(src.valueId); - } - -#endif - - public static Property CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new Property(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - public Property Set(string valueType = "", string value = "") - { - this.valueType = valueType; - this.value = value; - return this; - } - - public Property SetValueId(string valueId) - { - this.valueId = GlobalReference.CreateNew(value); - return this; - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Property", "Prop", - SubmodelElementWrapper.AdequateElementEnum.Property); - } - - public override string ValueAsText(string defaultLang = null) - { - return "" + value; - } - - public override void ValueFromText(string text, string defaultLang = null) - { - value = "" + text; - } - - public bool IsTrue() - { - if (this.valueType?.Trim().ToLower() == "boolean") - { - var v = "" + this.value?.Trim().ToLower(); - if (v == "true" || v == "1") - return true; - } - return false; - } - - public override double? ValueAsDouble() - { - // pointless - if (this.value == null || this.value.Trim() == "" || this.valueType == null) - return null; - - // type? - var vt = this.valueType.Trim().ToLower(); - if (!DataElement.ValueTypes_Number.Contains(vt)) - return null; - - // try convert - if (double.TryParse(this.value, NumberStyles.Any, CultureInfo.InvariantCulture, out double dbl)) - return dbl; - - // no - return null; - } - - public override object ToValueOnlySerialization() - { - var valueObject = new Dictionary - { - { idShort, value } - }; - return valueObject; - } - - } - - public class MultiLanguageProperty : DataElement - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - - public LangStringSet value = new LangStringSet(); - public GlobalReference valueId = null; - - // constructors - - public MultiLanguageProperty() { } - - public MultiLanguageProperty(SubmodelElement src) - : base(src) - { - if (!(src is MultiLanguageProperty mlp)) - return; - - this.value = new LangStringSet(mlp.value); - if (mlp.valueId != null) - valueId = new GlobalReference(mlp.valueId); - } - -#if !DoNotUseAasxCompatibilityModels - // not available in V1.0 - public MultiLanguageProperty(AasxCompatibilityModels.AdminShellV20.MultiLanguageProperty src) - : base(src) - { - this.value = new LangStringSet(src.value); - if (src.valueId != null) - valueId = new GlobalReference(src.valueId); - } -#endif - - public static MultiLanguageProperty CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new MultiLanguageProperty(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("MultiLanguageProperty", "MLP", - SubmodelElementWrapper.AdequateElementEnum.MultiLanguageProperty); - } - - public MultiLanguageProperty Set(LangStringSet ls) - { - this.value = ls; - return this; - } - - public MultiLanguageProperty Set(ListOfLangStr ls) - { - this.value = new LangStringSet(ls); - return this; - } - - public MultiLanguageProperty Set(LangStr ls) - { - if (ls == null) - return this; - if (this.value?.langString == null) - this.value = new LangStringSet(); - this.value.langString[ls.lang] = ls.str; - return this; - } - - public MultiLanguageProperty Set(string lang, string str) - { - return this.Set(new LangStr(lang, str)); - } - - public override string ValueAsText(string defaultLang = null) - { - return "" + value?.GetDefaultStr(defaultLang); - } - - public override void ValueFromText(string text, string defaultLang = null) - { - Set(defaultLang, text); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary>(); - var valueDict = new Dictionary(); - foreach (LangStr langStr in value.langString) - { - valueDict.Add(langStr.lang, langStr.str); - } - - output.Add(idShort, valueDict); - return output; - } - - } - - public class Range : DataElement - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - - [MetaModelName("Range.valueType")] - [TextSearchable] - [JsonIgnore] - [CountForHash] - public string valueType = ""; - - [XmlIgnore] - [JsonProperty(PropertyName = "valueType")] - public JsonValueTypeCast JsonValueType - { - get { return new JsonValueTypeCast(this.valueType); } - set { this.valueType = value?.dataObjectType?.name; } - } - - [MetaModelName("Range.min")] - [TextSearchable] - [CountForHash] - public string min = ""; - - [MetaModelName("Range.max")] - [TextSearchable] - [CountForHash] - public string max = ""; - - // constructors - - public Range() { } - - public Range(SubmodelElement src) - : base(src) - { - if (!(src is Range rng)) - return; - - this.valueType = rng.valueType; - this.min = rng.min; - this.max = rng.max; - } - -#if !DoNotUseAasxCompatibilityModels - // not available in V1.0 - - public Range(AasxCompatibilityModels.AdminShellV20.Range src) - : base(src) - { - this.valueType = src.valueType; - this.min = src.min; - this.max = src.max; - } -#endif - - public static Range CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new Range(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Range", "Range", - SubmodelElementWrapper.AdequateElementEnum.Range); - } - - public override string ValueAsText(string defaultLang = null) - { - return "" + min + " .. " + max; - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary>(); - var valueDict = new Dictionary - { - { "min", min }, - { "max", max } - }; - - output.Add(idShort, valueDict); - return output; - } - } - - public class Blob : DataElement - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - - [MetaModelName("Blob.mimeType")] - [TextSearchable] - [CountForHash] - public string mimeType = ""; - - [MetaModelName("Blob.value")] - [TextSearchable] - [CountForHash] - public string value = ""; - - // constructors - - public Blob() { } - - public Blob(SubmodelElement src) - : base(src) - { - if (!(src is Blob blb)) - return; - - this.mimeType = blb.mimeType; - this.value = blb.value; - } - -#if !DoNotUseAasxCompatibilityModels - public Blob(AasxCompatibilityModels.AdminShellV10.Blob src) - : base(src) - { - if (src == null) - return; - - this.mimeType = src.mimeType; - this.value = src.value; - } - - public Blob(AasxCompatibilityModels.AdminShellV20.Blob src) - : base(src) - { - if (src == null) - return; - - this.mimeType = src.mimeType; - this.value = src.value; - } -#endif - - public static Blob CreateNew(string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new Blob(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - public void Set(string mimeType = "", string value = "") - { - this.mimeType = mimeType; - this.value = value; - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Blob", "Blob", - SubmodelElementWrapper.AdequateElementEnum.Blob); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary>(); - var valueDict = new Dictionary - { - { "mimeType", mimeType }, - }; - - output.Add(idShort, valueDict); - return output; - } - - public object ToWithBlobOnlyValue() - { - var output = new Dictionary>(); - var valueDict = new Dictionary - { - { "mimeType", mimeType }, - { "value", Base64UrlEncoder.Encode(value) } - }; - - output.Add(idShort, valueDict); - return output; - } - - } - - public class File : DataElement - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - - [MetaModelName("File.mimeType")] - [TextSearchable] - [CountForHash] - public string mimeType = ""; - - [MetaModelName("File.value")] - [TextSearchable] - [CountForHash] - public string value = ""; - - // constructors - - public File() { } - - public File(SubmodelElement src) - : base(src) - { - if (!(src is File fil)) - return; - - this.mimeType = fil.mimeType; - this.value = fil.value; - } - -#if !DoNotUseAasxCompatibilityModels - public File(AasxCompatibilityModels.AdminShellV10.File src) - : base(src) - { - if (src == null) - return; - - this.mimeType = src.mimeType; - this.value = src.value; - } - - public File(AasxCompatibilityModels.AdminShellV20.File src) - : base(src) - { - if (src == null) - return; - - this.mimeType = src.mimeType; - this.value = src.value; - } -#endif - - public static File CreateNew(string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new File(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - public void Set(string mimeType = "", string value = "") - { - this.mimeType = mimeType; - this.value = value; - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("File", "File", - SubmodelElementWrapper.AdequateElementEnum.File); - } - - public static string[] GetPopularMimeTypes() - { - return - new[] { - System.Net.Mime.MediaTypeNames.Text.Plain, - System.Net.Mime.MediaTypeNames.Text.Xml, - System.Net.Mime.MediaTypeNames.Text.Html, - "application/json", - "application/rdf+xml", - System.Net.Mime.MediaTypeNames.Application.Pdf, - System.Net.Mime.MediaTypeNames.Image.Jpeg, - "image/png", - System.Net.Mime.MediaTypeNames.Image.Gif, - "application/iges", - "application/step" - }; - } - - public override string ValueAsText(string defaultLang = null) - { - return "" + value; - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary>(); - var valueDict = new Dictionary - { - { "mimeType", mimeType }, - { "value", value } - }; - - output.Add(idShort, valueDict); - return output; - } - } - - // - // Reference elements - // - - /// - /// This class was the old V2.0 ReferenceElement, which now turned into - /// more a abstract class. - /// - public class ReferenceElement : DataElement - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - - // constructors - - public ReferenceElement() { } - - public ReferenceElement(SubmodelElement src) - : base(src) - { - } - -#if !DoNotUseAasxCompatibilityModels - public ReferenceElement(AasxCompatibilityModels.AdminShellV10.ReferenceElement src) - : base(src) - { - } - - public ReferenceElement(AasxCompatibilityModels.AdminShellV20.ReferenceElement src) - : base(src) - { - } -#endif - - // self description - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("ReferenceElement", "Ref", - SubmodelElementWrapper.AdequateElementEnum.ReferenceElement); - } - - } - - /// - /// New V3.0 reference element, specifically targeted at model references - /// - public class ModelReferenceElement : ReferenceElement - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - - public ModelReference value = new ModelReference(); - - // constructors - - public ModelReferenceElement() { } - - public ModelReferenceElement(SubmodelElement src) - : base(src) - { - if (!(src is ModelReferenceElement mre)) - return; - - if (mre.value != null) - this.value = new ModelReference(mre.value); - } - -#if !DoNotUseAasxCompatibilityModels - public ModelReferenceElement(AasxCompatibilityModels.AdminShellV10.ReferenceElement src) - : base(src) - { - if (src == null) - return; - - if (src.value != null) - this.value = new ModelReference(src.value); - } - - public ModelReferenceElement(AasxCompatibilityModels.AdminShellV20.ReferenceElement src) - : base(src) - { - if (src == null) - return; - - if (src.value != null) - this.value = new ModelReference(src.value); - } -#endif - - public static ModelReferenceElement CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new ModelReferenceElement(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - public void Set(ModelReference value = null) - { - this.value = value; - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("ModelReferenceElement", "RefM", - SubmodelElementWrapper.AdequateElementEnum.ModelReferenceElement); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary>>(); - - var list = new List>(); - foreach (var key in value.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - list.Add(valueDict); - } - - output.Add(idShort, list); - return output; - } - - } - - /// - /// New V3.0 reference element, specifically targeted at global references - /// - public class GlobalReferenceElement : ReferenceElement - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - - public GlobalReference value = new GlobalReference(); - - // constructors - - public GlobalReferenceElement() { } - - public GlobalReferenceElement(SubmodelElement src) - : base(src) - { - if (!(src is GlobalReferenceElement gre)) - return; - - if (gre.value != null) - this.value = new GlobalReference(gre.value); - } - -#if !DoNotUseAasxCompatibilityModels - public GlobalReferenceElement(AasxCompatibilityModels.AdminShellV10.ReferenceElement src) - : base(src) - { - if (src == null) - return; - - if (src.value != null) - this.value = new GlobalReference(src.value); - } - - public GlobalReferenceElement(AasxCompatibilityModels.AdminShellV20.ReferenceElement src) - : base(src) - { - if (src == null) - return; - - if (src.value != null) - this.value = new GlobalReference(src.value); - } -#endif - - public static GlobalReferenceElement CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new GlobalReferenceElement(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - public void Set(GlobalReference value = null) - { - this.value = value; - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("GlobalReferenceElement", "RefG", - SubmodelElementWrapper.AdequateElementEnum.GlobalReferenceElement); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary>(); - - var list = new List(); - foreach (var refVal in this.value.Value) - { - list.Add(refVal.value); - } - - output.Add(idShort, list); - return output; - } - - } - - // - // Relationships - // - - public class RelationshipElement : DataElement - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - - public ModelReference first = new ModelReference(); - public ModelReference second = new ModelReference(); - - // constructors - - public RelationshipElement() { } - - public RelationshipElement(SubmodelElement src) - : base(src) - { - if (!(src is RelationshipElement rel)) - return; - - if (rel.first != null) - this.first = new ModelReference(rel.first); - if (rel.second != null) - this.second = new ModelReference(rel.second); - } - -#if !DoNotUseAasxCompatibilityModels - public RelationshipElement(AasxCompatibilityModels.AdminShellV10.RelationshipElement src) - : base(src) - { - if (src == null) - return; - - if (src.first != null) - this.first = new ModelReference(src.first); - if (src.second != null) - this.second = new ModelReference(src.second); - } - - public RelationshipElement(AasxCompatibilityModels.AdminShellV20.RelationshipElement src) - : base(src) - { - if (src == null) - return; - - if (src.first != null) - this.first = new ModelReference(src.first); - if (src.second != null) - this.second = new ModelReference(src.second); - } -#endif - - public static RelationshipElement CreateNew( - string idShort = null, string category = null, - Identifier semanticIdKey = null, ModelReference first = null, - ModelReference second = null) - { - var x = new RelationshipElement(); - x.CreateNewLogic(idShort, category, semanticIdKey); - x.first = first; - x.second = second; - return (x); - } - - public void Set(ModelReference first = null, ModelReference second = null) - { - this.first = first; - this.second = second; - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("RelationshipElement", "Rel", - SubmodelElementWrapper.AdequateElementEnum.RelationshipElement); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary(); - - var listFirst = new List>(); - foreach (var key in first.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - listFirst.Add(valueDict); - } - - var listSecond = new List>(); - foreach (var key in second.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - listSecond.Add(valueDict); - } - - dynamic relObj = new ExpandoObject(); - relObj.first = listFirst; - relObj.second = listSecond; - output.Add(idShort, relObj); - return output; - } - } - - public class AnnotatedRelationshipElement : RelationshipElement, IManageSubmodelElements, IEnumerateChildren - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - - // from this very class - - [JsonIgnore] - [SkipForHash] // do NOT count children! - [XmlArray("annotations")] - [XmlArrayItem("dataElement")] - public DataElementWrapperCollection annotations = null; - - [XmlIgnore] - [JsonProperty(PropertyName = "annotations")] - public DataElement[] JsonAnotations - { - get - { - var res = new List(); - if (annotations != null) - foreach (var smew in annotations) - if (smew.submodelElement is DataElement de) - res.Add(de); - return res.ToArray(); - } - set - { - if (value != null) - { - this.annotations = new DataElementWrapperCollection(); - foreach (var x in value) - { - var smew = new SubmodelElementWrapper() { submodelElement = x }; - this.annotations.Add(smew); - } - } - } - } - - // constructors - - public AnnotatedRelationshipElement() { } - - public AnnotatedRelationshipElement(SubmodelElement src) - : base(src) - { - if (!(src is AnnotatedRelationshipElement arel)) - return; - if (arel.first != null) - this.first = new ModelReference(arel.first); - if (arel.second != null) - this.second = new ModelReference(arel.second); - if (arel.annotations != null) - this.annotations = new DataElementWrapperCollection(arel.annotations); - } - -#if !DoNotUseAasxCompatibilityModels - public AnnotatedRelationshipElement(AasxCompatibilityModels.AdminShellV20.AnnotatedRelationshipElement src) - : base(src) - { - if (src.first != null) - this.first = new ModelReference(src.first); - if (src.second != null) - this.second = new ModelReference(src.second); - if (src.annotations != null) - this.annotations = new DataElementWrapperCollection(src.annotations); - } -#endif - - public new static AnnotatedRelationshipElement CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null, - ModelReference first = null, ModelReference second = null) - { - var x = new AnnotatedRelationshipElement(); - x.CreateNewLogic(idShort, category, semanticIdKey); - x.first = first; - x.second = second; - return (x); - } - - // enumerates its children - - public IEnumerable EnumerateChildren() - { - if (this.annotations != null) - foreach (var smw in this.annotations) - yield return smw; - } - - public EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child) - { - return null; - } - - public object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null) - { - if (smw == null || !(smw.submodelElement is DataElement)) - return null; - if (this.annotations == null) - this.annotations = new DataElementWrapperCollection(); - if (smw.submodelElement != null) - smw.submodelElement.parent = this; - this.annotations.Add(smw); - return smw; - } - - // from IManageSubmodelElements - public void Add(SubmodelElement sme) - { - if (annotations == null) - annotations = new DataElementWrapperCollection(); - var sew = new SubmodelElementWrapper(); - sme.parent = this; // track parent here! - sew.submodelElement = sme; - annotations.Add(sew); - } - - public void Insert(int index, SubmodelElement sme) - { - if (annotations == null) - annotations = new DataElementWrapperCollection(); - var sew = new SubmodelElementWrapper(); - sme.parent = this; // track parent here! - if (index < 0 || index >= annotations.Count) - return; - annotations.Insert(index, sew); - } - - public void Remove(SubmodelElement sme) - { - if (annotations != null) - annotations.Remove(sme); - } - - // further - - public new void Set(ModelReference first = null, ModelReference second = null) - { - this.first = first; - this.second = second; - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("AnnotatedRelationshipElement", "RelA", - SubmodelElementWrapper.AdequateElementEnum.AnnotatedRelationshipElement); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary(); - - var listFirst = new List>(); - foreach (var key in first.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - listFirst.Add(valueDict); - } - - var listSecond = new List>(); - foreach (var key in second.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - listSecond.Add(valueDict); - } - - List valueOnlyAnnotations = new List(); - - foreach (var sme in annotations) - { - valueOnlyAnnotations.Add(sme.submodelElement.ToValueOnlySerialization()); - } - - dynamic relObj = new ExpandoObject(); - relObj.first = listFirst; - relObj.second = listSecond; - relObj.annotation = valueOnlyAnnotations; - output.Add(idShort, relObj); - return output; - } - - } - - public class Capability : SubmodelElement - { - public Capability() { } - - public Capability(SubmodelElement src) - : base(src) - { } - -#if !DoNotUseAasxCompatibilityModels - public Capability(AasxCompatibilityModels.AdminShellV20.Capability src) - : base(src) - { } -#endif - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Capability", "Cap", - SubmodelElementWrapper.AdequateElementEnum.Capability); - } - } - - /// - /// In V2.0, this was the most important SME to hold multiple child SME. - /// Ib V3.0, this is deprecated and will made abstract. - /// Use SubmodelElementList, SubmodelElementStruct instead. - /// - public class SubmodelElementCollection : SubmodelElement, IManageSubmodelElements, IEnumerateChildren - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // values == SMEs - [XmlIgnore] - [JsonIgnore] - [SkipForHash] // do NOT count children! - //private SubmodelElementWrapperCollection _value = null; - private SubmodelElementWrapperCollection _value = new SubmodelElementWrapperCollection(); - - [JsonIgnore] - public SubmodelElementWrapperCollection value - { - get { return _value; } - set { _value = value; _value.Parent = this; } - } - - [XmlIgnore] - [JsonProperty(PropertyName = "value")] - public SubmodelElement[] JsonValue - { - get - { - var res = new ListOfSubmodelElement(); - if (value != null) - foreach (var smew in value) - res.Add(smew.submodelElement); - return res.ToArray(); - } - set - { - if (value != null) - { - this.value = new SubmodelElementWrapperCollection(); - foreach (var x in value) - { - var smew = new SubmodelElementWrapper() { submodelElement = x }; - this.value.Add(smew); - } - } - } - } - - // constant members - public bool ordered = false; - public bool allowDuplicates = false; - - // enumartes its children - - public IEnumerable EnumerateChildren() - { - if (this.value != null) - foreach (var smw in this.value) - yield return smw; - } - - public EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child) - { - return null; - } - - public object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null) - { - if (smw == null) - return null; - if (this.value == null) - this.value = new SubmodelElementWrapperCollection(); - if (smw.submodelElement != null) - smw.submodelElement.parent = this; - this.value.Add(smw); - return smw; - } - - // constructors - - public SubmodelElementCollection() { } - - public SubmodelElementCollection(SubmodelElement src, bool shallowCopy = false) - : base(src) - { - if (!(src is SubmodelElementCollection smc)) - return; - - this.ordered = smc.ordered; - this.allowDuplicates = smc.allowDuplicates; - this.value = new SubmodelElementWrapperCollection(); - if (!shallowCopy) - foreach (var smw in smc.value) - value.Add(new SubmodelElementWrapper(smw.submodelElement)); - } - -#if !DoNotUseAasxCompatibilityModels - public SubmodelElementCollection( - AasxCompatibilityModels.AdminShellV10.SubmodelElementCollection src, bool shallowCopy = false) - : base(src) - { - if (src == null) - return; - - this.ordered = src.ordered; - this.allowDuplicates = src.allowDuplicates; - this.value = new SubmodelElementWrapperCollection(); - if (!shallowCopy) - foreach (var smw in src.value) - value.Add(new SubmodelElementWrapper(smw.submodelElement)); - } - - public SubmodelElementCollection( - AasxCompatibilityModels.AdminShellV20.SubmodelElement src, bool shallowCopy = false) - : base(src) - { - if (!(src is AasxCompatibilityModels.AdminShellV20.SubmodelElementCollection smc)) - return; - - this.ordered = smc.ordered; - this.allowDuplicates = smc.allowDuplicates; - this.value = new SubmodelElementWrapperCollection(); - if (!shallowCopy) - foreach (var smw in smc.value) - value.Add(new SubmodelElementWrapper(smw.submodelElement)); - } -#endif - - public static SubmodelElementCollection CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new SubmodelElementCollection(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - // from IManageSubmodelElements - public void Add(SubmodelElement sme) - { - if (value == null) - value = new SubmodelElementWrapperCollection(); - var sew = new SubmodelElementWrapper(); - sme.parent = this; // track parent here! - sew.submodelElement = sme; - value.Add(sew); - } - - public void Insert(int index, SubmodelElement sme) - { - if (value == null) - value = new SubmodelElementWrapperCollection(); - var sew = new SubmodelElementWrapper(); - sme.parent = this; // track parent here! - sew.submodelElement = sme; - if (index < 0 || index >= value.Count) - return; - value.Insert(index, sew); - } - - public void Remove(SubmodelElement sme) - { - if (value != null) - value.Remove(sme); - } - - // further - - public void Set(bool allowDuplicates = false, bool ordered = false) - { - this.allowDuplicates = allowDuplicates; - this.ordered = ordered; - } - - public SubmodelElementWrapper FindFirstIdShort(string idShort) - { - return this.value?.FindFirstIdShort(idShort); - } - - public T CreateSMEForCD(ConceptDescription cd, string category = null, string idShort = null, - string idxTemplate = null, int maxNum = 999, bool addSme = false) where T : SubmodelElement, new() - { - if (this.value == null) - this.value = new SubmodelElementWrapperCollection(); - return this.value.CreateSMEForCD(cd, category, idShort, idxTemplate, maxNum, addSme); - } - - public T CreateSMEForIdShort(string idShort, string category = null, - string idxTemplate = null, int maxNum = 999, bool addSme = false) where T : SubmodelElement, new() - { - if (this.value == null) - this.value = new SubmodelElementWrapperCollection(); - return this.value.CreateSMEForIdShort(idShort, category, idxTemplate, maxNum, addSme); - } - - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("SubmodelElementCollection", "SMC", - SubmodelElementWrapper.AdequateElementEnum.SubmodelElementCollection); - } - - // Recursing - - /// - /// Recurses on all Submodel elements of a Submodel or SME, which allows children. - /// The state object will be passed to the lambda function in order to provide - /// stateful approaches. - /// - /// State object to be provided to lambda. Could be null. - /// The lambda function as (state, parents, SME) - /// The lambda shall return TRUE in order to deep into recursion. - /// - public void RecurseOnSubmodelElements( - object state, Func lambda) - { - this.value?.RecurseOnReferables(state, null, (o, par, rf) => - { - if (rf is SubmodelElement sme) - return lambda(o, par, sme); - else - return true; - }); - } - - /// - /// Recurses on all Submodel elements of a Submodel or SME, which allows children. - /// The state object will be passed to the lambda function in order to provide - /// stateful approaches. Include this element, as well. - /// - /// State object to be provided to lambda. Could be null. - /// The lambda function as (state, parents, SME) - /// The lambda shall return TRUE in order to deep into recursion. - /// Include this element as well. parents will then - /// include this element as well! - public override void RecurseOnReferables( - object state, Func lambda, - bool includeThis = false) - { - var parents = new ListOfReferable(); - if (includeThis) - { - lambda(state, null, this); - parents.Add(this); - } - this.value?.RecurseOnReferables(state, parents, lambda); - } - } - - public class SubmodelElementList : SubmodelElementCollection - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - // (from "old" SMC, there are a lot members!) - - public bool orderRelevant = false; - - public SemanticId semanticIdListElement = null; - - // Note MIHO: I was attempted to have the type of SubmodelElementWrapper.AdequateElementEnum, - // however basic approach of this SDK is to have everything as string to be open - public string typeValueListElement = null; - - public string valueTypeListElement = null; - - // constructors - - public SubmodelElementList() { } - - public SubmodelElementList(SubmodelElement src, bool shallowCopy = false) - : base(src, shallowCopy) - { - if (!(src is SubmodelElementList sml)) - return; - - this.orderRelevant = sml.orderRelevant; - - if (sml.semanticIdListElement != null) - this.semanticIdListElement = new SemanticId(sml.semanticIdListElement); - - this.typeValueListElement = sml.typeValueListElement; - this.valueTypeListElement = sml.valueTypeListElement; - } - -#if !DoNotUseAasxCompatibilityModels - // new in V3.0 -#endif - - public new static SubmodelElementList CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new SubmodelElementList(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - // advanced checks - - public class ConstraintStat - { - /// - /// Constraint AASd-107: If a first level child element in a SubmodelElementList has a semanticId - /// it shall be identical to SubmodelElementList/semanticIdListElement. - /// - public bool AllChildSemIdMatch = true; - - /// - /// Constraint AASd-108: All first level child elements in a SubmodelElementList shall have the - /// same submodel element type as specified in SubmodelElementList/typeValueListElement. - /// - public bool AllChildSmeTypeMatch = true; - - /// - /// Constraint AASd-109: If SubmodelElementList/typeValueListElement equal to Property or Range, - /// SubmodelElementList/valueTypeListElement shall be set and all first level child elements in - /// the SubmodelElementList shall have the the value type as specified in - /// SubmodelElementList/valueTypeListElement - /// - public bool AllChildValueTypeMatch = true; - } - - public ConstraintStat EvalConstraintStat() - { - // access - var res = new ConstraintStat(); - if (value == null) - return res; - - // prepare SME type - var smeTypeToCheck = SubmodelElementWrapper.GetAdequateEnum2(typeValueListElement); - - // prepare value type - var valueTypeToCheck = valueTypeListElement?.Trim().ToLower(); - - // eval - foreach (var smw in value) - { - // access - var sme = smw?.submodelElement; - if (sme == null) - continue; - - // need self description - var smesd = sme.GetSelfDescription(); - if (smesd == null) - continue; - - // sem id? - if (res.AllChildSemIdMatch - && semanticIdListElement?.IsValid == true - && sme.semanticId?.IsValid == true - && !semanticIdListElement.Matches(sme.semanticId)) - res.AllChildSemIdMatch = false; - - // type of SME? - if (smeTypeToCheck != SubmodelElementWrapper.AdequateElementEnum.Unknown - && res.AllChildSmeTypeMatch - && smesd.ElementEnum != smeTypeToCheck) - res.AllChildSmeTypeMatch = false; - - // value type to check - // TODO (MIHO, 2022-01-08): GetValueType() worth the effort to implement? - if (valueTypeToCheck != null && valueTypeToCheck.Length > 0 - && res.AllChildValueTypeMatch - && sme is AdminShell.Property prop - && prop.valueType != null && prop.value.Trim().Length > 0 - && prop.value.Trim().ToLower() != valueTypeToCheck) - res.AllChildValueTypeMatch = false; - - if (valueTypeToCheck != null && valueTypeToCheck.Length > 0 - && res.AllChildValueTypeMatch - && sme is AdminShell.Property range - && range.valueType != null && range.value.Trim().Length > 0 - && range.value.Trim().ToLower() != valueTypeToCheck) - res.AllChildValueTypeMatch = false; - } - - // ok - return res; - } - - // self description - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("SubmodelElementList", "SML", - SubmodelElementWrapper.AdequateElementEnum.SubmodelElementList); - } - - - } - - public class SubmodelElementStruct : SubmodelElementCollection - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - // (no new members compared to SMC of V2.0) - - // constructors - - public SubmodelElementStruct() { } - - public SubmodelElementStruct(SubmodelElement src, bool shallowCopy = false) - : base(src, shallowCopy) - { - } - -#if !DoNotUseAasxCompatibilityModels - // new in V3.0 -#endif - - public new static SubmodelElementStruct CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new SubmodelElementStruct(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - // self description - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("SubmodelElementStruct", "SMS", - SubmodelElementWrapper.AdequateElementEnum.SubmodelElementStruct); - } - - - } - - // - // Operation - // - - public class OperationVariable : IAasElement - { - public enum Direction { In, Out, InOut }; - - // Note: for OperationVariable, the values of the SubmodelElement itself ARE NOT TO BE USED! - // only the SME attributes of "value" are counting - - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public JsonModelTypeWrapper JsonModelType { get { return new JsonModelTypeWrapper(GetElementName()); } } - - // members - public SubmodelElementWrapper value = null; - - // constructors - - public OperationVariable() - { - } - - public OperationVariable(OperationVariable src, bool shallowCopy = false) - { - this.value = new SubmodelElementWrapper(src?.value?.submodelElement, shallowCopy); - } - -#if !DoNotUseAasxCompatibilityModels - public OperationVariable( - AasxCompatibilityModels.AdminShellV10.OperationVariable src, bool shallowCopy = false) - { - this.value = new SubmodelElementWrapper(src.value.submodelElement, shallowCopy); - } - - public OperationVariable( - AasxCompatibilityModels.AdminShellV20.OperationVariable src, bool shallowCopy = false) - { - this.value = new SubmodelElementWrapper(src.value.submodelElement, shallowCopy); - } -#endif - - public OperationVariable(SubmodelElement elem) - : base() - { - this.value = new SubmodelElementWrapper(elem); - } - - public AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("OperationVariable", "OprVar"); - } - - public string GetElementName() - { - return this.GetSelfDescription()?.ElementName; - } - } - - public class Operation : SubmodelElement, IEnumerateChildren - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // members - [JsonIgnore] - [XmlElement(ElementName = "inputVariable")] - [SkipForHash] // do NOT count children! - public List inputVariable = new List(); - - [JsonIgnore] - [XmlElement(ElementName = "outputVariable")] - [SkipForHash] // do NOT count children! - public List outputVariable = new List(); - - [JsonIgnore] - [XmlElement(ElementName = "inoutputVariable")] - [SkipForHash] // do NOT count children! - public List inoutputVariable = new List(); - - [XmlIgnore] - // MICHA 190504: enabled JSON operation variables! - [JsonProperty(PropertyName = "inputVariable")] - public OperationVariable[] JsonInputVariable - { - get { return inputVariable?.ToArray(); } - set { inputVariable = (value != null) ? new List(value) : null; } - } - - [XmlIgnore] - [JsonProperty(PropertyName = "outputVariable")] - // MICHA 190504: enabled JSON operation variables! - public OperationVariable[] JsonOutputVariable - { - get { return outputVariable?.ToArray(); } - set { outputVariable = (value != null) ? new List(value) : null; } - } - - [XmlIgnore] - [JsonProperty(PropertyName = "inoutputVariable")] - // MICHA 190504: enabled JSON operation variables! - public OperationVariable[] JsonInOutputVariable - { - get { return inoutputVariable?.ToArray(); } - set { inoutputVariable = (value != null) ? new List(value) : null; } - } - - public List this[OperationVariable.Direction dir] - { - get - { - if (dir == OperationVariable.Direction.In) - return inputVariable; - else - if (dir == OperationVariable.Direction.Out) - return outputVariable; - else - return inoutputVariable; - } - set - { - if (dir == OperationVariable.Direction.In) - inputVariable = value; - else - if (dir == OperationVariable.Direction.Out) - outputVariable = value; - else - inoutputVariable = value; - } - } - - public List this[int dir] - { - get - { - if (dir == 0) - return inputVariable; - else - if (dir == 1) - return outputVariable; - else - return inoutputVariable; - } - set - { - if (dir == 0) - inputVariable = value; - else - if (dir == 1) - outputVariable = value; - else - inoutputVariable = value; - } - } - - public static SubmodelElementWrapperCollection GetWrappers(List ovl) - { - var res = new SubmodelElementWrapperCollection(); - foreach (var ov in ovl) - if (ov.value != null) - res.Add(ov.value); - return res; - } - - // enumartes its children - public IEnumerable EnumerateChildren() - { - if (this.inputVariable != null) - foreach (var smw in this.inputVariable) - yield return smw?.value; - - if (this.outputVariable != null) - foreach (var smw in this.outputVariable) - yield return smw?.value; - - if (this.inoutputVariable != null) - foreach (var smw in this.inoutputVariable) - yield return smw?.value; - } - - public class EnumerationPlacmentOperationVariable : EnumerationPlacmentBase - { - public OperationVariable.Direction Direction; - public OperationVariable OperationVariable; - } - - public EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child) - { - // trivial - if (child == null) - return null; - - // search - OperationVariable.Direction? dir = null; - OperationVariable opvar = null; - if (this.inputVariable != null) - foreach (var ov in this.inputVariable) - if (ov?.value?.submodelElement == child) - { - dir = OperationVariable.Direction.In; - opvar = ov; - } - - if (this.outputVariable != null) - foreach (var ov in this.outputVariable) - if (ov?.value?.submodelElement == child) - { - dir = OperationVariable.Direction.Out; - opvar = ov; - } - - if (this.inoutputVariable != null) - foreach (var ov in this.inoutputVariable) - if (ov?.value?.submodelElement == child) - { - dir = OperationVariable.Direction.InOut; - opvar = ov; - } - - // found - if (!dir.HasValue) - return null; - return new EnumerationPlacmentOperationVariable() - { - Direction = dir.Value, - OperationVariable = opvar - }; - } - - public object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null) - { - // not enough information to select list of children? - var pl = placement as EnumerationPlacmentOperationVariable; - if (smw == null || pl == null) - return null; - - // ok, use information - var ov = new OperationVariable(); - ov.value = smw; - - if (smw.submodelElement != null) - smw.submodelElement.parent = this; - - if (pl.Direction == OperationVariable.Direction.In) - { - if (inputVariable == null) - inputVariable = new List(); - inputVariable.Add(ov); - } - - if (pl.Direction == OperationVariable.Direction.Out) - { - if (outputVariable == null) - outputVariable = new List(); - outputVariable.Add(ov); - } - - if (pl.Direction == OperationVariable.Direction.InOut) - { - if (inoutputVariable == null) - inoutputVariable = new List(); - inoutputVariable.Add(ov); - } - - return ov; - } - - // constructors - - public Operation() { } - - public Operation(SubmodelElement src) - : base(src) - { - if (!(src is Operation op)) - return; - - for (int i = 0; i < 2; i++) - if (op[i] != null) - { - if (this[i] == null) - this[i] = new List(); - foreach (var ov in op[i]) - this[i].Add(new OperationVariable(ov)); - } - } - -#if !DoNotUseAasxCompatibilityModels - public Operation(AasxCompatibilityModels.AdminShellV10.Operation src) - : base(src) - { - for (int i = 0; i < 2; i++) - if (src[i] != null) - { - if (this[i] == null) - this[i] = new List(); - foreach (var ov in src[i]) - this[i].Add(new OperationVariable(ov)); - } - } - - public Operation(AasxCompatibilityModels.AdminShellV20.Operation src) - : base(src) - { - for (int i = 0; i < 2; i++) - if (src[i] != null) - { - if (this[i] == null) - this[i] = new List(); - foreach (var ov in src[i]) - this[i].Add(new OperationVariable(ov)); - } - } -#endif - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Operation", "Opr", - SubmodelElementWrapper.AdequateElementEnum.Operation); - } - } - - public class Entity : SubmodelElement, IManageSubmodelElements, IEnumerateChildren - { - public enum EntityTypeEnum { CoManagedEntity = 0, SelfManagedEntity = 1, Undef = 3 } - public static string[] EntityTypeNames = new string[] { "CoManagedEntity", "SelfManagedEntity" }; - - // for JSON only - - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // from this very class - [XmlIgnore] - [JsonIgnore] - [SkipForHash] // do NOT count children! - private SubmodelElementWrapperCollection _statements = null; - - [JsonIgnore] - public SubmodelElementWrapperCollection statements - { - get { return _statements; } - set { _statements = value; _statements.Parent = this; } - } - - [XmlIgnore] - [JsonProperty(PropertyName = "statements")] - public SubmodelElement[] JsonStatements - { - get - { - var res = new ListOfSubmodelElement(); - if (statements != null) - foreach (var smew in statements) - res.Add(smew.submodelElement); - return res.ToArray(); - } - set - { - if (value != null) - { - this.statements = new SubmodelElementWrapperCollection(); - foreach (var x in value) - { - var smew = new SubmodelElementWrapper() { submodelElement = x }; - this.statements.Add(smew); - } - } - } - } - - // further members - - [CountForHash] - public string entityType = ""; - - [JsonProperty(PropertyName = "asset")] - public ModelReference assetRef = null; - - // enumerates its children - - public IEnumerable EnumerateChildren() - { - if (this.statements != null) - foreach (var smw in this.statements) - yield return smw; - } - - public EnumerationPlacmentBase GetChildrenPlacement(SubmodelElement child) - { - return null; - } - - public object AddChild(SubmodelElementWrapper smw, EnumerationPlacmentBase placement = null) - { - if (smw == null) - return null; - if (this.statements == null) - this.statements = new SubmodelElementWrapperCollection(); - if (smw.submodelElement != null) - smw.submodelElement.parent = this; - this.statements.Add(smw); - return smw; - } - - // constructors - - public Entity() { } - - public Entity(SubmodelElement src) - : base(src) - { - if (!(src is Entity ent)) - return; - - if (ent.statements != null) - { - this.statements = new SubmodelElementWrapperCollection(); - foreach (var smw in ent.statements) - this.statements.Add(new SubmodelElementWrapper(smw.submodelElement)); - } - this.entityType = ent.entityType; - if (ent.assetRef != null) - this.assetRef = new ModelReference(ent.assetRef); - } - - public Entity(EntityTypeEnum entityType, string idShort = null, ModelReference assetRef = null, - string category = null, Identifier semanticIdKey = null) - { - CreateNewLogic(idShort, null, semanticIdKey); - - this.entityType = EntityTypeNames[(int)entityType]; - this.assetRef = assetRef; - } - -#if !DoNotUseAasxCompatibilityModels - // not available in V1.0 - - public Entity(AasxCompatibilityModels.AdminShellV20.Entity src) - : base(src) - { - if (src.statements != null) - { - this.statements = new SubmodelElementWrapperCollection(); - foreach (var smw in src.statements) - this.statements.Add(new SubmodelElementWrapper(smw.submodelElement)); - } - this.entityType = src.entityType; - if (src.assetRef != null) - this.assetRef = new ModelReference(src.assetRef); - } -#endif - - public static Entity CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new Entity(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - // from IManageSubmodelElements - public void Add(SubmodelElement sme) - { - if (statements == null) - statements = new SubmodelElementWrapperCollection(); - var sew = new SubmodelElementWrapper(); - sme.parent = this; // track parent here! - sew.submodelElement = sme; - statements.Add(sew); - } - - public void Insert(int index, SubmodelElement sme) - { - if (statements == null) - statements = new SubmodelElementWrapperCollection(); - var sew = new SubmodelElementWrapper(); - sme.parent = this; // track parent here! - sew.submodelElement = sme; - if (index < 0 || index >= statements.Count) - return; - statements.Insert(index, sew); - } - - public void Remove(SubmodelElement sme) - { - if (statements != null) - statements.Remove(sme); - } - - // management of elememts - - public SubmodelElementWrapper FindSubmodelElementWrapper(string idShort) - { - if (this.statements == null) - return null; - foreach (var smw in this.statements) - if (smw.submodelElement != null) - if (smw.submodelElement.idShort.Trim().ToLower() == idShort.Trim().ToLower()) - return smw; - return null; - } - - // entity type - - public EntityTypeEnum GetEntityType() - { - EntityTypeEnum res = EntityTypeEnum.Undef; - if (this.entityType != null && this.entityType.Trim().ToLower() == EntityTypeNames[0].ToLower()) - res = EntityTypeEnum.CoManagedEntity; - if (this.entityType != null && this.entityType.Trim().ToLower() == EntityTypeNames[1].ToLower()) - res = EntityTypeEnum.SelfManagedEntity; - return res; - } - - // name - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("Entity", "Ent", - SubmodelElementWrapper.AdequateElementEnum.Entity); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary(); - List valueOnlyStatements = new List(); - - foreach (var sme in statements) - { - valueOnlyStatements.Add(sme.submodelElement.ToValueOnlySerialization()); - } - - var valueDict = new Dictionary - { - { "statements", valueOnlyStatements }, - { "entityType", entityType}, - { "assetId", assetRef.First.value }, - }; - - output.Add(idShort, valueDict); - return output; - } - } - - public class BasicEvent : SubmodelElement - { - // for JSON only - [XmlIgnore] - [JsonProperty(PropertyName = "modelType")] - public new JsonModelTypeWrapper JsonModelType - { - get { return new JsonModelTypeWrapper(GetElementName()); } - } - - // from this very class - // TODO (MIHO, 2022-01-03): check if default to null?? - public ModelReference observed = new ModelReference(); - - // constructors - - public BasicEvent() { } - - public BasicEvent(SubmodelElement src) - : base(src) - { - if (!(src is BasicEvent be)) - return; - - if (be.observed != null) - this.observed = new ModelReference(be.observed); - } - -#if !DoNotUseAasxCompatibilityModels - // not available in V1.0 - - public BasicEvent(AasxCompatibilityModels.AdminShellV20.BasicEvent src) - : base(src) - { - if (src.observed != null) - this.observed = new ModelReference(src.observed); - } -#endif - - public static BasicEvent CreateNew( - string idShort = null, string category = null, Identifier semanticIdKey = null) - { - var x = new BasicEvent(); - x.CreateNewLogic(idShort, category, semanticIdKey); - return (x); - } - - public override AasElementSelfDescription GetSelfDescription() - { - return new AasElementSelfDescription("BasicEvent", "Evt", - SubmodelElementWrapper.AdequateElementEnum.BasicEvent); - } - - public override object ToValueOnlySerialization() - { - var output = new Dictionary(); - var list = new List>(); - foreach (var key in observed.Keys) - { - var valueDict = new Dictionary - { - { "type", key.type }, - { "value", key.value } - }; - list.Add(valueDict); - } - - var observedDict = new Dictionary>>(); - observedDict.Add("observed", list); - output.Add(idShort, observedDict); - - return output; - } - } - - } -} diff --git a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/Resource.cs b/src/AasxServerStandardBib/AasxCompatibilityModels/V30/Resource.cs deleted file mode 100644 index 4a4c6bad4..000000000 --- a/src/AasxServerStandardBib/AasxCompatibilityModels/V30/Resource.cs +++ /dev/null @@ -1,114 +0,0 @@ -/* - This class has beed added with respect to the specifications "Details of Asset Administration Shell Part 1 V3RC02" published on 30.05.2022 - - */ - - -//namespace AdminShellNS -using static AdminShell_V30.AdminShellV30; - -namespace AdminShell_V30 -{ - public class Resource - { - - [MetaModelName("Resource.path")] - [TextSearchable] - [CountForHash] - public string path = ""; - - [MetaModelName("Resource.contentType")] - [TextSearchable] - [CountForHash] - public string contentType = ""; - - //Default Constructor - public Resource() - { - } - - public Resource(Resource src) - { - if (src == null) - return; - - path = src.path; - contentType = src.contentType; - } - - - - public Resource(string path, string contentType) - { - this.path = path; - this.contentType = contentType; - } - - /// - /// 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((Resource)obj); - } - - /// - /// Returns true if Resource instances are equal - /// - /// Instance of Resource to be compared - /// Boolean - public bool Equals(Resource other) - { - if (ReferenceEquals(null, other)) return false; - if (ReferenceEquals(this, other)) return true; - - return - ( - path == other.path || - path != null && - path.Equals(other.path) - ) && - ( - contentType == other.contentType || - contentType != null && - contentType.Equals(other.contentType) - ); - } - - /// - /// 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 (path != null) - hashCode = hashCode * 59 + path.GetHashCode(); - if (contentType != null) - hashCode = hashCode * 59 + contentType.GetHashCode(); - return hashCode; - } - } - - #region Operators - - public static bool operator ==(Resource left, Resource right) - { - return Equals(left, right); - } - - public static bool operator !=(Resource left, Resource right) - { - return !Equals(left, right); - } - - #endregion Operators - } -} diff --git a/src/AasxServerStandardBib/AasxHttpContextHelper.cs b/src/AasxServerStandardBib/AasxHttpContextHelper.cs index 24cff2754..57a35412c 100644 --- a/src/AasxServerStandardBib/AasxHttpContextHelper.cs +++ b/src/AasxServerStandardBib/AasxHttpContextHelper.cs @@ -1,40 +1,33 @@ -using System; -using System.Collections.Generic; -using System.Dynamic; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Net.Http; -using System.Net; -using System.Reflection; -using System.Security.Cryptography; -using System.Security.Cryptography.X509Certificates; -using System.Security.Permissions; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading; -using System.Threading.Tasks; -using AasCore.Aas3_0_RC02; +using AasCore.Aas3_0_RC02; using AasxServer; using AdminShellNS; -using Extenstions; +using Extensions; using Grapevine.Interfaces.Server; using Grapevine.Server; using Grapevine.Server.Attributes; using Grapevine.Shared; using Jose; -using Jose.jwe; -using Jose.netstandard1_4; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; -using HttpStatusCode = Grapevine.Shared.HttpStatusCode; +using System; +using System.Collections.Generic; using System.Collections.Specialized; -using JetBrains.Annotations; using System.Data; -using Opc.Ua; +using System.Dynamic; +using System.Globalization; +using System.IO; +using System.Linq; +using System.Net; +using System.Net.Http; +using System.Reflection; +using System.Security.Cryptography; +using System.Security.Cryptography.X509Certificates; +using System.Text; using System.Text.Json.Nodes; -using Namotion.Reflection; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using HttpStatusCode = Grapevine.Shared.HttpStatusCode; /* Copyright (c) 2018-2019 Festo AG & Co. KG , author: Michael Hoffmeister diff --git a/src/AasxServerStandardBib/AasxRestClient.cs b/src/AasxServerStandardBib/AasxRestClient.cs index 711d7f48e..84358afc0 100644 --- a/src/AasxServerStandardBib/AasxRestClient.cs +++ b/src/AasxServerStandardBib/AasxRestClient.cs @@ -1,18 +1,12 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Net; -using System.Text; -using System.Threading.Tasks; -using AasCore.Aas3_0_RC02; +using AasCore.Aas3_0_RC02; using AasxIntegrationBase; using AdminShellNS; -using Extenstions; -using Grapevine; +using Extensions; using Grapevine.Client; -using Grapevine.Shared; using Newtonsoft.Json.Linq; +using System; +using System.IO; +using System.Net; namespace AasxRestServerLibrary { diff --git a/src/AasxServerStandardBib/AasxRestServer.cs b/src/AasxServerStandardBib/AasxRestServer.cs index 93e1bc881..df7114388 100644 --- a/src/AasxServerStandardBib/AasxRestServer.cs +++ b/src/AasxServerStandardBib/AasxRestServer.cs @@ -4,7 +4,7 @@ using AasxMqttClient; using AdminShellEvents; using AdminShellNS; -using Extenstions; +using Extensions; using Grapevine.Interfaces.Server; using Grapevine.Server; using Grapevine.Server.Attributes; @@ -689,12 +689,12 @@ public static string runQueryRegistryOnly(string query, string restPayload, Subm result += " " + f.Value; if (sme is MultiLanguageProperty mlp) { - if (mlp.Value != null && mlp.Value.LangStrings != null) + if (mlp.Value != null && mlp.Value != null) { - for (int iMlp = 0; iMlp < mlp.Value.LangStrings.Count; iMlp++) + for (int iMlp = 0; iMlp < mlp.Value.Count; iMlp++) { - result += " [" + mlp.Value.LangStrings[iMlp].Language + "]" + - mlp.Value.LangStrings[iMlp].Text; + result += " [" + mlp.Value[iMlp].Language + "]" + + mlp.Value[iMlp].Text; } } @@ -1319,12 +1319,12 @@ public static string runQuery(string query, string restPayload) result += " " + f.Value; if (sme is MultiLanguageProperty mlp) { - if (mlp.Value != null && mlp.Value.LangStrings != null) + if (mlp.Value != null && mlp.Value != null) { - for (int iMlp = 0; iMlp < mlp.Value.LangStrings.Count; iMlp++) + for (int iMlp = 0; iMlp < mlp.Value.Count; iMlp++) { - result += " [" + mlp.Value.LangStrings[iMlp].Language + "]" + - mlp.Value.LangStrings[iMlp].Text; + result += " [" + mlp.Value[iMlp].Language + "]" + + mlp.Value[iMlp].Text; } } diff --git a/src/AasxServerStandardBib/AasxServerStandardBib.csproj b/src/AasxServerStandardBib/AasxServerStandardBib.csproj index 12384e191..b227e65a6 100644 --- a/src/AasxServerStandardBib/AasxServerStandardBib.csproj +++ b/src/AasxServerStandardBib/AasxServerStandardBib.csproj @@ -16,31 +16,28 @@ - - - - + Always + - PreserveNewest diff --git a/src/AasxServerStandardBib/AdminShellUtil.cs.bak b/src/AasxServerStandardBib/AdminShellUtil.cs.bak deleted file mode 100644 index 586cfc3e6..000000000 --- a/src/AasxServerStandardBib/AdminShellUtil.cs.bak +++ /dev/null @@ -1,328 +0,0 @@ -using System; -using System.Collections; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; - -namespace AdminShellNS -{ - public static class AdminShellUtil - { - public static string EvalToNonNullString(string fmt, object o, string elseString = "") - { - if (o == null) - return elseString; - return string.Format(fmt, o); - } - - public static string EvalToNonEmptyString(string fmt, string o, string elseString = "") - { - if (o == "") - return elseString; - return string.Format(fmt, o); - } - - public static string FilterFriendlyName(string src) - { - if (src == null) - return null; - return Regex.Replace(src, @"[^a-zA-Z0-9\-_]", "_"); - } - - public static bool HasWhitespace(string src) - { - if (src == null) - throw new ArgumentNullException(nameof(src)); - foreach (var s in src) - if (char.IsWhiteSpace(s)) - return true; - return false; - } - - public static bool ComplyIdShort(string src) - { - if (src == null) - throw new ArgumentNullException(nameof(src)); - var res = true; - foreach (var s in src) - if (!Char.IsLetterOrDigit(s) && s != '_') - res = false; - if (src.Length > 0 && !Char.IsLetter(src[0])) - res = false; - return res; - } - - public static string ShortLocation(Exception ex) - { - if (ex == null || ex.StackTrace == null) - return ""; - string[] lines = ex.StackTrace.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.None); - if (lines.Length < 1) - return ""; - // search for " in " - // as the most actual stacktrace might be a built-in function, this might not work and therefore - // go down in the stack - int currLine = 0; - while (true) - { - // nothing found at all - if (currLine >= lines.Length) - return ""; - // access current line - var p = lines[currLine].IndexOf(" in ", StringComparison.Ordinal); - if (p < 0) - { - // advance to next oldest line - currLine++; - continue; - } - // search last "\" or "/", to get only filename portion and position - p = lines[currLine].LastIndexOfAny(new[] { '\\', '/' }); - if (p < 0) - { - // advance to next oldest line - currLine++; - continue; - } - // return this - return lines[currLine].Substring(p); - } - } - - // - // - // - // - // - - public static void PrintSearchableProperties(object obj, int indent) - { - if (obj == null) return; - string indentString = new string(' ', indent); - Type objType = obj.GetType(); - PropertyInfo[] properties = objType.GetProperties(); - foreach (PropertyInfo property in properties) - { - object propValue = property.GetValue(obj, null); - var elems = propValue as IList; - if (elems != null) - { - foreach (var item in elems) - { - PrintSearchableProperties(item, indent + 3); - } - } - else - { - // This will not cut-off System.Collections because of the first check - if (property.PropertyType.Assembly == objType.Assembly) - { - Console.WriteLine("{0}{1}:", indentString, property.Name); - - PrintSearchableProperties(propValue, indent + 2); - } - else - { - Console.WriteLine("{0}{1}: {2}", indentString, property.Name, propValue); - } - } - } - - } - - public class SearchOptions - { - public Assembly[] allowedAssemblies = null; - public int maxDepth = int.MaxValue; - public bool findFirst = false; - public int skipFirstResults = 0; - public string findText = null; - public bool isIgnoreCase = false; - public bool isRegex = false; - } - - public class SearchResultItem : IEquatable - { - public SearchOptions searchOptions; - public string qualifiedNameHead; - public string metaModelName; - public object businessObject; - public string foundText; - public object foundObject; - public object containingObject; - public int foundHash; - - public bool Equals(SearchResultItem other) - { - if (other == null) - return false; - - return this.qualifiedNameHead == other.qualifiedNameHead && - this.metaModelName == other.metaModelName && - this.businessObject == other.businessObject && - this.containingObject == other.containingObject && - this.foundText == other.foundText && - this.foundHash == other.foundHash; - } - } - - public class SearchResults - { - public int foundIndex = 0; - public List foundResults = new List(); - - public void Clear() - { - foundIndex = -1; - foundResults.Clear(); - } - } - - public static void CheckSearchable(SearchResults results, SearchOptions options, string qualifiedNameHead, object businessObject, - MemberInfo mi, object memberValue, object containingObject, Func getMemberHash) - { - // try get a speaking name - var metaModelName = ""; - var x1 = mi.GetCustomAttribute(); - if (x1 != null && x1.name != null) - metaModelName = x1.name; - - // check if this object is searchable - var x2 = mi.GetCustomAttribute(); - if (x2 != null) - { - // what to check? - string foundText = "" + memberValue?.ToString(); - - // find options - var found = true; - if (options.findText != null) - found = foundText.IndexOf(options.findText, options.isIgnoreCase ? StringComparison.CurrentCultureIgnoreCase : 0) >= 0; - - // add? - if (found) - { - var sri = new SearchResultItem(); - sri.searchOptions = options; - sri.qualifiedNameHead = qualifiedNameHead; - sri.metaModelName = metaModelName; - sri.businessObject = businessObject; - sri.foundText = foundText; - sri.foundObject = memberValue; - sri.containingObject = containingObject; - if (getMemberHash != null) - sri.foundHash = getMemberHash(); - - // avoid duplicates - if (!results.foundResults.Contains(sri)) - results.foundResults.Add(sri); - } - } - } - - public static void EnumerateSearchable(SearchResults results, object obj, string qualifiedNameHead, int depth, SearchOptions options, object businessObject = null) - { - // access - if (results == null || obj == null || options == null) - return; - Type objType = obj.GetType(); - - // depth - if (depth > options.maxDepth) - return; - - // try to get element name of an AAS entity - string elName = null; - if (obj is IReferable) - { - elName = (obj as IReferable).GetElementName(); - businessObject = obj; - } - - // enrich qualified name, accordingly - var qualifiedName = qualifiedNameHead; - if (elName != null) - qualifiedName = qualifiedName + (qualifiedName.Length > 0 ? "." : "") + elName; - - // do NOT dive into objects, which are not in the reight assembly - if (options.allowedAssemblies == null || !options.allowedAssemblies.Contains(objType.Assembly)) - return; - - // look at fields, first - var fields = objType.GetFields(); - foreach (var fi in fields) - { - // is the object marked to be skipped? - var x3 = fi.GetCustomAttribute(); - if (x3 != null) - continue; - - var x4 = fi.GetCustomAttribute(); - if (x4 != null) - continue; - - // get value(s) - var fieldValue = fi.GetValue(obj); - if (fieldValue == null) - continue; - var valueElems = fieldValue as IList; - if (valueElems != null) - { - // field is a collection .. dive deeper, if allowed - foreach (var el in valueElems) - EnumerateSearchable(results, el, qualifiedName, depth + 1, options, businessObject); - } - else - { - // field is a single entity .. check it - CheckSearchable(results, options, qualifiedName, businessObject, fi, fieldValue, obj, () => { return fieldValue.GetHashCode(); }); - - // dive deeper .. - EnumerateSearchable(results, fieldValue, qualifiedName, depth + 1, options, businessObject); - } - } - - // properties & objects behind - var properties = objType.GetProperties(); - foreach (var pi in properties) - { - var gip = pi.GetIndexParameters(); - if (gip.Length > 0) - // no indexed properties, yet - continue; - - // is the object marked to be skipped? - var x3 = pi.GetCustomAttribute(); - if (x3 != null) - continue; - - var x4 = pi.GetCustomAttribute(); - if (x4 != null) - continue; - - // get value(s) - var propValue = pi.GetValue(obj, null); - if (propValue == null) - continue; - var valueElems = propValue as IList; - if (valueElems != null) - { - // property is a collection .. dive deeper, if allowed - foreach (var el in valueElems) - EnumerateSearchable(results, el, qualifiedName, depth + 1, options, businessObject); - } - else - { - // field is a single entity .. check it - CheckSearchable(results, options, qualifiedName, businessObject, pi, propValue, obj, () => { return propValue.GetHashCode(); }); - - // dive deeper .. - EnumerateSearchable(results, propValue, qualifiedName, depth + 1, options, businessObject); - } - } - } - } -} diff --git a/src/AasxServerStandardBib/EnergyModel.cs b/src/AasxServerStandardBib/EnergyModel.cs index 9833914bf..56e7caa49 100644 --- a/src/AasxServerStandardBib/EnergyModel.cs +++ b/src/AasxServerStandardBib/EnergyModel.cs @@ -1,21 +1,13 @@ -using System; +using AasCore.Aas3_0_RC02; +using AasxTimeSeries; +using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; using System.Text; using System.Threading; -using AasCore.Aas3_0_RC02; -using AasxServer; -using AasxTimeSeries; -using AdminShellNS; -using Extenstions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Opc.Ua; -using SampleClient; +using Extensions; namespace AasxDemonstration { diff --git a/src/AasxServerStandardBib/Exceptions/DuplicateException.cs b/src/AasxServerStandardBib/Exceptions/DuplicateException.cs index 1e8dfd4af..d6d263440 100644 --- a/src/AasxServerStandardBib/Exceptions/DuplicateException.cs +++ b/src/AasxServerStandardBib/Exceptions/DuplicateException.cs @@ -1,8 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace AasxServerStandardBib.Exceptions { diff --git a/src/AasxServerStandardBib/Extensions/ExtendServiceCollection.cs b/src/AasxServerStandardBib/Extensions/ExtendServiceCollection.cs new file mode 100644 index 000000000..f054e2598 --- /dev/null +++ b/src/AasxServerStandardBib/Extensions/ExtendServiceCollection.cs @@ -0,0 +1,23 @@ +using Microsoft.Extensions.DependencyInjection; +using System; + +namespace AasxServerStandardBib.Extensions +{ + public static class ExtendServiceCollection + { + public static IServiceCollection AddLazyResolution(this IServiceCollection services) + { + return services.AddTransient( + typeof(Lazy<>), + typeof(LazilyResolved<>)); + } + + private class LazilyResolved : Lazy + { + public LazilyResolved(IServiceProvider serviceProvider) + : base(serviceProvider.GetRequiredService) + { + } + } + } +} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendAnnotedRelationshipElement.cs b/src/AasxServerStandardBib/Extenstions/ExtendAnnotedRelationshipElement.cs deleted file mode 100644 index 07031bf73..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendAnnotedRelationshipElement.cs +++ /dev/null @@ -1,51 +0,0 @@ -using AasCore.Aas3_0_RC02; -using Extenstions; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AasxServerStandardBib.Extenstions -{ - public static class ExtendAnnotedRelationshipElement - { - public static AnnotatedRelationshipElement ConvertAnnotationsFromV20(this AnnotatedRelationshipElement annotatedRelationshipElement, AasxCompatibilityModels.AdminShellV20.AnnotatedRelationshipElement sourceAnnotedRelElement) - { - if (sourceAnnotedRelElement == null) - { - return null; - } - - if (sourceAnnotedRelElement.annotations != null) - { - annotatedRelationshipElement.Annotations ??= new List(); - foreach (var submodelElementWrapper in sourceAnnotedRelElement.annotations) - { - var sourceSubmodelElement = submodelElementWrapper.submodelElement; - ISubmodelElement outputSubmodelElement = null; - if (sourceSubmodelElement != null) - { - outputSubmodelElement = outputSubmodelElement.ConvertFromV20(sourceSubmodelElement); - } - annotatedRelationshipElement.Annotations.Add((IDataElement)outputSubmodelElement); - } - } - - return annotatedRelationshipElement; - } - - public static T FindFirstIdShortAs(this AnnotatedRelationshipElement annotedRelationshipElement, string idShort) where T : ISubmodelElement - { - - var submodelElements = annotedRelationshipElement.Annotations.Where(sme => (sme != null) && (sme is T) && sme.IdShort.Equals(idShort, StringComparison.OrdinalIgnoreCase)); - - if (submodelElements.Any()) - { - return (T)submodelElements.First(); - } - - return default; - } - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendBlob.cs b/src/AasxServerStandardBib/Extenstions/ExtendBlob.cs deleted file mode 100644 index bf8394351..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendBlob.cs +++ /dev/null @@ -1,26 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Extenstions -{ - public static class ExtendBlob - { - public static Blob ConvertFromV10(this Blob blob, AasxCompatibilityModels.AdminShellV10.Blob sourceBlob) - { - blob.ContentType = sourceBlob.mimeType; - blob.Value = Encoding.ASCII.GetBytes(sourceBlob.value); - return blob; - } - - public static Blob ConvertFromV20(this Blob blob, AasxCompatibilityModels.AdminShellV20.Blob sourceBlob) - { - blob.ContentType = sourceBlob.mimeType; - blob.Value = Encoding.ASCII.GetBytes(sourceBlob.value); - return blob; - } - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendConceptDescription.cs b/src/AasxServerStandardBib/Extenstions/ExtendConceptDescription.cs deleted file mode 100644 index 2f4b72cfa..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendConceptDescription.cs +++ /dev/null @@ -1,100 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Extenstions -{ - public static class ExtendConceptDescription - { - public static ConceptDescription ConvertFromV10(this ConceptDescription conceptDescription, AasxCompatibilityModels.AdminShellV10.ConceptDescription sourceConceptDescription) - { - if (sourceConceptDescription == null) - { - return null; - } - - if (string.IsNullOrEmpty(sourceConceptDescription.idShort)) - { - conceptDescription.IdShort = ""; - } - else - { - conceptDescription.IdShort = sourceConceptDescription.idShort; - } - - if (sourceConceptDescription.description != null) - { - conceptDescription.Description = ExtensionsUtil.ConvertDescriptionFromV10(sourceConceptDescription.description); - } - - if (sourceConceptDescription.administration != null) - { - conceptDescription.Administration = new AdministrativeInformation(version: sourceConceptDescription.administration.version, revision: sourceConceptDescription.administration.revision); - } - - if (sourceConceptDescription.IsCaseOf != null && sourceConceptDescription.IsCaseOf.Count != 0) - { - if (conceptDescription.IsCaseOf == null) - { - conceptDescription.IsCaseOf = new List(); - } - foreach (var caseOf in sourceConceptDescription.IsCaseOf) - { - conceptDescription.IsCaseOf.Add(ExtensionsUtil.ConvertReferenceFromV10(caseOf, ReferenceTypes.ModelReference)); - } - } - - return conceptDescription; - } - - public static ConceptDescription ConvertFromV20(this ConceptDescription conceptDescription, AasxCompatibilityModels.AdminShellV20.ConceptDescription sourceConceptDescription) - { - if (sourceConceptDescription == null) - { - return null; - } - - if (string.IsNullOrEmpty(sourceConceptDescription.idShort)) - { - conceptDescription.IdShort = ""; - } - else - { - conceptDescription.IdShort = sourceConceptDescription.idShort; - } - - if (sourceConceptDescription.description != null) - { - conceptDescription.Description = ExtensionsUtil.ConvertDescriptionFromV20(sourceConceptDescription.description); - } - - if (sourceConceptDescription.administration != null) - { - conceptDescription.Administration = new AdministrativeInformation(version: sourceConceptDescription.administration.version, revision: sourceConceptDescription.administration.revision); - } - - if (sourceConceptDescription.IsCaseOf != null && sourceConceptDescription.IsCaseOf.Count != 0) - { - if (conceptDescription.IsCaseOf == null) - { - conceptDescription.IsCaseOf = new List(); - } - foreach (var caseOf in sourceConceptDescription.IsCaseOf) - { - conceptDescription.IsCaseOf.Add(ExtensionsUtil.ConvertReferenceFromV20(caseOf, ReferenceTypes.ModelReference)); - } - } - - return conceptDescription; - } - - public static Reference GetCdReference(this ConceptDescription conceptDescription) - { - var key = new Key(KeyTypes.ConceptDescription, conceptDescription.Id); - return new Reference(ReferenceTypes.ModelReference, new List { key }); - } - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendEnvironment.cs b/src/AasxServerStandardBib/Extenstions/ExtendEnvironment.cs deleted file mode 100644 index 08cebf85f..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendEnvironment.cs +++ /dev/null @@ -1,519 +0,0 @@ -using AasCore.Aas3_0_RC02; -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace Extenstions -{ - public static class ExtendEnvironment - { - #region Environment - -#if !DoNotUseAasxCompatibilityModels - - public static AasCore.Aas3_0_RC02.Environment ConvertFromV10(this AasCore.Aas3_0_RC02.Environment environment, AasxCompatibilityModels.AdminShellV10.AdministrationShellEnv sourceEnvironement) - { - //Convert Administration Shells - if (sourceEnvironement.AdministrationShells != null) - { - if (environment.AssetAdministrationShells == null) - { - environment.AssetAdministrationShells = new List(); - } - foreach (var sourceAas in sourceEnvironement.AdministrationShells) - { - var sourceAsset = sourceEnvironement?.FindAsset(sourceAas.assetRef); - if (sourceAsset != null) - { - var newAssetInformation = new AssetInformation(AssetKind.Instance); - newAssetInformation = newAssetInformation.ConvertFromV10(sourceAsset); - - var newAas = new AssetAdministrationShell(id: sourceAas.identification.id, newAssetInformation); - newAas = newAas.ConvertFromV10(sourceAas); - - environment.AssetAdministrationShells.Add(newAas); - } - - } - } - - //Convert Submodels - if (sourceEnvironement.Submodels != null) - { - if (environment.Submodels == null) - { - environment.Submodels = new List(); - } - foreach (var sourceSubmodel in sourceEnvironement.Submodels) - { - var newSubmodel = new Submodel(sourceSubmodel.identification.id); - newSubmodel = newSubmodel.ConvertFromV10(sourceSubmodel); - environment.Submodels.Add(newSubmodel); - } - } - - if (sourceEnvironement.ConceptDescriptions != null) - { - if (environment.ConceptDescriptions == null) - { - environment.ConceptDescriptions = new List(); - } - foreach (var sourceConceptDescription in sourceEnvironement.ConceptDescriptions) - { - var newConceptDescription = new ConceptDescription(sourceConceptDescription.identification.id); - newConceptDescription = newConceptDescription.ConvertFromV10(sourceConceptDescription); - environment.ConceptDescriptions.Add(newConceptDescription); - } - } - - return environment; - } - - - public static AasCore.Aas3_0_RC02.Environment ConvertFromV20(this AasCore.Aas3_0_RC02.Environment environment, AasxCompatibilityModels.AdminShellV20.AdministrationShellEnv sourceEnvironement) - { - //Convert Administration Shells - if (sourceEnvironement.AdministrationShells != null) - { - if (environment.AssetAdministrationShells == null) - { - environment.AssetAdministrationShells = new List(); - } - foreach (var sourceAas in sourceEnvironement.AdministrationShells) - { - var sourceAsset = sourceEnvironement?.FindAsset(sourceAas.assetRef); - if (sourceAsset != null) - { - var newAssetInformation = new AssetInformation(AssetKind.Instance); - newAssetInformation = newAssetInformation.ConvertFromV20(sourceAsset); - - var newAas = new AssetAdministrationShell(id: sourceAas.identification.id, newAssetInformation); - newAas = newAas.ConvertFromV20(sourceAas); - - environment.AssetAdministrationShells.Add(newAas); - } - - } - } - - //Convert Submodels - if (sourceEnvironement.Submodels != null) - { - if (environment.Submodels == null) - { - environment.Submodels = new List(); - } - foreach (var sourceSubmodel in sourceEnvironement.Submodels) - { - var newSubmodel = new Submodel(sourceSubmodel.identification.id); - newSubmodel = newSubmodel.ConvertFromV20(sourceSubmodel); - environment.Submodels.Add(newSubmodel); - } - } - - if (sourceEnvironement.ConceptDescriptions != null) - { - if (environment.ConceptDescriptions == null) - { - environment.ConceptDescriptions = new List(); - } - foreach (var sourceConceptDescription in sourceEnvironement.ConceptDescriptions) - { - var newConceptDescription = new ConceptDescription(sourceConceptDescription.identification.id); - newConceptDescription = newConceptDescription.ConvertFromV20(sourceConceptDescription); - environment.ConceptDescriptions.Add(newConceptDescription); - } - } - - return environment; - } - -#endif - - //TODO:jtikekar to test - public static AasCore.Aas3_0_RC02.Environment CreateFromExistingEnvironment(this AasCore.Aas3_0_RC02.Environment environment, AasCore.Aas3_0_RC02.Environment sourceEnvironment, List filterForAas = null, List filterForAssets = null, List filterForSubmodel = null, List filterForConceptDescriptions = null) - { - if (filterForAas == null) - { - filterForAas = new List(); - } - - if (filterForAssets == null) - { - filterForAssets = new List(); - } - - if (filterForSubmodel == null) - { - filterForSubmodel = new List(); - } - - if (filterForConceptDescriptions == null) - { - filterForConceptDescriptions = new List(); - } - - //var outputEnvironment = new AasCore.Aas3_0_RC02.Environment(); - - //Copy AssetAdministrationShells - foreach (var aas in sourceEnvironment.AssetAdministrationShells) - { - if (filterForAas.Contains(aas)) - { - environment.AssetAdministrationShells.Add(aas); - - if (aas.Submodels != null && aas.Submodels.Count > 0) - { - foreach (var submodelReference in aas.Submodels) - { - var submodel = sourceEnvironment.FindSubmodel(submodelReference); - if (submodel != null) - { - filterForSubmodel.Add(submodel); - } - } - } - } - } - - //Copy Submodel - foreach (var submodel in sourceEnvironment.Submodels) - { - if (filterForSubmodel.Contains(submodel)) - { - environment.Submodels.Add(submodel); - - //Find Used CDs - environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, submodel.SubmodelElements, ref filterForConceptDescriptions); - } - } - - //Copy ConceptDescription - foreach (var conceptDescription in sourceEnvironment.ConceptDescriptions) - { - if (filterForConceptDescriptions.Contains(conceptDescription)) - { - environment.ConceptDescriptions.Add(conceptDescription); - } - } - - return environment; - - } - - public static void CreateFromExistingEnvRecurseForCDs(this AasCore.Aas3_0_RC02.Environment environment, AasCore.Aas3_0_RC02.Environment sourceEnvironment, List submodelElements, ref List filterForConceptDescription) - { - if (submodelElements == null || submodelElements.Count == 0 || filterForConceptDescription == null || filterForConceptDescription.Count == 0) - { - return; - } - - foreach (var submodelElement in submodelElements) - { - if (submodelElement == null) - { - return; - } - - if (submodelElement.SemanticId != null) - { - var conceptDescription = sourceEnvironment.FindConceptDescriptionByReference(submodelElement.SemanticId); - if (conceptDescription != null) - { - filterForConceptDescription.Add(conceptDescription); - } - } - - if (submodelElement is SubmodelElementCollection smeColl) - { - environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, smeColl.Value, ref filterForConceptDescription); - } - - if (submodelElement is SubmodelElementList smeList) - { - environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, smeList.Value, ref filterForConceptDescription); - } - - if (submodelElement is Entity entity) - { - environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, entity.Statements, ref filterForConceptDescription); - } - - if (submodelElement is AnnotatedRelationshipElement annotatedRelationshipElement) - { - var annotedELements = new List(); - foreach (var annotation in annotatedRelationshipElement.Annotations) - { - annotedELements.Add(annotation); - } - environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, annotedELements, ref filterForConceptDescription); - } - - if (submodelElement is Operation operation) - { - var operationELements = new List(); - foreach (var inputVariable in operation.InputVariables) - { - operationELements.Add(inputVariable.Value); - } - - foreach (var outputVariable in operation.OutputVariables) - { - operationELements.Add(outputVariable.Value); - } - - foreach (var inOutVariable in operation.InoutputVariables) - { - operationELements.Add(inOutVariable.Value); - } - - environment.CreateFromExistingEnvRecurseForCDs(sourceEnvironment, operationELements, ref filterForConceptDescription); - - } - } - } - - public static JsonWriter SerialiazeJsonToStream(this AasCore.Aas3_0_RC02.Environment environment, StreamWriter streamWriter, bool leaveJsonWriterOpen = false) - { - streamWriter.AutoFlush = true; - - JsonSerializer serializer = new JsonSerializer() - { - NullValueHandling = NullValueHandling.Ignore, - ReferenceLoopHandling = ReferenceLoopHandling.Serialize, - Formatting = Newtonsoft.Json.Formatting.Indented - }; - - JsonWriter writer = new JsonTextWriter(streamWriter); - serializer.Serialize(writer, environment); - if (leaveJsonWriterOpen) - return writer; - writer.Close(); - return null; - } - - - #endregion - - #region Submodel Queries - public static Submodel FindSubmodel(this AasCore.Aas3_0_RC02.Environment environment, Reference submodelReference) - { - if (submodelReference == null) - { - return null; - } - - if (submodelReference.Keys.Count != 1) // Can have only one reference key - { - return null; - } - - var key = submodelReference.Keys[0]; - if (key.Type != KeyTypes.Submodel) - { - return null; - } - - var submodels = environment.Submodels.Where(s => s.Id.Equals(key.Value, StringComparison.OrdinalIgnoreCase)); - if (submodels.Any()) - { - return submodels.First(); - } - - return null; - } - - public static Submodel FindSubmodelById(this AasCore.Aas3_0_RC02.Environment environment, string submodelId) - { - if (string.IsNullOrEmpty(submodelId)) - { - return null; - } - - var submodels = environment.Submodels.Where(s => s.Id.Equals(submodelId)); - if (submodels.Any()) - { - return submodels.First(); - } - - return null; - } - - public static IEnumerable FindAllSubmodelsGroupedByAAS(this AasCore.Aas3_0_RC02.Environment environment, Func p = null) - { - if (environment.AssetAdministrationShells == null || environment.Submodels == null) - yield break; - foreach (var aas in environment.AssetAdministrationShells) - { - if (aas?.Submodels == null) - continue; - foreach (var submodelReference in aas.Submodels) - { - var submodel = environment.FindSubmodel(submodelReference); - if (submodel != null && (p == null || p(aas, submodel))) - yield return submodel; - } - } - } - - public static IEnumerable FindAllSubmodelBySemanticId(this AasCore.Aas3_0_RC02.Environment environment, string semanticId) - { - if (semanticId == null) - yield break; - - foreach (var submodel in environment.Submodels) - if (true == submodel.SemanticId?.Matches(semanticId)) - yield return submodel; - } - - #endregion - - #region AssetAdministrationShell Queries - public static AssetAdministrationShell FindAasWithSubmodelId(this AasCore.Aas3_0_RC02.Environment environment, string submodelId) - { - if (submodelId == null) - { - return null; - } - - var aas = environment.AssetAdministrationShells.Where(a => (a.Submodels?.Where(s => s.Matches(submodelId)).First()) != null).First(); - - return aas; - } - - public static AssetAdministrationShell FindAasById(this AasCore.Aas3_0_RC02.Environment environment, string aasId) - { - if (string.IsNullOrEmpty(aasId)) - { - return null; - } - - var aasList = environment.AssetAdministrationShells.Where(a => a.Id.Equals(aasId)); - if(aasList.Any()) - { - return aasList.First(); - } - - return null; - } - - #endregion - - #region ConceptDescription Queries - - public static ConceptDescription FindConceptDescriptionById(this AasCore.Aas3_0_RC02.Environment environment, string conceptDescriptionId) - { - if (string.IsNullOrEmpty(conceptDescriptionId)) - { - return null; - } - - var conceptDescriptionList = environment.ConceptDescriptions.Where(c => c.Id.Equals(conceptDescriptionId)); - if(conceptDescriptionList.Any()) - { - return conceptDescriptionList.First(); - } - - return null; - } - - public static ConceptDescription FindConceptDescriptionByReference(this AasCore.Aas3_0_RC02.Environment environment, Reference reference) - { - if (reference == null) - { - return null; - } - - return environment.FindConceptDescriptionById(reference.GetAsIdentifier()); - } - - #endregion - - #region Referable Queries - - //TODO: jtikekar Need to test - public static IReferable FindReferableByReference(this AasCore.Aas3_0_RC02.Environment environment, Reference reference, int keyIndex = 0, List submodelElementList = null) - { - var keyList = reference.Keys; - - if (keyList == null || keyList.Count == 0) - { - return null; - } - - var firstKeyType = keyList[keyIndex].Type; - var firstKeyId = keyList[keyIndex].Value; - - switch (firstKeyType) - { - case KeyTypes.AssetAdministrationShell: - { - var aas = environment.FindAasById(firstKeyId); - - //Not found or already at the end of our search - if (aas == null || keyIndex >= keyList.Count - 1) - { - return aas; - } - - return environment.FindReferableByReference(reference, ++keyIndex); - - } - - case KeyTypes.ConceptDescription: - { - return environment.FindConceptDescriptionById(firstKeyId); - } - - case KeyTypes.Submodel: - { - var submodel = environment.FindSubmodelById(firstKeyId); - if (submodel == null || keyIndex >= keyList.Count - 1) - { - return submodel; - } - - return environment.FindReferableByReference(reference, ++keyIndex, submodel.SubmodelElements); - } - case KeyTypes.SubmodelElementCollection: - case KeyTypes.Property: - case KeyTypes.SubmodelElement: - { - if (submodelElementList != null) - { - var submodelElement = submodelElementList.Where(sme => sme.IdShort.Equals(keyList[keyIndex].Value, StringComparison.OrdinalIgnoreCase)).First(); - - //This is required element - if (keyIndex + 1 >= keyList.Count) - { - return submodelElement; - } - - //Recurse again - if (submodelElement != null && submodelElement is SubmodelElementCollection smeColl) - { - return environment.FindReferableByReference(reference, ++keyIndex, smeColl.Value); - } - - if (submodelElement != null && submodelElement is SubmodelElementList smeList) - { - return environment.FindReferableByReference(reference, ++keyIndex, smeList.Value); - } - } - break; - } - } - - //Nothing in this environment - return null; - - } - - #endregion - - - - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendFile.cs b/src/AasxServerStandardBib/Extenstions/ExtendFile.cs deleted file mode 100644 index 8c993b9c8..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendFile.cs +++ /dev/null @@ -1,30 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Extenstions -{ - public static class ExtendFile - { - public static string ValueAsText(this File file) - { - return "" + file.Value; - } - - public static File ConvertFromV10(this File file, AasxCompatibilityModels.AdminShellV10.File sourceFile) - { - file.ContentType = sourceFile.mimeType; - file.Value = sourceFile.value; - return file; - } - public static File ConvertFromV20(this File file, AasxCompatibilityModels.AdminShellV20.File sourceFile) - { - file.ContentType = sourceFile.mimeType; - file.Value = sourceFile.value; - return file; - } - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendIReferable.cs b/src/AasxServerStandardBib/Extenstions/ExtendIReferable.cs deleted file mode 100644 index 45786760b..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendIReferable.cs +++ /dev/null @@ -1,144 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Extenstions -{ - public static class ExtendIReferable - { - public static void SetTimeStamp(this IReferable referable, DateTime timeStamp) - { - IReferable newReferable = referable; - newReferable.TimeStamp = timeStamp; - do - { - newReferable.TimeStampTree = timeStamp; - if (newReferable != newReferable.Parent) - { - newReferable = (IReferable)newReferable.Parent; - } - else - newReferable = null; - } - while (newReferable != null); - } - - public static IEnumerable EnumerateChildren(this IReferable referable) - { - if (referable is Submodel submodel && submodel.SubmodelElements != null) - { - if (submodel.SubmodelElements != null) - { - foreach (var submodelElement in submodel.SubmodelElements) - { - yield return submodelElement; - } - } - } - else if (referable is SubmodelElementCollection submodelElementCollection) - { - if (submodelElementCollection.Value != null) - { - foreach (var submodelElement in submodelElementCollection.Value) - { - yield return submodelElement; - } - } - } - else if (referable is SubmodelElementList submodelElementList) - { - if (submodelElementList.Value != null) - { - foreach (var submodelElement in submodelElementList.Value) - { - yield return submodelElement; - } - } - } - else if (referable is AnnotatedRelationshipElement annotatedRelationshipElement) - { - if (annotatedRelationshipElement.Annotations != null) - { - foreach (var submodelElement in annotatedRelationshipElement.Annotations) - { - yield return submodelElement; - } - } - } - else if (referable is Entity entity) - { - if (entity.Statements != null) - { - foreach (var submodelElement in entity.Statements) - { - yield return submodelElement; - } - } - } - else if (referable is Operation operation) - { - foreach (var inputVariable in operation.InputVariables) - { - yield return inputVariable.Value; - } - - foreach (var outputVariable in operation.OutputVariables) - { - yield return outputVariable.Value; - } - - foreach (var inOutVariable in operation.InoutputVariables) - { - yield return inOutVariable.Value; - } - } - else - { - yield break; - } - } - - - public static void SetAllParentsAndTimestamps(this IReferable referable, IReferable parent, DateTime timeStamp, DateTime timeStampCreate) - { - // if (parent == null) - // return; - - referable.Parent = parent; - referable.TimeStamp = timeStamp; - referable.TimeStampCreate = timeStampCreate; - referable.TimeStampTree = timeStamp; - - foreach (var submodelElement in referable.EnumerateChildren()) - { - submodelElement.SetAllParentsAndTimestamps(referable, timeStamp, timeStampCreate); - } - } - - public static Submodel GetParentSubmodel(this IReferable referable) - { - IReferable parent = referable; - while (parent is not Submodel && parent != null) - parent = (IReferable)parent.Parent; - return parent as Submodel; - } - - public static string CollectIdShortByParent(this IReferable referable) - { - // recurse first - var head = ""; - if (referable is not IIdentifiable && referable.Parent is IReferable parentReferable) - // can go up - head = parentReferable.CollectIdShortByParent() + "/"; - // add own - var myid = ""; - if (string.IsNullOrEmpty(referable.IdShort)) - myid = referable.IdShort.Trim(); - // together - return head + myid; - } - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendISubmodelElement.cs b/src/AasxServerStandardBib/Extenstions/ExtendISubmodelElement.cs deleted file mode 100644 index f5623c06c..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendISubmodelElement.cs +++ /dev/null @@ -1,698 +0,0 @@ -using AasCore.Aas3_0_RC02; -using AasxCompatibilityModels; -using AasxServerStandardBib.Extenstions; -using Opc.Ua; -using System; -using System.Collections.Generic; -using System.Linq; -using ReferenceTypes = AasCore.Aas3_0_RC02.ReferenceTypes; - -namespace Extenstions -{ - public static class ExtendISubmodelElement - { - public static string ValueAsText(this ISubmodelElement submodelElement) - { - //TODO:Need to check/test this logic again - if (submodelElement is Property property) - { - return property.ValueAsText(); - } - - if (submodelElement is MultiLanguageProperty multiLanguageProperty) - { - return multiLanguageProperty.ValueAsText(); - } - - if (submodelElement is AasCore.Aas3_0_RC02.Range range) - { - return range.ValueAsText(); - } - - if (submodelElement is File file) - { - return file.ValueAsText(); - } - - return ""; - } - - public static Qualifier FindQualifierOfType(this ISubmodelElement submodelElement, string qualifierType) - { - if (submodelElement.Qualifiers == null || submodelElement.Qualifiers.Count == 0) - { - return null; - } - - foreach (var qualifier in submodelElement.Qualifiers) - { - if (qualifier.Type.Equals(qualifierType, StringComparison.OrdinalIgnoreCase)) - { - return qualifier; - } - } - - return null; - - } - - public static Reference GetModelReference(this ISubmodelElement submodelElement, bool includeParents = true) - { - var keyList = new List(); - var keyType = ExtensionsUtil.GetKeyType(submodelElement); - var key = new Key(keyType, submodelElement.IdShort); - keyList.Add(key); - - //Keys for Parents - var currentParent = submodelElement.Parent; - while (includeParents && currentParent != null) - { - if (currentParent is IIdentifiable identifiable) - { - var currentParentKey = new Key(ExtensionsUtil.GetKeyType(identifiable), identifiable.Id); - keyList.Add(currentParentKey); - currentParent = null; - } - else if (currentParent is IReferable referable) - { - var currentParentKey = new Key(ExtensionsUtil.GetKeyType(referable), referable.IdShort); - keyList.Add(currentParentKey); - currentParent = referable.Parent; - } - - } - - var outputReference = new Reference(ReferenceTypes.ModelReference, keyList); - outputReference.ReferredSemanticId = submodelElement.SemanticId; - return outputReference; - } - - - public static IEnumerable FindDeep(this ISubmodelElement submodelElement) - { - if (submodelElement is T) - { - yield return (T)submodelElement; - } - - if (submodelElement is SubmodelElementCollection submodelElementCollection) - { - foreach (var collectionElement in submodelElementCollection.Value) - { - yield return (T)collectionElement.FindDeep(); - } - } - - if (submodelElement is AnnotatedRelationshipElement annotatedRelationshipElement) - { - foreach (var annotation in annotatedRelationshipElement.Annotations) - { - yield return (T)annotation.FindDeep(); - } - } - - if (submodelElement is Entity entity) - { - foreach (var statement in entity.Statements) - { - yield return (T)statement.FindDeep(); - } - } - - if (submodelElement is Operation operation) - { - var variableCollection = new SubmodelElementCollection(); - variableCollection.Value = new List(); - foreach (var inputVariable in operation.InputVariables) - { - variableCollection.Value.Add(inputVariable.Value); - } - foreach (var outputVariable in operation.OutputVariables) - { - variableCollection.Value.Add(outputVariable.Value); - } - foreach (var inOutVariable in operation.InoutputVariables) - { - variableCollection.Value.Add(inOutVariable.Value); - } - yield return (T)variableCollection.FindDeep(); - } - } - - public static ISubmodelElement ConvertFromV10(this ISubmodelElement submodelElement, AdminShellV10.SubmodelElement sourceSubmodelElement, bool shallowCopy = false) - { - ISubmodelElement outputSubmodelElement = null; - if (sourceSubmodelElement != null) - { - if (sourceSubmodelElement is AdminShellV10.SubmodelElementCollection collection) - { - var newSmeCollection = new SubmodelElementCollection(); - outputSubmodelElement = newSmeCollection.ConvertFromV10(collection, shallowCopy); - } - else if (sourceSubmodelElement is AdminShellV10.Property sourceProperty) - { - var newProperty = new Property(DataTypeDefXsd.String); - outputSubmodelElement = newProperty.ConvertFromV10(sourceProperty); - } - else if (sourceSubmodelElement is AdminShellV10.File sourceFile) - { - var newFile = new File(""); - outputSubmodelElement = newFile.ConvertFromV10(sourceFile); - } - else if (sourceSubmodelElement is AdminShellV10.Blob blob) - { - var newBlob = new Blob(""); - outputSubmodelElement = newBlob.ConvertFromV10(blob); - } - else if (sourceSubmodelElement is AdminShellV10.ReferenceElement sourceReferenceElement) - { - outputSubmodelElement = new ReferenceElement(); - } - else if (sourceSubmodelElement is AdminShellV10.RelationshipElement sourceRelationshipElement) - { - var newFirst = ExtensionsUtil.ConvertReferenceFromV10(sourceRelationshipElement.first, ReferenceTypes.ModelReference); - var newSecond = ExtensionsUtil.ConvertReferenceFromV10(sourceRelationshipElement.second, ReferenceTypes.ModelReference); - outputSubmodelElement = new RelationshipElement(newFirst, newSecond); - } - - if (sourceSubmodelElement is AdminShellV10.Operation sourceOperation) - { - var newInputVariables = new List(); - var newOutputVariables = new List(); - if (sourceOperation.valueIn != null) - { - - foreach (var inputVariable in sourceOperation.valueIn) - { - if (inputVariable.value.submodelElement != null) - { - ISubmodelElement newSubmodelElement = null; - newSubmodelElement = newSubmodelElement.ConvertFromV10(inputVariable.value.submodelElement); - var newOpVariable = new OperationVariable(newSubmodelElement); - newInputVariables.Add(newOpVariable); - } - } - } - if (sourceOperation.valueOut != null) - { - foreach (var outputVariable in sourceOperation.valueOut) - { - if (outputVariable.value.submodelElement != null) - { - ISubmodelElement newSubmodelElement = null; - newSubmodelElement = newSubmodelElement.ConvertFromV10(outputVariable.value.submodelElement); - var newOpVariable = new OperationVariable(newSubmodelElement); - newOutputVariables.Add(newOpVariable); - } - } - } - - outputSubmodelElement = new Operation(inputVariables: newInputVariables, outputVariables: newOutputVariables); - } - - - outputSubmodelElement.BasicConversionFromV10(sourceSubmodelElement); - } - - return outputSubmodelElement; - } - - private static void BasicConversionFromV10(this ISubmodelElement submodelElement, AdminShellV10.SubmodelElement sourceSubmodelElement) - { - if (!string.IsNullOrEmpty(sourceSubmodelElement.idShort)) - { - submodelElement.IdShort = sourceSubmodelElement.idShort; - } - - if (!string.IsNullOrEmpty(sourceSubmodelElement.category)) - { - submodelElement.Category = sourceSubmodelElement.category; - } - - if (sourceSubmodelElement.description != null) - { - submodelElement.Description = ExtensionsUtil.ConvertDescriptionFromV10(sourceSubmodelElement.description); - } - - if (sourceSubmodelElement.semanticId != null) - { - var keyList = new List(); - foreach (var refKey in sourceSubmodelElement.semanticId.Keys) - { - var keyType = Stringification.KeyTypesFromString(refKey.type); - if (keyType != null) - { - keyList.Add(new Key((KeyTypes)keyType, refKey.value)); - } - else - { - Console.WriteLine($"KeyType value {refKey.type} not found."); - } - } - submodelElement.SemanticId = new Reference(ReferenceTypes.GlobalReference, keyList); - } - - if (sourceSubmodelElement.kind != null) - { - if (sourceSubmodelElement.kind.IsInstance) - { - submodelElement.Kind = ModelingKind.Instance; - } - else - { - submodelElement.Kind = ModelingKind.Template; - } - } - - if (sourceSubmodelElement.qualifiers != null && sourceSubmodelElement.qualifiers.Count != 0) - { - if (submodelElement.Qualifiers == null && submodelElement.Qualifiers.Count != 0) - { - submodelElement.Qualifiers = new List(); - } - - foreach (var sourceQualifier in sourceSubmodelElement.qualifiers) - { - var newQualifier = new Qualifier("", DataTypeDefXsd.String); - newQualifier = newQualifier.ConvertFromV10(sourceQualifier); - submodelElement.Qualifiers.Add(newQualifier); - } - } - - if (sourceSubmodelElement.hasDataSpecification != null) - { - //TODO: jtikekar : EmbeddedDataSpecification?? (as per old implementation) - if (submodelElement.DataSpecifications == null) - { - submodelElement.DataSpecifications = new List(); - } - foreach (var dataSpecification in sourceSubmodelElement.hasDataSpecification.reference) - { - submodelElement.DataSpecifications.Add(ExtensionsUtil.ConvertReferenceFromV10(dataSpecification, ReferenceTypes.GlobalReference)); - } - } - } - - public static ISubmodelElement ConvertFromV20(this ISubmodelElement submodelElement, AdminShellV20.SubmodelElement sourceSubmodelElement, bool shallowCopy = false) - { - ISubmodelElement outputSubmodelElement = null; - if (sourceSubmodelElement != null) - { - if (sourceSubmodelElement is AdminShellV20.SubmodelElementCollection collection) - { - var newSmeCollection = new SubmodelElementCollection(); - outputSubmodelElement = newSmeCollection.ConvertFromV20(collection, shallowCopy); - } - else if (sourceSubmodelElement is AdminShellV20.Property sourceProperty) - { - var newProperty = new Property(DataTypeDefXsd.String); - outputSubmodelElement = newProperty.ConvertFromV20(sourceProperty); - } - else if (sourceSubmodelElement is AdminShellV20.MultiLanguageProperty sourceMultiLangProp) - { - var newMultiLangProperty = new MultiLanguageProperty(); - outputSubmodelElement = newMultiLangProperty.ConvertFromV20(sourceMultiLangProp); - } - else if (sourceSubmodelElement is AdminShellV20.Range sourceRange) - { - var newRange = new AasCore.Aas3_0_RC02.Range(DataTypeDefXsd.String); - outputSubmodelElement = newRange.ConvertFromV20(sourceRange); - } - else if (sourceSubmodelElement is AdminShellV20.File sourceFile) - { - var newFile = new File(""); - outputSubmodelElement = newFile.ConvertFromV20(sourceFile); - } - else if (sourceSubmodelElement is AdminShellV20.Blob blob) - { - var newBlob = new Blob(""); - outputSubmodelElement = newBlob.ConvertFromV20(blob); - } - else if (sourceSubmodelElement is AdminShellV20.ReferenceElement sourceReferenceElement) - { - var newReference = ExtensionsUtil.ConvertReferenceFromV20(sourceReferenceElement.value, ReferenceTypes.ModelReference); - outputSubmodelElement = new ReferenceElement(value: newReference); - } - else if (sourceSubmodelElement is AdminShellV20.AnnotatedRelationshipElement sourceAnnotedRelationshipElement) - { - var newFirst = ExtensionsUtil.ConvertReferenceFromV20(sourceAnnotedRelationshipElement.first, ReferenceTypes.ModelReference); - var newSecond = ExtensionsUtil.ConvertReferenceFromV20(sourceAnnotedRelationshipElement.second, ReferenceTypes.ModelReference); - var newAnnotedRelElement = new AnnotatedRelationshipElement(newFirst, newSecond); - outputSubmodelElement = newAnnotedRelElement.ConvertAnnotationsFromV20(sourceAnnotedRelationshipElement); - } - else if (sourceSubmodelElement is AdminShellV20.RelationshipElement sourceRelationshipElement) - { - var newFirst = ExtensionsUtil.ConvertReferenceFromV20(sourceRelationshipElement.first, ReferenceTypes.ModelReference); - var newSecond = ExtensionsUtil.ConvertReferenceFromV20(sourceRelationshipElement.second, ReferenceTypes.ModelReference); - outputSubmodelElement = new RelationshipElement(newFirst, newSecond); - } - else if (sourceSubmodelElement is AdminShellV20.BasicEvent sourceBasicEvent) - { - var newObserved = ExtensionsUtil.ConvertReferenceFromV20(sourceBasicEvent.observed, ReferenceTypes.ModelReference); - - outputSubmodelElement = new BasicEventElement(newObserved, Direction.Input, StateOfEvent.Off); //TODO: jtikekar default values of enums - } - else if (sourceSubmodelElement is AdminShellV20.Entity sourceEntity) - { - var entityType = Stringification.EntityTypeFromString(sourceEntity.entityType); - var newEntity = new Entity((EntityType)entityType); - outputSubmodelElement = newEntity.ConvertFromV20(sourceEntity); - } - else if (sourceSubmodelElement is AdminShellV20.Operation sourceOperation) - { - var newInputVariables = new List(); - var newOutputVariables = new List(); - var newInOutVariables = new List(); - if (sourceOperation.inputVariable != null) - { - - foreach (var inputVariable in sourceOperation.inputVariable) - { - if (inputVariable.value.submodelElement != null) - { - ISubmodelElement newSubmodelElement = null; - newSubmodelElement = newSubmodelElement.ConvertFromV20(inputVariable.value.submodelElement); - var newOpVariable = new OperationVariable(newSubmodelElement); - newInputVariables.Add(newOpVariable); - } - } - } - if (sourceOperation.outputVariable != null) - { - foreach (var outputVariable in sourceOperation.outputVariable) - { - if (outputVariable.value.submodelElement != null) - { - ISubmodelElement newSubmodelElement = null; - newSubmodelElement = newSubmodelElement.ConvertFromV20(outputVariable.value.submodelElement); - var newOpVariable = new OperationVariable(newSubmodelElement); - newOutputVariables.Add(newOpVariable); - } - } - } - - if (sourceOperation.inoutputVariable != null) - { - foreach (var inOutVariable in sourceOperation.inoutputVariable) - { - if (inOutVariable.value.submodelElement != null) - { - ISubmodelElement newSubmodelElement = null; - newSubmodelElement = newSubmodelElement.ConvertFromV20(inOutVariable.value.submodelElement); - var newOpVariable = new OperationVariable(newSubmodelElement); - newInOutVariables.Add(newOpVariable); - } - } - } - - outputSubmodelElement = new Operation(inputVariables: newInputVariables, outputVariables: newOutputVariables, inoutputVariables: newInOutVariables); - } - - outputSubmodelElement.BasicConversionFromV20(sourceSubmodelElement); - } - - return outputSubmodelElement; - } - - private static void BasicConversionFromV20(this ISubmodelElement submodelElement, AdminShellV20.SubmodelElement sourceSubmodelElement) - { - if (!string.IsNullOrEmpty(sourceSubmodelElement.idShort)) - { - submodelElement.IdShort = sourceSubmodelElement.idShort; - } - - if (!string.IsNullOrEmpty(sourceSubmodelElement.category)) - { - submodelElement.Category = sourceSubmodelElement.category; - } - - if (sourceSubmodelElement.description != null) - { - submodelElement.Description = ExtensionsUtil.ConvertDescriptionFromV20(sourceSubmodelElement.description); - } - - if (sourceSubmodelElement.semanticId != null) - { - var keyList = new List(); - foreach (var refKey in sourceSubmodelElement.semanticId.Keys) - { - var keyType = Stringification.KeyTypesFromString(refKey.type); - if (keyType != null) - { - keyList.Add(new Key((KeyTypes)keyType, refKey.value)); - } - else - { - Console.WriteLine($"KeyType value {refKey.type} not found."); - } - } - submodelElement.SemanticId = new Reference(ReferenceTypes.GlobalReference, keyList); - } - - if (sourceSubmodelElement.kind != null) - { - if (sourceSubmodelElement.kind.IsInstance) - { - submodelElement.Kind = ModelingKind.Instance; - } - else - { - submodelElement.Kind = ModelingKind.Template; - } - } - - if (sourceSubmodelElement.qualifiers != null && sourceSubmodelElement.qualifiers.Count != 0) - { - if (submodelElement.Qualifiers == null || submodelElement.Qualifiers.Count == 0) - { - submodelElement.Qualifiers = new List(); - } - - foreach (var sourceQualifier in sourceSubmodelElement.qualifiers) - { - var newQualifier = new Qualifier("", DataTypeDefXsd.String); - newQualifier = newQualifier.ConvertFromV20(sourceQualifier); - submodelElement.Qualifiers.Add(newQualifier); - } - } - - if (sourceSubmodelElement.hasDataSpecification != null) - { - //TODO: jtikekar : EmbeddedDataSpecification?? (as per old implementation) - if (submodelElement.DataSpecifications == null) - { - submodelElement.DataSpecifications = new List(); - } - - //TODO: jtikekar: DataSpecificationContent?? (as per old implementation) - foreach (var sourceDataSpec in sourceSubmodelElement.hasDataSpecification) - { - submodelElement.DataSpecifications.Add(ExtensionsUtil.ConvertReferenceFromV20(sourceDataSpec.dataSpecification, ReferenceTypes.GlobalReference)); - } - } - } - - public static void RecurseOnReferables(this List submodelElements, object state, List parents, - Func, IReferable, bool> lambda) - { - if (lambda == null) - return; - if (parents == null) - parents = new List(); - - // over all elements - foreach (var submodelElement in submodelElements) - { - var current = submodelElement; - if (current == null) - continue; - - // call lambda for this element - // AND decide, if to recurse! - var goDeeper = lambda(state, parents, current); - - if (goDeeper) - { - // add to parents - parents.Add(current); - - // dive into? - if (current is SubmodelElementCollection smc) - smc.Value?.RecurseOnReferables(state, parents, lambda); - - if (current is Entity ent) - ent.Statements?.RecurseOnReferables(state, parents, lambda); - - if (current is Operation operation) - { - SubmodelElementCollection opVariableCollection = new SubmodelElementCollection(); - foreach (var inputVariable in operation.InputVariables) - { - opVariableCollection.Value.Add(inputVariable.Value); - } - - foreach (var outputVariable in operation.OutputVariables) - { - opVariableCollection.Value.Add(outputVariable.Value); - } - - foreach (var inOutVariable in operation.InoutputVariables) - { - opVariableCollection.Value.Add(inOutVariable.Value); - } - - opVariableCollection.Value.RecurseOnReferables(state, parents, lambda); - } - - if (current is AnnotatedRelationshipElement annotatedRelationshipElement) - { - var annotationElements = new List(); - foreach (var annotation in annotatedRelationshipElement.Annotations) - { - annotationElements.Add(annotation); - } - annotationElements.RecurseOnReferables(state, parents, lambda); - } - - // remove from parents - parents.RemoveAt(parents.Count - 1); - } - } - } - - public static void RecurseOnSubmodelElements(this List submodelElements, object state, List parents, Action, ISubmodelElement> lambda) - { - // trivial - if (lambda == null) - return; - if (parents == null) - parents = new List(); - - // over all elements - foreach (var smw in submodelElements) - { - var current = smw; - if (current == null) - continue; - - // call lambda for this element - lambda(state, parents, current); - - // add to parents - parents.Add(current); - - // dive into? - if (current is SubmodelElementCollection smc) - smc.Value?.RecurseOnSubmodelElements(state, parents, lambda); - - if (current is Entity ent) - ent.Statements?.RecurseOnSubmodelElements(state, parents, lambda); - - if (current is Operation operation) - { - SubmodelElementCollection opVariableCollection = new SubmodelElementCollection(); - foreach (var inputVariable in operation.InputVariables) - { - opVariableCollection.Value.Add(inputVariable.Value); - } - - foreach (var outputVariable in operation.OutputVariables) - { - opVariableCollection.Value.Add(outputVariable.Value); - } - - foreach (var inOutVariable in operation.InoutputVariables) - { - opVariableCollection.Value.Add(inOutVariable.Value); - } - - opVariableCollection.Value.RecurseOnSubmodelElements(state, parents, lambda); - } - - if (current is AnnotatedRelationshipElement annotatedRelationshipElement) - { - var annotationElements = new List(); - foreach (var annotation in annotatedRelationshipElement.Annotations) - { - annotationElements.Add(annotation); - } - annotationElements.RecurseOnSubmodelElements(state, parents, lambda); - } - - // remove from parents - parents.RemoveAt(parents.Count - 1); - } - } - - public static IEnumerable FindAllSemanticIdAs(this List submodelELements, string semanticId) where T : ISubmodelElement - { - foreach (var submodelElement in submodelELements) - { - if (submodelElement != null && submodelElement is T && submodelElement.SemanticId != null) - { - if (submodelElement.SemanticId.Matches(semanticId)) - { - yield return (T)submodelElement; - } - } - } - } - - public static T FindFirstSemanticIdAs(this List submodelELements, string semanticId) where T : ISubmodelElement - { - return submodelELements.FindAllSemanticIdAs(semanticId).FirstOrDefault(); - } - - public static T FindFirstAnySemanticIdAs(this List submodelELements, string[] semanticIds) where T : ISubmodelElement - { - if (semanticIds == null) - return default; - foreach (var semanticId in semanticIds) - { - var found = submodelELements.FindFirstSemanticIdAs(semanticId); - if (found != null) - return found; - } - return default; - } - - public static IEnumerable FindAllSemanticId(this List submodelElements, string[] allowedSemanticIds, bool invertedAllowed = false) where T : ISubmodelElement - { - if (allowedSemanticIds == null || allowedSemanticIds.Length < 1) - yield break; - - foreach (var submodelElement in submodelElements) - { - if (submodelElement == null || !(submodelElement is T)) - continue; - - if (submodelElement.SemanticId == null || submodelElement.SemanticId.Keys.Count < 1) - { - if (invertedAllowed) - yield return (T)submodelElement; - continue; - } - - var found = false; - foreach (var semanticId in allowedSemanticIds) - if (submodelElement.SemanticId.Matches(semanticId)) - { - found = true; - break; - } - - if (invertedAllowed) - found = !found; - - if (found) - yield return (T)submodelElement; - } - } - - public static T FindFirstAnySemanticId(this List submodelElements, string[] allowedSemanticIds, bool invertAllowed = false) where T : ISubmodelElement - { - return submodelElements.FindAllSemanticId(allowedSemanticIds, invertAllowed).FirstOrDefault(); - } - - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendKey.cs b/src/AasxServerStandardBib/Extenstions/ExtendKey.cs deleted file mode 100644 index abcc84309..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendKey.cs +++ /dev/null @@ -1,54 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System.Collections.Generic; -using System.Linq; - -namespace Extenstions -{ - public static class ExtendKey - { - public static bool Matches(this Key key, Key otherKey) - { - if (otherKey == null) - { - return false; - } - - if (key.Type == otherKey.Type && key.Value.Equals(otherKey.Value)) - { - return true; - } - - return false; - } - - public static bool StartsWith(this List keyList, List otherKeyList) - { - if (otherKeyList == null || otherKeyList.Count == 0) - return false; - - // simply test element-wise - for (int i = 0; i < otherKeyList.Count; i++) - { - // does head have more elements than this list? - if (i >= keyList.Count) - return false; - - if (!otherKeyList[i].Matches(keyList[i])) - return false; - } - - // ok! - return true; - } - - public static string ToStringExtended(this Key key) - { - return $"[{key.Type}, {key.Value}]"; - } - - public static string ToStringExtended(this List keys) - { - return string.Join(",", keys.Select((x) => x.ToStringExtended())); - } - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendLangStringSet.cs b/src/AasxServerStandardBib/Extenstions/ExtendLangStringSet.cs deleted file mode 100644 index e8e6dc515..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendLangStringSet.cs +++ /dev/null @@ -1,48 +0,0 @@ -using AasCore.Aas3_0_RC02; -using Microsoft.IdentityModel.Tokens; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Extenstions -{ - public static class ExtendLangStringSet - { - public static string GetDefaultString(this LangStringSet langStringSet, string defaultLang = null) - { - // start - if (defaultLang == null) - defaultLang = "en"; //Default Lang in old implementation is en - - string res = null; - - // search - foreach (var langString in langStringSet.LangStrings) - if (langString.Language.Equals(defaultLang, StringComparison.OrdinalIgnoreCase)) - res = langString.Text; - - if (res == null && langStringSet.LangStrings.Count > 0) - res = langStringSet.LangStrings[0].Text; - - // found? - return res; - } - - public static LangStringSet ConvertFromV20(this LangStringSet langStringSet, AasxCompatibilityModels.AdminShellV20.LangStringSet sourceLangStrings) - { - - if (!sourceLangStrings.langString.IsNullOrEmpty()) - { - langStringSet.LangStrings = new List(); - foreach (var sourceLangString in sourceLangStrings.langString) - { - var langString = new LangString(sourceLangString.lang, sourceLangString.str); - langStringSet.LangStrings.Add(langString); - } - } - return langStringSet; - } - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendMultiLamguageProperty.cs b/src/AasxServerStandardBib/Extenstions/ExtendMultiLamguageProperty.cs deleted file mode 100644 index e286e29d7..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendMultiLamguageProperty.cs +++ /dev/null @@ -1,54 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Extenstions -{ - public static class ExtendMultiLamguageProperty - { - public static string ValueAsText(this MultiLanguageProperty multiLanguageProperty) - { - //TODO: need to check/test again - return "" + multiLanguageProperty.Value?.LangStrings.FirstOrDefault().Text; - } - - public static MultiLanguageProperty ConvertFromV20(this MultiLanguageProperty property, AasxCompatibilityModels.AdminShellV20.MultiLanguageProperty sourceProperty) - { - if (sourceProperty == null) - { - return null; - } - - if (sourceProperty.valueId != null) - { - var keyList = new List(); - foreach (var refKey in sourceProperty.valueId.Keys) - { - //keyList.Add(new Key(ExtensionsUtil.GetKeyTypeFromString(refKey.type), refKey.value)); - var keyType = Stringification.KeyTypesFromString(refKey.type); - if (keyType != null) - { - keyList.Add(new Key((KeyTypes)keyType, refKey.value)); - } - else - { - Console.WriteLine($"KeyType value not found for property {property.IdShort}"); - } - } - property.ValueId = new Reference(ReferenceTypes.GlobalReference, keyList); - } - - var newLangStrings = new List(); - - LangStringSet newLangStringSet = new(newLangStrings); - - property.Value = newLangStringSet.ConvertFromV20(sourceProperty.value); - - return property; - - } - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendRange.cs b/src/AasxServerStandardBib/Extenstions/ExtendRange.cs deleted file mode 100644 index e70b8c420..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendRange.cs +++ /dev/null @@ -1,40 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Extenstions -{ - public static class ExtendRange - { - public static string ValueAsText(this AasCore.Aas3_0_RC02.Range range) - { - return "" + range.Min + " .. " + range.Max; - } - - public static AasCore.Aas3_0_RC02.Range ConvertFromV20(this AasCore.Aas3_0_RC02.Range range, AasxCompatibilityModels.AdminShellV20.Range sourceRange) - { - if (sourceRange == null) - { - return null; - } - - var propertyType = Stringification.DataTypeDefXsdFromString("xs:" + sourceRange.valueType); - if (propertyType != null) - { - range.ValueType = (DataTypeDefXsd)propertyType; - } - else - { - Console.WriteLine($"ValueType {sourceRange.valueType} not found for property {range.IdShort}"); - } - - range.Max = sourceRange.max; - range.Min = sourceRange.min; - - return range; - } - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendReference.cs b/src/AasxServerStandardBib/Extenstions/ExtendReference.cs deleted file mode 100644 index 96b6f8814..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendReference.cs +++ /dev/null @@ -1,87 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Extenstions -{ - public static class ExtendReference - { - public static bool Matches(this Reference reference, string id) - { - if (string.IsNullOrEmpty(id)) - { - return false; - } - - if (reference.Keys.Count == 1) // As per old implementation - { - if (reference.Keys[0].Value == id) - return true; - } - - return false; - } - - public static bool Matches(this Reference reference, Reference otherReference) - { - if (reference.Keys == null || reference.Keys.Count == 0 || otherReference.Keys == null || otherReference.Keys.Count == 0) - { - return false; - } - - bool match = true; - for (int i = 0; i < reference.Keys.Count; i++) - { - match = match && reference.Keys[i].Matches(otherReference.Keys[i]); - } - - return match; - } - - public static string GetAsIdentifier(this Reference reference) - { - if (reference.Type == ReferenceTypes.GlobalReference) // Applying only to Global Reference, based on older implementation, TODO:Make it Generic - { - if (reference.Keys == null || reference.Keys.Count < 1) - { - return null; - } - - return reference.Keys[0].Value; - } - - return null; - } - - public static string MostSignificantInfo(this Reference reference) - { - if (reference.Keys.Count < 1) - { - return "-"; - } - - var i = reference.Keys.Count - 1; - var output = reference.Keys[i].Value; - if (reference.Keys[i].Type == KeyTypes.FragmentReference && i > 0) - output += reference.Keys[i - 1].Value; - return output; - } - - public static Key GetAsExactlyOneKey(this Reference reference) - { - if (reference.Keys == null || reference.Keys.Count != 1) - { - return null; - } - - var key = reference.Keys[0]; - return new Key(key.Type, key.Value); - } - - - } - -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendSubmodelElementCollection.cs b/src/AasxServerStandardBib/Extenstions/ExtendSubmodelElementCollection.cs deleted file mode 100644 index 693fc2f37..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendSubmodelElementCollection.cs +++ /dev/null @@ -1,105 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Extenstions -{ - public static class ExtendSubmodelElementCollection - { - public static T FindFirstIdShortAs(this SubmodelElementCollection submodelElementCollection, string idShort) where T : ISubmodelElement - { - try - { - var submodelElement = submodelElementCollection.Value.Where(sme => (sme != null) && (sme is T) && sme.IdShort.Equals(idShort, StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); - - return (T)submodelElement; - } - catch - { - return default(T); - } - } - - public static SubmodelElementCollection ConvertFromV10(this SubmodelElementCollection submodelElementCollection, AasxCompatibilityModels.AdminShellV10.SubmodelElementCollection sourceSmeCollection, bool shallowCopy = false) - { - if (sourceSmeCollection == null) - return null; - - if (submodelElementCollection.Value == null) - { - submodelElementCollection.Value = new List(); - } - - if (!shallowCopy) - { - foreach (var submodelElementWrapper in sourceSmeCollection.value) - { - var sourceSubmodelElement = submodelElementWrapper.submodelElement; - ISubmodelElement outputSubmodelElement = null; - if (sourceSubmodelElement != null) - { - outputSubmodelElement = outputSubmodelElement.ConvertFromV10(sourceSubmodelElement, shallowCopy); - } - - submodelElementCollection.Value.Add(outputSubmodelElement); - } - } - - return submodelElementCollection; - } - - public static SubmodelElementCollection ConvertFromV20(this SubmodelElementCollection submodelElementCollection, AasxCompatibilityModels.AdminShellV20.SubmodelElementCollection sourceSmeCollection, bool shallowCopy = false) - { - if (sourceSmeCollection == null) - return null; - - if (submodelElementCollection.Value == null) - { - submodelElementCollection.Value = new List(); - } - - if (!shallowCopy) - { - foreach (var submodelElementWrapper in sourceSmeCollection.value) - { - var sourceSubmodelElement = submodelElementWrapper.submodelElement; - ISubmodelElement outputSubmodelElement = null; - if (sourceSubmodelElement != null) - { - outputSubmodelElement = outputSubmodelElement.ConvertFromV20(sourceSubmodelElement, shallowCopy); - } - - submodelElementCollection.Value.Add(outputSubmodelElement); - } - } - - return submodelElementCollection; - } - - public static void Add(this SubmodelElementCollection submodelElementCollection, ISubmodelElement submodelElement) - { - if (submodelElementCollection.Value == null) - { - submodelElementCollection.Value = new List(); - } - - submodelElement.Parent = submodelElementCollection; - submodelElementCollection.Value.Add(submodelElement); - } - - public static void Insert(this SubmodelElementCollection submodelElementCollection, int index, ISubmodelElement submodelElement) - { - if (submodelElementCollection.Value == null) - { - submodelElementCollection.Value = new List(); - } - - submodelElement.Parent = submodelElementCollection; - submodelElementCollection.Value.Insert(index, submodelElement); - } - - } -} diff --git a/src/AasxServerStandardBib/Extenstions/ExtendSubmodelElementList.cs b/src/AasxServerStandardBib/Extenstions/ExtendSubmodelElementList.cs deleted file mode 100644 index e4a6a06c8..000000000 --- a/src/AasxServerStandardBib/Extenstions/ExtendSubmodelElementList.cs +++ /dev/null @@ -1,25 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AasxServerStandardBib.Extenstions -{ - public static class ExtendSubmodelElementList - { - public static T FindFirstIdShortAs(this SubmodelElementList submodelElementList, string idShort) where T : ISubmodelElement - { - - var submodelElements = submodelElementList.Value.Where(sme => (sme != null) && (sme is T) && sme.IdShort.Equals(idShort, StringComparison.OrdinalIgnoreCase)); - - if (submodelElements.Any()) - { - return (T)submodelElements.First(); - } - - return default; - } - } -} diff --git a/src/AasxServerStandardBib/Interfaces/IAdminShellPackageEnvironmentService.cs b/src/AasxServerStandardBib/Interfaces/IAdminShellPackageEnvironmentService.cs new file mode 100644 index 000000000..1751c671a --- /dev/null +++ b/src/AasxServerStandardBib/Interfaces/IAdminShellPackageEnvironmentService.cs @@ -0,0 +1,43 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AasxServerStandardBib.Interfaces +{ + public interface IAdminShellPackageEnvironmentService + { + #region AssetAdministrationShell + AssetAdministrationShell CreateAssetAdministrationShell(AssetAdministrationShell body); + void DeleteAssetAdministrationShell(int packageIndex, AssetAdministrationShell aas); + List GetAllAssetAdministrationShells(); + AssetAdministrationShell GetAssetAdministrationShellById(string aasIdentifier, out int packageIndex); + Stream GetAssetInformationThumbnail(int packageIndex); + bool IsAssetAdministrationShellPresent(string aasIdentifier); + void UpdateAssetAdministrationShellById(AssetAdministrationShell body, string aasIdentifier); + void UpdateAssetInformationThumbnail(Resource defaultThumbnail, Stream fileContent, int packageIndex); + + #endregion + + #region Submodel + void DeleteSubmodelById(string submodelIdentifier); + Submodel GetSubmodelById(string submodelIdentifier, out int packageIndex); + + #endregion + + #region ConceptDescription + + void DeleteConceptDescriptionById(string cdIdentifier); + ConceptDescription GetConceptDescriptionById(string cdIdentifier, out int packageIndex); + List GetAllConceptDescriptions(); + bool IsConceptDescriptionPresent(string cdIdentifier); + ConceptDescription CreateConceptDescription(ConceptDescription body); + void UpdateConceptDescriptionById(ConceptDescription body, string cdIdentifier); + + #endregion + + } +} diff --git a/src/AasxServerStandardBib/Interfaces/IAssetAdministrationShellService.cs b/src/AasxServerStandardBib/Interfaces/IAssetAdministrationShellService.cs new file mode 100644 index 000000000..4303a856b --- /dev/null +++ b/src/AasxServerStandardBib/Interfaces/IAssetAdministrationShellService.cs @@ -0,0 +1,24 @@ +using AasCore.Aas3_0_RC02; +using System.Collections.Generic; +using System.IO; + +namespace AasxServerStandardBib.Interfaces +{ + public interface IAssetAdministrationShellService + { + AssetAdministrationShell CreateAssetAdministrationShell(AssetAdministrationShell body); + Reference CreateSubmodelReferenceInAAS(Reference body, string aasIdentifier); + void DeleteAssetAdministrationShellById(string aasIdentifier); + void DeleteSubmodelElementByPath(string aasIdentifier, string submodelIdentifier, string idShortPath); + void DeleteSubmodelReferenceById(string aasIdentifier, string submodelIdentifier); + List GetAllAssetAdministrationShells(List assetIds = null, string idShort = null); + List GetAllSubmodelElements(string aasIdentifier, string submodelIdentifier); + List GetAllSubmodelReferencesFromAas(string aasIdentifier); + AssetAdministrationShell GetAssetAdministrationShellById(string aasIdentifier); + AssetInformation GetAssetInformation(string aasIdentifier); + string GetThumbnail(string aasIdentifier, out byte[] content, out long fileSize); + void UpdateAssetAdministrationShellById(AssetAdministrationShell body, string aasIdentifier); + void UpdateAssetInformation(AssetInformation body, string aasIdentifier); + void UpdateThumbnail(string aasIdentifier, string fileName, string contentType, Stream stream); + } +} diff --git a/src/AasxServerStandardBib/Interfaces/IConceptDescriptionService.cs b/src/AasxServerStandardBib/Interfaces/IConceptDescriptionService.cs new file mode 100644 index 000000000..ed1ed98b0 --- /dev/null +++ b/src/AasxServerStandardBib/Interfaces/IConceptDescriptionService.cs @@ -0,0 +1,14 @@ +using AasCore.Aas3_0_RC02; +using System.Collections.Generic; + +namespace AasxServerStandardBib.Interfaces +{ + public interface IConceptDescriptionService + { + ConceptDescription CreateConceptDescription(ConceptDescription body); + void DeleteConceptDescriptionById(string cdIdentifier); + List GetAllConceptDescriptions(string idShort, Reference isCaseOf, Reference dataSpecificationRef); + ConceptDescription GetConceptDescriptionById(string cdIdentifier); + void UpdateConceptDescriptionById(ConceptDescription body, string cdIdentifier); + } +} diff --git a/src/AasxServerStandardBib/Interfaces/IMetamodelVerificationService.cs b/src/AasxServerStandardBib/Interfaces/IMetamodelVerificationService.cs new file mode 100644 index 000000000..103749114 --- /dev/null +++ b/src/AasxServerStandardBib/Interfaces/IMetamodelVerificationService.cs @@ -0,0 +1,14 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AasxServerStandardBib.Interfaces +{ + public interface IMetamodelVerificationService + { + void VerifyRequestBody(IClass body); + } +} diff --git a/src/AasxServerStandardBib/Interfaces/ISubmodelService.cs b/src/AasxServerStandardBib/Interfaces/ISubmodelService.cs new file mode 100644 index 000000000..016afe256 --- /dev/null +++ b/src/AasxServerStandardBib/Interfaces/ISubmodelService.cs @@ -0,0 +1,16 @@ +using AasCore.Aas3_0_RC02; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AasxServerStandardBib.Interfaces +{ + public interface ISubmodelService + { + void DeleteSubmodelById(string submodelIdentifier); + void DeleteSubmodelElementByPath(string submodelIdentifier, string idShortPath); + List GetAllSubmodelElements(string submodelIdentifier); + } +} diff --git a/src/IO.Swagger.V1RC03/Logging/IAppLogger.cs b/src/AasxServerStandardBib/Logging/IAppLogger.cs similarity index 69% rename from src/IO.Swagger.V1RC03/Logging/IAppLogger.cs rename to src/AasxServerStandardBib/Logging/IAppLogger.cs index f19056f47..5270c6fb5 100644 --- a/src/IO.Swagger.V1RC03/Logging/IAppLogger.cs +++ b/src/AasxServerStandardBib/Logging/IAppLogger.cs @@ -1,10 +1,10 @@ -namespace IO.Swagger.V1RC03.Logging +namespace AasxServerStandardBib.Logging { public interface IAppLogger { void LogInformation(string message, params object[] args); void LogWarning(string message, params object[] args); - void LogError(string message, params object[] args); + void LogDebug(string message, params object[] args); } } \ No newline at end of file diff --git a/src/IO.Swagger.V1RC03/Logging/LoggerAdapter.cs b/src/AasxServerStandardBib/Logging/LoggerAdapter.cs similarity index 56% rename from src/IO.Swagger.V1RC03/Logging/LoggerAdapter.cs rename to src/AasxServerStandardBib/Logging/LoggerAdapter.cs index 5614a5e53..747079979 100644 --- a/src/IO.Swagger.V1RC03/Logging/LoggerAdapter.cs +++ b/src/AasxServerStandardBib/Logging/LoggerAdapter.cs @@ -1,11 +1,6 @@ using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace IO.Swagger.V1RC03.Logging +namespace AasxServerStandardBib.Logging { public class LoggerAdapter : IAppLogger { @@ -15,19 +10,10 @@ public LoggerAdapter(ILoggerFactory loggerFactory) { _logger = loggerFactory.CreateLogger(); } - public void LogError(string message, params object[] args) - { - _logger.LogError(message, args); - } - public void LogInformation(string message, params object[] args) - { - _logger.LogInformation(message, args); - } - - public void LogWarning(string message, params object[] args) - { - _logger.LogWarning(message, args); - } + public void LogDebug(string message, params object[] args) => _logger.LogDebug(message, args); + public void LogError(string message, params object[] args) => _logger.LogError(message, args); + public void LogInformation(string message, params object[] args) => _logger.LogInformation(message, args); + public void LogWarning(string message, params object[] args) => _logger.LogWarning(message, args); } } diff --git a/src/AasxServerStandardBib/Logging/TestClass.cs b/src/AasxServerStandardBib/Logging/TestClass.cs new file mode 100644 index 000000000..3b5d7ee74 --- /dev/null +++ b/src/AasxServerStandardBib/Logging/TestClass.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AasxServerStandardBib.Logging +{ + internal class TestClass + { + } +} diff --git a/src/AasxServerStandardBib/ProductChange.cs b/src/AasxServerStandardBib/ProductChange.cs index 9fec34760..6f7be5bd7 100644 --- a/src/AasxServerStandardBib/ProductChange.cs +++ b/src/AasxServerStandardBib/ProductChange.cs @@ -1,4 +1,11 @@ -using System; +using AasCore.Aas3_0_RC02; +using AdminShellNS; +using Extensions; +using MailKit; +using MailKit.Net.Imap; +using MailKit.Search; +using MailKit.Security; +using System; using System.Collections.Generic; using System.IO; using System.IO.Compression; @@ -6,13 +13,6 @@ using System.Net.Http; using System.Threading; using System.Xml; -using AasCore.Aas3_0_RC02; -using AdminShellNS; -using Extenstions; -using MailKit; -using MailKit.Net.Imap; -using MailKit.Search; -using MailKit.Security; namespace ProductChange { diff --git a/src/AasxServerStandardBib/Program.cs b/src/AasxServerStandardBib/Program.cs index 9210dbc83..592719c9e 100644 --- a/src/AasxServerStandardBib/Program.cs +++ b/src/AasxServerStandardBib/Program.cs @@ -1,13 +1,23 @@ -using System; +using AasCore.Aas3_0_RC02; +using AasOpcUaServer; +using AasxMqttServer; +using AasxRestServerLibrary; +using AdminShellNS; +using Extensions; +using Jose; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Opc.Ua; +using Opc.Ua.Configuration; +using Opc.Ua.Server; +using System; using System.Collections.Generic; using System.CommandLine; using System.CommandLine.Help; using System.CommandLine.IO; using System.ComponentModel; -using System.ComponentModel.DataAnnotations; using System.Globalization; using System.IO; -using System.IO.Compression; using System.Net; using System.Net.Http; using System.Net.Http.Headers; @@ -19,25 +29,7 @@ using System.Timers; using System.Xml; using System.Xml.Serialization; -using AasCore.Aas3_0_RC02; -using AasOpcUaServer; -using AasxMqttServer; -using AasxRestServerLibrary; -using AdminShellNS; -using Extenstions; -using Jose; -using MailKit; -using MailKit.Net.Imap; -using MailKit.Search; -using MailKit.Security; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Opc.Ua; -using Opc.Ua.Configuration; -using Opc.Ua.Server; -using static AasxDemonstration.EnergyModel; using Formatting = Newtonsoft.Json.Formatting; - /* Copyright (c) 2019-2020 PHOENIX CONTACT GmbH & Co. KG , author: Andreas Orzelski Copyright (c) 2018-2020 Festo SE & Co. KG , author: Michael Hoffmeister @@ -897,7 +889,7 @@ public class SubmodelDescriptors [XmlElement(ElementName = "description")] [JsonIgnore] //public AdminShell.Description description = null; - public LangStringSet description = null; + public List description = null; [XmlElement(ElementName = "idShort")] [JsonIgnore] @@ -925,7 +917,7 @@ public class aasDescriptor [XmlElement(ElementName = "description")] [JsonIgnore] //public AdminShell.Description description = new AdminShell.Description(); - public LangStringSet description = new(new List()); + public List description = new(new List()); [XmlElement(ElementName = "idShort")] public string idShort = ""; diff --git a/src/AasxServerStandardBib/SecurityClient.cs b/src/AasxServerStandardBib/SecurityClient.cs index 562dd8741..0f1bb3f34 100644 --- a/src/AasxServerStandardBib/SecurityClient.cs +++ b/src/AasxServerStandardBib/SecurityClient.cs @@ -1,4 +1,13 @@ -using System; +using AasCore.Aas3_0_RC02; +using AasxRestServerLibrary; +using AdminShellNS; +using Extensions; +using IdentityModel; +using IdentityModel.Client; +using Microsoft.IdentityModel.Tokens; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using System; using System.Collections.Generic; using System.Globalization; using System.IdentityModel.Tokens.Jwt; @@ -9,16 +18,6 @@ using System.Security.Cryptography.X509Certificates; using System.Threading; using System.Threading.Tasks; -using AasCore.Aas3_0_RC02; -using AasxRestServerLibrary; -using AasxServer; -using AdminShellNS; -using Extenstions; -using IdentityModel; -using IdentityModel.Client; -using Microsoft.IdentityModel.Tokens; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; namespace AasxServer { @@ -1342,7 +1341,7 @@ public static void createCfpTree(int envIndex, DateTime timeStamp) if (p.Value != null) { string s = null; - foreach (var ls in p.Value.LangStrings) + foreach (var ls in p.Value) { if (ls.Language.ToLower() == "en") { diff --git a/src/AasxServerStandardBib/Services/AdminShellPackageEnvironmentService.cs b/src/AasxServerStandardBib/Services/AdminShellPackageEnvironmentService.cs new file mode 100644 index 000000000..089c56c07 --- /dev/null +++ b/src/AasxServerStandardBib/Services/AdminShellPackageEnvironmentService.cs @@ -0,0 +1,344 @@ +using AasCore.Aas3_0_RC02; +using AasxServer; +using AasxServerStandardBib.Exceptions; +using AasxServerStandardBib.Interfaces; +using AasxServerStandardBib.Logging; +using AdminShellNS; +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace AasxServerStandardBib.Services +{ + public class AdminShellPackageEnvironmentService : IAdminShellPackageEnvironmentService + { + private readonly IAppLogger _logger; + private readonly Lazy _aasService; + private AdminShellPackageEnv[] _packages; + + public AdminShellPackageEnvironmentService(IAppLogger logger, Lazy aasService) + { + _logger = logger; + _aasService = aasService; + _packages = Program.env; + } + + #region Others + + private bool EmptyPackageAvailable(out int emptyPackageIndex) + { + emptyPackageIndex = -1; + + for (int envi = 0; envi < _packages.Length; envi++) + { + if (_packages[envi] == null) + { + emptyPackageIndex = envi; + _packages[emptyPackageIndex] = new AdminShellPackageEnv(); + return true; + } + } + + return false; + } + #endregion + + #region AssetAdministrationShell + public AssetAdministrationShell CreateAssetAdministrationShell(AssetAdministrationShell body) + { + if (EmptyPackageAvailable(out int emptyPackageIndex)) + { + + _packages[emptyPackageIndex].AasEnv.AssetAdministrationShells.Add(body); + Program.signalNewData(2); + return _packages[emptyPackageIndex].AasEnv.AssetAdministrationShells[0]; //Considering it is the first AAS being added to empty package. + } + else + { + throw new Exception("No empty environment package available in the server."); + } + } + + public void DeleteAssetAdministrationShell(int packageIndex, AssetAdministrationShell aas) + { + if (aas != null && packageIndex != -1) + { + bool deleted = (bool)(_packages[packageIndex].AasEnv?.AssetAdministrationShells.Remove(aas)); + if (deleted) + { + _logger.LogDebug($"Deleted Asset Administration Shell with id {aas.Id}"); + //if no more shells in the environment, then remove the environment + //TODO:jtikekar: what about submodels and concept descriptions for the same environment + if (_packages[packageIndex].AasEnv.AssetAdministrationShells.Count == 0) + { + _packages[packageIndex] = null; + } + + Program.signalNewData(2); + } + else + { + _logger.LogError($"Could not delete Asset Administration Shell with id {aas.Id}"); + } + } + } + + public List GetAllAssetAdministrationShells() + { + List output = new List(); + + foreach (var package in _packages) + { + if (package != null) + { + var env = package.AasEnv; + if (env != null && env.AssetAdministrationShells != null && env.AssetAdministrationShells.Count != 0) + { + output.AddRange(env.AssetAdministrationShells); + } + } + } + + return output; + } + + public AssetAdministrationShell GetAssetAdministrationShellById(string aasIdentifier, out int packageIndex) + { + bool found = IsAssetAdministrationShellPresent(aasIdentifier, out AssetAdministrationShell output, out packageIndex); + if (found) + { + _logger.LogDebug($"Asset Administration Shell with id {aasIdentifier} found."); + return output; + } + else + { + throw new NotFoundException($"Asset Administration Shell with id {aasIdentifier} not found."); + } + } + + public bool IsAssetAdministrationShellPresent(string aasIdentifier) + { + return IsAssetAdministrationShellPresent(aasIdentifier, out _, out _); + } + + private bool IsAssetAdministrationShellPresent(string aasIdentifier, out AssetAdministrationShell output, out int packageIndex) + { + output = null; packageIndex = -1; + foreach (var package in _packages) + { + if (package != null) + { + var env = package.AasEnv; + if (env != null) + { + var aas = env.AssetAdministrationShells.Where(a => a.Id.Equals(aasIdentifier)); + if (aas.Any()) + { + output = aas.First(); + packageIndex = Array.IndexOf(_packages, package); + return true; + } + } + } + } + + return false; + } + + public void UpdateAssetAdministrationShellById(AssetAdministrationShell body, string aasIdentifier) + { + var aas = GetAssetAdministrationShellById(aasIdentifier, out int packageIndex); + if (aas != null && packageIndex != -1) + { + var aasIndex = _packages[packageIndex].AasEnv.AssetAdministrationShells.IndexOf(aas); + _packages[packageIndex].AasEnv.AssetAdministrationShells.Remove(aas); + _packages[packageIndex].AasEnv.AssetAdministrationShells.Insert(aasIndex, body); + Program.signalNewData(1); //0 not working, hence 1 = same tree, structure may change + + _logger.LogDebug($"Successfully updated the AAS with requested AAS"); + } + } + + public Stream GetAssetInformationThumbnail(int packageIndex) + { + return _packages[packageIndex].GetLocalThumbnailStream(); + } + + public void UpdateAssetInformationThumbnail(Resource defaultThumbnail, Stream fileContent, int packageIndex) + { + _packages[packageIndex].EmbeddAssetInformationThumbnail(defaultThumbnail, fileContent); + Program.signalNewData(0); + } + #endregion + + #region Submodel + + public void DeleteSubmodelById(string submodelIdentifier) + { + var submodel = GetSubmodelById(submodelIdentifier, out int packageIndex); + if(submodel != null && packageIndex != -1) + { + foreach (var aas in _packages[packageIndex].AasEnv.AssetAdministrationShells) + { + _aasService.Value.DeleteSubmodelReferenceById(aas.Id, submodelIdentifier); + } + _packages[packageIndex].AasEnv.Submodels.Remove(submodel); + _logger.LogDebug($"Deleted submodel with id {submodelIdentifier}."); + AasxServer.Program.signalNewData(1); + } + } + + public Submodel GetSubmodelById(string submodelIdentifier, out int packageIndex) + { + var found = IsSubmodelPresent(submodelIdentifier, out Submodel submodel,out packageIndex); + if(found) + { + _logger.LogDebug($"Found the submodel with Id {submodelIdentifier}"); + return submodel; + } + else + { + throw new NotFoundException($"Submodel with id {submodelIdentifier} NOT found."); + } + } + + private bool IsSubmodelPresent(string submodelIdentifier, out Submodel output, out int packageIndex) + { + output = null; + packageIndex = -1; + foreach (var package in _packages) + { + if (package != null) + { + var env = package.AasEnv; + if (env != null) + { + var submodels = env.Submodels.Where(a => a.Id.Equals(submodelIdentifier)); + if (submodels.Any()) + { + output = submodels.First(); + packageIndex = Array.IndexOf(_packages, package); + return true; + } + } + } + } + + return false; + } + + #endregion + + #region ConceptDescription + + public void DeleteConceptDescriptionById(string cdIdentifier) + { + var conceptDescription = GetConceptDescriptionById(cdIdentifier, out int packageIndex); + + if ((conceptDescription != null) && (packageIndex != -1)) + { + _packages[packageIndex].AasEnv.ConceptDescriptions.Remove(conceptDescription); + _logger.LogDebug($"Delete ConceptDescription with id {cdIdentifier}"); + AasxServer.Program.signalNewData(1); + } + } + + //TODO:jtikekar hide out packageIndex ?? + public ConceptDescription GetConceptDescriptionById(string cdIdentifier, out int packageIndex) + { + var found = IsConceptDescriptionPresent(cdIdentifier, out ConceptDescription output, out packageIndex); + if(found) + { + _logger.LogDebug($"Found the conceptDescription with id {cdIdentifier}"); + return output; + } + else + { + throw new NotFoundException($"ConceptDescription with id {cdIdentifier} NOT found."); + } + } + + + private bool IsConceptDescriptionPresent(string cdIdentifier, out ConceptDescription output, out int packageIndex) + { + output = null; + packageIndex = -1; + foreach (var package in _packages) + { + if (package != null) + { + var env = package.AasEnv; + if (env != null) + { + var conceptDescriptions = env.ConceptDescriptions.Where(c => c.Id.Equals(cdIdentifier)); + if (conceptDescriptions.Any()) + { + output = conceptDescriptions.First(); + packageIndex = Array.IndexOf(_packages, package); + return true; + } + } + } + } + + return false; + } + + public List GetAllConceptDescriptions() + { + var output = new List(); + + //Get All Concept descriptions + foreach (var package in _packages) + { + if (package != null) + { + var env = package.AasEnv; + if (env != null) + { + output.AddRange(env.ConceptDescriptions); + } + } + } + + return output; + } + + public bool IsConceptDescriptionPresent(string cdIdentifier) + { + return IsConceptDescriptionPresent(cdIdentifier, out _, out _); + } + + public ConceptDescription CreateConceptDescription(ConceptDescription body) + { + if (EmptyPackageAvailable(out int emptyPackageIndex)) + { + + _packages[emptyPackageIndex].AasEnv.ConceptDescriptions.Add(body); + Program.signalNewData(2); + return _packages[emptyPackageIndex].AasEnv.ConceptDescriptions[0]; //Considering it is the first AAS being added to empty package. + } + else + { + throw new Exception("No empty environment package available in the server."); + } + } + + public void UpdateConceptDescriptionById(ConceptDescription body, string cdIdentifier) + { + var conceptDescription = GetConceptDescriptionById(cdIdentifier, out int packageIndex); + if (conceptDescription != null && packageIndex != -1) + { + var cdIndex = _packages[packageIndex].AasEnv.ConceptDescriptions.IndexOf(conceptDescription); + _packages[packageIndex].AasEnv.ConceptDescriptions.Remove(conceptDescription); + _packages[packageIndex].AasEnv.ConceptDescriptions.Insert(cdIndex, body); + Program.signalNewData(1); //0 not working, hence 1 = same tree, structure may change + + _logger.LogDebug($"Successfully updated the ConceptDescription."); + } + } + + #endregion + } +} diff --git a/src/AasxServerStandardBib/Services/AssetAdministrationShellService.cs b/src/AasxServerStandardBib/Services/AssetAdministrationShellService.cs new file mode 100644 index 000000000..2192ccb9d --- /dev/null +++ b/src/AasxServerStandardBib/Services/AssetAdministrationShellService.cs @@ -0,0 +1,351 @@ +using AasCore.Aas3_0_RC02; +using AasxServer; +using AasxServerStandardBib.Exceptions; +using AasxServerStandardBib.Interfaces; +using AasxServerStandardBib.Logging; +using AdminShellNS.Exceptions; +using AdminShellNS.Extensions; +using Extensions; +using Microsoft.IdentityModel.Tokens; +using MimeKit; +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; + +namespace AasxServerStandardBib.Services +{ + public class AssetAdministrationShellService : IAssetAdministrationShellService + { + private readonly IAppLogger _logger; + private readonly IAdminShellPackageEnvironmentService _packageEnvService; + private readonly IMetamodelVerificationService _verificationService; + private readonly ISubmodelService _submodelService; + + public AssetAdministrationShellService(IAppLogger logger, IAdminShellPackageEnvironmentService packageEnvService, IMetamodelVerificationService verificationService, ISubmodelService submodelService) + { + _logger = logger; + _packageEnvService = packageEnvService; + _verificationService = verificationService; + _submodelService = submodelService; + } + + public AssetAdministrationShell CreateAssetAdministrationShell(AssetAdministrationShell body) + { + //Verify the body first + _verificationService.VerifyRequestBody(body); + + var found = _packageEnvService.IsAssetAdministrationShellPresent(body.Id); + if(found) + { + _logger.LogDebug($"Cannot create requested AAS !!"); + throw new DuplicateException($"AssetAdministrationShell with id {body.Id} already exists."); + } + + var output = _packageEnvService.CreateAssetAdministrationShell(body); + + return output; + } + + public Reference CreateSubmodelReferenceInAAS(Reference body, string aasIdentifier) + { + Reference output = null; + //Verify request body + _verificationService.VerifyRequestBody(body); + + //TODO:jtikekar to check if submodel with requested submodelReference exists in the server + var aas = _packageEnvService.GetAssetAdministrationShellById(aasIdentifier, out _); + + if(aas != null) + { + if(aas.Submodels.IsNullOrEmpty()) + { + aas.Submodels = new List + { + body + }; + output = aas.Submodels.Last(); + } + else + { + bool found = false; + //Check if duplicate + foreach(var submodelReference in aas.Submodels) + { + if(submodelReference.Matches(body)) + { + found = true; + break; + } + } + + if(found) + { + _logger.LogDebug($"Cannot create requested Submodel-Reference in the AAS !!"); + throw new DuplicateException($"Requested SubmodelReference already exists in the AAS with Id {aasIdentifier}."); + } + else + { + aas.Submodels.Add( body ); + output = aas.Submodels.Last(); + } + } + } + + return output; + } + + + + public void DeleteAssetAdministrationShellById(string aasIdentifier) + { + //TODO:jtikekar can be further refactored?? + var aas = _packageEnvService.GetAssetAdministrationShellById(aasIdentifier, out int packageIndex); + + if (aas != null && packageIndex != -1) + { + _packageEnvService.DeleteAssetAdministrationShell(packageIndex, aas); + } + } + + public void DeleteSubmodelElementByPath(string aasIdentifier, string submodelIdentifier, string idShortPath) + { + var found = IsSubmodelPresentWithinAAS(aasIdentifier, submodelIdentifier); + if(found) + { + _logger.LogDebug($"Found submodel with id {submodelIdentifier} in AAS with id {aasIdentifier}"); + _submodelService.DeleteSubmodelElementByPath(submodelIdentifier, idShortPath); + } + else + { + throw new($"Submodel with id {submodelIdentifier} NOT found in AAS with id {aasIdentifier}"); + } + + } + + + + public void DeleteSubmodelReferenceById(string aasIdentifier, string submodelIdentifier) + { + var aas = _packageEnvService.GetAssetAdministrationShellById(aasIdentifier, out _); + + if(aas != null) + { + var submodelReference = aas.Submodels.Where(s => s.Matches(submodelIdentifier)); + if(submodelReference.Any()) + { + _logger.LogDebug($"Found requested submodel reference in the aas."); + bool deleted = aas.Submodels.Remove(submodelReference.First()); + if(deleted) + { + _logger.LogDebug($"Deleted submodel reference with id {submodelIdentifier} from the AAS with id {aasIdentifier}."); + Program.signalNewData(1); + } + else + { + _logger.LogError($"Could not delete submodel reference with id {submodelIdentifier} from the AAS with id {aasIdentifier}."); + } + } + else + { + throw new NotFoundException($"SubmodelReference with id {submodelIdentifier} not found in AAS with id {aasIdentifier}"); + } + } + } + + public List GetAllAssetAdministrationShells(List assetIds = null, string idShort = null) + { + var output = _packageEnvService.GetAllAssetAdministrationShells(); + + //Apply filters + + if (output.Any()) + { + if (!string.IsNullOrEmpty(idShort)) + { + _logger.LogDebug($"Filtering AASs with idShort {idShort}."); + output = output.Where(a => a.IdShort.Equals(idShort)).ToList(); + if(output.IsNullOrEmpty()) + { + _logger.LogInformation($"No AAS with idShhort {idShort} found."); + } + } + + if(!assetIds.IsNullOrEmpty()) + { + _logger.LogDebug($"Filtering AASs with requested specific assetIds."); + var aasList = new List(); + foreach (var assetId in assetIds) + { + aasList = output.Where(a => a.AssetInformation.SpecificAssetIds.ContainsSpecificAssetId(assetId)).ToList(); + } + + if (aasList.Any()) + { + return aasList; + } + else + { + _logger.LogInformation($"No AAS with requested specific assetId found."); + } + } + } + + return output; + } + + public List GetAllSubmodelElements(string aasIdentifier, string submodelIdentifier) + { + var found = IsSubmodelPresentWithinAAS(aasIdentifier, submodelIdentifier); + if (found) + { + _logger.LogDebug($"Found submodel with id {submodelIdentifier} in AAS with id {aasIdentifier}"); + return _submodelService.GetAllSubmodelElements(submodelIdentifier); + } + else + { + throw new($"Submodel with id {submodelIdentifier} NOT found in AAS with id {aasIdentifier}"); + } + } + + public List GetAllSubmodelReferencesFromAas(string aasIdentifier) + { + List output = new List(); + var aas = _packageEnvService.GetAssetAdministrationShellById(aasIdentifier, out _); + + if(aas != null) + { + if(aas.Submodels.IsNullOrEmpty()) + { + _logger.LogDebug($"No submodels present in the AAS with Id {aasIdentifier}"); + } + + output = aas.Submodels; + } + + return output; + } + + public AssetAdministrationShell GetAssetAdministrationShellById(string aasIdentifier) + { + return _packageEnvService.GetAssetAdministrationShellById(aasIdentifier, out _); + } + + public AssetInformation GetAssetInformation(string aasIdentifier) + { + var aas = _packageEnvService.GetAssetAdministrationShellById(aasIdentifier, out _); + return aas.AssetInformation; + } + + public string GetThumbnail(string aasIdentifier, out byte[] byteArray, out long fileSize) + { + string fileName = null; + byteArray = null; + fileSize = 0; + var aas = _packageEnvService.GetAssetAdministrationShellById(aasIdentifier, out int packageIndex); + if (aas != null) + { + if (aas.AssetInformation != null) + { + if (aas.AssetInformation.DefaultThumbnail != null && !string.IsNullOrEmpty(aas.AssetInformation.DefaultThumbnail.Path)) + { + fileName = aas.AssetInformation.DefaultThumbnail.Path; + + Stream stream = _packageEnvService.GetAssetInformationThumbnail(packageIndex); + byteArray = stream.ToByteArray(); + fileSize = byteArray.Length; + + _logger.LogDebug($"Updated the thumbnail in AAS with Id {aasIdentifier}"); + } + else + { + throw new NotFoundException($"No default thumbnail embedded in the AssetInformation of the requested AAS."); + } + } + else + { + throw new NotFoundException($"AssetInformation is NULL in requested AAS with id {aasIdentifier}"); + } + } + + return fileName; + } + + public void UpdateAssetAdministrationShellById(AssetAdministrationShell body, string aasIdentifier) + { + //Verify the body first + _verificationService.VerifyRequestBody(body); + + _packageEnvService.UpdateAssetAdministrationShellById(body, aasIdentifier); + + } + + public void UpdateAssetInformation(AssetInformation body, string aasIdentifier) + { + _verificationService.VerifyRequestBody(body); + var aas = _packageEnvService.GetAssetAdministrationShellById(aasIdentifier, out _); + if (aas != null) + { + aas.AssetInformation = body; + Program.signalNewData(0); + + _logger.LogDebug($"AssetInformation from AAS with id {aasIdentifier} updated successfully."); + } + } + + public void UpdateThumbnail(string aasIdentifier, string fileName, string contentType, Stream fileContent) + { + var aas = _packageEnvService.GetAssetAdministrationShellById(aasIdentifier, out int packageIndex); + if (aas != null) + { + if (aas.AssetInformation != null) + { + var asset = aas.AssetInformation; + + if (string.IsNullOrEmpty(contentType)) + { + contentType = "application/octet-stream"; + } + + if (asset.DefaultThumbnail == null) + { + //If thumbnail is not set, set to default path + asset.DefaultThumbnail ??= new(Path.Combine("/aasx/files", fileName).Replace('/', Path.DirectorySeparatorChar), contentType); + } + else + { + asset.DefaultThumbnail.Path = asset.DefaultThumbnail.Path.Replace('/', Path.DirectorySeparatorChar); + } + + _packageEnvService.UpdateAssetInformationThumbnail(asset.DefaultThumbnail, fileContent, packageIndex); + + + } + else + { + throw new NotFoundException($"AssetInformation is NULL in requested AAS with id {aasIdentifier}"); + } + } + } + + #region PrivateMethods + + private bool IsSubmodelPresentWithinAAS(string aasIdentifier, string submodelIdentifier) + { + var aas = _packageEnvService.GetAssetAdministrationShellById(aasIdentifier, out _); + if(aas != null) + { + foreach(var submodelReference in aas.Submodels) + { + if(submodelReference.GetAsExactlyOneKey().Value.Equals(submodelIdentifier)) + { return true; } + } + } + + return false; + } + + #endregion + } +} diff --git a/src/AasxServerStandardBib/Services/ConceptDescriptionService.cs b/src/AasxServerStandardBib/Services/ConceptDescriptionService.cs new file mode 100644 index 000000000..8c847203d --- /dev/null +++ b/src/AasxServerStandardBib/Services/ConceptDescriptionService.cs @@ -0,0 +1,142 @@ +using AasCore.Aas3_0_RC02; +using AasxServerStandardBib.Exceptions; +using AasxServerStandardBib.Interfaces; +using AasxServerStandardBib.Logging; +using Microsoft.IdentityModel.Tokens; +using System.Collections.Generic; +using System.Linq; +using Extensions; + +namespace AasxServerStandardBib.Services +{ + public class ConceptDescriptionService : IConceptDescriptionService + { + private readonly IAppLogger _logger; + private readonly IAdminShellPackageEnvironmentService _packageEnvService; + private readonly IMetamodelVerificationService _verificationService; + + public ConceptDescriptionService(IAppLogger logger, IAdminShellPackageEnvironmentService packageEnvService, IMetamodelVerificationService verificationService) + { + _logger = logger; + _packageEnvService = packageEnvService; + _verificationService = verificationService; + } + + public ConceptDescription CreateConceptDescription(ConceptDescription body) + { + //Verify the body first + _verificationService.VerifyRequestBody(body); + + var found = _packageEnvService.IsConceptDescriptionPresent(body.Id); + if (found) + { + _logger.LogDebug($"Cannot create requested ConceptDescription !!"); + throw new DuplicateException($"ConceptDescription with id {body.Id} already exists."); + } + + var output = _packageEnvService.CreateConceptDescription(body); + + return output; + } + + public void DeleteConceptDescriptionById(string cdIdentifier) + { + _packageEnvService.DeleteConceptDescriptionById(cdIdentifier); + } + + public List GetAllConceptDescriptions(string idShort, Reference isCaseOf, Reference dataSpecificationRef) + { + //Get All Concept descriptions + var output = _packageEnvService.GetAllConceptDescriptions(); + + if (output.Any()) + { + //Filter AASs based on IdShort + if (!string.IsNullOrEmpty(idShort)) + { + var cdList = output.Where(cd => cd.IdShort.Equals(idShort)).ToList(); + if (cdList.IsNullOrEmpty()) + { + _logger.LogDebug($"No Concept Description with IdShort {idShort} Found."); + } + else + { + output = cdList; + } + } + + //Filter based on IsCaseOf + if (isCaseOf != null) + { + var cdList = new List(); + foreach (var conceptDescription in output) + { + if (!conceptDescription.IsCaseOf.IsNullOrEmpty()) + { + foreach (var reference in conceptDescription.IsCaseOf) + { + if (reference != null && reference.Matches(isCaseOf)) + { + cdList.Add(conceptDescription); + break; + } + } + } + } + if (cdList.IsNullOrEmpty()) + { + _logger.LogDebug($"No Concept Description with requested IsCaseOf found."); + } + else + { + output = cdList; + } + + } + + //Filter based on DataSpecificationRef + if (dataSpecificationRef != null) + { + var cdList = new List(); + foreach (var conceptDescription in output) + { + if (!conceptDescription.EmbeddedDataSpecifications.IsNullOrEmpty()) + { + foreach (var reference in conceptDescription.EmbeddedDataSpecifications) + { + if (reference != null && reference.DataSpecification.Matches(dataSpecificationRef)) + { + cdList.Add(conceptDescription); + break; + } + } + } + } + if (cdList.IsNullOrEmpty()) + { + _logger.LogDebug($"No Concept Description with requested DataSpecificationReference found."); + } + else + { + output = cdList; + } + } + } + + return output; + } + + public ConceptDescription GetConceptDescriptionById(string cdIdentifier) + { + return _packageEnvService.GetConceptDescriptionById(cdIdentifier, out _); + } + + public void UpdateConceptDescriptionById(ConceptDescription body, string cdIdentifier) + { + //Verify the body first + _verificationService.VerifyRequestBody(body); + + _packageEnvService.UpdateConceptDescriptionById(body, cdIdentifier); + } + } +} diff --git a/src/AasxServerStandardBib/Services/MetamodelVerificationService.cs b/src/AasxServerStandardBib/Services/MetamodelVerificationService.cs new file mode 100644 index 000000000..9bc513db4 --- /dev/null +++ b/src/AasxServerStandardBib/Services/MetamodelVerificationService.cs @@ -0,0 +1,32 @@ +using AasCore.Aas3_0_RC02; +using AasxServerStandardBib.Interfaces; +using AasxServerStandardBib.Logging; +using AdminShellNS.Exceptions; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AasxServerStandardBib.Services +{ + public class MetamodelVerificationService :IMetamodelVerificationService + { + private readonly IAppLogger _logger; + + public MetamodelVerificationService(IAppLogger logger) + { + _logger = logger; + } + public void VerifyRequestBody(IClass body) + { + var errorList = Verification.Verify(body).ToList(); + if (errorList.Any()) + { + throw new MetamodelVerificationException(errorList); + } + + _logger.LogDebug($"The request body is conformant with the metamodel."); + } + } +} diff --git a/src/AasxServerStandardBib/Services/SubmodelService.cs b/src/AasxServerStandardBib/Services/SubmodelService.cs new file mode 100644 index 000000000..bb38e4ce3 --- /dev/null +++ b/src/AasxServerStandardBib/Services/SubmodelService.cs @@ -0,0 +1,205 @@ +using AasCore.Aas3_0_RC02; +using AasxServer; +using AasxServerStandardBib.Exceptions; +using AasxServerStandardBib.Interfaces; +using AasxServerStandardBib.Logging; +using Extensions; +using System; +using System.Collections.Generic; + +namespace AasxServerStandardBib.Services +{ + public class SubmodelService : ISubmodelService + { + private readonly IAppLogger _logger; + private readonly IAdminShellPackageEnvironmentService _packageEnvService; + + public SubmodelService(IAppLogger logger, IAdminShellPackageEnvironmentService packageEnvService) + { + _logger = logger; + _packageEnvService = packageEnvService; + } + + #region PrivateMethods + + private bool IsSubmodelElementPresent(string submodelIdentifier, string idShortPath, out ISubmodelElement output, out IReferable smeParent) + { + output = null; + smeParent = null; + var submodel = _packageEnvService.GetSubmodelById(submodelIdentifier, out _); + + if (submodel != null) + { + output = GetSubmodelElementByPath(submodel, idShortPath, out IReferable parent); + smeParent = parent; + if (output != null) + { + _logger.LogInformation($"Found SubmodelElement at {idShortPath} in submodel with Id {submodelIdentifier}"); + return true; + } + + } + + return false; + } + + //TODO:jtikekar refactor + private ISubmodelElement GetSubmodelElementByPath(IReferable parent, string idShortPath, out IReferable outParent) + { + outParent = parent; + if (idShortPath.Contains('.')) + { + string[] idShorts = idShortPath.Split('.', 2); + if (parent is Submodel submodel) + { + var submodelElement = submodel.FindSubmodelElementByIdShort(idShorts[0]); + if (submodelElement != null) + { + return GetSubmodelElementByPath(submodelElement, idShorts[1], out outParent); + } + } + else if (parent is SubmodelElementCollection collection) + { + var submodelElement = collection.FindFirstIdShortAs(idShorts[0]); + if (submodelElement != null) + { + return GetSubmodelElementByPath(submodelElement, idShorts[1], out outParent); + } + } + else if (parent is SubmodelElementList list) + { + var submodelElement = list.FindFirstIdShortAs(idShorts[0]); + if (submodelElement != null) + { + return GetSubmodelElementByPath(submodelElement, idShorts[1], out outParent); + } + } + else if (parent is Entity entity) + { + var submodelElement = entity.FindFirstIdShortAs(idShortPath); + if (submodelElement != null) + { + return GetSubmodelElementByPath(submodelElement, idShorts[1], out outParent); + } + } + else if (parent is AnnotatedRelationshipElement annotatedRelationshipElement) + { + var submodelElement = annotatedRelationshipElement.FindFirstIdShortAs(idShortPath); + if (submodelElement != null) + { + return GetSubmodelElementByPath(submodelElement, idShorts[1], out outParent); + } + } + else + { + throw new Exception($"Parent of type {parent.GetType()} not supported."); + } + } + else + { + if (parent is Submodel submodel) + { + var submodelElement = submodel.FindSubmodelElementByIdShort(idShortPath); + if (submodelElement != null) + { + return submodelElement; + } + } + else if (parent is SubmodelElementCollection collection) + { + var submodelElement = collection.FindFirstIdShortAs(idShortPath); + if (submodelElement != null) + { + return submodelElement; + } + } + else if (parent is SubmodelElementList list) + { + var submodelElement = list.FindFirstIdShortAs(idShortPath); + if (submodelElement != null) + { + return submodelElement; + } + } + else if (parent is Entity entity) + { + var submodelElement = entity.FindFirstIdShortAs(idShortPath); + if (submodelElement != null) + { + return submodelElement; + } + } + else if (parent is AnnotatedRelationshipElement annotatedRelationshipElement) + { + var submodelElement = annotatedRelationshipElement.FindFirstIdShortAs(idShortPath); + if (submodelElement != null) + { + return submodelElement; + } + } + else + { + throw new Exception($"Parent of type {parent.GetType()} not supported."); + } + } + return null; + } + + + + #endregion + + public void DeleteSubmodelById(string submodelIdentifier) + { + _packageEnvService.DeleteSubmodelById(submodelIdentifier); + } + + public void DeleteSubmodelElementByPath(string submodelIdentifier, string idShortPath) + { + var found = IsSubmodelElementPresent(submodelIdentifier, idShortPath, out ISubmodelElement submodelElement, out IReferable smeParent); + if(found) + { + if (smeParent is SubmodelElementCollection parentCollection) + { + parentCollection.Value.Remove(submodelElement); + } + else if (smeParent is SubmodelElementList parentList) + { + parentList.Value.Remove(submodelElement); + } + else if (smeParent is AnnotatedRelationshipElement annotatedRelationshipElement) + { + annotatedRelationshipElement.Annotations.Remove((IDataElement)submodelElement); + } + else if (smeParent is Entity entity) + { + entity.Statements.Remove(submodelElement); + } + else if (smeParent is Submodel parentSubmodel) + { + parentSubmodel.SubmodelElements.Remove(submodelElement); + } + else + { + _logger.LogDebug($"Could not delete SubmodelElement {submodelElement.IdShort}"); + throw new Exception($"Unsupported data type of parent {smeParent.IdShort} for delete operation."); + } + } + else + { + throw new NotFoundException($"Requested SubmodelElement NOT found in submodel with Id {submodelIdentifier}"); + } + + Program.signalNewData(1); + _logger.LogDebug($"Deleted SubmodelElement at {idShortPath} from submodel with Id {submodelIdentifier}"); + } + + public List GetAllSubmodelElements(string submodelIdentifier) + { + var submodel = _packageEnvService.GetSubmodelById(submodelIdentifier, out _); + return submodel.SubmodelElements; + } + + + } +} diff --git a/src/AasxServerStandardBib/TimeSeries.cs b/src/AasxServerStandardBib/TimeSeries.cs index 03984509e..f0ba34dc9 100644 --- a/src/AasxServerStandardBib/TimeSeries.cs +++ b/src/AasxServerStandardBib/TimeSeries.cs @@ -1,6 +1,13 @@ +using AasCore.Aas3_0_RC02; +using AasxServer; +using Extensions; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; +using Opc.Ua; +using Org.Webpki.JsonCanonicalizer; +using SampleClient; using System; using System.Collections.Generic; -using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; @@ -8,15 +15,6 @@ using System.Security.Cryptography.X509Certificates; using System.Text; using System.Threading; -using AasCore.Aas3_0_RC02; -using AasxServer; -using AdminShellNS; -using Extenstions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Opc.Ua; -using Org.Webpki.JsonCanonicalizer; -using SampleClient; namespace AasxTimeSeries { diff --git a/src/AasxServerStandardBib/TimeSeriesPlotting.cs b/src/AasxServerStandardBib/TimeSeriesPlotting.cs index eef8a7fbc..d9bb16479 100644 --- a/src/AasxServerStandardBib/TimeSeriesPlotting.cs +++ b/src/AasxServerStandardBib/TimeSeriesPlotting.cs @@ -1,18 +1,13 @@ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Globalization; -using System.IO; -using System.Reflection; -using System.Text; -using AasCore.Aas3_0_RC02; -using AasxServer; +using AasCore.Aas3_0_RC02; using AdminShellNS; -using Extenstions; +using Extensions; using Newtonsoft.Json; using Newtonsoft.Json.Linq; -using QRCoder; using ScottPlot; +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Reflection; //using static AdminShellNS.AdminShellV20; namespace AasxServerStandardBib diff --git a/src/AasxServerStandardBib/i40Language.cs b/src/AasxServerStandardBib/i40Language.cs index f7e604c78..3d954ad38 100644 --- a/src/AasxServerStandardBib/i40Language.cs +++ b/src/AasxServerStandardBib/i40Language.cs @@ -1,16 +1,12 @@ -using System; +using AasCore.Aas3_0_RC02; +using AdminShellNS; +using Extensions; +using Newtonsoft.Json; +using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; using System.Text.RegularExpressions; using System.Threading; -using AasCore.Aas3_0_RC02; -using AdminShellNS; -using Extenstions; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using Newtonsoft.Json.Serialization; -using Opc.Ua.Server; /* Copyright (c) 2019-2020 PHOENIX CONTACT GmbH & Co. KG , author: Andreas Orzelski diff --git a/src/IO.Swagger.Lib.V3/.gitignore b/src/IO.Swagger.Lib.V3/.gitignore new file mode 100644 index 000000000..cd9b840e5 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/.gitignore @@ -0,0 +1,208 @@ +PID + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +bower_components/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt diff --git a/src/IO.Swagger.Lib.V3/Attributes/ValidateModelStateAttribute.cs b/src/IO.Swagger.Lib.V3/Attributes/ValidateModelStateAttribute.cs new file mode 100644 index 000000000..07cfabe83 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Attributes/ValidateModelStateAttribute.cs @@ -0,0 +1,61 @@ +using System.ComponentModel.DataAnnotations; +using System.Reflection; +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.AspNetCore.Mvc.Filters; +using Microsoft.AspNetCore.Mvc.ModelBinding; + +namespace IO.Swagger.Attributes +{ + /// + /// Model state validation attribute + /// + public class ValidateModelStateAttribute : ActionFilterAttribute + { + /// + /// Called before the action method is invoked + /// + /// + public override void OnActionExecuting(ActionExecutingContext context) + { + // Per https://blog.markvincze.com/how-to-validate-action-parameters-with-dataannotation-attributes/ + var descriptor = context.ActionDescriptor as ControllerActionDescriptor; + if (descriptor != null) + { + foreach (var parameter in descriptor.MethodInfo.GetParameters()) + { + object args = null; + if (context.ActionArguments.ContainsKey(parameter.Name)) + { + args = context.ActionArguments[parameter.Name]; + } + + ValidateAttributes(parameter, args, context.ModelState); + } + } + + if (!context.ModelState.IsValid) + { + context.Result = new BadRequestObjectResult(context.ModelState); + } + } + + private void ValidateAttributes(ParameterInfo parameter, object args, ModelStateDictionary modelState) + { + foreach (var attributeData in parameter.CustomAttributes) + { + var attributeInstance = parameter.GetCustomAttribute(attributeData.AttributeType); + + var validationAttribute = attributeInstance as ValidationAttribute; + if (validationAttribute != null) + { + var isValid = validationAttribute.IsValid(args); + if (!isValid) + { + modelState.AddModelError(parameter.Name, validationAttribute.FormatErrorMessage(parameter.Name)); + } + } + } + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs new file mode 100644 index 000000000..a6cd24424 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellRepositoryAPIApi.cs @@ -0,0 +1,1846 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using AasCore.Aas3_0_RC02; +using AasxServerStandardBib.Interfaces; +using AasxServerStandardBib.Logging; +using IO.Swagger.Attributes; +using IO.Swagger.Lib.V3.Interfaces; +using IO.Swagger.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using Swashbuckle.AspNetCore.Annotations; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.IO; +using System.Net.Mime; + +namespace IO.Swagger.Controllers +{ + /// + /// + /// + [ApiController] + public class AssetAdministrationShellRepositoryAPIApiController : ControllerBase + { + private readonly IAppLogger _logger; + private readonly IAssetAdministrationShellService _aasService; + private readonly IBase64UrlDecoderService _decoderService; + private readonly IAasRepositoryApiHelperService _aasRepoApiHelper; + + //Contructor + + public AssetAdministrationShellRepositoryAPIApiController(IAppLogger logger, IAssetAdministrationShellService aasService, IBase64UrlDecoderService decoderService, IAasRepositoryApiHelperService aasRepoApiHelper) + { + _logger = logger; + _aasService = aasService; + _decoderService = decoderService; + _aasRepoApiHelper = aasRepoApiHelper; + } + + /// + /// Deletes an Asset Administration Shell + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// Asset Administration Shell deleted successfully + /// Not Found + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("/shells/{aasIdentifier}")] + [ValidateModelState] + [SwaggerOperation("DeleteAssetAdministrationShellById")] + [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 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 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("DeleteSubmodelElementByPath")] + [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 DeleteSubmodelElementByPath([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); + + _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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpDelete] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("DeleteSubmodelReferenceById")] + [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 DeleteSubmodelReferenceById([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier) + { + 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, decodedSubmodelIdentifier); + + return NoContent(); + } + + /// + /// Returns all Asset Administration Shells + /// + /// A list of specific Asset identifiers + /// The Asset Administration Shell’s IdShort + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// Requested Asset Administration Shells + /// 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("/shells")] + [ValidateModelState] + [SwaggerOperation("GetAllAssetAdministrationShells")] + [SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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? from, [FromQuery]int? size) + { + _logger.LogInformation($"Received the request to get all Asset Administration Shells."); + + List aasList = _aasService.GetAllAssetAdministrationShells(assetIds, idShort); + + return new ObjectResult(aasList); + } + + /// + /// Returns References to all Asset Administration Shells + /// + /// A list of specific Asset identifiers + /// The Asset Administration Shell’s IdShort + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/$reference")] + [ValidateModelState] + [SwaggerOperation("GetAllAssetAdministrationShellsReference")] + [SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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? from, [FromQuery]int? size) + { + _logger.LogInformation($"Received the request to get references of all Asset Administration Shells."); + + var aasList = _aasService.GetAllAssetAdministrationShells(assetIds, idShort); + + //TODO:jtikekar: performance impact due to convertAll + var output = _aasRepoApiHelper.GetAllReferences(aasList.ConvertAll(aas => (IReferable)aas)); + + 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// 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(List), 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: 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? from, [FromQuery]int? size, [FromQuery]string level, [FromQuery]string extent) + { + _logger.LogInformation($"Received request to get all SubmodelElements of the submodel from AAS"); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + var output = _aasService.GetAllSubmodelElements(decodedAasIdentifier, decodedSmIdentifier); + + 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsMetadata")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "List of found submodel elements")] + //[SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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 GetAllSubmodelElementsMetadata([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]int? from, [FromQuery]int? size, [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(List)); + + //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 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 example = null; + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$path")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsPath")] + [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: 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 GetAllSubmodelElementsPath([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]int? from, [FromQuery]int? size, [FromQuery]string level, [FromQuery]string extent) + { + //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(List)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$reference")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsReference")] + [SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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 GetAllSubmodelElementsReference([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]int? from, [FromQuery]int? size, [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(List)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/$value")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsValueOnly")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "List of found submodel elements in their ValueOnly representation")] + //[SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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 GetAllSubmodelElementsValueOnly([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]int? from, [FromQuery]int? size, [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(List)); + + //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 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 example = null; + return new ObjectResult(example); + } + + /// + /// Returns all submodel references + /// + /// The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// Requested submodel references + /// 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("/shells/{aasIdentifier}/submodels")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelReferences")] + [SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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 GetAllSubmodelReferences([FromRoute][Required]string aasIdentifier, [FromQuery]int? from, [FromQuery]int? size) + { + _logger.LogInformation($"Received request to get all submodel references from the AAS."); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + List output = _aasService.GetAllSubmodelReferencesFromAas(decodedAasIdentifier); + + 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. + /// 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: 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) + { + _logger.LogInformation($"Received request to to get the AAS by Id."); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + var output = _aasService.GetAssetAdministrationShellById(decodedAasIdentifier); + + return new ObjectResult(output); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/$reference")] + [ValidateModelState] + [SwaggerOperation("GetAssetAdministrationShellReferenceById")] + [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: 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 GetAssetAdministrationShellReferenceById([FromRoute][Required]string aasIdentifier) + { + _logger.LogInformation($"Received request to get the reference of AAS by Id"); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + var aas = _aasService.GetAssetAdministrationShellById(decodedAasIdentifier); + + var output = _aasRepoApiHelper.GetReference(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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/asset-information")] + [ValidateModelState] + [SwaggerOperation("GetAssetInformation")] + [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: 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 GetAssetInformation([FromRoute][Required]string aasIdentifier) + { + _logger.LogInformation($"Received request to get AssetInformation from the AAS."); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + 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. + /// 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("GetFileByPath")] + [SwaggerResponse(statusCode: 200, type: typeof(string), 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: 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 GetFileByPath([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(string)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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), in this case an operation + /// 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. + /// 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("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: 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 aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromRoute][Required]string handleId, [FromQuery]string content) + { + //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 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 example = null; //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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("GetSubmodel")] + [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: 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 GetSubmodel([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level, [FromQuery]string extent) + { + //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(Submodel)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPath")] + [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: 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 GetSubmodelElementByPath([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]int? from, [FromQuery]int? size, [FromQuery]string level, [FromQuery]string extent) + { + //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(SubmodelElement)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// 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("GetSubmodelElementByPathMetadata")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Requested submodel element")] + //[SwaggerResponse(statusCode: 200, type: typeof(SubmodelElementMetadata), 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: 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 GetSubmodelElementByPathMetadata([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]int? from, [FromQuery]int? size, [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(SubmodelElementMetadata)); + + //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 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 example = null; + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// 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("GetSubmodelElementByPathPath")] + [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: 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 GetSubmodelElementByPathPath([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]int? from, [FromQuery]int? size, [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(string)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Returns the Reference of 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// 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("GetSubmodelElementByPathReference")] + [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: 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 GetSubmodelElementByPathReference([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]int? from, [FromQuery]int? size, [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(Reference)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// 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("GetSubmodelElementByPathValueOnly")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Requested submodel element in its ValueOnly representation")] + //[SwaggerResponse(statusCode: 200, type: typeof(SubmodelElementValue), 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: 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 GetSubmodelElementByPathValueOnly([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]int? from, [FromQuery]int? size, [FromQuery]string level, [FromQuery]string extent) + { + //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(SubmodelElementValue)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelMetadata")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Requested Submodel")] + //[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: 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 GetSubmodelMetadata([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [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(SubmodelMetadata)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// Determines the structural depth of the respective resource content + /// Requested Submodel as a Reference + /// 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("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$reference")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelMetadataReference")] + [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: 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 GetSubmodelMetadataReference([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [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(Reference)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$path")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelPath")] + [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: 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 GetSubmodelPath([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [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(List)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$value")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelValueOnly")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Requested Submodel")] + //[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: 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 GetSubmodelValueOnly([FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level, [FromQuery]string extent) + { + //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(SubmodelValue)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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), in this case an operation + /// Determines whether an operation invocation is performed asynchronously or synchronously + /// Determines the request or response kind of the resource + /// Operation result object + /// 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 + [HttpPost] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/invoke")] + [ValidateModelState] + [SwaggerOperation("InvokeOperation")] + [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: 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 InvokeOperation([FromBody]OperationRequest body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]bool? _async, [FromQuery]string content) + { + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodel")] + [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 PatchSubmodel([FromBody]Submodel body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelElementValueByPath")] + [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 PatchSubmodelElementValueByPath([FromBody]ISubmodelElement body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// 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: 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")] + //TODO: jtikekar json patch + //public virtual IActionResult PatchSubmodelElementValueByPathMetadata([FromBody]SubmodelElementMetadata body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string level) + public virtual IActionResult PatchSubmodelElementValueByPathMetadata([FromBody]ISubmodelElement body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// 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: 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")] + //TODO: jtikekar json patch + //public virtual IActionResult PatchSubmodelElementValueByPathValueOnly([FromBody]SubmodelElementValue body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string level) + public virtual IActionResult PatchSubmodelElementValueByPathValueOnly([FromBody]ISubmodelElement body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$metadata")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelMetadata")] + [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")] + //TODO: jtikekar json patch + //public virtual IActionResult PatchSubmodelMetadata([FromBody]SubmodelMetadata body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level) + public virtual IActionResult PatchSubmodelMetadata([FromBody]Submodel body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPatch] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/$value")] + [ValidateModelState] + [SwaggerOperation("PatchSubmodelValueOnly")] + [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")] + //TODO: jtikekar json patch + //public virtual IActionResult PatchSubmodelValueOnly([FromBody]SubmodelValue body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level) + public virtual IActionResult PatchSubmodelValueOnly([FromBody]Submodel body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// 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: 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) + { + 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) + /// Determines the structural depth of the respective resource content + /// Determines the request or response kind of the resource + /// Determines to which extent the resource is being serialized + /// Submodel element created successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// 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("PostSubmodelElement")] + [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: 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 PostSubmodelElement([FromBody]ISubmodelElement body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level, [FromQuery]string content, [FromQuery]string extent) + { + //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(201, default(SubmodelElement)); + + //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 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 409 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(409, 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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. + /// 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("PostSubmodelElementByPath")] + [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: 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 PostSubmodelElementByPath([FromBody]ISubmodelElement body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath) + { + //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(201, default(SubmodelElement)); + + //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 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 409 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(409, 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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. + /// 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")] + [ValidateModelState] + [SwaggerOperation("PostSubmodelReference")] + [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: 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 PostSubmodelReference([FromBody]Reference body, [FromRoute][Required]string aasIdentifier) + { + _logger.LogInformation($"Received request to add a new Submodel-Reference to the AAS."); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + var output = _aasService.CreateSubmodelReferenceInAAS(body, decodedAasIdentifier); + + return CreatedAtAction("PostSubmodelReference", 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. + /// 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: 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) + { + _logger.LogInformation($"Received a request to update the AAS."); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + _aasService.UpdateAssetAdministrationShellById(body, decodedAasIdentifier); + + return NoContent(); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("/shells/{aasIdentifier}/asset-information")] + [ValidateModelState] + [SwaggerOperation("PutAssetInformation")] + [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 PutAssetInformation([FromBody]AssetInformation body, [FromRoute][Required]string aasIdentifier) + { + _logger.LogInformation("Received request to update the AssetInformation"); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + _aasService.UpdateAssetInformation(body, decodedAasIdentifier); + + return NoContent(); + } + + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}")] + [ValidateModelState] + [SwaggerOperation("PutSubmodel")] + [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 PutSubmodel([FromBody]Submodel body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpPut] + [Route("/shells/{aasIdentifier}/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("PutSubmodelElementByPath")] + [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 PutSubmodelElementByPath([FromBody]ISubmodelElement body, [FromRoute][Required]string aasIdentifier, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// + /// + /// 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. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/shells/{aasIdentifier}/asset-information/thumbnail")] + [ValidateModelState] + //[SwaggerOperation("ShellsAasIdentifierAssetInformationThumbnailGet")] + [SwaggerOperation("GetThumbnail")] + [SwaggerResponse(statusCode: 200, type: typeof(string), 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: 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 ShellsAasIdentifierAssetInformationThumbnailGet([FromRoute][Required]string aasIdentifier) + public virtual IActionResult GetThumbnail([FromRoute][Required]string aasIdentifier) + { + _logger.LogInformation($"Received request to get AssetInformation-Thumbnail from AAS."); + + var decodedAasIdentifier = _decoderService.Decode("aasIdentifier", aasIdentifier); + + var fileName = _aasService.GetThumbnail(decodedAasIdentifier, out byte[] content, out long fileSize); + + //content-disposition so that the aasx file can be doenloaded from the web browser. + ContentDisposition contentDisposition = new() + { + FileName = fileName + }; + + HttpContext.Response.Headers.Add("Content-Disposition", contentDisposition.ToString()); + HttpContext.Response.ContentLength = fileSize; + HttpContext.Response.Body.WriteAsync(content); + return new EmptyResult(); + } + + /// + /// 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); + + var stream = new MemoryStream(); + file.CopyTo(stream); + string fileName = file.FileName; + string contentType = file.ContentType; + + _aasService.UpdateThumbnail(decodedAasIdentifier, fileName, contentType, stream); + return NoContent(); + } + + } +} diff --git a/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellSerializationAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellSerializationAPIApi.cs new file mode 100644 index 000000000..22d699ee2 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Controllers/AssetAdministrationShellSerializationAPIApi.cs @@ -0,0 +1,75 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * 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 Microsoft.AspNetCore.Authorization; +using IO.Swagger.Models; + +namespace IO.Swagger.Controllers +{ + /// + /// + /// + [ApiController] + public class AssetAdministrationShellSerializationAPIApiController : ControllerBase + { + /// + /// 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. + /// 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: 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][Required()]List aasIds, [FromQuery][Required()]List submodelIds, [FromQuery][Required()]bool? includeConceptDescriptions) + { + //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(byte[])); + + //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 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 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 + ? JsonConvert.DeserializeObject(exampleJson) + : default(byte[]); //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs new file mode 100644 index 000000000..3e4350e1b --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Controllers/ConceptDescriptionRepositoryAPIApi.cs @@ -0,0 +1,201 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using AasCore.Aas3_0_RC02; +using AasxServerStandardBib.Interfaces; +using AasxServerStandardBib.Logging; +using IO.Swagger.Attributes; +using IO.Swagger.Lib.V3.Interfaces; +using IO.Swagger.Lib.V3.Services; +using IO.Swagger.Models; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using Swashbuckle.AspNetCore.Annotations; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace IO.Swagger.Controllers +{ + /// + /// + /// + [ApiController] + public class ConceptDescriptionRepositoryAPIApiController : ControllerBase + { + private readonly IAppLogger _logger; + private readonly IConceptDescriptionService _cdService; + private readonly IBase64UrlDecoderService _decoderService; + private readonly IJsonQueryDeserializer _jsonQueryDeserializer; + + public ConceptDescriptionRepositoryAPIApiController(IAppLogger logger, IConceptDescriptionService cdService, IBase64UrlDecoderService decoderService, IJsonQueryDeserializer jsonQueryDeserializer) + { + _logger = logger; + _cdService = cdService; + _decoderService = decoderService; + _jsonQueryDeserializer = jsonQueryDeserializer; + } + /// + /// 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) + { + _logger.LogInformation($"Received request to delete the concept description"); + + var decodedCdIdentifier = _decoderService.Decode("cdIdentifier", cdIdentifier); + + _cdService.DeleteConceptDescriptionById(decodedCdIdentifier); + + return NoContent(); + } + + /// + /// Returns all Concept Descriptions + /// + /// The Concept Description’s IdShort + /// IsCaseOf reference (UTF8-BASE64-URL-encoded) + /// DataSpecification reference (UTF8-BASE64-URL-encoded) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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? from, [FromQuery]int? size) + { + _logger.LogInformation($"Received request to get all the concept descriptions."); + + var reqIsCaseOf = _jsonQueryDeserializer.DeserializeReference("isCaseOf", isCaseOf); + + var reqDataSpecificationRef = _jsonQueryDeserializer.DeserializeReference("dataSpecificationRef", dataSpecificationRef); + + var output = _cdService.GetAllConceptDescriptions(idShort, reqIsCaseOf, reqDataSpecificationRef); + + //TODO: jtikekar pagination + 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) + { + _logger.LogInformation("Received request to get concept description."); + + var decodedCdIdentifier = _decoderService.Decode("cdIdentifier", cdIdentifier); + + var output = _cdService.GetConceptDescriptionById(decodedCdIdentifier); + + 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) + { + _logger.LogInformation($"Received request to create a concept description."); + + var output = _cdService.CreateConceptDescription(body); + + return CreatedAtAction("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) + { + _logger.LogInformation("Received request to get concept description."); + + var decodedCdIdentifier = _decoderService.Decode("cdIdentifier", cdIdentifier); + + _cdService.UpdateConceptDescriptionById(body, decodedCdIdentifier); + + return NoContent(); + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Controllers/DescriptionAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/DescriptionAPIApi.cs new file mode 100644 index 000000000..8dcc75d12 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Controllers/DescriptionAPIApi.cs @@ -0,0 +1,57 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * 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 Microsoft.AspNetCore.Authorization; +using IO.Swagger.Models; + +namespace IO.Swagger.Controllers +{ + /// + /// + /// + [ApiController] + public class DescriptionAPIApiController : ControllerBase + { + /// + /// Returns the self-describing information of a network resource (Description) + /// + /// Requested Description + /// Forbidden + [HttpGet] + [Route("/description")] + [ValidateModelState] + [SwaggerOperation("GetDescription")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested Description")] + [SwaggerResponse(statusCode: 403, type: typeof(Result), description: "Forbidden")] + public virtual IActionResult GetDescription() + { + //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(List)); + + //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)); + string exampleJson = null; + exampleJson = "[ \"{\n \"profiles\": [\n \"RepositoryServiceSpecification/V3.0-MinimalProfile\",\n \"RegistryServiceSpecification/V3.0\"\n ]\n}\", \"{\n \"profiles\": [\n \"RepositoryServiceSpecification/V3.0-MinimalProfile\",\n \"RegistryServiceSpecification/V3.0\"\n ]\n}\" ]"; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject>(exampleJson) + : default(List); //TODO: Change the data returned + return new ObjectResult(example); + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs b/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs new file mode 100644 index 000000000..df9bc4125 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Controllers/SubmodelRepositoryAPIApi.cs @@ -0,0 +1,1708 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using AasCore.Aas3_0_RC02; +using AasxServerStandardBib.Interfaces; +using AasxServerStandardBib.Logging; +using IO.Swagger.Attributes; +using IO.Swagger.Lib.V3.Interfaces; +using IO.Swagger.Models; +using Microsoft.AspNetCore.Mvc; +using MQTTnet.Adapter; +using Newtonsoft.Json; +using Swashbuckle.AspNetCore.Annotations; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace IO.Swagger.Controllers +{ + /// + /// + /// + [ApiController] + public class SubmodelRepositoryAPIApiController : ControllerBase + { + private readonly IAppLogger _logger; + private readonly ISubmodelService _submodelService; + private readonly IBase64UrlDecoderService _decoderService; + + public SubmodelRepositoryAPIApiController(IAppLogger logger, ISubmodelService submodelService, IBase64UrlDecoderService decoderService) + { + _logger = logger; + _submodelService = submodelService; + _decoderService = decoderService; + } + + /// + /// 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. + /// 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: 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) + { + _logger.LogInformation($"Received request to delete the submodel."); + + var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _submodelService.DeleteSubmodelById(decodedSmIdentifier); + + 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. + /// 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: 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) + { + _logger.LogInformation($"Received request to delete SubmodelElement from Submodel."); + + var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + _submodelService.DeleteSubmodelElementByPath(decodedSmIdentifier, idShortPath); + + return NoContent(); + } + + /// + /// Returns all submodel elements including their hierarchy + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// Determines the structural depth of the respective resource content + /// Determines to which extent the resource is being serialized + /// List of found submodel elements + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/{submodelIdentifier}/submodel-elements")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElements")] + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "List of found submodel elements")] + [SwaggerResponse(statusCode: 0, type: typeof(Result), description: "Default error handling for unmentioned status codes")] + public virtual IActionResult GetAllSubmodelElements([FromRoute][Required]string submodelIdentifier, [FromQuery]int? from, [FromQuery]int? size, [FromQuery]LevelEnum level, [FromQuery]ExtentEnum extent) + { + _logger.LogInformation($"Received request to get all the SubmodelElements from submodel."); + + var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + var output = _submodelService.GetAllSubmodelElements(decodedSmIdentifier); + + //TODO:jtikekar pagination + return new ObjectResult(output); + } + + /// + /// Returns the metadata attributes of all submodel elements including their hierarchy + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/{submodelIdentifier}/submodel-elements/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsMetadataSubmodelRepo")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "List of found submodel elements")] + //[SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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? from, [FromQuery]int? size, [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(List)); + + //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 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 example = null; + return new ObjectResult(example); + } + + /// + /// Returns all submodel elements including their hierarchy in the Path notation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// Determines the structural depth of the respective resource content + /// 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. + /// 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: 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? from, [FromQuery]int? size, [FromQuery]string level) + { + _logger.LogInformation($"Received request to get all the SubmodelElements from submodel."); + + var decodedSmIdentifier = _decoderService.Decode("submodelIdentifier", submodelIdentifier); + + //TODO: jtikekar implement + return new ObjectResult(decodedSmIdentifier); + } + + /// + /// Returns the References of all submodel elements + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// 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(List), 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: 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? from, [FromQuery]int? size, [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(List)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Returns all submodel elements including their hierarchy in the ValueOnly representation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/{submodelIdentifier}/submodel-elements/$value")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelElementsValueOnlySubmodelRepo")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "List of found submodel elements")] + //[SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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? from, [FromQuery]int? size, [FromQuery]string level, [FromQuery]string extent) + { + //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(List)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Returns all Submodels + /// + /// The value of the semantic id reference (BASE64-URL-encoded) + /// The Submodel’s idShort + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodels")] + [SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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] [MaxLength(3072)]string semanticId, [FromQuery]string idShort, [FromQuery]int? from, [FromQuery]int? size, [FromQuery]string level, [FromQuery]string extent) + { + //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(List)); + + //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 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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Returns the metadata attributes of all Submodels + /// + /// The value of the semantic id reference (BASE64-URL-encoded) + /// The Submodel’s idShort + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelsMetadata")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested Submodels")] + //[SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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] [MaxLength(3072)]string semanticId, [FromQuery]string idShort, [FromQuery]int? from, [FromQuery]int? size, [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(List)); + + //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 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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Returns all Submodels in the Path notation + /// + /// The value of the semantic id reference (BASE64-URL-encoded) + /// The Submodel’s idShort + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/$path")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelsPath")] + [SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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] [MaxLength(3072)]string semanticId, [FromQuery]string idShort, [FromQuery]int? from, [FromQuery]int? size, [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(List)); + + //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 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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Returns the References for all Submodels + /// + /// The value of the semantic id reference (BASE64-URL-encoded) + /// The Submodel’s idShort + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/$reference")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelsReference")] + [SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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] [MaxLength(3072)]string semanticId, [FromQuery]string idShort, [FromQuery]int? from, [FromQuery]int? size, [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(List)); + + //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 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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Returns all Submodels in their ValueOnly representation + /// + /// The value of the semantic id reference (BASE64-URL-encoded) + /// The Submodel’s idShort + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/$value")] + [ValidateModelState] + [SwaggerOperation("GetAllSubmodelsValueOnly")] + //TODO: jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(List), description: "Requested Submodels")] + //[SwaggerResponse(statusCode: 200, type: typeof(List), 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: 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] [MaxLength(3072)]string semanticId, [FromQuery]string idShort, [FromQuery]int? from, [FromQuery]int? size, [FromQuery]string level, [FromQuery]string extent) + { + //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(List)); + + //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 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 example = null; + return new ObjectResult(example); + } + + /// + /// 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. + /// 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(string), 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: 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 IActionResult GetFileByPathSubmodelRepo([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(string)); + + //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 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)); + string exampleJson = null; + exampleJson = "\"\""; + + var example = exampleJson != null + ? JsonConvert.DeserializeObject(exampleJson) + : default(string); //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Returns the Operation result of an asynchronous invoked Operation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated), in this case an operation + /// 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. + /// 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("GetOperationAsyncResultSubmodelRepo")] + [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: 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 GetOperationAsyncResultSubmodelRepo([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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Returns the Operation result of an asynchronous invoked Operation + /// + /// The Submodel’s unique id (UTF8-BASE64-URL-encoded) + /// IdShort path to the submodel element (dot-separated), in this case an operation + /// 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. + /// 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("GetOperationAsyncResultValueOnlySubmodelRepo")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Value of the operation result object")] + //[SwaggerResponse(statusCode: 200, type: typeof(OperationResultValueOnly), 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: 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 GetOperationAsyncResultValueOnlySubmodelRepo([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(OperationResultValueOnly)); + + //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 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 example = null; + return new ObjectResult(example); + } + + /// + /// 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. + /// 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: 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) + { + //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(Submodel)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/{submodelIdentifier}/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdMetadata")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Requested Submodel in the metadata representation")] + //[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: 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]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(SubmodelMetadata)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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. + /// 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: 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) + { + //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(List)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Returns the Reference of a specific Submodel + /// + /// 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. + /// 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: 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, [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(Reference)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/{submodelIdentifier}/$value")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelByIdValueOnly")] + //TODO: jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Requested Submodel")] + //[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: 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) + { + //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(SubmodelValue)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$metadata")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathMetadataSubmodelRepo")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Metadata attributes of the requested submodel element")] + //[SwaggerResponse(statusCode: 200, type: typeof(SubmodelElementMetadata), 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: 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]int? from, [FromQuery]int? size, [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(SubmodelElementMetadata)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// 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: 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]int? from, [FromQuery]int? size, [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(List)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// 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: 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]int? from, [FromQuery]int? size, [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(Reference)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathSubmodelRepo")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Requested submodel element")] + //[SwaggerResponse(statusCode: 200, type: typeof(SubmodelElement), 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: 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]int? from, [FromQuery]int? size, [FromQuery]string level, [FromQuery]string extent) + { + //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(SubmodelElement)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// A non-negative number defining the offset item. + /// The maximum number of elements in the response array. + /// 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. + /// Forbidden + /// Not Found + /// Internal Server Error + /// Default error handling for unmentioned status codes + [HttpGet] + [Route("/submodels/{submodelIdentifier}/submodel-elements/{idShortPath}/$value")] + [ValidateModelState] + [SwaggerOperation("GetSubmodelElementByPathValueOnlySubmodelRepo")] + //TODO:jtikekar replace object + [SwaggerResponse(statusCode: 200, type: typeof(object), description: "Requested submodel element")] + //[SwaggerResponse(statusCode: 200, type: typeof(SubmodelElementValue), 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: 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]int? from, [FromQuery]int? size, [FromQuery]string level, [FromQuery]string extent) + { + //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(SubmodelElementValue)); + + //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 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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), in this case an operation + /// Determines whether an operation invocation is performed asynchronously or synchronously + /// Determines the request or response kind of the resource + /// Operation result object + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// 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: 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, [FromQuery]string content) + { + //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 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)); + string example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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. + /// 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: 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) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// 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: 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")] + //TODO: jtikekar json patch + //public virtual IActionResult PatchSubmodelByIdMetadata([FromBody]SubmodelMetadata body, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level) + public virtual IActionResult PatchSubmodelByIdMetadata([FromBody]Submodel body, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// 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: 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")] + //TODO:jtikekar json patch + //public virtual IActionResult PatchSubmodelByIdValueOnly([FromBody]SubmodelValue body, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level) + public virtual IActionResult PatchSubmodelByIdValueOnly([FromBody]Submodel body, [FromRoute][Required]string submodelIdentifier, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// 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: 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")] + //TODO:jtikekar json patch + //public virtual IActionResult PatchSubmodelElementByPathMetadataSubmodelRepo([FromBody]SubmodelElementMetadata body, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string level) + public virtual IActionResult PatchSubmodelElementByPathMetadataSubmodelRepo([FromBody]ISubmodelElement body, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// 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: 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")] + //TODO:jtikekar json patch + //public virtual IActionResult PatchSubmodelElementByPathSubmodelRepo([FromBody]SubmodelElement body, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string level) + public virtual IActionResult PatchSubmodelElementByPathSubmodelRepo([FromBody]ISubmodelElement body, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// 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: 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")] + //TODO:jtikekar json patch + //public virtual IActionResult PatchSubmodelElementByPathValueOnlySubmodelRepo([FromBody]SubmodelElementValue body, [FromRoute][Required]string submodelIdentifier, [FromRoute][Required]string idShortPath, [FromQuery]string level) + public virtual IActionResult PatchSubmodelElementByPathValueOnlySubmodelRepo([FromBody] ISubmodelElement body, [FromRoute][Required] string submodelIdentifier, [FromRoute][Required] string idShortPath, [FromQuery] string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// Creates a new Submodel + /// + /// Submodel object + /// Submodel 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("/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: 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) + { + //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(201, default(Submodel)); + + //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 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 409 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(409, 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// 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) + /// Determines the structural depth of the respective resource content + /// Determines the request or response kind of the resource + /// Determines to which extent the resource is being serialized + /// Submodel element created successfully + /// Bad Request, e.g. the request parameters of the format of the request body is wrong. + /// 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: 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, [FromQuery]string level, [FromQuery]string content, [FromQuery]string extent) + { + //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(201, default(SubmodelElement)); + + //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 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 409 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(409, 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + /// + /// Creates a new submodel element + /// + /// Requested submodel element + /// 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. + /// 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: 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) + { + //TODO: Uncomment the next line to return response 201 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(201, default(SubmodelElement)); + + //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 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 409 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(409, 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 example = null; //TODO: Change the data returned + return new ObjectResult(example); + } + + + /// + /// 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. + /// 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: 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, [FromQuery]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + + /// + /// 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. + /// 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: 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]string level) + { + //TODO: Uncomment the next line to return response 204 or use other options such as return this.NotFound(), return this.BadRequest(..), ... + // return StatusCode(204); + + //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 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(); + } + } +} diff --git a/src/AasxServerStandardBib/Exceptions/Base64UrlDecoderException.cs b/src/IO.Swagger.Lib.V3/Exceptions/Base64UrlDecoderException.cs similarity index 88% rename from src/AasxServerStandardBib/Exceptions/Base64UrlDecoderException.cs rename to src/IO.Swagger.Lib.V3/Exceptions/Base64UrlDecoderException.cs index d4970d1cc..8052821ce 100644 --- a/src/AasxServerStandardBib/Exceptions/Base64UrlDecoderException.cs +++ b/src/IO.Swagger.Lib.V3/Exceptions/Base64UrlDecoderException.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AasxServerStandardBib.Exceptions +namespace IO.Swagger.Lib.V3.Exceptions { public class Base64UrlDecoderException : Exception { diff --git a/src/AasxServerStandardBib/Exceptions/InvalidNumberOfChildElements.cs b/src/IO.Swagger.Lib.V3/Exceptions/InvalidNumberOfChildElements.cs similarity index 92% rename from src/AasxServerStandardBib/Exceptions/InvalidNumberOfChildElements.cs rename to src/IO.Swagger.Lib.V3/Exceptions/InvalidNumberOfChildElements.cs index 58f7c61fd..369e1f651 100644 --- a/src/AasxServerStandardBib/Exceptions/InvalidNumberOfChildElements.cs +++ b/src/IO.Swagger.Lib.V3/Exceptions/InvalidNumberOfChildElements.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AasxServerStandardBib.Exceptions +namespace IO.Swagger.Lib.V3.Exceptions { //TODO: jtikekar change name public class InvalidNumberOfChildElementsException : Exception diff --git a/src/IO.Swagger.Lib.V3/Exceptions/InvalidSerializationModifierException.cs b/src/IO.Swagger.Lib.V3/Exceptions/InvalidSerializationModifierException.cs new file mode 100644 index 000000000..92d66af57 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Exceptions/InvalidSerializationModifierException.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IO.Swagger.Lib.V3.Exceptions +{ + //TODO:jtikekar Move to API project + public class InvalidSerializationModifierException : Exception + { + public InvalidSerializationModifierException(string modifier, string type) : base($"Invalid serialization modifier {modifier} for the requested element of type {type}.") + { + + } + } +} diff --git a/src/AasxServerStandardBib/Exceptions/JsonDeserializationException.cs b/src/IO.Swagger.Lib.V3/Exceptions/JsonDeserializationException.cs similarity index 89% rename from src/AasxServerStandardBib/Exceptions/JsonDeserializationException.cs rename to src/IO.Swagger.Lib.V3/Exceptions/JsonDeserializationException.cs index 53c2ddc68..40c2f2ef2 100644 --- a/src/AasxServerStandardBib/Exceptions/JsonDeserializationException.cs +++ b/src/IO.Swagger.Lib.V3/Exceptions/JsonDeserializationException.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AasxServerStandardBib.Exceptions +namespace IO.Swagger.Lib.V3.Exceptions { public class JsonDeserializationException : Exception { diff --git a/src/AasxServerStandardBib/Exceptions/NoIdentifierException.cs b/src/IO.Swagger.Lib.V3/Exceptions/NoIdentifierException.cs similarity index 87% rename from src/AasxServerStandardBib/Exceptions/NoIdentifierException.cs rename to src/IO.Swagger.Lib.V3/Exceptions/NoIdentifierException.cs index aec692d92..c13fd3cf3 100644 --- a/src/AasxServerStandardBib/Exceptions/NoIdentifierException.cs +++ b/src/IO.Swagger.Lib.V3/Exceptions/NoIdentifierException.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AasxServerStandardBib.Exceptions +namespace IO.Swagger.Lib.V3.Exceptions { public class NoIdentifierException : Exception { diff --git a/src/AasxServerStandardBib/Exceptions/NotAllowed.cs b/src/IO.Swagger.Lib.V3/Exceptions/NotAllowed.cs similarity index 85% rename from src/AasxServerStandardBib/Exceptions/NotAllowed.cs rename to src/IO.Swagger.Lib.V3/Exceptions/NotAllowed.cs index bb5f871d5..d66660214 100644 --- a/src/AasxServerStandardBib/Exceptions/NotAllowed.cs +++ b/src/IO.Swagger.Lib.V3/Exceptions/NotAllowed.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AasxServerStandardBib.Exceptions +namespace IO.Swagger.Lib.V3.Exceptions { public class NotAllowed : Exception { diff --git a/src/AasxServerStandardBib/Exceptions/NotImplementedException.cs b/src/IO.Swagger.Lib.V3/Exceptions/NotImplementedException.cs similarity index 86% rename from src/AasxServerStandardBib/Exceptions/NotImplementedException.cs rename to src/IO.Swagger.Lib.V3/Exceptions/NotImplementedException.cs index f1a0366f2..e219275ad 100644 --- a/src/AasxServerStandardBib/Exceptions/NotImplementedException.cs +++ b/src/IO.Swagger.Lib.V3/Exceptions/NotImplementedException.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AasxServerStandardBib.Exceptions +namespace IO.Swagger.Lib.V3.Exceptions { internal class NotImplementedException :Exception { diff --git a/src/AasxServerStandardBib/Exceptions/OperationVariableException.cs b/src/IO.Swagger.Lib.V3/Exceptions/OperationVariableException.cs similarity index 86% rename from src/AasxServerStandardBib/Exceptions/OperationVariableException.cs rename to src/IO.Swagger.Lib.V3/Exceptions/OperationVariableException.cs index a9bf523f7..326024ea2 100644 --- a/src/AasxServerStandardBib/Exceptions/OperationVariableException.cs +++ b/src/IO.Swagger.Lib.V3/Exceptions/OperationVariableException.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AasxServerStandardBib.Exceptions +namespace IO.Swagger.Lib.V3.Exceptions { public class OperationVariableException : Exception { diff --git a/src/AasxServerStandardBib/Exceptions/UnprocessableEntityException.cs b/src/IO.Swagger.Lib.V3/Exceptions/UnprocessableEntityException.cs similarity index 87% rename from src/AasxServerStandardBib/Exceptions/UnprocessableEntityException.cs rename to src/IO.Swagger.Lib.V3/Exceptions/UnprocessableEntityException.cs index c6c00d2c0..65c286784 100644 --- a/src/AasxServerStandardBib/Exceptions/UnprocessableEntityException.cs +++ b/src/IO.Swagger.Lib.V3/Exceptions/UnprocessableEntityException.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AasxServerStandardBib.Exceptions +namespace IO.Swagger.Lib.V3.Exceptions { public class UnprocessableEntityException : Exception { diff --git a/src/IO.Swagger.Lib.V3/Filters/BasePathFilter.cs b/src/IO.Swagger.Lib.V3/Filters/BasePathFilter.cs new file mode 100644 index 000000000..c9d95d6d1 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Filters/BasePathFilter.cs @@ -0,0 +1,51 @@ +using System.Linq; +using System.Text.RegularExpressions; +using Swashbuckle.AspNetCore.Swagger; +using Swashbuckle.AspNetCore.SwaggerGen; +using Microsoft.OpenApi.Models; + +namespace IO.Swagger.Filters +{ + /// + /// BasePath Document Filter sets BasePath property of Swagger and removes it from the individual URL paths + /// + public class BasePathFilter : IDocumentFilter + { + /// + /// Constructor + /// + /// BasePath to remove from Operations + public BasePathFilter(string basePath) + { + BasePath = basePath; + } + + /// + /// Gets the BasePath of the Swagger Doc + /// + /// The BasePath of the Swagger Doc + public string BasePath { get; } + + /// + /// Apply the filter + /// + /// OpenApiDocument + /// FilterContext + public void Apply(OpenApiDocument swaggerDoc, DocumentFilterContext context) + { + swaggerDoc.Servers.Add(new OpenApiServer() { Url = this.BasePath }); + + var pathsToModify = swaggerDoc.Paths.Where(p => p.Key.StartsWith(this.BasePath)).ToList(); + + foreach (var path in pathsToModify) + { + if (path.Key.StartsWith(this.BasePath)) + { + string newKey = Regex.Replace(path.Key, $"^{this.BasePath}", string.Empty); + swaggerDoc.Paths.Remove(path.Key); + swaggerDoc.Paths.Add(newKey, path.Value); + } + } + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Filters/GeneratePathParamsValidationFilter.cs b/src/IO.Swagger.Lib.V3/Filters/GeneratePathParamsValidationFilter.cs new file mode 100644 index 000000000..1845e56ac --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Filters/GeneratePathParamsValidationFilter.cs @@ -0,0 +1,96 @@ +using System.ComponentModel.DataAnnotations; +using System.Linq; +using Microsoft.AspNetCore.Mvc.Controllers; +using Microsoft.OpenApi.Models; +using Swashbuckle.AspNetCore.SwaggerGen; + +namespace IO.Swagger.Filters +{ + /// + /// Path Parameter Validation Rules Filter + /// + public class GeneratePathParamsValidationFilter : IOperationFilter + { + /// + /// Constructor + /// + /// Operation + /// OperationFilterContext + public void Apply(OpenApiOperation operation, OperationFilterContext context) + { + var pars = context.ApiDescription.ParameterDescriptions; + + foreach (var par in pars) + { + var swaggerParam = operation.Parameters.SingleOrDefault(p => p.Name == par.Name); + + var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes; + + if (attributes != null && attributes.Count() > 0 && swaggerParam != null) + { + // Required - [Required] + var requiredAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RequiredAttribute)); + if (requiredAttr != null) + { + swaggerParam.Required = true; + } + + // Regex Pattern [RegularExpression] + var regexAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RegularExpressionAttribute)); + if (regexAttr != null) + { + string regex = (string)regexAttr.ConstructorArguments[0].Value; + if (swaggerParam is OpenApiParameter) + { + ((OpenApiParameter)swaggerParam).Schema.Pattern = regex; + } + } + + // String Length [StringLength] + int? minLenght = null, maxLength = null; + var stringLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(StringLengthAttribute)); + if (stringLengthAttr != null) + { + if (stringLengthAttr.NamedArguments.Count == 1) + { + minLenght = (int)stringLengthAttr.NamedArguments.Single(p => p.MemberName == "MinimumLength").TypedValue.Value; + } + maxLength = (int)stringLengthAttr.ConstructorArguments[0].Value; + } + + var minLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MinLengthAttribute)); + if (minLengthAttr != null) + { + minLenght = (int)minLengthAttr.ConstructorArguments[0].Value; + } + + var maxLengthAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(MaxLengthAttribute)); + if (maxLengthAttr != null) + { + maxLength = (int)maxLengthAttr.ConstructorArguments[0].Value; + } + + if (swaggerParam is OpenApiParameter) + { + ((OpenApiParameter)swaggerParam).Schema.MinLength = minLenght; + ((OpenApiParameter)swaggerParam).Schema.MaxLength = maxLength; + } + + // Range [Range] + var rangeAttr = attributes.FirstOrDefault(p => p.AttributeType == typeof(RangeAttribute)); + if (rangeAttr != null) + { + int rangeMin = (int)rangeAttr.ConstructorArguments[0].Value; + int rangeMax = (int)rangeAttr.ConstructorArguments[1].Value; + + if (swaggerParam is OpenApiParameter) + { + ((OpenApiParameter)swaggerParam).Schema.Minimum = rangeMin; + ((OpenApiParameter)swaggerParam).Schema.Maximum = rangeMax; + } + } + } + } + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs b/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs new file mode 100644 index 000000000..a0a0202a5 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Formatters/AasRequestFormatter.cs @@ -0,0 +1,70 @@ +using AasCore.Aas3_0_RC02; +using Microsoft.AspNetCore.Mvc.Formatters; +using Microsoft.Net.Http.Headers; +using System; +using System.Text.Json.Nodes; +using System.Threading.Tasks; + +namespace IO.Swagger.Lib.V3.Formatters +{ + public class AasRequestFormatter : InputFormatter + { + public AasRequestFormatter() + { + this.SupportedMediaTypes.Clear(); + this.SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json")); + } + + public override bool CanRead(InputFormatterContext context) + { + if (typeof(IClass).IsAssignableFrom(context.ModelType)) + { + return true; + } + else + { + return false; + } + } + + public override Task ReadRequestBodyAsync(InputFormatterContext context) + { + Type type = context.ModelType; + var request = context.HttpContext.Request; + object result = null; + + JsonNode node = System.Text.Json.JsonSerializer.DeserializeAsync(request.Body).Result; + + if (type == typeof(Submodel)) + { + result = Jsonization.Deserialize.SubmodelFrom(node); + } + else if (type == typeof(AssetAdministrationShell)) + { + result = Jsonization.Deserialize.AssetAdministrationShellFrom(node); + } + else if (type == typeof(SpecificAssetId)) + { + result = Jsonization.Deserialize.SpecificAssetIdFrom(node); + } + else if (type == typeof(ISubmodelElement)) + { + result = Jsonization.Deserialize.ISubmodelElementFrom(node); + } + else if (type == typeof(Reference)) + { + result = Jsonization.Deserialize.ReferenceFrom(node); + } + else if (type == typeof(ConceptDescription)) + { + result = Jsonization.Deserialize.ConceptDescriptionFrom(node); + } + else if (type == typeof(AssetInformation)) + { + result = Jsonization.Deserialize.AssetInformationFrom(node); + } + return InputFormatterResult.SuccessAsync(result); + + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs b/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs new file mode 100644 index 000000000..52c247a41 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Formatters/AasResponseFormatter.cs @@ -0,0 +1,116 @@ +using AasCore.Aas3_0_RC02; +using IO.Swagger.Lib.V3.SerializationModifiers; +using IO.Swagger.Models; +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.Formatters; +using Microsoft.Extensions.Primitives; +using Microsoft.Net.Http.Headers; +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Text.Json.Nodes; +using System.Threading.Tasks; + +namespace IO.Swagger.Lib.V3.Formatters +{ + public class AasResponseFormatter : OutputFormatter + { + public AasResponseFormatter() + { + this.SupportedMediaTypes.Clear(); + this.SupportedMediaTypes.Add(MediaTypeHeaderValue.Parse("application/json")); + } + public static bool IsGenericListOfIClass(object o) + { + var oType = o.GetType(); + return oType.IsGenericType && + (oType.GetGenericTypeDefinition() == typeof(List<>) && + (typeof(IClass).IsAssignableFrom(oType.GetGenericArguments()[0]))); + } + + public override bool CanWriteResult(OutputFormatterCanWriteContext context) + { + if (typeof(IClass).IsAssignableFrom(context.ObjectType)) + { + return base.CanWriteResult(context); + } + if (IsGenericListOfIClass(context.Object)) + { + return base.CanWriteResult(context); + } + else + return false; + } + public override Task WriteResponseBodyAsync(OutputFormatterWriteContext context) + { + var response = context.HttpContext.Response; + + //SerializationModifier + GetSerializationMidifiersFromRequest(context.HttpContext.Request, out LevelEnum level, out ExtentEnum extent); + + + if (typeof(IClass).IsAssignableFrom(context.ObjectType)) + { + //Validate modifiers + SerializationModifiersValidator.Validate((IClass)context.Object, level, extent); + + JsonObject json = Jsonization.Serialize.ToJsonObject((IClass)context.Object); + var writer = new Utf8JsonWriter(response.Body); + json.WriteTo(writer); + writer.FlushAsync().GetAwaiter().GetResult(); + } + else if(IsGenericListOfIClass(context.Object)) + { + + var jsonArray = new JsonArray(); + IList genericList = (IList)context.Object; + List contextObjectType = new List(); + foreach (var generic in genericList) + { + contextObjectType.Add((IClass)generic); + } + + //Validate Modifiers + SerializationModifiersValidator.Validate(contextObjectType, level, extent); + var modifierContext = new SerializationModifierContext(level, extent); + + foreach (var item in contextObjectType) + { + //var json = Jsonization.Serialize.ToJsonObject(item); + var json = LevelExtentSerializer.ToJsonObject(item, modifierContext); + jsonArray.Add(json); + } + var writer = new Utf8JsonWriter(response.Body); + jsonArray.WriteTo(writer); + writer.FlushAsync().GetAwaiter().GetResult(); + } + + return Task.FromResult(response); + } + + private void GetSerializationMidifiersFromRequest(HttpRequest request, out LevelEnum level, out ExtentEnum extent) + { + request.Query.TryGetValue("level", out StringValues levelValues); + if(levelValues.Any()) + { + Enum.TryParse(levelValues.First(), out level); + } + else + { + level = LevelEnum.Deep; + } + + request.Query.TryGetValue("extent", out StringValues extenValues); + if(extenValues.Any()) + { + Enum.TryParse(extenValues.First(), out extent); + } + else + { + extent = ExtentEnum.WithoutBlobValue; + } + } + } +} diff --git a/src/IO.Swagger.Lib.V3/IO.Swagger.Lib.V3.csproj b/src/IO.Swagger.Lib.V3/IO.Swagger.Lib.V3.csproj new file mode 100644 index 000000000..0d5cf9447 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/IO.Swagger.Lib.V3.csproj @@ -0,0 +1,25 @@ + + + IO.Swagger + IO.Swagger + net6.0 + true + true + IO.Swagger.Lib.V3 + IO.Swagger + Library + + + + + + + + + + + + + + + diff --git a/src/IO.Swagger.Lib.V3/Interfaces/IAasRepositoryApiHelperService.cs b/src/IO.Swagger.Lib.V3/Interfaces/IAasRepositoryApiHelperService.cs new file mode 100644 index 000000000..219d7f765 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Interfaces/IAasRepositoryApiHelperService.cs @@ -0,0 +1,11 @@ +using AasCore.Aas3_0_RC02; +using System.Collections.Generic; + +namespace IO.Swagger.Lib.V3.Interfaces +{ + public interface IAasRepositoryApiHelperService + { + List GetAllReferences(List referables); + Reference GetReference(IReferable referable); + } +} diff --git a/src/IO.Swagger.Lib.V3/Interfaces/IBase64UrlDecoderService.cs b/src/IO.Swagger.Lib.V3/Interfaces/IBase64UrlDecoderService.cs new file mode 100644 index 000000000..c8f23e194 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Interfaces/IBase64UrlDecoderService.cs @@ -0,0 +1,7 @@ +namespace IO.Swagger.Lib.V3.Interfaces +{ + public interface IBase64UrlDecoderService + { + string Decode(string fieldName, string encodedString); + } +} \ No newline at end of file diff --git a/src/IO.Swagger.Lib.V3/Interfaces/IJsonQueryDeserializer.cs b/src/IO.Swagger.Lib.V3/Interfaces/IJsonQueryDeserializer.cs new file mode 100644 index 000000000..e8ae81c59 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Interfaces/IJsonQueryDeserializer.cs @@ -0,0 +1,9 @@ +using AasCore.Aas3_0_RC02; + +namespace IO.Swagger.Lib.V3.Services +{ + public interface IJsonQueryDeserializer + { + Reference DeserializeReference(string fieldName, string referenceString); + } +} \ No newline at end of file diff --git a/src/IO.Swagger.Lib.V3/Interfaces/IPaginationService.cs b/src/IO.Swagger.Lib.V3/Interfaces/IPaginationService.cs new file mode 100644 index 000000000..125b270d2 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Interfaces/IPaginationService.cs @@ -0,0 +1,10 @@ +using IO.Swagger.Lib.V3.Models; +using System.Collections.Generic; + +namespace IO.Swagger.Lib.V3.Interfaces +{ + public interface IPaginationService + { + List GetPaginatedList(List sourceList, PaginationParameters paginationParameters); + } +} diff --git a/src/IO.Swagger.Lib.V3/Middleware/ExceptionMiddleware.cs b/src/IO.Swagger.Lib.V3/Middleware/ExceptionMiddleware.cs new file mode 100644 index 000000000..805edbe6b --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Middleware/ExceptionMiddleware.cs @@ -0,0 +1,148 @@ +using AasxServerStandardBib.Exceptions; +using AasxServerStandardBib.Logging; +using AdminShellNS.Exceptions; +using IO.Swagger.Lib.V3.Exceptions; +using IO.Swagger.Models; +using Microsoft.AspNetCore.Http; +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Threading.Tasks; + +namespace IO.Swagger.Lib.V3.Middleware +{ + public class ExceptionMiddleware + { + private readonly RequestDelegate _next; + + public ExceptionMiddleware(RequestDelegate next) + { + _next = next; + } + + public async Task InvokeAsync(HttpContext httpContext, IAppLogger logger) + { + try + { + await _next(httpContext); + } + catch (Exception ex) + { + await HandleExceptionAsync(httpContext, ex, logger); + } + } + + + private async Task HandleExceptionAsync(HttpContext context, Exception exception, IAppLogger logger) + { + logger.LogError(exception.Message); + logger.LogDebug(exception.StackTrace); + context.Response.ContentType = "application/json"; + var result = new Result(); + var message = new Message(); + + switch (exception) + { + case DuplicateException ex: + { + context.Response.StatusCode = (int)HttpStatusCode.Conflict; + message.Code = HttpStatusCode.Conflict.ToString(); + message.Text = ex.Message; + message.Timestamp = DateTime.Now.ToString(); + message.MessageType = Message.MessageTypeEnum.ErrorEnum; + break; + } + case FileNotFoundException: + case NotFoundException: + { + context.Response.StatusCode = (int)HttpStatusCode.NotFound; + message.Code = HttpStatusCode.NotFound.ToString(); + message.Text = exception.Message; + message.Timestamp = DateTime.Now.ToString(); + message.MessageType = Message.MessageTypeEnum.ErrorEnum; + break; + } + case NotAllowed: + { + context.Response.StatusCode = (int)HttpStatusCode.Forbidden; + message.Code = HttpStatusCode.Forbidden.ToString(); + message.Text = exception.Message; + message.Timestamp = DateTime.Now.ToString(); + message.MessageType = Message.MessageTypeEnum.ErrorEnum; + break; + } + case MetamodelVerificationException ex: + { + //Print the errors in debug level + foreach(var error in ex.ErrorList) + { + var errorText = AasCore.Aas3_0_RC02.Reporting.GenerateJsonPath(error.PathSegments) + ":" + error.Cause; + logger.LogDebug(errorText); + } + + context.Response.StatusCode = (int)HttpStatusCode.BadRequest; + message.Code = HttpStatusCode.BadRequest.ToString(); + message.Text = exception.Message; + message.Timestamp = DateTime.Now.ToString(); + message.MessageType = Message.MessageTypeEnum.ErrorEnum; + break; + } + case InvalidNumberOfChildElementsException: + case NoIdentifierException: + case ArgumentNullException: + case OperationVariableException: + case JsonDeserializationException: + case Base64UrlDecoderException: + { + context.Response.StatusCode = (int)HttpStatusCode.BadRequest; + message.Code = HttpStatusCode.BadRequest.ToString(); + message.Text = exception.Message; + message.Timestamp = DateTime.Now.ToString(); + message.MessageType = Message.MessageTypeEnum.ErrorEnum; + break; + } + case InvalidSerializationModifierException: + { + context.Response.StatusCode = (int)HttpStatusCode.MethodNotAllowed; + message.Code = HttpStatusCode.MethodNotAllowed.ToString(); + message.Text = exception.Message; + message.Timestamp = DateTime.Now.ToString(); + message.MessageType = Message.MessageTypeEnum.ErrorEnum; + break; + } + case Exceptions.NotImplementedException: + { + context.Response.StatusCode = (int)HttpStatusCode.NotImplemented; + message.Code = HttpStatusCode.NotImplemented.ToString(); + message.Text = exception.Message; + message.Timestamp = DateTime.Now.ToString(); + message.MessageType = Message.MessageTypeEnum.ErrorEnum; + break; + } + case UnprocessableEntityException: + { + context.Response.StatusCode = (int)HttpStatusCode.UnprocessableEntity; + message.Code = HttpStatusCode.UnprocessableEntity.ToString(); + message.Text = exception.Message; + message.Timestamp = DateTime.Now.ToString(); + message.MessageType = Message.MessageTypeEnum.ErrorEnum; + break; + } + default: + { + context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; + message.Code = HttpStatusCode.InternalServerError.ToString(); + message.Text = exception.Message; + message.Timestamp = DateTime.Now.ToString(); + message.MessageType = Message.MessageTypeEnum.ErrorEnum; + break; + } + } + + result.Success = false; + result.Messages = new List() { message }; + await context.Response.WriteAsync(result.ToJson()); + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Models/Description.cs b/src/IO.Swagger.Lib.V3/Models/Description.cs new file mode 100644 index 000000000..ebd5f1941 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/Description.cs @@ -0,0 +1,207 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * 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 Description object enables servers to present their capabilities to the clients, in particular which profiles they implement. At least one defined profile is required. Additional, proprietary attributes might be included. Nevertheless, the server must not expect that a regular client understands them. + /// + [DataContract] + public partial class Description : IEquatable + { + /// + /// Gets or Sets Profiles + /// + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum ProfilesEnum + { + /// + /// Enum AssetAdministrationShellServiceSpecificationV30Enum for AssetAdministrationShellServiceSpecification/V3.0 + /// + [EnumMember(Value = "AssetAdministrationShellServiceSpecification/V3.0")] + AssetAdministrationShellServiceSpecificationV30Enum = 0, + /// + /// Enum AssetAdministrationShellServiceSpecificationV30MinimalProfileEnum for AssetAdministrationShellServiceSpecification/V3.0-MinimalProfile + /// + [EnumMember(Value = "AssetAdministrationShellServiceSpecification/V3.0-MinimalProfile")] + AssetAdministrationShellServiceSpecificationV30MinimalProfileEnum = 1, + /// + /// Enum SubmodelServiceSpecificationV30Enum for SubmodelServiceSpecification/V3.0 + /// + [EnumMember(Value = "SubmodelServiceSpecification/V3.0")] + SubmodelServiceSpecificationV30Enum = 2, + /// + /// Enum SubmodelServiceSpecificationV30ValueProfileEnum for SubmodelServiceSpecification/V3.0-ValueProfile + /// + [EnumMember(Value = "SubmodelServiceSpecification/V3.0-ValueProfile")] + SubmodelServiceSpecificationV30ValueProfileEnum = 3, + /// + /// Enum SubmodelServiceSpecificationV30MinimalProfileEnum for SubmodelServiceSpecification/V3.0-MinimalProfile + /// + [EnumMember(Value = "SubmodelServiceSpecification/V3.0-MinimalProfile")] + SubmodelServiceSpecificationV30MinimalProfileEnum = 4, + /// + /// Enum AasxFileServerServiceSpecificationV30Enum for AasxFileServerServiceSpecification/V3.0 + /// + [EnumMember(Value = "AasxFileServerServiceSpecification/V3.0")] + AasxFileServerServiceSpecificationV30Enum = 5, + /// + /// Enum RegistryServiceSpecificationV30Enum for RegistryServiceSpecification/V3.0 + /// + [EnumMember(Value = "RegistryServiceSpecification/V3.0")] + RegistryServiceSpecificationV30Enum = 6, + /// + /// Enum RegistryServiceSpecificationV30AssetAdministrationShellRegistryEnum for RegistryServiceSpecification/V3.0- AssetAdministrationShellRegistry + /// + [EnumMember(Value = "RegistryServiceSpecification/V3.0- AssetAdministrationShellRegistry")] + RegistryServiceSpecificationV30AssetAdministrationShellRegistryEnum = 7, + /// + /// Enum RegistryServiceSpecificationV30SubmodelRegistryEnum for RegistryServiceSpecification/V3.0-SubmodelRegistry + /// + [EnumMember(Value = "RegistryServiceSpecification/V3.0-SubmodelRegistry")] + RegistryServiceSpecificationV30SubmodelRegistryEnum = 8, + /// + /// Enum RepositoryServiceSpecificationV30Enum for RepositoryServiceSpecification/V3.0 + /// + [EnumMember(Value = "RepositoryServiceSpecification/V3.0")] + RepositoryServiceSpecificationV30Enum = 9, + /// + /// Enum RepositoryServiceSpecificationV30MinimalProfileEnum for RepositoryServiceSpecification/V3.0-MinimalProfile + /// + [EnumMember(Value = "RepositoryServiceSpecification/V3.0-MinimalProfile")] + RepositoryServiceSpecificationV30MinimalProfileEnum = 10, + /// + /// Enum AssetAdministrationShellRepositoryServiceSpecificationV30Enum for AssetAdministrationShellRepositoryServiceSpecification/V3.0 + /// + [EnumMember(Value = "AssetAdministrationShellRepositoryServiceSpecification/V3.0")] + AssetAdministrationShellRepositoryServiceSpecificationV30Enum = 11, + /// + /// Enum AssetAdministrationShellRepositoryServiceSpecificationV30MinimalProfileEnum for AssetAdministrationShellRepositoryServiceSpecification/V3.0-MinimalProfile + /// + [EnumMember(Value = "AssetAdministrationShellRepositoryServiceSpecification/V3.0-MinimalProfile")] + AssetAdministrationShellRepositoryServiceSpecificationV30MinimalProfileEnum = 12, + /// + /// Enum SubmodelRepositoryServiceSpecificationV30Enum for SubmodelRepositoryServiceSpecification/V3.0 + /// + [EnumMember(Value = "SubmodelRepositoryServiceSpecification/V3.0")] + SubmodelRepositoryServiceSpecificationV30Enum = 13, + /// + /// Enum SubmodelRepositoryServiceSpecificationV30MinimalProfileEnum for SubmodelRepositoryServiceSpecification/V3.0-MinimalProfile + /// + [EnumMember(Value = "SubmodelRepositoryServiceSpecification/V3.0-MinimalProfile")] + SubmodelRepositoryServiceSpecificationV30MinimalProfileEnum = 14, + /// + /// Enum RegistryAndDiscoveryServiceSpecificationV30Enum for RegistryAndDiscoveryServiceSpecification/V3.0 + /// + [EnumMember(Value = "RegistryAndDiscoveryServiceSpecification/V3.0")] + RegistryAndDiscoveryServiceSpecificationV30Enum = 15 } + + /// + /// Gets or Sets Profiles + /// + + [DataMember(Name="profiles")] + public List Profiles { 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 Description {\n"); + sb.Append(" Profiles: ").Append(Profiles).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((Description)obj); + } + + /// + /// Returns true if Description instances are equal + /// + /// Instance of Description to be compared + /// Boolean + public bool Equals(Description other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Profiles == other.Profiles || + Profiles != null && + Profiles.SequenceEqual(other.Profiles) + ); + } + + /// + /// 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 (Profiles != null) + hashCode = hashCode * 59 + Profiles.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Description left, Description right) + { + return Equals(left, right); + } + + public static bool operator !=(Description left, Description right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger.Lib.V3/Models/ExecutionState.cs b/src/IO.Swagger.Lib.V3/Models/ExecutionState.cs new file mode 100644 index 000000000..dc7d53a2d --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/ExecutionState.cs @@ -0,0 +1,59 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * 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 +{ + /// + /// Gets or Sets ExecutionState + /// + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum ExecutionState + { + /// + /// Enum InitiatedEnum for Initiated + /// + [EnumMember(Value = "Initiated")] + InitiatedEnum = 0, + /// + /// Enum RunningEnum for Running + /// + [EnumMember(Value = "Running")] + RunningEnum = 1, + /// + /// Enum CompletedEnum for Completed + /// + [EnumMember(Value = "Completed")] + CompletedEnum = 2, + /// + /// Enum CanceledEnum for Canceled + /// + [EnumMember(Value = "Canceled")] + CanceledEnum = 3, + /// + /// Enum FailedEnum for Failed + /// + [EnumMember(Value = "Failed")] + FailedEnum = 4, + /// + /// Enum TimeoutEnum for Timeout + /// + [EnumMember(Value = "Timeout")] + TimeoutEnum = 5 } +} diff --git a/src/IO.Swagger.Lib.V3/Models/Message.cs b/src/IO.Swagger.Lib.V3/Models/Message.cs new file mode 100644 index 000000000..b3170688c --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/Message.cs @@ -0,0 +1,198 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * 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 Message : IEquatable + { + /// + /// Gets or Sets Code + /// + + [MaxLength(8)] + [DataMember(Name="code")] + public string Code { get; set; } + + /// + /// Gets or Sets MessageType + /// + [JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public enum MessageTypeEnum + { + /// + /// Enum UndefinedEnum for Undefined + /// + [EnumMember(Value = "Undefined")] + UndefinedEnum = 0, + /// + /// Enum InfoEnum for Info + /// + [EnumMember(Value = "Info")] + InfoEnum = 1, + /// + /// Enum WarningEnum for Warning + /// + [EnumMember(Value = "Warning")] + WarningEnum = 2, + /// + /// Enum ErrorEnum for Error + /// + [EnumMember(Value = "Error")] + ErrorEnum = 3, + /// + /// Enum ExceptionEnum for Exception + /// + [EnumMember(Value = "Exception")] + ExceptionEnum = 4 } + + /// + /// Gets or Sets MessageType + /// + + [DataMember(Name="messageType")] + public MessageTypeEnum? MessageType { get; set; } + + /// + /// Gets or Sets Text + /// + + [DataMember(Name="text")] + public string Text { get; set; } + + /// + /// Gets or Sets Timestamp + /// + + [DataMember(Name="timestamp")] + public string Timestamp { 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 Message {\n"); + sb.Append(" Code: ").Append(Code).Append("\n"); + sb.Append(" MessageType: ").Append(MessageType).Append("\n"); + sb.Append(" Text: ").Append(Text).Append("\n"); + sb.Append(" Timestamp: ").Append(Timestamp).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((Message)obj); + } + + /// + /// Returns true if Message instances are equal + /// + /// Instance of Message to be compared + /// Boolean + public bool Equals(Message other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Code == other.Code || + Code != null && + Code.Equals(other.Code) + ) && + ( + MessageType == other.MessageType || + MessageType != null && + MessageType.Equals(other.MessageType) + ) && + ( + Text == other.Text || + Text != null && + Text.Equals(other.Text) + ) && + ( + Timestamp == other.Timestamp || + Timestamp != null && + Timestamp.Equals(other.Timestamp) + ); + } + + /// + /// 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 (Code != null) + hashCode = hashCode * 59 + Code.GetHashCode(); + if (MessageType != null) + hashCode = hashCode * 59 + MessageType.GetHashCode(); + if (Text != null) + hashCode = hashCode * 59 + Text.GetHashCode(); + if (Timestamp != null) + hashCode = hashCode * 59 + Timestamp.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Message left, Message right) + { + return Equals(left, right); + } + + public static bool operator !=(Message left, Message right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger.Lib.V3/Models/OperationRequest.cs b/src/IO.Swagger.Lib.V3/Models/OperationRequest.cs new file mode 100644 index 000000000..f7b7dcb4c --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/OperationRequest.cs @@ -0,0 +1,164 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using AasCore.Aas3_0_RC02; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class OperationRequest : IEquatable + { + /// + /// Gets or Sets InoutputArguments + /// + + [DataMember(Name="inoutputArguments")] + public List InoutputArguments { get; set; } + + /// + /// Gets or Sets InputArguments + /// + + [DataMember(Name="inputArguments")] + public List InputArguments { get; set; } + + /// + /// Gets or Sets RequestId + /// + + [MaxLength(128)] + [DataMember(Name="requestId")] + public string RequestId { get; set; } + + /// + /// Gets or Sets Timeout + /// + + [DataMember(Name="timeout")] + public int? Timeout { 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 OperationRequest {\n"); + sb.Append(" InoutputArguments: ").Append(InoutputArguments).Append("\n"); + sb.Append(" InputArguments: ").Append(InputArguments).Append("\n"); + sb.Append(" RequestId: ").Append(RequestId).Append("\n"); + sb.Append(" Timeout: ").Append(Timeout).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((OperationRequest)obj); + } + + /// + /// Returns true if OperationRequest instances are equal + /// + /// Instance of OperationRequest to be compared + /// Boolean + public bool Equals(OperationRequest other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + InoutputArguments == other.InoutputArguments || + InoutputArguments != null && + InoutputArguments.SequenceEqual(other.InoutputArguments) + ) && + ( + InputArguments == other.InputArguments || + InputArguments != null && + InputArguments.SequenceEqual(other.InputArguments) + ) && + ( + RequestId == other.RequestId || + RequestId != null && + RequestId.Equals(other.RequestId) + ) && + ( + Timeout == other.Timeout || + Timeout != null && + Timeout.Equals(other.Timeout) + ); + } + + /// + /// 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 (RequestId != null) + hashCode = hashCode * 59 + RequestId.GetHashCode(); + if (Timeout != null) + hashCode = hashCode * 59 + Timeout.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(OperationRequest left, OperationRequest right) + { + return Equals(left, right); + } + + public static bool operator !=(OperationRequest left, OperationRequest right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger.Lib.V3/Models/OperationResult.cs b/src/IO.Swagger.Lib.V3/Models/OperationResult.cs new file mode 100644 index 000000000..3555ad2aa --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/OperationResult.cs @@ -0,0 +1,179 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using AasCore.Aas3_0_RC02; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.Linq; +using System.Runtime.Serialization; +using System.Text; + +namespace IO.Swagger.Models +{ + /// + /// + /// + [DataContract] + public partial class OperationResult : IEquatable + { + /// + /// Gets or Sets ExecutionResult + /// + + [DataMember(Name="executionResult")] + public Result ExecutionResult { get; set; } + + /// + /// Gets or Sets ExecutionState + /// + + [DataMember(Name="executionState")] + public ExecutionState ExecutionState { get; set; } + + /// + /// Gets or Sets InoutputArguments + /// + + [DataMember(Name="inoutputArguments")] + public List InoutputArguments { get; set; } + + /// + /// Gets or Sets OutputArguments + /// + + [DataMember(Name="outputArguments")] + public List OutputArguments { get; set; } + + /// + /// Gets or Sets RequestId + /// + + [MaxLength(128)] + [DataMember(Name="requestId")] + public string RequestId { 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 OperationResult {\n"); + sb.Append(" ExecutionResult: ").Append(ExecutionResult).Append("\n"); + sb.Append(" ExecutionState: ").Append(ExecutionState).Append("\n"); + sb.Append(" InoutputArguments: ").Append(InoutputArguments).Append("\n"); + sb.Append(" OutputArguments: ").Append(OutputArguments).Append("\n"); + sb.Append(" RequestId: ").Append(RequestId).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((OperationResult)obj); + } + + /// + /// Returns true if OperationResult instances are equal + /// + /// Instance of OperationResult to be compared + /// Boolean + public bool Equals(OperationResult other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + ExecutionResult == other.ExecutionResult || + ExecutionResult != null && + ExecutionResult.Equals(other.ExecutionResult) + ) && + ( + ExecutionState == other.ExecutionState || + ExecutionState != null && + ExecutionState.Equals(other.ExecutionState) + ) && + ( + InoutputArguments == other.InoutputArguments || + InoutputArguments != null && + InoutputArguments.SequenceEqual(other.InoutputArguments) + ) && + ( + OutputArguments == other.OutputArguments || + OutputArguments != null && + OutputArguments.SequenceEqual(other.OutputArguments) + ) && + ( + RequestId == other.RequestId || + RequestId != null && + RequestId.Equals(other.RequestId) + ); + } + + /// + /// 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 (ExecutionResult != null) + hashCode = hashCode * 59 + ExecutionResult.GetHashCode(); + if (ExecutionState != null) + hashCode = hashCode * 59 + ExecutionState.GetHashCode(); + if (InoutputArguments != null) + hashCode = hashCode * 59 + InoutputArguments.GetHashCode(); + if (OutputArguments != null) + hashCode = hashCode * 59 + OutputArguments.GetHashCode(); + if (RequestId != null) + hashCode = hashCode * 59 + RequestId.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(OperationResult left, OperationResult right) + { + return Equals(left, right); + } + + public static bool operator !=(OperationResult left, OperationResult right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger.Lib.V3/Models/PaginationParameters.cs b/src/IO.Swagger.Lib.V3/Models/PaginationParameters.cs new file mode 100644 index 000000000..38fe058dc --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/PaginationParameters.cs @@ -0,0 +1,43 @@ +namespace IO.Swagger.Lib.V3.Models +{ + public class PaginationParameters + { + const int MAX_RESULT_SIZE = 100; + + /** + * The result set should start at this value. + */ + public int From { get; set; } = 0; + + private int _size = MAX_RESULT_SIZE; + + public PaginationParameters(int? from, int? size) + { + if(from != null) + { + From = from.Value; + } + + if(size != null) + { + Size = size.Value; + } + } + + /** + * The maximum size of the result set. + */ + public int Size + { + get + { + return _size; + } + set + { + _size = (value > MAX_RESULT_SIZE) ? MAX_RESULT_SIZE : value; + } + } + + } +} diff --git a/src/IO.Swagger.Lib.V3/Models/Result.cs b/src/IO.Swagger.Lib.V3/Models/Result.cs new file mode 100644 index 000000000..8977bb8b2 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/Result.cs @@ -0,0 +1,135 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * 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 Result : IEquatable + { + /// + /// Gets or Sets Messages + /// + + [DataMember(Name="messages")] + public List Messages { get; set; } + + /// + /// Gets or Sets Success + /// + + [DataMember(Name="success")] + public bool? Success { 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 Result {\n"); + sb.Append(" Messages: ").Append(Messages).Append("\n"); + sb.Append(" Success: ").Append(Success).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((Result)obj); + } + + /// + /// Returns true if Result instances are equal + /// + /// Instance of Result to be compared + /// Boolean + public bool Equals(Result other) + { + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + + return + ( + Messages == other.Messages || + Messages != null && + Messages.SequenceEqual(other.Messages) + ) && + ( + Success == other.Success || + Success != null && + Success.Equals(other.Success) + ); + } + + /// + /// 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 (Messages != null) + hashCode = hashCode * 59 + Messages.GetHashCode(); + if (Success != null) + hashCode = hashCode * 59 + Success.GetHashCode(); + return hashCode; + } + } + + #region Operators + #pragma warning disable 1591 + + public static bool operator ==(Result left, Result right) + { + return Equals(left, right); + } + + public static bool operator !=(Result left, Result right) + { + return !Equals(left, right); + } + + #pragma warning restore 1591 + #endregion Operators + } +} diff --git a/src/IO.Swagger.Lib.V3/Models/SerializationModifiersEnum.cs b/src/IO.Swagger.Lib.V3/Models/SerializationModifiersEnum.cs new file mode 100644 index 000000000..cc6d78498 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Models/SerializationModifiersEnum.cs @@ -0,0 +1,30 @@ +using System.Text.Json.Serialization; + +namespace IO.Swagger.Models +{ + [JsonConverter(typeof(JsonStringEnumConverter))] + public enum LevelEnum + { + Deep, + Core + } + + [JsonConverter(typeof(JsonStringEnumConverter))] + public enum ContentEnum + { + Normal, + Value, + Metadata, + Reference, + Path + } + + [JsonConverter(typeof(JsonStringEnumConverter))] + public enum ExtentEnum + { + WithoutBlobValue, + WithBlobValue + } + + +} diff --git a/src/IO.Swagger.Lib.V3/Properties/launchSettings.json b/src/IO.Swagger.Lib.V3/Properties/launchSettings.json new file mode 100644 index 000000000..5bb6f8299 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Properties/launchSettings.json @@ -0,0 +1,36 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:50352/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "launchUrl": "swagger/", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "web": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "swagger", + "applicationUrl": "https://localhost:5001;http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Docker": { + "commandName": "Docker", + "launchBrowser": true, + "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger", + "publishAllPorts": true, + "useSSL": true + } + } +} \ No newline at end of file diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtentSerializer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtentSerializer.cs new file mode 100644 index 000000000..ab3af2421 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtentSerializer.cs @@ -0,0 +1,19 @@ +/** + * This class applies only Level and Extent modifiers. As per new specification, there are seperate APIs for the content modifiers. + * + */ +using AasCore.Aas3_0_RC02; +using System.Text.Json.Nodes; + +namespace IO.Swagger.Lib.V3.SerializationModifiers +{ + public class LevelExtentSerializer + { + private static readonly LevelExtentTransformer _transformer = new LevelExtentTransformer(); + + public static JsonObject ToJsonObject(IClass that, SerializationModifierContext context) + { + return _transformer.Transform(that, context); + } + } +} diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtentTransformer.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtentTransformer.cs new file mode 100644 index 000000000..267195c27 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/LevelExtentTransformer.cs @@ -0,0 +1,208 @@ +using AasCore.Aas3_0_RC02; +using IO.Swagger.Models; +using Opc.Ua; +using System.Text.Json.Nodes; +using static AasCore.Aas3_0_RC02.Visitation; + +namespace IO.Swagger.Lib.V3.SerializationModifiers +{ + public class LevelExtentTransformer : AbstractTransformerWithContext + { + public override JsonObject Transform(Extension that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(AdministrativeInformation that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(Qualifier that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(AssetAdministrationShell that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(AssetInformation that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(Resource that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(SpecificAssetId that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(Submodel that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(RelationshipElement that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(SubmodelElementList that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(SubmodelElementCollection that, SerializationModifierContext context) + { + var result = Jsonization.Serialize.ToJsonObject(that); + + //Transform SubmodelElements w.r.t. extent + if (context.Extent == ExtentEnum.WithoutBlobValue) + { + JsonArray valueArray = (JsonArray)result["value"]; + foreach (JsonObject item in valueArray) + { + var modelType = item["modelType"].GetValue(); + if(modelType.Equals("Blob")) + { + item.Remove("value"); + } + } + } + + return result; + } + + public override JsonObject Transform(Property that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(MultiLanguageProperty that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(AasCore.Aas3_0_RC02.Range that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(ReferenceElement that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(Blob that, SerializationModifierContext context) + { + var result = Jsonization.Serialize.ToJsonObject(that); + + //Check extent and remove value if WithoutBlob + if(result != null) + { + if(context.Extent == ExtentEnum.WithoutBlobValue) + { + result.Remove("value"); + } + } + + return result; + } + + public override JsonObject Transform(File that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(AnnotatedRelationshipElement that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(Entity that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(EventPayload that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(BasicEventElement that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(Operation that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(OperationVariable that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(Capability that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(ConceptDescription that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(Reference that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(Key that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(LangString that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(Environment that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(EmbeddedDataSpecification that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(ValueReferencePair that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(ValueList that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(DataSpecificationIec61360 that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + + public override JsonObject Transform(DataSpecificationPhysicalUnit that, SerializationModifierContext context) + { + return Jsonization.Serialize.ToJsonObject(that); + } + } +} diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/SerializationModifierContext.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/SerializationModifierContext.cs new file mode 100644 index 000000000..49c407723 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/SerializationModifierContext.cs @@ -0,0 +1,17 @@ +using IO.Swagger.Models; + +namespace IO.Swagger.Lib.V3.SerializationModifiers +{ + public class SerializationModifierContext + { + public LevelEnum Level { get; set; } + + public ExtentEnum Extent { get; set; } + + public SerializationModifierContext(LevelEnum level, ExtentEnum extent) + { + Level = level; + Extent = extent; + } + } +} diff --git a/src/IO.Swagger.Lib.V3/SerializationModifiers/SerializationModifiersValidator.cs b/src/IO.Swagger.Lib.V3/SerializationModifiers/SerializationModifiersValidator.cs new file mode 100644 index 000000000..7eac74d63 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/SerializationModifiers/SerializationModifiersValidator.cs @@ -0,0 +1,59 @@ +using AasCore.Aas3_0_RC02; +using IO.Swagger.Lib.V3.Exceptions; +using IO.Swagger.Models; +using System.Collections.Generic; + +namespace IO.Swagger.Lib.V3.SerializationModifiers +{ + public static class SerializationModifiersValidator + { + //As per new APIs, content is not handled here + public static void Validate(IClass resource, LevelEnum level, ExtentEnum extent) + { + switch(resource) + { + case BasicEventElement: + case Capability: + case Operation: + { + if(level == LevelEnum.Core) + { + throw new InvalidSerializationModifierException(level.ToString(), resource.GetType().Name); + } + + if(extent == ExtentEnum.WithBlobValue) + { + throw new InvalidSerializationModifierException(level.ToString(), resource.GetType().Name); + } + break; + } + case Blob: + { + if (level == LevelEnum.Core) + { + throw new InvalidSerializationModifierException(level.ToString(), resource.GetType().Name); + } + break; + } + case IDataElement: + { + if (level == LevelEnum.Core) + { + throw new InvalidSerializationModifierException(level.ToString(), resource.GetType().Name); + } + if (extent == ExtentEnum.WithBlobValue) + { + throw new InvalidSerializationModifierException(level.ToString(), resource.GetType().Name); + } + break; + } + } + } + + public static void Validate(List resources, LevelEnum level, ExtentEnum extent) + { + foreach(IClass resource in resources) + Validate(resource, level, extent); + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Services/AasRepositoryApiHelperService.cs b/src/IO.Swagger.Lib.V3/Services/AasRepositoryApiHelperService.cs new file mode 100644 index 000000000..bd78cda67 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Services/AasRepositoryApiHelperService.cs @@ -0,0 +1,75 @@ +using AasCore.Aas3_0_RC02; +using AasxServerStandardBib.Logging; +using Extensions; +using IO.Swagger.Lib.V3.Interfaces; +using Microsoft.IdentityModel.Tokens; +using System.Collections.Generic; + +namespace IO.Swagger.Lib.V3.Services +{ + public class AasRepositoryApiHelperService : IAasRepositoryApiHelperService + { + private readonly IAppLogger _logger; + + public AasRepositoryApiHelperService(IAppLogger logger) + { + _logger = logger; + } + public List GetAllAssetAdministrationShellReference(List aasList) + { + if(aasList.IsNullOrEmpty()) + { + _logger.LogDebug($"No asset administrations shells present."); + return null; + } + + var result = new List(); + foreach (var aas in aasList) + { + result.Add(aas.GetReference()); + } + + return result; + } + + public Reference GetAssetAdministrationShellReference(AssetAdministrationShell aas) + { + if(aas == null) + { + _logger.LogDebug($"Retrieved AAS is null"); + return null; + } + + return aas.GetReference(); + } + + public List GetAllReferences(List referables) + { + if (referables.IsNullOrEmpty()) + { + _logger.LogDebug($"No asset administrations shells present."); + return null; + } + + var result = new List(); + foreach (var referable in referables) + { + result.Add(GetReference(referable)); + } + + return result; + } + + + public Reference GetReference(IReferable referable) + { + if (referable == null) + { + _logger.LogDebug($"Retrieved AAS is null"); + return null; + } + + return referable.GetReference(); + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Services/Base64UrlDecoderService.cs b/src/IO.Swagger.Lib.V3/Services/Base64UrlDecoderService.cs new file mode 100644 index 000000000..8966023e3 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Services/Base64UrlDecoderService.cs @@ -0,0 +1,33 @@ +using IO.Swagger.Lib.V3.Exceptions; +using IO.Swagger.Lib.V3.Interfaces; +using Microsoft.IdentityModel.Tokens; +using System; + +namespace IO.Swagger.Lib.V3.Services +{ + public class Base64UrlDecoderService : IBase64UrlDecoderService + { + public string Decode(string fieldName, string encodedString) + { + try + { + if (!string.IsNullOrEmpty(encodedString)) + { + return Base64UrlEncoder.Decode(encodedString); + } + else + { + return null; + } + } + catch (FormatException) + { + throw new Base64UrlDecoderException(fieldName); + } + catch (Exception) + { + throw; + } + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Services/JsonQueryDeserializer.cs b/src/IO.Swagger.Lib.V3/Services/JsonQueryDeserializer.cs new file mode 100644 index 000000000..82d64be2b --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Services/JsonQueryDeserializer.cs @@ -0,0 +1,49 @@ +using AasCore.Aas3_0_RC02; +using AasxServerStandardBib.Logging; +using IO.Swagger.Lib.V3.Exceptions; +using IO.Swagger.Lib.V3.Interfaces; +using System; +using System.IO; +using System.Text; +using System.Text.Json; +using System.Text.Json.Nodes; + +namespace IO.Swagger.Lib.V3.Services +{ + public class JsonQueryDeserializer : IJsonQueryDeserializer + { + private readonly IAppLogger _logger; + private readonly IBase64UrlDecoderService _decoderService; + + public JsonQueryDeserializer(IAppLogger logger, IBase64UrlDecoderService decoderService) + { + _logger = logger; + _decoderService = decoderService; + } + + public Reference DeserializeReference(string fieldName, string referenceString) + { + Reference output = null; + try + { + if (!string.IsNullOrEmpty(referenceString)) + { + var decodedString = _decoderService.Decode(fieldName, referenceString); + MemoryStream mStrm = new MemoryStream(Encoding.UTF8.GetBytes(decodedString)); + JsonNode node = JsonSerializer.DeserializeAsync(mStrm).Result; + output = Jsonization.Deserialize.ReferenceFrom(node); + } + } + catch (JsonException ex) + { + throw new JsonDeserializationException(fieldName, ex.Message); + } + catch (Exception) + { + throw; + } + + return output; + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Services/PaginationService.cs b/src/IO.Swagger.Lib.V3/Services/PaginationService.cs new file mode 100644 index 000000000..2ada153df --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Services/PaginationService.cs @@ -0,0 +1,42 @@ +using AasxServerStandardBib.Logging; +using IO.Swagger.Lib.V3.Interfaces; +using IO.Swagger.Lib.V3.Models; +using System.Collections.Generic; + +namespace IO.Swagger.Lib.V3.Services +{ + public class PaginationService : IPaginationService + { + private readonly IAppLogger _logger; + + public PaginationService(IAppLogger logger) + { + _logger = logger; + } + public List GetPaginatedList(List sourceList, PaginationParameters paginationParameters) + { + var result = new List(); + var startIndex = paginationParameters.From; + var endIndex = startIndex + paginationParameters.Size - 1; + + //cap the endIndex + if(endIndex > sourceList.Count -1) + { + endIndex = sourceList.Count - 1; + } + + //If there are less elements in the sourceList than "from" + if(startIndex > sourceList.Count -1) + { + _logger.LogError($"There are less elements in the retrived list than requested pagination - (from: {startIndex}, size:{endIndex})"); + } + + for(int i = startIndex; i <= endIndex; i++) + { + result.Add(sourceList[i]); + } + + return result; + } + } +} diff --git a/src/IO.Swagger.Lib.V3/Startup.cs b/src/IO.Swagger.Lib.V3/Startup.cs new file mode 100644 index 000000000..a6aaf8813 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/Startup.cs @@ -0,0 +1,141 @@ +/* + * DotAAS Part 2 | HTTP/REST | Repository Service Specification + * + * The entire Repository Service Specification as part of Details of the Asset Administration Shell Part 2 + * + * OpenAPI spec version: V3.0 + * + * Generated by: https://github.com/swagger-api/swagger-codegen.git + */ +using System; +using System.IO; +using Microsoft.AspNetCore.Authentication; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Microsoft.Extensions.Logging; +using Microsoft.OpenApi.Models; +using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Serialization; +using Swashbuckle.AspNetCore.Swagger; +using Swashbuckle.AspNetCore.SwaggerGen; +using IO.Swagger.Filters; + + +namespace IO.Swagger +{ + /// + /// Startup + /// + public class Startup + { + private readonly IWebHostEnvironment _hostingEnv; + + private IConfiguration Configuration { get; } + + /// + /// Constructor + /// + /// + /// + public Startup(IWebHostEnvironment env, IConfiguration configuration) + { + _hostingEnv = env; + Configuration = configuration; + } + + /// + /// This method gets called by the runtime. Use this method to add services to the container. + /// + /// + public void ConfigureServices(IServiceCollection services) + { + // Add framework services. + services + .AddMvc(options => + { + options.InputFormatters.RemoveType(); + options.OutputFormatters.RemoveType(); + }) + .AddNewtonsoftJson(opts => + { + opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); + opts.SerializerSettings.Converters.Add(new StringEnumConverter(new CamelCaseNamingStrategy())); + }) + .AddXmlSerializerFormatters(); + + + services + .AddSwaggerGen(c => + { + c.SwaggerDoc("V3.0", new OpenApiInfo + { + Version = "V3.0", + Title = "DotAAS Part 2 | HTTP/REST | Repository Service Specification", + Description = "DotAAS Part 2 | HTTP/REST | Repository Service Specification (ASP.NET Core 3.1)", + Contact = new OpenApiContact() + { + Name = "Constantin Ziesche, Andreas Orzelski, Florian Krebs, Bastian Rössl, Manuel Sauer, Jens Vialkowitsch, Michael Hoffmeister, Torben Miny, Sebastian Bader, Marko Ristin, Nico Braunisch", + Url = new Uri("https://github.com/swagger-api/swagger-codegen"), + Email = "" + }, + TermsOfService = new Uri("https://github.com/admin-shell-io/aas-specs") + }); + c.CustomSchemaIds(type => type.FullName); + c.IncludeXmlComments($"{AppContext.BaseDirectory}{Path.DirectorySeparatorChar}{_hostingEnv.ApplicationName}.xml"); + + // Include DataAnnotation attributes on Controller Action parameters as Swagger validation rules (e.g required, pattern, ..) + // Use [ValidateModelState] on Actions to actually validate it in C# as well! + c.OperationFilter(); + }); + } + + /// + /// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + /// + /// + /// + /// + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.UseRouting(); + + //TODO: Uncomment this if you need wwwroot folder + // app.UseStaticFiles(); + + app.UseAuthorization(); + + app.UseSwagger(); + app.UseSwaggerUI(c => + { + //TODO: Either use the SwaggerGen generated Swagger contract (generated from C# classes) + c.SwaggerEndpoint("/swagger/V3.0/swagger.json", "DotAAS Part 2 | HTTP/REST | Repository Service Specification"); + + //TODO: Or alternatively use the original Swagger contract that's included in the static files + // c.SwaggerEndpoint("/swagger-original.json", "DotAAS Part 2 | HTTP/REST | Repository Service Specification Original"); + }); + + //TODO: Use Https Redirection + // app.UseHttpsRedirection(); + + app.UseEndpoints(endpoints => + { + endpoints.MapControllers(); + }); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + else + { + //TODO: Enable production exception handling (https://docs.microsoft.com/en-us/aspnet/core/fundamentals/error-handling) + app.UseExceptionHandler("/Error"); + + app.UseHsts(); + } + } + } +} diff --git a/src/IO.Swagger.Lib.V3/appsettings.json b/src/IO.Swagger.Lib.V3/appsettings.json new file mode 100644 index 000000000..c6af7d9b0 --- /dev/null +++ b/src/IO.Swagger.Lib.V3/appsettings.json @@ -0,0 +1,10 @@ +{ + "Logging": { + "IncludeScopes": false, + "LogLevel": { + "Default": "Information", + "System": "Information", + "Microsoft": "Information" + } + } +} diff --git a/src/IO.Swagger.Registry.Lib/Controllers/RegistryAndDiscoveryInterfaceApi.cs b/src/IO.Swagger.Registry.Lib/Controllers/RegistryAndDiscoveryInterfaceApi.cs index 9a7a1bf2b..8e42167e2 100644 --- a/src/IO.Swagger.Registry.Lib/Controllers/RegistryAndDiscoveryInterfaceApi.cs +++ b/src/IO.Swagger.Registry.Lib/Controllers/RegistryAndDiscoveryInterfaceApi.cs @@ -7,6 +7,16 @@ * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ +using AasCore.Aas3_0_RC02; +using AasxServer; +using Extensions; +using IdentityModel.Client; +using IO.Swagger.Registry.Attributes; +using IO.Swagger.Registry.Models; +using Microsoft.AspNetCore.Mvc; +using Microsoft.IdentityModel.Tokens; +using Newtonsoft.Json; +using Swashbuckle.AspNetCore.Annotations; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -17,25 +27,6 @@ using System.Text; using System.Text.Json.Nodes; using System.Threading.Tasks; -using AasCore.Aas3_0_RC02; -using AasxServer; -using AasxTimeSeries; -using AdminShellNS; -using Extenstions; -using IdentityModel.Client; -using IO.Swagger.Registry.Attributes; -using IO.Swagger.Registry.Models; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Components.Routing; -using Microsoft.AspNetCore.Http; -using Microsoft.AspNetCore.Mvc; -using Microsoft.IdentityModel.Tokens; -using Microsoft.VisualBasic; -using Newtonsoft.Json; -using Org.BouncyCastle.Asn1.Ocsp; -using Swashbuckle.AspNetCore.Annotations; -using Swashbuckle.AspNetCore.SwaggerGen; -using static QRCoder.PayloadGenerator; using Key = AasCore.Aas3_0_RC02.Key; namespace IO.Swagger.Registry.Controllers @@ -1030,13 +1021,11 @@ public static void initRegistry(List cList, DateTime times continue; // check, if AAS is exisiting and must be replaced - var aas = new AssetAdministrationShell(); + var aas = new AssetAdministrationShell(ad.Identification, new AssetInformation(AssetKind.Instance)); aas.Extensions = new List { new Extension("endpoint", value: ad.Endpoints[0].ProtocolInformation.EndpointAddress) }; aas.TimeStamp = timestamp; aas.TimeStampCreate = timestamp; - aas.Id = ad.Identification; aas.IdShort = ad.IdShort + " - EXTERNAL"; - aas.AssetInformation = new AssetInformation(AssetKind.Instance); string gid = ad.GlobalAssetId.Value[0]; aas.AssetInformation.GlobalAssetId = new AasCore.Aas3_0_RC02.Reference(AasCore.Aas3_0_RC02.ReferenceTypes.GlobalReference, new List() { new Key(KeyTypes.GlobalReference, gid) }); diff --git a/src/IO.Swagger.V1RC03/APIModels/Core/CoreTransformer.cs b/src/IO.Swagger.V1RC03/APIModels/Core/CoreTransformer.cs index 98f55d1c0..46e0a39b9 100644 --- a/src/IO.Swagger.V1RC03/APIModels/Core/CoreTransformer.cs +++ b/src/IO.Swagger.V1RC03/APIModels/Core/CoreTransformer.cs @@ -1,15 +1,11 @@ using AasCore.Aas3_0_RC02; -using Extenstions; using IO.Swagger.V1RC03.APIModels.ValueOnly; -using Opc.Ua; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.Json.Nodes; -using System.Threading.Tasks; using static AasCore.Aas3_0_RC02.Jsonization; using static AasCore.Aas3_0_RC02.Visitation; +using Extensions; +using System.Collections.Generic; namespace IO.Swagger.V1RC03.APIModels.Core { @@ -65,16 +61,16 @@ public JsonObject Transform(AdministrativeInformation that, OutputModifierContex { var result = new JsonObject(); - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Version != null) @@ -205,16 +201,16 @@ public JsonObject Transform(AssetAdministrationShell that, OutputModifierContext result["id"] = JsonValue.Create( that.Id); - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.DerivedFrom != null) @@ -464,16 +460,16 @@ public JsonObject Transform(Submodel that, OutputModifierContext context) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.SubmodelElements != null) @@ -601,16 +597,14 @@ public JsonObject Transform(RelationshipElement that, OutputModifierContext cont result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (!string.IsNullOrEmpty(context.Content) && !context.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) @@ -727,16 +721,16 @@ public JsonObject Transform(SubmodelElementList that, OutputModifierContext cont result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.OrderRelevant != null) @@ -887,16 +881,16 @@ public JsonObject Transform(SubmodelElementCollection that, OutputModifierContex result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Value != null) @@ -1023,16 +1017,14 @@ public JsonObject Transform(Property that, OutputModifierContext context) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["valueType"] = Serialize.DataTypeDefXsdToJsonValue( @@ -1158,16 +1150,14 @@ public JsonObject Transform(MultiLanguageProperty that, OutputModifierContext co result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (!string.IsNullOrEmpty(context.Content) && !context.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) @@ -1290,16 +1280,14 @@ public JsonObject Transform(AasCore.Aas3_0_RC02.Range that, OutputModifierContex result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["valueType"] = Serialize.DataTypeDefXsdToJsonValue( @@ -1425,16 +1413,14 @@ public JsonObject Transform(ReferenceElement that, OutputModifierContext context result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Value != null) @@ -1548,16 +1534,14 @@ public JsonObject Transform(Blob that, OutputModifierContext context) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (!string.IsNullOrEmpty(context.Content) && !context.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) @@ -1681,16 +1665,14 @@ public JsonObject Transform(File that, OutputModifierContext context) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (!string.IsNullOrEmpty(context.Content) && !context.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) @@ -1810,16 +1792,14 @@ public JsonObject Transform(AnnotatedRelationshipElement that, OutputModifierCon result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (!string.IsNullOrEmpty(context.Content) && !context.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) @@ -1955,16 +1935,14 @@ public JsonObject Transform(Entity that, OutputModifierContext context) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Statements != null) @@ -2155,16 +2133,14 @@ public JsonObject Transform(BasicEventElement that, OutputModifierContext contex result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (!string.IsNullOrEmpty(context.Content) && !context.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) @@ -2304,16 +2280,17 @@ public JsonObject Transform(Operation that, OutputModifierContext context) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.InputVariables != null) @@ -2457,16 +2434,14 @@ public JsonObject Transform(Capability that, OutputModifierContext context) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["modelType"] = "Capability"; @@ -2529,16 +2504,14 @@ public JsonObject Transform(ConceptDescription that, OutputModifierContext conte result["id"] = JsonValue.Create( that.Id); - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item, context)); + arrayEmbeddedDataSpecifications.Add(Transform(item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.IsCaseOf != null) @@ -2610,12 +2583,12 @@ public JsonObject Transform(LangString that, OutputModifierContext context) return result; } - public JsonObject Transform(LangStringSet that, OutputModifierContext context) + public JsonObject Transform(List that, OutputModifierContext context) { var result = new JsonObject(); var arrayLangStrings = new JsonArray(); - foreach (LangString item in that.LangStrings) + foreach (LangString item in that) { arrayLangStrings.Add( Transform( @@ -2626,38 +2599,13 @@ public JsonObject Transform(LangStringSet that, OutputModifierContext context) return result; } - public JsonObject Transform(DataSpecificationContent that, OutputModifierContext context) + public JsonObject Transform(IDataSpecificationContent that, OutputModifierContext context) { var result = new JsonObject(); return result; } - public JsonObject Transform(DataSpecification that, OutputModifierContext context) - { - var result = new JsonObject(); - - result["id"] = JsonValue.Create( - that.Id); - - result["dataSpecificationContent"] = Transform( - that.DataSpecificationContent, context); - - if (that.Administration != null) - { - result["administration"] = Transform( - that.Administration, context); - } - - if (that.Description != null) - { - result["description"] = Transform( - that.Description, context); - } - - return result; - } - public JsonObject Transform(AasCore.Aas3_0_RC02.Environment that, OutputModifierContext context) { var result = new JsonObject(); @@ -2698,24 +2646,240 @@ public JsonObject Transform(AasCore.Aas3_0_RC02.Environment that, OutputModifier result["conceptDescriptions"] = arrayConceptDescriptions; } - if (that.DataSpecifications != null) + return result; + } + + public JsonObject Transform(IClass that, OutputModifierContext context) + { + return that.Transform(this, context); + } + + public JsonObject Transform(EmbeddedDataSpecification that, OutputModifierContext context) + { + var result = new JsonObject(); + + result["dataSpecification"] = Transform( + that.DataSpecification, context); + + result["dataSpecificationContent"] = Transform( + that.DataSpecificationContent, context); + + return result; + } + + public JsonObject Transform(ValueReferencePair that, OutputModifierContext context) + { + var result = new JsonObject(); + + result["value"] = JsonValue.Create( + that.Value); + + result["valueId"] = Transform( + that.ValueId, context); + + return result; + } + + public JsonObject Transform(ValueList that, OutputModifierContext context) + { + var result = new JsonObject(); + + var arrayValueReferencePairs = new JsonArray(); + foreach (ValueReferencePair item in that.ValueReferencePairs) + { + arrayValueReferencePairs.Add( + Transform( + item, context)); + } + result["valueReferencePairs"] = arrayValueReferencePairs; + + return result; + } + + public JsonObject Transform(DataSpecificationIec61360 that, OutputModifierContext context) + { + var result = new JsonObject(); + + var arrayPreferredName = new JsonArray(); + foreach (LangString item in that.PreferredName) { - var arrayDataSpecifications = new JsonArray(); - foreach (DataSpecification item in that.DataSpecifications) + arrayPreferredName.Add( + Transform( + item, context)); + } + result["preferredName"] = arrayPreferredName; + + if (that.ShortName != null) + { + var arrayShortName = new JsonArray(); + foreach (LangString item in that.ShortName) + { + arrayShortName.Add( + Transform( + item, context)); + } + result["shortName"] = arrayShortName; + } + + if (that.Unit != null) + { + result["unit"] = JsonValue.Create( + that.Unit); + } + + if (that.UnitId != null) + { + result["unitId"] = Transform( + that.UnitId, context); + } + + if (that.SourceOfDefinition != null) + { + result["sourceOfDefinition"] = JsonValue.Create( + that.SourceOfDefinition); + } + + if (that.Symbol != null) + { + result["symbol"] = JsonValue.Create( + that.Symbol); + } + + if (that.DataType != null) + { + // We need to help the static analyzer with a null coalescing. + DataTypeIec61360 value = that.DataType + ?? throw new System.InvalidOperationException(); + result["dataType"] = Serialize.DataTypeIec61360ToJsonValue( + value); + } + + if (that.Definition != null) + { + var arrayDefinition = new JsonArray(); + foreach (LangString item in that.Definition) { - arrayDataSpecifications.Add( + arrayDefinition.Add( Transform( item, context)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["definition"] = arrayDefinition; + } + + if (that.ValueFormat != null) + { + result["valueFormat"] = JsonValue.Create( + that.ValueFormat); + } + + if (that.ValueList != null) + { + result["valueList"] = Transform( + that.ValueList, context); + } + + if (that.Value != null) + { + result["value"] = JsonValue.Create( + that.Value); + } + + if (that.LevelType != null) + { + // We need to help the static analyzer with a null coalescing. + LevelType value = that.LevelType + ?? throw new System.InvalidOperationException(); + result["levelType"] = Serialize.LevelTypeToJsonValue( + value); } + result["modelType"] = "DataSpecificationIEC61360"; + return result; } - public JsonObject Transform(IClass that, OutputModifierContext context) + public JsonObject Transform(DataSpecificationPhysicalUnit that, OutputModifierContext context) { - return that.Transform(this, context); + var result = new JsonObject(); + + result["unitName"] = JsonValue.Create( + that.UnitName); + + result["unitSymbol"] = JsonValue.Create( + that.UnitSymbol); + + var arrayDefinition = new JsonArray(); + foreach (LangString item in that.Definition) + { + arrayDefinition.Add( + Transform( + item, context)); + } + result["definition"] = arrayDefinition; + + if (that.SiNotation != null) + { + result["siNotation"] = JsonValue.Create( + that.SiNotation); + } + + if (that.SiName != null) + { + result["siName"] = JsonValue.Create( + that.SiName); + } + + if (that.DinNotation != null) + { + result["dinNotation"] = JsonValue.Create( + that.DinNotation); + } + + if (that.EceName != null) + { + result["eceName"] = JsonValue.Create( + that.EceName); + } + + if (that.EceCode != null) + { + result["eceCode"] = JsonValue.Create( + that.EceCode); + } + + if (that.NistName != null) + { + result["nistName"] = JsonValue.Create( + that.NistName); + } + + if (that.SourceOfDefinition != null) + { + result["sourceOfDefinition"] = JsonValue.Create( + that.SourceOfDefinition); + } + + if (that.ConversionFactor != null) + { + result["conversionFactor"] = JsonValue.Create( + that.ConversionFactor); + } + + if (that.RegistrationAuthorityId != null) + { + result["registrationAuthorityId"] = JsonValue.Create( + that.RegistrationAuthorityId); + } + + if (that.Supplier != null) + { + result["supplier"] = JsonValue.Create( + that.Supplier); + } + + result["modelType"] = "DataSpecificationPhysicalUnit"; + + return result; } } } diff --git a/src/IO.Swagger.V1RC03/APIModels/Core/EntityCore.cs b/src/IO.Swagger.V1RC03/APIModels/Core/EntityCore.cs deleted file mode 100644 index bb9aee8fc..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/Core/EntityCore.cs +++ /dev/null @@ -1,32 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.Core -{ - internal class EntityCore : Entity - { - public EntityCore(Entity entity) : base(entity.EntityType, entity.Extensions, entity.Category, entity.IdShort, entity.DisplayName, entity.Description, entity.Checksum, entity.Kind, entity.SemanticId, entity.SupplementalSemanticIds, entity.Qualifiers, entity.DataSpecifications, entity.Statements, entity.GlobalAssetId, entity.SpecificAssetId) - { - //Remove indirect children - foreach (var submodelElement in this.Statements) - { - if (submodelElement is SubmodelElementCollection childCollection) - { - childCollection.Value.Clear(); - } - else if (submodelElement is SubmodelElementList childList) - { - childList.Value.Clear(); - } - else if (submodelElement is Entity childEntity) - { - childEntity.Statements.Clear(); - } - } - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/Core/PathTransformer.cs b/src/IO.Swagger.V1RC03/APIModels/Core/PathTransformer.cs index 4e15e7a35..dbfc10977 100644 --- a/src/IO.Swagger.V1RC03/APIModels/Core/PathTransformer.cs +++ b/src/IO.Swagger.V1RC03/APIModels/Core/PathTransformer.cs @@ -437,24 +437,39 @@ public List Transform(LangString that, OutputModifierContext context) throw new System.NotImplementedException(); } - public List Transform(LangStringSet that, OutputModifierContext context) + public List Transform(List that, OutputModifierContext context) { throw new System.NotImplementedException(); } - public List Transform(DataSpecificationContent that, OutputModifierContext context) + public List Transform(AasCore.Aas3_0_RC02.Environment that, OutputModifierContext context) { throw new System.NotImplementedException(); } - public List Transform(DataSpecification that, OutputModifierContext context) + public List Transform(EmbeddedDataSpecification that, OutputModifierContext context) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); } - public List Transform(AasCore.Aas3_0_RC02.Environment that, OutputModifierContext context) + public List Transform(ValueReferencePair that, OutputModifierContext context) { - throw new System.NotImplementedException(); + throw new NotImplementedException(); + } + + public List Transform(ValueList that, OutputModifierContext context) + { + throw new NotImplementedException(); + } + + public List Transform(DataSpecificationIec61360 that, OutputModifierContext context) + { + throw new NotImplementedException(); + } + + public List Transform(DataSpecificationPhysicalUnit that, OutputModifierContext context) + { + throw new NotImplementedException(); } } } \ No newline at end of file diff --git a/src/IO.Swagger.V1RC03/APIModels/Core/SubmodelCore.cs b/src/IO.Swagger.V1RC03/APIModels/Core/SubmodelCore.cs deleted file mode 100644 index 193973c5b..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/Core/SubmodelCore.cs +++ /dev/null @@ -1,32 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.Core -{ - internal class SubmodelCore : Submodel - { - public SubmodelCore(Submodel submodel) : base(submodel.Id, submodel.Extensions, submodel.Category, submodel.IdShort, submodel.DisplayName, submodel.Description, submodel.Checksum, submodel.Administration, submodel.Kind, submodel.SemanticId, submodel.SupplementalSemanticIds, submodel.Qualifiers, submodel.DataSpecifications, submodel.SubmodelElements) - { - //Remove indirect children - foreach (var submodelElement in this.SubmodelElements) - { - if (submodelElement is SubmodelElementCollection collection) - { - collection.Value.Clear(); - } - else if (submodelElement is SubmodelElementList list) - { - list.Value.Clear(); - } - else if (submodelElement is Entity entity) - { - entity.Statements.Clear(); - } - } - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/Core/SubmodelElementCollectionCore.cs b/src/IO.Swagger.V1RC03/APIModels/Core/SubmodelElementCollectionCore.cs deleted file mode 100644 index 08464bdd5..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/Core/SubmodelElementCollectionCore.cs +++ /dev/null @@ -1,32 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.Core -{ - internal class SubmodelElementCollectionCore : SubmodelElementCollection - { - public SubmodelElementCollectionCore(SubmodelElementCollection collection) : base(collection.Extensions, collection.Category, collection.IdShort, collection.DisplayName, collection.Description, collection.Checksum, collection.Kind, collection.SemanticId, collection.SupplementalSemanticIds, collection.Qualifiers, collection.DataSpecifications, collection.Value) - { - //Remove indirect children - foreach (var submodelElement in this.Value) - { - if (submodelElement is SubmodelElementCollection childCollection) - { - childCollection.Value.Clear(); - } - else if (submodelElement is SubmodelElementList list) - { - list.Value.Clear(); - } - else if (submodelElement is Entity entity) - { - entity.Statements.Clear(); - } - } - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/Core/SubmodelElementListCore.cs b/src/IO.Swagger.V1RC03/APIModels/Core/SubmodelElementListCore.cs deleted file mode 100644 index 0c93bd91f..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/Core/SubmodelElementListCore.cs +++ /dev/null @@ -1,32 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.Core -{ - internal class SubmodelElementListCore : SubmodelElementList - { - public SubmodelElementListCore(SubmodelElementList list) : base(list.TypeValueListElement, list.Extensions, list.Category, list.IdShort, list.DisplayName, list.Description, list.Checksum, list.Kind, list.SemanticId, list.SupplementalSemanticIds, list.Qualifiers, list.DataSpecifications, list.OrderRelevant, list.Value, list.SemanticIdListElement, list.ValueTypeListElement) - { - //Remove indirect children - foreach (var submodelElement in this.Value) - { - if (submodelElement is SubmodelElementCollection childCollection) - { - childCollection.Value.Clear(); - } - else if (submodelElement is SubmodelElementList childList) - { - childList.Value.Clear(); - } - else if (submodelElement is Entity entity) - { - entity.Statements.Clear(); - } - } - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/Metadata/MetadataDeserializer.cs b/src/IO.Swagger.V1RC03/APIModels/Metadata/MetadataDeserializer.cs index 821adf25d..c55b8105d 100644 --- a/src/IO.Swagger.V1RC03/APIModels/Metadata/MetadataDeserializer.cs +++ b/src/IO.Swagger.V1RC03/APIModels/Metadata/MetadataDeserializer.cs @@ -179,43 +179,101 @@ private static ISubmodelElement SubmodelElementListFrom(JsonNode node, out Repor } JsonNode? nodeDisplayName = obj["displayName"]; - LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) + JsonArray? arrayDisplayName = nodeDisplayName as JsonArray; + if (arrayDisplayName == null) { - theDisplayName = Jsonization.Deserialize.LangStringSetFrom(nodeDisplayName); - if (error != null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDisplayName.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + List? theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (JsonNode? item in arrayDisplayName) + { + if (item == null) { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); error.PrependSegment( new Reporting.NameSegment( "displayName")); return null; } - if (theDisplayName == null) + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + if (error != null) { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; } + JsonNode? nodeDescription = obj["description"]; - LangStringSet? theDescription = null; - if (nodeDescription != null) + JsonArray? arrayDescription = nodeDescription as JsonArray; + if (arrayDescription == null) { - theDescription = Jsonization.Deserialize.LangStringSetFrom(nodeDescription); - if (error != null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDescription.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + List? theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (JsonNode? item in arrayDescription) + { + if (item == null) { + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); error.PrependSegment( new Reporting.NameSegment( "description")); return null; } - if (theDescription == null) + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + + if (error != null) { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; } + + JsonNode? nodeChecksum = obj["checksum"]; string? theChecksum = null; if (nodeChecksum != null) @@ -339,44 +397,40 @@ private static ISubmodelElement SubmodelElementListFrom(JsonNode node, out Repor } } - JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) + JsonNode? nodeEmbeddedDataSpecifications = obj["embeddedDataSpecifications"]; + JsonArray? arrayEmbeddedDataSpecifications = nodeEmbeddedDataSpecifications as JsonArray; + if (arrayEmbeddedDataSpecifications == null) { - JsonArray? arrayDataSpecifications = nodeDataSpecifications as JsonArray; - if (arrayDataSpecifications == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeEmbeddedDataSpecifications.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + List theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) { error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); return null; } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = Jsonization.Deserialize.ReferenceFrom(item); - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } + EmbeddedDataSpecification? parsedItem = Jsonization.Deserialize.EmbeddedDataSpecificationFrom(item); + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; } JsonNode? nodeOrderRelevant = obj["orderRelevant"]; @@ -502,7 +556,7 @@ private static ISubmodelElement SubmodelElementListFrom(JsonNode node, out Repor theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theOrderRelevant, theValue, theSemanticIdListElement, @@ -601,27 +655,96 @@ private static ISubmodelElement SubmodelElementCollectionFrom(JsonNode node, out } JsonNode? nodeDisplayName = obj["displayName"]; - LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) + JsonArray? arrayDisplayName = nodeDisplayName as JsonArray; + if (arrayDisplayName == null) { - theDisplayName = Jsonization.Deserialize.LangStringSetFrom(nodeDisplayName); - if (theDisplayName == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDisplayName.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + List? theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (JsonNode? item in arrayDisplayName) + { + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; } JsonNode? nodeDescription = obj["description"]; - LangStringSet? theDescription = null; - if (nodeDescription != null) + JsonArray? arrayDescription = nodeDescription as JsonArray; + if (arrayDescription == null) { - theDescription = Jsonization.Deserialize.LangStringSetFrom(nodeDescription); - if (theDescription == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDescription.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + List? theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (JsonNode? item in arrayDescription) + { + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; } JsonNode? nodeChecksum = obj["checksum"]; @@ -747,44 +870,40 @@ private static ISubmodelElement SubmodelElementCollectionFrom(JsonNode node, out } } - JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) + JsonNode? nodeEmbeddedDataSpecifications = obj["embeddedDataSpecifications"]; + JsonArray? arrayEmbeddedDataSpecifications = nodeEmbeddedDataSpecifications as JsonArray; + if (arrayEmbeddedDataSpecifications == null) { - JsonArray? arrayDataSpecifications = nodeDataSpecifications as JsonArray; - if (arrayDataSpecifications == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeEmbeddedDataSpecifications.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + List theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) { error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); return null; } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = Jsonization.Deserialize.ReferenceFrom(item); - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } + EmbeddedDataSpecification? parsedItem = Jsonization.Deserialize.EmbeddedDataSpecificationFrom(item); + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; } JsonNode? nodeValue = obj["value"]; @@ -848,7 +967,7 @@ private static ISubmodelElement SubmodelElementCollectionFrom(JsonNode node, out theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theValue); } @@ -982,27 +1101,96 @@ private static File FileFrom(JsonNode node, out Reporting.Error error) } JsonNode? nodeDisplayName = obj["displayName"]; - LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) + JsonArray? arrayDisplayName = nodeDisplayName as JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDisplayName.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + List? theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (JsonNode? item in arrayDisplayName) { - theDisplayName = Jsonization.Deserialize.LangStringSetFrom(nodeDisplayName); - if (theDisplayName == null) + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; } JsonNode? nodeDescription = obj["description"]; - LangStringSet? theDescription = null; - if (nodeDescription != null) + JsonArray? arrayDescription = nodeDescription as JsonArray; + if (arrayDescription == null) { - theDescription = Jsonization.Deserialize.LangStringSetFrom(nodeDescription); - if (theDescription == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDescription.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + List? theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (JsonNode? item in arrayDescription) + { + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; } JsonNode? nodeChecksum = obj["checksum"]; @@ -1121,44 +1309,40 @@ private static File FileFrom(JsonNode node, out Reporting.Error error) } } - JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) + JsonNode? nodeEmbeddedDataSpecifications = obj["embeddedDataSpecifications"]; + JsonArray? arrayEmbeddedDataSpecifications = nodeEmbeddedDataSpecifications as JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeEmbeddedDataSpecifications.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + List theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (JsonNode? item in arrayEmbeddedDataSpecifications) { - JsonArray? arrayDataSpecifications = nodeDataSpecifications as JsonArray; - if (arrayDataSpecifications == null) + if (item == null) { error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); return null; } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = Jsonization.Deserialize.ReferenceFrom(item); - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } + EmbeddedDataSpecification? parsedItem = Jsonization.Deserialize.EmbeddedDataSpecificationFrom(item); + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; } //No contentType and Value in case of metadata, hence null @@ -1174,7 +1358,7 @@ private static File FileFrom(JsonNode node, out Reporting.Error error) theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, null); } @@ -1257,27 +1441,96 @@ private static Blob BlobFrom(JsonNode node, out Reporting.Error error) } JsonNode? nodeDisplayName = obj["displayName"]; - LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) + JsonArray? arrayDisplayName = nodeDisplayName as JsonArray; + if (arrayDisplayName == null) { - theDisplayName = Jsonization.Deserialize.LangStringSetFrom(nodeDisplayName); - if (theDisplayName == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDisplayName.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + List? theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (JsonNode? item in arrayDisplayName) + { + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; } JsonNode? nodeDescription = obj["description"]; - LangStringSet? theDescription = null; - if (nodeDescription != null) + JsonArray? arrayDescription = nodeDescription as JsonArray; + if (arrayDescription == null) { - theDescription = Jsonization.Deserialize.LangStringSetFrom(nodeDescription); - if (theDescription == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDescription.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + List? theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (JsonNode? item in arrayDescription) + { + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; } JsonNode? nodeChecksum = obj["checksum"]; @@ -1396,44 +1649,40 @@ private static Blob BlobFrom(JsonNode node, out Reporting.Error error) } } - JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) + JsonNode? nodeEmbeddedDataSpecifications = obj["embeddedDataSpecifications"]; + JsonArray? arrayEmbeddedDataSpecifications = nodeEmbeddedDataSpecifications as JsonArray; + if (arrayEmbeddedDataSpecifications == null) { - JsonArray? arrayDataSpecifications = nodeDataSpecifications as JsonArray; - if (arrayDataSpecifications == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeEmbeddedDataSpecifications.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + List theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) { error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); return null; } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = Jsonization.Deserialize.ReferenceFrom(item); - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } + EmbeddedDataSpecification? parsedItem = Jsonization.Deserialize.EmbeddedDataSpecificationFrom(item); + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; } @@ -1451,7 +1700,7 @@ private static Blob BlobFrom(JsonNode node, out Reporting.Error error) theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, null); } @@ -1534,27 +1783,96 @@ private static ISubmodelElement BasicEventElementFrom(JsonNode node, out Reporti } JsonNode? nodeDisplayName = obj["displayName"]; - LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) + JsonArray? arrayDisplayName = nodeDisplayName as JsonArray; + if (arrayDisplayName == null) { - theDisplayName = Jsonization.Deserialize.LangStringSetFrom(nodeDisplayName); - if (theDisplayName == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDisplayName.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + List? theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (JsonNode? item in arrayDisplayName) + { + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; } JsonNode? nodeDescription = obj["description"]; - LangStringSet? theDescription = null; - if (nodeDescription != null) + JsonArray? arrayDescription = nodeDescription as JsonArray; + if (arrayDescription == null) { - theDescription = Jsonization.Deserialize.LangStringSetFrom(nodeDescription); - if (theDescription == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDescription.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + List? theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (JsonNode? item in arrayDescription) + { + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; } JsonNode? nodeChecksum = obj["checksum"]; @@ -1673,44 +1991,40 @@ private static ISubmodelElement BasicEventElementFrom(JsonNode node, out Reporti } } - JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) + JsonNode? nodeEmbeddedDataSpecifications = obj["embeddedDataSpecifications"]; + JsonArray? arrayEmbeddedDataSpecifications = nodeEmbeddedDataSpecifications as JsonArray; + if (arrayEmbeddedDataSpecifications == null) { - JsonArray? arrayDataSpecifications = nodeDataSpecifications as JsonArray; - if (arrayDataSpecifications == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeEmbeddedDataSpecifications.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + List theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) { error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); return null; } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = Jsonization.Deserialize.ReferenceFrom(item); - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } + EmbeddedDataSpecification? parsedItem = Jsonization.Deserialize.EmbeddedDataSpecificationFrom(item); + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; } JsonNode? nodeDirection = obj["direction"]; @@ -1820,7 +2134,7 @@ private static ISubmodelElement BasicEventElementFrom(JsonNode node, out Reporti theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theMessageTopic, theMessageBroker, theLastUpdate, @@ -1907,27 +2221,96 @@ private static ISubmodelElement AnnotatedRelationshipElementFrom(JsonNode node, } JsonNode? nodeDisplayName = obj["displayName"]; - LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) + JsonArray? arrayDisplayName = nodeDisplayName as JsonArray; + if (arrayDisplayName == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDisplayName.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + List? theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (JsonNode? item in arrayDisplayName) { - theDisplayName = Jsonization.Deserialize.LangStringSetFrom(nodeDisplayName); - if (theDisplayName == null) + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; } JsonNode? nodeDescription = obj["description"]; - LangStringSet? theDescription = null; - if (nodeDescription != null) + JsonArray? arrayDescription = nodeDescription as JsonArray; + if (arrayDescription == null) { - theDescription = Jsonization.Deserialize.LangStringSetFrom(nodeDescription); - if (theDescription == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDescription.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + List? theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (JsonNode? item in arrayDescription) + { + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; } JsonNode? nodeChecksum = obj["checksum"]; @@ -2046,44 +2429,40 @@ private static ISubmodelElement AnnotatedRelationshipElementFrom(JsonNode node, } } - JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) + JsonNode? nodeEmbeddedDataSpecifications = obj["embeddedDataSpecifications"]; + JsonArray? arrayEmbeddedDataSpecifications = nodeEmbeddedDataSpecifications as JsonArray; + if (arrayEmbeddedDataSpecifications == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeEmbeddedDataSpecifications.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + List theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (JsonNode? item in arrayEmbeddedDataSpecifications) { - JsonArray? arrayDataSpecifications = nodeDataSpecifications as JsonArray; - if (arrayDataSpecifications == null) + if (item == null) { error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); return null; } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = Jsonization.Deserialize.ReferenceFrom(item); - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } + EmbeddedDataSpecification? parsedItem = Jsonization.Deserialize.EmbeddedDataSpecificationFrom(item); + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; } JsonNode? nodeAnnotations = obj["annotations"]; @@ -2152,7 +2531,7 @@ private static ISubmodelElement AnnotatedRelationshipElementFrom(JsonNode node, theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications, + theEmbeddedDataSpecifications, theAnnotations); } @@ -2288,27 +2667,96 @@ private static ISubmodelElement RelationshipElementFrom(JsonNode node, out Repor } JsonNode? nodeDisplayName = obj["displayName"]; - LangStringSet? theDisplayName = null; - if (nodeDisplayName != null) + JsonArray? arrayDisplayName = nodeDisplayName as JsonArray; + if (arrayDisplayName == null) { - theDisplayName = Jsonization.Deserialize.LangStringSetFrom(nodeDisplayName); - if (theDisplayName == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDisplayName.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + List? theDisplayName = new List( + arrayDisplayName.Count); + int indexDisplayName = 0; + foreach (JsonNode? item in arrayDisplayName) + { + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDisplayName null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDisplayName)); + error.PrependSegment( + new Reporting.NameSegment( + "displayName")); + return null; + } + theDisplayName.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDisplayName++; } JsonNode? nodeDescription = obj["description"]; - LangStringSet? theDescription = null; - if (nodeDescription != null) + JsonArray? arrayDescription = nodeDescription as JsonArray; + if (arrayDescription == null) + { + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeDescription.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + List? theDescription = new List( + arrayDescription.Count); + int indexDescription = 0; + foreach (JsonNode? item in arrayDescription) { - theDescription = Jsonization.Deserialize.LangStringSetFrom(nodeDescription); - if (theDescription == null) + if (item == null) { - throw new System.InvalidOperationException( - "Unexpected theDescription null when error is also null"); + error = new Reporting.Error( + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; } + LangString? parsedItem = Jsonization.Deserialize.LangStringFrom(item); + + if (error != null) + { + error.PrependSegment( + new Reporting.IndexSegment( + indexDescription)); + error.PrependSegment( + new Reporting.NameSegment( + "description")); + return null; + } + theDescription.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexDescription++; } JsonNode? nodeChecksum = obj["checksum"]; @@ -2427,44 +2875,40 @@ private static ISubmodelElement RelationshipElementFrom(JsonNode node, out Repor } } - JsonNode? nodeDataSpecifications = obj["dataSpecifications"]; - List? theDataSpecifications = null; - if (nodeDataSpecifications != null) + JsonNode? nodeEmbeddedDataSpecifications = obj["embeddedDataSpecifications"]; + JsonArray? arrayEmbeddedDataSpecifications = nodeEmbeddedDataSpecifications as JsonArray; + if (arrayEmbeddedDataSpecifications == null) { - JsonArray? arrayDataSpecifications = nodeDataSpecifications as JsonArray; - if (arrayDataSpecifications == null) + error = new Reporting.Error( + $"Expected a JsonArray, but got {nodeEmbeddedDataSpecifications.GetType()}"); + error.PrependSegment( + new Reporting.NameSegment( + "embeddedDataSpecifications")); + return null; + } + List theEmbeddedDataSpecifications = new List( + arrayEmbeddedDataSpecifications.Count); + int indexEmbeddedDataSpecifications = 0; + foreach (JsonNode? item in arrayEmbeddedDataSpecifications) + { + if (item == null) { error = new Reporting.Error( - $"Expected a JsonArray, but got {nodeDataSpecifications.GetType()}"); + "Expected a non-null item, but got a null"); + error.PrependSegment( + new Reporting.IndexSegment( + indexEmbeddedDataSpecifications)); error.PrependSegment( new Reporting.NameSegment( - "dataSpecifications")); + "embeddedDataSpecifications")); return null; } - theDataSpecifications = new List( - arrayDataSpecifications.Count); - int indexDataSpecifications = 0; - foreach (JsonNode? item in arrayDataSpecifications) - { - if (item == null) - { - error = new Reporting.Error( - "Expected a non-null item, but got a null"); - error.PrependSegment( - new Reporting.IndexSegment( - indexDataSpecifications)); - error.PrependSegment( - new Reporting.NameSegment( - "dataSpecifications")); - return null; - } - Reference? parsedItem = Jsonization.Deserialize.ReferenceFrom(item); - theDataSpecifications.Add( - parsedItem - ?? throw new System.InvalidOperationException( - "Unexpected result null when error is null")); - indexDataSpecifications++; - } + EmbeddedDataSpecification? parsedItem = Jsonization.Deserialize.EmbeddedDataSpecificationFrom(item); + theEmbeddedDataSpecifications.Add( + parsedItem + ?? throw new System.InvalidOperationException( + "Unexpected result null when error is null")); + indexEmbeddedDataSpecifications++; } //No first and second in metadata, hence null @@ -2481,7 +2925,7 @@ private static ISubmodelElement RelationshipElementFrom(JsonNode node, out Repor theSemanticId, theSupplementalSemanticIds, theQualifiers, - theDataSpecifications); + theEmbeddedDataSpecifications); } } } diff --git a/src/IO.Swagger.V1RC03/APIModels/Metadata/MetadataTransfomer.cs b/src/IO.Swagger.V1RC03/APIModels/Metadata/MetadataTransfomer.cs index 3a8a5100a..733fb0b5c 100644 --- a/src/IO.Swagger.V1RC03/APIModels/Metadata/MetadataTransfomer.cs +++ b/src/IO.Swagger.V1RC03/APIModels/Metadata/MetadataTransfomer.cs @@ -67,16 +67,16 @@ public override Nodes.JsonObject Transform(AdministrativeInformation that) { var result = new Nodes.JsonObject(); - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Version != null) @@ -201,16 +201,16 @@ public override Nodes.JsonObject Transform(AssetAdministrationShell that) result["id"] = Nodes.JsonValue.Create( that.Id); - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( + arrayEmbeddedDataSpecifications.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.DerivedFrom != null) @@ -402,16 +402,14 @@ public override Nodes.JsonObject Transform(Submodel that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["modelType"] = "Submodel"; @@ -504,16 +502,14 @@ public override Nodes.JsonObject Transform(RelationshipElement that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["modelType"] = "RelationshipElement"; @@ -606,16 +602,14 @@ public override Nodes.JsonObject Transform(SubmodelElementList that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.OrderRelevant != null) @@ -732,16 +726,14 @@ public override Nodes.JsonObject Transform(SubmodelElementCollection that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["modelType"] = "SubmodelElementCollection"; @@ -834,16 +826,14 @@ public override Nodes.JsonObject Transform(Property that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["valueType"] = Serialize.DataTypeDefXsdToJsonValue( @@ -939,16 +929,14 @@ public override Nodes.JsonObject Transform(MultiLanguageProperty that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["modelType"] = "MultiLanguageProperty"; @@ -1041,16 +1029,14 @@ public override Nodes.JsonObject Transform(AasCore.Aas3_0_RC02.Range that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["valueType"] = Serialize.DataTypeDefXsdToJsonValue( @@ -1146,16 +1132,14 @@ public override Nodes.JsonObject Transform(ReferenceElement that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.Value != null) @@ -1254,16 +1238,14 @@ public override Nodes.JsonObject Transform(Blob that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["modelType"] = "Blob"; @@ -1356,16 +1338,14 @@ public override Nodes.JsonObject Transform(File that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["modelType"] = "File"; @@ -1458,16 +1438,14 @@ public override Nodes.JsonObject Transform(AnnotatedRelationshipElement that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["modelType"] = "AnnotatedRelationshipElement"; @@ -1560,16 +1538,14 @@ public override Nodes.JsonObject Transform(Entity that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["entityType"] = Serialize.EntityTypeToJsonValue( @@ -1711,16 +1687,14 @@ public override Nodes.JsonObject Transform(BasicEventElement that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["direction"] = Serialize.DirectionToJsonValue( @@ -1849,16 +1823,14 @@ public override Nodes.JsonObject Transform(Operation that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.InputVariables != null) @@ -1997,16 +1969,14 @@ public override Nodes.JsonObject Transform(Capability that) result["qualifiers"] = arrayQualifiers; } - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } result["modelType"] = "Capability"; @@ -2069,16 +2039,14 @@ public override Nodes.JsonObject Transform(ConceptDescription that) result["id"] = Nodes.JsonValue.Create( that.Id); - if (that.DataSpecifications != null) + if (that.EmbeddedDataSpecifications != null) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (Reference item in that.DataSpecifications) + var arrayEmbeddedDataSpecifications = new Nodes.JsonArray(); + foreach (EmbeddedDataSpecification item in that.EmbeddedDataSpecifications) { - arrayDataSpecifications.Add( - Transform( - item)); + arrayEmbeddedDataSpecifications.Add(Transform(item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["embeddedDataSpecifications"] = arrayEmbeddedDataSpecifications; } if (that.IsCaseOf != null) @@ -2149,12 +2117,13 @@ public override Nodes.JsonObject Transform(LangString that) return result; } - public override Nodes.JsonObject Transform(LangStringSet that) + //public override Nodes.JsonObject Transform(List that) + public Nodes.JsonObject Transform(List that) { var result = new Nodes.JsonObject(); var arrayLangStrings = new Nodes.JsonArray(); - foreach (LangString item in that.LangStrings) + foreach (LangString item in that) { arrayLangStrings.Add( Transform( @@ -2165,37 +2134,7 @@ public override Nodes.JsonObject Transform(LangStringSet that) return result; } - public override Nodes.JsonObject Transform(DataSpecificationContent that) - { - var result = new Nodes.JsonObject(); - - return result; - } - - public override Nodes.JsonObject Transform(DataSpecification that) - { - var result = new Nodes.JsonObject(); - - result["id"] = Nodes.JsonValue.Create( - that.Id); - result["dataSpecificationContent"] = Transform( - that.DataSpecificationContent); - - if (that.Administration != null) - { - result["administration"] = Transform( - that.Administration); - } - - if (that.Description != null) - { - result["description"] = Transform( - that.Description); - } - - return result; - } public override Nodes.JsonObject Transform(AasCore.Aas3_0_RC02.Environment that) { @@ -2237,20 +2176,235 @@ public override Nodes.JsonObject Transform(AasCore.Aas3_0_RC02.Environment that) result["conceptDescriptions"] = arrayConceptDescriptions; } - if (that.DataSpecifications != null) + return result; + } + + public override Nodes.JsonObject Transform(EmbeddedDataSpecification that) + { + var result = new Nodes.JsonObject(); + + result["dataSpecification"] = Transform( + that.DataSpecification); + + result["dataSpecificationContent"] = Transform( + that.DataSpecificationContent); + + return result; + } + + public override Nodes.JsonObject Transform(ValueReferencePair that) + { + var result = new Nodes.JsonObject(); + + result["value"] = Nodes.JsonValue.Create( + that.Value); + + result["valueId"] = Transform( + that.ValueId); + + return result; + } + + public override Nodes.JsonObject Transform(ValueList that) + { + var result = new Nodes.JsonObject(); + + var arrayValueReferencePairs = new Nodes.JsonArray(); + foreach (ValueReferencePair item in that.ValueReferencePairs) { - var arrayDataSpecifications = new Nodes.JsonArray(); - foreach (DataSpecification item in that.DataSpecifications) + arrayValueReferencePairs.Add( + Transform( + item)); + } + result["valueReferencePairs"] = arrayValueReferencePairs; + + return result; + } + + public override Nodes.JsonObject Transform(DataSpecificationIec61360 that) + { + var result = new Nodes.JsonObject(); + + var arrayPreferredName = new Nodes.JsonArray(); + foreach (LangString item in that.PreferredName) + { + arrayPreferredName.Add( + Transform( + item)); + } + result["preferredName"] = arrayPreferredName; + + if (that.ShortName != null) + { + var arrayShortName = new Nodes.JsonArray(); + foreach (LangString item in that.ShortName) { - arrayDataSpecifications.Add( + arrayShortName.Add( Transform( item)); } - result["dataSpecifications"] = arrayDataSpecifications; + result["shortName"] = arrayShortName; + } + + if (that.Unit != null) + { + result["unit"] = Nodes.JsonValue.Create( + that.Unit); + } + + if (that.UnitId != null) + { + result["unitId"] = Transform( + that.UnitId); + } + + if (that.SourceOfDefinition != null) + { + result["sourceOfDefinition"] = Nodes.JsonValue.Create( + that.SourceOfDefinition); + } + + if (that.Symbol != null) + { + result["symbol"] = Nodes.JsonValue.Create( + that.Symbol); + } + + if (that.DataType != null) + { + // We need to help the static analyzer with a null coalescing. + DataTypeIec61360 value = that.DataType + ?? throw new System.InvalidOperationException(); + result["dataType"] = Serialize.DataTypeIec61360ToJsonValue( + value); + } + + if (that.Definition != null) + { + var arrayDefinition = new Nodes.JsonArray(); + foreach (LangString item in that.Definition) + { + arrayDefinition.Add( + Transform( + item)); + } + result["definition"] = arrayDefinition; + } + + if (that.ValueFormat != null) + { + result["valueFormat"] = Nodes.JsonValue.Create( + that.ValueFormat); + } + + if (that.ValueList != null) + { + result["valueList"] = Transform( + that.ValueList); + } + + if (that.Value != null) + { + result["value"] = Nodes.JsonValue.Create( + that.Value); + } + + if (that.LevelType != null) + { + // We need to help the static analyzer with a null coalescing. + LevelType value = that.LevelType + ?? throw new System.InvalidOperationException(); + result["levelType"] = Serialize.LevelTypeToJsonValue( + value); } + result["modelType"] = "DataSpecificationIEC61360"; + return result; } + public override Nodes.JsonObject Transform(DataSpecificationPhysicalUnit that) + { + var result = new Nodes.JsonObject(); + + result["unitName"] = Nodes.JsonValue.Create( + that.UnitName); + + result["unitSymbol"] = Nodes.JsonValue.Create( + that.UnitSymbol); + + var arrayDefinition = new Nodes.JsonArray(); + foreach (LangString item in that.Definition) + { + arrayDefinition.Add( + Transform( + item)); + } + result["definition"] = arrayDefinition; + + if (that.SiNotation != null) + { + result["siNotation"] = Nodes.JsonValue.Create( + that.SiNotation); + } + + if (that.SiName != null) + { + result["siName"] = Nodes.JsonValue.Create( + that.SiName); + } + + if (that.DinNotation != null) + { + result["dinNotation"] = Nodes.JsonValue.Create( + that.DinNotation); + } + + if (that.EceName != null) + { + result["eceName"] = Nodes.JsonValue.Create( + that.EceName); + } + + if (that.EceCode != null) + { + result["eceCode"] = Nodes.JsonValue.Create( + that.EceCode); + } + + if (that.NistName != null) + { + result["nistName"] = Nodes.JsonValue.Create( + that.NistName); + } + + if (that.SourceOfDefinition != null) + { + result["sourceOfDefinition"] = Nodes.JsonValue.Create( + that.SourceOfDefinition); + } + + if (that.ConversionFactor != null) + { + result["conversionFactor"] = Nodes.JsonValue.Create( + that.ConversionFactor); + } + + if (that.RegistrationAuthorityId != null) + { + result["registrationAuthorityId"] = Nodes.JsonValue.Create( + that.RegistrationAuthorityId); + } + + if (that.Supplier != null) + { + result["supplier"] = Nodes.JsonValue.Create( + that.Supplier); + } + + result["modelType"] = "DataSpecificationPhysicalUnit"; + + return result; + } } } diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/BlobValue.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/BlobValue.cs deleted file mode 100644 index db8b93bbd..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/BlobValue.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.ValueOnly -{ - internal class BlobValue : IValue - { - public BlobValue(string idShort, string contentType, byte[] value) - { - IdShort = idShort; - ContentType = contentType; - Value = value; - } - - public string IdShort { get; } - public string ContentType { get; } - public byte[] Value { get; } - - public void ToJsonObject(Stream body) - { - var writerOptions = new JsonWriterOptions - { - Indented = true - }; - var writer = new Utf8JsonWriter(body, writerOptions); - writer.WriteStartObject(); - writer.WritePropertyName(IdShort); - writer.WriteStringValue(Value); - writer.WriteStartObject(); - writer.WritePropertyName("contentType"); - writer.WriteStringValue(ContentType); - writer.WritePropertyName("value"); - writer.WriteStringValue(Value); - writer.WriteEndObject(); - writer.FlushAsync().GetAwaiter().GetResult(); - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/FileValue.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/FileValue.cs deleted file mode 100644 index 1fd3c16c3..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/FileValue.cs +++ /dev/null @@ -1,43 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.ValueOnly -{ - internal class FileValue : IValue - { - public FileValue(string idShort, string contentType, string value) - { - IdShort = idShort; - ContentType = contentType; - Value = value; - } - - public string IdShort { get; } - public string ContentType { get; } - public string Value { get; } - - public void ToJsonObject(Stream body) - { - var writerOptions = new JsonWriterOptions - { - Indented = true - }; - var writer = new Utf8JsonWriter(body, writerOptions); - writer.WriteStartObject(); - writer.WritePropertyName(IdShort); - writer.WriteStringValue(Value); - writer.WriteStartObject(); - writer.WritePropertyName("contentType"); - writer.WriteStringValue(ContentType); - writer.WritePropertyName("value"); - writer.WriteStringValue(Value); - writer.WriteEndObject(); - writer.FlushAsync().GetAwaiter().GetResult(); - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/IUpdateTransformerWithContext.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/IUpdateTransformerWithContext.cs deleted file mode 100644 index a33b0079a..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/IUpdateTransformerWithContext.cs +++ /dev/null @@ -1,48 +0,0 @@ -using AasCore.Aas3_0_RC02; -using IO.Swagger.V1RC03.APIModels.Core; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using static AasCore.Aas3_0_RC02.Visitation; - -namespace IO.Swagger.V1RC03.APIModels.ValueOnly -{ - internal interface IUpdateTransformerWithContext : ITransformerWithContext - { - public void Transform(IClass that, IClass source, OutputModifierContext context); - public void Transform(Extension that, Extension source, OutputModifierContext context); - public void Transform(AdministrativeInformation that, AdministrativeInformation source, OutputModifierContext context); - public void Transform(Qualifier that, Qualifier source, OutputModifierContext context); - public void Transform(AssetAdministrationShell that, AssetAdministrationShell source, OutputModifierContext context); - public void Transform(AssetInformation that, AssetInformation source, OutputModifierContext context); - public void Transform(Resource that, Resource source, OutputModifierContext context); - public void Transform(SpecificAssetId that, SpecificAssetId source, OutputModifierContext context); - public void Transform(Submodel that, Submodel source, OutputModifierContext context); - public void Transform(RelationshipElement that, RelationshipElement source, OutputModifierContext context); - public void Transform(SubmodelElementList that, SubmodelElementList source, OutputModifierContext context); - public void Transform(SubmodelElementCollection that, SubmodelElementCollection source, OutputModifierContext context); - public void Transform(Property that, Property source, OutputModifierContext context); - public void Transform(MultiLanguageProperty that, MultiLanguageProperty source, OutputModifierContext context); - public void Transform(AasCore.Aas3_0_RC02.Range that, OutputModifierContext context); - public void Transform(ReferenceElement that, ReferenceElement source, OutputModifierContext context); - public void Transform(Blob that, Blob source, OutputModifierContext context); - public void Transform(File that, File source, OutputModifierContext context); - public void Transform(AnnotatedRelationshipElement that, AnnotatedRelationshipElement source, OutputModifierContext context); - public void Transform(Entity that, Entity source, OutputModifierContext context); - public void Transform(EventPayload that, EventPayload source, OutputModifierContext context); - public void Transform(BasicEventElement that, BasicEventElement source, OutputModifierContext context); - public void Transform(Operation that, Operation source, OutputModifierContext context); - public void Transform(OperationVariable that, OperationVariable source, OutputModifierContext context); - public void Transform(Capability that, Capability source, OutputModifierContext context); - public void Transform(ConceptDescription that, ConceptDescription source, OutputModifierContext context); - public void Transform(Reference that, Reference source, OutputModifierContext context); - public void Transform(Key that, Key source, OutputModifierContext context); - public void Transform(LangString that, LangString source, OutputModifierContext context); - public void Transform(LangStringSet that, LangStringSet source, OutputModifierContext context); - public void Transform(DataSpecificationContent that, DataSpecificationContent source, OutputModifierContext context); - public void Transform(DataSpecification that, DataSpecification source, OutputModifierContext context); - public void Transform(AasCore.Aas3_0_RC02.Environment that, OutputModifierContext context); - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/MultiLanguagePropertyValue.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/MultiLanguagePropertyValue.cs deleted file mode 100644 index 802456b8d..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/MultiLanguagePropertyValue.cs +++ /dev/null @@ -1,45 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.ValueOnly -{ - internal class MultiLanguagePropertyValue : IValue - { - public MultiLanguagePropertyValue(string idShort, LangStringSet value) - { - IdShort = idShort; - Value = value; - } - - public string IdShort { get; } - public LangStringSet Value { get; } - - public void ToJsonObject(Stream body) - { - var writerOptions = new JsonWriterOptions - { - Indented = true - }; - var writer = new Utf8JsonWriter(body, writerOptions); - writer.WriteStartObject(); - writer.WritePropertyName(IdShort); - writer.WriteStartArray(); - foreach (var langString in Value.LangStrings) - { - writer.WriteStartObject(); - writer.WritePropertyName(langString.Language); - writer.WriteStringValue(langString.Text); - writer.WriteEndObject(); - } - writer.WriteEndArray(); - writer.WriteEndObject(); - writer.FlushAsync().GetAwaiter().GetResult(); - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/PropertyValue.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/PropertyValue.cs deleted file mode 100644 index 2a4c91b70..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/PropertyValue.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.ValueOnly -{ - internal class PropertyValue : IValue - { - public string IdShort { get; set; } - public string Value { get; set; } - - public PropertyValue(string idShort, string value) - { - IdShort = idShort; - Value = value; - } - - public void ToJsonObject(System.IO.Stream body) - { - var writerOptions = new JsonWriterOptions - { - Indented = true - }; - var writer = new Utf8JsonWriter(body, writerOptions); - writer.WriteStartObject(); - writer.WritePropertyName(IdShort); - writer.WriteStringValue(Value); - writer.WriteEndObject(); - writer.FlushAsync().GetAwaiter().GetResult(); - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/RangeValue.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/RangeValue.cs deleted file mode 100644 index fddffe0f2..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/RangeValue.cs +++ /dev/null @@ -1,44 +0,0 @@ -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.ValueOnly -{ - internal class RangeValue : IValue - { - public RangeValue(string idShort, string min, string max) - { - IdShort = idShort; - Min = min; - Max = max; - } - - public string IdShort { get; } - public string Min { get; } - public string Max { get; } - - public void ToJsonObject(Stream body) - { - var writerOptions = new JsonWriterOptions - { - Indented = true - }; - var writer = new Utf8JsonWriter(body, writerOptions); - writer.WriteStartObject(); - writer.WritePropertyName(IdShort); - writer.WriteStartObject(); - writer.WritePropertyName("min"); - writer.WriteStringValue(Min); - writer.WritePropertyName("max"); - writer.WriteStringValue(Max); - writer.WriteEndObject(); - writer.WriteEndObject(); - writer.FlushAsync().GetAwaiter().GetResult(); - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ReferenceElementValue.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ReferenceElementValue.cs deleted file mode 100644 index 5adfc7d52..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ReferenceElementValue.cs +++ /dev/null @@ -1,51 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.ValueOnly -{ - internal class ReferenceElementValue : IValue - { - public ReferenceElementValue(string idShort, Reference value) - { - IdShort = idShort; - Value = value; - } - - public string IdShort { get; } - public Reference Value { get; } - - public void ToJsonObject(Stream body) - { - var writerOptions = new JsonWriterOptions - { - Indented = true - }; - var writer = new Utf8JsonWriter(body, writerOptions); - writer.WriteStartObject(); - writer.WritePropertyName(IdShort); - writer.WriteStartObject(); - writer.WritePropertyName("type"); - writer.WriteStringValue(Value.Type.ToString()); - writer.WritePropertyName("keys"); - writer.WriteStartArray(); - foreach (var key in Value.Keys) - { - writer.WriteStartObject(); - writer.WritePropertyName("type"); - writer.WriteStringValue(key.Type.ToString()); - writer.WritePropertyName("value"); - writer.WriteStringValue(key.Value); - writer.WriteEndObject(); - } - writer.WriteEndArray(); - writer.WriteEndObject(); - writer.FlushAsync().GetAwaiter().GetResult(); - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/RelationshipElementValue.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/RelationshipElementValue.cs deleted file mode 100644 index cb89d91c5..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/RelationshipElementValue.cs +++ /dev/null @@ -1,78 +0,0 @@ -using AasCore.Aas3_0_RC02; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.ValueOnly -{ - internal class RelationshipElementValue : IValue - { - public RelationshipElementValue(string idShort, Reference first, Reference second) - { - IdShort = idShort; - First = first; - Second = second; - } - - public string IdShort { get; } - public Reference First { get; } - public Reference Second { get; } - - - public void ToJsonObject(Stream body) - { - var writerOptions = new JsonWriterOptions - { - Indented = true - }; - var writer = new Utf8JsonWriter(body, writerOptions); - writer.WriteStartObject(); - writer.WritePropertyName(IdShort); - //first - writer.WriteStartObject(); - writer.WritePropertyName("first"); - writer.WriteStartObject(); - writer.WritePropertyName("modelType"); - writer.WriteStringValue(First.Type.ToString()); - writer.WritePropertyName("keys"); - writer.WriteStartArray(); - foreach (var key in First.Keys) - { - writer.WriteStartObject(); - writer.WritePropertyName("type"); - writer.WriteStringValue(key.Type.ToString()); - writer.WritePropertyName("value"); - writer.WriteStringValue(key.Value); - writer.WriteEndObject(); - } - writer.WriteEndArray(); - writer.WriteEndObject(); - //Second - writer.WriteStartObject(); - writer.WritePropertyName("second"); - writer.WriteStartObject(); - writer.WritePropertyName("modelType"); - writer.WriteStringValue(First.Type.ToString()); - writer.WritePropertyName("keys"); - writer.WriteStartArray(); - foreach (var key in First.Keys) - { - writer.WriteStartObject(); - writer.WritePropertyName("type"); - writer.WriteStringValue(key.Type.ToString()); - writer.WritePropertyName("value"); - writer.WriteStringValue(key.Value); - writer.WriteEndObject(); - } - writer.WriteEndArray(); - //end - writer.WriteEndObject(); - writer.FlushAsync().GetAwaiter().GetResult(); - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/SubmodelValue.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/SubmodelValue.cs deleted file mode 100644 index bf993bf32..000000000 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/SubmodelValue.cs +++ /dev/null @@ -1,39 +0,0 @@ -using AasCore.Aas3_0_RC02; -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; - -namespace IO.Swagger.V1RC03.APIModels.ValueOnly -{ - internal class SubmodelValue : IValue - { - - public SubmodelValue(List submodelElements) - { - this.SubmodelElements = submodelElements; - } - - public List SubmodelElements { get; } - - public void ToJsonObject(Stream body) - { - var writerOptions = new JsonWriterOptions - { - Indented = true - }; - - var writer = new Utf8JsonWriter(body, writerOptions); - writer.WriteStartObject(); - foreach (var submodelElement in SubmodelElements) - { - submodelElement.ToJsonObject(body); - } - writer.WriteEndObject(); - writer.FlushAsync().GetAwaiter().GetResult(); - } - } -} diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/UpdateTransformer.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/UpdateTransformer.cs index 16a62c185..04c3b0ec0 100644 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/UpdateTransformer.cs +++ b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/UpdateTransformer.cs @@ -1,11 +1,6 @@ using AasCore.Aas3_0_RC02; -using AasxServerStandardBib.Exceptions; -using IO.Swagger.V1RC03.APIModels.Core; using System; -using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; using static AasCore.Aas3_0_RC02.Visitation; namespace IO.Swagger.V1RC03.APIModels.ValueOnly @@ -63,7 +58,7 @@ public IClass Transform(Submodel that, UpdateContext context) //First check if number of elements in source and that are equal if (that.SubmodelElements == null || that.SubmodelElements.Count != source.SubmodelElements.Count) { - throw new InvalidNumberOfChildElementsException("Submodel : " + that.IdShort, source.SubmodelElements.Count, that.SubmodelElements.Count); + throw new Exceptions.InvalidNumberOfChildElementsException("Submodel : " + that.IdShort, source.SubmodelElements.Count, that.SubmodelElements.Count); } for (int i = 0; i < source.SubmodelElements.Count; i++) { @@ -83,7 +78,7 @@ public IClass Transform(Submodel that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; if (outputModifierContext.IncludeChildren) { @@ -96,7 +91,7 @@ public IClass Transform(Submodel that, UpdateContext context) //First check if number of elements in source and that are equal if (that.SubmodelElements == null || that.SubmodelElements.Count != source.SubmodelElements.Count) { - throw new InvalidNumberOfChildElementsException("Submodel : " + that.IdShort, source.SubmodelElements.Count, that.SubmodelElements.Count); + throw new Exceptions.InvalidNumberOfChildElementsException("Submodel : " + that.IdShort, source.SubmodelElements.Count, that.SubmodelElements.Count); } for (int i = 0; i < source.SubmodelElements.Count; i++) { @@ -129,7 +124,7 @@ public IClass Transform(RelationshipElement that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; if (!outputModifierContext.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) { @@ -151,7 +146,7 @@ public IClass Transform(SubmodelElementList that, UpdateContext context) //First check if number of elements in source and that are equal if (that.Value == null || that.Value.Count != source.Value.Count) { - throw new InvalidNumberOfChildElementsException("SubmodelElementList : " + that.IdShort, source.Value.Count, that.Value.Count); + throw new Exceptions.InvalidNumberOfChildElementsException("SubmodelElementList : " + that.IdShort, source.Value.Count, that.Value.Count); } for (int i = 0; i < source.Value.Count; i++) { @@ -171,7 +166,7 @@ public IClass Transform(SubmodelElementList that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; if (outputModifierContext.IncludeChildren) { @@ -184,7 +179,7 @@ public IClass Transform(SubmodelElementList that, UpdateContext context) //First check if number of elements in source and that are equal if (that.Value == null || that.Value.Count != source.Value.Count) { - throw new InvalidNumberOfChildElementsException("SubmodelElementList : " + that.IdShort, source.Value.Count, that.Value.Count); + throw new Exceptions.InvalidNumberOfChildElementsException("SubmodelElementList : " + that.IdShort, source.Value.Count, that.Value.Count); } for (int i = 0; i < source.Value.Count; i++) { @@ -207,7 +202,7 @@ public IClass Transform(SubmodelElementCollection that, UpdateContext context) //First check if number of elements in source and that are equal if (that.Value == null || that.Value.Count != source.Value.Count) { - throw new InvalidNumberOfChildElementsException("SubmodelElementCollection : " + that.IdShort, source.Value.Count, that.Value.Count); + throw new Exceptions.InvalidNumberOfChildElementsException("SubmodelElementCollection : " + that.IdShort, source.Value.Count, that.Value.Count); } for (int i = 0; i < source.Value.Count; i++) { @@ -227,7 +222,7 @@ public IClass Transform(SubmodelElementCollection that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; if (outputModifierContext.IncludeChildren) { @@ -240,7 +235,7 @@ public IClass Transform(SubmodelElementCollection that, UpdateContext context) //First check if number of elements in source and that are equal if (that.Value == null || that.Value.Count != source.Value.Count) { - throw new InvalidNumberOfChildElementsException("SubmodelElementCollection : " + that.IdShort, source.Value.Count, that.Value.Count); + throw new Exceptions.InvalidNumberOfChildElementsException("SubmodelElementCollection : " + that.IdShort, source.Value.Count, that.Value.Count); } for (int i = 0; i < source.Value.Count; i++) { @@ -272,7 +267,7 @@ public IClass Transform(Property that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; that.ValueType = source.ValueType; that.ValueId = source.ValueId; @@ -304,7 +299,7 @@ public IClass Transform(MultiLanguageProperty that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; that.ValueId = source.ValueId; if (!outputModifierContext.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) @@ -336,7 +331,7 @@ public IClass Transform(AasCore.Aas3_0_RC02.Range that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; that.ValueType = source.ValueType; if (!outputModifierContext.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) @@ -368,7 +363,7 @@ public IClass Transform(ReferenceElement that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; if (!outputModifierContext.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) { @@ -402,7 +397,7 @@ public IClass Transform(Blob that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; if (!outputModifierContext.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) { @@ -434,7 +429,7 @@ public IClass Transform(File that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; if (!outputModifierContext.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) { @@ -458,7 +453,7 @@ public IClass Transform(AnnotatedRelationshipElement that, UpdateContext context //First check if number of elements in source and that are equal if (that.Annotations == null || that.Annotations.Count != source.Annotations.Count) { - throw new InvalidNumberOfChildElementsException("AnnotedRelationshipElement : " + that.IdShort, source.Annotations.Count, that.Annotations.Count); + throw new Exceptions.InvalidNumberOfChildElementsException("AnnotedRelationshipElement : " + that.IdShort, source.Annotations.Count, that.Annotations.Count); } for (int i = 0; i < source.Annotations.Count; i++) { @@ -478,7 +473,7 @@ public IClass Transform(AnnotatedRelationshipElement that, UpdateContext context that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; if (!outputModifierContext.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) { @@ -497,7 +492,7 @@ public IClass Transform(AnnotatedRelationshipElement that, UpdateContext context //First check if number of elements in source and that are equal if (that.Annotations == null || that.Annotations.Count != source.Annotations.Count) { - throw new InvalidNumberOfChildElementsException("AnnotedRelationshipElement : " + that.IdShort, source.Annotations.Count, that.Annotations.Count); + throw new Exceptions.InvalidNumberOfChildElementsException("AnnotedRelationshipElement : " + that.IdShort, source.Annotations.Count, that.Annotations.Count); } for (int i = 0; i < source.Annotations.Count; i++) { @@ -530,7 +525,7 @@ public IClass Transform(Entity that, UpdateContext context) { if (that.Statements == null || that.Statements.Count != source.Statements.Count) { - throw new InvalidNumberOfChildElementsException("Entity : " + that.IdShort, source.Statements.Count, that.Statements.Count); + throw new Exceptions.InvalidNumberOfChildElementsException("Entity : " + that.IdShort, source.Statements.Count, that.Statements.Count); } for (int i = 0; i < source.Statements.Count; i++) { @@ -550,7 +545,7 @@ public IClass Transform(Entity that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; that.EntityType = source.EntityType; if (!outputModifierContext.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) @@ -576,7 +571,7 @@ public IClass Transform(Entity that, UpdateContext context) { if (that.Statements == null || that.Statements.Count != source.Statements.Count) { - throw new InvalidNumberOfChildElementsException("Entity : " + that.IdShort, source.Statements.Count, that.Statements.Count); + throw new Exceptions.InvalidNumberOfChildElementsException("Entity : " + that.IdShort, source.Statements.Count, that.Statements.Count); } for (int i = 0; i < source.Statements.Count; i++) { @@ -614,7 +609,7 @@ public IClass Transform(BasicEventElement that, UpdateContext context) that.SemanticId = source.SemanticId; that.SupplementalSemanticIds = source.SupplementalSemanticIds; that.Qualifiers = source.Qualifiers; - that.DataSpecifications = source.DataSpecifications; + that.EmbeddedDataSpecifications = source.EmbeddedDataSpecifications; if (!outputModifierContext.Content.Equals("metadata", StringComparison.OrdinalIgnoreCase)) { @@ -658,22 +653,32 @@ public IClass Transform(LangString that, UpdateContext context) throw new NotImplementedException(); } - public IClass Transform(LangStringSet that, UpdateContext context) + public IClass Transform(AasCore.Aas3_0_RC02.Environment that, UpdateContext context) { throw new NotImplementedException(); } - public IClass Transform(DataSpecificationContent that, UpdateContext context) + public IClass Transform(EmbeddedDataSpecification that, UpdateContext context) { throw new NotImplementedException(); } - public IClass Transform(DataSpecification that, UpdateContext context) + public IClass Transform(ValueReferencePair that, UpdateContext context) { throw new NotImplementedException(); } - public IClass Transform(AasCore.Aas3_0_RC02.Environment that, UpdateContext context) + public IClass Transform(ValueList that, UpdateContext context) + { + throw new NotImplementedException(); + } + + public IClass Transform(DataSpecificationIec61360 that, UpdateContext context) + { + throw new NotImplementedException(); + } + + public IClass Transform(DataSpecificationPhysicalUnit that, UpdateContext context) { throw new NotImplementedException(); } diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ValueOnlyDeserializer.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ValueOnlyDeserializer.cs index 755a63bdc..1bbb4b02c 100644 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ValueOnlyDeserializer.cs +++ b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ValueOnlyDeserializer.cs @@ -1,13 +1,9 @@ using AasCore.Aas3_0_RC02; -using AasxServerStandardBib.Exceptions; -using IO.Swagger.V1RC03.Logging; +using AasxServerStandardBib.Logging; +using IO.Swagger.V1RC03.Exceptions; using IO.Swagger.V1RC03.Services; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Text.Json.Nodes; -using System.Threading.Tasks; namespace IO.Swagger.V1RC03.APIModels.ValueOnly { @@ -391,7 +387,6 @@ private ISubmodelElement CreateRange(string idShort, JsonObject jsonObject) private ISubmodelElement CreateMultilanguageProperty(string idShort, JsonArray jsonArray) { var langStrings = new List(); - var langStringSet = new LangStringSet(langStrings); var enumerator = jsonArray.GetEnumerator(); while (enumerator.MoveNext()) { @@ -401,7 +396,7 @@ private ISubmodelElement CreateMultilanguageProperty(string idShort, JsonArray j langStrings.Add(langString); } - return new MultiLanguageProperty(idShort: idShort, value: langStringSet); + return new MultiLanguageProperty(idShort: idShort, value: langStrings); } private void GetPropertyFromJsonObject(JsonObject item, out string propertyName, out string propertyValue) diff --git a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ValueTransformer.cs b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ValueTransformer.cs index 877822953..b5e7ecefb 100644 --- a/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ValueTransformer.cs +++ b/src/IO.Swagger.V1RC03/APIModels/ValueOnly/ValueTransformer.cs @@ -1,6 +1,7 @@ using AasCore.Aas3_0_RC02; using IO.Swagger.V1RC03.APIModels.Core; using Org.BouncyCastle.Utilities.Encoders; +using System.Collections.Generic; using System.Text.Json.Nodes; using static AasCore.Aas3_0_RC02.Jsonization; using static AasCore.Aas3_0_RC02.Visitation; @@ -321,35 +322,46 @@ public JsonObject Transform(LangString that, OutputModifierContext context) return result; } - public JsonObject Transform(LangStringSet that, OutputModifierContext context) + + public JsonObject Transform(Environment that, OutputModifierContext context) { throw new System.NotImplementedException(); } - public JsonObject Transform(DataSpecificationContent that, OutputModifierContext context) + public JsonObject Transform(IClass that, OutputModifierContext context) + { + return that.Transform(this, context); + } + + public JsonObject Transform(EmbeddedDataSpecification that, OutputModifierContext context) { throw new System.NotImplementedException(); } - public JsonObject Transform(DataSpecification that, OutputModifierContext context) + public JsonObject Transform(ValueReferencePair that, OutputModifierContext context) { throw new System.NotImplementedException(); } - public JsonObject Transform(Environment that, OutputModifierContext context) + public JsonObject Transform(ValueList that, OutputModifierContext context) { throw new System.NotImplementedException(); } - public JsonObject Transform(IClass that, OutputModifierContext context) + public JsonObject Transform(DataSpecificationIec61360 that, OutputModifierContext context) { - return that.Transform(this, context); + throw new System.NotImplementedException(); + } + + public JsonObject Transform(DataSpecificationPhysicalUnit that, OutputModifierContext context) + { + throw new System.NotImplementedException(); } - internal JsonNode TransformValue(LangStringSet that, OutputModifierContext context) + internal JsonNode TransformValue(List that, OutputModifierContext context) { var arrayLangStrings = new Nodes.JsonArray(); - foreach (LangString item in that.LangStrings) + foreach (LangString item in that) { arrayLangStrings.Add( Transform( diff --git a/src/IO.Swagger.V1RC03/AasCoreOutputFormatter.cs b/src/IO.Swagger.V1RC03/AasCoreOutputFormatter.cs index 390071896..80a6327b1 100644 --- a/src/IO.Swagger.V1RC03/AasCoreOutputFormatter.cs +++ b/src/IO.Swagger.V1RC03/AasCoreOutputFormatter.cs @@ -49,10 +49,6 @@ public override bool CanWriteResult(OutputFormatterCanWriteContext context) { return base.CanWriteResult(context); } - if (typeof(IValue).IsAssignableFrom(context.ObjectType)) - { - return base.CanWriteResult(context); - } else return false; } diff --git a/src/IO.Swagger.V1RC03/Controllers/AASXFileServerAPI.cs b/src/IO.Swagger.V1RC03/Controllers/AASXFileServerAPI.cs index 23a63858f..621cb609f 100644 --- a/src/IO.Swagger.V1RC03/Controllers/AASXFileServerAPI.cs +++ b/src/IO.Swagger.V1RC03/Controllers/AASXFileServerAPI.cs @@ -7,23 +7,18 @@ * * 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.V1RC03.Attributes; - -using Microsoft.AspNetCore.Authorization; +using AasxServerStandardBib.Logging; using IO.Swagger.V1RC03.ApiModel; -using IO.Swagger.V1RC03.Logging; +using IO.Swagger.V1RC03.Attributes; using IO.Swagger.V1RC03.Services; -using System.Net.Mime; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; +using Swashbuckle.AspNetCore.Annotations; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; using System.IO; -using Microsoft.IdentityModel.Tokens; +using System.Net.Mime; namespace IO.Swagger.V1RC03.Controllers { diff --git a/src/IO.Swagger.V1RC03/Controllers/AssetAdministrationShellEnvironmentAPIApi.cs b/src/IO.Swagger.V1RC03/Controllers/AssetAdministrationShellEnvironmentAPIApi.cs index 6f0201d28..b2ab196df 100644 --- a/src/IO.Swagger.V1RC03/Controllers/AssetAdministrationShellEnvironmentAPIApi.cs +++ b/src/IO.Swagger.V1RC03/Controllers/AssetAdministrationShellEnvironmentAPIApi.cs @@ -7,40 +7,23 @@ * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ -using System; -using System.Collections.Generic; +using AasCore.Aas3_0_RC02; +using AasxServerStandardBib.Logging; +using IO.Swagger.Lib.V3.Interfaces; +using IO.Swagger.V1RC03.ApiModel; +using IO.Swagger.V1RC03.APIModels; +using IO.Swagger.V1RC03.APIModels.Core; +using IO.Swagger.V1RC03.Attributes; +using IO.Swagger.V1RC03.Services; +using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Swashbuckle.AspNetCore.Annotations; -using Swashbuckle.AspNetCore.SwaggerGen; +using System; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using IO.Swagger.V1RC03.Attributes; - -using Microsoft.AspNetCore.Authorization; -using IO.Swagger.V1RC03.ApiModel; -using AasCore.Aas3_0_RC02; -using IO.Swagger.V1RC03.Logging; -using IO.Swagger.V1RC03.Services; -using System.Text.Json; -using Org.BouncyCastle.Utilities.Encoders; -using Microsoft.IdentityModel.Tokens; -using Opc.Ua; -using System.Text.Json.Nodes; -using Microsoft.VisualBasic; using System.IO; -using System.Text; -using IO.Swagger.V1RC03.ModelBinder; using System.Net.Mime; -using IO.Swagger.V1RC03.APIModels.Core; -using Microsoft.AspNetCore.Http; -using IO.Swagger.V1RC03.APIModels; -using System.Collections.Specialized; -using Grapevine.Client; -using System.Web; -using AasxServer; -using Grapevine.Interfaces.Server; -using System.Dynamic; using HttpContext = Microsoft.AspNetCore.Http.HttpContext; -using AasxServerStandardBib.Exceptions; namespace IO.Swagger.V1RC03.Controllers { diff --git a/src/IO.Swagger.V1RC03/Controllers/AssetAdministrationShellEnvironmentSerializationAPIApi.cs b/src/IO.Swagger.V1RC03/Controllers/AssetAdministrationShellEnvironmentSerializationAPIApi.cs index 35097f465..ad1def677 100644 --- a/src/IO.Swagger.V1RC03/Controllers/AssetAdministrationShellEnvironmentSerializationAPIApi.cs +++ b/src/IO.Swagger.V1RC03/Controllers/AssetAdministrationShellEnvironmentSerializationAPIApi.cs @@ -7,20 +7,15 @@ * * Generated by: https://github.com/swagger-api/swagger-codegen.git */ -using System; -using System.Collections.Generic; +using AasxServerStandardBib.Logging; +using IO.Swagger.V1RC03.ApiModel; +using IO.Swagger.V1RC03.Attributes; +using IO.Swagger.V1RC03.Services; using Microsoft.AspNetCore.Mvc; -using Swashbuckle.AspNetCore.Annotations; -using Swashbuckle.AspNetCore.SwaggerGen; using Newtonsoft.Json; +using Swashbuckle.AspNetCore.Annotations; +using System.Collections.Generic; using System.ComponentModel.DataAnnotations; -using IO.Swagger.V1RC03.Attributes; - -using Microsoft.AspNetCore.Authorization; -using IO.Swagger.V1RC03.ApiModel; -using AasCore.Aas3_0_RC02; -using IO.Swagger.V1RC03.Logging; -using IO.Swagger.V1RC03.Services; namespace IO.Swagger.V1RC03.Controllers { diff --git a/src/IO.Swagger.V1RC03/Exceptions/Base64UrlDecoderException.cs b/src/IO.Swagger.V1RC03/Exceptions/Base64UrlDecoderException.cs new file mode 100644 index 000000000..e4636de46 --- /dev/null +++ b/src/IO.Swagger.V1RC03/Exceptions/Base64UrlDecoderException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IO.Swagger.V1RC03.Exceptions +{ + public class Base64UrlDecoderException : Exception + { + public Base64UrlDecoderException(string fieldName) : base($"Unable decode {fieldName}. Incorrect Base64Url encoded string.") + { + + } + } +} diff --git a/src/IO.Swagger.V1RC03/Exceptions/DuplicateException.cs b/src/IO.Swagger.V1RC03/Exceptions/DuplicateException.cs new file mode 100644 index 000000000..1e8dfd4af --- /dev/null +++ b/src/IO.Swagger.V1RC03/Exceptions/DuplicateException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AasxServerStandardBib.Exceptions +{ + public class DuplicateException : Exception + { + public DuplicateException(string message) : base(message) + { + + } + } +} diff --git a/src/IO.Swagger.V1RC03/Exceptions/InvalidNumberOfChildElements.cs b/src/IO.Swagger.V1RC03/Exceptions/InvalidNumberOfChildElements.cs new file mode 100644 index 000000000..028777364 --- /dev/null +++ b/src/IO.Swagger.V1RC03/Exceptions/InvalidNumberOfChildElements.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IO.Swagger.V1RC03.Exceptions +{ + //TODO: jtikekar change name + public class InvalidNumberOfChildElementsException : Exception + { + public InvalidNumberOfChildElementsException(string resourceName, int sourceCount, int expectedCount) : base($"Invalid child elements in {resourceName}. {expectedCount} child elements are expected, whereas {sourceCount} are found in the request.") + { + + } + } +} diff --git a/src/AasxServerStandardBib/Exceptions/InvalidOutputModifierException.cs b/src/IO.Swagger.V1RC03/Exceptions/InvalidOutputModifierException.cs similarity index 90% rename from src/AasxServerStandardBib/Exceptions/InvalidOutputModifierException.cs rename to src/IO.Swagger.V1RC03/Exceptions/InvalidOutputModifierException.cs index 39137f44a..593f244de 100644 --- a/src/AasxServerStandardBib/Exceptions/InvalidOutputModifierException.cs +++ b/src/IO.Swagger.V1RC03/Exceptions/InvalidOutputModifierException.cs @@ -4,7 +4,7 @@ using System.Text; using System.Threading.Tasks; -namespace AasxServerStandardBib.Exceptions +namespace IO.Swagger.V1RC03.Exceptions { //TODO:jtikekar Move to API project public class InvalidOutputModifierException : Exception diff --git a/src/IO.Swagger.V1RC03/Exceptions/JsonDeserializationException.cs b/src/IO.Swagger.V1RC03/Exceptions/JsonDeserializationException.cs new file mode 100644 index 000000000..a16dcc19f --- /dev/null +++ b/src/IO.Swagger.V1RC03/Exceptions/JsonDeserializationException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IO.Swagger.V1RC03.Exceptions +{ + public class JsonDeserializationException : Exception + { + public JsonDeserializationException(string fieldName, string message) : base($"Unable to deserialize {fieldName}. Reason: {message}") + { + + } + } +} diff --git a/src/IO.Swagger.V1RC03/Exceptions/NoIdentifierException.cs b/src/IO.Swagger.V1RC03/Exceptions/NoIdentifierException.cs new file mode 100644 index 000000000..b0423f1ad --- /dev/null +++ b/src/IO.Swagger.V1RC03/Exceptions/NoIdentifierException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IO.Swagger.V1RC03.Exceptions +{ + public class NoIdentifierException : Exception + { + public NoIdentifierException(string fieldName) : base($"No indentier found in {fieldName}.") + { + + } + } +} diff --git a/src/IO.Swagger.V1RC03/Exceptions/NotAllowed.cs b/src/IO.Swagger.V1RC03/Exceptions/NotAllowed.cs new file mode 100644 index 000000000..1cc2e1121 --- /dev/null +++ b/src/IO.Swagger.V1RC03/Exceptions/NotAllowed.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IO.Swagger.V1RC03.Exceptions +{ + public class NotAllowed : Exception + { + public NotAllowed(string message) : base(message) + { + + } + } +} diff --git a/src/IO.Swagger.V1RC03/Exceptions/NotFoundException.cs b/src/IO.Swagger.V1RC03/Exceptions/NotFoundException.cs new file mode 100644 index 000000000..b162317f3 --- /dev/null +++ b/src/IO.Swagger.V1RC03/Exceptions/NotFoundException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IO.Swagger.V1RC03.Exceptions +{ + public class NotFoundException : Exception + { + public NotFoundException(string message) : base(message) + { + + } + } +} diff --git a/src/IO.Swagger.V1RC03/Exceptions/NotImplementedException.cs b/src/IO.Swagger.V1RC03/Exceptions/NotImplementedException.cs new file mode 100644 index 000000000..b8c91f070 --- /dev/null +++ b/src/IO.Swagger.V1RC03/Exceptions/NotImplementedException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IO.Swagger.V1RC03.Exceptions +{ + internal class NotImplementedException :Exception + { + public NotImplementedException(string message) : base(message) + { + + } + } +} diff --git a/src/IO.Swagger.V1RC03/Exceptions/OperationVariableException.cs b/src/IO.Swagger.V1RC03/Exceptions/OperationVariableException.cs new file mode 100644 index 000000000..fafeceb74 --- /dev/null +++ b/src/IO.Swagger.V1RC03/Exceptions/OperationVariableException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IO.Swagger.V1RC03.Exceptions +{ + public class OperationVariableException : Exception + { + public OperationVariableException(string message) : base(message) + { + + } + } +} diff --git a/src/IO.Swagger.V1RC03/Exceptions/UnprocessableEntityException.cs b/src/IO.Swagger.V1RC03/Exceptions/UnprocessableEntityException.cs new file mode 100644 index 000000000..1b4fcdb03 --- /dev/null +++ b/src/IO.Swagger.V1RC03/Exceptions/UnprocessableEntityException.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace IO.Swagger.V1RC03.Exceptions +{ + public class UnprocessableEntityException : Exception + { + public UnprocessableEntityException(string message) : base(message) + { + + } + } +} diff --git a/src/IO.Swagger.V1RC03/IO.Swagger.V1RC03.csproj b/src/IO.Swagger.V1RC03/IO.Swagger.V1RC03.csproj index 84b729db6..572530b20 100644 --- a/src/IO.Swagger.V1RC03/IO.Swagger.V1RC03.csproj +++ b/src/IO.Swagger.V1RC03/IO.Swagger.V1RC03.csproj @@ -23,11 +23,7 @@ - - - - diff --git a/src/IO.Swagger.V1RC03/IO.Swagger.V1RC03.xml b/src/IO.Swagger.V1RC03/IO.Swagger.V1RC03.xml index 27f86e817..0f1402883 100644 --- a/src/IO.Swagger.V1RC03/IO.Swagger.V1RC03.xml +++ b/src/IO.Swagger.V1RC03/IO.Swagger.V1RC03.xml @@ -1747,7 +1747,7 @@ Operation OperationFilterContext - + Constructor @@ -1767,7 +1767,7 @@ - + diff --git a/src/IO.Swagger.V1RC03/Middleware/ExceptionMiddleware.cs b/src/IO.Swagger.V1RC03/Middleware/ExceptionMiddleware.cs index 3a976a1b4..87a30a954 100644 --- a/src/IO.Swagger.V1RC03/Middleware/ExceptionMiddleware.cs +++ b/src/IO.Swagger.V1RC03/Middleware/ExceptionMiddleware.cs @@ -1,13 +1,11 @@ using AasxServerStandardBib.Exceptions; using IO.Swagger.V1RC03.ApiModel; -using IO.Swagger.V1RC03.Logging; +using IO.Swagger.V1RC03.Exceptions; using Microsoft.AspNetCore.Http; using System; using System.Collections.Generic; using System.IO; -using System.Linq; using System.Net; -using System.Text; using System.Threading.Tasks; namespace IO.Swagger.V1RC03.Middleware @@ -95,7 +93,7 @@ private async Task HandleExceptionAsync(HttpContext context, Exception exception message.MessageType = Message.MessageTypeEnum.ErrorEnum; break; } - case NotImplementedException: + case Exceptions.NotImplementedException: { context.Response.StatusCode = (int)HttpStatusCode.NotImplemented; message.Code = HttpStatusCode.NotImplemented.ToString(); diff --git a/src/IO.Swagger.V1RC03/ModelBinder/JsonQueryBinder.cs b/src/IO.Swagger.V1RC03/ModelBinder/JsonQueryBinder.cs index 58e0591ca..e85e77785 100644 --- a/src/IO.Swagger.V1RC03/ModelBinder/JsonQueryBinder.cs +++ b/src/IO.Swagger.V1RC03/ModelBinder/JsonQueryBinder.cs @@ -1,11 +1,8 @@ -using IO.Swagger.V1RC03.Logging; +using AasxServerStandardBib.Logging; using Microsoft.AspNetCore.Mvc.ModelBinding; using Microsoft.IdentityModel.Tokens; using System; -using System.Collections.Generic; -using System.CommandLine.Parsing; using System.IO; -using System.Linq; using System.Text; using System.Text.Json; using System.Text.Json.Nodes; diff --git a/src/IO.Swagger.V1RC03/Services/AasxFileServerInterfaceService.cs b/src/IO.Swagger.V1RC03/Services/AasxFileServerInterfaceService.cs index 50538e2fa..ec9998283 100644 --- a/src/IO.Swagger.V1RC03/Services/AasxFileServerInterfaceService.cs +++ b/src/IO.Swagger.V1RC03/Services/AasxFileServerInterfaceService.cs @@ -1,18 +1,14 @@ using AasxRestServerLibrary; using AasxServer; -using AasxServerStandardBib.Exceptions; +using AasxServerStandardBib.Logging; using AdminShellNS; -using Extenstions; +using Extensions; using IO.Swagger.V1RC03.ApiModel; -using IO.Swagger.V1RC03.Logging; +using IO.Swagger.V1RC03.Exceptions; using System; -using System.Collections; using System.Collections.Generic; using System.IO; -using System.IO.Packaging; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace IO.Swagger.V1RC03.Services { diff --git a/src/IO.Swagger.V1RC03/Services/AssetAdministrationShellEnvironmentService.cs b/src/IO.Swagger.V1RC03/Services/AssetAdministrationShellEnvironmentService.cs index bbc881133..60fe6f152 100644 --- a/src/IO.Swagger.V1RC03/Services/AssetAdministrationShellEnvironmentService.cs +++ b/src/IO.Swagger.V1RC03/Services/AssetAdministrationShellEnvironmentService.cs @@ -1,25 +1,20 @@ using AasCore.Aas3_0_RC02; using AasxServer; using AasxServerStandardBib.Exceptions; -using AasxServerStandardBib.Extenstions; +using AasxServerStandardBib.Logging; using AdminShellNS; -using Extenstions; +using Extensions; using IO.Swagger.V1RC03.ApiModel; using IO.Swagger.V1RC03.APIModels.Core; using IO.Swagger.V1RC03.APIModels.ValueOnly; -using IO.Swagger.V1RC03.Logging; +using IO.Swagger.V1RC03.Exceptions; using Microsoft.AspNetCore.Http; using Microsoft.IdentityModel.Tokens; using System; -using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.IO; -using System.IO.Packaging; using System.Linq; -using System.Reflection; -using System.Reflection.Metadata.Ecma335; -using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Web; @@ -196,7 +191,7 @@ private bool IsSubmodelPresentInAAS(AssetAdministrationShell aas, string submode } else { - throw new NotFoundException($"SubmodelReference with id {submodelIdentifier} not found in AAS with id {aas.Id}"); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"SubmodelReference with id {submodelIdentifier} not found in AAS with id {aas.Id}"); } } @@ -384,7 +379,7 @@ public Submodel GetSubmodel(string aasIdentifier, string submodelIdentifier) } else { - throw new NotFoundException($"SubmodelReference with id {submodelIdentifier} not found in AAS with id {aasIdentifier}"); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"SubmodelReference with id {submodelIdentifier} not found in AAS with id {aasIdentifier}"); } } @@ -404,7 +399,7 @@ public void DeleteSubmodelReferenceById(string aasIdentifier, string submodelIde } else { - throw new NotFoundException($"SubmodelReference with id {submodelIdentifier} not found in AAS with id {aasIdentifier}"); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"SubmodelReference with id {submodelIdentifier} not found in AAS with id {aasIdentifier}"); } } } @@ -479,7 +474,7 @@ public List GetAllAssetAdministrationShells(List a.IdShort.Equals(idShort)).ToList(); if (output.IsNullOrEmpty()) { - throw new NotFoundException($"AssetAdministrationShells with IdShort {idShort} Not Found."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"AssetAdministrationShells with IdShort {idShort} Not Found."); } } @@ -498,7 +493,7 @@ public List GetAllAssetAdministrationShells(List s.Matches(submodelIdentifier)).IsNullOrEmpty()) { - throw new NotFoundException($"Requested submodel: {submodelIdentifier} not found in AAS: {aasIdentifier}"); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Requested submodel: {submodelIdentifier} not found in AAS: {aasIdentifier}"); } output = GetAllSubmodelElementsFromSubmodel(submodelIdentifier, outputModifierContext); @@ -537,7 +532,7 @@ public AssetAdministrationShell GetAssetAdministrationShellById(string aasIdenti } else { - throw new NotFoundException($"AssetAdministrationShell with id {aasIdentifier} not found."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"AssetAdministrationShell with id {aasIdentifier} not found."); } } @@ -636,7 +631,7 @@ public ConceptDescription GetConceptDescriptionById(string cdIdentifier, out int } else { - throw new NotFoundException($"ConceptDescription with id {cdIdentifier} not found."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"ConceptDescription with id {cdIdentifier} not found."); } } @@ -698,7 +693,7 @@ public List GetAllConceptDescriptions(string idShort = null, var cdList = output.Where(cd => cd.IdShort.Equals(idShort)).ToList(); if (cdList.IsNullOrEmpty()) { - throw new NotFoundException($"Concept Description with IdShort {idShort} Not Found."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Concept Description with IdShort {idShort} Not Found."); } else { @@ -726,7 +721,7 @@ public List GetAllConceptDescriptions(string idShort = null, } if (cdList.IsNullOrEmpty()) { - throw new NotFoundException($"Concept Description with requested IsCaseOf Not Found."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Concept Description with requested IsCaseOf Not Found."); } else { @@ -741,11 +736,11 @@ public List GetAllConceptDescriptions(string idShort = null, var cdList = new List(); foreach (var conceptDescription in output) { - if (!conceptDescription.DataSpecifications.IsNullOrEmpty()) + if (!conceptDescription.EmbeddedDataSpecifications.IsNullOrEmpty()) { - foreach (var reference in conceptDescription.DataSpecifications) + foreach (var reference in conceptDescription.EmbeddedDataSpecifications) { - if (reference != null && reference.Matches(reqDataSpecificationRef)) + if (reference != null && reference.DataSpecification.Matches(reqDataSpecificationRef)) { cdList.Add(conceptDescription); break; @@ -755,7 +750,7 @@ public List GetAllConceptDescriptions(string idShort = null, } if (cdList.IsNullOrEmpty()) { - throw new NotFoundException($"Concept Description with requested DataSpecificationReference Not Found."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Concept Description with requested DataSpecificationReference Not Found."); } else { @@ -1041,7 +1036,7 @@ public Submodel GetSubmodelById(string submodelIdentifier, out int packageIndex) } else { - throw new NotFoundException($"Submodel with id {submodelIdentifier} not found."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Submodel with id {submodelIdentifier} not found."); } } @@ -1240,7 +1235,7 @@ public ISubmodelElement GetSubmodelElementByPathSubmodelRepo(string submodelIden } else { - throw new NotFoundException($"Requested submodel element {idShortPath} NOT found."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Requested submodel element {idShortPath} NOT found."); } } @@ -1422,7 +1417,7 @@ public string GetFileByPathSubmodelRepo(string submodelIdentifier, string idShor } else { - throw new NotFoundException($"Submodel element {fileElement.IdShort} is not of type File."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Submodel element {fileElement.IdShort} is not of type File."); } } @@ -1445,7 +1440,7 @@ public void UpdateFileByPathSubmodelRepo(string submodelIdentifier, string idSho if(file.Value.StartsWith("http") || file.Value.StartsWith("https")) { _logger.LogWarning($"Value of the Submodel-Element File with IdShort {file.IdShort} is an external link."); - throw new NotImplementedException($"File location for {file.IdShort} is external {file.Value}. Currently this fuctionality is not supported."); + throw new Exceptions.NotImplementedException($"File location for {file.IdShort} is external {file.Value}. Currently this fuctionality is not supported."); } //Check if a directory else if(file.Value.StartsWith('/') || file.Value.StartsWith('\\')) @@ -1489,7 +1484,7 @@ public void UpdateFileByPathSubmodelRepo(string submodelIdentifier, string idSho } else { - throw new NotFoundException($"Submodel element {fileElement.IdShort} is not of type File."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Submodel element {fileElement.IdShort} is not of type File."); } } } @@ -1516,7 +1511,7 @@ public OperationResult GetOperationAsyncResultSubmodelRepo(string decodedSubmode } else { - throw new NotFoundException($"Submodel element {operationElement.IdShort} is not of type Operation."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Submodel element {operationElement.IdShort} is not of type Operation."); } } @@ -1548,7 +1543,7 @@ public OperationResult InvokeOperationSubmodelRepo(string submodelIdentifier, st } else { - throw new NotFoundException($"Submodel element {operationElement.IdShort} is not of type Operation."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Submodel element {operationElement.IdShort} is not of type Operation."); } } @@ -1589,7 +1584,7 @@ public OperationHandle InvokeOperationAsyncSubmodelRepo(string submodelIdentifie } else { - throw new NotFoundException($"Submodel element {operationElement.IdShort} is not of type Operation."); + throw new AasxServerStandardBib.Exceptions.NotFoundException($"Submodel element {operationElement.IdShort} is not of type Operation."); } } diff --git a/src/IO.Swagger.V1RC03/Services/Base64UrlDecoderService.cs b/src/IO.Swagger.V1RC03/Services/Base64UrlDecoderService.cs index c112e910d..30ddcbb7f 100644 --- a/src/IO.Swagger.V1RC03/Services/Base64UrlDecoderService.cs +++ b/src/IO.Swagger.V1RC03/Services/Base64UrlDecoderService.cs @@ -1,12 +1,9 @@ -using AasxServerStandardBib.Exceptions; +using IO.Swagger.V1RC03.Exceptions; +using IO.Swagger.V1RC03.Services; using Microsoft.IdentityModel.Tokens; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -namespace IO.Swagger.V1RC03.Services +namespace IO.Swagger.Lib.V3.Services { public class Base64UrlDecoderService : IBase64UrlDecoderService { diff --git a/src/IO.Swagger.V1RC03/Services/GenerateSerializationService.cs b/src/IO.Swagger.V1RC03/Services/GenerateSerializationService.cs index 1a7cb8257..47220d985 100644 --- a/src/IO.Swagger.V1RC03/Services/GenerateSerializationService.cs +++ b/src/IO.Swagger.V1RC03/Services/GenerateSerializationService.cs @@ -1,9 +1,7 @@ using AasCore.Aas3_0_RC02; -using IO.Swagger.V1RC03.Logging; +using AasxServerStandardBib.Logging; using System.Collections.Generic; using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace IO.Swagger.V1RC03.Services { diff --git a/src/IO.Swagger.V1RC03/Services/IJsonQueryDeserializer.cs b/src/IO.Swagger.V1RC03/Services/IJsonQueryDeserializer.cs index d0836c061..f2ed58648 100644 --- a/src/IO.Swagger.V1RC03/Services/IJsonQueryDeserializer.cs +++ b/src/IO.Swagger.V1RC03/Services/IJsonQueryDeserializer.cs @@ -1,6 +1,6 @@ using AasCore.Aas3_0_RC02; -namespace IO.Swagger.V1RC03.Services +namespace IO.Swagger.Lib.V3.Interfaces { public interface IJsonQueryDeserializer { diff --git a/src/IO.Swagger.V1RC03/Services/IOutputModifiersService.cs b/src/IO.Swagger.V1RC03/Services/IOutputModifiersService.cs index a5501af72..5f138ef41 100644 --- a/src/IO.Swagger.V1RC03/Services/IOutputModifiersService.cs +++ b/src/IO.Swagger.V1RC03/Services/IOutputModifiersService.cs @@ -2,7 +2,7 @@ { public interface IOutputModifiersService { - object ApplyOutputModifiers(object obj, string level = null, string content = null, string extent = null); + //object ApplyOutputModifiers(object obj, string level = null, string content = null, string extent = null); //TODO: jtikekar remove void ValidateOutputModifiers(object obj, string level = null, string content = null, string extent = null); } } \ No newline at end of file diff --git a/src/IO.Swagger.V1RC03/Services/InputModifierService.cs b/src/IO.Swagger.V1RC03/Services/InputModifierService.cs index eb7333eac..d21ec2510 100644 --- a/src/IO.Swagger.V1RC03/Services/InputModifierService.cs +++ b/src/IO.Swagger.V1RC03/Services/InputModifierService.cs @@ -1,14 +1,8 @@ using AasCore.Aas3_0_RC02; -using AasxServerStandardBib.Exceptions; +using AasxServerStandardBib.Logging; +using IO.Swagger.V1RC03.Exceptions; using IO.Swagger.V1RC03.Extensions; -using IO.Swagger.V1RC03.Logging; -using Org.BouncyCastle.Asn1.X509.Qualified; -using ScottPlot; using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace IO.Swagger.V1RC03.Services { diff --git a/src/IO.Swagger.V1RC03/Services/JsonQueryDeserializer.cs b/src/IO.Swagger.V1RC03/Services/JsonQueryDeserializer.cs index 8e4a4f5b4..36576e516 100644 --- a/src/IO.Swagger.V1RC03/Services/JsonQueryDeserializer.cs +++ b/src/IO.Swagger.V1RC03/Services/JsonQueryDeserializer.cs @@ -1,17 +1,15 @@ using AasCore.Aas3_0_RC02; -using AasxServerStandardBib.Exceptions; -using IO.Swagger.V1RC03.Logging; -using Microsoft.IdentityModel.Tokens; +using AasxServerStandardBib.Logging; +using IO.Swagger.Lib.V3.Interfaces; +using IO.Swagger.V1RC03.Exceptions; +using IO.Swagger.V1RC03.Services; using System; -using System.Collections.Generic; using System.IO; -using System.Linq; using System.Text; using System.Text.Json; using System.Text.Json.Nodes; -using System.Threading.Tasks; -namespace IO.Swagger.V1RC03.Services +namespace IO.Swagger.Lib.V3.Services { public class JsonQueryDeserializer : IJsonQueryDeserializer { @@ -35,13 +33,14 @@ public Reference DeserializeReference(string fieldName, string referenceString) MemoryStream mStrm = new MemoryStream(Encoding.UTF8.GetBytes(decodedString)); JsonNode node = JsonSerializer.DeserializeAsync(mStrm).Result; output = Jsonization.Deserialize.ReferenceFrom(node); + _logger.LogDebug("Successfully decoded and deserialized the reference."); } } catch (JsonException ex) { throw new JsonDeserializationException(fieldName, ex.Message); } - catch (Exception ex) + catch (Exception) { throw; } diff --git a/src/IO.Swagger.V1RC03/Services/OutputModifiersService.cs b/src/IO.Swagger.V1RC03/Services/OutputModifiersService.cs index cdd5ca88a..36e18f67d 100644 --- a/src/IO.Swagger.V1RC03/Services/OutputModifiersService.cs +++ b/src/IO.Swagger.V1RC03/Services/OutputModifiersService.cs @@ -1,20 +1,11 @@ using AasCore.Aas3_0_RC02; -using AasxServerStandardBib.Exceptions; -using Extenstions; -using IO.Swagger.V1RC03.APIModels.Core; +using AasxServerStandardBib.Logging; +using Extensions; using IO.Swagger.V1RC03.APIModels.Metadata; using IO.Swagger.V1RC03.APIModels.ValueOnly; +using IO.Swagger.V1RC03.Exceptions; using IO.Swagger.V1RC03.Extensions; -using IO.Swagger.V1RC03.Logging; -using ScottPlot; -using Swashbuckle.AspNetCore.Annotations; -using System; using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using System.Text.Json; -using System.Threading.Tasks; using Nodes = System.Text.Json.Nodes; namespace IO.Swagger.V1RC03.Services @@ -28,14 +19,15 @@ public OutputModifiersService(IAppLogger logger) _logger = logger; } - public object ApplyOutputModifiers(object obj, string level = null, string content = null, string extent = null) - { - ValidateOutputModifiers(obj, level, content, extent); - object output = ApplyLevelModifier(obj, level); - output = ApplyContentModifier(output, content); + //TODO: jtikekar Remove + //public object ApplyOutputModifiers(object obj, string level = null, string content = null, string extent = null) + //{ + // ValidateOutputModifiers(obj, level, content, extent); + // object output = ApplyLevelModifier(obj, level); + // output = ApplyContentModifier(output, content); - return output; - } + // return output; + //} private object ApplyContentModifier(object obj, string content) { @@ -189,37 +181,37 @@ private void GetIdShortPath(object obj, ref List idShortPathList, string } //TODO:jtikekar remove - public object ApplyLevelModifier(object obj, string level) - { - if (!string.IsNullOrEmpty(level) && level.Equals("core", StringComparison.OrdinalIgnoreCase)) - { - switch (obj) - { - case Submodel submodel: - { - var submodelCore = new SubmodelCore(submodel); - return submodelCore; - } - case SubmodelElementCollection collection: - { - var submodelCore = new SubmodelElementCollectionCore(collection); - return submodelCore; - } - case SubmodelElementList list: - { - var submodelCore = new SubmodelElementListCore(list); - return submodelCore; - } - case Entity entity: - { - var submodelCore = new EntityCore(entity); - return submodelCore; - } - } - } + //public object ApplyLevelModifier(object obj, string level) + //{ + // if (!string.IsNullOrEmpty(level) && level.Equals("core", StringComparison.OrdinalIgnoreCase)) + // { + // switch (obj) + // { + // case Submodel submodel: + // { + // var submodelCore = new SubmodelCore(submodel); + // return submodelCore; + // } + // case SubmodelElementCollection collection: + // { + // var submodelCore = new SubmodelElementCollectionCore(collection); + // return submodelCore; + // } + // case SubmodelElementList list: + // { + // var submodelCore = new SubmodelElementListCore(list); + // return submodelCore; + // } + // case Entity entity: + // { + // var submodelCore = new EntityCore(entity); + // return submodelCore; + // } + // } + // } - return obj; - } + // return obj; + //} public void ValidateOutputModifiers(object obj, string level = null, string content = null, string extent = null) {