Skip to content

Commit

Permalink
* improve scripting
Browse files Browse the repository at this point in the history
   for integration testing
  • Loading branch information
festo-i40 committed Jul 28, 2024
1 parent d404bf5 commit 2ad36b0
Show file tree
Hide file tree
Showing 9 changed files with 85 additions and 58 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,40 @@ namespace Extensions
{
public static class ExtendILangStringPreferredNameTypeIec61360
{
public static List<ILangStringPreferredNameTypeIec61360> CreateLangStringPreferredNameType(string language, string text)
public static string GetDefaultString(this List<ILangStringPreferredNameTypeIec61360> langStringSet, string defaultLang = null)
{
return new List<ILangStringPreferredNameTypeIec61360> { new LangStringPreferredNameTypeIec61360(language, text) };
return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang);
}

public static string GetDefaultString(this List<ILangStringPreferredNameTypeIec61360> langStringSet, string defaultLang = null)
public static List<ILangStringPreferredNameTypeIec61360> 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<ILangStringPreferredNameTypeIec61360>();
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<ILangStringPreferredNameTypeIec61360> 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<ILangStringPreferredNameTypeIec61360> 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<ILangStringPreferredNameTypeIec61360> ConvertFromV20(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,32 +13,40 @@ namespace Extensions
{
public static class ExtendILangStringShortNameTypeIec61360
{
public static List<ILangStringShortNameTypeIec61360> CreateLangStringShortNameType(string language, string text)
public static string GetDefaultString(this List<ILangStringShortNameTypeIec61360> langStringSet, string defaultLang = null)
{
return new List<ILangStringShortNameTypeIec61360> { new LangStringShortNameTypeIec61360(language, text) };
return ExtendLangString.GetDefaultStringGen(langStringSet, defaultLang);
}

public static string GetDefaultString(this List<ILangStringShortNameTypeIec61360> langStringSet, string defaultLang = null)
public static List<ILangStringShortNameTypeIec61360> 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<ILangStringShortNameTypeIec61360>();
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<ILangStringShortNameTypeIec61360> 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<ILangStringShortNameTypeIec61360> 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<ILangStringShortNameTypeIec61360> ConvertFromV20(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions src/AasxPackageExplorer/options-debug.MIHO.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions src/AasxPackageLogic/DispEditHelperMiniModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
43 changes: 29 additions & 14 deletions src/AasxPackageLogic/DispEditHelperModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ public void DisplayOrEditEntityReferable(
setNullList: () => referable.DisplayName = null);
}



// category deprecated
this.AddHintBubble(
stack, hintMode,
Expand Down Expand Up @@ -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<Aas.ILangStringPreferredNameTypeIec61360>();
dsiec.PreferredName = ExtendILangStringPreferredNameTypeIec61360.CreateFrom(
lang: AdminShellUtil.GetDefaultLngIso639(), text: "");
this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
return new AnyUiLambdaActionRedrawEntity();
}))
AddKeyListLangStr<ILangStringPreferredNameTypeIec61360>(
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 " +
Expand All @@ -1502,7 +1516,8 @@ public void DisplayOrEditEntityDataSpecificationIec61360(
stack, repo, dsiec.ShortName, "shortName:", "Create data element!",
v =>
{
dsiec.ShortName = new List<Aas.ILangStringShortNameTypeIec61360>();
dsiec.ShortName = ExtendILangStringShortNameTypeIec61360.CreateFrom(
lang: AdminShellUtil.GetDefaultLngIso639(), text: "");
this.AddDiaryEntry(relatedReferable, new DiaryEntryStructChange());
return new AnyUiLambdaActionRedrawEntity();
}))
Expand Down
1 change: 0 additions & 1 deletion src/BlazorExplorer/BlazorExplorer.options-for-debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/BlazorExplorer/BlazorExplorer.options-for-release.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 2ad36b0

Please sign in to comment.