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

error bubble for duplicate aas id and globalassetid #692

Merged
merged 2 commits into from
Feb 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
19 changes: 16 additions & 3 deletions src/AasxPackageLogic/DispEditHelperEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,19 @@ public void DisplayOrEditAasEntityAssetInformation(
"found on its name plate. " +
"This attribute is required as soon as the AAS is exchanged via partners in " +
"the life cycle of the asset.",
severityLevel: HintCheck.Severity.High),
new HintCheck(
() =>
{
int count = 0;
foreach(var aas in env.AssetAdministrationShells)
{
if(aas.AssetInformation.GlobalAssetId == asset.GlobalAssetId)
count++;
}
return (count>=2?true:false);
},
"It is not allowed to have duplicate GlobalAssetIds in the same file. This will break functionality and we strongly encoure to make the Id unique!",
severityLevel: HintCheck.Severity.High)
});

Expand Down Expand Up @@ -1454,7 +1467,7 @@ public void DisplayOrEditAasEntityAas(

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

Expand Down Expand Up @@ -1967,7 +1980,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 +2159,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
Loading