Skip to content

Commit

Permalink
Fix for GitHub Issue 142
Browse files Browse the repository at this point in the history
  • Loading branch information
juileetikekar committed Mar 12, 2024
1 parent 15e75ff commit 5287c0d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
15 changes: 14 additions & 1 deletion src/AasxCsharpLibrary/Extensions/ExtendEnvironment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -748,11 +748,24 @@ public static IReferable FindReferableByReference(
}
}



if (firstKeyType.IsSME() && submodelElems != null)
{
var submodelElement = submodelElems.Where(
ISubmodelElement submodelElement;
//check if key.value is index
bool isIndex = int.TryParse(firstKeyId, out int index);
if (isIndex)
{
var smeList = submodelElems.ToList();
submodelElement = smeList[index];
}
else
{
submodelElement = submodelElems.Where(
sme => sme.IdShort.Equals(keyList[keyIndex].Value,
StringComparison.OrdinalIgnoreCase)).First();
}

//This is required element
if (keyIndex + 1 >= keyList.Count)
Expand Down
14 changes: 11 additions & 3 deletions src/AasxPackageLogic/VisualAasxElements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,17 @@ public VisualElementGeneric FindSibling(bool before = true, bool after = true)
if (ve.GetMainDataObject() is Aas.IReferable rf)
{
// add a key and go up ..
res.Insert(
0,
new Aas.Key((Aas.KeyTypes)Aas.Stringification.KeyTypesFromString(rf.GetSelfDescription().AasElementName), rf.IdShort));
IKey key;
if (ve.Parent.GetMainDataObject() is ISubmodelElementList smeList)
{
var index = smeList.Value.IndexOf((ISubmodelElement)rf);
key = new Aas.Key((Aas.KeyTypes)Aas.Stringification.KeyTypesFromString(rf.GetSelfDescription().AasElementName), index.ToString());
}
else
{
key = new Aas.Key((Aas.KeyTypes)Aas.Stringification.KeyTypesFromString(rf.GetSelfDescription().AasElementName), rf.IdShort);
}
res.Insert(0,key);
}
else
// uups!
Expand Down

0 comments on commit 5287c0d

Please sign in to comment.