From 2ad36b08f8545f25921cb0a312f38c122b154d36 Mon Sep 17 00:00:00 2001 From: Michael Hoffmeister Date: Sun, 28 Jul 2024 18:17:23 +0200 Subject: [PATCH] * improve scripting for integration testing --- ...endILangStringPreferredNameTypeIec61360.cs | 44 +++++++++++-------- .../ExtendILangStringShortNameTypeIec61360.cs | 44 +++++++++++-------- ...AasxPackageExplorer.options-for-debug.json | 1 - ...sxPackageExplorer.options-for-release.json | 1 - .../options-debug.MIHO.json | 4 +- .../DispEditHelperMiniModules.cs | 4 +- src/AasxPackageLogic/DispEditHelperModules.cs | 43 ++++++++++++------ .../BlazorExplorer.options-for-debug.json | 1 - .../BlazorExplorer.options-for-release.json | 1 - 9 files changed, 85 insertions(+), 58 deletions(-) diff --git a/src/AasxCsharpLibrary/Extensions/ExtendILangStringPreferredNameTypeIec61360.cs b/src/AasxCsharpLibrary/Extensions/ExtendILangStringPreferredNameTypeIec61360.cs index abff939d..36328fe7 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendILangStringPreferredNameTypeIec61360.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendILangStringPreferredNameTypeIec61360.cs @@ -13,32 +13,40 @@ namespace Extensions { public static class ExtendILangStringPreferredNameTypeIec61360 { - public static List CreateLangStringPreferredNameType(string language, string text) + public static string GetDefaultString(this List langStringSet, string defaultLang = null) { - return new List { new LangStringPreferredNameTypeIec61360(language, text) }; + return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang); } - public static string GetDefaultString(this List langStringSet, string defaultLang = null) + public static List CreateFrom(string text, string lang = "en") { - return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang); - // dead-csharp off - //// start - //if (defaultLang == null) - // defaultLang = "en"; //Default Lang in old implementation is en + if (text == null) + return null; - //string res = null; + var res = new List(); + res.Add(new LangStringPreferredNameTypeIec61360(lang, text)); + return res; + } - //// search - //foreach (var langString in langStringSet) - // if (langString.Language.Equals(defaultLang, StringComparison.OrdinalIgnoreCase)) - // res = langString.Text; + public static bool IsEmpty(this List langStringSet) + { + if (langStringSet == null || langStringSet.Count == 0) + { + return true; + } - //if (res == null && langStringSet.Count > 0) - // res = langStringSet[0].Text; + return false; + } - //// found? - //return res; - // dead-csharp on + public static bool IsValid(this List elems) + { + if (elems == null || elems.Count < 1) + return false; + foreach (var ls in elems) + if (ls?.Language == null || ls.Language.Trim().Length < 1 + || ls.Text == null || ls.Text.Trim().Length < 1) + return false; + return true; } public static List ConvertFromV20( diff --git a/src/AasxCsharpLibrary/Extensions/ExtendILangStringShortNameTypeIec61360.cs b/src/AasxCsharpLibrary/Extensions/ExtendILangStringShortNameTypeIec61360.cs index 8cdb0e3e..2c46710a 100644 --- a/src/AasxCsharpLibrary/Extensions/ExtendILangStringShortNameTypeIec61360.cs +++ b/src/AasxCsharpLibrary/Extensions/ExtendILangStringShortNameTypeIec61360.cs @@ -13,32 +13,40 @@ namespace Extensions { public static class ExtendILangStringShortNameTypeIec61360 { - public static List CreateLangStringShortNameType(string language, string text) + public static string GetDefaultString(this List langStringSet, string defaultLang = null) { - return new List { new LangStringShortNameTypeIec61360(language, text) }; + return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang); } - public static string GetDefaultString(this List langStringSet, string defaultLang = null) + public static List CreateFrom(string text, string lang = "en") { - return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang); - // dead-csharp off - //// start - //if (defaultLang == null) - // defaultLang = "en"; //Default Lang in old implementation is en + if (text == null) + return null; - //string res = null; + var res = new List(); + res.Add(new LangStringShortNameTypeIec61360(lang, text)); + return res; + } - //// search - //foreach (var langString in langStringSet) - // if (langString.Language.Equals(defaultLang, StringComparison.OrdinalIgnoreCase)) - // res = langString.Text; + public static bool IsEmpty(this List langStringSet) + { + if (langStringSet == null || langStringSet.Count == 0) + { + return true; + } - //if (res == null && langStringSet.Count > 0) - // res = langStringSet[0].Text; + return false; + } - //// found? - //return res; - // dead-csharp on + public static bool IsValid(this List elems) + { + if (elems == null || elems.Count < 1) + return false; + foreach (var ls in elems) + if (ls?.Language == null || ls.Language.Trim().Length < 1 + || ls.Text == null || ls.Text.Trim().Length < 1) + return false; + return true; } public static List ConvertFromV20( diff --git a/src/AasxPackageExplorer/AasxPackageExplorer.options-for-debug.json b/src/AasxPackageExplorer/AasxPackageExplorer.options-for-debug.json index 61756f2e..b591731e 100644 --- a/src/AasxPackageExplorer/AasxPackageExplorer.options-for-debug.json +++ b/src/AasxPackageExplorer/AasxPackageExplorer.options-for-debug.json @@ -12,7 +12,6 @@ "EclassDir": ".\\eclass\\", "LogoFile": "PI40_and_IDTA.png", "QualifiersFile": "qualifier-presets.json", - "AasxRepositoryFn": "..\\..\\..\\..\\..\\Sample_AAS\\aasxrepo-new.json", "ContentHome": "https://github.com/admin-shell/io/blob/master/README.md", "UseFlyovers": true, "SplashTime": 5000, diff --git a/src/AasxPackageExplorer/AasxPackageExplorer.options-for-release.json b/src/AasxPackageExplorer/AasxPackageExplorer.options-for-release.json index ff346d04..a4fcf5b3 100644 --- a/src/AasxPackageExplorer/AasxPackageExplorer.options-for-release.json +++ b/src/AasxPackageExplorer/AasxPackageExplorer.options-for-release.json @@ -12,7 +12,6 @@ "EclassDir": ".\\eclass\\", "LogoFile": "PI40_and_IDTA.png", "QualifiersFile": "qualifier-presets.json", - "AasxRepositoryFn": "..\\..\\..\\..\\..\\Sample_AAS\\aasxrepo-new.json", "ContentHome": "https://github.com/admin-shell/io/blob/master/README.md", "UseFlyovers": true, "SplashTime": 5000, diff --git a/src/AasxPackageExplorer/options-debug.MIHO.json b/src/AasxPackageExplorer/options-debug.MIHO.json index d38bee33..fd64fe99 100644 --- a/src/AasxPackageExplorer/options-debug.MIHO.json +++ b/src/AasxPackageExplorer/options-debug.MIHO.json @@ -39,7 +39,7 @@ // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_TechData_Work\\IDTA 02003-1-2_SubmodelTemplate_TechnicalData_v1.2__with_Draft_1_3_and_AsciiDoc_v01.aasx", // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Draft_v22.aasx", // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx", - // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\SMT_ProductChangeNotification_Draft_v20_spiel.aasx", + "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\SMT_ProductChangeNotification_Draft_v20_spiel.aasx", // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx", // "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx", // "AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx", @@ -56,7 +56,7 @@ // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\2023_AID1.0_Template_Rework_MIHO.aasx", // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\aid-test-2.aasx", // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\aid-test-3_new_opcua.aasx", - "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\test-data\\OpcUaReadSubmodel\\OpcUaReadSubmodel.aasx", + // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\test-data\\OpcUaReadSubmodel\\OpcUaReadSubmodel.aasx", // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\Aid-HMI-2024_v1.aasx", // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\robotic_cell_for_demo_suitcase_new-v3.aasx", // "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\IDTA 02006-2-1_Template_Digital Nameplate_V3_Demo_ExportSMT - Kopie.aasx", diff --git a/src/AasxPackageLogic/DispEditHelperMiniModules.cs b/src/AasxPackageLogic/DispEditHelperMiniModules.cs index d7b4f97e..37adafcc 100644 --- a/src/AasxPackageLogic/DispEditHelperMiniModules.cs +++ b/src/AasxPackageLogic/DispEditHelperMiniModules.cs @@ -1567,10 +1567,10 @@ public void ValueListHelper( ExtendIDataSpecificationContent.GetReferencForIec61360(), new Aas.DataSpecificationIec61360( preferredName: ExtendILangStringPreferredNameTypeIec61360 - .CreateLangStringPreferredNameType( + .CreateFrom( AdminShellUtil.GetDefaultLngIso639(), "" + valuePairs[i].Value), shortName: ExtendILangStringShortNameTypeIec61360 - .CreateLangStringShortNameType( + .CreateFrom( AdminShellUtil.GetDefaultLngIso639(), "" + valuePairs[i].Value), definition: ExtendILangStringDefinitionTypeIec61360 .CreateLangStringDefinitionType( diff --git a/src/AasxPackageLogic/DispEditHelperModules.cs b/src/AasxPackageLogic/DispEditHelperModules.cs index d8c55d5c..c94d4a1c 100644 --- a/src/AasxPackageLogic/DispEditHelperModules.cs +++ b/src/AasxPackageLogic/DispEditHelperModules.cs @@ -228,8 +228,6 @@ public void DisplayOrEditEntityReferable( setNullList: () => referable.DisplayName = null); } - - // category deprecated this.AddHintBubble( stack, hintMode, @@ -1453,34 +1451,50 @@ public void DisplayOrEditEntityDataSpecificationIec61360( AddHintBubble( stack, hintMode, new[] { - new HintCheck( - () => { return dsiec.PreferredName == null || dsiec.PreferredName.Count < 1; }, - "Please add a preferred name, which could be used on user interfaces " + - "to identify the concept to a human person.", - breakIfTrue: true), - new HintCheck( - () => { return dsiec.PreferredName.Count <2; }, - "Please add multiple languanges.", - severityLevel: HintCheck.Severity.Notice) + new HintCheck( + () => dsiec.PreferredName != null && dsiec.PreferredName.IsValid() != true, + "According to the specification, an existing list of elements shall contain " + + "at least one element and for each element all mandatory fields shall be " + + "not empty."), + new HintCheck( + () => { return dsiec.PreferredName == null || dsiec.PreferredName.Count < 1; }, + "Please add a preferred name, which could be used on user interfaces " + + "to identify the concept to a human person.", + breakIfTrue: true), + new HintCheck( + () => { return dsiec.PreferredName.Count <2; }, + "Please add multiple languanges.", + severityLevel: HintCheck.Severity.Notice) }); if (SafeguardAccess( stack, repo, dsiec.PreferredName, "preferredName:", "Create data element!", v => { - dsiec.PreferredName = new List(); + dsiec.PreferredName = ExtendILangStringPreferredNameTypeIec61360.CreateFrom( + lang: AdminShellUtil.GetDefaultLngIso639(), text: ""); + this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange()); return new AnyUiLambdaActionRedrawEntity(); })) AddKeyListLangStr( stack, "preferredName", dsiec.PreferredName, repo, relatedReferable: relatedReferable, - setNullList: () => dsiec.PreferredName = null); + setNullList: () => + { + dsiec.PreferredName = ExtendILangStringPreferredNameTypeIec61360.CreateFrom( + lang: AdminShellUtil.GetDefaultLngIso639(), text: ""); + }); // ShortName AddHintBubble( stack, hintMode, new[] { + new HintCheck( + () => dsiec.ShortName != null && dsiec.ShortName.IsValid() != true, + "According to the specification, an existing list of elements shall contain " + + "at least one element and for each element all mandatory fields shall be " + + "not empty."), new HintCheck( () => { return dsiec.ShortName == null || dsiec.ShortName.Count < 1; }, "Please check if you can add a short name, which is a reduced, even symbolic version of " + @@ -1502,7 +1516,8 @@ public void DisplayOrEditEntityDataSpecificationIec61360( stack, repo, dsiec.ShortName, "shortName:", "Create data element!", v => { - dsiec.ShortName = new List(); + dsiec.ShortName = ExtendILangStringShortNameTypeIec61360.CreateFrom( + lang: AdminShellUtil.GetDefaultLngIso639(), text: ""); this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange()); return new AnyUiLambdaActionRedrawEntity(); })) diff --git a/src/BlazorExplorer/BlazorExplorer.options-for-debug.json b/src/BlazorExplorer/BlazorExplorer.options-for-debug.json index 0ce912fa..5d9153f9 100644 --- a/src/BlazorExplorer/BlazorExplorer.options-for-debug.json +++ b/src/BlazorExplorer/BlazorExplorer.options-for-debug.json @@ -12,7 +12,6 @@ "EclassDir": ".\\eclass\\", "LogoFile": "PI40_and_IDTA.png", "QualifiersFile": "qualifier-presets.json", - "AasxRepositoryFn": "..\\..\\..\\..\\..\\Sample_AAS\\aasxrepo-new.json", "ContentHome": "https://github.com/admin-shell/io/blob/master/README.md", "UseFlyovers": true, "SplashTime": 5000, diff --git a/src/BlazorExplorer/BlazorExplorer.options-for-release.json b/src/BlazorExplorer/BlazorExplorer.options-for-release.json index ff346d04..a4fcf5b3 100644 --- a/src/BlazorExplorer/BlazorExplorer.options-for-release.json +++ b/src/BlazorExplorer/BlazorExplorer.options-for-release.json @@ -12,7 +12,6 @@ "EclassDir": ".\\eclass\\", "LogoFile": "PI40_and_IDTA.png", "QualifiersFile": "qualifier-presets.json", - "AasxRepositoryFn": "..\\..\\..\\..\\..\\Sample_AAS\\aasxrepo-new.json", "ContentHome": "https://github.com/admin-shell/io/blob/master/README.md", "UseFlyovers": true, "SplashTime": 5000,