Sparx Systems Forum
Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: A. Betts on July 08, 2011, 09:50:54 am
-
Hi All,
Is there any way to retrieve assocation specialisation information via the automation API? I've looked in RoleTags,CustomProperties,MiscData,Properties etc. and haven't found them so far.
Any leads appreciated.
Regards,
Ashley
-
Ashley,
I don't know the answer, but what I do in such cases is:
- create a new (empty) model
- add only the things that I'm interested in
- Open the database and figure out how EA stored the information I'm after
- Then try to figure out whether (or not) the API exposes that particular piece of information.
- If it's not exposed by the API I use Repository.SQLQuery() to get that information.
Geert
-
Thanks Geert, I'll have a bit of dig around when I get the chance and report back.
-
It's in t_xref:
Behavior: redefinedProperty or subsettedProperty
Description: base assocation guid
Client: subsetting or redefining association guid
Does anyone have any examples of processing the result set from Repository.SQLQuery in VBscript or JScript (I'm a VB and JScript gumby and need help)? I assume there's some convenient way to wrap the stringified xml back up into object form?
Regards,
Ashley
-
Ashley,
Here's what I use in C#. I'm sure you'll understand the idea
/// <summary>
/// search the model using an sql query
/// </summary>
/// <param name="SQLQuery">the query to be performed</param>
/// <param name="searchTerm">the searchterm to be looked for</param>
/// <returns>a list of EA wrappers matching the required criteria</returns>
private List<object> SearchSQL(string SQLQuery,string searchTerm)
{
List<object> searchResults = new List<object>();
// add the searchTerm in the query
SQLQuery = SQLQuery.Replace("<Search Term>", searchTerm);
string searchResult = wrappedModel.SQLQuery(SQLQuery);
//parse string (xml format) to find out which objects are returned
List<string> guids = XMLParser.getTagValues(searchResult, "CLASSGUID");
List<string> types = XMLParser.getTagValues(searchResult, "CLASSTYPE");
for (int i = 0; i < guids.Count; i++)
{
object objectToBeWrapped = null;
if (types[i] == "Attribute")
{
objectToBeWrapped = wrappedModel.GetAttributeByGuid(guids[i]);
}
else if (types[i] == "Connector")
{
objectToBeWrapped = wrappedModel.GetConnectorByGuid(guids[i]);
}
else if (types[i] == "Operation")
{
objectToBeWrapped = wrappedModel.GetMethodByGuid(guids[i]);
}
else if (types[i] == "Diagram")
{
objectToBeWrapped = wrappedModel.GetDiagramByGuid(guids[i]);
}
else
//must be an element then
{
objectToBeWrapped = wrappedModel.GetElementByGuid(guids[i]);
}
if (objectToBeWrapped != null)
{
searchResults.Add(EAWrapperFactory.createEAWrapper(this, objectToBeWrapped));
}
}
return searchResults;
}
Geert