Skip to content

Commit a167462

Browse files
committed
* updates
1 parent aa58081 commit a167462

10 files changed

+53
-36
lines changed

src/AasxCsharpLibrary/AdminShellUtil.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,7 @@ public static string RemoveNewLinesAndLimit(string input, int maxLength = -1, st
13321332
// (used by some function on this basic level)
13331333
//
13341334

1335-
public static string DefaultLngIso639 = "en?";
1335+
public static string DefaultLngIso639 = "en";
13361336

13371337
public static string GetDefaultLngIso639()
13381338
{

src/AasxCsharpLibrary/Extensions/ExtendILangStringNameType.cs

+31
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,36 @@ public static string ToStringExtended(this List<ILangStringNameType> elems,
3131
{
3232
return string.Join(delimiter, elems.Select((k) => k.ToStringExtended(format)));
3333
}
34+
35+
public static List<ILangStringNameType> CreateFrom(string text, string lang = "en")
36+
{
37+
if (text == null)
38+
return null;
39+
40+
var res = new List<ILangStringNameType>();
41+
res.Add(new LangStringNameType(lang, text));
42+
return res;
43+
}
44+
45+
public static bool IsEmpty(this List<ILangStringNameType> langStringSet)
46+
{
47+
if (langStringSet == null || langStringSet.Count == 0)
48+
{
49+
return true;
50+
}
51+
52+
return false;
53+
}
54+
55+
public static bool IsValid(this List<ILangStringNameType> elems)
56+
{
57+
if (elems == null || elems.Count < 1)
58+
return false;
59+
foreach (var ls in elems)
60+
if (ls?.Language == null || ls.Language.Trim().Length < 1
61+
|| ls.Text == null || ls.Text.Trim().Length < 1)
62+
return false;
63+
return true;
64+
}
3465
}
3566
}

src/AasxCsharpLibrary/Extensions/ExtendLangString.cs

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,23 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt).
66
77
This source code may use other Open Source software components (see LICENSE.txt).
88
*/
9+
using AasxCompatibilityModels;
10+
using AdminShellNS;
911
using System.Collections.Generic;
1012

1113
namespace Extensions
1214
{
1315
//TODO (jtikekar, 0000-00-00): remove
16+
//MIHO, 2024-06-01: migrate LANG_DEFAULT to AdminShellUtil.GetDefaultLngIso639()
1417
public static class ExtendLangString
1518
{
16-
// constants
17-
public static string LANG_DEFAULT = "en";
18-
1919
// new version
2020
public static string GetDefaultStringGen<T>(List<T> langStrings, string defaultLang = null)
2121
where T : IAbstractLangString
2222
{
2323
// start
2424
if (defaultLang == null)
25-
defaultLang = "en";
25+
defaultLang = AdminShellUtil.GetDefaultLngIso639();
2626
defaultLang = defaultLang.Trim().ToLower();
2727
string res = null;
2828

src/AasxCsharpLibrary/Extensions/ExtendLangStringSet.cs

+2-23
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This source code is licensed under the Apache License 2.0 (see LICENSE.txt).
66
77
This source code may use other Open Source software components (see LICENSE.txt).
88
*/
9+
using AdminShellNS;
910
using System;
1011
using System.Collections.Generic;
1112
using System.Text.RegularExpressions;
@@ -15,28 +16,6 @@ namespace Extensions
1516
//TODO (jtikekar, 0000-00-00): remove or seperate
1617
public static class ExtendLangStringSet
1718
{
18-
#region AasxPackageExplorer
19-
20-
public static bool IsValid(this List<ILangStringNameType> langStringSet)
21-
{
22-
if (langStringSet != null && langStringSet.Count >= 1)
23-
{
24-
return true;
25-
}
26-
27-
return false;
28-
}
29-
30-
#endregion
31-
public static bool IsEmpty(this List<ILangStringNameType> langStringSet)
32-
{
33-
if (langStringSet == null || langStringSet.Count == 0)
34-
{
35-
return true;
36-
}
37-
38-
return false;
39-
}
4019
// dead-csharp off
4120
//public static string GetDefaultString(this List<ILangStringTextType> langStringSet, string defaultLang = null)
4221
//{
@@ -146,7 +125,7 @@ public static List<T> Parse<T>(string cell,
146125
{
147126
if (cell.Trim() != "")
148127
{
149-
res.Add(createLs(ExtendLangString.LANG_DEFAULT, cell));
128+
res.Add(createLs(AdminShellUtil.GetDefaultLngIso639(), cell));
150129
}
151130
break;
152131
}

src/AasxPackageExplorer/options-debug.MIHO.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\samm-test\\Run2_DNP_plus_CD_SM_step_2.aasx",
3232
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\Test1.aasx",
3333
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\samm-test\\SMT_and_SAMM_Showcase_v02.aasx",
34-
"AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\SMT_and_SAMM_Showcase_v02.aasx",
34+
// "AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\SMT_and_SAMM_Showcase_v02.aasx",
35+
"AasxToLoad": "C:\\MIHO\\Develop\\Aasx\\repo\\SMT_and_SAMM_Showcase_v01.aasx",
3536
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\SAMSON_TROVIS_3730-3_Vorlage_Demo_Achema.aasx",
3637
// "AasxToLoad": "C:\\Users\\homi0002\\Desktop\\Prototyp_DPP_SkillsConveyor\\Prototyp_SkillsConveyor.aasx",
3738
// "AasxToLoad": "C:\\HOMI\\Develop\\Aasx\\repo\\samm-test\\Aspect_Example_SML_MLP.ttl",
@@ -193,7 +194,7 @@
193194
{
194195
"Path": "..\\..\\..\\..\\..\\..\\AasxPluginWebBrowser\\bin\\x64\\Debug\\AasxPluginWebBrowser.dll",
195196
"Args": []
196-
},
197+
}
197198

198199
// Festo specific from here on
199200
/*

src/AasxPackageLogic/DispEditHelperBasics.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ public void AddKeyListLangStr<T>(
885885
colSpan: 3),
886886
(o) =>
887887
{
888-
langStr.Add<T>(language: ExtendLangString.LANG_DEFAULT, text: "");
888+
langStr.Add<T>(language: AdminShellUtil.GetDefaultLngIso639(), text: "");
889889

890890
emitCustomEvent?.Invoke(relatedReferable);
891891
return new AnyUiLambdaActionRedrawEntity();

src/AasxPackageLogic/DispEditHelperExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ public void ExtensionHelperAddEditFieldsByReflection(
609609
v =>
610610
{
611611
lambdaSetValue(ExtendILangStringTextType.CreateFrom(
612-
lang: ExtendLangString.LANG_DEFAULT, text: ""));
612+
lang: AdminShellUtil.GetDefaultLngIso639(), text: ""));
613613
return new AnyUiLambdaActionRedrawEntity();
614614
}))
615615
{

src/AasxPackageLogic/DispEditHelperModules.cs

+8-2
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ public void DisplayOrEditEntityReferable(
199199
this.AddHintBubble(
200200
stack, hintMode,
201201
new[] {
202+
new HintCheck(
203+
() => referable.DisplayName != null && referable.DisplayName.IsValid() != true,
204+
"According to the specification, an existing list of elements shall contain " +
205+
"at least one element and for each element all mandatory fields shall be " +
206+
"not empty."),
202207
new HintCheck(
203208
() => referable.DisplayName?.IsValid() != true,
204209
"The use of a display name is recommended to express a human readable name " +
@@ -212,7 +217,8 @@ public void DisplayOrEditEntityReferable(
212217
});
213218
if (this.SafeguardAccess(stack, repo, referable.DisplayName, "displayName:", "Create data element!", v =>
214219
{
215-
referable.DisplayName = new List<Aas.ILangStringNameType>(new List<Aas.LangStringNameType>());
220+
referable.DisplayName = ExtendILangStringNameType.CreateFrom(
221+
lang: AdminShellUtil.GetDefaultLngIso639(), text: "");
216222
this.AddDiaryEntry(referable, new DiaryEntryStructChange());
217223
return new AnyUiLambdaActionRedrawEntity();
218224
}))
@@ -265,7 +271,7 @@ public void DisplayOrEditEntityReferable(
265271
if (this.SafeguardAccess(stack, repo, referable.Description, "description:", "Create data element!", v =>
266272
{
267273
referable.Description = ExtendILangStringTextType.CreateFrom(
268-
lang: ExtendLangString.LANG_DEFAULT, text: "");
274+
lang: AdminShellUtil.GetDefaultLngIso639(), text: "");
269275
return new AnyUiLambdaActionRedrawEntity();
270276
}))
271277
{

src/AasxPackageLogic/DispEditHelperSammModules.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -534,7 +534,7 @@ public void SammExtensionHelperAddCompleteModelElement(
534534
v =>
535535
{
536536
lambdaSetValue(ExtendILangStringTextType.CreateFrom(
537-
lang: ExtendLangString.LANG_DEFAULT, text: ""));
537+
lang: AdminShellUtil.GetDefaultLngIso639(), text: ""));
538538
return new AnyUiLambdaActionRedrawEntity();
539539
}))
540540
{

src/AasxPluginExportTable/Table/ImportPopulateByTable.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ protected ContextResult CreateBodySme(
367367

368368
if (sme is Aas.MultiLanguageProperty mlp)
369369
{
370-
mlp.Value = ExtendLangStringSet.CreateLangStringTextType(ExtendLangString.LANG_DEFAULT, context.SmeValue);
370+
mlp.Value = ExtendLangStringSet.CreateLangStringTextType(AdminShellUtil.GetDefaultLngIso639(), context.SmeValue);
371371
}
372372

373373
if (sme is Aas.File file)

0 commit comments

Comments
 (0)