Book a Demo

Author Topic: Finding Operation-associated Actions  (Read 3867 times)

blawton

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Finding Operation-associated Actions
« on: February 24, 2012, 05:44:58 am »
I want to find any actions that are associated with a selected operation. I know I can do this from properties | call :: behavior in the GUI from the action-side, but how do I do it from my C# addin and from the operation side of things? I suspect a SQL query would help (it seems to always be the answer) but I'm not certain how or where that connection would be stored -- the only reference to behavior I see in the SQL schema are t_xref's, are those what I'm looking for?

I created the action by dragging the operation into a diagram, but aside from the call in the action's properties (seen via the GUI) I don't see a way of tracking it down given only the operation's identity -- how is that information stored in EA's schema, or is there a simpler way to make that connection on the addin side than delving into SQL queries?

We're trying to associate requirements with individual operations and we figured this would be the way to go, but I can't figure out how to trace the relationship!

Thanks!
« Last Edit: February 24, 2012, 05:55:55 am by blawton »

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Finding Operation-associated Actions
« Reply #1 on: February 24, 2012, 09:01:10 am »
The operation will have a GUID in t_operation.ea_guid. A CallOperationAction will store the operation's GUID in t_object.Classifier_guid.
The Sparx Team
[email protected]

blawton

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Finding Operation-associated Actions
« Reply #2 on: February 24, 2012, 09:05:58 am »
Great, thanks!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Finding Operation-associated Actions
« Reply #3 on: February 24, 2012, 05:34:34 pm »
The EA Navigator does that for you, and since it's open source you can borrow the code for it.
You can find the operation here:
https://github.com/GeertBellekens/Enterprise-Architect-Add-in-Framework/blob/master/EAAddinFramework/EAWrappers/Operation.cs at line 265
Code: [Select]
   /// <summary>
    /// returns all CallOperationActions that call this operation
    /// </summary>
    /// <returns>all CallOperationActions that call this operation</returns>
    public HashSet<UML.Actions.BasicActions.CallOperationAction> getDependentCallOperationActions()
    {
          string sqlCallOperationActions =
                @"SELECT a.Object_ID FROM t_operation op
                  inner join t_object a on op.ea_guid = a.Classifier_guid
                  where op.OperationID = " +this.wrappedOperation.MethodID;
          return new HashSet<UML.Actions.BasicActions.CallOperationAction>(this.model.getElementWrappersByQuery(sqlCallOperationActions).Cast<UML.Actions.BasicActions.CallOperationAction>());
    }

Geert