Skip to content
This repository has been archived by the owner on Apr 16, 2024. It is now read-only.

Commit

Permalink
added error message for duplicate AAS Ids
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderWollbrink authored and martafullen committed Feb 7, 2024
1 parent 7cd0454 commit db81ba3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/AasxCsharpLibrary/Extensions/ExtendReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ public static bool MatchesExactlyOneKey(this IReference reference, IKey key, Mat

public static string GetAsIdentifier(this IReference reference)
{
if (reference.Type == ReferenceTypes.ExternalReference) // Applying only to Global Reference, based on older implementation, TODO:Make it Generic

if (reference != null && reference.Type == ReferenceTypes.ExternalReference) // Applying only to Global Reference, based on older implementation, TODO:Make it Generic
{
if (reference.Keys == null || reference.Keys.Count < 1)
{
Expand Down
6 changes: 3 additions & 3 deletions src/AasxPackageLogic/DispEditHelperEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1454,7 +1454,7 @@ public void DisplayOrEditAasEntityAas(

// Identifiable
this.DisplayOrEditEntityIdentifiable(
stack, aas,
stack, env, aas,
Options.Curr.TemplateIdAas,
null);

Expand Down Expand Up @@ -1967,7 +1967,7 @@ public void DisplayOrEditAasEntitySubmodelOrRef(

// Identifiable
this.DisplayOrEditEntityIdentifiable(
stack, submodel,
stack, env, submodel,
(submodel.Kind == Aas.ModellingKind.Template)
? Options.Curr.TemplateIdSubmodelTemplate
: Options.Curr.TemplateIdSubmodelInstance,
Expand Down Expand Up @@ -2146,7 +2146,7 @@ public void DisplayOrEditAasEntityConceptDescription(
// Identifiable

this.DisplayOrEditEntityIdentifiable(
stack, cd,
stack, env, cd,
Options.Curr.TemplateIdConceptDescription,
new DispEditHelperModules.DispEditInjectAction(
new[] { "Rename" },
Expand Down
19 changes: 17 additions & 2 deletions src/AasxPackageLogic/DispEditHelperModules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ public void DisplayOrEditEntityListOfExtension(AnyUiStackPanel stack,
//

public void DisplayOrEditEntityIdentifiable(AnyUiStackPanel stack,
Aas.Environment env,
Aas.IIdentifiable identifiable,
string templateForIdString,
DispEditInjectAction injectToId = null)
Expand All @@ -339,8 +340,19 @@ public void DisplayOrEditEntityIdentifiable(AnyUiStackPanel stack,
() => { return identifiable.Id == ""; },
"Identification id shall not be empty. You could use the 'Generate' button in order to " +
"generate a worldwide unique id. " +
"The template of this id could be set by commandline arguments." )

"The template of this id could be set by commandline arguments." ),
new HintCheck(
() => {
int count = 0;
foreach(var aas in env.AssetAdministrationShells)
{
if(aas.Id == identifiable.Id)
count++;
}
return (count >= 2?true:false);
},
"It is not allowed to have duplicate Ids in AAS of the same file. This will break functionality and we strongly encoure to make the Id unique!",
breakIfTrue: false)
});
if (this.SafeguardAccess(
stack, repo, identifiable.Id, "id:", "Create data element!",
Expand All @@ -356,7 +368,10 @@ public void DisplayOrEditEntityIdentifiable(AnyUiStackPanel stack,
v =>
{
var dr = new DiaryReference(identifiable);
string value = v as string;
bool duplicate = false;
identifiable.Id = v as string;
//mlem
this.AddDiaryEntry(identifiable, new DiaryEntryStructChange(), diaryReference: dr);
return new AnyUiLambdaActionNone();
},
Expand Down

0 comments on commit db81ba3

Please sign in to comment.