Hi All,
The following is the code I used within my EA Extension
EA SafeDelete private bool isStructuralElement(EA.Repository repository, EA.Element contextElement)
{
// Get the object type
switch (contextElement.Type)
{
case "Port":
return true;
case "ActionPin":
return true;
case "ProvidedInterface":
return true;
case "RequiredInterface":
return true;
case "ActivityParameter":
return true;
case "ExpansionNode":
return true;
case "ObjectNode":
return true;
case "Part":
return isNotReferencePart(repository, contextElement);
default:
return false;
}
}
private bool isNotReferencePart(EA.Repository repository, EA.Element contextElement)
{
// To find this out, we need to extract and examine the Description field in the
// contextElement's corresponding entry in the t_xref table
String tXrefDescription = null;
string sqlSearch = "SELECT t_xref.Description AS [Description]" +
"FROM t_object, t_xref " +
"WHERE t_object.ea_guid = '" + contextElement.ElementGUID + "'" +
"AND t_object.ea_guid = t_xref.Client";
string queryResult = string.Empty;
queryResult = repository.SQLQuery(sqlSearch);
XmlDocument requirement = new XmlDocument();
requirement.LoadXml(queryResult);
// Examine the result
XmlNode description = requirement.SelectSingleNode("//Row/Description");
if (description != null)
{
tXrefDescription = description.InnerText;
// Now, the fun begins, we need to
//
// First extract the parts of description (delimited by

// Extract the value that tells us if the element is a reference Part
String[] descriptionParts = tXrefDescription.Split(new char[] { ';' });
// We need the eighth part (index 7)
//
// This has the format @VALU=n @ENDVALU
//
// So we can just test for a contains of 0 for not a reference part
return descriptionParts[7].Contains('0');
}
return true;
}
This appears to work for me, don't think I missed any Structural Elements (embedded elements).
Cheers
Phil