Skip to content

Commit 2ad36b0

Browse files
committed
* improve scripting
for integration testing
1 parent d404bf5 commit 2ad36b0

9 files changed

+85
-58
lines changed

src/AasxCsharpLibrary/Extensions/ExtendILangStringPreferredNameTypeIec61360.cs

+26-18
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,40 @@ namespace Extensions
1313
{
1414
public static class ExtendILangStringPreferredNameTypeIec61360
1515
{
16-
public static List<ILangStringPreferredNameTypeIec61360> CreateLangStringPreferredNameType(string language, string text)
16+
public static string GetDefaultString(this List<ILangStringPreferredNameTypeIec61360> langStringSet, string defaultLang = null)
1717
{
18-
return new List<ILangStringPreferredNameTypeIec61360> { new LangStringPreferredNameTypeIec61360(language, text) };
18+
return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang);
1919
}
2020

21-
public static string GetDefaultString(this List<ILangStringPreferredNameTypeIec61360> langStringSet, string defaultLang = null)
21+
public static List<ILangStringPreferredNameTypeIec61360> CreateFrom(string text, string lang = "en")
2222
{
23-
return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang);
24-
// dead-csharp off
25-
//// start
26-
//if (defaultLang == null)
27-
// defaultLang = "en"; //Default Lang in old implementation is en
23+
if (text == null)
24+
return null;
2825

29-
//string res = null;
26+
var res = new List<ILangStringPreferredNameTypeIec61360>();
27+
res.Add(new LangStringPreferredNameTypeIec61360(lang, text));
28+
return res;
29+
}
3030

31-
//// search
32-
//foreach (var langString in langStringSet)
33-
// if (langString.Language.Equals(defaultLang, StringComparison.OrdinalIgnoreCase))
34-
// res = langString.Text;
31+
public static bool IsEmpty(this List<ILangStringPreferredNameTypeIec61360> langStringSet)
32+
{
33+
if (langStringSet == null || langStringSet.Count == 0)
34+
{
35+
return true;
36+
}
3537

36-
//if (res == null && langStringSet.Count > 0)
37-
// res = langStringSet[0].Text;
38+
return false;
39+
}
3840

39-
//// found?
40-
//return res;
41-
// dead-csharp on
41+
public static bool IsValid(this List<ILangStringPreferredNameTypeIec61360> elems)
42+
{
43+
if (elems == null || elems.Count < 1)
44+
return false;
45+
foreach (var ls in elems)
46+
if (ls?.Language == null || ls.Language.Trim().Length < 1
47+
|| ls.Text == null || ls.Text.Trim().Length < 1)
48+
return false;
49+
return true;
4250
}
4351

4452
public static List<ILangStringPreferredNameTypeIec61360> ConvertFromV20(

src/AasxCsharpLibrary/Extensions/ExtendILangStringShortNameTypeIec61360.cs

+26-18
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,40 @@ namespace Extensions
1313
{
1414
public static class ExtendILangStringShortNameTypeIec61360
1515
{
16-
public static List<ILangStringShortNameTypeIec61360> CreateLangStringShortNameType(string language, string text)
16+
public static string GetDefaultString(this List<ILangStringShortNameTypeIec61360> langStringSet, string defaultLang = null)
1717
{
18-
return new List<ILangStringShortNameTypeIec61360> { new LangStringShortNameTypeIec61360(language, text) };
18+
return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang);
1919
}
2020

21-
public static string GetDefaultString(this List<ILangStringShortNameTypeIec61360> langStringSet, string defaultLang = null)
21+
public static List<ILangStringShortNameTypeIec61360> CreateFrom(string text, string lang = "en")
2222
{
23-
return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang);
24-
// dead-csharp off
25-
//// start
26-
//if (defaultLang == null)
27-
// defaultLang = "en"; //Default Lang in old implementation is en
23+
if (text == null)
24+
return null;
2825

29-
//string res = null;
26+
var res = new List<ILangStringShortNameTypeIec61360>();
27+
res.Add(new LangStringShortNameTypeIec61360(lang, text));
28+
return res;
29+
}
3030

31-
//// search
32-
//foreach (var langString in langStringSet)
33-
// if (langString.Language.Equals(defaultLang, StringComparison.OrdinalIgnoreCase))
34-
// res = langString.Text;
31+
public static bool IsEmpty(this List<ILangStringShortNameTypeIec61360> langStringSet)
32+
{
33+
if (langStringSet == null || langStringSet.Count == 0)
34+
{
35+
return true;
36+
}
3537

36-
//if (res == null && langStringSet.Count > 0)
37-
// res = langStringSet[0].Text;
38+
return false;
39+
}
3840

39-
//// found?
40-
//return res;
41-
// dead-csharp on
41+
public static bool IsValid(this List<ILangStringShortNameTypeIec61360> elems)
42+
{
43+
if (elems == null || elems.Count < 1)
44+
return false;
45+
foreach (var ls in elems)
46+
if (ls?.Language == null || ls.Language.Trim().Length < 1
47+
|| ls.Text == null || ls.Text.Trim().Length < 1)
48+
return false;
49+
return true;
4250
}
4351

4452
public static List<ILangStringShortNameTypeIec61360> ConvertFromV20(

src/AasxPackageExplorer/AasxPackageExplorer.options-for-debug.json

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"EclassDir": ".\\eclass\\",
1313
"LogoFile": "PI40_and_IDTA.png",
1414
"QualifiersFile": "qualifier-presets.json",
15-
"AasxRepositoryFn": "..\\..\\..\\..\\..\\Sample_AAS\\aasxrepo-new.json",
1615
"ContentHome": "https://github.com/admin-shell/io/blob/master/README.md",
1716
"UseFlyovers": true,
1817
"SplashTime": 5000,

src/AasxPackageExplorer/AasxPackageExplorer.options-for-release.json

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"EclassDir": ".\\eclass\\",
1313
"LogoFile": "PI40_and_IDTA.png",
1414
"QualifiersFile": "qualifier-presets.json",
15-
"AasxRepositoryFn": "..\\..\\..\\..\\..\\Sample_AAS\\aasxrepo-new.json",
1615
"ContentHome": "https://github.com/admin-shell/io/blob/master/README.md",
1716
"UseFlyovers": true,
1817
"SplashTime": 5000,

src/AasxPackageExplorer/options-debug.MIHO.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_TechData_Work\\IDTA 02003-1-2_SubmodelTemplate_TechnicalData_v1.2__with_Draft_1_3_and_AsciiDoc_v01.aasx",
4040
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Draft_v22.aasx",
4141
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx",
42-
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\SMT_ProductChangeNotification_Draft_v20_spiel.aasx",
42+
"AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\SMT_ProductChangeNotification_Draft_v20_spiel.aasx",
4343
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\SMT_ProductChangeNotification\\IDTA_02036-1-0_SMT_ProductChangeNotification_Examples_v08.aasx",
4444
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\tmp\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx",
4545
// "AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\Syn2tecMachine_P2518_AAS__V3_DL2.aasx",
@@ -56,7 +56,7 @@
5656
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\2023_AID1.0_Template_Rework_MIHO.aasx",
5757
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\aid-test-2.aasx",
5858
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\aid-test-3_new_opcua.aasx",
59-
"AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\test-data\\OpcUaReadSubmodel\\OpcUaReadSubmodel.aasx",
59+
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\test-data\\OpcUaReadSubmodel\\OpcUaReadSubmodel.aasx",
6060
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\Aid-HMI-2024_v1.aasx",
6161
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\aid\\robotic_cell_for_demo_suitcase_new-v3.aasx",
6262
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\IDTA 02006-2-1_Template_Digital Nameplate_V3_Demo_ExportSMT - Kopie.aasx",

src/AasxPackageLogic/DispEditHelperMiniModules.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1567,10 +1567,10 @@ public void ValueListHelper(
15671567
ExtendIDataSpecificationContent.GetReferencForIec61360(),
15681568
new Aas.DataSpecificationIec61360(
15691569
preferredName: ExtendILangStringPreferredNameTypeIec61360
1570-
.CreateLangStringPreferredNameType(
1570+
.CreateFrom(
15711571
AdminShellUtil.GetDefaultLngIso639(), "" + valuePairs[i].Value),
15721572
shortName: ExtendILangStringShortNameTypeIec61360
1573-
.CreateLangStringShortNameType(
1573+
.CreateFrom(
15741574
AdminShellUtil.GetDefaultLngIso639(), "" + valuePairs[i].Value),
15751575
definition: ExtendILangStringDefinitionTypeIec61360
15761576
.CreateLangStringDefinitionType(

src/AasxPackageLogic/DispEditHelperModules.cs

+29-14
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,6 @@ public void DisplayOrEditEntityReferable(
228228
setNullList: () => referable.DisplayName = null);
229229
}
230230

231-
232-
233231
// category deprecated
234232
this.AddHintBubble(
235233
stack, hintMode,
@@ -1453,34 +1451,50 @@ public void DisplayOrEditEntityDataSpecificationIec61360(
14531451
AddHintBubble(
14541452
stack, hintMode,
14551453
new[] {
1456-
new HintCheck(
1457-
() => { return dsiec.PreferredName == null || dsiec.PreferredName.Count < 1; },
1458-
"Please add a preferred name, which could be used on user interfaces " +
1459-
"to identify the concept to a human person.",
1460-
breakIfTrue: true),
1461-
new HintCheck(
1462-
() => { return dsiec.PreferredName.Count <2; },
1463-
"Please add multiple languanges.",
1464-
severityLevel: HintCheck.Severity.Notice)
1454+
new HintCheck(
1455+
() => dsiec.PreferredName != null && dsiec.PreferredName.IsValid() != true,
1456+
"According to the specification, an existing list of elements shall contain " +
1457+
"at least one element and for each element all mandatory fields shall be " +
1458+
"not empty."),
1459+
new HintCheck(
1460+
() => { return dsiec.PreferredName == null || dsiec.PreferredName.Count < 1; },
1461+
"Please add a preferred name, which could be used on user interfaces " +
1462+
"to identify the concept to a human person.",
1463+
breakIfTrue: true),
1464+
new HintCheck(
1465+
() => { return dsiec.PreferredName.Count <2; },
1466+
"Please add multiple languanges.",
1467+
severityLevel: HintCheck.Severity.Notice)
14651468
});
14661469
if (SafeguardAccess(
14671470
stack, repo, dsiec.PreferredName, "preferredName:", "Create data element!",
14681471
v =>
14691472
{
1470-
dsiec.PreferredName = new List<Aas.ILangStringPreferredNameTypeIec61360>();
1473+
dsiec.PreferredName = ExtendILangStringPreferredNameTypeIec61360.CreateFrom(
1474+
lang: AdminShellUtil.GetDefaultLngIso639(), text: "");
1475+
14711476
this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
14721477
return new AnyUiLambdaActionRedrawEntity();
14731478
}))
14741479
AddKeyListLangStr<ILangStringPreferredNameTypeIec61360>(
14751480
stack, "preferredName", dsiec.PreferredName,
14761481
repo, relatedReferable: relatedReferable,
1477-
setNullList: () => dsiec.PreferredName = null);
1482+
setNullList: () =>
1483+
{
1484+
dsiec.PreferredName = ExtendILangStringPreferredNameTypeIec61360.CreateFrom(
1485+
lang: AdminShellUtil.GetDefaultLngIso639(), text: "");
1486+
});
14781487

14791488
// ShortName
14801489

14811490
AddHintBubble(
14821491
stack, hintMode,
14831492
new[] {
1493+
new HintCheck(
1494+
() => dsiec.ShortName != null && dsiec.ShortName.IsValid() != true,
1495+
"According to the specification, an existing list of elements shall contain " +
1496+
"at least one element and for each element all mandatory fields shall be " +
1497+
"not empty."),
14841498
new HintCheck(
14851499
() => { return dsiec.ShortName == null || dsiec.ShortName.Count < 1; },
14861500
"Please check if you can add a short name, which is a reduced, even symbolic version of " +
@@ -1502,7 +1516,8 @@ public void DisplayOrEditEntityDataSpecificationIec61360(
15021516
stack, repo, dsiec.ShortName, "shortName:", "Create data element!",
15031517
v =>
15041518
{
1505-
dsiec.ShortName = new List<Aas.ILangStringShortNameTypeIec61360>();
1519+
dsiec.ShortName = ExtendILangStringShortNameTypeIec61360.CreateFrom(
1520+
lang: AdminShellUtil.GetDefaultLngIso639(), text: "");
15061521
this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
15071522
return new AnyUiLambdaActionRedrawEntity();
15081523
}))

src/BlazorExplorer/BlazorExplorer.options-for-debug.json

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"EclassDir": ".\\eclass\\",
1313
"LogoFile": "PI40_and_IDTA.png",
1414
"QualifiersFile": "qualifier-presets.json",
15-
"AasxRepositoryFn": "..\\..\\..\\..\\..\\Sample_AAS\\aasxrepo-new.json",
1615
"ContentHome": "https://github.com/admin-shell/io/blob/master/README.md",
1716
"UseFlyovers": true,
1817
"SplashTime": 5000,

src/BlazorExplorer/BlazorExplorer.options-for-release.json

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
"EclassDir": ".\\eclass\\",
1313
"LogoFile": "PI40_and_IDTA.png",
1414
"QualifiersFile": "qualifier-presets.json",
15-
"AasxRepositoryFn": "..\\..\\..\\..\\..\\Sample_AAS\\aasxrepo-new.json",
1615
"ContentHome": "https://github.com/admin-shell/io/blob/master/README.md",
1716
"UseFlyovers": true,
1817
"SplashTime": 5000,

0 commit comments

Comments
 (0)